author | rubidium |
Sun, 23 Mar 2008 07:35:29 +0000 | |
changeset 8723 | e513a23c2797 |
parent 8615 | d9525e4e85f5 |
child 8726 | 0d8a2fdb5bbb |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
3 |
/** @file main_gui.cpp */ |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1885
diff
changeset
|
6 |
#include "openttd.h" |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
7 |
#include "heightmap.h" |
2292 | 8 |
#include "currency.h" |
1349
15979a2e9001
(svn r1853) Move spritecache function declarations into a header of their own and use SpriteID as parameter type where appropriate
tron
parents:
1336
diff
changeset
|
9 |
#include "spritecache.h" |
0 | 10 |
#include "gui.h" |
8107
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
11 |
#include "window_gui.h" |
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
12 |
#include "window_func.h" |
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
13 |
#include "textbuf_gui.h" |
8224
c5a64d87cc54
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8214
diff
changeset
|
14 |
#include "viewport_func.h" |
8116
8da76dcb3287
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8114
diff
changeset
|
15 |
#include "command_func.h" |
0 | 16 |
#include "news.h" |
17 |
#include "town.h" |
|
126 | 18 |
#include "console.h" |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
983
diff
changeset
|
19 |
#include "signs.h" |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1500
diff
changeset
|
20 |
#include "waypoint.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2150
diff
changeset
|
21 |
#include "variables.h" |
2676
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2652
diff
changeset
|
22 |
#include "train.h" |
6857
60130753e595
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
6847
diff
changeset
|
23 |
#include "roadveh.h" |
7202
dc312a87f450
(svn r10480) -Fix: Don't allow building lighthouses and transmitters under bridges in the scenario editor, or during world generation.
maedhros
parents:
7127
diff
changeset
|
24 |
#include "bridge_map.h" |
4184
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
25 |
#include "screenshot.h" |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
26 |
#include "genworld.h" |
4668
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4634
diff
changeset
|
27 |
#include "vehicle_gui.h" |
6427
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6357
diff
changeset
|
28 |
#include "transparency_gui.h" |
5237
4fce3ea379c2
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
5235
diff
changeset
|
29 |
#include "newgrf_config.h" |
8111
02d19f43eea6
(svn r11672) -Codechange: refactor some stuff out of gui.h.
rubidium
parents:
8108
diff
changeset
|
30 |
#include "rail_gui.h" |
02d19f43eea6
(svn r11672) -Codechange: refactor some stuff out of gui.h.
rubidium
parents:
8108
diff
changeset
|
31 |
#include "road_gui.h" |
8140
0d0d8c94f84b
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents:
8139
diff
changeset
|
32 |
#include "date_func.h" |
8131
160939e24ed3
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8123
diff
changeset
|
33 |
#include "functions.h" |
8144
65cec0877b78
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8140
diff
changeset
|
34 |
#include "vehicle_func.h" |
8157
1505def01945
(svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents:
8149
diff
changeset
|
35 |
#include "sound_func.h" |
8149
1b1390cb0844
(svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents:
8144
diff
changeset
|
36 |
#include "fios.h" |
8205
2bde724f1b5d
(svn r11768) -Codechange: move some terraform related gui stuff from main_gui.cpp to terraform_gui.cpp (and introduce terraform_gui.h). Based on a patch by Roujin.
rubidium
parents:
8196
diff
changeset
|
37 |
#include "terraform_gui.h" |
4942
7fb6c39eb421
(svn r6930) -Codechange: Move industry name into IndustrySpec
belugas
parents:
4938
diff
changeset
|
38 |
#include "industry.h" |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
7824
diff
changeset
|
39 |
#include "transparency.h" |
8114
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8111
diff
changeset
|
40 |
#include "strings_func.h" |
8123
ce31d2843a95
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents:
8121
diff
changeset
|
41 |
#include "zoom_func.h" |
8214
971f861d5543
(svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents:
8208
diff
changeset
|
42 |
#include "string_func.h" |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8224
diff
changeset
|
43 |
#include "player_base.h" |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8224
diff
changeset
|
44 |
#include "player_func.h" |
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8224
diff
changeset
|
45 |
#include "player_gui.h" |
8270
e7c342f6b14c
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8264
diff
changeset
|
46 |
#include "settings_type.h" |
8723
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
47 |
#include "toolbar_gui.h" |
0 | 48 |
|
8264
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
49 |
#include "network/network.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
50 |
#include "network/network_data.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
51 |
#include "network/network_client.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
52 |
#include "network/network_server.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
53 |
#include "network/network_gui.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
54 |
|
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
55 |
#include "table/sprites.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
56 |
#include "table/strings.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
57 |
|
5413 | 58 |
static int _rename_id = 1; |
59 |
static int _rename_what = -1; |
|
0 | 60 |
|
5116
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5108
diff
changeset
|
61 |
RailType _last_built_railtype; |
6666
41ceafa4c85e
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
6654
diff
changeset
|
62 |
RoadType _last_built_roadtype; |
7643
af32b07bc027
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
7521
diff
changeset
|
63 |
bool _draw_bounding_boxes = false; |
af32b07bc027
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
7521
diff
changeset
|
64 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
65 |
|
6847
77facd267574
(svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents:
6845
diff
changeset
|
66 |
void CcGiveMoney(bool success, TileIndex tile, uint32 p1, uint32 p2) |
77facd267574
(svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents:
6845
diff
changeset
|
67 |
{ |
6898
d23c46e9a6ec
(svn r10145) -Fix: make compiling with networking disabled (again) possible.
rubidium
parents:
6857
diff
changeset
|
68 |
#ifdef ENABLE_NETWORK |
7657
2b55af55cc51
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7643
diff
changeset
|
69 |
if (!success || !_patches.give_money) return; |
6847
77facd267574
(svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents:
6845
diff
changeset
|
70 |
|
77facd267574
(svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents:
6845
diff
changeset
|
71 |
char msg[20]; |
77facd267574
(svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents:
6845
diff
changeset
|
72 |
/* Inform the player of this action */ |
77facd267574
(svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents:
6845
diff
changeset
|
73 |
snprintf(msg, sizeof(msg), "%d", p1); |
77facd267574
(svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents:
6845
diff
changeset
|
74 |
|
77facd267574
(svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents:
6845
diff
changeset
|
75 |
if (!_network_server) { |
77facd267574
(svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents:
6845
diff
changeset
|
76 |
SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, p2, msg); |
77facd267574
(svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents:
6845
diff
changeset
|
77 |
} else { |
77facd267574
(svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents:
6845
diff
changeset
|
78 |
NetworkServer_HandleChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, p2, msg, NETWORK_SERVER_INDEX); |
77facd267574
(svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents:
6845
diff
changeset
|
79 |
} |
6898
d23c46e9a6ec
(svn r10145) -Fix: make compiling with networking disabled (again) possible.
rubidium
parents:
6857
diff
changeset
|
80 |
#endif /* ENABLE_NETWORK */ |
6847
77facd267574
(svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents:
6845
diff
changeset
|
81 |
} |
77facd267574
(svn r10087) -Fix [FS#834]: multiple subsequent "give money" actions could result in duplicate messages that money has been transfered when it only happened once.
rubidium
parents:
6845
diff
changeset
|
82 |
|
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5413
diff
changeset
|
83 |
void HandleOnEditText(const char *str) |
1799
6d82d202c145
(svn r2303) - CodeChange (fix): when giving money to other players only allow transferring money that is above your loan. Eg you can't give away your loan.
Darkvater
parents:
1793
diff
changeset
|
84 |
{ |
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5413
diff
changeset
|
85 |
int id = _rename_id; |
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5413
diff
changeset
|
86 |
_cmd_text = str; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
87 |
|
1799
6d82d202c145
(svn r2303) - CodeChange (fix): when giving money to other players only allow transferring money that is above your loan. Eg you can't give away your loan.
Darkvater
parents:
1793
diff
changeset
|
88 |
switch (_rename_what) { |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
89 |
case 1: // Rename a waypoint |
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5413
diff
changeset
|
90 |
if (*str == '\0') return; |
395
788a9bba0889
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
355
diff
changeset
|
91 |
DoCommandP(0, id, 0, NULL, CMD_RENAME_WAYPOINT | CMD_MSG(STR_CANT_CHANGE_WAYPOINT_NAME)); |
0 | 92 |
break; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
93 |
#ifdef ENABLE_NETWORK |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
94 |
case 3: { // Give money, you can only give money in excess of loan |
1962
8254df1b359b
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1932
diff
changeset
|
95 |
const Player *p = GetPlayer(_current_player); |
7505
55e7acbf7a69
(svn r11020) -Fix [FS#1174]: One could not give money when (s)he had too much money or rather: when casting the amount of money to an int32 becomes negative.
rubidium
parents:
7480
diff
changeset
|
96 |
Money money = min(p->player_money - p->current_loan, (Money)(atoi(str) / _currency->rate)); |
1799
6d82d202c145
(svn r2303) - CodeChange (fix): when giving money to other players only allow transferring money that is above your loan. Eg you can't give away your loan.
Darkvater
parents:
1793
diff
changeset
|
97 |
|
7922
a7e266f966d9
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents:
7889
diff
changeset
|
98 |
uint32 money_c = Clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0 |
813
640a517dc129
(svn r1284) -Fix: Fixed 'money-cheat' (read: bug which could give people a lot of money)
truelight
parents:
793
diff
changeset
|
99 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
100 |
/* Give 'id' the money, and substract it from ourself */ |
6990
136a08baf0ed
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
6953
diff
changeset
|
101 |
DoCommandP(0, money_c, id, CcGiveMoney, CMD_GIVE_MONEY | CMD_MSG(STR_INSUFFICIENT_FUNDS)); |
6492
286a52449b54
(svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents:
6486
diff
changeset
|
102 |
} break; |
5413 | 103 |
#endif /* ENABLE_NETWORK */ |
104 |
default: NOT_REACHED(); |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
105 |
} |
5413 | 106 |
|
107 |
_rename_id = _rename_what = -1; |
|
0 | 108 |
} |
109 |
||
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
110 |
/** |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
111 |
* This code is shared for the majority of the pushbuttons. |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
112 |
* Handles e.g. the pressing of a button (to build things), playing of click sound and sets certain parameters |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
113 |
* |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
114 |
* @param w Window which called the function |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
115 |
* @param widget ID of the widget (=button) that called this function |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
116 |
* @param cursor How should the cursor image change? E.g. cursor with depot image in it |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
117 |
* @param mode Tile highlighting mode, e.g. drawing a rectangle or a dot on the ground |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
118 |
* @param placeproc Procedure which will be called when someone clicks on the map |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
119 |
* @return true if the button is clicked, false if it's unclicked |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
120 |
*/ |
7889
e74ce8853ba7
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents:
7857
diff
changeset
|
121 |
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, ViewportHighlightMode mode, PlaceProc *placeproc) |
0 | 122 |
{ |
7997
df87ccd00a96
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
7954
diff
changeset
|
123 |
if (w->IsWidgetDisabled(widget)) return false; |
0 | 124 |
|
2621
2bacc2e9c68f
(svn r3159) Remove the read-only variable _no_button_sound
tron
parents:
2615
diff
changeset
|
125 |
SndPlayFx(SND_15_BEEP); |
0 | 126 |
SetWindowDirty(w); |
127 |
||
7997
df87ccd00a96
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
7954
diff
changeset
|
128 |
if (w->IsWidgetLowered(widget)) { |
0 | 129 |
ResetObjectToPlace(); |
130 |
return false; |
|
131 |
} |
|
132 |
||
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
133 |
SetObjectToPlace(cursor, PAL_NONE, mode, w->window_class, w->window_number); |
7997
df87ccd00a96
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
7954
diff
changeset
|
134 |
w->LowerWidget(widget); |
0 | 135 |
_place_proc = placeproc; |
136 |
return true; |
|
137 |
} |
|
138 |
||
139 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
140 |
void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 141 |
{ |
541 | 142 |
if (success) SndPlayTileFx(SND_12_EXPLOSION, tile); |
0 | 143 |
} |
144 |
||
145 |
||
410 | 146 |
static void MenuClickSettings(int index) |
0 | 147 |
{ |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
148 |
switch (index) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
149 |
case 0: ShowGameOptions(); return; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
150 |
case 1: ShowGameDifficulty(); return; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
151 |
case 2: ShowPatchesSelection(); return; |
5352
86fca6a41aa1
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5261
diff
changeset
|
152 |
case 3: ShowNewGRFSettings(!_networking, true, true, &_grfconfig); return; |
7015
0e76fdaed37c
(svn r10271) -Fix r9563: move the Transparency Option menu item to the place it should have been in the first place: Option Menu, not Map Menu (go figure :p)
truelight
parents:
7002
diff
changeset
|
153 |
case 4: ShowTransparencyToolbar(); break; |
0e76fdaed37c
(svn r10271) -Fix r9563: move the Transparency Option menu item to the place it should have been in the first place: Option Menu, not Map Menu (go figure :p)
truelight
parents:
7002
diff
changeset
|
154 |
|
7932
6c3d71e8a129
(svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
skidd13
parents:
7931
diff
changeset
|
155 |
case 6: ToggleBit(_display_opt, DO_SHOW_TOWN_NAMES); break; |
6c3d71e8a129
(svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
skidd13
parents:
7931
diff
changeset
|
156 |
case 7: ToggleBit(_display_opt, DO_SHOW_STATION_NAMES); break; |
6c3d71e8a129
(svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
skidd13
parents:
7931
diff
changeset
|
157 |
case 8: ToggleBit(_display_opt, DO_SHOW_SIGNS); break; |
6c3d71e8a129
(svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
skidd13
parents:
7931
diff
changeset
|
158 |
case 9: ToggleBit(_display_opt, DO_WAYPOINTS); break; |
6c3d71e8a129
(svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
skidd13
parents:
7931
diff
changeset
|
159 |
case 10: ToggleBit(_display_opt, DO_FULL_ANIMATION); break; |
6c3d71e8a129
(svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
skidd13
parents:
7931
diff
changeset
|
160 |
case 11: ToggleBit(_display_opt, DO_FULL_DETAIL); break; |
8452
8f87ace6640e
(svn r12022) -Revert(r12018): Invisible trees are now separate from the building concept.
belugas
parents:
8448
diff
changeset
|
161 |
case 12: ToggleTransparency(TO_HOUSES); break; |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
7824
diff
changeset
|
162 |
case 13: ToggleTransparency(TO_SIGNS); break; |
0 | 163 |
} |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
164 |
MarkWholeScreenDirty(); |
0 | 165 |
} |
166 |
||
8723
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
167 |
void MenuClickSaveLoad(int index) |
0 | 168 |
{ |
169 |
if (_game_mode == GM_EDITOR) { |
|
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
170 |
switch (index) { |
5894
afbd6aea0d56
(svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents:
5893
diff
changeset
|
171 |
case 0: ShowSaveLoadDialog(SLD_SAVE_SCENARIO); break; |
afbd6aea0d56
(svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents:
5893
diff
changeset
|
172 |
case 1: ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break; |
afbd6aea0d56
(svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents:
5893
diff
changeset
|
173 |
case 2: ShowSaveLoadDialog(SLD_LOAD_HEIGHTMAP); break; |
afbd6aea0d56
(svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents:
5893
diff
changeset
|
174 |
case 3: AskExitToGameMenu(); break; |
afbd6aea0d56
(svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents:
5893
diff
changeset
|
175 |
case 5: HandleExitGameRequest(); break; |
0 | 176 |
} |
177 |
} else { |
|
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
178 |
switch (index) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
179 |
case 0: ShowSaveLoadDialog(SLD_SAVE_GAME); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
180 |
case 1: ShowSaveLoadDialog(SLD_LOAD_GAME); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
181 |
case 2: AskExitToGameMenu(); break; |
4548
6165e12570bf
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4536
diff
changeset
|
182 |
case 3: HandleExitGameRequest(); break; |
0 | 183 |
} |
184 |
} |
|
185 |
} |
|
186 |
||
410 | 187 |
static void MenuClickMap(int index) |
0 | 188 |
{ |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
189 |
switch (index) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
190 |
case 0: ShowSmallMap(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
191 |
case 1: ShowExtraViewPortWindow(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
192 |
case 2: ShowSignList(); break; |
0 | 193 |
} |
194 |
} |
|
195 |
||
410 | 196 |
static void MenuClickTown(int index) |
0 | 197 |
{ |
198 |
ShowTownDirectory(); |
|
199 |
} |
|
200 |
||
410 | 201 |
static void MenuClickScenMap(int index) |
0 | 202 |
{ |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
203 |
switch (index) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
204 |
case 0: ShowSmallMap(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
205 |
case 1: ShowExtraViewPortWindow(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
206 |
case 2: ShowSignList(); break; |
7125
ef3b4aaf994f
(svn r10398) -Fix (r10271): transparency menu option wasn't moved properly in the scenario editor
peter1138
parents:
7086
diff
changeset
|
207 |
case 3: ShowTownDirectory(); break; |
0 | 208 |
} |
209 |
} |
|
210 |
||
410 | 211 |
static void MenuClickSubsidies(int index) |
0 | 212 |
{ |
213 |
ShowSubsidiesList(); |
|
214 |
} |
|
215 |
||
410 | 216 |
static void MenuClickStations(int index) |
0 | 217 |
{ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
218 |
ShowPlayerStations((PlayerID)index); |
0 | 219 |
} |
220 |
||
410 | 221 |
static void MenuClickFinances(int index) |
0 | 222 |
{ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
223 |
ShowPlayerFinances((PlayerID)index); |
0 | 224 |
} |
225 |
||
410 | 226 |
static void MenuClickCompany(int index) |
0 | 227 |
{ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
228 |
if (_networking && index == 0) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
229 |
ShowClientList(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
230 |
} else { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
231 |
if (_networking) index--; |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
232 |
ShowPlayerCompany((PlayerID)index); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
233 |
} |
0 | 234 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
235 |
|
410 | 236 |
static void MenuClickGraphs(int index) |
0 | 237 |
{ |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
238 |
switch (index) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
239 |
case 0: ShowOperatingProfitGraph(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
240 |
case 1: ShowIncomeGraph(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
241 |
case 2: ShowDeliveredCargoGraph(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
242 |
case 3: ShowPerformanceHistoryGraph(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
243 |
case 4: ShowCompanyValueGraph(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
244 |
case 5: ShowCargoPaymentRates(); break; |
0 | 245 |
} |
246 |
} |
|
247 |
||
410 | 248 |
static void MenuClickLeague(int index) |
0 | 249 |
{ |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
250 |
switch (index) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
251 |
case 0: ShowCompanyLeagueTable(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
252 |
case 1: ShowPerformanceRatingDetail(); break; |
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
74
diff
changeset
|
253 |
} |
0 | 254 |
} |
255 |
||
410 | 256 |
static void MenuClickIndustry(int index) |
0 | 257 |
{ |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
258 |
switch (index) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
259 |
case 0: ShowIndustryDirectory(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
260 |
case 1: ShowBuildIndustryWindow(); break; |
0 | 261 |
} |
262 |
} |
|
263 |
||
410 | 264 |
static void MenuClickShowTrains(int index) |
0 | 265 |
{ |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6247
diff
changeset
|
266 |
ShowVehicleListWindow((PlayerID)index, VEH_TRAIN); |
0 | 267 |
} |
268 |
||
410 | 269 |
static void MenuClickShowRoad(int index) |
0 | 270 |
{ |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6247
diff
changeset
|
271 |
ShowVehicleListWindow((PlayerID)index, VEH_ROAD); |
0 | 272 |
} |
273 |
||
410 | 274 |
static void MenuClickShowShips(int index) |
0 | 275 |
{ |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6247
diff
changeset
|
276 |
ShowVehicleListWindow((PlayerID)index, VEH_SHIP); |
0 | 277 |
} |
278 |
||
410 | 279 |
static void MenuClickShowAir(int index) |
0 | 280 |
{ |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6247
diff
changeset
|
281 |
ShowVehicleListWindow((PlayerID)index, VEH_AIRCRAFT); |
0 | 282 |
} |
283 |
||
410 | 284 |
static void MenuClickBuildRail(int index) |
0 | 285 |
{ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
286 |
_last_built_railtype = (RailType)index; |
0 | 287 |
ShowBuildRailToolbar(_last_built_railtype, -1); |
288 |
} |
|
289 |
||
410 | 290 |
static void MenuClickBuildRoad(int index) |
0 | 291 |
{ |
6666
41ceafa4c85e
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
6654
diff
changeset
|
292 |
_last_built_roadtype = (RoadType)index; |
41ceafa4c85e
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
6654
diff
changeset
|
293 |
ShowBuildRoadToolbar(_last_built_roadtype); |
0 | 294 |
} |
295 |
||
410 | 296 |
static void MenuClickBuildWater(int index) |
0 | 297 |
{ |
298 |
ShowBuildDocksToolbar(); |
|
299 |
} |
|
300 |
||
410 | 301 |
static void MenuClickBuildAir(int index) |
0 | 302 |
{ |
303 |
ShowBuildAirToolbar(); |
|
304 |
} |
|
305 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
306 |
#ifdef ENABLE_NETWORK |
4830
668bcb0a30b2
(svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents:
4824
diff
changeset
|
307 |
void ShowNetworkGiveMoneyWindow(PlayerID player) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
308 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
309 |
_rename_id = player; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
310 |
_rename_what = 3; |
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5413
diff
changeset
|
311 |
ShowQueryString(STR_EMPTY, STR_NETWORK_GIVE_MONEY_CAPTION, 30, 180, NULL, CS_NUMERAL); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
312 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
313 |
#endif /* ENABLE_NETWORK */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
314 |
|
2116 | 315 |
void ShowRenameWaypointWindow(const Waypoint *wp) |
0 | 316 |
{ |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1500
diff
changeset
|
317 |
int id = wp->index; |
697
eaada71b7c85
(svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents:
682
diff
changeset
|
318 |
|
eaada71b7c85
(svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents:
682
diff
changeset
|
319 |
/* Are we allowed to change the name of the waypoint? */ |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1500
diff
changeset
|
320 |
if (!CheckTileOwnership(wp->xy)) { |
926
a6d140a6a4de
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
872
diff
changeset
|
321 |
ShowErrorMessage(_error_message, STR_CANT_CHANGE_WAYPOINT_NAME, |
3422
a6eba3443452
(svn r4249) -Codechange: Replace more occurences of 16 by TILE_SIZE and of 8 by TILE_HEIGHT. Reverted one change from the previous commit because it was faulty
celestar
parents:
3326
diff
changeset
|
322 |
TileX(wp->xy) * TILE_SIZE, TileY(wp->xy) * TILE_SIZE); |
697
eaada71b7c85
(svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents:
682
diff
changeset
|
323 |
return; |
eaada71b7c85
(svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents:
682
diff
changeset
|
324 |
} |
eaada71b7c85
(svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents:
682
diff
changeset
|
325 |
|
0 | 326 |
_rename_id = id; |
327 |
_rename_what = 1; |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
328 |
SetDParam(0, id); |
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5413
diff
changeset
|
329 |
ShowQueryString(STR_WAYPOINT_RAW, STR_EDIT_WAYPOINT_NAME, 30, 180, NULL, CS_ALPHANUMERAL); |
0 | 330 |
} |
331 |
||
8723
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
332 |
void SelectSignTool() |
0 | 333 |
{ |
2639 | 334 |
if (_cursor.sprite == SPR_CURSOR_SIGN) { |
0 | 335 |
ResetObjectToPlace(); |
2639 | 336 |
} else { |
7889
e74ce8853ba7
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents:
7857
diff
changeset
|
337 |
SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, VHM_RECT, WC_MAIN_TOOLBAR, 0); |
0 | 338 |
_place_proc = PlaceProc_Sign; |
339 |
} |
|
340 |
} |
|
341 |
||
410 | 342 |
static void MenuClickForest(int index) |
0 | 343 |
{ |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
344 |
switch (index) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
345 |
case 0: ShowTerraformToolbar(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
346 |
case 1: ShowBuildTreesToolbar(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
347 |
case 2: SelectSignTool(); break; |
0 | 348 |
} |
349 |
} |
|
350 |
||
410 | 351 |
static void MenuClickMusicWindow(int index) |
0 | 352 |
{ |
353 |
ShowMusicWindow(); |
|
354 |
} |
|
355 |
||
410 | 356 |
static void MenuClickNewspaper(int index) |
0 | 357 |
{ |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
358 |
switch (index) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
359 |
case 0: ShowLastNewsMessage(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
360 |
case 1: ShowMessageOptions(); break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2630
diff
changeset
|
361 |
case 2: ShowMessageHistory(); break; |
0 | 362 |
} |
363 |
} |
|
364 |
||
8723
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
365 |
void MenuClickSmallScreenshot() |
4184
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
366 |
{ |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
367 |
SetScreenshotType(SC_VIEWPORT); |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
368 |
} |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
369 |
|
8723
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
370 |
void MenuClickWorldScreenshot() |
4184
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
371 |
{ |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
372 |
SetScreenshotType(SC_WORLD); |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
373 |
} |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
374 |
|
410 | 375 |
static void MenuClickHelp(int index) |
0 | 376 |
{ |
2432
c48585a8b05f
(svn r2958) - Feature: [ 1258971 ] Menu option to toggle console. Mainly for MacOS's or PDA's. (toholio)
Darkvater
parents:
2430
diff
changeset
|
377 |
switch (index) { |
4184
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
378 |
case 0: PlaceLandBlockInfo(); break; |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
379 |
case 2: IConsoleSwitch(); break; |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
380 |
case 3: MenuClickSmallScreenshot(); break; |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
381 |
case 4: MenuClickWorldScreenshot(); break; |
541f819f2125
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
382 |
case 5: ShowAboutWindow(); break; |
0 | 383 |
} |
384 |
} |
|
385 |
||
2639 | 386 |
|
387 |
typedef void MenuClickedProc(int index); |
|
388 |
||
0 | 389 |
static MenuClickedProc * const _menu_clicked_procs[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
390 |
NULL, /* 0 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
391 |
NULL, /* 1 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
392 |
MenuClickSettings, /* 2 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
393 |
MenuClickSaveLoad, /* 3 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
394 |
MenuClickMap, /* 4 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
395 |
MenuClickTown, /* 5 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
396 |
MenuClickSubsidies, /* 6 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
397 |
MenuClickStations, /* 7 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
398 |
MenuClickFinances, /* 8 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
399 |
MenuClickCompany, /* 9 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
400 |
MenuClickGraphs, /* 10 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
401 |
MenuClickLeague, /* 11 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
402 |
MenuClickIndustry, /* 12 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
403 |
MenuClickShowTrains, /* 13 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
404 |
MenuClickShowRoad, /* 14 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
405 |
MenuClickShowShips, /* 15 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
406 |
MenuClickShowAir, /* 16 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
407 |
MenuClickScenMap, /* 17 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
408 |
NULL, /* 18 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
409 |
MenuClickBuildRail, /* 19 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
410 |
MenuClickBuildRoad, /* 20 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
411 |
MenuClickBuildWater, /* 21 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
412 |
MenuClickBuildAir, /* 22 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
413 |
MenuClickForest, /* 23 */ |
0 | 414 |
MenuClickMusicWindow, /* 24 */ |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
415 |
MenuClickNewspaper, /* 25 */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4337
diff
changeset
|
416 |
MenuClickHelp, /* 26 */ |
0 | 417 |
}; |
418 |
||
419 |
static void MenuWndProc(Window *w, WindowEvent *e) |
|
420 |
{ |
|
2639 | 421 |
switch (e->event) { |
4820
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
422 |
case WE_CREATE: w->widget[0].right = w->width - 1; break; |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
423 |
|
0 | 424 |
case WE_PAINT: { |
4822
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
425 |
int x, y; |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
426 |
|
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
427 |
byte count = WP(w, menu_d).item_count; |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
428 |
byte sel = WP(w, menu_d).sel_index; |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
429 |
uint16 chk = WP(w, menu_d).checked_items; |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
430 |
StringID string = WP(w, menu_d).string_id; |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
431 |
byte dis = WP(w, menu_d).disabled_items; |
0 | 432 |
|
433 |
DrawWindowWidgets(w); |
|
434 |
||
435 |
x = 1; |
|
436 |
y = 1; |
|
437 |
||
4822
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
438 |
for (; count != 0; count--, string++, sel--) { |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
439 |
TextColour color = HasBit(dis, 0) ? TC_GREY : (sel == 0) ? TC_WHITE : TC_BLACK; |
4822
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
440 |
if (sel == 0) GfxFillRect(x, y, x + w->width - 3, y + 9, 0); |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
441 |
|
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
442 |
if (HasBit(chk, 0)) DrawString(x + 2, y, STR_CHECKMARK, color); |
4822
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
443 |
DrawString(x + 2, y, string, color); |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
444 |
|
0 | 445 |
y += 10; |
446 |
chk >>= 1; |
|
4822
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
447 |
dis >>= 1; |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
448 |
} |
0 | 449 |
} break; |
450 |
||
451 |
case WE_DESTROY: { |
|
452 |
Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0); |
|
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
453 |
v->RaiseWidget(WP(w, menu_d).main_button); |
0 | 454 |
SetWindowDirty(v); |
455 |
return; |
|
456 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
457 |
|
0 | 458 |
case WE_POPUPMENU_SELECT: { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
459 |
int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); |
0 | 460 |
int action_id; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
461 |
|
0 | 462 |
|
463 |
if (index < 0) { |
|
464 |
Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0); |
|
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
465 |
if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w, menu_d).main_button) |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
466 |
index = WP(w, menu_d).sel_index; |
0 | 467 |
} |
468 |
||
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
469 |
action_id = WP(w, menu_d).action_id; |
0 | 470 |
DeleteWindow(w); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
471 |
|
4822
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
472 |
if (index >= 0) { |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
473 |
assert((uint)index <= lengthof(_menu_clicked_procs)); |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
474 |
_menu_clicked_procs[action_id](index); |
cc1a5189d4d7
(svn r6746) -Codechange: Remove the need for double strings in "checkmarked" items. While
Darkvater
parents:
4821
diff
changeset
|
475 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
476 |
|
0 | 477 |
break; |
478 |
} |
|
2639 | 479 |
|
0 | 480 |
case WE_POPUPMENU_OVER: { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
481 |
int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); |
0 | 482 |
|
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
483 |
if (index == -1 || index == WP(w, menu_d).sel_index) return; |
0 | 484 |
|
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
485 |
WP(w, menu_d).sel_index = index; |
0 | 486 |
SetWindowDirty(w); |
487 |
return; |
|
488 |
} |
|
489 |
} |
|
490 |
} |
|
491 |
||
4820
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
492 |
/* Dynamic widget length determined by toolbar-string length. |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
493 |
* See PopupMainToolbMenu en MenuWndProc */ |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
494 |
static const Widget _menu_widgets[] = { |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
495 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 0, 0, 0, 0x0, STR_NULL}, |
4820
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
496 |
{ WIDGETS_END}, |
0 | 497 |
}; |
498 |
||
499 |
||
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
500 |
static const Widget _player_menu_widgets[] = { |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
501 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 240, 0, 81, 0x0, STR_NULL}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
502 |
{ WIDGETS_END}, |
0 | 503 |
}; |
504 |
||
505 |
||
506 |
static int GetPlayerIndexFromMenu(int index) |
|
507 |
{ |
|
508 |
if (index >= 0) { |
|
4171 | 509 |
const Player *p; |
2630 | 510 |
|
0 | 511 |
FOR_ALL_PLAYERS(p) { |
2639 | 512 |
if (p->is_active && --index < 0) return p->index; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
513 |
} |
0 | 514 |
} |
515 |
return -1; |
|
516 |
} |
|
517 |
||
518 |
static void UpdatePlayerMenuHeight(Window *w) |
|
519 |
{ |
|
4824
c49e6ffcb89a
(svn r6748) -Codechange: Use already existing function to count active players.
Darkvater
parents:
4822
diff
changeset
|
520 |
byte num = ActivePlayerCount(); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
521 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
522 |
/* Increase one to fit in PlayerList in the menu when in network */ |
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
523 |
if (_networking && WP(w, menu_d).main_button == 9) num++; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
524 |
|
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
525 |
if (WP(w, menu_d).item_count != num) { |
8723
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
526 |
Point pos; |
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
527 |
WP(w, menu_d).item_count = num; |
0 | 528 |
SetWindowDirty(w); |
529 |
num = num * 10 + 2; |
|
530 |
w->height = num; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
531 |
w->widget[0].bottom = w->widget[0].top + num - 1; |
8723
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
532 |
pos = GetToolbarDropdownPos(0, w->width, w->height); |
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
533 |
w->top = pos.y; |
0 | 534 |
SetWindowDirty(w); |
535 |
} |
|
536 |
} |
|
537 |
||
538 |
static void PlayerMenuWndProc(Window *w, WindowEvent *e) |
|
539 |
{ |
|
2639 | 540 |
switch (e->event) { |
0 | 541 |
case WE_PAINT: { |
542 |
int x,y; |
|
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7657
diff
changeset
|
543 |
byte sel; |
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7657
diff
changeset
|
544 |
TextColour color; |
0 | 545 |
Player *p; |
546 |
uint16 chk; |
|
547 |
||
548 |
UpdatePlayerMenuHeight(w); |
|
549 |
DrawWindowWidgets(w); |
|
550 |
||
551 |
x = 1; |
|
552 |
y = 1; |
|
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
553 |
sel = WP(w, menu_d).sel_index; |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
554 |
chk = WP(w, menu_d).checked_items; // let this mean gray items. |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
555 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
556 |
/* 9 = playerlist */ |
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
557 |
if (_networking && WP(w, menu_d).main_button == 9) { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
558 |
if (sel == 0) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
559 |
GfxFillRect(x, y, x + 238, y + 9, 0); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
560 |
} |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7657
diff
changeset
|
561 |
DrawString(x + 19, y, STR_NETWORK_CLIENT_LIST, TC_FROMSTRING); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
562 |
y += 10; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
563 |
sel--; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
564 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
565 |
|
0 | 566 |
FOR_ALL_PLAYERS(p) { |
567 |
if (p->is_active) { |
|
568 |
if (p->index == sel) { |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
569 |
GfxFillRect(x, y, x + 238, y + 9, 0); |
0 | 570 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
571 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
572 |
DrawPlayerIcon(p->index, x + 2, y + 1); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
573 |
|
7058
8105bb13ce3d
(svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents:
7056
diff
changeset
|
574 |
SetDParam(0, p->index); |
8105bb13ce3d
(svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents:
7056
diff
changeset
|
575 |
SetDParam(1, p->index); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
576 |
|
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7657
diff
changeset
|
577 |
color = (p->index == sel) ? TC_WHITE : TC_BLACK; |
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7657
diff
changeset
|
578 |
if (chk&1) color = TC_GREY; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
579 |
DrawString(x + 19, y, STR_7021, color); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
580 |
|
0 | 581 |
y += 10; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
582 |
} |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
583 |
chk >>= 1; |
0 | 584 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
585 |
|
0 | 586 |
break; |
587 |
} |
|
588 |
||
589 |
case WE_DESTROY: { |
|
590 |
Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0); |
|
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
591 |
v->RaiseWidget(WP(w, menu_d).main_button); |
0 | 592 |
SetWindowDirty(v); |
593 |
return; |
|
594 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
595 |
|
0 | 596 |
case WE_POPUPMENU_SELECT: { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
597 |
int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); |
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
598 |
int action_id = WP(w, menu_d).action_id; |
0 | 599 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
600 |
/* We have a new entry at the top of the list of menu 9 when networking |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
601 |
* so keep that in count */ |
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
602 |
if (_networking && WP(w, menu_d).main_button == 9) { |
2639 | 603 |
if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1; |
604 |
} else { |
|
724
a73dec475b53
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
605 |
index = GetPlayerIndexFromMenu(index); |
2639 | 606 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
607 |
|
0 | 608 |
if (index < 0) { |
609 |
Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0); |
|
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
610 |
if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w, menu_d).main_button) |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
611 |
index = WP(w, menu_d).sel_index; |
0 | 612 |
} |
613 |
||
614 |
DeleteWindow(w); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
615 |
|
0 | 616 |
if (index >= 0) { |
617 |
assert(index >= 0 && index < 30); |
|
618 |
_menu_clicked_procs[action_id](index); |
|
619 |
} |
|
620 |
break; |
|
621 |
} |
|
622 |
case WE_POPUPMENU_OVER: { |
|
623 |
int index; |
|
624 |
UpdatePlayerMenuHeight(w); |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
625 |
index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
626 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
627 |
/* We have a new entry at the top of the list of menu 9 when networking |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
628 |
* so keep that in count */ |
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
629 |
if (_networking && WP(w, menu_d).main_button == 9) { |
2639 | 630 |
if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1; |
631 |
} else { |
|
724
a73dec475b53
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
632 |
index = GetPlayerIndexFromMenu(index); |
2639 | 633 |
} |
634 |
||
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
635 |
if (index == -1 || index == WP(w, menu_d).sel_index) return; |
0 | 636 |
|
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
637 |
WP(w, menu_d).sel_index = index; |
0 | 638 |
SetWindowDirty(w); |
639 |
return; |
|
640 |
} |
|
641 |
} |
|
642 |
} |
|
643 |
||
4820
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
644 |
/** Get the maximum length of a given string in a string-list. This is an |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
645 |
* implicit string-list where the ID's are consecutive |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
646 |
* @param base_string StringID of the first string in the list |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
647 |
* @param count amount of StringID's in the list |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
648 |
* @return the length of the longest string */ |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
649 |
static int GetStringListMaxWidth(StringID base_string, byte count) |
0 | 650 |
{ |
4820
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
651 |
char buffer[512]; |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
652 |
int width, max_width; |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
653 |
byte i; |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
654 |
|
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
655 |
max_width = 0; |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
656 |
for (i = 0; i != count; i++) { |
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4907
diff
changeset
|
657 |
GetString(buffer, base_string + i, lastof(buffer)); |
4820
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
658 |
width = GetStringBoundingBox(buffer).width; |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
659 |
if (width > max_width) max_width = width; |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
660 |
} |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
661 |
|
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
662 |
return max_width; |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
663 |
} |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
664 |
|
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
665 |
/** Show a general dropdown menu. The positioning of the dropdown menu |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
666 |
* defaults to the left side of the parent_button, eg the button that caused |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
667 |
* this window to appear. The only exceptions are when the right side of this |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
668 |
* dropdown would fall outside the main toolbar window, in that case it is |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
669 |
* aligned with the toolbar's right side. |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
670 |
* Since the disable-mask is only 8 bits right now, these dropdowns are |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
671 |
* restricted to 8 items max if any bits of disabled_mask are active. |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
672 |
* @param w Pointer to a window this dropdown menu belongs to. Has no effect |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
673 |
* whatsoever, only graphically for positioning. |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
674 |
* @param parent_button The widget identifier of the button that was clicked for |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
675 |
* this dropdown. The created dropdown then knows what button to raise (button) on |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
676 |
* action and whose function to execute (action). |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
677 |
* It is possible to appoint another button for an action event by setting the |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
678 |
* upper 8 bits of this parameter. If non is set, action is presumed to be the same |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
679 |
* as button. So<br> |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
680 |
* button bits 0 - 7 - widget clicked to get dropdown |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
681 |
* action bits 8 - 15 - function of widget to execute on select (defaults to bits 0 - 7) |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
682 |
* @param base_string The first StringID shown in the dropdown list. All others are |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
683 |
* consecutive indeces from the language file. XXX - fix? Use ingame-string tables? |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
684 |
* @param item_count Number of strings in the list, see previous parameter |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
685 |
* @param disabled_mask Bitmask of disabled strings in the list |
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
686 |
* @return Return a pointer to the newly created dropdown window */ |
8723
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
687 |
Window *PopupMainToolbMenu(Window *w, uint16 parent_button, StringID base_string, byte item_count, byte disabled_mask) |
4820
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
688 |
{ |
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
689 |
int width; |
8723
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
690 |
int height; |
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
691 |
Point pos; |
0 | 692 |
|
4820
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
693 |
assert(disabled_mask == 0 || item_count <= 8); |
7997
df87ccd00a96
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
7954
diff
changeset
|
694 |
w->LowerWidget(parent_button); |
8028
e578ea22f371
(svn r11588) -Codechange: use the new member introduced in r11551
glx
parents:
7997
diff
changeset
|
695 |
w->InvalidateWidget(parent_button); |
0 | 696 |
|
697 |
DeleteWindowById(WC_TOOLBAR_MENU, 0); |
|
698 |
||
8723
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
699 |
// Extend the dropdown toolbar to the longest string in the list |
4821
71d1da6c6f03
(svn r6745) -Codechange: Have the dropdown menus fall fully inside the top toolbar. So
Darkvater
parents:
4820
diff
changeset
|
700 |
width = max(GetStringListMaxWidth(base_string, item_count) + 6, 140); |
8723
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
701 |
height = item_count * 10 + 2; |
4820
dd69fb4c3fcd
(svn r6744) -Fix: Determine the length of the main toolbar dropdown list based
Darkvater
parents:
4781
diff
changeset
|
702 |
|
8723
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
703 |
pos = GetToolbarDropdownPos(parent_button, width, height); |
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
704 |
|
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
705 |
w = AllocateWindow(pos.x, pos.y, width, height, MenuWndProc, WC_TOOLBAR_MENU, _menu_widgets); |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
706 |
w->widget[0].bottom = item_count * 10 + 1; |
0 | 707 |
w->flags4 &= ~WF_WHITE_BORDER_MASK; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
708 |
|
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
709 |
WP(w, menu_d).item_count = item_count; |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
710 |
WP(w, menu_d).sel_index = 0; |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
711 |
WP(w, menu_d).main_button = GB(parent_button, 0, 8); |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
712 |
WP(w, menu_d).action_id = (GB(parent_button, 8, 8) != 0) ? GB(parent_button, 8, 8) : parent_button; |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
713 |
WP(w, menu_d).string_id = base_string; |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
714 |
WP(w, menu_d).checked_items = 0; |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
715 |
WP(w, menu_d).disabled_items = disabled_mask; |
0 | 716 |
|
717 |
_popup_menu_active = true; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
718 |
|
541 | 719 |
SndPlayFx(SND_15_BEEP); |
0 | 720 |
return w; |
721 |
} |
|
722 |
||
8723
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
723 |
Window *PopupMainPlayerToolbMenu(Window *w, int main_button, int gray) |
0 | 724 |
{ |
8723
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
725 |
Point pos;; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
726 |
|
7997
df87ccd00a96
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
7954
diff
changeset
|
727 |
w->LowerWidget(main_button); |
8028
e578ea22f371
(svn r11588) -Codechange: use the new member introduced in r11551
glx
parents:
7997
diff
changeset
|
728 |
w->InvalidateWidget(main_button); |
0 | 729 |
|
730 |
DeleteWindowById(WC_TOOLBAR_MENU, 0); |
|
8723
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
731 |
pos = GetToolbarDropdownPos(main_button, 241, 82); |
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
732 |
w = AllocateWindow(pos.x, pos.y, 241, 82, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets); |
0 | 733 |
w->flags4 &= ~WF_WHITE_BORDER_MASK; |
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
734 |
WP(w, menu_d).item_count = 0; |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
735 |
WP(w, menu_d).sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0); |
724
a73dec475b53
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
736 |
if (_networking && main_button == 9) { |
4848
45f848b46222
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4830
diff
changeset
|
737 |
if (_local_player != PLAYER_SPECTATOR) { |
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
738 |
WP(w, menu_d).sel_index++; |
2639 | 739 |
} else { |
724
a73dec475b53
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
740 |
/* Select client list by default for spectators */ |
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
741 |
WP(w, menu_d).sel_index = 0; |
2639 | 742 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
743 |
} |
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
744 |
WP(w, menu_d).action_id = main_button; |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
745 |
WP(w, menu_d).main_button = main_button; |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
746 |
WP(w, menu_d).checked_items = gray; |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
747 |
WP(w, menu_d).disabled_items = 0; |
0 | 748 |
_popup_menu_active = true; |
541 | 749 |
SndPlayFx(SND_15_BEEP); |
0 | 750 |
return w; |
751 |
} |
|
752 |
||
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
135
diff
changeset
|
753 |
/* Zooms a viewport in a window in or out */ |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
135
diff
changeset
|
754 |
/* No button handling or what so ever */ |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
135
diff
changeset
|
755 |
bool DoZoomInOutWindow(int how, Window *w) |
0 | 756 |
{ |
757 |
ViewPort *vp; |
|
5045
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
758 |
|
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
759 |
assert(w != NULL); |
0 | 760 |
vp = w->viewport; |
761 |
||
5044
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
762 |
switch (how) { |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
763 |
case ZOOM_IN: |
6626
207875b9069a
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
6624
diff
changeset
|
764 |
if (vp->zoom == ZOOM_LVL_MIN) return false; |
8095
f834186120af
(svn r11656) -Codechange: add ZOOM_LVL_BEGIN and postfix operators so ZoomLevel can be used in some iterations
smatz
parents:
8082
diff
changeset
|
765 |
vp->zoom = (ZoomLevel)((int)vp->zoom - 1); |
5044
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
766 |
vp->virtual_width >>= 1; |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
767 |
vp->virtual_height >>= 1; |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
768 |
|
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
769 |
WP(w, vp_d).scrollpos_x += vp->virtual_width >> 1; |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
770 |
WP(w, vp_d).scrollpos_y += vp->virtual_height >> 1; |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
771 |
WP(w, vp_d).dest_scrollpos_x = WP(w,vp_d).scrollpos_x; |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
772 |
WP(w, vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y; |
5044
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
773 |
break; |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
774 |
case ZOOM_OUT: |
6626
207875b9069a
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
6624
diff
changeset
|
775 |
if (vp->zoom == ZOOM_LVL_MAX) return false; |
8095
f834186120af
(svn r11656) -Codechange: add ZOOM_LVL_BEGIN and postfix operators so ZoomLevel can be used in some iterations
smatz
parents:
8082
diff
changeset
|
776 |
vp->zoom = (ZoomLevel)((int)vp->zoom + 1); |
5044
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
777 |
|
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
778 |
WP(w, vp_d).scrollpos_x -= vp->virtual_width >> 1; |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
779 |
WP(w, vp_d).scrollpos_y -= vp->virtual_height >> 1; |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
780 |
WP(w, vp_d).dest_scrollpos_x = WP(w,vp_d).scrollpos_x; |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
781 |
WP(w, vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y; |
5044
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
782 |
|
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
783 |
vp->virtual_width <<= 1; |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
784 |
vp->virtual_height <<= 1; |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
785 |
break; |
0 | 786 |
} |
5214
62a0325b53c7
(svn r7329) -Fix (r7157): Invalid viewport position on quick zoom
KUDr
parents:
5118
diff
changeset
|
787 |
if (vp != NULL) { // the vp can be null when how == ZOOM_NONE |
62a0325b53c7
(svn r7329) -Fix (r7157): Invalid viewport position on quick zoom
KUDr
parents:
5118
diff
changeset
|
788 |
vp->virtual_left = WP(w, vp_d).scrollpos_x; |
62a0325b53c7
(svn r7329) -Fix (r7157): Invalid viewport position on quick zoom
KUDr
parents:
5118
diff
changeset
|
789 |
vp->virtual_top = WP(w, vp_d).scrollpos_y; |
62a0325b53c7
(svn r7329) -Fix (r7157): Invalid viewport position on quick zoom
KUDr
parents:
5118
diff
changeset
|
790 |
} |
5044
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5006
diff
changeset
|
791 |
SetWindowDirty(w); |
5045
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
792 |
/* Update the windows that have zoom-buttons to perhaps disable their buttons */ |
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
793 |
SendWindowMessageClass(w->window_class, how, w->window_number, 0); |
0 | 794 |
return true; |
795 |
} |
|
796 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
797 |
void ZoomInOrOutToCursorWindow(bool in, Window *w) |
0 | 798 |
{ |
8723
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
799 |
assert(w != NULL); |
0 | 800 |
|
4536
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
801 |
if (_game_mode != GM_MENU) { |
8723
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
802 |
ViewPort *vp = w->viewport; |
6626
207875b9069a
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
6624
diff
changeset
|
803 |
if ((in && vp->zoom == ZOOM_LVL_MIN) || (!in && vp->zoom == ZOOM_LVL_MAX)) |
0 | 804 |
return; |
805 |
||
8723
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
806 |
Point pt = GetTileZoomCenterWindow(in,w); |
0 | 807 |
if (pt.x != -1) { |
6730
9311a208f8f7
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
6691
diff
changeset
|
808 |
ScrollWindowTo(pt.x, pt.y, w, true); |
0 | 809 |
|
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
135
diff
changeset
|
810 |
DoZoomInOutWindow(in ? ZOOM_IN : ZOOM_OUT, w); |
0 | 811 |
} |
812 |
} |
|
813 |
} |
|
814 |
||
815 |
||
816 |
extern GetNewsStringCallbackProc * const _get_news_string_callback[]; |
|
817 |
||
818 |
||
7359
35ecb2c98944
(svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents:
7357
diff
changeset
|
819 |
static bool DrawScrollingStatusText(const NewsItem *ni, int pos, int width) |
0 | 820 |
{ |
1336
69391734ce23
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1329
diff
changeset
|
821 |
char buf[512]; |
0 | 822 |
StringID str; |
8584
6e53efd3a137
(svn r12165) -Fix [FS#1652, FS#1773]: buffer overflow when drawing scrolling news
glx
parents:
8529
diff
changeset
|
823 |
const char *s, *last; |
1329 | 824 |
char *d; |
0 | 825 |
DrawPixelInfo tmp_dpi, *old_dpi; |
826 |
int x; |
|
1329 | 827 |
char buffer[256]; |
0 | 828 |
|
7854
8232d650df92
(svn r11404) -Codechange: remove 2 magical numbers
belugas
parents:
7849
diff
changeset
|
829 |
if (ni->display_mode == NM_CALLBACK) { |
0 | 830 |
str = _get_news_string_callback[ni->callback](ni); |
831 |
} else { |
|
7266
b16e67e992b4
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7248
diff
changeset
|
832 |
CopyInDParam(0, ni->params, lengthof(ni->params)); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
833 |
str = ni->string_id; |
0 | 834 |
} |
835 |
||
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4907
diff
changeset
|
836 |
GetString(buf, str, lastof(buf)); |
0 | 837 |
|
1336
69391734ce23
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1329
diff
changeset
|
838 |
s = buf; |
0 | 839 |
d = buffer; |
8584
6e53efd3a137
(svn r12165) -Fix [FS#1652, FS#1773]: buffer overflow when drawing scrolling news
glx
parents:
8529
diff
changeset
|
840 |
last = lastof(buffer); |
0 | 841 |
|
5108
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5107
diff
changeset
|
842 |
for (;;) { |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5107
diff
changeset
|
843 |
WChar c = Utf8Consume(&s); |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5107
diff
changeset
|
844 |
if (c == 0) { |
0 | 845 |
break; |
8584
6e53efd3a137
(svn r12165) -Fix [FS#1652, FS#1773]: buffer overflow when drawing scrolling news
glx
parents:
8529
diff
changeset
|
846 |
} else if (c == 0x0D) { |
6e53efd3a137
(svn r12165) -Fix [FS#1652, FS#1773]: buffer overflow when drawing scrolling news
glx
parents:
8529
diff
changeset
|
847 |
if (d + 4 >= last) break; |
0 | 848 |
d[0] = d[1] = d[2] = d[3] = ' '; |
2639 | 849 |
d += 4; |
5108
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5107
diff
changeset
|
850 |
} else if (IsPrintable(c)) { |
8584
6e53efd3a137
(svn r12165) -Fix [FS#1652, FS#1773]: buffer overflow when drawing scrolling news
glx
parents:
8529
diff
changeset
|
851 |
if (d + Utf8CharLen(c) >= last) break; |
5108
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5107
diff
changeset
|
852 |
d += Utf8Encode(d, c); |
0 | 853 |
} |
854 |
} |
|
8584
6e53efd3a137
(svn r12165) -Fix [FS#1652, FS#1773]: buffer overflow when drawing scrolling news
glx
parents:
8529
diff
changeset
|
855 |
*d = '\0'; |
0 | 856 |
|
7359
35ecb2c98944
(svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents:
7357
diff
changeset
|
857 |
if (!FillDrawPixelInfo(&tmp_dpi, 141, 1, width, 11)) return true; |
0 | 858 |
|
859 |
old_dpi = _cur_dpi; |
|
860 |
_cur_dpi = &tmp_dpi; |
|
861 |
||
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7657
diff
changeset
|
862 |
x = DoDrawString(buffer, pos, 0, TC_LIGHT_BLUE); |
0 | 863 |
_cur_dpi = old_dpi; |
864 |
||
865 |
return x > 0; |
|
866 |
} |
|
867 |
||
410 | 868 |
static void StatusBarWndProc(Window *w, WindowEvent *e) |
0 | 869 |
{ |
1885
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
870 |
switch (e->event) { |
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
871 |
case WE_PAINT: { |
4848
45f848b46222
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4830
diff
changeset
|
872 |
const Player *p = (_local_player == PLAYER_SPECTATOR) ? NULL : GetPlayer(_local_player); |
1885
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
873 |
|
0 | 874 |
DrawWindowWidgets(w); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
875 |
SetDParam(0, _date); |
2639 | 876 |
DrawStringCentered( |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7657
diff
changeset
|
877 |
70, 1, (_pause_game || _patches.status_long_date) ? STR_00AF : STR_00AE, TC_FROMSTRING |
2639 | 878 |
); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
879 |
|
4536
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
880 |
if (p != NULL) { |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
881 |
/* Draw player money */ |
7002
1bf6a62b0fcb
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
6991
diff
changeset
|
882 |
SetDParam(0, p->player_money); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7657
diff
changeset
|
883 |
DrawStringCentered(w->widget[2].left + 70, 1, STR_0004, TC_FROMSTRING); |
0 | 884 |
} |
885 |
||
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
886 |
/* Draw status bar */ |
1885
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
887 |
if (w->message.msg) { // true when saving is active |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7657
diff
changeset
|
888 |
DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_SAVING_GAME, TC_FROMSTRING); |
1885
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
889 |
} else if (_do_autosave) { |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7657
diff
changeset
|
890 |
DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_032F_AUTOSAVE, TC_FROMSTRING); |
6231
ff7454d35935
(svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents:
6201
diff
changeset
|
891 |
} else if (_pause_game) { |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7657
diff
changeset
|
892 |
DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_0319_PAUSED, TC_FROMSTRING); |
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
893 |
} else if (WP(w, def_d).data_1 > -1280 && FindWindowById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) { |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
894 |
/* Draw the scrolling news text */ |
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
895 |
if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w, def_d).data_1, w->widget[1].right - w->widget[1].left - 2)) { |
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
896 |
WP(w, def_d).data_1 = -1280; |
7359
35ecb2c98944
(svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents:
7357
diff
changeset
|
897 |
if (p != NULL) { |
35ecb2c98944
(svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents:
7357
diff
changeset
|
898 |
/* This is the default text */ |
35ecb2c98944
(svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents:
7357
diff
changeset
|
899 |
SetDParam(0, p->index); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7657
diff
changeset
|
900 |
DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_02BA, TC_FROMSTRING); |
7359
35ecb2c98944
(svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents:
7357
diff
changeset
|
901 |
} |
35ecb2c98944
(svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents:
7357
diff
changeset
|
902 |
} |
0 | 903 |
} else { |
4536
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
904 |
if (p != NULL) { |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
905 |
/* This is the default text */ |
7058
8105bb13ce3d
(svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents:
7056
diff
changeset
|
906 |
SetDParam(0, p->index); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7657
diff
changeset
|
907 |
DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_02BA, TC_FROMSTRING); |
0 | 908 |
} |
909 |
} |
|
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
910 |
|
7359
35ecb2c98944
(svn r10722) -Codechange: unhardcode the positions of strings in the status bar.
rubidium
parents:
7357
diff
changeset
|
911 |
if (WP(w, def_d).data_2 > 0) DrawSprite(SPR_BLOT, PALETTE_TO_RED, w->widget[1].right - 11, 2); |
1885
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
912 |
} break; |
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
913 |
|
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
914 |
case WE_MESSAGE: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
915 |
w->message.msg = e->we.message.msg; |
1885
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
916 |
SetWindowDirty(w); |
0 | 917 |
break; |
918 |
||
919 |
case WE_CLICK: |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
920 |
switch (e->we.click.widget) { |
1885
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
921 |
case 1: ShowLastNewsMessage(); break; |
4848
45f848b46222
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4830
diff
changeset
|
922 |
case 2: if (_local_player != PLAYER_SPECTATOR) ShowPlayerFinances(_local_player); break; |
1885
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1820
diff
changeset
|
923 |
default: ResetObjectToPlace(); |
0 | 924 |
} |
925 |
break; |
|
926 |
||
927 |
case WE_TICK: { |
|
6231
ff7454d35935
(svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents:
6201
diff
changeset
|
928 |
if (_pause_game) return; |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
929 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
930 |
if (WP(w, def_d).data_1 > -1280) { // Scrolling text |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
931 |
WP(w, def_d).data_1 -= 2; |
8028
e578ea22f371
(svn r11588) -Codechange: use the new member introduced in r11551
glx
parents:
7997
diff
changeset
|
932 |
w->InvalidateWidget(1); |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
933 |
} |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
934 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
935 |
if (WP(w, def_d).data_2 > 0) { // Red blot to show there are new unread newsmessages |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
936 |
WP(w, def_d).data_2 -= 2; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
937 |
} else if (WP(w, def_d).data_2 < 0) { |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
938 |
WP(w, def_d).data_2 = 0; |
8028
e578ea22f371
(svn r11588) -Codechange: use the new member introduced in r11551
glx
parents:
7997
diff
changeset
|
939 |
w->InvalidateWidget(1); |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
940 |
} |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1657
diff
changeset
|
941 |
|
0 | 942 |
break; |
943 |
} |
|
944 |
} |
|
945 |
} |
|
946 |
||
947 |
static const Widget _main_status_widgets[] = { |
|
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
948 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 139, 0, 11, 0x0, STR_NULL}, |
7360
113ae4cb8aad
(svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents:
7359
diff
changeset
|
949 |
{ WWT_PUSHBTN, RESIZE_RIGHT, 14, 140, 179, 0, 11, 0x0, STR_02B7_SHOW_LAST_MESSAGE_OR_NEWS}, |
113ae4cb8aad
(svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents:
7359
diff
changeset
|
950 |
{ WWT_PUSHBTN, RESIZE_LR, 14, 180, 319, 0, 11, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
951 |
{ WIDGETS_END}, |
0 | 952 |
}; |
953 |
||
954 |
static WindowDesc _main_status_desc = { |
|
7360
113ae4cb8aad
(svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
rubidium
parents:
7359
diff
changeset
|
955 |
WDP_CENTER, 0, 320, 12, 640, 12, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5890
diff
changeset
|
956 |
WC_STATUS_BAR, WC_NONE, |
0 | 957 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
958 |
_main_status_widgets, |
|
959 |
StatusBarWndProc |
|
960 |
}; |
|
961 |
||
6247 | 962 |
extern void UpdateAllStationVirtCoord(); |
0 | 963 |
|
4171 | 964 |
static void MainWindowWndProc(Window *w, WindowEvent *e) |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4013
diff
changeset
|
965 |
{ |
0 | 966 |
int off_x; |
967 |
||
2952 | 968 |
switch (e->event) { |
0 | 969 |
case WE_PAINT: |
970 |
DrawWindowViewport(w); |
|
971 |
if (_game_mode == GM_MENU) { |
|
581
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
972 |
off_x = _screen.width / 2; |
0 | 973 |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
974 |
DrawSprite(SPR_OTTD_O, PAL_NONE, off_x - 120, 50); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
975 |
DrawSprite(SPR_OTTD_P, PAL_NONE, off_x - 86, 50); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
976 |
DrawSprite(SPR_OTTD_E, PAL_NONE, off_x - 53, 50); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
977 |
DrawSprite(SPR_OTTD_N, PAL_NONE, off_x - 22, 50); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
978 |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
979 |
DrawSprite(SPR_OTTD_T, PAL_NONE, off_x + 34, 50); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
980 |
DrawSprite(SPR_OTTD_T, PAL_NONE, off_x + 65, 50); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
981 |
DrawSprite(SPR_OTTD_D, PAL_NONE, off_x + 96, 50); |
670
d164965bb35a
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
658
diff
changeset
|
982 |
|
581
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
983 |
/* |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
984 |
DrawSprite(SPR_OTTD_R, off_x + 119, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
985 |
DrawSprite(SPR_OTTD_A, off_x + 148, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
986 |
DrawSprite(SPR_OTTD_N, off_x + 181, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
987 |
DrawSprite(SPR_OTTD_S, off_x + 215, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
988 |
DrawSprite(SPR_OTTD_P, off_x + 246, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
989 |
DrawSprite(SPR_OTTD_O, off_x + 275, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
990 |
DrawSprite(SPR_OTTD_R, off_x + 307, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
991 |
DrawSprite(SPR_OTTD_T, off_x + 337, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
992 |
|
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
993 |
DrawSprite(SPR_OTTD_T, off_x + 390, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
994 |
DrawSprite(SPR_OTTD_Y, off_x + 417, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
995 |
DrawSprite(SPR_OTTD_C, off_x + 447, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
996 |
DrawSprite(SPR_OTTD_O, off_x + 478, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
997 |
DrawSprite(SPR_OTTD_O, off_x + 509, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
998 |
DrawSprite(SPR_OTTD_N, off_x + 541, 50); |
3e83b468ee56
(svn r1001) -Changed the title name to OpenTTD. Don't know how this was missed all this time; but is fixed now.
darkvater
parents:
545
diff
changeset
|
999 |
*/ |
0 | 1000 |
} |
1001 |
break; |
|
1002 |
||
1003 |
case WE_KEYPRESS: |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1004 |
switch (e->we.keypress.keycode) { |
2639 | 1005 |
case 'Q' | WKC_CTRL: |
1006 |
case 'Q' | WKC_META: |
|
4548
6165e12570bf
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4536
diff
changeset
|
1007 |
HandleExitGameRequest(); |
2639 | 1008 |
break; |
2501
8d13d08b9232
(svn r3027) -Feature: [OSX] command+q now works in main menu (Tobin)
bjarni
parents:
2469
diff
changeset
|
1009 |
} |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1397
diff
changeset
|
1010 |
|
4536
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
1011 |
/* Disable all key shortcuts, except quit shortcuts when |
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
1012 |
* generating the world, otherwise they create threading |
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
1013 |
* problem during the generating, resulting in random |
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
1014 |
* assertions that are hard to trigger and debug */ |
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
1015 |
if (IsGeneratingWorld()) break; |
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
1016 |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1017 |
if (e->we.keypress.keycode == WKC_BACKQUOTE) { |
4536
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
1018 |
IConsoleSwitch(); |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1019 |
e->we.keypress.cont = false; |
4536
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
1020 |
break; |
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
1021 |
} |
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
1022 |
|
7643
af32b07bc027
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
7521
diff
changeset
|
1023 |
if (e->we.keypress.keycode == ('B' | WKC_CTRL)) { |
af32b07bc027
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
7521
diff
changeset
|
1024 |
e->we.keypress.cont = false; |
af32b07bc027
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
7521
diff
changeset
|
1025 |
_draw_bounding_boxes = !_draw_bounding_boxes; |
af32b07bc027
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
7521
diff
changeset
|
1026 |
MarkWholeScreenDirty(); |
af32b07bc027
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
7521
diff
changeset
|
1027 |
break; |
af32b07bc027
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
7521
diff
changeset
|
1028 |
} |
af32b07bc027
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
7521
diff
changeset
|
1029 |
|
4536
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4512
diff
changeset
|
1030 |
if (_game_mode == GM_MENU) break; |
0 | 1031 |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1032 |
switch (e->we.keypress.keycode) { |
2639 | 1033 |
case 'C': |
1034 |
case 'Z': { |
|
1035 |
Point pt = GetTileBelowCursor(); |
|
1036 |
if (pt.x != -1) { |
|
8176
b45860add89b
(svn r11739) -Fix [FS#1609]: Set the new scroll position after zooming in instead of before, as the zoom will cancel it out.
peter1138
parents:
8157
diff
changeset
|
1037 |
if (e->we.keypress.keycode == 'Z') MaxZoomInOut(ZOOM_IN, w); |
2639 | 1038 |
ScrollMainWindowTo(pt.x, pt.y); |
1039 |
} |
|
1040 |
break; |
|
0 | 1041 |
} |
2639 | 1042 |
|
1043 |
case WKC_ESC: ResetObjectToPlace(); break; |
|
1044 |
case WKC_DELETE: DeleteNonVitalWindows(); break; |
|
1045 |
case WKC_DELETE | WKC_SHIFT: DeleteAllNonVitalWindows(); break; |
|
1046 |
case 'R' | WKC_CTRL: MarkWholeScreenDirty(); break; |
|
1047 |
||
1772
a619792528e9
(svn r2276) - CodeChange: remove DebugProc() and make the ALT+0...4 codes only available in debug mode
Darkvater
parents:
1705
diff
changeset
|
1048 |
#if defined(_DEBUG) |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
1049 |
case '0' | WKC_ALT: // Crash the game |
2639 | 1050 |
*(byte*)0 = 0; |
1051 |
break; |
|
1052 |
||
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
1053 |
case '1' | WKC_ALT: // Gimme money |
2639 | 1054 |
/* Server can not cheat in advertise mode either! */ |
1055 |
if (!_networking || !_network_server || !_network_advertise) |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1056 |
DoCommandP(0, 10000000, 0, NULL, CMD_MONEY_CHEAT); |
2639 | 1057 |
break; |
1058 |
||
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
1059 |
case '2' | WKC_ALT: // Update the coordinates of all station signs |
2639 | 1060 |
UpdateAllStationVirtCoord(); |
1061 |
break; |
|
1062 |
#endif |
|
1063 |
||
6427
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6357
diff
changeset
|
1064 |
case '1' | WKC_CTRL: |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6357
diff
changeset
|
1065 |
case '2' | WKC_CTRL: |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6357
diff
changeset
|
1066 |
case '3' | WKC_CTRL: |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6357
diff
changeset
|
1067 |
case '4' | WKC_CTRL: |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6357
diff
changeset
|
1068 |
case '5' | WKC_CTRL: |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6357
diff
changeset
|
1069 |
case '6' | WKC_CTRL: |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6357
diff
changeset
|
1070 |
case '7' | WKC_CTRL: |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
7824
diff
changeset
|
1071 |
case '8' | WKC_CTRL: |
8529
93d4dea423e5
(svn r12104) -Fix (r12103): remember loading indicators transparency settings and make in switchable by Ctrl+9
smatz
parents:
8452
diff
changeset
|
1072 |
case '9' | WKC_CTRL: |
6427
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6357
diff
changeset
|
1073 |
/* Transparency toggle hot keys */ |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
7824
diff
changeset
|
1074 |
ToggleTransparency((TransparencyOption)(e->we.keypress.keycode - ('1' | WKC_CTRL))); |
2639 | 1075 |
MarkWholeScreenDirty(); |
1076 |
break; |
|
0 | 1077 |
|
6427
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6357
diff
changeset
|
1078 |
case 'X' | WKC_CTRL: |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6357
diff
changeset
|
1079 |
ShowTransparencyToolbar(); |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6357
diff
changeset
|
1080 |
break; |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6357
diff
changeset
|
1081 |
|
6494
b41e51f3c9ef
(svn r9677) -Codechange: Make the 'transparent buildings' menu item toggle all transparency, to keep its old behaviour.
peter1138
parents:
6492
diff
changeset
|
1082 |
case 'X': |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
7824
diff
changeset
|
1083 |
ResetRestoreAllTransparency(); |
6427
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6357
diff
changeset
|
1084 |
break; |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6357
diff
changeset
|
1085 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1086 |
#ifdef ENABLE_NETWORK |
5107
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
1087 |
case WKC_RETURN: case 'T': // smart chat; send to team if any, otherwise to all |
4887
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
1088 |
if (_networking) { |
5107
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
1089 |
const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_index); |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
1090 |
bool teamchat = false; |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
1091 |
|
5672
86ab5e4289a5
(svn r8132) -Fix (r6824): The game could crash when the chat key (<ENTER>) is pressed too vehemently during the join of the game. Your client's id does not exist in the clients list yet, and returns NULL.
Darkvater
parents:
5668
diff
changeset
|
1092 |
if (cio == NULL) break; |
86ab5e4289a5
(svn r8132) -Fix (r6824): The game could crash when the chat key (<ENTER>) is pressed too vehemently during the join of the game. Your client's id does not exist in the clients list yet, and returns NULL.
Darkvater
parents:
5668
diff
changeset
|
1093 |
|
5107
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
1094 |
/* Only players actually playing can speak to team. Eg spectators cannot */ |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
1095 |
if (_patches.prefer_teamchat && IsValidPlayer(cio->client_playas)) { |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
1096 |
const NetworkClientInfo *ci; |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
1097 |
FOR_ALL_ACTIVE_CLIENT_INFOS(ci) { |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
1098 |
if (ci->client_playas == cio->client_playas && ci != cio) { |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
1099 |
teamchat = true; |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
1100 |
break; |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
1101 |
} |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
1102 |
} |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
1103 |
} |
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
1104 |
|
f3cddd9ce5f4
(svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents:
5102
diff
changeset
|
1105 |
ShowNetworkChatQueryWindow(teamchat ? DESTTYPE_TEAM : DESTTYPE_BROADCAST, cio->client_playas); |
4887
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
1106 |
} |
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
1107 |
break; |
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
1108 |
|
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
1109 |
case WKC_SHIFT | WKC_RETURN: case WKC_SHIFT | 'T': // send text message to all players |
2639 | 1110 |
if (_networking) ShowNetworkChatQueryWindow(DESTTYPE_BROADCAST, 0); |
1111 |
break; |
|
4887
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
1112 |
|
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
1113 |
case WKC_CTRL | WKC_RETURN: case WKC_CTRL | 'T': // send text to all team mates |
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
1114 |
if (_networking) { |
5672
86ab5e4289a5
(svn r8132) -Fix (r6824): The game could crash when the chat key (<ENTER>) is pressed too vehemently during the join of the game. Your client's id does not exist in the clients list yet, and returns NULL.
Darkvater
parents:
5668
diff
changeset
|
1115 |
const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_index); |
86ab5e4289a5
(svn r8132) -Fix (r6824): The game could crash when the chat key (<ENTER>) is pressed too vehemently during the join of the game. Your client's id does not exist in the clients list yet, and returns NULL.
Darkvater
parents:
5668
diff
changeset
|
1116 |
if (cio == NULL) break; |
86ab5e4289a5
(svn r8132) -Fix (r6824): The game could crash when the chat key (<ENTER>) is pressed too vehemently during the join of the game. Your client's id does not exist in the clients list yet, and returns NULL.
Darkvater
parents:
5668
diff
changeset
|
1117 |
|
86ab5e4289a5
(svn r8132) -Fix (r6824): The game could crash when the chat key (<ENTER>) is pressed too vehemently during the join of the game. Your client's id does not exist in the clients list yet, and returns NULL.
Darkvater
parents:
5668
diff
changeset
|
1118 |
ShowNetworkChatQueryWindow(DESTTYPE_TEAM, cio->client_playas); |
4887
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
1119 |
} |
71da70810c22
(svn r6824) -Feature: Change the functionality of the chat window. SHIFT+ENTER (SHIFT+T)
Darkvater
parents:
4848
diff
changeset
|
1120 |
break; |
1772
a619792528e9
(svn r2276) - CodeChange: remove DebugProc() and make the ALT+0...4 codes only available in debug mode
Darkvater
parents:
1705
diff
changeset
|
1121 |
#endif |
a619792528e9
(svn r2276) - CodeChange: remove DebugProc() and make the ALT+0...4 codes only available in debug mode
Darkvater
parents:
1705
diff
changeset
|
1122 |
|
2639 | 1123 |
default: return; |
0 | 1124 |
} |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1125 |
e->we.keypress.cont = false; |
0 | 1126 |
break; |
4335
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
1127 |
|
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
1128 |
case WE_SCROLL: { |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
1129 |
ViewPort *vp = IsPtInWindowViewport(w, _cursor.pos.x, _cursor.pos.y); |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
1130 |
|
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
1131 |
if (vp == NULL) { |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
1132 |
_cursor.fix_at = false; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
1133 |
_scrolling_viewport = false; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
1134 |
} |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
1135 |
|
6654
31d17823506f
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight
parents:
6626
diff
changeset
|
1136 |
WP(w, vp_d).scrollpos_x += ScaleByZoom(e->we.scroll.delta.x, vp->zoom); |
31d17823506f
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight
parents:
6626
diff
changeset
|
1137 |
WP(w, vp_d).scrollpos_y += ScaleByZoom(e->we.scroll.delta.y, vp->zoom); |
6730
9311a208f8f7
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
6691
diff
changeset
|
1138 |
WP(w, vp_d).dest_scrollpos_x = WP(w, vp_d).scrollpos_x; |
9311a208f8f7
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
6691
diff
changeset
|
1139 |
WP(w, vp_d).dest_scrollpos_y = WP(w, vp_d).scrollpos_y; |
4335
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4300
diff
changeset
|
1140 |
} break; |
4337
e705eef174bf
(svn r6038) -Codechange: move mousewheel code to event WE_MOUSEWHEEL instead of a general function that handles that
truelight
parents:
4335
diff
changeset
|
1141 |
|
e705eef174bf
(svn r6038) -Codechange: move mousewheel code to event WE_MOUSEWHEEL instead of a general function that handles that
truelight
parents:
4335
diff
changeset
|
1142 |
case WE_MOUSEWHEEL: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4548
diff
changeset
|
1143 |
ZoomInOrOutToCursorWindow(e->we.wheel.wheel < 0, w); |
4337
e705eef174bf
(svn r6038) -Codechange: move mousewheel code to event WE_MOUSEWHEEL instead of a general function that handles that
truelight
parents:
4335
diff
changeset
|
1144 |
break; |
5045
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
1145 |
|
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
1146 |
case WE_MESSAGE: |
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
1147 |
/* Forward the message to the appropiate toolbar (ingame or scenario editor) */ |
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
1148 |
SendWindowMessage(WC_MAIN_TOOLBAR, 0, e->we.message.msg, e->we.message.wparam, e->we.message.lparam); |
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
1149 |
break; |
0 | 1150 |
} |
1151 |
} |
|
1152 |
||
1153 |
||
6247 | 1154 |
void ShowSelectGameWindow(); |
1155 |
||
1156 |
void SetupColorsAndInitialWindow() |
|
0 | 1157 |
{ |
2639 | 1158 |
uint i; |
0 | 1159 |
Window *w; |
5413 | 1160 |
int width, height; |
0 | 1161 |
|
2639 | 1162 |
for (i = 0; i != 16; i++) { |
4171 | 1163 |
const byte *b = GetNonSprite(PALETTE_RECOLOR_START + i); |
1357 | 1164 |
|
0 | 1165 |
assert(b); |
4444
8d40844e6755
(svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents:
4434
diff
changeset
|
1166 |
memcpy(_colour_gradient[i], b + 0xC6, sizeof(_colour_gradient[i])); |
0 | 1167 |
} |
1168 |
||
1169 |
width = _screen.width; |
|
1170 |
height = _screen.height; |
|
1171 |
||
5432
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
1172 |
w = AllocateWindow(0, 0, width, height, MainWindowWndProc, WC_MAIN_WINDOW, NULL); |
6624
880e29b1f25e
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
6591
diff
changeset
|
1173 |
AssignWindowViewport(w, 0, 0, width, height, TileXY(32, 32), ZOOM_LVL_VIEWPORT); |
5432
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
1174 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
5894
diff
changeset
|
1175 |
/* XXX: these are not done */ |
2639 | 1176 |
switch (_game_mode) { |
5432
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
1177 |
default: NOT_REACHED(); |
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
1178 |
case GM_MENU: |
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
1179 |
ShowSelectGameWindow(); |
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
1180 |
break; |
0 | 1181 |
|
5432
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
1182 |
case GM_NORMAL: |
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
1183 |
case GM_EDITOR: |
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
1184 |
ShowVitalWindows(); |
5940d6a253c5
(svn r7638) -Codechange: Remove special window ShowJoinStatusWindowAfterJoin and shuffle around
Darkvater
parents:
5431
diff
changeset
|
1185 |
break; |
0 | 1186 |
} |
1187 |
} |
|
1188 |
||
6247 | 1189 |
void ShowVitalWindows() |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
1190 |
{ |
8723
e513a23c2797
(svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium
parents:
8615
diff
changeset
|
1191 |
Window *w = AllocateToolbar(); |
5048
b784951def0a
(svn r7098) -Regression (r7094): Zoom buttons were not properly updated with a new/loaded game. The
Darkvater
parents:
5046
diff
changeset
|
1192 |
DoZoomInOutWindow(ZOOM_NONE, w); |
b784951def0a
(svn r7098) -Regression (r7094): Zoom buttons were not properly updated with a new/loaded game. The
Darkvater
parents:
5046
diff
changeset
|
1193 |
|
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
1194 |
CLRBITS(w->flags4, WF_WHITE_BORDER_MASK); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
1195 |
|
7997
df87ccd00a96
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
7954
diff
changeset
|
1196 |
w->SetWidgetDisabledState(0, _networking && !_network_server); // if not server, disable pause button |
df87ccd00a96
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
7954
diff
changeset
|
1197 |
w->SetWidgetDisabledState(1, _networking); // if networking, disable fast-forward button |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1015
diff
changeset
|
1198 |
|
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1199 |
/* 'w' is for sure a WC_MAIN_TOOLBAR */ |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1200 |
PositionMainToolbar(w); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1201 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1202 |
/* Status bad only for normal games */ |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4299
diff
changeset
|
1203 |
if (_game_mode == GM_EDITOR) return; |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
1204 |
|
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
1205 |
_main_status_desc.top = _screen.height - 12; |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
1206 |
w = AllocateWindowDesc(&_main_status_desc); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
1207 |
CLRBITS(w->flags4, WF_WHITE_BORDER_MASK); |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
1208 |
|
8082
63240e1bd6cc
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents:
8070
diff
changeset
|
1209 |
WP(w, def_d).data_1 = -1280; |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
1210 |
} |
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
1211 |
|
6247 | 1212 |
void GameSizeChanged() |
0 | 1213 |
{ |
2429
5e5b66fb8420
(svn r2955) Fix: make ottd start with the last resolution you had set (custom) (win32)
Darkvater
parents:
2361
diff
changeset
|
1214 |
_cur_resolution[0] = _screen.width; |
5e5b66fb8420
(svn r2955) Fix: make ottd start with the last resolution you had set (custom) (win32)
Darkvater
parents:
2361
diff
changeset
|
1215 |
_cur_resolution[1] = _screen.height; |
0 | 1216 |
RelocateAllWindows(_screen.width, _screen.height); |
1217 |
ScreenSizeChanged(); |
|
1218 |
MarkWholeScreenDirty(); |
|
1219 |
} |
|
3622
730fd3cd0050
(svn r4520) -Fix: Did last commit in the wrong branch. Repair and shame on me.
celestar
parents:
3469
diff
changeset
|
1220 |
|
6247 | 1221 |
void InitializeMainGui() |
3622
730fd3cd0050
(svn r4520) -Fix: Did last commit in the wrong branch. Repair and shame on me.
celestar
parents:
3469
diff
changeset
|
1222 |
{ |
730fd3cd0050
(svn r4520) -Fix: Did last commit in the wrong branch. Repair and shame on me.
celestar
parents:
3469
diff
changeset
|
1223 |
/* Clean old GUI values */ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1224 |
_last_built_railtype = RAILTYPE_RAIL; |
6666
41ceafa4c85e
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium
parents:
6654
diff
changeset
|
1225 |
_last_built_roadtype = ROADTYPE_ROAD; |
3622
730fd3cd0050
(svn r4520) -Fix: Did last commit in the wrong branch. Repair and shame on me.
celestar
parents:
3469
diff
changeset
|
1226 |
} |
5116
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5108
diff
changeset
|
1227 |
|
5237
4fce3ea379c2
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
5235
diff
changeset
|
1228 |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
1229 |
|
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7657
diff
changeset
|
1230 |
|
8056
ae85cb9a770d
(svn r11617) -Feature(ette): Add the same game-mode keyboard shortcuts in scenario more.(Bilbo)
belugas
parents:
8036
diff
changeset
|
1231 |