annotate src/town_gui.cpp @ 9111:d48433370037 draft

(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
author rubidium <rubidium@openttd.org>
date Tue, 06 May 2008 15:11:33 +0000
parents a3f3038e9b9a
children 44beb31166aa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1 /* $Id$ */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2
9111
d48433370037 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents: 9094
diff changeset
3 /** @file town_gui.cpp GUI for towns. */
6422
fb10eafe2a26 (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents: 6247
diff changeset
4
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
5 #include "stdafx.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
6 #include "openttd.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
7 #include "debug.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
8 #include "town.h"
8224
c45446125bf0 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents: 8131
diff changeset
9 #include "viewport_func.h"
c45446125bf0 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents: 8131
diff changeset
10 #include "gfx_func.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
11 #include "gui.h"
8107
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
12 #include "window_gui.h"
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
13 #include "textbuf_gui.h"
8116
9cc845deddfe (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium <rubidium@openttd.org>
parents: 8114
diff changeset
14 #include "command_func.h"
8254
7d580c9c41fb (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium <rubidium@openttd.org>
parents: 8224
diff changeset
15 #include "player_func.h"
7d580c9c41fb (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium <rubidium@openttd.org>
parents: 8224
diff changeset
16 #include "player_base.h"
7d580c9c41fb (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium <rubidium@openttd.org>
parents: 8224
diff changeset
17 #include "player_gui.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
18 #include "network/network.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
19 #include "variables.h"
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents: 8107
diff changeset
20 #include "strings_func.h"
8723
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
21 #include "sound_func.h"
8116
9cc845deddfe (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium <rubidium@openttd.org>
parents: 8114
diff changeset
22 #include "economy_func.h"
8130
0586823afe39 (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium <rubidium@openttd.org>
parents: 8121
diff changeset
23 #include "core/alloc_func.hpp"
8270
5613b863190d (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium <rubidium@openttd.org>
parents: 8264
diff changeset
24 #include "settings_type.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
25
8264
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
26 #include "table/sprites.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
27 #include "table/strings.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
28
8723
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
29 extern bool GenerateTowns();
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
30 static int _scengen_town_size = 1; // depress medium-sized towns per default
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
31
7657
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
32 enum TownAuthorityWidget {
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
33 TWA_CLOSEBOX = 0,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
34 TWA_CAPTION,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
35 TWA_RATING_INFO,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
36 TWA_COMMAND_LIST,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
37 TWA_SCROLLBAR,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
38 TWA_ACTION_INFO,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
39 TWA_EXECUTE,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
40 };
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
41
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
42 static const Widget _town_authority_widgets[] = {
7657
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
43 { WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // TWA_CLOSEBOX
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
44 { WWT_CAPTION, RESIZE_NONE, 13, 11, 316, 0, 13, STR_2022_LOCAL_AUTHORITY, STR_018C_WINDOW_TITLE_DRAG_THIS}, // TWA_CAPTION
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
45 { WWT_PANEL, RESIZE_NONE, 13, 0, 316, 14, 105, 0x0, STR_NULL}, // TWA_RATING_INFO
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
46 { WWT_PANEL, RESIZE_NONE, 13, 0, 304, 106, 157, 0x0, STR_2043_LIST_OF_THINGS_TO_DO_AT}, // TWA_COMMAND_LIST
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
47 { WWT_SCROLLBAR, RESIZE_NONE, 13, 305, 316, 106, 157, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // TWA_SCROLLBAR
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
48 { WWT_PANEL, RESIZE_NONE, 13, 0, 316, 158, 209, 0x0, STR_NULL}, // TWA_ACTION_INFO
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
49 { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 0, 316, 210, 221, STR_2042_DO_IT, STR_2044_CARRY_OUT_THE_HIGHLIGHTED}, // TWA_EXECUTE
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
50 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
51 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
52
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
53 extern const byte _town_action_costs[8];
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
54
7657
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
55 enum TownActions {
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
56 TACT_NONE = 0x00,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
57
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
58 TACT_ADVERTISE_SMALL = 0x01,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
59 TACT_ADVERTISE_MEDIUM = 0x02,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
60 TACT_ADVERTISE_LARGE = 0x04,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
61 TACT_ROAD_REBUILD = 0x08,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
62 TACT_BUILD_STATUE = 0x10,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
63 TACT_FOUND_BUILDINGS = 0x20,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
64 TACT_BUY_RIGHTS = 0x40,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
65 TACT_BRIBE = 0x80,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
66
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
67 TACT_ADVERTISE = TACT_ADVERTISE_SMALL | TACT_ADVERTISE_MEDIUM | TACT_ADVERTISE_LARGE,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
68 TACT_CONSTRUCTION = TACT_ROAD_REBUILD | TACT_BUILD_STATUE | TACT_FOUND_BUILDINGS,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
69 TACT_FUNDS = TACT_BUY_RIGHTS | TACT_BRIBE,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
70 TACT_ALL = TACT_ADVERTISE | TACT_CONSTRUCTION | TACT_FUNDS,
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
71 };
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
72
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
73 DECLARE_ENUM_AS_BIT_SET(TownActions);
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
74
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
75 /** Get a list of available actions to do at a town.
6422
fb10eafe2a26 (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents: 6247
diff changeset
76 * @param nump if not NULL add put the number of available actions in it
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
77 * @param pid the player that is querying the town
6422
fb10eafe2a26 (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents: 6247
diff changeset
78 * @param t the town that is queried
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
79 * @return bitmasked value of enabled actions
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
80 */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
81 uint GetMaskOfTownActions(int *nump, PlayerID pid, const Town *t)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
82 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
83 int num = 0;
7657
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
84 TownActions buttons = TACT_NONE;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
85
7657
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
86 /* Spectators and unwanted have no options */
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
87 if (pid != PLAYER_SPECTATOR && !(_patches.bribe && t->unwanted[pid])) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
88
6422
fb10eafe2a26 (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents: 6247
diff changeset
89 /* Things worth more than this are not shown */
7657
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
90 Money avail = GetPlayer(pid)->player_money + _price.station_value * 200;
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
91 Money ref = _price.build_industry >> 8;
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
92
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
93 /* Check the action bits for validity and
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
94 * if they are valid add them */
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
95 for (uint i = 0; i != lengthof(_town_action_costs); i++) {
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
96 const TownActions cur = (TownActions)(1 << i);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
97
7657
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
98 /* Is the player not able to bribe ? */
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
99 if (cur == TACT_BRIBE && (!_patches.bribe || t->ratings[pid] >= RATING_BRIBE_MAXIMUM))
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
100 continue;
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
101
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
102 /* Is the player not able to buy exclusive rights ? */
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
103 if (cur == TACT_BUY_RIGHTS && !_patches.exclusive_rights)
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
104 continue;
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
105
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
106 /* Is the player not able to build a statue ? */
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7824
diff changeset
107 if (cur == TACT_BUILD_STATUE && HasBit(t->statues, pid))
7657
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
108 continue;
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
109
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
110 if (avail >= _town_action_costs[i] * ref) {
65ad965cd225 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium <rubidium@openttd.org>
parents: 7386
diff changeset
111 buttons |= cur;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
112 num++;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
113 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
114 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
115 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
116
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
117 if (nump != NULL) *nump = num;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
118 return buttons;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
119 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
120
7982
a3042fc837e1 (svn r11538) -Codechange: Rewrite GetNthSetBit in a more uncontroversial way and add its documentation
skidd13 <skidd13@openttd.org>
parents: 7954
diff changeset
121 /**
a3042fc837e1 (svn r11538) -Codechange: Rewrite GetNthSetBit in a more uncontroversial way and add its documentation
skidd13 <skidd13@openttd.org>
parents: 7954
diff changeset
122 * Get the position of the Nth set bit.
a3042fc837e1 (svn r11538) -Codechange: Rewrite GetNthSetBit in a more uncontroversial way and add its documentation
skidd13 <skidd13@openttd.org>
parents: 7954
diff changeset
123 *
a3042fc837e1 (svn r11538) -Codechange: Rewrite GetNthSetBit in a more uncontroversial way and add its documentation
skidd13 <skidd13@openttd.org>
parents: 7954
diff changeset
124 * If there is no Nth bit set return -1
a3042fc837e1 (svn r11538) -Codechange: Rewrite GetNthSetBit in a more uncontroversial way and add its documentation
skidd13 <skidd13@openttd.org>
parents: 7954
diff changeset
125 *
a3042fc837e1 (svn r11538) -Codechange: Rewrite GetNthSetBit in a more uncontroversial way and add its documentation
skidd13 <skidd13@openttd.org>
parents: 7954
diff changeset
126 * @param bits The value to search in
a3042fc837e1 (svn r11538) -Codechange: Rewrite GetNthSetBit in a more uncontroversial way and add its documentation
skidd13 <skidd13@openttd.org>
parents: 7954
diff changeset
127 * @param n The Nth set bit from which we want to know the position
a3042fc837e1 (svn r11538) -Codechange: Rewrite GetNthSetBit in a more uncontroversial way and add its documentation
skidd13 <skidd13@openttd.org>
parents: 7954
diff changeset
128 * @return The position of the Nth set bit
a3042fc837e1 (svn r11538) -Codechange: Rewrite GetNthSetBit in a more uncontroversial way and add its documentation
skidd13 <skidd13@openttd.org>
parents: 7954
diff changeset
129 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
130 static int GetNthSetBit(uint32 bits, int n)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
131 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
132 if (n >= 0) {
8005
ee6d40f79c32 (svn r11564) -Codechange: Increase the usage of the for_each_bit macro and rename it fitting to the naming style
skidd13 <skidd13@openttd.org>
parents: 7997
diff changeset
133 uint i;
ee6d40f79c32 (svn r11564) -Codechange: Increase the usage of the for_each_bit macro and rename it fitting to the naming style
skidd13 <skidd13@openttd.org>
parents: 7997
diff changeset
134 FOR_EACH_SET_BIT(i, bits) {
ee6d40f79c32 (svn r11564) -Codechange: Increase the usage of the for_each_bit macro and rename it fitting to the naming style
skidd13 <skidd13@openttd.org>
parents: 7997
diff changeset
135 n--;
7982
a3042fc837e1 (svn r11538) -Codechange: Rewrite GetNthSetBit in a more uncontroversial way and add its documentation
skidd13 <skidd13@openttd.org>
parents: 7954
diff changeset
136 if (n < 0) return i;
a3042fc837e1 (svn r11538) -Codechange: Rewrite GetNthSetBit in a more uncontroversial way and add its documentation
skidd13 <skidd13@openttd.org>
parents: 7954
diff changeset
137 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
138 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
139 return -1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
140 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
141
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
142 static void TownAuthorityWndProc(Window *w, WindowEvent *e)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
143 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
144 switch (e->event) {
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
145 case WE_PAINT: {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
146 const Town *t = GetTown(w->window_number);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
147 int numact;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
148 uint buttons = GetMaskOfTownActions(&numact, _local_player, t);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
149
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
150 SetVScrollCount(w, numact + 1);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
151
8969
01cc3ee6ecb1 (svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium <rubidium@openttd.org>
parents: 8945
diff changeset
152 if (WP(w, def_d).data_1 != -1 && !HasBit(buttons, WP(w, def_d).data_1))
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
153 WP(w, def_d).data_1 = -1;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
154
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
155 w->SetWidgetDisabledState(6, WP(w, def_d).data_1 == -1);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
156
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
157 {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
158 int y;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
159 const Player *p;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
160 int r;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
161 StringID str;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
162
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
163 SetDParam(0, w->window_number);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
164 DrawWindowWidgets(w);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
165
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
166 DrawString(2, 15, STR_2023_TRANSPORT_COMPANY_RATINGS, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
167
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
168 /* Draw list of players */
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
169 y = 25;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
170 FOR_ALL_PLAYERS(p) {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
171 if (p->is_active && (HasBit(t->have_ratings, p->index) || t->exclusivity == p->index)) {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
172 DrawPlayerIcon(p->index, 2, y);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
173
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
174 SetDParam(0, p->index);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
175 SetDParam(1, p->index);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
176
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
177 r = t->ratings[p->index];
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
178 (str = STR_3035_APPALLING, r <= RATING_APPALLING) || // Apalling
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
179 (str++, r <= RATING_VERYPOOR) || // Very Poor
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
180 (str++, r <= RATING_POOR) || // Poor
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
181 (str++, r <= RATING_MEDIOCRE) || // Mediocore
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
182 (str++, r <= RATING_GOOD) || // Good
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
183 (str++, r <= RATING_VERYGOOD) || // Very Good
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
184 (str++, r <= RATING_EXCELLENT) || // Excellent
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
185 (str++, true); // Outstanding
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
186
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
187 SetDParam(2, str);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
188 if (t->exclusivity == p->index) { // red icon for player with exclusive rights
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
189 DrawSprite(SPR_BLOT, PALETTE_TO_RED, 18, y);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
190 }
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
191
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
192 DrawString(28, y, STR_2024, TC_FROMSTRING);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
193 y += 10;
5668
3d6d9bff3dd8 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents: 5609
diff changeset
194 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
195 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
196 }
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
197
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
198 /* Draw actions list */
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
199 {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
200 int y = 107, i;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
201 int pos = w->vscroll.pos;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
202
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
203 if (--pos < 0) {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
204 DrawString(2, y, STR_2045_ACTIONS_AVAILABLE, TC_FROMSTRING);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
205 y += 10;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
206 }
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
207
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
208 for (i = 0; buttons; i++, buttons >>= 1) {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
209 if (pos <= -5) break; ///< Draw only the 5 fitting lines
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
210
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
211 if ((buttons & 1) && --pos < 0) {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
212 DrawString(3, y, STR_2046_SMALL_ADVERTISING_CAMPAIGN + i, TC_ORANGE);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
213 y += 10;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
214 }
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
215 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
216 }
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
217
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
218 {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
219 int i = WP(w, def_d).data_1;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
220
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
221 if (i != -1) {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
222 SetDParam(1, (_price.build_industry >> 8) * _town_action_costs[i]);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
223 SetDParam(0, STR_2046_SMALL_ADVERTISING_CAMPAIGN + i);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
224 DrawStringMultiLine(2, 159, STR_204D_INITIATE_A_SMALL_LOCAL + i, 313);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
225 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
226 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
227
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
228 } break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
229
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
230 case WE_DOUBLE_CLICK:
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
231 case WE_CLICK:
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
232 switch (e->we.click.widget) {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
233 case TWA_COMMAND_LIST: {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
234 const Town *t = GetTown(w->window_number);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
235 int y = (e->we.click.pt.y - 0x6B) / 10;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
236
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
237 if (!IsInsideMM(y, 0, 5)) return;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
238
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
239 y = GetNthSetBit(GetMaskOfTownActions(NULL, _local_player, t), y + w->vscroll.pos - 1);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
240 if (y >= 0) {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
241 WP(w, def_d).data_1 = y;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
242 SetWindowDirty(w);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
243 }
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
244 /* Fall through to clicking in case we are double-clicked */
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
245 if (e->event != WE_DOUBLE_CLICK || y < 0) break;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
246 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
247
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
248 case TWA_EXECUTE:
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
249 DoCommandP(GetTown(w->window_number)->xy, w->window_number, WP(w, def_d).data_1, NULL, CMD_DO_TOWN_ACTION | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
250 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
251 }
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
252 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
253
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
254 case WE_4:
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
255 SetWindowDirty(w);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
256 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
257 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
258 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
259
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
260 static const WindowDesc _town_authority_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7058
diff changeset
261 WDP_AUTO, WDP_AUTO, 317, 222, 317, 222,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5750
diff changeset
262 WC_TOWN_AUTHORITY, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
263 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
264 _town_authority_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
265 TownAuthorityWndProc
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
266 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
267
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
268 static void ShowTownAuthorityWindow(uint town)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
269 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
270 Window *w = AllocateWindowDescFront(&_town_authority_desc, town);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
271
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
272 if (w != NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
273 w->vscroll.cap = 5;
8082
4540919ba965 (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium <rubidium@openttd.org>
parents: 8040
diff changeset
274 WP(w, def_d).data_1 = -1;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
275 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
276 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
277
8933
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
278
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
279 enum TownViewWidget {
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
280 TVW_CAPTION = 1,
8945
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
281 TVW_STICKY,
8933
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
282 TVW_CENTERVIEW = 6,
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
283 TVW_SHOWAUTORITY,
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
284 TVW_CHANGENAME,
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
285 TVW_EXPAND,
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
286 TVW_DELETE,
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
287 };
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
288
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
289 static void TownViewWndProc(Window *w, WindowEvent *e)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
290 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
291 Town *t = GetTown(w->window_number);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
292
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
293 switch (e->event) {
8945
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
294 case WE_CREATE: {
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
295 bool ingame = _game_mode != GM_EDITOR;
8933
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
296 if (t->larger_town) w->widget[TVW_CAPTION].data = STR_CITY;
8945
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
297 w->SetWidgetHiddenState(TVW_DELETE, ingame); // hide delete button on game mode
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
298 w->SetWidgetHiddenState(TVW_EXPAND, ingame); // hide expand button on game mode
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
299 w->SetWidgetHiddenState(TVW_SHOWAUTORITY, !ingame); // hide autority button on editor mode
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
300
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
301 if (ingame) {
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
302 /* resize caption bar */
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
303 w->widget[TVW_CAPTION].right = w->widget[TVW_STICKY].left -1;
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
304 /* move the rename from top on scenario to bottom in game */
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
305 w->widget[TVW_CHANGENAME].top = w->widget[TVW_EXPAND].top;
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
306 w->widget[TVW_CHANGENAME].bottom = w->widget[TVW_EXPAND].bottom;
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
307 w->widget[TVW_CHANGENAME].right = w->widget[TVW_STICKY].right;
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
308 }
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
309 } break;
8717
207c3da7c7fe (svn r12391) -Feature: Show whether a town is a "city" in the town description title bar.
maedhros <maedhros@openttd.org>
parents: 8578
diff changeset
310
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
311 case WE_PAINT:
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
312 /* disable renaming town in network games if you are not the server */
8933
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
313 w->SetWidgetDisabledState(TVW_CHANGENAME, _networking && !_network_server);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
314
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
315 SetDParam(0, t->index);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
316 DrawWindowWidgets(w);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
317
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
318 SetDParam(0, t->population);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
319 SetDParam(1, t->num_houses);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
320 DrawString(2, 107, STR_2006_POPULATION, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
321
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
322 SetDParam(0, t->act_pass);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
323 SetDParam(1, t->max_pass);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
324 DrawString(2, 117, STR_200D_PASSENGERS_LAST_MONTH_MAX, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
325
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
326 SetDParam(0, t->act_mail);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
327 SetDParam(1, t->max_mail);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
328 DrawString(2, 127, STR_200E_MAIL_LAST_MONTH_MAX, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
329
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
330 DrawWindowViewport(w);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
331 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
332
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
333 case WE_CLICK:
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
334 switch (e->we.click.widget) {
8933
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
335 case TVW_CENTERVIEW: /* scroll to location */
9094
a3f3038e9b9a (svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138 <peter1138@openttd.org>
parents: 8994
diff changeset
336 if (_ctrl_pressed) {
a3f3038e9b9a (svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138 <peter1138@openttd.org>
parents: 8994
diff changeset
337 ShowExtraViewPortWindow(t->xy);
a3f3038e9b9a (svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138 <peter1138@openttd.org>
parents: 8994
diff changeset
338 } else {
a3f3038e9b9a (svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138 <peter1138@openttd.org>
parents: 8994
diff changeset
339 ScrollMainWindowToTile(t->xy);
a3f3038e9b9a (svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138 <peter1138@openttd.org>
parents: 8994
diff changeset
340 }
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
341 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
342
8933
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
343 case TVW_SHOWAUTORITY: /* town authority */
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
344 ShowTownAuthorityWindow(w->window_number);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
345 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
346
8933
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
347 case TVW_CHANGENAME: /* rename */
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
348 SetDParam(0, w->window_number);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
349 ShowQueryString(STR_TOWN, STR_2007_RENAME_TOWN, 31, 130, w, CS_ALPHANUMERAL);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
350 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
351
8933
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
352 case TVW_EXPAND: /* expand town - only available on Scenario editor */
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
353 ExpandTown(t);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
354 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
355
8933
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
356 case TVW_DELETE: /* delete town - only available on Scenario editor */
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
357 delete t;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
358 break;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
359 } break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
360
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
361 case WE_ON_EDIT_TEXT:
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
362 if (e->we.edittext.str[0] != '\0') {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
363 _cmd_text = e->we.edittext.str;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
364 DoCommandP(0, w->window_number, 0, NULL,
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
365 CMD_RENAME_TOWN | CMD_MSG(STR_2008_CAN_T_RENAME_TOWN));
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
366 }
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
367 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
368 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
369 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
370
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
371
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
372 static const Widget _town_view_widgets[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
373 { WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
8945
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
374 { WWT_CAPTION, RESIZE_NONE, 13, 11, 172, 0, 13, STR_2005, STR_018C_WINDOW_TITLE_DRAG_THIS},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
375 { WWT_STICKYBOX, RESIZE_NONE, 13, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
376 { WWT_PANEL, RESIZE_NONE, 13, 0, 259, 14, 105, 0x0, STR_NULL},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
377 { WWT_INSET, RESIZE_NONE, 13, 2, 257, 16, 103, 0x0, STR_NULL},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
378 { WWT_PANEL, RESIZE_NONE, 13, 0, 259, 106, 137, 0x0, STR_NULL},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
379 { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 0, 85, 138, 149, STR_00E4_LOCATION, STR_200B_CENTER_THE_MAIN_VIEW_ON},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
380 { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 86, 171, 138, 149, STR_2020_LOCAL_AUTHORITY, STR_2021_SHOW_INFORMATION_ON_LOCAL},
8945
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
381 { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 172, 247, 0, 13, STR_0130_RENAME, STR_200C_CHANGE_TOWN_NAME},
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
382 { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 86, 171, 138, 149, STR_023C_EXPAND, STR_023B_INCREASE_SIZE_OF_TOWN},
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
383 { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 172, 259, 138, 149, STR_0290_DELETE, STR_0291_DELETE_THIS_TOWN_COMPLETELY},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
384 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
385 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
386
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
387 static const WindowDesc _town_view_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7058
diff changeset
388 WDP_AUTO, WDP_AUTO, 260, 150, 260, 150,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5750
diff changeset
389 WC_TOWN_VIEW, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
390 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
391 _town_view_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
392 TownViewWndProc
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
393 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
394
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
395 void ShowTownViewWindow(TownID town)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
396 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
397 Window *w;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
398
8945
cb509cf1b23c (svn r12733) -Codechange: Merge two more Widgets arrays (town views ) into one.
belugas <belugas@openttd.org>
parents: 8933
diff changeset
399 w = AllocateWindowDescFront(&_town_view_desc, town);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
400
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
401 if (w != NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
402 w->flags4 |= WF_DISABLE_VP_SCROLL;
8994
e4c3087abbde (svn r12789) -Codechange: rename AssignWindowViewport to InitializeWindowViewport because the viewport is now part of the window struct. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents: 8969
diff changeset
403 InitializeWindowViewport(w, 3, 17, 254, 86, GetTown(town)->xy, ZOOM_LVL_TOWN);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
404 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
405 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
406
8578
5fd73509ab21 (svn r12159) -Codechange: Enumify some widget magical numbers
belugas <belugas@openttd.org>
parents: 8349
diff changeset
407 enum TownDirectoryWidget {
5fd73509ab21 (svn r12159) -Codechange: Enumify some widget magical numbers
belugas <belugas@openttd.org>
parents: 8349
diff changeset
408 TDW_SORTNAME = 3,
5fd73509ab21 (svn r12159) -Codechange: Enumify some widget magical numbers
belugas <belugas@openttd.org>
parents: 8349
diff changeset
409 TDW_SORTPOPULATION,
5fd73509ab21 (svn r12159) -Codechange: Enumify some widget magical numbers
belugas <belugas@openttd.org>
parents: 8349
diff changeset
410 TDW_CENTERTOWN,
5fd73509ab21 (svn r12159) -Codechange: Enumify some widget magical numbers
belugas <belugas@openttd.org>
parents: 8349
diff changeset
411 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
412 static const Widget _town_directory_widgets[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
413 { WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
414 { WWT_CAPTION, RESIZE_NONE, 13, 11, 195, 0, 13, STR_2000_TOWNS, STR_018C_WINDOW_TITLE_DRAG_THIS},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
415 { WWT_STICKYBOX, RESIZE_NONE, 13, 196, 207, 0, 13, 0x0, STR_STICKY_BUTTON},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
416 { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 0, 98, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
417 { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 99, 195, 14, 25, STR_SORT_BY_POPULATION, STR_SORT_ORDER_TIP},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
418 { WWT_PANEL, RESIZE_BOTTOM, 13, 0, 195, 26, 189, 0x0, STR_200A_TOWN_NAMES_CLICK_ON_NAME},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
419 { WWT_SCROLLBAR, RESIZE_BOTTOM, 13, 196, 207, 14, 189, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
420 { WWT_PANEL, RESIZE_TB, 13, 0, 195, 190, 201, 0x0, STR_NULL},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
421 { WWT_RESIZEBOX, RESIZE_TB, 13, 196, 207, 190, 201, 0x0, STR_RESIZE_BUTTON},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
422 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
423 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
424
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
425
6422
fb10eafe2a26 (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents: 6247
diff changeset
426 /* used to get a sorted list of the towns */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
427 static uint _num_town_sort;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
428
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
429 static char _bufcache[64];
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
430 static const Town* _last_town;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
431
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
432 static int CDECL TownNameSorter(const void *a, const void *b)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
433 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
434 const Town* ta = *(const Town**)a;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
435 const Town* tb = *(const Town**)b;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
436 char buf1[64];
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
437 int r;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
438
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
439 SetDParam(0, ta->index);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
440 GetString(buf1, STR_TOWN, lastof(buf1));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
441
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
442 /* If 'b' is the same town as in the last round, use the cached value
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
443 * We do this to speed stuff up ('b' is called with the same value a lot of
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
444 * times after eachother) */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
445 if (tb != _last_town) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
446 _last_town = tb;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
447 SetDParam(0, tb->index);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
448 GetString(_bufcache, STR_TOWN, lastof(_bufcache));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
449 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
450
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
451 r = strcmp(buf1, _bufcache);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
452 if (_town_sort_order & 1) r = -r;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
453 return r;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
454 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
455
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
456 static int CDECL TownPopSorter(const void *a, const void *b)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
457 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
458 const Town* ta = *(const Town**)a;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
459 const Town* tb = *(const Town**)b;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
460 int r = ta->population - tb->population;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
461 if (_town_sort_order & 1) r = -r;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
462 return r;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
463 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
464
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
465 static void MakeSortedTownList()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
466 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
467 const Town* t;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
468 uint n = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
469
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
470 /* Create array for sorting */
5609
358c07fb3212 (svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr <KUDr@openttd.org>
parents: 5587
diff changeset
471 _town_sort = ReallocT(_town_sort, GetMaxTownIndex() + 1);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
472
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
473 FOR_ALL_TOWNS(t) _town_sort[n++] = t;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
474
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
475 _num_town_sort = n;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
476
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
477 _last_town = NULL; // used for "cache"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
478 qsort((void*)_town_sort, n, sizeof(_town_sort[0]), _town_sort_order & 2 ? TownPopSorter : TownNameSorter);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
479
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
480 DEBUG(misc, 3, "Resorting towns list");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
481 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
482
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
483
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
484 static void TownDirectoryWndProc(Window *w, WindowEvent *e)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
485 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
486 switch (e->event) {
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
487 case WE_PAINT: {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
488 if (_town_sort_dirty) {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
489 _town_sort_dirty = false;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
490 MakeSortedTownList();
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
491 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
492
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
493 SetVScrollCount(w, _num_town_sort);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
494
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
495 DrawWindowWidgets(w);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
496 DrawSortButtonState(w, (_town_sort_order <= 1) ? TDW_SORTNAME : TDW_SORTPOPULATION, _town_sort_order & 1 ? SBS_DOWN : SBS_UP);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
497
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
498 {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
499 int n = 0;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
500 uint16 i = w->vscroll.pos;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
501 int y = 28;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
502
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
503 while (i < _num_town_sort) {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
504 const Town* t = _town_sort[i];
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
505
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
506 assert(t->xy);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
507
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
508 SetDParam(0, t->index);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
509 SetDParam(1, t->population);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
510 DrawString(2, y, STR_2057, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
511
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
512 y += 10;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
513 i++;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
514 if (++n == w->vscroll.cap) break; // max number of towns in 1 window
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
515 }
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
516 SetDParam(0, GetWorldPopulation());
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
517 DrawString(3, w->height - 12 + 2, STR_TOWN_POPULATION, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
518 }
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
519 } break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
520
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
521 case WE_CLICK:
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
522 switch (e->we.click.widget) {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
523 case TDW_SORTNAME: /* Sort by Name ascending/descending */
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
524 _town_sort_order = (_town_sort_order == 0) ? 1 : 0;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
525 _town_sort_dirty = true;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
526 SetWindowDirty(w);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
527 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
528
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
529 case TDW_SORTPOPULATION: /* Sort by Population ascending/descending */
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
530 _town_sort_order = (_town_sort_order == 2) ? 3 : 2;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
531 _town_sort_dirty = true;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
532 SetWindowDirty(w);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
533 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
534
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
535 case TDW_CENTERTOWN: { /* Click on Town Matrix */
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
536 const Town* t;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
537
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
538 uint16 id_v = (e->we.click.pt.y - 28) / 10;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
539
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
540 if (id_v >= w->vscroll.cap) return; // click out of bounds
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
541
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
542 id_v += w->vscroll.pos;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
543
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
544 if (id_v >= _num_town_sort) return; // click out of town bounds
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
545
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
546 t = _town_sort[id_v];
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
547 assert(t->xy);
9094
a3f3038e9b9a (svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138 <peter1138@openttd.org>
parents: 8994
diff changeset
548 if (_ctrl_pressed) {
a3f3038e9b9a (svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138 <peter1138@openttd.org>
parents: 8994
diff changeset
549 ShowExtraViewPortWindow(t->xy);
a3f3038e9b9a (svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138 <peter1138@openttd.org>
parents: 8994
diff changeset
550 } else {
a3f3038e9b9a (svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138 <peter1138@openttd.org>
parents: 8994
diff changeset
551 ScrollMainWindowToTile(t->xy);
a3f3038e9b9a (svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138 <peter1138@openttd.org>
parents: 8994
diff changeset
552 }
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
553 } break;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
554 }
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
555 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
556
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
557 case WE_4:
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
558 SetWindowDirty(w);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
559 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
560
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
561 case WE_RESIZE:
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
562 w->vscroll.cap += e->we.sizing.diff.y / 10;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
563 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
564 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
565 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
566
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
567 static const WindowDesc _town_directory_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7058
diff changeset
568 WDP_AUTO, WDP_AUTO, 208, 202, 208, 202,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5750
diff changeset
569 WC_TOWN_DIRECTORY, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
570 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
571 _town_directory_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
572 TownDirectoryWndProc
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
573 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
574
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
575
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 5893
diff changeset
576 void ShowTownDirectory()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
577 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
578 Window *w = AllocateWindowDescFront(&_town_directory_desc, 0);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
579
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
580 if (w != NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
581 w->vscroll.cap = 16;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
582 w->resize.step_height = 10;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
583 w->resize.height = w->height - 10 * 6; // minimum of 10 items in the list, each item 10 high
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
584 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
585 }
8723
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
586
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
587 void CcBuildTown(bool success, TileIndex tile, uint32 p1, uint32 p2)
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
588 {
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
589 if (success) {
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
590 SndPlayTileFx(SND_1F_SPLAT, tile);
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
591 ResetObjectToPlace();
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
592 }
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
593 }
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
594
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
595 static void PlaceProc_Town(TileIndex tile)
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
596 {
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
597 uint32 size = min(_scengen_town_size, (int)TSM_CITY);
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
598 uint32 mode = _scengen_town_size > TSM_CITY ? TSM_CITY : TSM_FIXED;
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
599 DoCommandP(tile, size, mode, CcBuildTown, CMD_BUILD_TOWN | CMD_MSG(STR_0236_CAN_T_BUILD_TOWN_HERE));
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
600 }
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
601
8933
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
602 enum TownScenarioEditorWidget {
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
603 TSEW_NEWTOWN = 4,
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
604 TSEW_RANDOMTOWN,
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
605 TSEW_MANYRANDOMTOWNS,
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
606 TSEW_SMALLTOWN,
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
607 TSEW_MEDIUMTOWN,
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
608 TSEW_LARGETOWN,
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
609 TSEW_CITY,
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
610 };
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
611
8723
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
612 static const Widget _scen_edit_town_gen_widgets[] = {
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
613 { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
614 { WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_0233_TOWN_GENERATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
615 { WWT_STICKYBOX, RESIZE_NONE, 7, 148, 159, 0, 13, 0x0, STR_STICKY_BUTTON},
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
616 { WWT_PANEL, RESIZE_NONE, 7, 0, 159, 14, 94, 0x0, STR_NULL},
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
617 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 157, 16, 27, STR_0234_NEW_TOWN, STR_0235_CONSTRUCT_NEW_TOWN},
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
618 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 157, 29, 40, STR_023D_RANDOM_TOWN, STR_023E_BUILD_TOWN_IN_RANDOM_LOCATION},
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
619 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 157, 42, 53, STR_MANY_RANDOM_TOWNS, STR_RANDOM_TOWNS_TIP},
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
620 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 53, 68, 79, STR_02A1_SMALL, STR_02A4_SELECT_TOWN_SIZE},
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
621 { WWT_TEXTBTN, RESIZE_NONE, 14, 54, 105, 68, 79, STR_02A2_MEDIUM, STR_02A4_SELECT_TOWN_SIZE},
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
622 { WWT_TEXTBTN, RESIZE_NONE, 14, 106, 157, 68, 79, STR_02A3_LARGE, STR_02A4_SELECT_TOWN_SIZE},
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
623 { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 157, 81, 92, STR_SCENARIO_EDITOR_CITY, STR_02A4_SELECT_TOWN_SIZE},
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
624 { WWT_LABEL, RESIZE_NONE, 7, 0, 147, 54, 67, STR_02A5_TOWN_SIZE, STR_NULL},
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
625 { WIDGETS_END},
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
626 };
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
627
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
628 static void ScenEditTownGenWndProc(Window *w, WindowEvent *e)
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
629 {
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
630 switch (e->event) {
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
631 case WE_PAINT:
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
632 DrawWindowWidgets(w);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
633 break;
8723
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
634
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
635 case WE_CREATE:
8933
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
636 w->LowerWidget(_scengen_town_size + TSEW_SMALLTOWN);
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
637 break;
8723
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
638
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
639 case WE_CLICK:
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
640 switch (e->we.click.widget) {
8933
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
641 case TSEW_NEWTOWN:
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
642 HandlePlacePushButton(w, TSEW_NEWTOWN, SPR_CURSOR_TOWN, VHM_RECT, PlaceProc_Town);
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
643 break;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
644
8933
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
645 case TSEW_RANDOMTOWN: {
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
646 Town *t;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
647 uint size = min(_scengen_town_size, (int)TSM_CITY);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
648 TownSizeMode mode = _scengen_town_size > TSM_CITY ? TSM_CITY : TSM_FIXED;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
649
8933
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
650 w->HandleButtonClick(TSEW_RANDOMTOWN);
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
651 _generating_world = true;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
652 t = CreateRandomTown(20, mode, size);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
653 _generating_world = false;
8723
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
654
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
655 if (t == NULL) {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
656 ShowErrorMessage(STR_NO_SPACE_FOR_TOWN, STR_CANNOT_GENERATE_TOWN, 0, 0);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
657 } else {
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
658 ScrollMainWindowToTile(t->xy);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
659 }
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
660 } break;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
661
8933
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
662 case TSEW_MANYRANDOMTOWNS:
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
663 w->HandleButtonClick(TSEW_MANYRANDOMTOWNS);
8723
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
664
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
665 _generating_world = true;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
666 if (!GenerateTowns()) ShowErrorMessage(STR_NO_SPACE_FOR_TOWN, STR_CANNOT_GENERATE_TOWN, 0, 0);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
667 _generating_world = false;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
668 break;
8723
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
669
8933
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
670 case TSEW_SMALLTOWN: case TSEW_MEDIUMTOWN: case TSEW_LARGETOWN: case TSEW_CITY:
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
671 w->RaiseWidget(_scengen_town_size + TSEW_SMALLTOWN);
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
672 _scengen_town_size = e->we.click.widget - TSEW_SMALLTOWN;
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
673 w->LowerWidget(_scengen_town_size + TSEW_SMALLTOWN);
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
674 SetWindowDirty(w);
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
675 break;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
676 } break;
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
677
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
678 case WE_TIMEOUT:
8933
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
679 w->RaiseWidget(TSEW_RANDOMTOWN);
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
680 w->RaiseWidget(TSEW_MANYRANDOMTOWNS);
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
681 SetWindowDirty(w);
8723
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
682 break;
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
683
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
684 case WE_PLACE_OBJ:
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
685 _place_proc(e->we.place.tile);
8723
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
686 break;
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
687
8932
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
688 case WE_ABORT_PLACE_OBJ:
449ecb690482 (svn r12704) -Codechange: code style cleanup, mostly switch case alignment
belugas <belugas@openttd.org>
parents: 8723
diff changeset
689 w->RaiseButtons();
8933
986f2ae0c876 (svn r12705) -Codechange: enumification of some more widgets
belugas <belugas@openttd.org>
parents: 8932
diff changeset
690 w->LowerWidget(_scengen_town_size + TSEW_SMALLTOWN);
8723
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
691 SetWindowDirty(w);
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
692 break;
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
693 }
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
694 }
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
695
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
696 static const WindowDesc _scen_edit_town_gen_desc = {
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
697 WDP_AUTO, WDP_AUTO, 160, 95, 160, 95,
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
698 WC_SCEN_TOWN_GEN, WC_NONE,
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
699 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
700 _scen_edit_town_gen_widgets,
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
701 ScenEditTownGenWndProc,
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
702 };
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
703
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
704 void ShowBuildTownWindow()
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
705 {
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
706 if (_game_mode != GM_EDITOR && !IsValidPlayer(_current_player)) return;
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
707 AllocateWindowDescFront(&_scen_edit_town_gen_desc, 0);
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
708 }
36823c86c7f1 (svn r12398) -Codechange [FS#1770]: Move toolbar related code to it's own little neighbourhood. Based on a patch by Dominik.
rubidium <rubidium@openttd.org>
parents: 8717
diff changeset
709