author | Darkvater |
Sat, 12 Mar 2005 21:21:47 +0000 | |
changeset 1500 | 228f77e88adf |
parent 1397 | b04402b901cd |
child 1542 | 2ca6d1624e6d |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
1349
07514c2cc6d1
(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
|
3 |
#include "spritecache.h" |
1309
dab90d4cbf2d
(svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents:
1230
diff
changeset
|
4 |
#include "strings.h" |
1363
01d3de5d8039
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1362
diff
changeset
|
5 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
497
diff
changeset
|
6 |
#include "table/strings.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
670
diff
changeset
|
7 |
#include "map.h" |
1209
a1ac96655b79
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1199
diff
changeset
|
8 |
#include "tile.h" |
0 | 9 |
#include "window.h" |
10 |
#include "gui.h" |
|
11 |
#include "viewport.h" |
|
12 |
#include "gfx.h" |
|
13 |
#include "player.h" |
|
14 |
#include "command.h" |
|
15 |
#include "news.h" |
|
16 |
#include "town.h" |
|
130
b593afdae262
(svn r131) Completely changed hotkey from tab to backquote (not working in Windows yet)
dominik
parents:
126
diff
changeset
|
17 |
#include "vehicle.h" |
126 | 18 |
#include "console.h" |
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
222
diff
changeset
|
19 |
#include "sound.h" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
20 |
#include "network.h" |
988
2482369a61ff
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
983
diff
changeset
|
21 |
#include "signs.h" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
22 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
23 |
#ifdef ENABLE_NETWORK |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
24 |
#include "network_data.h" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
25 |
#include "network_client.h" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
26 |
#include "network_server.h" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
27 |
#endif /* ENABLE_NETWORK */ |
0 | 28 |
|
29 |
#include "table/animcursors.h" |
|
30 |
||
31 |
||
349
47cdc8ab9cf7
(svn r532) Disable date change buttons in scenario editor if date limit is reached.
tron
parents:
337
diff
changeset
|
32 |
/* Min/Max date for scenario editor */ |
970
492ca84ecc6c
(svn r1465) -Fix: [1099101] starting year patch goes out of range. Clamped year between 1920-2090 as wel as adding defines for it.
darkvater
parents:
926
diff
changeset
|
33 |
static const uint MinDate = 0; // 1920-01-01 (MAX_YEAR_BEGIN_REAL) |
349
47cdc8ab9cf7
(svn r532) Disable date change buttons in scenario editor if date limit is reached.
tron
parents:
337
diff
changeset
|
34 |
static const uint MaxDate = 29220; // 2000-01-01 |
47cdc8ab9cf7
(svn r532) Disable date change buttons in scenario editor if date limit is reached.
tron
parents:
337
diff
changeset
|
35 |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
36 |
extern void DoTestSave(void); |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
37 |
extern void DoTestLoad(void); |
0 | 38 |
|
39 |
extern bool disable_computer; |
|
40 |
||
41 |
static int _rename_id; |
|
42 |
static int _rename_what; |
|
43 |
||
44 |
static byte _terraform_size = 1; |
|
45 |
static byte _last_built_railtype; |
|
1218 | 46 |
extern void GenerateWorld(int mode, uint log_x, uint log_y); |
0 | 47 |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
48 |
extern void GenerateIndustries(void); |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
49 |
extern void GenerateTowns(void); |
0 | 50 |
|
545
6e8767542192
(svn r945) -Fix: [Network] Terraform callback went wrong in merge
truelight
parents:
543
diff
changeset
|
51 |
extern void CcTerraform(bool success, uint tile, uint32 p1, uint32 p2); |
6e8767542192
(svn r945) -Fix: [Network] Terraform callback went wrong in merge
truelight
parents:
543
diff
changeset
|
52 |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
53 |
void HandleOnEditTextCancel(void) |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
54 |
{ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
55 |
switch(_rename_what) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
56 |
#ifdef ENABLE_NETWORK |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
57 |
case 4: |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
58 |
NetworkDisconnect(); |
611
2d4d7e3a94b8
(svn r1035) Fix: Added a line that I accidentally deleted in r1033
dominik
parents:
609
diff
changeset
|
59 |
ShowNetworkGameWindow(); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
60 |
break; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
61 |
#endif /* ENABLE_NETWORK */ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
62 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
63 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
64 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
65 |
void HandleOnEditText(WindowEvent *e) { |
1323
41397685320a
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1309
diff
changeset
|
66 |
const char *b = e->edittext.str; |
0 | 67 |
int id; |
68 |
memcpy(_decode_parameters, b, 32); |
|
69 |
||
70 |
id = _rename_id; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
71 |
|
0 | 72 |
switch(_rename_what) { |
73 |
case 0: |
|
74 |
// for empty string send "remove sign" parameter |
|
1165
2cdf7a0e217a
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1152
diff
changeset
|
75 |
DoCommandP(0, id, (*b==0)?OWNER_NONE:_current_player, NULL, CMD_RENAME_SIGN | CMD_MSG(STR_280C_CAN_T_CHANGE_SIGN_NAME)); |
0 | 76 |
break; |
77 |
case 1: |
|
78 |
if(*b == 0) |
|
79 |
return; |
|
395
4c990f33dab7
(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
|
80 |
DoCommandP(0, id, 0, NULL, CMD_RENAME_WAYPOINT | CMD_MSG(STR_CANT_CHANGE_WAYPOINT_NAME)); |
0 | 81 |
break; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
82 |
#ifdef ENABLE_NETWORK |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
83 |
case 2: |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
84 |
// Speak to.. |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
85 |
if (!_network_server) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
86 |
SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_CHAT + (id & 0xFF), id & 0xFF, (id >> 8) & 0xFF, e->edittext.str); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
87 |
else |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
88 |
NetworkServer_HandleChat(NETWORK_ACTION_CHAT + (id & 0xFF), id & 0xFF, (id >> 8) & 0xFF, e->edittext.str, NETWORK_SERVER_INDEX); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
89 |
break; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
90 |
case 3: { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
91 |
// Give money |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
92 |
int32 money = atoi(e->edittext.str) / GetCurrentCurrencyRate(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
93 |
char msg[100]; |
813
90d6adb8d4ad
(svn r1284) -Fix: Fixed 'money-cheat' (read: bug which could give people a lot of money)
truelight
parents:
793
diff
changeset
|
94 |
|
815
633faa72f094
(svn r1286) -Fix: oeps, I clamp'd some numbers wrong :$
truelight
parents:
813
diff
changeset
|
95 |
money = clamp(money, 0, 0xFFFFFF); // Clamp between 16 million and 0 |
813
90d6adb8d4ad
(svn r1284) -Fix: Fixed 'money-cheat' (read: bug which could give people a lot of money)
truelight
parents:
793
diff
changeset
|
96 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
97 |
// Give 'id' the money, and substract it from ourself |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
98 |
if (!DoCommandP(0, money, id, NULL, CMD_GIVE_MONEY)) break; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
99 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
100 |
// Inform the player of this action |
722
d0b031be5232
(svn r1174) -Fix: [Network] All strings can now be translated (no more hardcoded strings)
truelight
parents:
697
diff
changeset
|
101 |
snprintf(msg, 100, "%d", money); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
102 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
103 |
if (!_network_server) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
104 |
SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_PLAYER, id + 1, msg); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
105 |
else |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
106 |
NetworkServer_HandleChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_PLAYER, id + 1, msg, NETWORK_SERVER_INDEX); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
107 |
break; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
108 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
109 |
case 4: {// Game-Password and Company-Password |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
110 |
SEND_COMMAND(PACKET_CLIENT_PASSWORD)(id, e->edittext.str); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
111 |
break; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
112 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
113 |
#endif /* ENABLE_NETWORK */ |
0 | 114 |
} |
115 |
} |
|
116 |
||
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
117 |
/** |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
118 |
* This code is shared for the majority of the pushbuttons. |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
119 |
* Handles e.g. the pressing of a button (to build things), playing of click sound and sets certain parameters |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
120 |
* |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
121 |
* @param w Window which called the function |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
122 |
* @param widget ID of the widget (=button) that called this function |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
123 |
* @param cursor How should the cursor image change? E.g. cursor with depot image in it |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
124 |
* @param mode Tile highlighting mode, e.g. drawing a rectangle or a dot on the ground |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
125 |
* @param placeproc Procedure which will be called when someone clicks on the map |
1109
1bab892228cd
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1093
diff
changeset
|
126 |
|
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
127 |
* @return true if the button is clicked, false if it's unclicked |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
128 |
*/ |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1067
diff
changeset
|
129 |
|
0 | 130 |
bool HandlePlacePushButton(Window *w, int widget, uint32 cursor, int mode, PlaceProc *placeproc) |
131 |
{ |
|
132 |
uint32 mask = 1 << widget; |
|
133 |
||
134 |
if (w->disabled_state & mask) |
|
135 |
return false; |
|
136 |
||
541 | 137 |
if (!_no_button_sound) SndPlayFx(SND_15_BEEP); |
0 | 138 |
SetWindowDirty(w); |
139 |
||
140 |
if (w->click_state & mask) { |
|
141 |
ResetObjectToPlace(); |
|
142 |
return false; |
|
143 |
} |
|
144 |
||
145 |
SetObjectToPlace(cursor, mode, w->window_class, w->window_number); |
|
146 |
w->click_state |= mask; |
|
147 |
_place_proc = placeproc; |
|
148 |
return true; |
|
149 |
} |
|
150 |
||
151 |
||
152 |
void CcPlaySound10(bool success, uint tile, uint32 p1, uint32 p2) |
|
153 |
{ |
|
541 | 154 |
if (success) SndPlayTileFx(SND_12_EXPLOSION, tile); |
0 | 155 |
} |
156 |
||
157 |
||
158 |
typedef void ToolbarButtonProc(Window *w); |
|
159 |
||
160 |
static void ToolbarPauseClick(Window *w) |
|
161 |
{ |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
162 |
if (_networking && !_network_server) { return;} // only server can pause the game |
213
770e504a6e51
(svn r214) -Feature: CMD_NET_INSTANT [just in time command handling over network] (sign_de)
darkvater
parents:
206
diff
changeset
|
163 |
|
1147
3fae4b3e16a0
(svn r1648) -Fix: server can now pause and unpause a game through the console. Use 'pause' and 'unpause'
darkvater
parents:
1109
diff
changeset
|
164 |
if (DoCommandP(0, _pause ? 0 : 1, 0, NULL, CMD_PAUSE)) |
541 | 165 |
SndPlayFx(SND_15_BEEP); |
0 | 166 |
} |
167 |
||
168 |
static void ToolbarFastForwardClick(Window *w) |
|
169 |
{ |
|
170 |
_fast_forward ^= true; |
|
541 | 171 |
SndPlayFx(SND_15_BEEP); |
0 | 172 |
} |
173 |
||
174 |
typedef void MenuClickedProc(int index); |
|
175 |
||
176 |
||
410 | 177 |
static void MenuClickSettings(int index) |
0 | 178 |
{ |
179 |
switch(index) { |
|
180 |
case 0: ShowGameOptions(); return; |
|
181 |
case 1: ShowGameDifficulty(); return; |
|
182 |
case 2: ShowPatchesSelection(); return; |
|
478
19987403ee5d
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents:
424
diff
changeset
|
183 |
case 3: ShowNewgrf(); return; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
184 |
|
1015
bc0d6949d458
(svn r1515) -Removed the 'close ALL windows' from the toolbar since shift+del does this.
darkvater
parents:
1014
diff
changeset
|
185 |
case 5: _display_opt ^= DO_SHOW_TOWN_NAMES; MarkWholeScreenDirty(); return; |
bc0d6949d458
(svn r1515) -Removed the 'close ALL windows' from the toolbar since shift+del does this.
darkvater
parents:
1014
diff
changeset
|
186 |
case 6: _display_opt ^= DO_SHOW_STATION_NAMES; MarkWholeScreenDirty(); return; |
bc0d6949d458
(svn r1515) -Removed the 'close ALL windows' from the toolbar since shift+del does this.
darkvater
parents:
1014
diff
changeset
|
187 |
case 7: _display_opt ^= DO_SHOW_SIGNS; MarkWholeScreenDirty(); return; |
bc0d6949d458
(svn r1515) -Removed the 'close ALL windows' from the toolbar since shift+del does this.
darkvater
parents:
1014
diff
changeset
|
188 |
case 8: _display_opt ^= DO_WAYPOINTS; MarkWholeScreenDirty(); return; |
bc0d6949d458
(svn r1515) -Removed the 'close ALL windows' from the toolbar since shift+del does this.
darkvater
parents:
1014
diff
changeset
|
189 |
case 9: _display_opt ^= DO_FULL_ANIMATION; MarkWholeScreenDirty(); return; |
bc0d6949d458
(svn r1515) -Removed the 'close ALL windows' from the toolbar since shift+del does this.
darkvater
parents:
1014
diff
changeset
|
190 |
case 10: _display_opt ^= DO_FULL_DETAIL; MarkWholeScreenDirty(); return; |
bc0d6949d458
(svn r1515) -Removed the 'close ALL windows' from the toolbar since shift+del does this.
darkvater
parents:
1014
diff
changeset
|
191 |
case 11: _display_opt ^= DO_TRANS_BUILDINGS; MarkWholeScreenDirty(); return; |
0 | 192 |
} |
193 |
} |
|
194 |
||
410 | 195 |
static void MenuClickSaveLoad(int index) |
0 | 196 |
{ |
197 |
if (_game_mode == GM_EDITOR) { |
|
198 |
switch(index) { |
|
199 |
case 0: |
|
200 |
ShowSaveLoadDialog(SLD_SAVE_SCENARIO); |
|
201 |
break; |
|
202 |
case 1: |
|
203 |
ShowSaveLoadDialog(SLD_LOAD_SCENARIO); |
|
204 |
break; |
|
205 |
case 2: |
|
206 |
AskExitToGameMenu(); |
|
207 |
break; |
|
208 |
case 4: |
|
209 |
AskExitGame(); |
|
210 |
break; |
|
211 |
} |
|
212 |
} else { |
|
213 |
switch(index) { |
|
214 |
case 0: |
|
215 |
ShowSaveLoadDialog(SLD_SAVE_GAME); |
|
216 |
break; |
|
217 |
case 1: |
|
218 |
ShowSaveLoadDialog(SLD_LOAD_GAME); |
|
219 |
break; |
|
220 |
case 2: |
|
221 |
AskExitToGameMenu(); |
|
222 |
break; |
|
223 |
case 3: |
|
224 |
AskExitGame(); |
|
225 |
break; |
|
226 |
} |
|
227 |
} |
|
228 |
} |
|
229 |
||
410 | 230 |
static void MenuClickMap(int index) |
0 | 231 |
{ |
232 |
switch(index) { |
|
233 |
case 0: ShowSmallMap(); break; |
|
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
|
234 |
case 1: ShowExtraViewPortWindow(); break; |
0 | 235 |
} |
236 |
} |
|
237 |
||
410 | 238 |
static void MenuClickTown(int index) |
0 | 239 |
{ |
240 |
ShowTownDirectory(); |
|
241 |
} |
|
242 |
||
410 | 243 |
static void MenuClickScenMap(int index) |
0 | 244 |
{ |
245 |
switch(index) { |
|
246 |
case 0: ShowSmallMap(); break; |
|
355
19a08ced3274
(svn r543) -Fix: [ 1064742 ] Editor Map-Menu wrong String
tron
parents:
349
diff
changeset
|
247 |
case 1: ShowExtraViewPortWindow(); break; |
19a08ced3274
(svn r543) -Fix: [ 1064742 ] Editor Map-Menu wrong String
tron
parents:
349
diff
changeset
|
248 |
case 2: ShowTownDirectory(); break; |
0 | 249 |
} |
250 |
} |
|
251 |
||
410 | 252 |
static void MenuClickSubsidies(int index) |
0 | 253 |
{ |
254 |
ShowSubsidiesList(); |
|
255 |
} |
|
256 |
||
410 | 257 |
static void MenuClickStations(int index) |
0 | 258 |
{ |
259 |
ShowPlayerStations(index); |
|
260 |
} |
|
261 |
||
410 | 262 |
static void MenuClickFinances(int index) |
0 | 263 |
{ |
264 |
ShowPlayerFinances(index); |
|
265 |
} |
|
266 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
267 |
#ifdef ENABLE_NETWORK |
1003
5ce43e332bab
(svn r1502) -Fix: [1101889] Crash under windows... stupid typo in player_gui.c ^ should've been &
darkvater
parents:
999
diff
changeset
|
268 |
extern void ShowClientList(void); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
269 |
#endif /* ENABLE_NETWORK */ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
270 |
|
410 | 271 |
static void MenuClickCompany(int index) |
0 | 272 |
{ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
273 |
if (_networking && index == 0) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
274 |
#ifdef ENABLE_NETWORK |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
275 |
ShowClientList(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
276 |
#endif /* ENABLE_NETWORK */ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
277 |
} else { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
278 |
if (_networking) index--; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
279 |
ShowPlayerCompany(index); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
280 |
} |
0 | 281 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
282 |
|
0 | 283 |
|
410 | 284 |
static void MenuClickGraphs(int index) |
0 | 285 |
{ |
286 |
switch(index) { |
|
287 |
case 0: ShowOperatingProfitGraph(); return; |
|
288 |
case 1: ShowIncomeGraph(); return; |
|
289 |
case 2: ShowDeliveredCargoGraph(); return; |
|
290 |
case 3: ShowPerformanceHistoryGraph(); return; |
|
291 |
case 4: ShowCompanyValueGraph(); return; |
|
292 |
case 5: ShowCargoPaymentRates(); return; |
|
293 |
} |
|
294 |
} |
|
295 |
||
410 | 296 |
static void MenuClickLeague(int index) |
0 | 297 |
{ |
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
74
diff
changeset
|
298 |
switch(index) { |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
74
diff
changeset
|
299 |
case 0: ShowCompanyLeagueTable(); return; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
74
diff
changeset
|
300 |
case 1: ShowPerformanceRatingDetail(); return; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
74
diff
changeset
|
301 |
} |
0 | 302 |
} |
303 |
||
410 | 304 |
static void MenuClickIndustry(int index) |
0 | 305 |
{ |
306 |
switch(index) { |
|
197
25749afe81ef
(svn r198) -Fix: [1020269] Different production? Wrong production amount was showed in the industry list window
darkvater
parents:
196
diff
changeset
|
307 |
case 0: ShowIndustryDirectory(); break; |
25749afe81ef
(svn r198) -Fix: [1020269] Different production? Wrong production amount was showed in the industry list window
darkvater
parents:
196
diff
changeset
|
308 |
case 1: ShowBuildIndustryWindow(); break; |
0 | 309 |
} |
310 |
} |
|
311 |
||
410 | 312 |
static void MenuClickShowTrains(int index) |
0 | 313 |
{ |
588 | 314 |
ShowPlayerTrains(index, -1); |
0 | 315 |
} |
316 |
||
410 | 317 |
static void MenuClickShowRoad(int index) |
0 | 318 |
{ |
588 | 319 |
ShowPlayerRoadVehicles(index, -1); |
0 | 320 |
} |
321 |
||
410 | 322 |
static void MenuClickShowShips(int index) |
0 | 323 |
{ |
588 | 324 |
ShowPlayerShips(index, -1); |
0 | 325 |
} |
326 |
||
410 | 327 |
static void MenuClickShowAir(int index) |
0 | 328 |
{ |
588 | 329 |
ShowPlayerAircraft(index, -1); |
0 | 330 |
} |
331 |
||
410 | 332 |
static void MenuClickBuildRail(int index) |
0 | 333 |
{ |
334 |
Player *p = DEREF_PLAYER(_local_player); |
|
335 |
_last_built_railtype = min(index, p->max_railtype-1); |
|
336 |
ShowBuildRailToolbar(_last_built_railtype, -1); |
|
337 |
} |
|
338 |
||
410 | 339 |
static void MenuClickBuildRoad(int index) |
0 | 340 |
{ |
341 |
ShowBuildRoadToolbar(); |
|
342 |
} |
|
343 |
||
410 | 344 |
static void MenuClickBuildWater(int index) |
0 | 345 |
{ |
346 |
ShowBuildDocksToolbar(); |
|
347 |
} |
|
348 |
||
410 | 349 |
static void MenuClickBuildAir(int index) |
0 | 350 |
{ |
351 |
ShowBuildAirToolbar(); |
|
352 |
} |
|
353 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
354 |
#ifdef ENABLE_NETWORK |
649 | 355 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
356 |
void ShowNetworkChatQueryWindow(byte desttype, byte dest) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
357 |
{ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
358 |
_rename_id = desttype + (dest << 8); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
359 |
_rename_what = 2; |
793
0fbdcb357a2c
(svn r1263) -Fix: [Network] Client-names are limited (serverside) to 25 chars
truelight
parents:
774
diff
changeset
|
360 |
ShowChatWindow(STR_EMPTY, STR_NETWORK_CHAT_QUERY_CAPTION, 150, 338, 1, 0); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
361 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
362 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
363 |
void ShowNetworkGiveMoneyWindow(byte player) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
364 |
{ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
365 |
_rename_id = player; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
366 |
_rename_what = 3; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
367 |
ShowQueryString(STR_EMPTY, STR_NETWORK_GIVE_MONEY_CAPTION, 30, 180, 1, 0); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
368 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
369 |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
370 |
void ShowNetworkNeedGamePassword(void) |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
371 |
{ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
372 |
_rename_id = NETWORK_GAME_PASSWORD; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
373 |
_rename_what = 4; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
374 |
ShowQueryString(STR_EMPTY, STR_NETWORK_NEED_GAME_PASSWORD_CAPTION, 20, 180, WC_SELECT_GAME, 0); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
375 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
376 |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
377 |
void ShowNetworkNeedCompanyPassword(void) |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
378 |
{ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
379 |
_rename_id = NETWORK_COMPANY_PASSWORD; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
380 |
_rename_what = 4; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
381 |
ShowQueryString(STR_EMPTY, STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION, 20, 180, WC_SELECT_GAME, 0); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
382 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
383 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
384 |
#endif /* ENABLE_NETWORK */ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
385 |
|
0 | 386 |
void ShowRenameSignWindow(SignStruct *ss) |
387 |
{ |
|
988
2482369a61ff
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
983
diff
changeset
|
388 |
_rename_id = ss->index; |
0 | 389 |
_rename_what = 0; |
390 |
ShowQueryString(ss->str, STR_280B_EDIT_SIGN_TEXT, 30, 180, 1, 0); |
|
391 |
} |
|
392 |
||
395
4c990f33dab7
(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
|
393 |
void ShowRenameWaypointWindow(Waypoint *cp) |
0 | 394 |
{ |
395
4c990f33dab7
(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
|
395 |
int id = cp - _waypoints; |
697
0406d50190f2
(svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents:
682
diff
changeset
|
396 |
|
0406d50190f2
(svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents:
682
diff
changeset
|
397 |
/* Are we allowed to change the name of the waypoint? */ |
0406d50190f2
(svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents:
682
diff
changeset
|
398 |
if (!CheckTileOwnership(cp->xy)) { |
926
bd4312619522
(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
|
399 |
ShowErrorMessage(_error_message, STR_CANT_CHANGE_WAYPOINT_NAME, |
bd4312619522
(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
|
400 |
TileX(cp->xy) * 16, TileY(cp->xy) * 16); |
697
0406d50190f2
(svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents:
682
diff
changeset
|
401 |
return; |
0406d50190f2
(svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents:
682
diff
changeset
|
402 |
} |
0406d50190f2
(svn r1146) -Fix: You can no longer change waypoints whom are owned by somebody else
truelight
parents:
682
diff
changeset
|
403 |
|
0 | 404 |
_rename_id = id; |
405 |
_rename_what = 1; |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
406 |
SetDParam(0, id); |
395
4c990f33dab7
(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
|
407 |
ShowQueryString(STR_WAYPOINT_RAW, STR_EDIT_WAYPOINT_NAME, 30, 180, 1, 0); |
0 | 408 |
} |
409 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
410 |
static void SelectSignTool(void) |
0 | 411 |
{ |
412 |
if (_cursor.sprite == 0x2D2) |
|
413 |
ResetObjectToPlace(); |
|
414 |
else { |
|
415 |
SetObjectToPlace(0x2D2, 1, 1, 0); |
|
416 |
_place_proc = PlaceProc_Sign; |
|
417 |
} |
|
418 |
} |
|
419 |
||
410 | 420 |
static void MenuClickForest(int index) |
0 | 421 |
{ |
422 |
switch(index) { |
|
423 |
case 0: ShowTerraformToolbar(); break; |
|
424 |
case 1: ShowBuildTreesToolbar(); break; |
|
425 |
case 2: SelectSignTool(); break; |
|
426 |
} |
|
427 |
} |
|
428 |
||
410 | 429 |
static void MenuClickMusicWindow(int index) |
0 | 430 |
{ |
431 |
ShowMusicWindow(); |
|
432 |
} |
|
433 |
||
410 | 434 |
static void MenuClickNewspaper(int index) |
0 | 435 |
{ |
436 |
switch(index) { |
|
437 |
case 0: ShowLastNewsMessage(); break; |
|
438 |
case 1: ShowMessageOptions(); break; |
|
439 |
case 2: ShowMessageHistory(); break; |
|
440 |
case 3: ; /* XXX: chat not done */ |
|
441 |
} |
|
442 |
} |
|
443 |
||
410 | 444 |
static void MenuClickHelp(int index) |
0 | 445 |
{ |
446 |
switch(index) { |
|
447 |
case 0: PlaceLandBlockInfo(); break; |
|
448 |
case 2: _make_screenshot = 1; break; |
|
449 |
case 3: _make_screenshot = 2; break; |
|
450 |
case 4: ShowAboutWindow(); break; |
|
451 |
} |
|
452 |
} |
|
453 |
||
454 |
static MenuClickedProc * const _menu_clicked_procs[] = { |
|
455 |
NULL, /* 0 */ |
|
456 |
NULL, /* 1 */ |
|
457 |
MenuClickSettings, /* 2 */ |
|
458 |
MenuClickSaveLoad, /* 3 */ |
|
459 |
MenuClickMap, /* 4 */ |
|
460 |
MenuClickTown, /* 5 */ |
|
461 |
MenuClickSubsidies, /* 6 */ |
|
462 |
MenuClickStations, /* 7 */ |
|
463 |
MenuClickFinances, /* 8 */ |
|
464 |
MenuClickCompany, /* 9 */ |
|
465 |
MenuClickGraphs, /* 10 */ |
|
466 |
MenuClickLeague, /* 11 */ |
|
467 |
MenuClickIndustry, /* 12 */ |
|
468 |
MenuClickShowTrains, /* 13 */ |
|
469 |
MenuClickShowRoad, /* 14 */ |
|
470 |
MenuClickShowShips, /* 15 */ |
|
471 |
MenuClickShowAir, /* 16 */ |
|
472 |
MenuClickScenMap, /* 17 */ |
|
473 |
NULL, /* 18 */ |
|
474 |
MenuClickBuildRail, /* 19 */ |
|
475 |
MenuClickBuildRoad, /* 20 */ |
|
476 |
MenuClickBuildWater, /* 21 */ |
|
477 |
MenuClickBuildAir, /* 22 */ |
|
478 |
MenuClickForest, /* 23 */ |
|
479 |
MenuClickMusicWindow, /* 24 */ |
|
480 |
MenuClickNewspaper, /* 25 */ |
|
481 |
MenuClickHelp, /* 26 */ |
|
482 |
}; |
|
483 |
||
484 |
static void MenuWndProc(Window *w, WindowEvent *e) |
|
485 |
{ |
|
486 |
switch(e->event) { |
|
487 |
case WE_PAINT: { |
|
488 |
int count,sel; |
|
489 |
int x,y; |
|
490 |
uint16 chk; |
|
491 |
StringID string; |
|
492 |
int eo; |
|
493 |
int inc; |
|
494 |
||
495 |
DrawWindowWidgets(w); |
|
496 |
||
497 |
count = WP(w,menu_d).item_count; |
|
498 |
sel = WP(w,menu_d).sel_index; |
|
499 |
chk = WP(w,menu_d).checked_items; |
|
500 |
string = WP(w,menu_d).string_id; |
|
501 |
||
502 |
x = 1; |
|
503 |
y = 1; |
|
504 |
||
505 |
eo = 157; |
|
506 |
||
507 |
inc = (chk != 0) ? 2 : 1; |
|
508 |
||
509 |
do { |
|
510 |
if (sel== 0) GfxFillRect(x, y, x + eo, y+9, 0); |
|
511 |
DrawString(x + 2, y, (StringID)(string + (chk&1)), (byte)(sel==0?(byte)0xC:(byte)0x10)); |
|
512 |
y += 10; |
|
513 |
string += inc; |
|
514 |
chk >>= 1; |
|
515 |
} while (--sel,--count); |
|
516 |
} break; |
|
517 |
||
518 |
case WE_DESTROY: { |
|
519 |
Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0); |
|
520 |
v->click_state &= ~(1 << WP(w,menu_d).main_button); |
|
521 |
SetWindowDirty(v); |
|
522 |
return; |
|
523 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
524 |
|
0 | 525 |
case WE_POPUPMENU_SELECT: { |
526 |
int index = GetMenuItemIndex(w, e->popupmenu.pt.x, e->popupmenu.pt.y); |
|
527 |
int action_id; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
528 |
|
0 | 529 |
|
530 |
if (index < 0) { |
|
531 |
Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0); |
|
532 |
if (GetWidgetFromPos(w2, e->popupmenu.pt.x - w2->left, e->popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button) |
|
533 |
index = WP(w,menu_d).sel_index; |
|
534 |
} |
|
535 |
||
536 |
action_id = WP(w,menu_d).action_id; |
|
537 |
DeleteWindow(w); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
538 |
|
0 | 539 |
if (index >= 0) |
540 |
_menu_clicked_procs[action_id](index); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
541 |
|
0 | 542 |
break; |
543 |
} |
|
544 |
case WE_POPUPMENU_OVER: { |
|
545 |
int index = GetMenuItemIndex(w, e->popupmenu.pt.x, e->popupmenu.pt.y); |
|
546 |
||
547 |
if (index == -1 || index == WP(w,menu_d).sel_index) |
|
548 |
return; |
|
549 |
||
550 |
WP(w,menu_d).sel_index = index; |
|
551 |
SetWindowDirty(w); |
|
552 |
return; |
|
553 |
} |
|
554 |
} |
|
555 |
} |
|
556 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
557 |
static const Widget _menu_widgets[] = { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
558 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 159, 0, 65535, 0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
559 |
{ WIDGETS_END}, |
0 | 560 |
}; |
561 |
||
562 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
563 |
static const Widget _player_menu_widgets[] = { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
564 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 240, 0, 81, 0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
565 |
{ WIDGETS_END}, |
0 | 566 |
}; |
567 |
||
568 |
||
569 |
static int GetPlayerIndexFromMenu(int index) |
|
570 |
{ |
|
571 |
Player *p; |
|
572 |
||
573 |
if (index >= 0) { |
|
574 |
FOR_ALL_PLAYERS(p) { |
|
575 |
if (p->is_active) { |
|
576 |
if (--index < 0) |
|
577 |
return p->index; |
|
578 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
579 |
} |
0 | 580 |
} |
581 |
return -1; |
|
582 |
} |
|
583 |
||
584 |
static void UpdatePlayerMenuHeight(Window *w) |
|
585 |
{ |
|
586 |
int num = 0; |
|
587 |
Player *p; |
|
588 |
||
589 |
FOR_ALL_PLAYERS(p) { |
|
590 |
if (p->is_active) |
|
591 |
num++; |
|
592 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
593 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
594 |
// Increase one to fit in PlayerList in the menu when |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
595 |
// in network |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
596 |
if (_networking && WP(w,menu_d).main_button == 9) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
597 |
num++; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
598 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
599 |
|
0 | 600 |
if (WP(w,menu_d).item_count != num) { |
601 |
WP(w,menu_d).item_count = num; |
|
602 |
SetWindowDirty(w); |
|
603 |
num = num * 10 + 2; |
|
604 |
w->height = num; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
605 |
w->widget[0].bottom = w->widget[0].top + num - 1; |
0 | 606 |
SetWindowDirty(w); |
607 |
} |
|
608 |
} |
|
609 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
610 |
extern void DrawPlayerIcon(int p, int x, int y); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
611 |
|
0 | 612 |
static void PlayerMenuWndProc(Window *w, WindowEvent *e) |
613 |
{ |
|
614 |
switch(e->event) { |
|
615 |
case WE_PAINT: { |
|
616 |
int x,y; |
|
617 |
byte sel, color; |
|
618 |
Player *p; |
|
619 |
uint16 chk; |
|
620 |
||
621 |
UpdatePlayerMenuHeight(w); |
|
622 |
DrawWindowWidgets(w); |
|
623 |
||
624 |
x = 1; |
|
625 |
y = 1; |
|
626 |
sel = WP(w,menu_d).sel_index; |
|
627 |
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
|
628 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
629 |
// 9 = playerlist |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
630 |
if (_networking && WP(w,menu_d).main_button == 9) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
631 |
if (sel == 0) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
632 |
GfxFillRect(x, y, x + 238, y + 9, 0); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
633 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
634 |
DrawString(x + 19, y, STR_NETWORK_CLIENT_LIST, 0x0); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
635 |
y += 10; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
636 |
sel--; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
637 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
638 |
|
0 | 639 |
FOR_ALL_PLAYERS(p) { |
640 |
if (p->is_active) { |
|
641 |
if (p->index == sel) { |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
642 |
GfxFillRect(x, y, x + 238, y + 9, 0); |
0 | 643 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
644 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
645 |
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
|
646 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
647 |
SetDParam(0, p->name_1); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
648 |
SetDParam(1, p->name_2); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
649 |
SetDParam(2, GetPlayerNameString(p->index, 3)); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
650 |
|
0 | 651 |
color = (byte)((p->index==sel) ? 0xC : 0x10); |
652 |
if (chk&1) color = 14; |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
653 |
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
|
654 |
|
0 | 655 |
y += 10; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
656 |
} |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
657 |
chk >>= 1; |
0 | 658 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
659 |
|
0 | 660 |
break; |
661 |
} |
|
662 |
||
663 |
case WE_DESTROY: { |
|
664 |
Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0); |
|
665 |
v->click_state &= ~(1 << WP(w,menu_d).main_button); |
|
666 |
SetWindowDirty(v); |
|
667 |
return; |
|
668 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
669 |
|
0 | 670 |
case WE_POPUPMENU_SELECT: { |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
671 |
int index = GetMenuItemIndex(w, e->popupmenu.pt.x, e->popupmenu.pt.y); |
0 | 672 |
int action_id = WP(w,menu_d).action_id; |
673 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
674 |
// We have a new entry at the top of the list of menu 9 when networking |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
675 |
// so keep that in count |
724
082993b2adaa
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
676 |
if (_networking && WP(w,menu_d).main_button == 9) { |
082993b2adaa
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
677 |
if (index > 0) |
082993b2adaa
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
678 |
index = GetPlayerIndexFromMenu(index - 1) + 1; |
082993b2adaa
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
679 |
} else |
082993b2adaa
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
680 |
index = GetPlayerIndexFromMenu(index); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
681 |
|
0 | 682 |
if (index < 0) { |
683 |
Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0); |
|
684 |
if (GetWidgetFromPos(w2, e->popupmenu.pt.x - w2->left, e->popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button) |
|
685 |
index = WP(w,menu_d).sel_index; |
|
686 |
} |
|
687 |
||
688 |
DeleteWindow(w); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
689 |
|
0 | 690 |
if (index >= 0) { |
691 |
assert(index >= 0 && index < 30); |
|
692 |
_menu_clicked_procs[action_id](index); |
|
693 |
} |
|
694 |
break; |
|
695 |
} |
|
696 |
case WE_POPUPMENU_OVER: { |
|
697 |
int index; |
|
698 |
UpdatePlayerMenuHeight(w); |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
699 |
index = GetMenuItemIndex(w, e->popupmenu.pt.x, e->popupmenu.pt.y); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
700 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
701 |
// We have a new entry at the top of the list of menu 9 when networking |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
702 |
// so keep that in count |
724
082993b2adaa
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
703 |
if (_networking && WP(w,menu_d).main_button == 9) { |
082993b2adaa
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
704 |
if (index > 0) |
082993b2adaa
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
705 |
index = GetPlayerIndexFromMenu(index - 1) + 1; |
082993b2adaa
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
706 |
} else |
082993b2adaa
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
707 |
index = GetPlayerIndexFromMenu(index); |
0 | 708 |
|
709 |
if (index == -1 || index == WP(w,menu_d).sel_index) |
|
710 |
return; |
|
711 |
||
712 |
WP(w,menu_d).sel_index = index; |
|
713 |
SetWindowDirty(w); |
|
714 |
return; |
|
715 |
} |
|
716 |
} |
|
717 |
} |
|
718 |
||
719 |
static Window *PopupMainToolbMenu(Window *w, int x, int main_button, StringID base_string, int item_count) |
|
720 |
{ |
|
721 |
x += w->left; |
|
722 |
||
723 |
SETBIT(w->click_state, (byte)main_button); |
|
724 |
InvalidateWidget(w, (byte)main_button); |
|
725 |
||
726 |
DeleteWindowById(WC_TOOLBAR_MENU, 0); |
|
727 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
728 |
w = AllocateWindow(x, 0x16, 0xA0, item_count * 10 + 2, MenuWndProc, WC_TOOLBAR_MENU, _menu_widgets); |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
729 |
w->widget[0].bottom = item_count * 10 + 1; |
0 | 730 |
w->flags4 &= ~WF_WHITE_BORDER_MASK; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
731 |
|
0 | 732 |
WP(w,menu_d).item_count = item_count; |
733 |
WP(w,menu_d).sel_index = 0; |
|
734 |
WP(w,menu_d).main_button = main_button; |
|
735 |
WP(w,menu_d).action_id = (main_button >> 8) ? (main_button >> 8) : main_button; |
|
736 |
WP(w,menu_d).string_id = base_string; |
|
737 |
WP(w,menu_d).checked_items = 0; |
|
738 |
||
739 |
_popup_menu_active = true; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
740 |
|
541 | 741 |
SndPlayFx(SND_15_BEEP); |
0 | 742 |
|
743 |
return w; |
|
744 |
} |
|
745 |
||
746 |
static Window *PopupMainPlayerToolbMenu(Window *w, int x, int main_button, int gray) |
|
747 |
{ |
|
748 |
x += w->left; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
749 |
|
0 | 750 |
SETBIT(w->click_state, main_button); |
751 |
InvalidateWidget(w, main_button); |
|
752 |
||
753 |
DeleteWindowById(WC_TOOLBAR_MENU, 0); |
|
754 |
w = AllocateWindow(x, 0x16, 0xF1, 0x52, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets); |
|
755 |
w->flags4 &= ~WF_WHITE_BORDER_MASK; |
|
756 |
WP(w,menu_d).item_count = 0; |
|
724
082993b2adaa
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
757 |
WP(w,menu_d).sel_index = (_local_player != OWNER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0); |
082993b2adaa
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
758 |
if (_networking && main_button == 9) { |
082993b2adaa
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
759 |
if (_local_player != OWNER_SPECTATOR) |
082993b2adaa
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
760 |
WP(w,menu_d).sel_index++; |
082993b2adaa
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
761 |
else |
082993b2adaa
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
762 |
/* Select client list by default for spectators */ |
082993b2adaa
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
truelight
parents:
722
diff
changeset
|
763 |
WP(w,menu_d).sel_index = 0; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
764 |
} |
0 | 765 |
WP(w,menu_d).action_id = main_button; |
766 |
WP(w,menu_d).main_button = main_button; |
|
767 |
WP(w,menu_d).checked_items = gray; |
|
768 |
_popup_menu_active = true; |
|
541 | 769 |
SndPlayFx(SND_15_BEEP); |
0 | 770 |
return w; |
771 |
} |
|
772 |
||
773 |
static void ToolbarSaveClick(Window *w) |
|
774 |
{ |
|
775 |
PopupMainToolbMenu(w, 66, 3, STR_015C_SAVE_GAME, 4); |
|
776 |
} |
|
777 |
||
778 |
static void ToolbarMapClick(Window *w) |
|
779 |
{ |
|
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
|
780 |
PopupMainToolbMenu(w, 96, 4, STR_02DE_MAP_OF_WORLD, 2); |
0 | 781 |
} |
782 |
||
783 |
static void ToolbarTownClick(Window *w) |
|
784 |
{ |
|
785 |
PopupMainToolbMenu(w, 118, 5, STR_02BB_TOWN_DIRECTORY, 1); |
|
786 |
} |
|
787 |
||
788 |
static void ToolbarSubsidiesClick(Window *w) |
|
789 |
{ |
|
790 |
PopupMainToolbMenu(w, 140, 6, STR_02DD_SUBSIDIES, 1); |
|
791 |
} |
|
792 |
||
793 |
static void ToolbarStationsClick(Window *w) |
|
794 |
{ |
|
795 |
PopupMainPlayerToolbMenu(w, 162, 7, 0); |
|
796 |
} |
|
797 |
||
798 |
static void ToolbarMoneyClick(Window *w) |
|
799 |
{ |
|
800 |
PopupMainPlayerToolbMenu(w, 191, 8, 0); |
|
801 |
} |
|
802 |
||
803 |
static void ToolbarPlayersClick(Window *w) |
|
804 |
{ |
|
805 |
PopupMainPlayerToolbMenu(w, 213, 9, 0); |
|
806 |
} |
|
807 |
||
808 |
static void ToolbarGraphsClick(Window *w) |
|
809 |
{ |
|
810 |
PopupMainToolbMenu(w, 236, 10, STR_0154_OPERATING_PROFIT_GRAPH, 6); |
|
811 |
} |
|
812 |
||
813 |
static void ToolbarLeagueClick(Window *w) |
|
814 |
{ |
|
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
74
diff
changeset
|
815 |
PopupMainToolbMenu(w, 258, 11, STR_015A_COMPANY_LEAGUE_TABLE, 2); |
0 | 816 |
} |
817 |
||
818 |
static void ToolbarIndustryClick(Window *w) |
|
819 |
{ |
|
197
25749afe81ef
(svn r198) -Fix: [1020269] Different production? Wrong production amount was showed in the industry list window
darkvater
parents:
196
diff
changeset
|
820 |
PopupMainToolbMenu(w, 280, 12, STR_INDUSTRY_DIR, 2); |
0 | 821 |
} |
822 |
||
823 |
static void ToolbarTrainClick(Window *w) |
|
824 |
{ |
|
825 |
Vehicle *v; |
|
826 |
int dis = -1; |
|
827 |
FOR_ALL_VEHICLES(v) |
|
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1044
diff
changeset
|
828 |
if (v->type == VEH_Train && v->subtype == TS_Front_Engine) CLRBIT(dis, v->owner); |
0 | 829 |
PopupMainPlayerToolbMenu(w, 310, 13, dis); |
830 |
} |
|
831 |
||
832 |
static void ToolbarRoadClick(Window *w) |
|
833 |
{ |
|
834 |
Vehicle *v; |
|
835 |
int dis = -1; |
|
836 |
FOR_ALL_VEHICLES(v) |
|
837 |
if (v->type == VEH_Road) CLRBIT(dis, v->owner); |
|
838 |
PopupMainPlayerToolbMenu(w, 332, 14, dis); |
|
839 |
} |
|
840 |
||
841 |
static void ToolbarShipClick(Window *w) |
|
842 |
{ |
|
843 |
Vehicle *v; |
|
844 |
int dis = -1; |
|
845 |
FOR_ALL_VEHICLES(v) |
|
846 |
if (v->type == VEH_Ship) CLRBIT(dis, v->owner); |
|
847 |
PopupMainPlayerToolbMenu(w, 354, 15, dis); |
|
848 |
} |
|
849 |
||
850 |
static void ToolbarAirClick(Window *w) |
|
851 |
{ |
|
852 |
Vehicle *v; |
|
853 |
int dis = -1; |
|
854 |
FOR_ALL_VEHICLES(v) |
|
855 |
if (v->type == VEH_Aircraft) CLRBIT(dis, v->owner); |
|
856 |
PopupMainPlayerToolbMenu(w, 376, 16, dis); |
|
857 |
} |
|
858 |
||
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
|
859 |
/* 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
|
860 |
/* 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
|
861 |
bool DoZoomInOutWindow(int how, Window *w) |
0 | 862 |
{ |
863 |
ViewPort *vp; |
|
864 |
int button; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
865 |
|
0 | 866 |
switch(_game_mode) { |
867 |
case GM_EDITOR: button = 9; break; |
|
868 |
case GM_NORMAL: button = 17; break; |
|
869 |
default: return false; |
|
870 |
} |
|
871 |
||
872 |
assert(w); |
|
873 |
vp = w->viewport; |
|
874 |
||
875 |
if (how == ZOOM_IN) { |
|
876 |
if (vp->zoom == 0) return false; |
|
877 |
vp->zoom--; |
|
878 |
vp->virtual_width >>= 1; |
|
879 |
vp->virtual_height >>= 1; |
|
880 |
||
881 |
WP(w,vp_d).scrollpos_x += vp->virtual_width >> 1; |
|
882 |
WP(w,vp_d).scrollpos_y += vp->virtual_height >> 1; |
|
883 |
||
884 |
SetWindowDirty(w); |
|
885 |
} else if (how == ZOOM_OUT) { |
|
886 |
if (vp->zoom == 2) return false; |
|
887 |
vp->zoom++; |
|
888 |
||
889 |
WP(w,vp_d).scrollpos_x -= vp->virtual_width >> 1; |
|
890 |
WP(w,vp_d).scrollpos_y -= vp->virtual_height >> 1; |
|
891 |
||
892 |
vp->virtual_width <<= 1; |
|
893 |
vp->virtual_height <<= 1; |
|
894 |
||
895 |
SetWindowDirty(w); |
|
896 |
} |
|
897 |
||
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
|
898 |
// routine to disable/enable the zoom buttons. Didn't know where to place these otherwise |
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
|
899 |
{ |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
152
diff
changeset
|
900 |
Window *wt = NULL; |
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
|
901 |
switch (w->window_class) { |
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
|
902 |
case WC_MAIN_WINDOW: |
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
|
903 |
wt = FindWindowById(WC_MAIN_TOOLBAR, 0); |
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
|
904 |
break; |
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
|
905 |
case WC_EXTRA_VIEW_PORT: |
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
|
906 |
wt = FindWindowById(WC_EXTRA_VIEW_PORT, w->window_number); |
682
7f5de4abac85
(svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents:
679
diff
changeset
|
907 |
button = 5; |
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
|
908 |
break; |
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
|
909 |
} |
0 | 910 |
|
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
|
911 |
assert(wt); |
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
|
912 |
|
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
|
913 |
// update the toolbar button too |
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
|
914 |
CLRBIT(wt->disabled_state, button); |
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
|
915 |
CLRBIT(wt->disabled_state, button + 1); |
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
|
916 |
if (vp->zoom == 0) SETBIT(wt->disabled_state, button); |
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
|
917 |
else if (vp->zoom == 2) SETBIT(wt->disabled_state, button + 1); |
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
|
918 |
SetWindowDirty(wt); |
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
|
919 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
920 |
|
0 | 921 |
return true; |
922 |
} |
|
923 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
924 |
static void MaxZoomIn(void) |
0 | 925 |
{ |
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
|
926 |
while (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0) ) ) {} |
0 | 927 |
} |
928 |
||
929 |
static void ToolbarZoomInClick(Window *w) |
|
930 |
{ |
|
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
|
931 |
if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) { |
0 | 932 |
HandleButtonClick(w, 17); |
541 | 933 |
SndPlayFx(SND_15_BEEP); |
0 | 934 |
} |
935 |
} |
|
936 |
||
937 |
static void ToolbarZoomOutClick(Window *w) |
|
938 |
{ |
|
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
|
939 |
if (DoZoomInOutWindow(ZOOM_OUT,FindWindowById(WC_MAIN_WINDOW, 0))) { |
0 | 940 |
HandleButtonClick(w, 18); |
541 | 941 |
SndPlayFx(SND_15_BEEP); |
0 | 942 |
} |
943 |
} |
|
944 |
||
945 |
static void ToolbarBuildRailClick(Window *w) |
|
946 |
{ |
|
947 |
Player *p = DEREF_PLAYER(_local_player); |
|
948 |
Window *w2; |
|
949 |
w2 = PopupMainToolbMenu(w, 457, 19, STR_1015_RAILROAD_CONSTRUCTION, p->max_railtype); |
|
950 |
WP(w2,menu_d).sel_index = _last_built_railtype; |
|
951 |
} |
|
952 |
||
953 |
static void ToolbarBuildRoadClick(Window *w) |
|
954 |
{ |
|
955 |
PopupMainToolbMenu(w, 479, 20, STR_180A_ROAD_CONSTRUCTION, 1); |
|
956 |
} |
|
957 |
||
958 |
static void ToolbarBuildWaterClick(Window *w) |
|
959 |
{ |
|
960 |
PopupMainToolbMenu(w, 501, 21, STR_9800_DOCK_CONSTRUCTION, 1); |
|
961 |
} |
|
962 |
||
963 |
static void ToolbarBuildAirClick(Window *w) |
|
964 |
{ |
|
965 |
PopupMainToolbMenu(w, 0x1E0, 22, STR_A01D_AIRPORT_CONSTRUCTION, 1); |
|
966 |
} |
|
967 |
||
968 |
static void ToolbarForestClick(Window *w) |
|
969 |
{ |
|
970 |
PopupMainToolbMenu(w, 0x1E0, 23, STR_LANDSCAPING, 3); |
|
971 |
} |
|
972 |
||
973 |
static void ToolbarMusicClick(Window *w) |
|
974 |
{ |
|
975 |
PopupMainToolbMenu(w, 0x1E0, 24, STR_01D3_SOUND_MUSIC, 1); |
|
976 |
} |
|
977 |
||
978 |
static void ToolbarNewspaperClick(Window *w) |
|
979 |
{ |
|
980 |
PopupMainToolbMenu(w, 0x1E0, 25, STR_0200_LAST_MESSAGE_NEWS_REPORT, _newspaper_flag != 2 ? 3 : 4); |
|
981 |
} |
|
982 |
||
983 |
static void ToolbarHelpClick(Window *w) |
|
984 |
{ |
|
985 |
PopupMainToolbMenu(w, 0x1E0, 26, STR_02D5_LAND_BLOCK_INFO, 5); |
|
986 |
} |
|
987 |
||
988 |
static void ToolbarOptionsClick(Window *w) |
|
989 |
{ |
|
990 |
uint16 x; |
|
991 |
||
1015
bc0d6949d458
(svn r1515) -Removed the 'close ALL windows' from the toolbar since shift+del does this.
darkvater
parents:
1014
diff
changeset
|
992 |
w = PopupMainToolbMenu(w, 43, 2, STR_02C3_GAME_OPTIONS, 12); |
0 | 993 |
|
994 |
x = (uint16)-1; |
|
1015
bc0d6949d458
(svn r1515) -Removed the 'close ALL windows' from the toolbar since shift+del does this.
darkvater
parents:
1014
diff
changeset
|
995 |
if (_display_opt & DO_SHOW_TOWN_NAMES) x &= ~(1<<5); |
bc0d6949d458
(svn r1515) -Removed the 'close ALL windows' from the toolbar since shift+del does this.
darkvater
parents:
1014
diff
changeset
|
996 |
if (_display_opt & DO_SHOW_STATION_NAMES) x &= ~(1<<6); |
bc0d6949d458
(svn r1515) -Removed the 'close ALL windows' from the toolbar since shift+del does this.
darkvater
parents:
1014
diff
changeset
|
997 |
if (_display_opt & DO_SHOW_SIGNS) x &= ~(1<<7); |
bc0d6949d458
(svn r1515) -Removed the 'close ALL windows' from the toolbar since shift+del does this.
darkvater
parents:
1014
diff
changeset
|
998 |
if (_display_opt & DO_WAYPOINTS) x &= ~(1<<8); |
bc0d6949d458
(svn r1515) -Removed the 'close ALL windows' from the toolbar since shift+del does this.
darkvater
parents:
1014
diff
changeset
|
999 |
if (_display_opt & DO_FULL_ANIMATION) x &= ~(1<<9); |
bc0d6949d458
(svn r1515) -Removed the 'close ALL windows' from the toolbar since shift+del does this.
darkvater
parents:
1014
diff
changeset
|
1000 |
if (_display_opt & DO_FULL_DETAIL) x &= ~(1<<10); |
bc0d6949d458
(svn r1515) -Removed the 'close ALL windows' from the toolbar since shift+del does this.
darkvater
parents:
1014
diff
changeset
|
1001 |
if (_display_opt & DO_TRANS_BUILDINGS) x &= ~(1<<11); |
0 | 1002 |
WP(w,menu_d).checked_items = x; |
1003 |
} |
|
1004 |
||
1005 |
||
1006 |
static void ToolbarScenSaveOrLoad(Window *w) |
|
1007 |
{ |
|
1008 |
PopupMainToolbMenu(w, 0x2C, 3, STR_0292_SAVE_SCENARIO, 5); |
|
1009 |
} |
|
1010 |
||
1011 |
static void ToolbarScenDateBackward(Window *w) |
|
1012 |
{ |
|
1013 |
// don't allow too fast scrolling |
|
1014 |
if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { |
|
1015 |
HandleButtonClick(w, 6); |
|
1016 |
InvalidateWidget(w, 5); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1017 |
|
349
47cdc8ab9cf7
(svn r532) Disable date change buttons in scenario editor if date limit is reached.
tron
parents:
337
diff
changeset
|
1018 |
if (_date > MinDate) |
0 | 1019 |
SetDate(ConvertYMDToDay(_cur_year - 1, 0, 1)); |
1020 |
} |
|
1021 |
_left_button_clicked = false; |
|
1022 |
} |
|
1023 |
||
1024 |
static void ToolbarScenDateForward(Window *w) |
|
1025 |
{ |
|
1026 |
// don't allow too fast scrolling |
|
1027 |
if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { |
|
1028 |
HandleButtonClick(w, 7); |
|
1029 |
InvalidateWidget(w, 5); |
|
1030 |
||
349
47cdc8ab9cf7
(svn r532) Disable date change buttons in scenario editor if date limit is reached.
tron
parents:
337
diff
changeset
|
1031 |
if (_date < MaxDate) |
0 | 1032 |
SetDate(ConvertYMDToDay(_cur_year + 1, 0, 1)); |
1033 |
} |
|
1034 |
_left_button_clicked = false; |
|
1035 |
} |
|
1036 |
||
1037 |
static void ToolbarScenMapTownDir(Window *w) |
|
1038 |
{ |
|
355
19a08ced3274
(svn r543) -Fix: [ 1064742 ] Editor Map-Menu wrong String
tron
parents:
349
diff
changeset
|
1039 |
PopupMainToolbMenu(w, 0x16A, 8 | (17<<8), STR_02DE_MAP_OF_WORLD, 3); |
0 | 1040 |
} |
1041 |
||
1042 |
static void ToolbarScenZoomIn(Window *w) |
|
1043 |
{ |
|
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
|
1044 |
if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) { |
0 | 1045 |
HandleButtonClick(w, 9); |
541 | 1046 |
SndPlayFx(SND_15_BEEP); |
0 | 1047 |
} |
1048 |
} |
|
1049 |
||
1050 |
static void ToolbarScenZoomOut(Window *w) |
|
1051 |
{ |
|
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
|
1052 |
if (DoZoomInOutWindow(ZOOM_OUT, FindWindowById(WC_MAIN_WINDOW, 0))) { |
0 | 1053 |
HandleButtonClick(w, 10); |
541 | 1054 |
SndPlayFx(SND_15_BEEP); |
0 | 1055 |
} |
1056 |
} |
|
1057 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1058 |
void ZoomInOrOutToCursorWindow(bool in, Window *w) |
0 | 1059 |
{ |
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
|
1060 |
ViewPort * vp; |
0 | 1061 |
Point pt; |
1062 |
||
1063 |
assert(w != 0); |
|
1064 |
||
1065 |
vp = w->viewport; |
|
1066 |
||
1067 |
if (_game_mode != GM_MENU) { |
|
1068 |
if ((in && vp->zoom == 0) || (!in && vp->zoom == 2)) |
|
1069 |
return; |
|
1070 |
||
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
|
1071 |
pt = GetTileZoomCenterWindow(in,w); |
0 | 1072 |
if (pt.x != -1) { |
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
|
1073 |
ScrollWindowTo(pt.x, pt.y, w); |
0 | 1074 |
|
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
|
1075 |
DoZoomInOutWindow(in ? ZOOM_IN : ZOOM_OUT, w); |
0 | 1076 |
} |
1077 |
} |
|
1078 |
} |
|
1079 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
1080 |
static void ResetLandscape(void) |
0 | 1081 |
{ |
206 | 1082 |
_random_seeds[0][0] = InteractiveRandom(); |
1083 |
_random_seeds[0][1] = InteractiveRandom(); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1084 |
|
1218 | 1085 |
GenerateWorld(1, _patches.map_x, _patches.map_y); |
0 | 1086 |
MarkWholeScreenDirty(); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1087 |
} |
0 | 1088 |
|
1089 |
static const Widget _ask_reset_landscape_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1090 |
{ WWT_TEXTBTN, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1091 |
{ WWT_CAPTION, RESIZE_NONE, 4, 11, 179, 0, 13, STR_022C_RESET_LANDSCAPE, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1092 |
{ WWT_IMGBTN, RESIZE_NONE, 4, 0, 179, 14, 91, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1093 |
{ WWT_TEXTBTN, RESIZE_NONE, 12, 25, 84, 72, 83, STR_00C9_NO, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1094 |
{ WWT_TEXTBTN, RESIZE_NONE, 12, 95, 154, 72, 83, STR_00C8_YES, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1095 |
{ WIDGETS_END}, |
0 | 1096 |
}; |
1097 |
||
1098 |
// Ask first to reset landscape or to make a random landscape |
|
1099 |
static void AskResetLandscapeWndProc(Window *w, WindowEvent *e) |
|
1100 |
{ |
|
1101 |
uint mode = w->window_number; |
|
1102 |
||
1103 |
switch(e->event) { |
|
1104 |
case WE_PAINT: |
|
1105 |
DrawWindowWidgets(w); |
|
1106 |
DrawStringMultiCenter(90, 38, mode?STR_022D_ARE_YOU_SURE_YOU_WANT_TO:STR_GENERATE_RANDOM_LANDSCAPE , 168); |
|
1107 |
case WE_CLICK: |
|
1108 |
switch(e->click.widget) { |
|
1109 |
case 3: |
|
1110 |
DeleteWindow(w); |
|
1111 |
break; |
|
1112 |
case 4: |
|
1113 |
DeleteWindow(w); |
|
999
8b2a34061963
(svn r1497) -Fix: [1101179] Crash if generating land while industry window is open. This also happened for towns and the land information window
darkvater
parents:
989
diff
changeset
|
1114 |
DeleteWindowByClass(WC_INDUSTRY_VIEW); |
8b2a34061963
(svn r1497) -Fix: [1101179] Crash if generating land while industry window is open. This also happened for towns and the land information window
darkvater
parents:
989
diff
changeset
|
1115 |
DeleteWindowByClass(WC_TOWN_VIEW); |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1015
diff
changeset
|
1116 |
DeleteWindowByClass(WC_LAND_INFO); |
999
8b2a34061963
(svn r1497) -Fix: [1101179] Crash if generating land while industry window is open. This also happened for towns and the land information window
darkvater
parents:
989
diff
changeset
|
1117 |
|
8b2a34061963
(svn r1497) -Fix: [1101179] Crash if generating land while industry window is open. This also happened for towns and the land information window
darkvater
parents:
989
diff
changeset
|
1118 |
if (mode) { // reset landscape |
0 | 1119 |
ResetLandscape(); |
999
8b2a34061963
(svn r1497) -Fix: [1101179] Crash if generating land while industry window is open. This also happened for towns and the land information window
darkvater
parents:
989
diff
changeset
|
1120 |
} else { // make random landscape |
541 | 1121 |
SndPlayFx(SND_15_BEEP); |
0 | 1122 |
_switch_mode = SM_GENRANDLAND; |
1123 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1124 |
|
0 | 1125 |
break; |
1126 |
} |
|
1127 |
} |
|
1128 |
} |
|
1129 |
||
1130 |
static const WindowDesc _ask_reset_landscape_desc = { |
|
1131 |
230,205, 180, 92, |
|
1132 |
WC_ASK_RESET_LANDSCAPE,0, |
|
1133 |
WDF_STD_BTN | WDF_DEF_WIDGET, |
|
1134 |
_ask_reset_landscape_widgets, |
|
1135 |
AskResetLandscapeWndProc, |
|
1136 |
}; |
|
1137 |
||
1138 |
static void AskResetLandscape(uint mode) |
|
1139 |
{ |
|
1140 |
AllocateWindowDescFront(&_ask_reset_landscape_desc, mode); |
|
1141 |
} |
|
1142 |
||
1143 |
static void CommonRaiseLowerBigLand(uint tile, int mode) |
|
1144 |
{ |
|
1145 |
int size; |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1146 |
byte h; |
0 | 1147 |
|
1148 |
_error_message_2 = mode ? STR_0808_CAN_T_RAISE_LAND_HERE : STR_0809_CAN_T_LOWER_LAND_HERE; |
|
1149 |
||
1150 |
_generating_world = true; |
|
1151 |
||
926
bd4312619522
(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
|
1152 |
// tile = TILE_FROM_XY(TileX(tile) * 16 + _tile_fract_coords.x + 8, TileY(tile) * 16 + _tile_fract_coords.y + 8); |
0 | 1153 |
|
1154 |
if (_terraform_size == 1) { |
|
1014
c669eeb097c6
(svn r1514) -Fix: [1092474] little red box in scenario editor (Celestar). Error box is also shown in scenario editor for terraforming, thus solving the eternally-pulsating-tile problem.
darkvater
parents:
1003
diff
changeset
|
1155 |
DoCommandP(tile, 8, (uint32)mode, CcTerraform, CMD_TERRAFORM_LAND | CMD_AUTO | CMD_MSG(_error_message_2)); |
0 | 1156 |
} else { |
541 | 1157 |
SndPlayTileFx(SND_1F_SPLAT, tile); |
0 | 1158 |
|
1159 |
size = _terraform_size; |
|
1160 |
assert(size != 0); |
|
1161 |
if (mode != 0) { |
|
1162 |
/* Raise land */ |
|
1163 |
h = 15; |
|
1164 |
BEGIN_TILE_LOOP(tile2, size, size, tile) |
|
1044
9b73df700a7c
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1035
diff
changeset
|
1165 |
h = min(h, TileHeight(tile2)); |
0 | 1166 |
END_TILE_LOOP(tile2, size, size, tile) |
1167 |
} else { |
|
1168 |
/* Lower land */ |
|
1169 |
h = 0; |
|
1170 |
BEGIN_TILE_LOOP(tile2, size, size, tile) |
|
1044
9b73df700a7c
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1035
diff
changeset
|
1171 |
h = max(h, TileHeight(tile2)); |
0 | 1172 |
END_TILE_LOOP(tile2, size, size, tile) |
1173 |
} |
|
1174 |
||
1175 |
BEGIN_TILE_LOOP(tile2, size, size, tile) |
|
1044
9b73df700a7c
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1035
diff
changeset
|
1176 |
if (TileHeight(tile2) == h) { |
0 | 1177 |
DoCommandP(tile2, 8, (uint32)mode, NULL, CMD_TERRAFORM_LAND | CMD_AUTO); |
1178 |
} |
|
1179 |
END_TILE_LOOP(tile2, size, size, tile) |
|
1180 |
} |
|
1181 |
||
1182 |
_generating_world = false; |
|
1183 |
} |
|
1184 |
||
410 | 1185 |
static void PlaceProc_RaiseBigLand(uint tile) |
0 | 1186 |
{ |
1187 |
CommonRaiseLowerBigLand(tile, 1); |
|
1188 |
} |
|
1189 |
||
410 | 1190 |
static void PlaceProc_LowerBigLand(uint tile) |
0 | 1191 |
{ |
1192 |
CommonRaiseLowerBigLand(tile, 0); |
|
1193 |
} |
|
1194 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1195 |
//void CcDemolish(bool success, uint tile, uint32 p1, uint32 p2) |
0 | 1196 |
//{ |
1197 |
// if (success) { |
|
1198 |
//SndPlayTileFx(0x10, tile); |
|
926
bd4312619522
(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
|
1199 |
//CreateEffectVehicleAbove(TileX(tile) * 16 + 8, TileY(tile) * 16 + 8, 2, EV_DEMOLISH); |
0 | 1200 |
// } |
1201 |
//} |
|
1202 |
||
1203 |
//void PlaceProc_Demolish(uint tile) |
|
1204 |
//{ |
|
1205 |
// DoCommandP(tile, 0, 0, CcDemolish, CMD_LANDSCAPE_CLEAR | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA)); |
|
1206 |
//} |
|
1207 |
||
1208 |
||
410 | 1209 |
static void PlaceProc_RockyArea(uint tile) |
0 | 1210 |
{ |
1035
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
1019
diff
changeset
|
1211 |
if (!IsTileType(tile, MP_CLEAR) && !IsTileType(tile, MP_TREES)) |
0 | 1212 |
return; |
1213 |
||
872
bfea30a005d5
(svn r1353) -Fix: [1092707] placing rocks in scenario editor. You can place rocks on trees and vice versa
darkvater
parents:
868
diff
changeset
|
1214 |
ModifyTile(tile, MP_SETTYPE(MP_CLEAR) | MP_MAP5, (_map5[tile] & ~0x1C) | 0xB); |
541 | 1215 |
SndPlayTileFx(SND_1F_SPLAT, tile); |
0 | 1216 |
} |
1217 |
||
410 | 1218 |
static void PlaceProc_LightHouse(uint tile) |
0 | 1219 |
{ |
1220 |
TileInfo ti; |
|
1221 |
||
1222 |
FindLandscapeHeightByTile(&ti, tile); |
|
1223 |
if (ti.type != MP_CLEAR || (ti.tileh & 0x10)) |
|
1224 |
return; |
|
1225 |
||
1226 |
ModifyTile(tile, MP_SETTYPE(MP_UNMOVABLE) | MP_MAP5, 1); |
|
541 | 1227 |
SndPlayTileFx(SND_1F_SPLAT, tile); |
0 | 1228 |
} |
1229 |
||
410 | 1230 |
static void PlaceProc_Transmitter(uint tile) |
0 | 1231 |
{ |
1232 |
TileInfo ti; |
|
1233 |
||
1234 |
FindLandscapeHeightByTile(&ti, tile); |
|
1235 |
if (ti.type != MP_CLEAR || (ti.tileh & 0x10)) |
|
1236 |
return; |
|
1237 |
||
1238 |
ModifyTile(tile, MP_SETTYPE(MP_UNMOVABLE) | MP_MAP5, 0); |
|
541 | 1239 |
SndPlayTileFx(SND_1F_SPLAT, tile); |
0 | 1240 |
} |
1241 |
||
410 | 1242 |
static void PlaceProc_Desert(uint tile) |
0 | 1243 |
{ |
1244 |
SetMapExtraBits(tile, GetMapExtraBits(tile) == 1 ? 0 : 1); |
|
1245 |
} |
|
1246 |
||
1247 |
static const Widget _scen_edit_land_gen_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1248 |
{ WWT_TEXTBTN, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1249 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 153, 0, 13, STR_0223_LAND_GENERATION,STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1250 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 153, 14, 99, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1251 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 22, 43, 14, 35, 0x2B6, STR_018F_RAISE_A_CORNER_OF_LAND}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1252 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 44, 65, 14, 35, 0x2B7, STR_018E_LOWER_A_CORNER_OF_LAND}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1253 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 21, 14, 35, 0x2BF, STR_018D_DEMOLISH_BUILDINGS_ETC}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1254 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 125, 135, 43, 54, STR_0224, STR_0228_INCREASE_SIZE_OF_LAND_AREA}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1255 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 125, 135, 56, 67, STR_0225, STR_0229_DECREASE_SIZE_OF_LAND_AREA}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1256 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 20, 135, 75, 86, STR_0226_RANDOM_LAND, STR_022A_GENERATE_RANDOM_LAND}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1257 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 20, 135, 88, 99, STR_0227_RESET_LAND, STR_022B_RESET_LANDSCAPE}, |
0 | 1258 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1259 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 88, 109, 14, 35, 0xFF4, STR_028C_PLACE_ROCKY_AREAS_ON_LANDSCAPE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1260 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 110, 131, 14, 35, 0xFF5, STR_028D_PLACE_LIGHTHOUSE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1261 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 132, 153, 14, 35, 0xFF6, STR_028E_PLACE_TRANSMITTER}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1262 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 66, 87, 14, 35, SPR_OPENTTD_BASE+68, STR_LEVEL_LAND_TOOLTIP}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1263 |
{ WIDGETS_END}, |
0 | 1264 |
}; |
1265 |
||
1266 |
static const int8 _multi_terraform_coords[][2] = { |
|
1267 |
{ 0, -2}, |
|
1268 |
{ 4, 0},{ -4, 0},{ 0, 2}, |
|
1269 |
{ -8, 2},{ -4, 4},{ 0, 6},{ 4, 4},{ 8, 2}, |
|
1270 |
{-12, 0},{ -8, -2},{ -4, -4},{ 0, -6},{ 4, -4},{ 8, -2},{ 12, 0}, |
|
1271 |
{-16, 2},{-12, 4},{ -8, 6},{ -4, 8},{ 0, 10},{ 4, 8},{ 8, 6},{ 12, 4},{ 16, 2}, |
|
1272 |
{-20, 0},{-16, -2},{-12, -4},{ -8, -6},{ -4, -8},{ 0,-10},{ 4, -8},{ 8, -6},{ 12, -4},{ 16, -2},{ 20, 0}, |
|
1273 |
{-24, 2},{-20, 4},{-16, 6},{-12, 8},{ -8, 10},{ -4, 12},{ 0, 14},{ 4, 12},{ 8, 10},{ 12, 8},{ 16, 6},{ 20, 4},{ 24, 2}, |
|
1274 |
{-28, 0},{-24, -2},{-20, -4},{-16, -6},{-12, -8},{ -8,-10},{ -4,-12},{ 0,-14},{ 4,-12},{ 8,-10},{ 12, -8},{ 16, -6},{ 20, -4},{ 24, -2},{ 28, 0}, |
|
1275 |
}; |
|
1276 |
||
1277 |
static void ScenEditLandGenWndProc(Window *w, WindowEvent *e) |
|
1278 |
{ |
|
1279 |
switch(e->event) { |
|
1280 |
case WE_PAINT: |
|
989
36d9d925825b
(svn r1487) -Fix: [1100736] wrong tooltip for place desert button
darkvater
parents:
988
diff
changeset
|
1281 |
// XXX - lighthouse button is widget 11!! Don't forget when changing |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1015
diff
changeset
|
1282 |
w->widget[11].tooltips = (_opt.landscape == LT_DESERT) ? STR_028F_DEFINE_DESERT_AREA : STR_028D_PLACE_LIGHTHOUSE; |
0 | 1283 |
DrawWindowWidgets(w); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1284 |
|
0 | 1285 |
{ |
1286 |
int n = _terraform_size * _terraform_size; |
|
1287 |
const int8 *coords = &_multi_terraform_coords[0][0]; |
|
1288 |
||
1289 |
assert(n != 0); |
|
1290 |
do { |
|
1291 |
DrawSprite(0xFEF, 77 + coords[0], 55 + coords[1]); |
|
1292 |
coords += 2; |
|
1293 |
} while (--n); |
|
1294 |
} |
|
1295 |
||
1296 |
if (_thd.window_class == WC_SCEN_LAND_GEN && (w->click_state&(1<<3|1<<4))) { |
|
1297 |
SetTileSelectSize(_terraform_size, _terraform_size); |
|
1298 |
} |
|
1299 |
break; |
|
1300 |
case WE_CLICK: |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1397
diff
changeset
|
1301 |
switch (e->click.widget) { |
0 | 1302 |
case 3: /* raise corner */ |
1303 |
HandlePlacePushButton(w, 3, ANIMCURSOR_RAISELAND, 2, PlaceProc_RaiseBigLand); |
|
1304 |
break; |
|
1305 |
case 4: /* lower corner */ |
|
1306 |
HandlePlacePushButton(w, 4, ANIMCURSOR_LOWERLAND, 2, PlaceProc_LowerBigLand); |
|
1307 |
break; |
|
1308 |
case 5: /* demolish */ |
|
1309 |
HandlePlacePushButton(w, 5, ANIMCURSOR_DEMOLISH, 1, PlaceProc_DemolishArea); |
|
1310 |
break; |
|
1311 |
{ |
|
1312 |
int size; |
|
1313 |
case 6: /* increase terraform size */ |
|
1314 |
HandleButtonClick(w, 6); |
|
1315 |
size = 1; |
|
1316 |
goto terraform_size_common; |
|
1317 |
case 7: /* decrease terraform size */ |
|
1318 |
HandleButtonClick(w, 7); |
|
1319 |
size = -1; |
|
1320 |
terraform_size_common:; |
|
1321 |
size += _terraform_size; |
|
1322 |
if (!IS_INT_INSIDE(size, 1, 8+1)) |
|
1323 |
return; |
|
1324 |
_terraform_size = size; |
|
541 | 1325 |
SndPlayFx(SND_15_BEEP); |
0 | 1326 |
SetWindowDirty(w); |
1327 |
break; |
|
1328 |
} |
|
1329 |
||
1330 |
case 8: /* gen random land */ |
|
1331 |
HandleButtonClick(w, 8); |
|
1332 |
AskResetLandscape(0); |
|
1333 |
break; |
|
1334 |
||
1335 |
case 9: /* reset landscape */ |
|
1336 |
HandleButtonClick(w,9); |
|
1337 |
AskResetLandscape(1); |
|
1338 |
break; |
|
1339 |
||
1340 |
case 10: /* place rocky areas */ |
|
1341 |
HandlePlacePushButton(w, 10, 0xFF7, 1, PlaceProc_RockyArea); |
|
1342 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1343 |
|
0 | 1344 |
case 11: /* place lighthouse */ |
1345 |
HandlePlacePushButton(w, 11, 0xFF8, 1, _opt.landscape == LT_DESERT ? PlaceProc_Desert : PlaceProc_LightHouse); |
|
1346 |
break; |
|
1347 |
||
1348 |
case 12: /* place transmitter */ |
|
1349 |
HandlePlacePushButton(w, 12, 0xFF9, 1, PlaceProc_Transmitter); |
|
1350 |
break; |
|
1351 |
||
1352 |
case 13: /* level Land */ |
|
1353 |
HandlePlacePushButton(w, 13, SPR_OPENTTD_BASE+69, 2, PlaceProc_LevelLand); |
|
1354 |
break; |
|
1355 |
} |
|
1356 |
break; |
|
1357 |
case WE_TIMEOUT: |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1397
diff
changeset
|
1358 |
UnclickSomeWindowButtons(w, ~(1<<3 | 1<<4 | 1<<5 | 1<<10 | 1<<11 | 1<<12)); |
0 | 1359 |
break; |
1360 |
case WE_PLACE_OBJ: |
|
1361 |
_place_proc(e->place.tile); |
|
1362 |
break; |
|
1363 |
case WE_PLACE_DRAG: { |
|
1364 |
VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata & 0xF); |
|
1365 |
return; |
|
1366 |
} |
|
1367 |
case WE_PLACE_MOUSEUP: |
|
1368 |
if (e->click.pt.x != -1) { |
|
1369 |
uint start_tile = e->place.starttile; |
|
1370 |
uint end_tile = e->place.tile; |
|
1371 |
if (e->place.userdata == VPM_X_AND_Y) { |
|
1372 |
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA)); |
|
1373 |
} else if (e->place.userdata == (VPM_X_AND_Y | (2<<4))) { |
|
1374 |
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_LEVEL_LAND | CMD_AUTO); |
|
1375 |
} |
|
1376 |
} |
|
1377 |
break; |
|
1378 |
||
1379 |
case WE_ABORT_PLACE_OBJ: |
|
1380 |
w->click_state = 0; |
|
1381 |
SetWindowDirty(w); |
|
1382 |
break; |
|
1383 |
} |
|
1384 |
} |
|
1385 |
||
1386 |
static const WindowDesc _scen_edit_land_gen_desc = { |
|
1387 |
-1,-1, 154, 100, |
|
1388 |
WC_SCEN_LAND_GEN,0, |
|
1389 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
1390 |
_scen_edit_land_gen_widgets, |
|
1391 |
ScenEditLandGenWndProc, |
|
1392 |
}; |
|
1393 |
||
1394 |
static void ToolbarScenGenLand(Window *w) |
|
1395 |
{ |
|
1396 |
HandleButtonClick(w, 11); |
|
541 | 1397 |
SndPlayFx(SND_15_BEEP); |
0 | 1398 |
|
1399 |
AllocateWindowDescFront(&_scen_edit_land_gen_desc, 0); |
|
1400 |
} |
|
1401 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1402 |
void CcBuildTown(bool success, uint tile, uint32 p1, uint32 p2) |
0 | 1403 |
{ |
1404 |
if (success) { |
|
541 | 1405 |
SndPlayTileFx(SND_1F_SPLAT, tile); |
0 | 1406 |
ResetObjectToPlace(); |
1407 |
} |
|
1408 |
} |
|
1409 |
||
410 | 1410 |
static void PlaceProc_Town(uint tile) |
0 | 1411 |
{ |
1412 |
DoCommandP(tile, 0, 0, CcBuildTown, CMD_BUILD_TOWN | CMD_MSG(STR_0236_CAN_T_BUILD_TOWN_HERE)); |
|
1413 |
} |
|
1414 |
||
1415 |
||
1416 |
static const Widget _scen_edit_town_gen_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1417 |
{ WWT_TEXTBTN, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1418 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 159, 0, 13, STR_0233_TOWN_GENERATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1419 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 159, 14, 81, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1420 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 157, 16, 27, STR_0234_NEW_TOWN, STR_0235_CONSTRUCT_NEW_TOWN}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1421 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 157, 29, 40, STR_023D_RANDOM_TOWN, STR_023E_BUILD_TOWN_IN_RANDOM_LOCATION}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1422 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 157, 42, 53, STR_MANY_RANDOM_TOWNS, STR_RANDOM_TOWNS_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1423 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 53, 68, 79, STR_02A1_SMALL, STR_02A4_SELECT_TOWN_SIZE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1424 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 54, 105, 68, 79, STR_02A2_MEDIUM, STR_02A4_SELECT_TOWN_SIZE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1425 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 106, 157, 68, 79, STR_02A3_LARGE, STR_02A4_SELECT_TOWN_SIZE}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1426 |
{ WIDGETS_END}, |
0 | 1427 |
}; |
1428 |
||
1429 |
static void ScenEditTownGenWndProc(Window *w, WindowEvent *e) |
|
1430 |
{ |
|
1431 |
switch(e->event) { |
|
1432 |
case WE_PAINT: |
|
1433 |
w->click_state = (w->click_state & ~(1<<6 | 1<<7 | 1<<8) ) | (1 << (_new_town_size + 6)); |
|
1434 |
DrawWindowWidgets(w); |
|
1435 |
DrawStringCentered(80, 56, STR_02A5_TOWN_SIZE, 0); |
|
1436 |
break; |
|
1437 |
||
1438 |
case WE_CLICK: |
|
1439 |
switch(e->click.widget) { |
|
1440 |
case 3: /* new town */ |
|
1441 |
HandlePlacePushButton(w, 3, 0xFF0, 1, PlaceProc_Town); |
|
1442 |
break; |
|
1443 |
case 4: {/* random town */ |
|
1444 |
Town *t; |
|
1445 |
||
1446 |
HandleButtonClick(w, 4); |
|
1447 |
_generating_world = true; |
|
1362
adfd229bdc01
(svn r1866) -Fix: Intercepted generated maps with 0 towns on it. Currently just an
celestar
parents:
1357
diff
changeset
|
1448 |
t = CreateRandomTown(20); |
0 | 1449 |
_generating_world = false; |
1450 |
if (t != NULL) |
|
1451 |
ScrollMainWindowToTile(t->xy); |
|
1452 |
break; |
|
1453 |
} |
|
1454 |
case 5: {/* many random towns */ |
|
1455 |
HandleButtonClick(w, 5); |
|
1456 |
_generating_world = true; |
|
1457 |
_game_mode = GM_NORMAL; // little hack to avoid towns of the same size |
|
1458 |
GenerateTowns(); |
|
1459 |
_generating_world = false; |
|
1460 |
_game_mode = GM_EDITOR; |
|
1461 |
break; |
|
1462 |
} |
|
1463 |
||
1464 |
case 6: case 7: case 8: |
|
1465 |
_new_town_size = e->click.widget - 6; |
|
1466 |
SetWindowDirty(w); |
|
1467 |
break; |
|
1468 |
} |
|
1469 |
break; |
|
1470 |
||
1471 |
case WE_TIMEOUT: |
|
1472 |
UnclickSomeWindowButtons(w, 1<<4 | 1<<5); |
|
1473 |
break; |
|
1474 |
case WE_PLACE_OBJ: |
|
1475 |
_place_proc(e->place.tile); |
|
1476 |
break; |
|
1477 |
case WE_ABORT_PLACE_OBJ: |
|
1478 |
w->click_state = 0; |
|
1479 |
SetWindowDirty(w); |
|
1480 |
break; |
|
1481 |
} |
|
1482 |
} |
|
1483 |
||
1484 |
static const WindowDesc _scen_edit_town_gen_desc = { |
|
1485 |
-1,-1, 160, 82, |
|
1486 |
WC_SCEN_TOWN_GEN,0, |
|
1487 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
1488 |
_scen_edit_town_gen_widgets, |
|
1489 |
ScenEditTownGenWndProc, |
|
1490 |
}; |
|
1491 |
||
1492 |
static void ToolbarScenGenTown(Window *w) |
|
1493 |
{ |
|
1494 |
HandleButtonClick(w, 12); |
|
541 | 1495 |
SndPlayFx(SND_15_BEEP); |
0 | 1496 |
|
1497 |
AllocateWindowDescFront(&_scen_edit_town_gen_desc, 0); |
|
1498 |
} |
|
1499 |
||
1500 |
||
1501 |
static const Widget _scenedit_industry_normal_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1502 |
{ WWT_TEXTBTN, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1503 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_023F_INDUSTRY_GENERATION, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1504 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 169, 14, 224, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1505 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1506 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_MANY_RANDOM_INDUSTRIES, STR_RANDOM_INDUSTRIES_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1507 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1508 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0240_COAL_MINE, STR_0262_CONSTRUCT_COAL_MINE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1509 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1510 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0242_SAWMILL, STR_0264_CONSTRUCT_SAWMILL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1511 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 81, 92, STR_0243_FOREST, STR_0265_PLANT_FOREST}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1512 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 94, 105, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1513 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 107, 118, STR_0245_OIL_RIG, STR_0267_CONSTRUCT_OIL_RIG_CAN_ONLY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1514 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 120, 131, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1515 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 133, 144, STR_0247_STEEL_MILL, STR_0269_CONSTRUCT_STEEL_MILL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1516 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 146, 157, STR_0248_FARM, STR_026A_CONSTRUCT_FARM}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1517 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 159, 170, STR_0249_IRON_ORE_MINE, STR_026B_CONSTRUCT_IRON_ORE_MINE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1518 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 172, 183, STR_024A_OIL_WELLS, STR_026C_CONSTRUCT_OIL_WELLS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1519 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 185, 196, STR_024B_BANK, STR_026D_CONSTRUCT_BANK_CAN_ONLY}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1520 |
{ WIDGETS_END}, |
0 | 1521 |
}; |
1522 |
||
1523 |
||
1524 |
static const Widget _scenedit_industry_hilly_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1525 |
{ WWT_TEXTBTN, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1526 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_023F_INDUSTRY_GENERATION, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1527 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 169, 14, 224, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1528 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1529 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_MANY_RANDOM_INDUSTRIES, STR_RANDOM_INDUSTRIES_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1530 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1531 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0240_COAL_MINE, STR_0262_CONSTRUCT_COAL_MINE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1532 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0241_POWER_STATION, STR_0263_CONSTRUCT_POWER_STATION}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1533 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_024C_PAPER_MILL, STR_026E_CONSTRUCT_PAPER_MILL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1534 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 81, 92, STR_0243_FOREST, STR_0265_PLANT_FOREST}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1535 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 94, 105, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1536 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 107, 118, STR_024D_FOOD_PROCESSING_PLANT, STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1537 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 120, 131, STR_024E_PRINTING_WORKS, STR_0270_CONSTRUCT_PRINTING_WORKS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1538 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 133, 144, STR_024F_GOLD_MINE, STR_0271_CONSTRUCT_GOLD_MINE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1539 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 146, 157, STR_0248_FARM, STR_026A_CONSTRUCT_FARM}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1540 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 159, 170, STR_024B_BANK, STR_0272_CONSTRUCT_BANK_CAN_ONLY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1541 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 172, 183, STR_024A_OIL_WELLS, STR_026C_CONSTRUCT_OIL_WELLS}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1542 |
{ WIDGETS_END}, |
0 | 1543 |
}; |
1544 |
||
1545 |
static const Widget _scenedit_industry_desert_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1546 |
{ WWT_TEXTBTN, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1547 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_023F_INDUSTRY_GENERATION, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1548 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 169, 14, 224, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1549 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1550 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_MANY_RANDOM_INDUSTRIES, STR_RANDOM_INDUSTRIES_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1551 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1552 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0250_LUMBER_MILL, STR_0273_CONSTRUCT_LUMBER_MILL_TO}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1553 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0251_FRUIT_PLANTATION, STR_0274_PLANT_FRUIT_PLANTATION}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1554 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0252_RUBBER_PLANTATION,STR_0275_PLANT_RUBBER_PLANTATION}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1555 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 81, 92, STR_0244_OIL_REFINERY, STR_0266_CONSTRUCT_OIL_REFINERY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1556 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 94, 105, STR_024D_FOOD_PROCESSING_PLANT, STR_026F_CONSTRUCT_FOOD_PROCESSING}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1557 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 107, 118, STR_0246_FACTORY, STR_0268_CONSTRUCT_FACTORY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1558 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 120, 131, STR_0253_WATER_SUPPLY, STR_0276_CONSTRUCT_WATER_SUPPLY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1559 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 133, 144, STR_0248_FARM, STR_026A_CONSTRUCT_FARM}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1560 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 146, 157, STR_0254_WATER_TOWER, STR_0277_CONSTRUCT_WATER_TOWER_CAN}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1561 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 159, 170, STR_024A_OIL_WELLS, STR_026C_CONSTRUCT_OIL_WELLS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1562 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 172, 183, STR_024B_BANK, STR_0272_CONSTRUCT_BANK_CAN_ONLY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1563 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 185, 196, STR_0255_DIAMOND_MINE, STR_0278_CONSTRUCT_DIAMOND_MINE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1564 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 198, 209, STR_0256_COPPER_ORE_MINE, STR_0279_CONSTRUCT_COPPER_ORE_MINE}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1565 |
{ WIDGETS_END}, |
0 | 1566 |
}; |
1567 |
||
1568 |
static const Widget _scenedit_industry_candy_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1569 |
{ WWT_TEXTBTN, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1570 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_023F_INDUSTRY_GENERATION,STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1571 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 169, 14, 224, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1572 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1573 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 16, 27, STR_MANY_RANDOM_INDUSTRIES, STR_RANDOM_INDUSTRIES_TIP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1574 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1575 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 42, 53, STR_0257_COTTON_CANDY_FOREST,STR_027A_PLANT_COTTON_CANDY_FOREST}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1576 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 55, 66, STR_0258_CANDY_FACTORY, STR_027B_CONSTRUCT_CANDY_FACTORY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1577 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 68, 79, STR_0259_BATTERY_FARM, STR_027C_CONSTRUCT_BATTERY_FARM}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1578 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 81, 92, STR_025A_COLA_WELLS, STR_027D_CONSTRUCT_COLA_WELLS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1579 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 94, 105, STR_025B_TOY_SHOP, STR_027E_CONSTRUCT_TOY_SHOP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1580 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 107, 118, STR_025C_TOY_FACTORY, STR_027F_CONSTRUCT_TOY_FACTORY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1581 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 120, 131, STR_025D_PLASTIC_FOUNTAINS, STR_0280_CONSTRUCT_PLASTIC_FOUNTAINS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1582 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 133, 144, STR_025E_FIZZY_DRINK_FACTORY,STR_0281_CONSTRUCT_FIZZY_DRINK_FACTORY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1583 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 146, 157, STR_025F_BUBBLE_GENERATOR, STR_0282_CONSTRUCT_BUBBLE_GENERATOR}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1584 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 159, 170, STR_0260_TOFFEE_QUARRY, STR_0283_CONSTRUCT_TOFFEE_QUARRY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1585 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 167, 172, 183, STR_0261_SUGAR_MINE, STR_0284_CONSTRUCT_SUGAR_MINE}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1586 |
{ WIDGETS_END}, |
0 | 1587 |
}; |
1588 |
||
1589 |
int _industry_type_to_place; |
|
1590 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
1591 |
static bool AnyTownExists(void) |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
1592 |
{ |
0 | 1593 |
Town *t; |
1594 |
FOR_ALL_TOWNS(t) { |
|
1595 |
if (t->xy) |
|
1596 |
return true; |
|
1597 |
} |
|
1598 |
return false; |
|
1599 |
} |
|
1600 |
||
1601 |
extern Industry *CreateNewIndustry(uint tile, int type); |
|
1602 |
||
1603 |
static bool TryBuildIndustry(TileIndex tile, int type) |
|
1604 |
{ |
|
1605 |
int n; |
|
1606 |
||
7
f2e623faa778
(svn r8) Fix: Automatic oil refinery generation in editor
dominik
parents:
2
diff
changeset
|
1607 |
if (CreateNewIndustry(tile, type)) return true; |
f2e623faa778
(svn r8) Fix: Automatic oil refinery generation in editor
dominik
parents:
2
diff
changeset
|
1608 |
|
0 | 1609 |
n = 100; |
1610 |
do { |
|
1611 |
if (CreateNewIndustry(AdjustTileCoordRandomly(tile, 1), type)) return true; |
|
1612 |
} while (--n); |
|
1613 |
||
1614 |
n = 200; |
|
1615 |
do { |
|
1616 |
if (CreateNewIndustry(AdjustTileCoordRandomly(tile, 2), type)) return true; |
|
1617 |
} while (--n); |
|
1618 |
||
1619 |
n = 700; |
|
1620 |
do { |
|
1621 |
if (CreateNewIndustry(AdjustTileCoordRandomly(tile, 4), type)) return true; |
|
1622 |
} while (--n); |
|
1623 |
||
1624 |
return false; |
|
1625 |
} |
|
1626 |
||
1627 |
||
1628 |
static const byte _industry_type_list[4][16] = { |
|
1629 |
{0, 1, 2, 3, 4, 5, 6, 8, 9, 18, 11, 12}, |
|
1630 |
{0, 1, 14, 3, 4, 13, 7, 15, 9, 16, 11, 12}, |
|
1631 |
{25, 19, 20, 4, 13, 23, 21, 24, 22, 11, 16, 17, 10}, |
|
1632 |
{26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36}, |
|
1633 |
}; |
|
1634 |
||
7
f2e623faa778
(svn r8) Fix: Automatic oil refinery generation in editor
dominik
parents:
2
diff
changeset
|
1635 |
bool _ignore_restrictions; |
f2e623faa778
(svn r8) Fix: Automatic oil refinery generation in editor
dominik
parents:
2
diff
changeset
|
1636 |
|
0 | 1637 |
static void ScenEditIndustryWndProc(Window *w, WindowEvent *e) |
1638 |
{ |
|
1639 |
int button; |
|
1640 |
||
1641 |
switch(e->event) { |
|
1642 |
case WE_PAINT: |
|
1643 |
DrawWindowWidgets(w); |
|
1644 |
break; |
|
1645 |
||
1646 |
case WE_CLICK: |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1647 |
if ((button=e->click.widget) == 3) { |
0 | 1648 |
HandleButtonClick(w, 3); |
1649 |
||
1650 |
if (!AnyTownExists()) { |
|
1651 |
ShowErrorMessage(STR_0286_MUST_BUILD_TOWN_FIRST, STR_CAN_T_GENERATE_INDUSTRIES, 0, 0); |
|
1652 |
return; |
|
1653 |
} |
|
1654 |
||
1655 |
_generating_world = true; |
|
1656 |
GenerateIndustries(); |
|
1657 |
_generating_world = false; |
|
1658 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1659 |
|
0 | 1660 |
if ((button=e->click.widget) >= 4) { |
1661 |
if (HandlePlacePushButton(w, button, 0xFF1, 1, NULL)) |
|
1662 |
_industry_type_to_place = _industry_type_list[_opt.landscape][button - 4]; |
|
1663 |
} |
|
1664 |
break; |
|
1665 |
case WE_PLACE_OBJ: { |
|
1666 |
int type; |
|
1667 |
||
1668 |
// Show error if no town exists at all |
|
1669 |
type = _industry_type_to_place; |
|
1670 |
if (!AnyTownExists()) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1671 |
SetDParam(0, type + STR_4802_COAL_MINE); |
0 | 1672 |
ShowErrorMessage(STR_0286_MUST_BUILD_TOWN_FIRST,STR_0285_CAN_T_BUILD_HERE,e->place.pt.x, e->place.pt.y); |
1673 |
return; |
|
1674 |
} |
|
1675 |
||
1676 |
_current_player = OWNER_NONE; |
|
1677 |
_generating_world = true; |
|
7
f2e623faa778
(svn r8) Fix: Automatic oil refinery generation in editor
dominik
parents:
2
diff
changeset
|
1678 |
_ignore_restrictions = true; |
0 | 1679 |
if (!TryBuildIndustry(e->place.tile,type)) { |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1680 |
SetDParam(0, type + STR_4802_COAL_MINE); |
0 | 1681 |
ShowErrorMessage(_error_message, STR_0285_CAN_T_BUILD_HERE,e->place.pt.x, e->place.pt.y); |
1682 |
} |
|
7
f2e623faa778
(svn r8) Fix: Automatic oil refinery generation in editor
dominik
parents:
2
diff
changeset
|
1683 |
_ignore_restrictions = false; |
0 | 1684 |
_generating_world = false; |
1685 |
break; |
|
1686 |
} |
|
1687 |
case WE_ABORT_PLACE_OBJ: |
|
1688 |
w->click_state = 0; |
|
1689 |
SetWindowDirty(w); |
|
1690 |
break; |
|
1691 |
case WE_TIMEOUT: |
|
1692 |
UnclickSomeWindowButtons(w, 1<<3); |
|
1693 |
break; |
|
1694 |
} |
|
1695 |
} |
|
1696 |
||
1697 |
static const WindowDesc _scenedit_industry_normal_desc = { |
|
1698 |
-1,-1, 170, 225, |
|
1699 |
WC_SCEN_INDUSTRY,0, |
|
1700 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
1701 |
_scenedit_industry_normal_widgets, |
|
1702 |
ScenEditIndustryWndProc, |
|
1703 |
}; |
|
1704 |
||
1705 |
static const WindowDesc _scenedit_industry_hilly_desc = { |
|
1706 |
-1,-1, 170, 225, |
|
1707 |
WC_SCEN_INDUSTRY,0, |
|
1708 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
1709 |
_scenedit_industry_hilly_widgets, |
|
1710 |
ScenEditIndustryWndProc, |
|
1711 |
}; |
|
1712 |
||
1713 |
static const WindowDesc _scenedit_industry_desert_desc = { |
|
1714 |
-1,-1, 170, 225, |
|
1715 |
WC_SCEN_INDUSTRY,0, |
|
1716 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
1717 |
_scenedit_industry_desert_widgets, |
|
1718 |
ScenEditIndustryWndProc, |
|
1719 |
}; |
|
1720 |
||
1721 |
static const WindowDesc _scenedit_industry_candy_desc = { |
|
1722 |
-1,-1, 170, 225, |
|
1723 |
WC_SCEN_INDUSTRY,0, |
|
1724 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
|
1725 |
_scenedit_industry_candy_widgets, |
|
1726 |
ScenEditIndustryWndProc, |
|
1727 |
}; |
|
1728 |
||
1729 |
static const WindowDesc * const _scenedit_industry_descs[] = { |
|
1730 |
&_scenedit_industry_normal_desc, |
|
1731 |
&_scenedit_industry_hilly_desc, |
|
1732 |
&_scenedit_industry_desert_desc, |
|
1733 |
&_scenedit_industry_candy_desc, |
|
1734 |
}; |
|
1735 |
||
1736 |
||
1737 |
static void ToolbarScenGenIndustry(Window *w) |
|
1738 |
{ |
|
1739 |
HandleButtonClick(w, 13); |
|
541 | 1740 |
SndPlayFx(SND_15_BEEP); |
0 | 1741 |
AllocateWindowDescFront(_scenedit_industry_descs[_opt.landscape],0); |
1742 |
} |
|
1743 |
||
1744 |
static void ToolbarScenBuildRoad(Window *w) |
|
1745 |
{ |
|
1746 |
HandleButtonClick(w, 14); |
|
541 | 1747 |
SndPlayFx(SND_15_BEEP); |
0 | 1748 |
ShowBuildRoadScenToolbar(); |
1749 |
} |
|
1750 |
||
1751 |
static void ToolbarScenPlantTrees(Window *w) |
|
1752 |
{ |
|
1753 |
HandleButtonClick(w, 15); |
|
541 | 1754 |
SndPlayFx(SND_15_BEEP); |
0 | 1755 |
ShowBuildTreesScenToolbar(); |
1756 |
} |
|
1757 |
||
1758 |
static void ToolbarScenPlaceSign(Window *w) |
|
1759 |
{ |
|
1760 |
HandleButtonClick(w, 16); |
|
541 | 1761 |
SndPlayFx(SND_15_BEEP); |
0 | 1762 |
SelectSignTool(); |
1763 |
} |
|
1764 |
||
1765 |
static void ToolbarBtn_NULL(Window *w) |
|
1766 |
{ |
|
1767 |
} |
|
1768 |
||
1769 |
static ToolbarButtonProc* const _toolbar_button_procs[] = { |
|
1770 |
ToolbarPauseClick, |
|
1771 |
ToolbarFastForwardClick, |
|
1772 |
ToolbarOptionsClick, |
|
1773 |
ToolbarSaveClick, |
|
1774 |
ToolbarMapClick, |
|
1775 |
ToolbarTownClick, |
|
1776 |
ToolbarSubsidiesClick, |
|
1777 |
ToolbarStationsClick, |
|
1778 |
ToolbarMoneyClick, |
|
1779 |
ToolbarPlayersClick, |
|
1780 |
ToolbarGraphsClick, |
|
1781 |
ToolbarLeagueClick, |
|
1782 |
ToolbarIndustryClick, |
|
1783 |
ToolbarTrainClick, |
|
1784 |
ToolbarRoadClick, |
|
1785 |
ToolbarShipClick, |
|
1786 |
ToolbarAirClick, |
|
1787 |
ToolbarZoomInClick, |
|
1788 |
ToolbarZoomOutClick, |
|
1789 |
ToolbarBuildRailClick, |
|
1790 |
ToolbarBuildRoadClick, |
|
1791 |
ToolbarBuildWaterClick, |
|
1792 |
ToolbarBuildAirClick, |
|
1793 |
ToolbarForestClick, |
|
1794 |
ToolbarMusicClick, |
|
1795 |
ToolbarNewspaperClick, |
|
1796 |
ToolbarHelpClick, |
|
1797 |
}; |
|
1798 |
||
1799 |
static void MainToolbarWndProc(Window *w, WindowEvent *e) |
|
1800 |
{ |
|
1801 |
switch(e->event) { |
|
1802 |
case WE_PAINT: { |
|
1803 |
||
1804 |
// Draw brown-red toolbar bg. |
|
1805 |
GfxFillRect(0, 0, w->width-1, w->height-1, 0xB2); |
|
1806 |
GfxFillRect(0, 0, w->width-1, w->height-1, 0x80B4); |
|
1807 |
||
1808 |
// if spectator, disable things |
|
1 | 1809 |
if (_current_player == OWNER_SPECTATOR){ |
213
770e504a6e51
(svn r214) -Feature: CMD_NET_INSTANT [just in time command handling over network] (sign_de)
darkvater
parents:
206
diff
changeset
|
1810 |
w->disabled_state |= (1 << 19) | (1<<20) | (1<<21) | (1<<22) | (1<<23); |
0 | 1811 |
} else { |
213
770e504a6e51
(svn r214) -Feature: CMD_NET_INSTANT [just in time command handling over network] (sign_de)
darkvater
parents:
206
diff
changeset
|
1812 |
w->disabled_state &= ~((1 << 19) | (1<<20) | (1<<21) | (1<<22) | (1<<23)); |
0 | 1813 |
} |
1814 |
||
1815 |
DrawWindowWidgets(w); |
|
1816 |
break; |
|
1817 |
} |
|
1818 |
||
1819 |
case WE_CLICK: { |
|
1820 |
if (_game_mode != GM_MENU && !HASBIT(w->disabled_state, e->click.widget)) |
|
1821 |
_toolbar_button_procs[e->click.widget](w); |
|
1822 |
} break; |
|
1823 |
||
1824 |
case WE_KEYPRESS: { |
|
1825 |
int local = _local_player; |
|
1826 |
if (local == 0xff) local = 0; // spectator |
|
1827 |
||
1828 |
switch(e->keypress.keycode) { |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1397
diff
changeset
|
1829 |
case WKC_F1: case WKC_PAUSE: |
424
4c7808af7526
(svn r623) -Feature: [ 1066504 ] Pause key pauses the game
tron
parents:
410
diff
changeset
|
1830 |
ToolbarPauseClick(w); |
4c7808af7526
(svn r623) -Feature: [ 1066504 ] Pause key pauses the game
tron
parents:
410
diff
changeset
|
1831 |
break; |
0 | 1832 |
case WKC_F2: ShowGameOptions(); break; |
1833 |
case WKC_F3: MenuClickSaveLoad(0); break; |
|
1834 |
case WKC_F4: ShowSmallMap(); break; |
|
1835 |
case WKC_F5: ShowTownDirectory(); break; |
|
1836 |
case WKC_F6: ShowSubsidiesList(); break; |
|
1837 |
case WKC_F7: ShowPlayerStations(local); break; |
|
1838 |
case WKC_F8: ShowPlayerFinances(local); break; |
|
1839 |
case WKC_F9: ShowPlayerCompany(local); break; |
|
1840 |
case WKC_F10:ShowOperatingProfitGraph(); break; |
|
1841 |
case WKC_F11: ShowCompanyLeagueTable(); break; |
|
1842 |
case WKC_F12: ShowBuildIndustryWindow(); break; |
|
588 | 1843 |
case WKC_SHIFT | WKC_F1: ShowPlayerTrains(local, -1); break; |
1844 |
case WKC_SHIFT | WKC_F2: ShowPlayerRoadVehicles(local, -1); break; |
|
1845 |
case WKC_SHIFT | WKC_F3: ShowPlayerShips(local, -1); break; |
|
1846 |
case WKC_SHIFT | WKC_F4: ShowPlayerAircraft(local, -1); break; |
|
0 | 1847 |
case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(w); break; |
1848 |
case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(w); break; |
|
1849 |
case WKC_SHIFT | WKC_F7: ShowBuildRailToolbar(_last_built_railtype,-1); break; |
|
1850 |
case WKC_SHIFT | WKC_F8: ShowBuildRoadToolbar(); break; |
|
1851 |
case WKC_SHIFT | WKC_F9: ShowBuildDocksToolbar(); break; |
|
1852 |
case WKC_SHIFT | WKC_F10:ShowBuildAirToolbar(); break; |
|
1853 |
case WKC_SHIFT | WKC_F11: ShowBuildTreesToolbar(); break; |
|
1854 |
case WKC_SHIFT | WKC_F12: ShowMusicWindow(); break; |
|
1855 |
case WKC_CTRL | 'S': _make_screenshot = 1; break; |
|
130
b593afdae262
(svn r131) Completely changed hotkey from tab to backquote (not working in Windows yet)
dominik
parents:
126
diff
changeset
|
1856 |
case WKC_CTRL | 'G': _make_screenshot = 2; break; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
1857 |
case WKC_CTRL | WKC_ALT | 'C': if (!_networking) ShowCheatWindow(); break; |
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1397
diff
changeset
|
1858 |
default: return; |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1397
diff
changeset
|
1859 |
e->keypress.cont = false; |
0 | 1860 |
} |
1861 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1862 |
|
0 | 1863 |
case WE_PLACE_OBJ: { |
1864 |
_place_proc(e->place.tile); |
|
1865 |
} break; |
|
1866 |
||
1867 |
case WE_ABORT_PLACE_OBJ: { |
|
1868 |
w->click_state &= ~(1<<25); |
|
1869 |
SetWindowDirty(w); |
|
1870 |
} break; |
|
1871 |
||
1872 |
case WE_ON_EDIT_TEXT: HandleOnEditText(e); break; |
|
1873 |
||
1874 |
case WE_MOUSELOOP: |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1875 |
|
0 | 1876 |
if (((w->click_state) & 1) != (uint)!!_pause) { |
1877 |
w->click_state ^= (1 << 0); |
|
1878 |
SetWindowDirty(w); |
|
1879 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1880 |
|
0 | 1881 |
if (((w->click_state >> 1) & 1) != (uint)!!_fast_forward) { |
1882 |
w->click_state ^= (1 << 1); |
|
1883 |
SetWindowDirty(w); |
|
1884 |
} |
|
1885 |
break; |
|
1886 |
||
1887 |
case WE_TIMEOUT: |
|
1888 |
UnclickSomeWindowButtons(w, ~(1<<0 | 1<<1)); |
|
1889 |
break; |
|
1890 |
} |
|
1891 |
} |
|
1892 |
||
1893 |
static const Widget _toolb_normal_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1894 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 21, 0, 21, 0x2D6, STR_0171_PAUSE_GAME}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1895 |
{ WWT_PANEL, RESIZE_NONE, 14, 22, 43, 0, 21, SPR_OPENTTD_BASE + 57, STR_FAST_FORWARD}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1896 |
{ WWT_PANEL, RESIZE_NONE, 14, 44, 65, 0, 21, 0x2EF, STR_0187_OPTIONS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1897 |
{ WWT_PANEL_2, RESIZE_NONE, 14, 66, 87, 0, 21, 0x2D4, STR_0172_SAVE_GAME_ABANDON_GAME}, |
0 | 1898 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1899 |
{ WWT_PANEL, RESIZE_NONE, 14, 96, 117, 0, 21, 0x2C4, STR_0174_DISPLAY_MAP}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1900 |
{ WWT_PANEL, RESIZE_NONE, 14, 118, 139, 0, 21, 0xFED, STR_0176_DISPLAY_TOWN_DIRECTORY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1901 |
{ WWT_PANEL, RESIZE_NONE, 14, 140, 161, 0, 21, 0x2A7, STR_02DC_DISPLAY_SUBSIDIES}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1902 |
{ WWT_PANEL, RESIZE_NONE, 14, 162, 183, 0, 21, 0x513, STR_0173_DISPLAY_LIST_OF_COMPANY}, |
0 | 1903 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1904 |
{ WWT_PANEL, RESIZE_NONE, 14, 191, 212, 0, 21, 0x2E1, STR_0177_DISPLAY_COMPANY_FINANCES}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1905 |
{ WWT_PANEL, RESIZE_NONE, 14, 213, 235, 0, 21, 0x2E7, STR_0178_DISPLAY_COMPANY_GENERAL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1906 |
{ WWT_PANEL, RESIZE_NONE, 14, 236, 257, 0, 21, 0x2E9, STR_0179_DISPLAY_GRAPHS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1907 |
{ WWT_PANEL, RESIZE_NONE, 14, 258, 279, 0, 21, 0x2AC, STR_017A_DISPLAY_COMPANY_LEAGUE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1908 |
{ WWT_PANEL, RESIZE_NONE, 14, 280, 301, 0, 21, 0x2E5, STR_0312_FUND_CONSTRUCTION_OF_NEW}, |
0 | 1909 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1910 |
{ WWT_PANEL, RESIZE_NONE, 14, 310, 331, 0, 21, 0x2DB, STR_017B_DISPLAY_LIST_OF_COMPANY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1911 |
{ WWT_PANEL, RESIZE_NONE, 14, 332, 353, 0, 21, 0x2DC, STR_017C_DISPLAY_LIST_OF_COMPANY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1912 |
{ WWT_PANEL, RESIZE_NONE, 14, 354, 375, 0, 21, 0x2DD, STR_017D_DISPLAY_LIST_OF_COMPANY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1913 |
{ WWT_PANEL, RESIZE_NONE, 14, 376, 397, 0, 21, 0x2DE, STR_017E_DISPLAY_LIST_OF_COMPANY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1914 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1915 |
{ WWT_PANEL, RESIZE_NONE, 14, 406, 427, 0, 21, 0x2DF, STR_017F_ZOOM_THE_VIEW_IN}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1916 |
{ WWT_PANEL, RESIZE_NONE, 14, 428, 449, 0, 21, 0x2E0, STR_0180_ZOOM_THE_VIEW_OUT}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1917 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1918 |
{ WWT_PANEL, RESIZE_NONE, 14, 457, 478, 0, 21, 0x2D7, STR_0181_BUILD_RAILROAD_TRACK}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1919 |
{ WWT_PANEL, RESIZE_NONE, 14, 479, 500, 0, 21, 0x2D8, STR_0182_BUILD_ROADS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1920 |
{ WWT_PANEL, RESIZE_NONE, 14, 501, 522, 0, 21, 0x2D9, STR_0183_BUILD_SHIP_DOCKS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1921 |
{ WWT_PANEL, RESIZE_NONE, 14, 523, 544, 0, 21, 0x2DA, STR_0184_BUILD_AIRPORTS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1922 |
{ WWT_PANEL, RESIZE_NONE, 14, 545, 566, 0, 21, 0xFF3, STR_LANDSCAPING_TOOLBAR_TIP}, // tree icon is 0x2E6 |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1923 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1924 |
{ WWT_PANEL, RESIZE_NONE, 14, 574, 595, 0, 21, 0x2C9, STR_01D4_SHOW_SOUND_MUSIC_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1925 |
{ WWT_PANEL, RESIZE_NONE, 14, 596, 617, 0, 21, 0x2A8, STR_0203_SHOW_LAST_MESSAGE_NEWS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1926 |
{ WWT_PANEL, RESIZE_NONE, 14, 618, 639, 0, 21, 0x2D3, STR_0186_LAND_BLOCK_INFORMATION}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1927 |
{ WIDGETS_END}, |
0 | 1928 |
}; |
1929 |
||
1930 |
static const WindowDesc _toolb_normal_desc = { |
|
1931 |
0, 0, 640, 22, |
|
1932 |
WC_MAIN_TOOLBAR,0, |
|
1933 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET, |
|
1934 |
_toolb_normal_widgets, |
|
1935 |
MainToolbarWndProc |
|
1936 |
}; |
|
1937 |
||
1938 |
static const WindowDesc _toolb_intro_desc = { |
|
1939 |
0, -22, 640, 22, |
|
1940 |
WC_MAIN_TOOLBAR,0, |
|
1941 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET, |
|
1942 |
_toolb_normal_widgets, |
|
1943 |
MainToolbarWndProc |
|
1944 |
}; |
|
1945 |
||
1946 |
||
1947 |
static const Widget _toolb_scen_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1948 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 21, 0, 21, 0x2D6, STR_0171_PAUSE_GAME}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1949 |
{ WWT_PANEL, RESIZE_NONE, 14, 22, 43, 0, 21, SPR_OPENTTD_BASE + 57, STR_FAST_FORWARD}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1950 |
{ WWT_PANEL, RESIZE_NONE, 14, 44, 65, 0, 21, 0x2EF, STR_0187_OPTIONS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1951 |
{ WWT_PANEL_2, RESIZE_NONE, 14, 66, 87, 0, 21, 0x2D4, STR_0297_SAVE_SCENARIO_LOAD_SCENARIO}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1952 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1953 |
{ WWT_PANEL, RESIZE_NONE, 14, 96, 225, 0, 21, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1954 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1955 |
{ WWT_PANEL, RESIZE_NONE, 14, 233, 362, 0, 21, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1956 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 236, 246, 5, 16, STR_0225, STR_029E_MOVE_THE_STARTING_DATE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1957 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 347, 357, 5, 16, STR_0224, STR_029F_MOVE_THE_STARTING_DATE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1958 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1959 |
{ WWT_PANEL, RESIZE_NONE, 14, 371, 392, 0, 21, 0x2C4, STR_0175_DISPLAY_MAP_TOWN_DIRECTORY}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1960 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1961 |
{ WWT_PANEL, RESIZE_NONE, 14, 400, 421, 0, 21, 0x2DF, STR_017F_ZOOM_THE_VIEW_IN}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1962 |
{ WWT_PANEL, RESIZE_NONE, 14, 422, 443, 0, 21, 0x2E0, STR_0180_ZOOM_THE_VIEW_OUT}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1963 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1964 |
{ WWT_PANEL, RESIZE_NONE, 14, 452, 473, 0, 21, 0xFF3, STR_022E_LANDSCAPE_GENERATION}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1965 |
{ WWT_PANEL, RESIZE_NONE, 14, 474, 495, 0, 21, 0xFED, STR_022F_TOWN_GENERATION}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1966 |
{ WWT_PANEL, RESIZE_NONE, 14, 496, 517, 0, 21, 0x2E5, STR_0230_INDUSTRY_GENERATION}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1967 |
{ WWT_PANEL, RESIZE_NONE, 14, 518, 539, 0, 21, 0x2D8, STR_0231_ROAD_CONSTRUCTION}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1968 |
{ WWT_PANEL, RESIZE_NONE, 14, 540, 561, 0, 21, 0x2E6, STR_0288_PLANT_TREES}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1969 |
{ WWT_PANEL, RESIZE_NONE, 14, 562, 583, 0, 21, 0xFF2, STR_0289_PLACE_SIGN}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1970 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1971 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1972 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1973 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1974 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1975 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1976 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1977 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1978 |
{ WWT_PANEL, RESIZE_NONE, 14, 596, 617, 0, 21, 0x2C9, STR_01D4_SHOW_SOUND_MUSIC_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1979 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
1980 |
{ WWT_PANEL, RESIZE_NONE, 14, 618, 639, 0, 21, 0x2D3, STR_0186_LAND_BLOCK_INFORMATION}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
168
diff
changeset
|
1981 |
{ WIDGETS_END}, |
0 | 1982 |
}; |
1983 |
||
1984 |
static ToolbarButtonProc* const _scen_toolbar_button_procs[] = { |
|
1985 |
ToolbarPauseClick, |
|
1986 |
ToolbarFastForwardClick, |
|
1987 |
ToolbarOptionsClick, |
|
1988 |
ToolbarScenSaveOrLoad, |
|
1989 |
ToolbarBtn_NULL, |
|
1990 |
ToolbarBtn_NULL, |
|
1991 |
ToolbarScenDateBackward, |
|
1992 |
ToolbarScenDateForward, |
|
1993 |
ToolbarScenMapTownDir, |
|
1994 |
ToolbarScenZoomIn, |
|
1995 |
ToolbarScenZoomOut, |
|
1996 |
ToolbarScenGenLand, |
|
1997 |
ToolbarScenGenTown, |
|
1998 |
ToolbarScenGenIndustry, |
|
1999 |
ToolbarScenBuildRoad, |
|
2000 |
ToolbarScenPlantTrees, |
|
2001 |
ToolbarScenPlaceSign, |
|
2002 |
NULL, |
|
2003 |
NULL, |
|
2004 |
NULL, |
|
2005 |
NULL, |
|
2006 |
NULL, |
|
2007 |
NULL, |
|
2008 |
NULL, |
|
2009 |
ToolbarMusicClick, |
|
2010 |
NULL, |
|
2011 |
ToolbarHelpClick, |
|
2012 |
}; |
|
2013 |
||
2014 |
static void ScenEditToolbarWndProc(Window *w, WindowEvent *e) |
|
2015 |
{ |
|
2016 |
switch(e->event) { |
|
2017 |
case WE_PAINT: |
|
349
47cdc8ab9cf7
(svn r532) Disable date change buttons in scenario editor if date limit is reached.
tron
parents:
337
diff
changeset
|
2018 |
/* XXX look for better place for these */ |
47cdc8ab9cf7
(svn r532) Disable date change buttons in scenario editor if date limit is reached.
tron
parents:
337
diff
changeset
|
2019 |
if (_date <= MinDate) |
47cdc8ab9cf7
(svn r532) Disable date change buttons in scenario editor if date limit is reached.
tron
parents:
337
diff
changeset
|
2020 |
SETBIT(w->disabled_state, 6); |
47cdc8ab9cf7
(svn r532) Disable date change buttons in scenario editor if date limit is reached.
tron
parents:
337
diff
changeset
|
2021 |
else |
47cdc8ab9cf7
(svn r532) Disable date change buttons in scenario editor if date limit is reached.
tron
parents:
337
diff
changeset
|
2022 |
CLRBIT(w->disabled_state, 6); |
47cdc8ab9cf7
(svn r532) Disable date change buttons in scenario editor if date limit is reached.
tron
parents:
337
diff
changeset
|
2023 |
if (_date >= MaxDate) |
47cdc8ab9cf7
(svn r532) Disable date change buttons in scenario editor if date limit is reached.
tron
parents:
337
diff
changeset
|
2024 |
SETBIT(w->disabled_state, 7); |
47cdc8ab9cf7
(svn r532) Disable date change buttons in scenario editor if date limit is reached.
tron
parents:
337
diff
changeset
|
2025 |
else |
47cdc8ab9cf7
(svn r532) Disable date change buttons in scenario editor if date limit is reached.
tron
parents:
337
diff
changeset
|
2026 |
CLRBIT(w->disabled_state, 7); |
47cdc8ab9cf7
(svn r532) Disable date change buttons in scenario editor if date limit is reached.
tron
parents:
337
diff
changeset
|
2027 |
|
0 | 2028 |
// Draw brown-red toolbar bg. |
2029 |
GfxFillRect(0, 0, w->width-1, w->height-1, 0xB2); |
|
2030 |
GfxFillRect(0, 0, w->width-1, w->height-1, 0x80B4); |
|
2031 |
||
2032 |
DrawWindowWidgets(w); |
|
2033 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
2034 |
SetDParam(0, _date); |
0 | 2035 |
DrawStringCentered(298, 6, STR_00AF, 0); |
2036 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
2037 |
SetDParam(0, _date); |
74
d23a80ef6361
(svn r75) -Add proper crediting to graphics artists to about box.
darkvater
parents:
68
diff
changeset
|
2038 |
DrawStringCentered(161, 1, STR_0221_OPENTTD, 0); |
0 | 2039 |
DrawStringCentered(161, 11,STR_0222_SCENARIO_EDITOR, 0); |
2040 |
||
2041 |
break; |
|
2042 |
||
2043 |
case WE_CLICK: { |
|
2044 |
if (_game_mode == GM_MENU) |
|
2045 |
return; |
|
2046 |
_scen_toolbar_button_procs[e->click.widget](w); |
|
2047 |
} break; |
|
2048 |
||
2049 |
case WE_KEYPRESS: { |
|
2050 |
switch(e->keypress.keycode) { |
|
2051 |
case WKC_F1: ToolbarPauseClick(w); break; |
|
2052 |
case WKC_F2: ShowGameOptions(); break; |
|
2053 |
case WKC_F3: MenuClickSaveLoad(0); break; |
|
2054 |
case WKC_F4: ToolbarScenGenLand(w); break; |
|
2055 |
case WKC_F5: ToolbarScenGenTown(w); break; |
|
2056 |
case WKC_F6: ToolbarScenGenIndustry(w); break; |
|
2057 |
case WKC_F7: ToolbarScenBuildRoad(w); break; |
|
2058 |
case WKC_F8: ToolbarScenPlantTrees(w); break; |
|
2059 |
case WKC_F9: ToolbarScenPlaceSign(w); break; |
|
2060 |
case WKC_F10: ShowMusicWindow(); break; |
|
2061 |
case WKC_F11: PlaceLandBlockInfo(); break; |
|
2062 |
case WKC_CTRL | 'S': _make_screenshot = 1; break; |
|
2063 |
case WKC_CTRL | 'G': _make_screenshot = 2; break; |
|
2064 |
} |
|
2065 |
break; |
|
2066 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
2067 |
|
0 | 2068 |
case WE_PLACE_OBJ: { |
2069 |
_place_proc(e->place.tile); |
|
2070 |
} break; |
|
2071 |
||
2072 |
case WE_ABORT_PLACE_OBJ: { |
|
2073 |
w->click_state &= ~(1<<25); |
|
2074 |
SetWindowDirty(w); |
|
2075 |
} break; |
|
2076 |
||
2077 |
case WE_ON_EDIT_TEXT: HandleOnEditText(e); break; |
|
2078 |
||
2079 |
case WE_MOUSELOOP: |
|
24 | 2080 |
if (((w->click_state) & 1) != (uint)!!_pause) { |
2081 |
w->click_state ^= (1 << 0); |
|
2082 |
SetWindowDirty(w); |
|
2083 |
} |
|
2084 |
||
0 | 2085 |
if (((w->click_state >> 1) & 1) != (uint)!!_fast_forward) { |
2086 |
w->click_state ^= (1 << 1); |
|
2087 |
SetWindowDirty(w); |
|
2088 |
} |
|
2089 |
break; |
|
2090 |
||
2091 |
} |
|
2092 |
} |
|
2093 |
||
2094 |
static const WindowDesc _toolb_scen_desc = { |
|
2095 |
0, 0, 640, 22, |
|
2096 |
WC_MAIN_TOOLBAR,0, |
|
2097 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
2098 |
_toolb_scen_widgets, |
|
2099 |
ScenEditToolbarWndProc |
|
2100 |
}; |
|
2101 |
||
2102 |
extern GetNewsStringCallbackProc * const _get_news_string_callback[]; |
|
2103 |
||
2104 |
||
2105 |
static bool DrawScrollingStatusText(NewsItem *ni, int pos) |
|
2106 |
{ |
|
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1329
diff
changeset
|
2107 |
char buf[512]; |
0 | 2108 |
StringID str; |
1329 | 2109 |
const char *s; |
2110 |
char *d; |
|
0 | 2111 |
DrawPixelInfo tmp_dpi, *old_dpi; |
2112 |
int x; |
|
1329 | 2113 |
char buffer[256]; |
0 | 2114 |
|
2115 |
if (ni->display_mode == 3) { |
|
2116 |
str = _get_news_string_callback[ni->callback](ni); |
|
2117 |
} else { |
|
2118 |
COPY_IN_DPARAM(0, ni->params, lengthof(ni->params)); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
2119 |
str = ni->string_id; |
0 | 2120 |
} |
2121 |
||
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1329
diff
changeset
|
2122 |
GetString(buf, str); |
0 | 2123 |
|
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1329
diff
changeset
|
2124 |
s = buf; |
0 | 2125 |
d = buffer; |
2126 |
||
2127 |
for(;;s++) { |
|
2128 |
if (*s == 0) { |
|
2129 |
*d = 0; |
|
2130 |
break; |
|
2131 |
} else if (*s == 0x0D) { |
|
2132 |
d[0] = d[1] = d[2] = d[3] = ' '; |
|
2133 |
d+=4; |
|
1329 | 2134 |
} else if ((byte)*s >= ' ' && ((byte)*s < 0x88 || (byte)*s >= 0x99)) { |
0 | 2135 |
*d++ = *s; |
2136 |
} |
|
2137 |
} |
|
2138 |
||
2139 |
if (!FillDrawPixelInfo(&tmp_dpi, NULL, 141, 1, 358, 11)) |
|
2140 |
return true; |
|
2141 |
||
2142 |
old_dpi = _cur_dpi; |
|
2143 |
_cur_dpi = &tmp_dpi; |
|
2144 |
||
2145 |
x = DoDrawString(buffer, pos, 0, 13); |
|
2146 |
_cur_dpi = old_dpi; |
|
2147 |
||
2148 |
return x > 0; |
|
2149 |
} |
|
2150 |
||
410 | 2151 |
static void StatusBarWndProc(Window *w, WindowEvent *e) |
0 | 2152 |
{ |
2153 |
Player *p; |
|
2154 |
||
2155 |
switch(e->event) { |
|
2156 |
case WE_PAINT: |
|
2157 |
DrawWindowWidgets(w); |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
2158 |
SetDParam(0, _date); |
0 | 2159 |
DrawStringCentered(70, 1, ((_pause||_patches.status_long_date)?STR_00AF:STR_00AE), 0); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
2160 |
|
1 | 2161 |
p = _local_player == OWNER_SPECTATOR ? NULL : DEREF_PLAYER(_local_player); |
0 | 2162 |
|
2163 |
if (p) { |
|
2164 |
// Draw player money |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
2165 |
SetDParam64(0, p->money64); |
0 | 2166 |
DrawStringCentered(570, 1, p->player_money >= 0 ? STR_0004 : STR_0005, 0); |
2167 |
} |
|
2168 |
||
2169 |
// Draw status bar |
|
2170 |
if (_do_autosave) { |
|
2171 |
DrawStringCentered(320, 1, STR_032F_AUTOSAVE, 0); |
|
2172 |
} else if (_pause) { |
|
2173 |
DrawStringCentered(320, 1, STR_0319_PAUSED, 0); |
|
2174 |
} else if (WP(w,def_d).data_1 > -1280 && FindWindowById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) { |
|
2175 |
// Draw the scrolling news text |
|
2176 |
if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w,def_d).data_1)) |
|
2177 |
WP(w,def_d).data_1 = -1280; |
|
2178 |
} else { |
|
2179 |
if (p) { |
|
2180 |
// This is the default text |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
2181 |
SetDParam(0, p->name_1); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
2182 |
SetDParam(1, p->name_2); |
0 | 2183 |
DrawStringCentered(320, 1, STR_02BA, 0); |
2184 |
} |
|
2185 |
} |
|
2186 |
break; |
|
2187 |
||
2188 |
case WE_CLICK: |
|
2189 |
if (e->click.widget == 1) { |
|
2190 |
ShowLastNewsMessage(); |
|
2191 |
} else if (e->click.widget == 2) { |
|
1 | 2192 |
if (_local_player != OWNER_SPECTATOR) ShowPlayerFinances(_local_player); |
0 | 2193 |
} else { |
2194 |
ResetObjectToPlace(); |
|
2195 |
} |
|
2196 |
break; |
|
2197 |
||
2198 |
case WE_TICK: { |
|
2199 |
if (_pause || WP(w,def_d).data_1 <= -1280) |
|
2200 |
return; |
|
2201 |
WP(w,def_d).data_1 -= 2; |
|
2202 |
InvalidateWidget(w, 1); |
|
2203 |
break; |
|
2204 |
} |
|
2205 |
} |
|
2206 |
} |
|
2207 |
||
2208 |
static const Widget _main_status_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
2209 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 139, 0, 11, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
2210 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 140, 499, 0, 11, 0x0, STR_02B7_SHOW_LAST_MESSAGE_OR_NEWS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
815
diff
changeset
|
2211 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 14, 500, 639, 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
|
2212 |
{ WIDGETS_END}, |
0 | 2213 |
}; |
2214 |
||
2215 |
static WindowDesc _main_status_desc = { |
|
2216 |
WDP_CENTER, 0, 640, 12, |
|
2217 |
WC_STATUS_BAR,0, |
|
2218 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
2219 |
_main_status_widgets, |
|
2220 |
StatusBarWndProc |
|
2221 |
}; |
|
2222 |
||
2223 |
extern void DebugProc(int i); |
|
2224 |
||
2225 |
static void MainWindowWndProc(Window *w, WindowEvent *e) { |
|
2226 |
int off_x; |
|
2227 |
||
2228 |
switch(e->event) { |
|
2229 |
case WE_PAINT: |
|
2230 |
DrawWindowViewport(w); |
|
2231 |
if (_game_mode == GM_MENU) { |
|
581
ee767b9671a7
(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
|
2232 |
off_x = _screen.width / 2; |
0 | 2233 |
|
582
cc1bd1362c6c
(svn r1002) -Fixed the placement of the OpenTTD logo a bit (thx Jango).
darkvater
parents:
581
diff
changeset
|
2234 |
DrawSprite(SPR_OTTD_O, off_x - 120, 50); |
cc1bd1362c6c
(svn r1002) -Fixed the placement of the OpenTTD logo a bit (thx Jango).
darkvater
parents:
581
diff
changeset
|
2235 |
DrawSprite(SPR_OTTD_P, off_x - 86, 50); |
cc1bd1362c6c
(svn r1002) -Fixed the placement of the OpenTTD logo a bit (thx Jango).
darkvater
parents:
581
diff
changeset
|
2236 |
DrawSprite(SPR_OTTD_E, off_x - 53, 50); |
cc1bd1362c6c
(svn r1002) -Fixed the placement of the OpenTTD logo a bit (thx Jango).
darkvater
parents:
581
diff
changeset
|
2237 |
DrawSprite(SPR_OTTD_N, off_x - 22, 50); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
2238 |
|
582
cc1bd1362c6c
(svn r1002) -Fixed the placement of the OpenTTD logo a bit (thx Jango).
darkvater
parents:
581
diff
changeset
|
2239 |
DrawSprite(SPR_OTTD_T, off_x + 34, 50); |
cc1bd1362c6c
(svn r1002) -Fixed the placement of the OpenTTD logo a bit (thx Jango).
darkvater
parents:
581
diff
changeset
|
2240 |
DrawSprite(SPR_OTTD_T, off_x + 65, 50); |
cc1bd1362c6c
(svn r1002) -Fixed the placement of the OpenTTD logo a bit (thx Jango).
darkvater
parents:
581
diff
changeset
|
2241 |
DrawSprite(SPR_OTTD_D, off_x + 96, 50); |
670
7c58dc46609c
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
658
diff
changeset
|
2242 |
|
581
ee767b9671a7
(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
|
2243 |
/* |
ee767b9671a7
(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
|
2244 |
DrawSprite(SPR_OTTD_R, off_x + 119, 50); |
ee767b9671a7
(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
|
2245 |
DrawSprite(SPR_OTTD_A, off_x + 148, 50); |
ee767b9671a7
(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
|
2246 |
DrawSprite(SPR_OTTD_N, off_x + 181, 50); |
ee767b9671a7
(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
|
2247 |
DrawSprite(SPR_OTTD_S, off_x + 215, 50); |
ee767b9671a7
(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
|
2248 |
DrawSprite(SPR_OTTD_P, off_x + 246, 50); |
ee767b9671a7
(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
|
2249 |
DrawSprite(SPR_OTTD_O, off_x + 275, 50); |
ee767b9671a7
(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
|
2250 |
DrawSprite(SPR_OTTD_R, off_x + 307, 50); |
ee767b9671a7
(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
|
2251 |
DrawSprite(SPR_OTTD_T, off_x + 337, 50); |
ee767b9671a7
(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
|
2252 |
|
ee767b9671a7
(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
|
2253 |
DrawSprite(SPR_OTTD_T, off_x + 390, 50); |
ee767b9671a7
(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
|
2254 |
DrawSprite(SPR_OTTD_Y, off_x + 417, 50); |
ee767b9671a7
(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
|
2255 |
DrawSprite(SPR_OTTD_C, off_x + 447, 50); |
ee767b9671a7
(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
|
2256 |
DrawSprite(SPR_OTTD_O, off_x + 478, 50); |
ee767b9671a7
(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
|
2257 |
DrawSprite(SPR_OTTD_O, off_x + 509, 50); |
ee767b9671a7
(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
|
2258 |
DrawSprite(SPR_OTTD_N, off_x + 541, 50); |
ee767b9671a7
(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
|
2259 |
*/ |
0 | 2260 |
} |
2261 |
break; |
|
2262 |
||
2263 |
case WE_KEYPRESS: |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1397
diff
changeset
|
2264 |
if (e->keypress.keycode == WKC_BACKQUOTE) { |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1397
diff
changeset
|
2265 |
IConsoleSwitch(); |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1397
diff
changeset
|
2266 |
e->keypress.cont = false; |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1397
diff
changeset
|
2267 |
break; |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1397
diff
changeset
|
2268 |
} |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1397
diff
changeset
|
2269 |
|
0 | 2270 |
if (_game_mode == GM_MENU) |
2271 |
break; |
|
2272 |
||
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1397
diff
changeset
|
2273 |
switch (e->keypress.keycode) { |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1397
diff
changeset
|
2274 |
case 'C': case 'Z': { |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1397
diff
changeset
|
2275 |
Point pt = GetTileBelowCursor(); |
0 | 2276 |
if (pt.x != -1) { |
2277 |
ScrollMainWindowTo(pt.x, pt.y); |
|
2278 |
if (e->keypress.keycode == 'Z') |
|
2279 |
MaxZoomIn(); |
|
2280 |
} |
|
2281 |
break; |
|
2282 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
2283 |
|
0 | 2284 |
case WKC_ESC: ResetObjectToPlace(); break; |
2285 |
case WKC_DELETE: DeleteNonVitalWindows(); break; |
|
763
8ff348acf75e
(svn r1225) -Feature: SHIFT+DEL now deletes all non-vital windows (only status bar and main bar remain)
darkvater
parents:
758
diff
changeset
|
2286 |
case WKC_DELETE | WKC_SHIFT: DeleteAllNonVitalWindows(); break; |
0 | 2287 |
case 'Q' | WKC_CTRL: AskExitGame(); break; |
2288 |
case 'Q' | WKC_META: AskExitGame(); break; // this enables command + Q on mac |
|
2289 |
case 'R' | WKC_CTRL: MarkWholeScreenDirty(); break; |
|
2290 |
case '0' | WKC_ALT: |
|
2291 |
case '1' | WKC_ALT: |
|
2292 |
case '2' | WKC_ALT: |
|
2293 |
case '3' | WKC_ALT: |
|
2294 |
case '4' | WKC_ALT: |
|
2295 |
#if defined(_DEBUG) |
|
2296 |
DebugProc(e->keypress.keycode - ('0' | WKC_ALT)); |
|
2297 |
#endif |
|
2298 |
break; |
|
2299 |
||
2300 |
// invoke autorail |
|
2301 |
case 'A': |
|
658
ed6a0ea93a6c
(svn r1092) Fix: Autorail can be accessed with the 'a' hotkey again
dominik
parents:
649
diff
changeset
|
2302 |
ShowBuildRailToolbar(_last_built_railtype, 4); |
0 | 2303 |
break; |
2304 |
||
670
7c58dc46609c
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
658
diff
changeset
|
2305 |
case 'L': |
7c58dc46609c
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
658
diff
changeset
|
2306 |
ShowTerraformToolbar(); |
616
3ab1124303e0
(svn r1040) Fix: All character hotkeys are disabled now when a window for typing is open
dominik
parents:
611
diff
changeset
|
2307 |
break; |
3ab1124303e0
(svn r1040) Fix: All character hotkeys are disabled now when a window for typing is open
dominik
parents:
611
diff
changeset
|
2308 |
|
0 | 2309 |
case 'X': |
2310 |
_display_opt ^= DO_TRANS_BUILDINGS; |
|
2311 |
MarkWholeScreenDirty(); |
|
2312 |
break; |
|
2313 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
2314 |
#ifdef ENABLE_NETWORK |
649 | 2315 |
case WKC_RETURN: |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
2316 |
case 'T' | WKC_SHIFT: |
649 | 2317 |
if(_networking) |
2318 |
ShowNetworkChatQueryWindow(DESTTYPE_BROADCAST, 0); |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
2319 |
break; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
2320 |
#endif /* ENABLE_NETWORK */ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
541
diff
changeset
|
2321 |
|
0 | 2322 |
default: |
2323 |
return; |
|
2324 |
} |
|
2325 |
e->keypress.cont = false; |
|
2326 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
2327 |
|
0 | 2328 |
} |
2329 |
} |
|
2330 |
||
2331 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
2332 |
void ShowSelectGameWindow(void); |
774
258c11431acb
(svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.
darkvater
parents:
763
diff
changeset
|
2333 |
extern void ShowJoinStatusWindowAfterJoin(void); |
0 | 2334 |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
2335 |
void SetupColorsAndInitialWindow(void) |
0 | 2336 |
{ |
2337 |
int i; |
|
2338 |
Window *w; |
|
2339 |
int width,height; |
|
2340 |
||
2341 |
for(i=0; i!=16; i++) { |
|
1357 | 2342 |
const byte* b = GetNonSprite(0x307 + i); |
2343 |
||
0 | 2344 |
assert(b); |
2345 |
_color_list[i] = *(ColorList*)(b + 0xC6); |
|
2346 |
} |
|
2347 |
||
2348 |
width = _screen.width; |
|
2349 |
height = _screen.height; |
|
2350 |
||
2351 |
// XXX: these are not done |
|
2352 |
switch(_game_mode) { |
|
2353 |
case GM_MENU: |
|
2354 |
w = AllocateWindow(0, 0, width, height, MainWindowWndProc, 0, NULL); |
|
1218 | 2355 |
AssignWindowViewport(w, 0, 0, width, height, TILE_XY(32, 32), 0); |
0 | 2356 |
// w = AllocateWindowDesc(&_toolb_intro_desc); |
2357 |
// w->flags4 &= ~WF_WHITE_BORDER_MASK; |
|
2358 |
ShowSelectGameWindow(); |
|
2359 |
break; |
|
2360 |
case GM_NORMAL: |
|
2361 |
w = AllocateWindow(0, 0, width, height, MainWindowWndProc, 0, NULL); |
|
1218 | 2362 |
AssignWindowViewport(w, 0, 0, width, height, TILE_XY(32, 32), 0); |
0 | 2363 |
|
983
1be852dcdd4c
(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
|
2364 |
ShowVitalWindows(); |
0 | 2365 |
|
670
7c58dc46609c
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
658
diff
changeset
|
2366 |
/* Bring joining GUI to front till the client is really joined */ |
7c58dc46609c
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
658
diff
changeset
|
2367 |
if (_networking && !_network_server) |
7c58dc46609c
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
658
diff
changeset
|
2368 |
ShowJoinStatusWindowAfterJoin(); |
7c58dc46609c
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
truelight
parents:
658
diff
changeset
|
2369 |
|
0 | 2370 |
break; |
2371 |
case GM_EDITOR: |
|
2372 |
w = AllocateWindow(0, 0, width, height, MainWindowWndProc, 0, NULL); |
|
2373 |
AssignWindowViewport(w, 0, 0, width, height, 0, 0); |
|
2374 |
||
2375 |
w = AllocateWindowDesc(&_toolb_scen_desc); |
|
2376 |
w->disabled_state = 1 << 9; |
|
983
1be852dcdd4c
(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
|
2377 |
CLRBITS(w->flags4, WF_WHITE_BORDER_MASK); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
2378 |
|
68
4051f3c8efa2
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents:
24
diff
changeset
|
2379 |
PositionMainToolbar(w); // already WC_MAIN_TOOLBAR passed (&_toolb_scen_desc) |
0 | 2380 |
break; |
2381 |
default: |
|
2382 |
NOT_REACHED(); |
|
2383 |
} |
|
2384 |
} |
|
2385 |
||
983
1be852dcdd4c
(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
|
2386 |
void ShowVitalWindows(void) |
1be852dcdd4c
(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
|
2387 |
{ |
1be852dcdd4c
(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
|
2388 |
Window *w; |
1be852dcdd4c
(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
|
2389 |
|
1be852dcdd4c
(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
|
2390 |
w = AllocateWindowDesc(&_toolb_normal_desc); |
1be852dcdd4c
(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
|
2391 |
w->disabled_state = 1 << 17; // disable zoom-in button (by default game is zoomed in) |
1be852dcdd4c
(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
|
2392 |
CLRBITS(w->flags4, WF_WHITE_BORDER_MASK); |
1be852dcdd4c
(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
|
2393 |
|
1be852dcdd4c
(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
|
2394 |
if (_networking) { // if networking, disable fast-forward button |
1be852dcdd4c
(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
|
2395 |
SETBIT(w->disabled_state, 1); |
1be852dcdd4c
(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
|
2396 |
if (!_network_server) // if not server, disable pause button |
1be852dcdd4c
(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
|
2397 |
SETBIT(w->disabled_state, 0); |
1be852dcdd4c
(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
|
2398 |
} |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1015
diff
changeset
|
2399 |
|
983
1be852dcdd4c
(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
|
2400 |
PositionMainToolbar(w); // already WC_MAIN_TOOLBAR passed (&_toolb_normal_desc) |
1be852dcdd4c
(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
|
2401 |
|
1be852dcdd4c
(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
|
2402 |
_main_status_desc.top = _screen.height - 12; |
1be852dcdd4c
(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
|
2403 |
w = AllocateWindowDesc(&_main_status_desc); |
1be852dcdd4c
(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
|
2404 |
CLRBITS(w->flags4, WF_WHITE_BORDER_MASK); |
1be852dcdd4c
(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
|
2405 |
|
1be852dcdd4c
(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
|
2406 |
WP(w,def_d).data_1 = -1280; |
1be852dcdd4c
(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
|
2407 |
} |
1be852dcdd4c
(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
|
2408 |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
2409 |
void GameSizeChanged(void) |
0 | 2410 |
{ |
2411 |
RelocateAllWindows(_screen.width, _screen.height); |
|
2412 |
ScreenSizeChanged(); |
|
2413 |
MarkWholeScreenDirty(); |
|
2414 |
} |