Mercurial > hg > openttd
annotate src/main_gui.cpp @ 20454:872dc0744f21 draft
(svn r25412) -Codechange: Make use of Window::OnHotkey
author | frosch <frosch@openttd.org> |
---|---|
date | Sat, 15 Jun 2013 15:30:44 +0000 (2013-06-15) |
parents | 098020e43cf9 |
children |
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 |
12778
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
3 /* |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
4 * This file is part of OpenTTD. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
8 */ |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
9 |
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
|
10 /** @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
|
11 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
12 #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
|
13 #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
|
14 #include "spritecache.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
|
15 #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
|
16 #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
|
17 #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
|
18 #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
|
19 #include "command_func.h" |
9336
5287277c4972
(svn r13228) -Codechange: split console.h.
rubidium <rubidium@openttd.org>
parents:
9301
diff
changeset
|
20 #include "console_gui.h" |
17979
5302cd55d676
(svn r22788) -Codechange: move modal progress related functions and variables to progress.cpp/h
rubidium <rubidium@openttd.org>
parents:
17976
diff
changeset
|
21 #include "progress.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
|
22 #include "transparency_gui.h" |
17278
84f869ec145a
(svn r22018) -Cleanup: remove some (now) unneeded includes of functions.h
rubidium <rubidium@openttd.org>
parents:
17248
diff
changeset
|
23 #include "map_func.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
|
24 #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
|
25 #include "transparency.h" |
8114
2d6af5d7a142
(svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
8111
diff
changeset
|
26 #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
|
27 #include "zoom_func.h" |
10208
39cf8eebfda5
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
10207
diff
changeset
|
28 #include "company_base.h" |
39cf8eebfda5
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
10207
diff
changeset
|
29 #include "company_func.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
|
30 #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
|
31 #include "statusbar_gui.h" |
20312
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
32 #include "linkgraph/linkgraph_gui.h" |
9127
428852b86d4d
(svn r12987) -Codechange: split viewport and tile selection.
rubidium <rubidium@openttd.org>
parents:
9116
diff
changeset
|
33 #include "tilehighlight_func.h" |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
34 #include "hotkeys.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 |
16726
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
36 #include "saveload/saveload.h" |
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
37 |
18680
e87c7c30e606
(svn r23528) -Codechange: move widget enums to widgets/NNN_type.h
truebrain <truebrain@openttd.org>
parents:
18677
diff
changeset
|
38 #include "widgets/main_widget.h" |
e87c7c30e606
(svn r23528) -Codechange: move widget enums to widgets/NNN_type.h
truebrain <truebrain@openttd.org>
parents:
18677
diff
changeset
|
39 |
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
|
40 #include "network/network.h" |
9428
ba7cdcf21f4c
(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 <rubidium@openttd.org>
parents:
9413
diff
changeset
|
41 #include "network/network_func.h" |
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
|
42 #include "network/network_gui.h" |
10468
0edf9b619634
(svn r14723) -Codechange: shuffling some stuff around to reduce indirect #include dependencies.
rubidium <rubidium@openttd.org>
parents:
10462
diff
changeset
|
43 #include "network/network_base.h" |
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
|
44 |
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
|
45 #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
|
46 #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
|
47 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
48 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
|
49 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
|
50 |
14230
95250f9a5035
(svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents:
13950
diff
changeset
|
51 void CcGiveMoney(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) |
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 { |
6898
a7d1b5936638
(svn r10145) -Fix: make compiling with networking disabled (again) possible.
rubidium <rubidium@openttd.org>
parents:
6857
diff
changeset
|
53 #ifdef ENABLE_NETWORK |
14230
95250f9a5035
(svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents:
13950
diff
changeset
|
54 if (result.Failed() || !_settings_game.economy.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
|
55 |
15002
baf0e12ad2b4
(svn r19614) -Codechange: "it's" => "its" where appropriate
smatz <smatz@openttd.org>
parents:
14258
diff
changeset
|
56 /* Inform the company of the action of one of its clients (controllers). */ |
10507
5e0fb429b3ae
(svn r14764) -Codechange: make the '***' chat messages like "Game paused (not enough players)" fully translateable.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
57 char msg[64]; |
5e0fb429b3ae
(svn r14764) -Codechange: make the '***' chat messages like "Game paused (not enough players)" fully translateable.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
58 SetDParam(0, p2); |
5e0fb429b3ae
(svn r14764) -Codechange: make the '***' chat messages like "Game paused (not enough players)" fully translateable.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
59 GetString(msg, STR_COMPANY_NAME, lastof(msg)); |
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
|
60 |
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 if (!_network_server) { |
10507
5e0fb429b3ae
(svn r14764) -Codechange: make the '***' chat messages like "Game paused (not enough players)" fully translateable.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
62 NetworkClientSendChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, p2, msg, p1); |
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 } else { |
10507
5e0fb429b3ae
(svn r14764) -Codechange: make the '***' chat messages like "Game paused (not enough players)" fully translateable.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
64 NetworkServerSendChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, p2, msg, CLIENT_ID_SERVER, p1); |
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
|
65 } |
6898
a7d1b5936638
(svn r10145) -Fix: make compiling with networking disabled (again) possible.
rubidium <rubidium@openttd.org>
parents:
6857
diff
changeset
|
66 #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
|
67 } |
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
|
68 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
69 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
|
70 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
71 switch (_rename_what) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
72 #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
|
73 case 3: { // Give money, you can only give money in excess of loan |
13444
bc21e507dd03
(svn r17953) -Fix: when you start giving money (input window for amount), then get moved to spectators and you click 'Ok' a crash would occur
rubidium <rubidium@openttd.org>
parents:
13344
diff
changeset
|
74 const Company *c = Company::GetIfValid(_local_company); |
bc21e507dd03
(svn r17953) -Fix: when you start giving money (input window for amount), then get moved to spectators and you click 'Ok' a crash would occur
rubidium <rubidium@openttd.org>
parents:
13344
diff
changeset
|
75 if (c == NULL) break; |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
76 Money money = min(c->money - c->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
|
77 |
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
|
78 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
|
79 |
19968
0dba7f49118c
(svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by Eagle_rainbow)
planetmaker <planetmaker@openttd.org>
parents:
19913
diff
changeset
|
80 /* Give 'id' the money, and subtract it from ourself */ |
12632
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12581
diff
changeset
|
81 DoCommandP(0, money_c, _rename_id, CMD_GIVE_MONEY | CMD_MSG(STR_ERROR_INSUFFICIENT_FUNDS), CcGiveMoney, str); |
15618
e4640748f223
(svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents:
15552
diff
changeset
|
82 break; |
e4640748f223
(svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents:
15552
diff
changeset
|
83 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
84 #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
|
85 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
|
86 } |
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 _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
|
89 } |
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 * 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
|
93 * 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
|
94 * |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
95 * @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
|
96 * @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
|
97 * @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
|
98 * @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
|
99 * @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
|
100 */ |
16892
1e94199f85d6
(svn r21627) -Codechange: Remove _place_proc global variable.
alberth <alberth@openttd.org>
parents:
16726
diff
changeset
|
101 bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
102 { |
7997
d109780d515b
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents:
7954
diff
changeset
|
103 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
|
104 |
19913
f4e2c852270b
(svn r24846) -Add: Advanced settings to disable certain sound effects.
frosch <frosch@openttd.org>
parents:
19843
diff
changeset
|
105 if (_settings_client.sound.click_beep) 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
|
106 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
|
107 |
7997
d109780d515b
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents:
7954
diff
changeset
|
108 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
|
109 ResetObjectToPlace(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
110 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
|
111 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
112 |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5601
diff
changeset
|
113 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
|
114 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
|
115 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
|
116 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
117 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
118 |
14230
95250f9a5035
(svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents:
13950
diff
changeset
|
119 void CcPlaySound10(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
120 { |
19913
f4e2c852270b
(svn r24846) -Add: Advanced settings to disable certain sound effects.
frosch <frosch@openttd.org>
parents:
19843
diff
changeset
|
121 if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_12_EXPLOSION, tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
122 } |
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 #ifdef ENABLE_NETWORK |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
125 void ShowNetworkGiveMoneyWindow(CompanyID company) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
126 { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10145
diff
changeset
|
127 _rename_id = company; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
128 _rename_what = 3; |
17579
105b4e4eb168
(svn r22343) -Change: Remove pixel limiter for query strings.
terkhen <terkhen@openttd.org>
parents:
17486
diff
changeset
|
129 ShowQueryString(STR_EMPTY, STR_NETWORK_GIVE_MONEY_CAPTION, 30, NULL, CS_NUMERAL, QSF_NONE); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
130 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
131 #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
|
132 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
133 |
16310
cced8cded106
(svn r21018) -Doc: Add Doxygen comments to some function.
alberth <alberth@openttd.org>
parents:
16292
diff
changeset
|
134 /** |
cced8cded106
(svn r21018) -Doc: Add Doxygen comments to some function.
alberth <alberth@openttd.org>
parents:
16292
diff
changeset
|
135 * Zooms a viewport in a window in or out. |
cced8cded106
(svn r21018) -Doc: Add Doxygen comments to some function.
alberth <alberth@openttd.org>
parents:
16292
diff
changeset
|
136 * @param how Zooming direction. |
cced8cded106
(svn r21018) -Doc: Add Doxygen comments to some function.
alberth <alberth@openttd.org>
parents:
16292
diff
changeset
|
137 * @param w Window owning the viewport. |
cced8cded106
(svn r21018) -Doc: Add Doxygen comments to some function.
alberth <alberth@openttd.org>
parents:
16292
diff
changeset
|
138 * @return Returns \c true if zooming step could be done, \c false if further zooming is not possible. |
cced8cded106
(svn r21018) -Doc: Add Doxygen comments to some function.
alberth <alberth@openttd.org>
parents:
16292
diff
changeset
|
139 * @note No button handling or what so ever is done. |
cced8cded106
(svn r21018) -Doc: Add Doxygen comments to some function.
alberth <alberth@openttd.org>
parents:
16292
diff
changeset
|
140 */ |
15178
7aa184b4f6c9
(svn r19807) -Codechange: instead of having an unnamed enum and passing it as an int, name the enum and pass that
rubidium <rubidium@openttd.org>
parents:
15002
diff
changeset
|
141 bool DoZoomInOutWindow(ZoomStateChange how, Window *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
|
142 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
143 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
|
144 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
145 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
|
146 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
|
147 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
148 switch (how) { |
15184
68b7b29a6b7e
(svn r19813) -Fix (r19807): initialising viewports kinda failed
rubidium <rubidium@openttd.org>
parents:
15178
diff
changeset
|
149 case ZOOM_NONE: |
68b7b29a6b7e
(svn r19813) -Fix (r19807): initialising viewports kinda failed
rubidium <rubidium@openttd.org>
parents:
15178
diff
changeset
|
150 /* On initialisation of the viewport we don't do anything. */ |
68b7b29a6b7e
(svn r19813) -Fix (r19807): initialising viewports kinda failed
rubidium <rubidium@openttd.org>
parents:
15178
diff
changeset
|
151 break; |
68b7b29a6b7e
(svn r19813) -Fix (r19807): initialising viewports kinda failed
rubidium <rubidium@openttd.org>
parents:
15178
diff
changeset
|
152 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
153 case ZOOM_IN: |
18470
64ea4c57dcb9
(svn r23314) -Add: Add settings to restrict viewport zoom levels.
peter1138 <peter1138@openttd.org>
parents:
18111
diff
changeset
|
154 if (vp->zoom <= _settings_client.gui.zoom_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
|
155 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
|
156 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
|
157 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
|
158 |
9184
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9165
diff
changeset
|
159 w->viewport->scrollpos_x += vp->virtual_width >> 1; |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9165
diff
changeset
|
160 w->viewport->scrollpos_y += vp->virtual_height >> 1; |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9165
diff
changeset
|
161 w->viewport->dest_scrollpos_x = w->viewport->scrollpos_x; |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9165
diff
changeset
|
162 w->viewport->dest_scrollpos_y = w->viewport->scrollpos_y; |
15695
f6bb2f4578b7
(svn r20361) -Fix [FS#3989]: Stop vehicle following after zooming out.
terkhen <terkhen@openttd.org>
parents:
15618
diff
changeset
|
163 w->viewport->follow_vehicle = INVALID_VEHICLE; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
164 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
165 case ZOOM_OUT: |
18470
64ea4c57dcb9
(svn r23314) -Add: Add settings to restrict viewport zoom levels.
peter1138 <peter1138@openttd.org>
parents:
18111
diff
changeset
|
166 if (vp->zoom >= _settings_client.gui.zoom_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
|
167 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
|
168 |
9184
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9165
diff
changeset
|
169 w->viewport->scrollpos_x -= vp->virtual_width >> 1; |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9165
diff
changeset
|
170 w->viewport->scrollpos_y -= vp->virtual_height >> 1; |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9165
diff
changeset
|
171 w->viewport->dest_scrollpos_x = w->viewport->scrollpos_x; |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9165
diff
changeset
|
172 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
|
173 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
174 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
|
175 vp->virtual_height <<= 1; |
15695
f6bb2f4578b7
(svn r20361) -Fix [FS#3989]: Stop vehicle following after zooming out.
terkhen <terkhen@openttd.org>
parents:
15618
diff
changeset
|
176 w->viewport->follow_vehicle = INVALID_VEHICLE; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
177 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
178 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
179 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
|
180 vp->virtual_left = w->viewport->scrollpos_x; |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9165
diff
changeset
|
181 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
|
182 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
183 /* Update the windows that have zoom-buttons to perhaps disable their buttons */ |
13168
b3177ea0bd67
(svn r17673) -Codechange: make InvalidateThisWindowData a function of the window class
rubidium <rubidium@openttd.org>
parents:
13072
diff
changeset
|
184 w->InvalidateData(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
185 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
|
186 } |
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 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
|
189 { |
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
|
190 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
|
191 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
192 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
|
193 ViewPort *vp = w->viewport; |
18470
64ea4c57dcb9
(svn r23314) -Add: Add settings to restrict viewport zoom levels.
peter1138 <peter1138@openttd.org>
parents:
18111
diff
changeset
|
194 if ((in && vp->zoom <= _settings_client.gui.zoom_min) || (!in && vp->zoom >= _settings_client.gui.zoom_max)) return; |
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 |
10642
29bc871ff8d1
(svn r14944) -Cleanup: add spaces around some operators
rubidium <rubidium@openttd.org>
parents:
10507
diff
changeset
|
196 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
|
197 if (pt.x != -1) { |
11375
1d342902ac94
(svn r15725) -Fix: centering on a vehicle didn't respect its z coordinate
smatz <smatz@openttd.org>
parents:
11368
diff
changeset
|
198 ScrollWindowTo(pt.x, pt.y, -1, 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
|
199 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
200 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
|
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 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
203 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
204 |
12581
374037971842
(svn r17021) -Codechange: Use nested widgets for the main window.
alberth <alberth@openttd.org>
parents:
12391
diff
changeset
|
205 static const struct NWidgetPart _nested_main_window_widgets[] = { |
18688
b30160d770d8
(svn r23536) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents:
18680
diff
changeset
|
206 NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_M_VIEWPORT), SetResize(1, 1), |
12581
374037971842
(svn r17021) -Codechange: Use nested widgets for the main window.
alberth <alberth@openttd.org>
parents:
12391
diff
changeset
|
207 }; |
374037971842
(svn r17021) -Codechange: Use nested widgets for the main window.
alberth <alberth@openttd.org>
parents:
12391
diff
changeset
|
208 |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
209 enum { |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
210 GHK_QUIT, |
16726
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
211 GHK_ABANDON, |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
212 GHK_CONSOLE, |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
213 GHK_BOUNDING_BOXES, |
19191
631c14db8f5a
(svn r24065) -Feature-ish [FS#5101]: debug option for showing the redrawn dirty blocks/rectangles
rubidium <rubidium@openttd.org>
parents:
18688
diff
changeset
|
214 GHK_DIRTY_BLOCKS, |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
215 GHK_CENTER, |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
216 GHK_CENTER_ZOOM, |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
217 GHK_RESET_OBJECT_TO_PLACE, |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
218 GHK_DELETE_WINDOWS, |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
219 GHK_DELETE_NONVITAL_WINDOWS, |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
220 GHK_REFRESH_SCREEN, |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
221 GHK_CRASH, |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
222 GHK_MONEY, |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
223 GHK_UPDATE_COORDS, |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
224 GHK_TOGGLE_TRANSPARENCY, |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
225 GHK_TOGGLE_INVISIBILITY = GHK_TOGGLE_TRANSPARENCY + 9, |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
226 GHK_TRANSPARENCY_TOOLBAR = GHK_TOGGLE_INVISIBILITY + 8, |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
227 GHK_TRANSPARANCY, |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
228 GHK_CHAT, |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
229 GHK_CHAT_ALL, |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
230 GHK_CHAT_COMPANY, |
16292
96db4d85ff89
(svn r21000) -Feature[tte]: chat directly to the server or a bot/admin/irc channel monitoring the server (dihedral)
rubidium <rubidium@openttd.org>
parents:
16144
diff
changeset
|
231 GHK_CHAT_SERVER, |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
232 }; |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
233 |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
234 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
|
235 { |
20312
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
236 uint refresh; |
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
237 |
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
238 static const uint LINKGRAPH_REFRESH_PERIOD = 0xff; |
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
239 static const uint LINKGRAPH_DELAY = 0xf; |
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
240 |
20454
872dc0744f21
(svn r25412) -Codechange: Make use of Window::OnHotkey
frosch <frosch@openttd.org>
parents:
20452
diff
changeset
|
241 MainWindow(WindowDesc *desc) : Window(desc) |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
242 { |
20335
cadf6aaa0573
(svn r25287) -Codechange: Keep a reference to the WindowDesc in the Window after construction.
frosch <frosch@openttd.org>
parents:
20312
diff
changeset
|
243 this->InitNested(0); |
18677
7077d1f6763b
(svn r23525) -Codechange: make Window::flags4 WindowFlags instead of uint16, with only values known in WindowFlags (and move out 2 timers to their own variable)
truebrain <truebrain@openttd.org>
parents:
18470
diff
changeset
|
244 CLRBITS(this->flags, WF_WHITE_BORDER); |
12581
374037971842
(svn r17021) -Codechange: Use nested widgets for the main window.
alberth <alberth@openttd.org>
parents:
12391
diff
changeset
|
245 ResizeWindow(this, _screen.width, _screen.height); |
374037971842
(svn r17021) -Codechange: Use nested widgets for the main window.
alberth <alberth@openttd.org>
parents:
12391
diff
changeset
|
246 |
18688
b30160d770d8
(svn r23536) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents:
18680
diff
changeset
|
247 NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_M_VIEWPORT); |
12581
374037971842
(svn r17021) -Codechange: Use nested widgets for the main window.
alberth <alberth@openttd.org>
parents:
12391
diff
changeset
|
248 nvp->InitializeViewport(this, TileXY(32, 32), ZOOM_LVL_VIEWPORT); |
20312
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
249 |
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
250 this->viewport->overlay = new LinkGraphOverlay(this, WID_M_VIEWPORT, 0, 0, 3); |
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
251 this->refresh = LINKGRAPH_DELAY; |
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
252 } |
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
253 |
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
254 virtual void OnTick() |
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
255 { |
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
256 if (--refresh == 0) { |
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
257 this->viewport->overlay->RebuildCache(); |
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
258 this->GetWidget<NWidgetBase>(WID_M_VIEWPORT)->SetDirty(this); |
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
259 this->refresh = LINKGRAPH_REFRESH_PERIOD; |
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
260 } |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
261 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
262 |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
263 virtual void OnPaint() |
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
264 { |
12581
374037971842
(svn r17021) -Codechange: Use nested widgets for the main window.
alberth <alberth@openttd.org>
parents:
12391
diff
changeset
|
265 this->DrawWidgets(); |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
266 if (_game_mode == GM_MENU) { |
15434
995eaf7f493c
(svn r20077) -Codechange: remove the space between "open" and "ttd" in the title screen
yexo <yexo@openttd.org>
parents:
15431
diff
changeset
|
267 static const SpriteID title_sprites[] = {SPR_OTTD_O, SPR_OTTD_P, SPR_OTTD_E, SPR_OTTD_N, SPR_OTTD_T, SPR_OTTD_T, SPR_OTTD_D}; |
995eaf7f493c
(svn r20077) -Codechange: remove the space between "open" and "ttd" in the title screen
yexo <yexo@openttd.org>
parents:
15431
diff
changeset
|
268 static const uint LETTER_SPACING = 10; |
15930
ffc487f3e052
(svn r20618) -Fix [FS#4081]: drawing the "OpenTTD" text in the intro game caused crashes with very low resolutions
rubidium <rubidium@openttd.org>
parents:
15695
diff
changeset
|
269 int name_width = (lengthof(title_sprites) - 1) * LETTER_SPACING; |
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 |
15434
995eaf7f493c
(svn r20077) -Codechange: remove the space between "open" and "ttd" in the title screen
yexo <yexo@openttd.org>
parents:
15431
diff
changeset
|
271 for (uint i = 0; i < lengthof(title_sprites); i++) { |
995eaf7f493c
(svn r20077) -Codechange: remove the space between "open" and "ttd" in the title screen
yexo <yexo@openttd.org>
parents:
15431
diff
changeset
|
272 name_width += GetSpriteSize(title_sprites[i]).width; |
995eaf7f493c
(svn r20077) -Codechange: remove the space between "open" and "ttd" in the title screen
yexo <yexo@openttd.org>
parents:
15431
diff
changeset
|
273 } |
995eaf7f493c
(svn r20077) -Codechange: remove the space between "open" and "ttd" in the title screen
yexo <yexo@openttd.org>
parents:
15431
diff
changeset
|
274 int off_x = (this->width - name_width) / 2; |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
275 |
15434
995eaf7f493c
(svn r20077) -Codechange: remove the space between "open" and "ttd" in the title screen
yexo <yexo@openttd.org>
parents:
15431
diff
changeset
|
276 for (uint i = 0; i < lengthof(title_sprites); i++) { |
995eaf7f493c
(svn r20077) -Codechange: remove the space between "open" and "ttd" in the title screen
yexo <yexo@openttd.org>
parents:
15431
diff
changeset
|
277 DrawSprite(title_sprites[i], PAL_NONE, off_x, 50); |
995eaf7f493c
(svn r20077) -Codechange: remove the space between "open" and "ttd" in the title screen
yexo <yexo@openttd.org>
parents:
15431
diff
changeset
|
278 off_x += GetSpriteSize(title_sprites[i]).width + LETTER_SPACING; |
995eaf7f493c
(svn r20077) -Codechange: remove the space between "open" and "ttd" in the title screen
yexo <yexo@openttd.org>
parents:
15431
diff
changeset
|
279 } |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
280 } |
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
281 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
282 |
20454
872dc0744f21
(svn r25412) -Codechange: Make use of Window::OnHotkey
frosch <frosch@openttd.org>
parents:
20452
diff
changeset
|
283 virtual EventState OnHotkey(int hotkey) |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
284 { |
20454
872dc0744f21
(svn r25412) -Codechange: Make use of Window::OnHotkey
frosch <frosch@openttd.org>
parents:
20452
diff
changeset
|
285 if (hotkey == GHK_QUIT) { |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
286 HandleExitGameRequest(); |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
287 return ES_HANDLED; |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
288 } |
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
289 |
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
290 /* Disable all key shortcuts, except quit shortcuts when |
11361
02313cc6114e
(svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents:
11085
diff
changeset
|
291 * generating the world, otherwise they create threading |
02313cc6114e
(svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents:
11085
diff
changeset
|
292 * problem during the generating, resulting in random |
02313cc6114e
(svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents:
11085
diff
changeset
|
293 * assertions that are hard to trigger and debug */ |
17976
776acb0fd15e
(svn r22785) -Codechange: rename IsGeneratingWorld to HasModalProgress
rubidium <rubidium@openttd.org>
parents:
17879
diff
changeset
|
294 if (HasModalProgress()) 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
|
295 |
20454
872dc0744f21
(svn r25412) -Codechange: Make use of Window::OnHotkey
frosch <frosch@openttd.org>
parents:
20452
diff
changeset
|
296 switch (hotkey) { |
16726
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
297 case GHK_ABANDON: |
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
298 /* No point returning from the main menu to itself */ |
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
299 if (_game_mode == GM_MENU) return ES_HANDLED; |
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
300 if (_settings_client.gui.autosave_on_exit) { |
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
301 DoExitSave(); |
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
302 _switch_mode = SM_MENU; |
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
303 } else { |
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
304 AskExitToGameMenu(); |
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
305 } |
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
306 return ES_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
|
307 |
16726
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
308 case GHK_CONSOLE: |
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
309 IConsoleSwitch(); |
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
310 return ES_HANDLED; |
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
311 |
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
312 case GHK_BOUNDING_BOXES: |
17879
9310e39c80ce
(svn r22675) -Change: Add a menu entry for the sprite bounding box debuging feature in the help menu and enable bounding boxes only in conjunction with the newgrf developer tools
planetmaker <planetmaker@openttd.org>
parents:
17634
diff
changeset
|
313 ToggleBoundingBoxes(); |
16726
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
314 return ES_HANDLED; |
19191
631c14db8f5a
(svn r24065) -Feature-ish [FS#5101]: debug option for showing the redrawn dirty blocks/rectangles
rubidium <rubidium@openttd.org>
parents:
18688
diff
changeset
|
315 |
631c14db8f5a
(svn r24065) -Feature-ish [FS#5101]: debug option for showing the redrawn dirty blocks/rectangles
rubidium <rubidium@openttd.org>
parents:
18688
diff
changeset
|
316 case GHK_DIRTY_BLOCKS: |
631c14db8f5a
(svn r24065) -Feature-ish [FS#5101]: debug option for showing the redrawn dirty blocks/rectangles
rubidium <rubidium@openttd.org>
parents:
18688
diff
changeset
|
317 ToggleDirtyBlocks(); |
631c14db8f5a
(svn r24065) -Feature-ish [FS#5101]: debug option for showing the redrawn dirty blocks/rectangles
rubidium <rubidium@openttd.org>
parents:
18688
diff
changeset
|
318 return ES_HANDLED; |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
319 } |
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
320 |
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
|
321 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
|
322 |
20454
872dc0744f21
(svn r25412) -Codechange: Make use of Window::OnHotkey
frosch <frosch@openttd.org>
parents:
20452
diff
changeset
|
323 switch (hotkey) { |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
324 case GHK_CENTER: |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
325 case GHK_CENTER_ZOOM: { |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
326 Point pt = GetTileBelowCursor(); |
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
327 if (pt.x != -1) { |
20454
872dc0744f21
(svn r25412) -Codechange: Make use of Window::OnHotkey
frosch <frosch@openttd.org>
parents:
20452
diff
changeset
|
328 bool instant = (hotkey == GHK_CENTER_ZOOM && this->viewport->zoom != _settings_client.gui.zoom_min); |
872dc0744f21
(svn r25412) -Codechange: Make use of Window::OnHotkey
frosch <frosch@openttd.org>
parents:
20452
diff
changeset
|
329 if (hotkey == GHK_CENTER_ZOOM) MaxZoomInOut(ZOOM_IN, this); |
17248
114fbdb11b40
(svn r21988) -Change: Disable smooth scrolling for GHK_CENTER_ZOOM when zooming is also involved.
frosch <frosch@openttd.org>
parents:
17237
diff
changeset
|
330 ScrollMainWindowTo(pt.x, pt.y, -1, instant); |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
331 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
332 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
333 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
334 |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
335 case GHK_RESET_OBJECT_TO_PLACE: ResetObjectToPlace(); break; |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
336 case GHK_DELETE_WINDOWS: DeleteNonVitalWindows(); break; |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
337 case GHK_DELETE_NONVITAL_WINDOWS: DeleteAllNonVitalWindows(); break; |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
338 case GHK_REFRESH_SCREEN: 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
|
339 |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
340 case GHK_CRASH: // Crash the game |
16144
27bb22e4894c
(svn r20840) -Fix: make write to NULL pointer volatile so it's not optimised away
smatz <smatz@openttd.org>
parents:
15930
diff
changeset
|
341 *(volatile byte *)0 = 0; |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
342 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
|
343 |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
344 case GHK_MONEY: // Gimme money |
17288
32dbb86666ff
(svn r22028) -Cleanup: remove traces of a debugging "feature" that got disabled a long time ago
rubidium <rubidium@openttd.org>
parents:
17278
diff
changeset
|
345 /* You can only cheat for money in single player. */ |
32dbb86666ff
(svn r22028) -Cleanup: remove traces of a debugging "feature" that got disabled a long time ago
rubidium <rubidium@openttd.org>
parents:
17278
diff
changeset
|
346 if (!_networking) DoCommandP(0, 10000000, 0, CMD_MONEY_CHEAT); |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
347 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
|
348 |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
349 case GHK_UPDATE_COORDS: // Update the coordinates of all station signs |
13950
77bfe67f23bd
(svn r18486) -Fix: when switching language and you're getting a different font, recalculate the coordinates/sizes of the viewport signs. Otherwise it gets glitchy or abbreviated (in the smallmap)
rubidium <rubidium@openttd.org>
parents:
13796
diff
changeset
|
350 UpdateAllVirtCoords(); |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
351 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
|
352 |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
353 case GHK_TOGGLE_TRANSPARENCY: |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
354 case GHK_TOGGLE_TRANSPARENCY + 1: |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
355 case GHK_TOGGLE_TRANSPARENCY + 2: |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
356 case GHK_TOGGLE_TRANSPARENCY + 3: |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
357 case GHK_TOGGLE_TRANSPARENCY + 4: |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
358 case GHK_TOGGLE_TRANSPARENCY + 5: |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
359 case GHK_TOGGLE_TRANSPARENCY + 6: |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
360 case GHK_TOGGLE_TRANSPARENCY + 7: |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
361 case GHK_TOGGLE_TRANSPARENCY + 8: |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
362 /* Transparency toggle hot keys */ |
20454
872dc0744f21
(svn r25412) -Codechange: Make use of Window::OnHotkey
frosch <frosch@openttd.org>
parents:
20452
diff
changeset
|
363 ToggleTransparency((TransparencyOption)(hotkey - GHK_TOGGLE_TRANSPARENCY)); |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
364 MarkWholeScreenDirty(); |
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
365 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
|
366 |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
367 case GHK_TOGGLE_INVISIBILITY: |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
368 case GHK_TOGGLE_INVISIBILITY + 1: |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
369 case GHK_TOGGLE_INVISIBILITY + 2: |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
370 case GHK_TOGGLE_INVISIBILITY + 3: |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
371 case GHK_TOGGLE_INVISIBILITY + 4: |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
372 case GHK_TOGGLE_INVISIBILITY + 5: |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
373 case GHK_TOGGLE_INVISIBILITY + 6: |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
374 case GHK_TOGGLE_INVISIBILITY + 7: |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
375 /* Invisibility toggle hot keys */ |
20454
872dc0744f21
(svn r25412) -Codechange: Make use of Window::OnHotkey
frosch <frosch@openttd.org>
parents:
20452
diff
changeset
|
376 ToggleInvisibilityWithTransparency((TransparencyOption)(hotkey - GHK_TOGGLE_INVISIBILITY)); |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
377 MarkWholeScreenDirty(); |
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
378 break; |
8806
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8790
diff
changeset
|
379 |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
380 case GHK_TRANSPARENCY_TOOLBAR: |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
381 ShowTransparencyToolbar(); |
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
382 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
|
383 |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
384 case GHK_TRANSPARANCY: |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
385 ResetRestoreAllTransparency(); |
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
386 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
|
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 #ifdef ENABLE_NETWORK |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
389 case GHK_CHAT: // smart chat; send to team if any, otherwise to all |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
390 if (_networking) { |
17598
0a51450014d0
(svn r22362) -Codechange: NetworkFindClientInfoFromClientID -> NetworkClientInfo::GetByClientID
rubidium <rubidium@openttd.org>
parents:
17579
diff
changeset
|
391 const NetworkClientInfo *cio = NetworkClientInfo::GetByClientID(_network_own_client_id); |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
392 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
|
393 |
10460
8ce8857713b8
(svn r14715) -Codechange: move some network code from the main gui file into one of the the network files.
rubidium <rubidium@openttd.org>
parents:
10454
diff
changeset
|
394 ShowNetworkChatQueryWindow(NetworkClientPreferTeamChat(cio) ? DESTTYPE_TEAM : DESTTYPE_BROADCAST, cio->client_playas); |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
395 } |
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
396 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
|
397 |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
398 case GHK_CHAT_ALL: // send text message to all clients |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
399 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
|
400 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
|
401 |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
402 case GHK_CHAT_COMPANY: // send text to all team mates |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
403 if (_networking) { |
17598
0a51450014d0
(svn r22362) -Codechange: NetworkFindClientInfoFromClientID -> NetworkClientInfo::GetByClientID
rubidium <rubidium@openttd.org>
parents:
17579
diff
changeset
|
404 const NetworkClientInfo *cio = NetworkClientInfo::GetByClientID(_network_own_client_id); |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
405 if (cio == NULL) break; |
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
406 |
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
407 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
|
408 } |
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
409 break; |
16292
96db4d85ff89
(svn r21000) -Feature[tte]: chat directly to the server or a bot/admin/irc channel monitoring the server (dihedral)
rubidium <rubidium@openttd.org>
parents:
16144
diff
changeset
|
410 |
96db4d85ff89
(svn r21000) -Feature[tte]: chat directly to the server or a bot/admin/irc channel monitoring the server (dihedral)
rubidium <rubidium@openttd.org>
parents:
16144
diff
changeset
|
411 case GHK_CHAT_SERVER: // send text to the server |
96db4d85ff89
(svn r21000) -Feature[tte]: chat directly to the server or a bot/admin/irc channel monitoring the server (dihedral)
rubidium <rubidium@openttd.org>
parents:
16144
diff
changeset
|
412 if (_networking && !_network_server) { |
96db4d85ff89
(svn r21000) -Feature[tte]: chat directly to the server or a bot/admin/irc channel monitoring the server (dihedral)
rubidium <rubidium@openttd.org>
parents:
16144
diff
changeset
|
413 ShowNetworkChatQueryWindow(DESTTYPE_CLIENT, CLIENT_ID_SERVER); |
96db4d85ff89
(svn r21000) -Feature[tte]: chat directly to the server or a bot/admin/irc channel monitoring the server (dihedral)
rubidium <rubidium@openttd.org>
parents:
16144
diff
changeset
|
414 } |
96db4d85ff89
(svn r21000) -Feature[tte]: chat directly to the server or a bot/admin/irc channel monitoring the server (dihedral)
rubidium <rubidium@openttd.org>
parents:
16144
diff
changeset
|
415 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
|
416 #endif |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
417 |
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
|
418 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
|
419 } |
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
|
420 return ES_HANDLED; |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
421 } |
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 |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
423 virtual void OnScroll(Point delta) |
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
424 { |
17151
f89e4ac875e8
(svn r21889) -Fix [FS#4434]: crash when scrolling outside of the main window (with some video backends)
rubidium <rubidium@openttd.org>
parents:
17066
diff
changeset
|
425 this->viewport->scrollpos_x += ScaleByZoom(delta.x, this->viewport->zoom); |
f89e4ac875e8
(svn r21889) -Fix [FS#4434]: crash when scrolling outside of the main window (with some video backends)
rubidium <rubidium@openttd.org>
parents:
17066
diff
changeset
|
426 this->viewport->scrollpos_y += ScaleByZoom(delta.y, this->viewport->zoom); |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
427 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
|
428 this->viewport->dest_scrollpos_y = this->viewport->scrollpos_y; |
20312
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
429 this->refresh = LINKGRAPH_DELAY; |
17066
21cc53f6368d
(svn r21803) -Cleanup: Remove unnecessary semicolons.
terkhen <terkhen@openttd.org>
parents:
16892
diff
changeset
|
430 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
431 |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
432 virtual void OnMouseWheel(int wheel) |
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
433 { |
17237
d8b501ee60b3
(svn r21977) -Codechange: Always cal Window::OnMouseWheel(), independent of viewport scroll/zoom settings.
frosch <frosch@openttd.org>
parents:
17151
diff
changeset
|
434 if (_settings_client.gui.scrollwheel_scrolling == 0) { |
d8b501ee60b3
(svn r21977) -Codechange: Always cal Window::OnMouseWheel(), independent of viewport scroll/zoom settings.
frosch <frosch@openttd.org>
parents:
17151
diff
changeset
|
435 ZoomInOrOutToCursorWindow(wheel < 0, this); |
d8b501ee60b3
(svn r21977) -Codechange: Always cal Window::OnMouseWheel(), independent of viewport scroll/zoom settings.
frosch <frosch@openttd.org>
parents:
17151
diff
changeset
|
436 } |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
437 } |
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 |
13344
04b02b2cfa2b
(svn r17853) -Codechange: remove the 'delta' parameter from OnResize; it was used in ways that aren't always wanted, causing bugs and the like. Also with nested widgets most reasons for handling OnResize have gone.
rubidium <rubidium@openttd.org>
parents:
13186
diff
changeset
|
439 virtual void OnResize() |
12581
374037971842
(svn r17021) -Codechange: Use nested widgets for the main window.
alberth <alberth@openttd.org>
parents:
12391
diff
changeset
|
440 { |
374037971842
(svn r17021) -Codechange: Use nested widgets for the main window.
alberth <alberth@openttd.org>
parents:
12391
diff
changeset
|
441 if (this->viewport != NULL) { |
18688
b30160d770d8
(svn r23536) -Codechange: document and rename widgets to be consistent and understandable
truebrain <truebrain@openttd.org>
parents:
18680
diff
changeset
|
442 NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_M_VIEWPORT); |
12581
374037971842
(svn r17021) -Codechange: Use nested widgets for the main window.
alberth <alberth@openttd.org>
parents:
12391
diff
changeset
|
443 nvp->UpdateViewportCoordinates(this); |
20312
f7c13c96f7e2
(svn r25264) -Feature: linkgraph overlay over main viewport (fonsinchen)
rubidium <rubidium@openttd.org>
parents:
19968
diff
changeset
|
444 this->refresh = LINKGRAPH_DELAY; |
12581
374037971842
(svn r17021) -Codechange: Use nested widgets for the main window.
alberth <alberth@openttd.org>
parents:
12391
diff
changeset
|
445 } |
374037971842
(svn r17021) -Codechange: Use nested widgets for the main window.
alberth <alberth@openttd.org>
parents:
12391
diff
changeset
|
446 } |
374037971842
(svn r17021) -Codechange: Use nested widgets for the main window.
alberth <alberth@openttd.org>
parents:
12391
diff
changeset
|
447 |
17486
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17389
diff
changeset
|
448 /** |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17389
diff
changeset
|
449 * Some data on this window has become invalid. |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17389
diff
changeset
|
450 * @param data Information about the changed data. |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17389
diff
changeset
|
451 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details. |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17389
diff
changeset
|
452 */ |
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17389
diff
changeset
|
453 virtual void OnInvalidateData(int data = 0, bool gui_scope = true) |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
454 { |
17486
e7672bafbe1c
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
frosch <frosch@openttd.org>
parents:
17389
diff
changeset
|
455 if (!gui_scope) return; |
19843
9a8968c733ba
(svn r24776) -Doc: Typo fixes, additions, and additional dots collected from various sources (including Eagle_rainbow, MinchinWeb)
alberth <alberth@openttd.org>
parents:
19191
diff
changeset
|
456 /* Forward the message to the appropriate toolbar (ingame or scenario editor) */ |
17389
750d56071240
(svn r22135) -Fix [FS#4523]: When commands need to invalidate windows, process these events asynchronously before the next redraw. Calling window code directly from command scope uses wrong _current_company and might issue nested DoCommands() which interfer with the running command.
frosch <frosch@openttd.org>
parents:
17288
diff
changeset
|
457 InvalidateWindowData(WC_MAIN_TOOLBAR, 0, data, 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
|
458 } |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
459 |
20452
098020e43cf9
(svn r25410) -Codechange: Put all hotkeys of a window into a static HotkeyList member.
frosch <frosch@openttd.org>
parents:
20450
diff
changeset
|
460 static HotkeyList hotkeys; |
9205
a8b1f6fa5f79
(svn r13071) -Codechange: make also a class of the MainWindow.
rubidium <rubidium@openttd.org>
parents:
9184
diff
changeset
|
461 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
462 |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
463 const uint16 _ghk_quit_keys[] = {'Q' | WKC_CTRL, 'Q' | WKC_META, 0}; |
16726
e73c78393547
(svn r21459) -Feature(tte) [FS#3217]: Hotkey Ctrl+W for returning to the main menu
planetmaker <planetmaker@openttd.org>
parents:
16310
diff
changeset
|
464 const uint16 _ghk_abandon_keys[] = {'W' | WKC_CTRL, 'W' | WKC_META, 0}; |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
465 const uint16 _ghk_chat_keys[] = {WKC_RETURN, 'T', 0}; |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
466 const uint16 _ghk_chat_all_keys[] = {WKC_SHIFT | WKC_RETURN, WKC_SHIFT | 'T', 0}; |
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
467 const uint16 _ghk_chat_company_keys[] = {WKC_CTRL | WKC_RETURN, WKC_CTRL | 'T', 0}; |
16292
96db4d85ff89
(svn r21000) -Feature[tte]: chat directly to the server or a bot/admin/irc channel monitoring the server (dihedral)
rubidium <rubidium@openttd.org>
parents:
16144
diff
changeset
|
468 const uint16 _ghk_chat_server_keys[] = {WKC_CTRL | WKC_SHIFT | WKC_RETURN, WKC_CTRL | WKC_SHIFT | 'T', 0}; |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
469 |
20452
098020e43cf9
(svn r25410) -Codechange: Put all hotkeys of a window into a static HotkeyList member.
frosch <frosch@openttd.org>
parents:
20450
diff
changeset
|
470 static Hotkey global_hotkeys[] = { |
20450
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
471 Hotkey(_ghk_quit_keys, "quit", GHK_QUIT), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
472 Hotkey(_ghk_abandon_keys, "abandon", GHK_ABANDON), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
473 Hotkey(WKC_BACKQUOTE, "console", GHK_CONSOLE), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
474 Hotkey('B' | WKC_CTRL, "bounding_boxes", GHK_BOUNDING_BOXES), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
475 Hotkey('I' | WKC_CTRL, "dirty_blocks", GHK_DIRTY_BLOCKS), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
476 Hotkey('C', "center", GHK_CENTER), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
477 Hotkey('Z', "center_zoom", GHK_CENTER_ZOOM), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
478 Hotkey(WKC_ESC, "reset_object_to_place", GHK_RESET_OBJECT_TO_PLACE), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
479 Hotkey(WKC_DELETE, "delete_windows", GHK_DELETE_WINDOWS), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
480 Hotkey(WKC_DELETE | WKC_SHIFT, "delete_all_windows", GHK_DELETE_NONVITAL_WINDOWS), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
481 Hotkey('R' | WKC_CTRL, "refresh_screen", GHK_REFRESH_SCREEN), |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
482 #if defined(_DEBUG) |
20450
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
483 Hotkey('0' | WKC_ALT, "crash_game", GHK_CRASH), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
484 Hotkey('1' | WKC_ALT, "money", GHK_MONEY), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
485 Hotkey('2' | WKC_ALT, "update_coordinates", GHK_UPDATE_COORDS), |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
486 #endif |
20450
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
487 Hotkey('1' | WKC_CTRL, "transparency_signs", GHK_TOGGLE_TRANSPARENCY), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
488 Hotkey('2' | WKC_CTRL, "transparency_trees", GHK_TOGGLE_TRANSPARENCY + 1), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
489 Hotkey('3' | WKC_CTRL, "transparency_houses", GHK_TOGGLE_TRANSPARENCY + 2), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
490 Hotkey('4' | WKC_CTRL, "transparency_industries", GHK_TOGGLE_TRANSPARENCY + 3), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
491 Hotkey('5' | WKC_CTRL, "transparency_buildings", GHK_TOGGLE_TRANSPARENCY + 4), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
492 Hotkey('6' | WKC_CTRL, "transparency_bridges", GHK_TOGGLE_TRANSPARENCY + 5), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
493 Hotkey('7' | WKC_CTRL, "transparency_structures", GHK_TOGGLE_TRANSPARENCY + 6), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
494 Hotkey('8' | WKC_CTRL, "transparency_catenary", GHK_TOGGLE_TRANSPARENCY + 7), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
495 Hotkey('9' | WKC_CTRL, "transparency_loading", GHK_TOGGLE_TRANSPARENCY + 8), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
496 Hotkey('1' | WKC_CTRL | WKC_SHIFT, "invisibility_signs", GHK_TOGGLE_INVISIBILITY), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
497 Hotkey('2' | WKC_CTRL | WKC_SHIFT, "invisibility_trees", GHK_TOGGLE_INVISIBILITY + 1), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
498 Hotkey('3' | WKC_CTRL | WKC_SHIFT, "invisibility_houses", GHK_TOGGLE_INVISIBILITY + 2), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
499 Hotkey('4' | WKC_CTRL | WKC_SHIFT, "invisibility_industries", GHK_TOGGLE_INVISIBILITY + 3), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
500 Hotkey('5' | WKC_CTRL | WKC_SHIFT, "invisibility_buildings", GHK_TOGGLE_INVISIBILITY + 4), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
501 Hotkey('6' | WKC_CTRL | WKC_SHIFT, "invisibility_bridges", GHK_TOGGLE_INVISIBILITY + 5), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
502 Hotkey('7' | WKC_CTRL | WKC_SHIFT, "invisibility_structures", GHK_TOGGLE_INVISIBILITY + 6), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
503 Hotkey('8' | WKC_CTRL | WKC_SHIFT, "invisibility_catenary", GHK_TOGGLE_INVISIBILITY + 7), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
504 Hotkey('X' | WKC_CTRL, "transparency_toolbar", GHK_TRANSPARENCY_TOOLBAR), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
505 Hotkey('X', "toggle_transparency", GHK_TRANSPARANCY), |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
506 #ifdef ENABLE_NETWORK |
20450
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
507 Hotkey(_ghk_chat_keys, "chat", GHK_CHAT), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
508 Hotkey(_ghk_chat_all_keys, "chat_all", GHK_CHAT_ALL), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
509 Hotkey(_ghk_chat_company_keys, "chat_company", GHK_CHAT_COMPANY), |
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
510 Hotkey(_ghk_chat_server_keys, "chat_server", GHK_CHAT_SERVER), |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
511 #endif |
20450
006a29f83f18
(svn r25408) -Codechange: Simplify hotkeys by removing unused stuff.
frosch <frosch@openttd.org>
parents:
20338
diff
changeset
|
512 HOTKEY_LIST_END |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
513 }; |
20452
098020e43cf9
(svn r25410) -Codechange: Put all hotkeys of a window into a static HotkeyList member.
frosch <frosch@openttd.org>
parents:
20450
diff
changeset
|
514 HotkeyList MainWindow::hotkeys("global", global_hotkeys); |
15416
895563a537b9
(svn r20059) -Feature: customizable hotkeys for the main window (the global hotkeys)
yexo <yexo@openttd.org>
parents:
15184
diff
changeset
|
515 |
20454
872dc0744f21
(svn r25412) -Codechange: Make use of Window::OnHotkey
frosch <frosch@openttd.org>
parents:
20452
diff
changeset
|
516 static WindowDesc _main_window_desc( |
872dc0744f21
(svn r25412) -Codechange: Make use of Window::OnHotkey
frosch <frosch@openttd.org>
parents:
20452
diff
changeset
|
517 WDP_MANUAL, NULL, 0, 0, |
872dc0744f21
(svn r25412) -Codechange: Make use of Window::OnHotkey
frosch <frosch@openttd.org>
parents:
20452
diff
changeset
|
518 WC_MAIN_WINDOW, WC_NONE, |
872dc0744f21
(svn r25412) -Codechange: Make use of Window::OnHotkey
frosch <frosch@openttd.org>
parents:
20452
diff
changeset
|
519 0, |
872dc0744f21
(svn r25412) -Codechange: Make use of Window::OnHotkey
frosch <frosch@openttd.org>
parents:
20452
diff
changeset
|
520 _nested_main_window_widgets, lengthof(_nested_main_window_widgets), |
872dc0744f21
(svn r25412) -Codechange: Make use of Window::OnHotkey
frosch <frosch@openttd.org>
parents:
20452
diff
changeset
|
521 &MainWindow::hotkeys |
872dc0744f21
(svn r25412) -Codechange: Make use of Window::OnHotkey
frosch <frosch@openttd.org>
parents:
20452
diff
changeset
|
522 ); |
872dc0744f21
(svn r25412) -Codechange: Make use of Window::OnHotkey
frosch <frosch@openttd.org>
parents:
20452
diff
changeset
|
523 |
15431
d730740247bc
(svn r20074) -Fix (r20065): highscore window should use the same hotkey for quit as the toolbar
yexo <yexo@openttd.org>
parents:
15416
diff
changeset
|
524 /** |
d730740247bc
(svn r20074) -Fix (r20065): highscore window should use the same hotkey for quit as the toolbar
yexo <yexo@openttd.org>
parents:
15416
diff
changeset
|
525 * Does the given keycode match one of the keycodes bound to 'quit game'? |
d730740247bc
(svn r20074) -Fix (r20065): highscore window should use the same hotkey for quit as the toolbar
yexo <yexo@openttd.org>
parents:
15416
diff
changeset
|
526 * @param keycode The keycode that was pressed by the user. |
d730740247bc
(svn r20074) -Fix (r20065): highscore window should use the same hotkey for quit as the toolbar
yexo <yexo@openttd.org>
parents:
15416
diff
changeset
|
527 * @return True iff the keycode matches one of the hotkeys for 'quit'. |
d730740247bc
(svn r20074) -Fix (r20065): highscore window should use the same hotkey for quit as the toolbar
yexo <yexo@openttd.org>
parents:
15416
diff
changeset
|
528 */ |
d730740247bc
(svn r20074) -Fix (r20065): highscore window should use the same hotkey for quit as the toolbar
yexo <yexo@openttd.org>
parents:
15416
diff
changeset
|
529 bool IsQuitKey(uint16 keycode) |
d730740247bc
(svn r20074) -Fix (r20065): highscore window should use the same hotkey for quit as the toolbar
yexo <yexo@openttd.org>
parents:
15416
diff
changeset
|
530 { |
20452
098020e43cf9
(svn r25410) -Codechange: Put all hotkeys of a window into a static HotkeyList member.
frosch <frosch@openttd.org>
parents:
20450
diff
changeset
|
531 int num = MainWindow::hotkeys.CheckMatch(keycode); |
15431
d730740247bc
(svn r20074) -Fix (r20065): highscore window should use the same hotkey for quit as the toolbar
yexo <yexo@openttd.org>
parents:
15416
diff
changeset
|
532 return num == GHK_QUIT; |
d730740247bc
(svn r20074) -Fix (r20065): highscore window should use the same hotkey for quit as the toolbar
yexo <yexo@openttd.org>
parents:
15416
diff
changeset
|
533 } |
d730740247bc
(svn r20074) -Fix (r20065): highscore window should use the same hotkey for quit as the toolbar
yexo <yexo@openttd.org>
parents:
15416
diff
changeset
|
534 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
535 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
536 void ShowSelectGameWindow(); |
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
537 |
17634
5117fc12b816
(svn r22405) -Document: some more "random-ish" tidbits
rubidium <rubidium@openttd.org>
parents:
17598
diff
changeset
|
538 /** |
5117fc12b816
(svn r22405) -Document: some more "random-ish" tidbits
rubidium <rubidium@openttd.org>
parents:
17598
diff
changeset
|
539 * Initialise the default colours (remaps and the likes), and load the main windows. |
5117fc12b816
(svn r22405) -Document: some more "random-ish" tidbits
rubidium <rubidium@openttd.org>
parents:
17598
diff
changeset
|
540 */ |
11085
8da1855e9f14
(svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents:
10996
diff
changeset
|
541 void SetupColoursAndInitialWindow() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
542 { |
8977
9cfe40b47731
(svn r12769) -Codechange: some coding style cleanups.
rubidium <rubidium@openttd.org>
parents:
8976
diff
changeset
|
543 for (uint i = 0; i != 16; i++) { |
11085
8da1855e9f14
(svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents:
10996
diff
changeset
|
544 const byte *b = GetNonSprite(PALETTE_RECOLOUR_START + i, ST_RECOLOUR); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
545 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
546 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
|
547 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
|
548 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
549 |
20454
872dc0744f21
(svn r25412) -Codechange: Make use of Window::OnHotkey
frosch <frosch@openttd.org>
parents:
20452
diff
changeset
|
550 new MainWindow(&_main_window_desc); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
551 |
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
|
552 /* 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
|
553 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
|
554 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
|
555 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
|
556 ShowSelectGameWindow(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
557 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
558 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
559 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
|
560 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
|
561 ShowVitalWindows(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
562 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
563 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
564 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
565 |
17634
5117fc12b816
(svn r22405) -Document: some more "random-ish" tidbits
rubidium <rubidium@openttd.org>
parents:
17598
diff
changeset
|
566 /** |
5117fc12b816
(svn r22405) -Document: some more "random-ish" tidbits
rubidium <rubidium@openttd.org>
parents:
17598
diff
changeset
|
567 * Show the vital in-game windows. |
5117fc12b816
(svn r22405) -Document: some more "random-ish" tidbits
rubidium <rubidium@openttd.org>
parents:
17598
diff
changeset
|
568 */ |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
569 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
|
570 { |
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
|
571 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
|
572 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
573 /* 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
|
574 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
|
575 |
8976
cbf8b2b89c08
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium <rubidium@openttd.org>
parents:
8975
diff
changeset
|
576 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
|
577 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
578 |
8857
a75a0c683fea
(svn r12619) -Codechange: lots of documentation about window related stuff. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8806
diff
changeset
|
579 /** |
a75a0c683fea
(svn r12619) -Codechange: lots of documentation about window related stuff. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8806
diff
changeset
|
580 * 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
|
581 * 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
|
582 */ |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
583 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
|
584 { |
9533
176a9fe1018f
(svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents:
9481
diff
changeset
|
585 _cur_resolution.width = _screen.width; |
176a9fe1018f
(svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents:
9481
diff
changeset
|
586 _cur_resolution.height = _screen.height; |
8985
480d464f5e24
(svn r12779) -Codechange: remove a few constants from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
587 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
|
588 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
|
589 MarkWholeScreenDirty(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
590 } |