author | belugas |
Sun, 04 Nov 2007 00:08:57 +0000 | |
changeset 8320 | 6ffad7a5d242 |
parent 8153 | 32f871f7e7f7 |
child 8424 | 4a488a90ccab |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6573
diff
changeset
|
3 |
/** @file town_gui.cpp */ |
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6573
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1820
diff
changeset
|
6 |
#include "openttd.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1260
diff
changeset
|
7 |
#include "debug.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
8 |
#include "functions.h" |
1309
dab90d4cbf2d
(svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents:
1299
diff
changeset
|
9 |
#include "strings.h" |
1363
01d3de5d8039
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1323
diff
changeset
|
10 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
410
diff
changeset
|
11 |
#include "table/strings.h" |
0 | 12 |
#include "town.h" |
13 |
#include "window.h" |
|
14 |
#include "gfx.h" |
|
15 |
#include "viewport.h" |
|
16 |
#include "gui.h" |
|
17 |
#include "command.h" |
|
18 |
#include "player.h" |
|
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5682
diff
changeset
|
19 |
#include "network/network.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2070
diff
changeset
|
20 |
#include "variables.h" |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
21 |
#include "helpers.hpp" |
0 | 22 |
|
8153
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
23 |
enum TownAuthorityWidget { |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
24 |
TWA_CLOSEBOX = 0, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
25 |
TWA_CAPTION, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
26 |
TWA_RATING_INFO, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
27 |
TWA_COMMAND_LIST, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
28 |
TWA_SCROLLBAR, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
29 |
TWA_ACTION_INFO, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
30 |
TWA_EXECUTE, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
31 |
}; |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
32 |
|
0 | 33 |
static const Widget _town_authority_widgets[] = { |
8153
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
34 |
{ WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // TWA_CLOSEBOX |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
35 |
{ WWT_CAPTION, RESIZE_NONE, 13, 11, 316, 0, 13, STR_2022_LOCAL_AUTHORITY, STR_018C_WINDOW_TITLE_DRAG_THIS}, // TWA_CAPTION |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
36 |
{ WWT_PANEL, RESIZE_NONE, 13, 0, 316, 14, 105, 0x0, STR_NULL}, // TWA_RATING_INFO |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
37 |
{ WWT_PANEL, RESIZE_NONE, 13, 0, 304, 106, 157, 0x0, STR_2043_LIST_OF_THINGS_TO_DO_AT}, // TWA_COMMAND_LIST |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
38 |
{ WWT_SCROLLBAR, RESIZE_NONE, 13, 305, 316, 106, 157, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // TWA_SCROLLBAR |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
39 |
{ WWT_PANEL, RESIZE_NONE, 13, 0, 316, 158, 209, 0x0, STR_NULL}, // TWA_ACTION_INFO |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
40 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 0, 316, 210, 221, STR_2042_DO_IT, STR_2044_CARRY_OUT_THE_HIGHLIGHTED}, // TWA_EXECUTE |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
41 |
{ WIDGETS_END}, |
0 | 42 |
}; |
43 |
||
44 |
extern const byte _town_action_costs[8]; |
|
45 |
||
8153
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
46 |
enum TownActions { |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
47 |
TACT_NONE = 0x00, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
48 |
|
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
49 |
TACT_ADVERTISE_SMALL = 0x01, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
50 |
TACT_ADVERTISE_MEDIUM = 0x02, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
51 |
TACT_ADVERTISE_LARGE = 0x04, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
52 |
TACT_ROAD_REBUILD = 0x08, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
53 |
TACT_BUILD_STATUE = 0x10, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
54 |
TACT_FOUND_BUILDINGS = 0x20, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
55 |
TACT_BUY_RIGHTS = 0x40, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
56 |
TACT_BRIBE = 0x80, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
57 |
|
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
58 |
TACT_ADVERTISE = TACT_ADVERTISE_SMALL | TACT_ADVERTISE_MEDIUM | TACT_ADVERTISE_LARGE, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
59 |
TACT_CONSTRUCTION = TACT_ROAD_REBUILD | TACT_BUILD_STATUE | TACT_FOUND_BUILDINGS, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
60 |
TACT_FUNDS = TACT_BUY_RIGHTS | TACT_BRIBE, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
61 |
TACT_ALL = TACT_ADVERTISE | TACT_CONSTRUCTION | TACT_FUNDS, |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
62 |
}; |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
63 |
|
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
64 |
DECLARE_ENUM_AS_BIT_SET(TownActions); |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
65 |
|
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1363
diff
changeset
|
66 |
/** Get a list of available actions to do at a town. |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6573
diff
changeset
|
67 |
* @param nump if not NULL add put the number of available actions in it |
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1363
diff
changeset
|
68 |
* @param pid the player that is querying the town |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6573
diff
changeset
|
69 |
* @param t the town that is queried |
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1363
diff
changeset
|
70 |
* @return bitmasked value of enabled actions |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1363
diff
changeset
|
71 |
*/ |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1363
diff
changeset
|
72 |
uint GetMaskOfTownActions(int *nump, PlayerID pid, const Town *t) |
0 | 73 |
{ |
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1363
diff
changeset
|
74 |
int num = 0; |
8153
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
75 |
TownActions buttons = TACT_NONE; |
2639 | 76 |
|
8153
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
77 |
/* Spectators and unwanted have no options */ |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
78 |
if (pid != PLAYER_SPECTATOR && !(_patches.bribe && t->unwanted[pid])) { |
0 | 79 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6573
diff
changeset
|
80 |
/* Things worth more than this are not shown */ |
8153
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
81 |
Money avail = GetPlayer(pid)->player_money + _price.station_value * 200; |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
82 |
Money ref = _price.build_industry >> 8; |
0 | 83 |
|
8153
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
84 |
/* Check the action bits for validity and |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
85 |
* if they are valid add them */ |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
86 |
for (uint i = 0; i != lengthof(_town_action_costs); i++) { |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
87 |
const TownActions cur = (TownActions)(1 << i); |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
88 |
|
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
89 |
/* Is the player not able to bribe ? */ |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
90 |
if (cur == TACT_BRIBE && (!_patches.bribe || t->ratings[pid] >= RATING_BRIBE_MAXIMUM)) |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
91 |
continue; |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
92 |
|
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
93 |
/* Is the player not able to buy exclusive rights ? */ |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
94 |
if (cur == TACT_BUY_RIGHTS && !_patches.exclusive_rights) |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
95 |
continue; |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
96 |
|
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
97 |
/* Is the player not able to build a statue ? */ |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
98 |
if (cur == TACT_BUILD_STATUE && HASBIT(t->statues, pid)) |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
99 |
continue; |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
100 |
|
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
101 |
if (avail >= _town_action_costs[i] * ref) { |
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
102 |
buttons |= cur; |
0 | 103 |
num++; |
104 |
} |
|
105 |
} |
|
106 |
} |
|
107 |
||
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1363
diff
changeset
|
108 |
if (nump != NULL) *nump = num; |
0 | 109 |
return buttons; |
110 |
} |
|
111 |
||
112 |
static int GetNthSetBit(uint32 bits, int n) |
|
113 |
{ |
|
114 |
int i = 0; |
|
2639 | 115 |
|
0 | 116 |
if (n >= 0) { |
117 |
do { |
|
2639 | 118 |
if (bits & 1 && --n < 0) return i; |
0 | 119 |
i++; |
2639 | 120 |
} while (bits >>= 1); |
0 | 121 |
} |
122 |
return -1; |
|
123 |
} |
|
124 |
||
125 |
static void TownAuthorityWndProc(Window *w, WindowEvent *e) |
|
126 |
{ |
|
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1363
diff
changeset
|
127 |
switch (e->event) { |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1363
diff
changeset
|
128 |
case WE_PAINT: { |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1363
diff
changeset
|
129 |
const Town *t = GetTown(w->window_number); |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1363
diff
changeset
|
130 |
int numact; |
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1363
diff
changeset
|
131 |
uint buttons = GetMaskOfTownActions(&numact, _local_player, t); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
132 |
|
0 | 133 |
SetVScrollCount(w, numact + 1); |
134 |
||
135 |
if (WP(w,def_d).data_1 != -1 && !HASBIT(buttons, WP(w,def_d).data_1)) |
|
136 |
WP(w,def_d).data_1 = -1; |
|
137 |
||
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
138 |
SetWindowWidgetDisabledState(w, 6, WP(w, def_d).data_1 == -1); |
0 | 139 |
|
140 |
{ |
|
141 |
int y; |
|
4171 | 142 |
const Player *p; |
0 | 143 |
int r; |
144 |
StringID str; |
|
145 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
146 |
SetDParam(0, w->window_number); |
0 | 147 |
DrawWindowWidgets(w); |
148 |
||
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8153
diff
changeset
|
149 |
DrawString(2, 15, STR_2023_TRANSPORT_COMPANY_RATINGS, TC_FROMSTRING); |
122
6e56237f536c
(svn r123) Fixed some indentions... btw credits for the last commit go to Celestar
dominik
parents:
121
diff
changeset
|
150 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6573
diff
changeset
|
151 |
/* Draw list of players */ |
0 | 152 |
y = 25; |
153 |
FOR_ALL_PLAYERS(p) { |
|
2639 | 154 |
if (p->is_active && (HASBIT(t->have_ratings, p->index) || t->exclusivity == p->index)) { |
125 | 155 |
DrawPlayerIcon(p->index, 2, y); |
121
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
69
diff
changeset
|
156 |
|
7554
076c42f44a83
(svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents:
7523
diff
changeset
|
157 |
SetDParam(0, p->index); |
076c42f44a83
(svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents:
7523
diff
changeset
|
158 |
SetDParam(1, p->index); |
0 | 159 |
|
160 |
r = t->ratings[p->index]; |
|
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4416
diff
changeset
|
161 |
(str = STR_3035_APPALLING, r <= RATING_APPALLING) || // Apalling |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4416
diff
changeset
|
162 |
(str++, r <= RATING_VERYPOOR) || // Very Poor |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4416
diff
changeset
|
163 |
(str++, r <= RATING_POOR) || // Poor |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4416
diff
changeset
|
164 |
(str++, r <= RATING_MEDIOCRE) || // Mediocore |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4416
diff
changeset
|
165 |
(str++, r <= RATING_GOOD) || // Good |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4416
diff
changeset
|
166 |
(str++, r <= RATING_VERYGOOD) || // Very Good |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4416
diff
changeset
|
167 |
(str++, r <= RATING_EXCELLENT) || // Excellent |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4416
diff
changeset
|
168 |
(str++, true); // Outstanding |
0 | 169 |
|
7554
076c42f44a83
(svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents:
7523
diff
changeset
|
170 |
SetDParam(2, str); |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5860
diff
changeset
|
171 |
if (t->exclusivity == p->index) { // red icon for player with exclusive rights |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5860
diff
changeset
|
172 |
DrawSprite(SPR_BLOT, PALETTE_TO_RED, 18, y); |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5860
diff
changeset
|
173 |
} |
246
de179e5f7c3d
(svn r247) -Fix: Town exclusivity was not shown in town-window because stringformat ({YELLOW}) overrode colour-code. Now the exclusive player gets a red icon in front of its name
darkvater
parents:
222
diff
changeset
|
174 |
|
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8153
diff
changeset
|
175 |
DrawString(28, y, STR_2024, TC_FROMSTRING); |
2639 | 176 |
y += 10; |
0 | 177 |
} |
178 |
} |
|
179 |
} |
|
180 |
||
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6573
diff
changeset
|
181 |
/* Draw actions list */ |
0 | 182 |
{ |
183 |
int y = 107, i; |
|
184 |
int pos = w->vscroll.pos; |
|
185 |
||
186 |
if (--pos < 0) { |
|
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8153
diff
changeset
|
187 |
DrawString(2, y, STR_2045_ACTIONS_AVAILABLE, TC_FROMSTRING); |
2639 | 188 |
y += 10; |
0 | 189 |
} |
2639 | 190 |
for (i = 0; buttons; i++, buttons >>= 1) { |
8153
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
191 |
if (pos <= -5) break; ///< Draw only the 5 fitting lines |
0 | 192 |
|
8153
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
193 |
if ((buttons & 1) && --pos < 0) { |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8153
diff
changeset
|
194 |
DrawString(3, y, STR_2046_SMALL_ADVERTISING_CAMPAIGN + i, TC_ORANGE); |
0 | 195 |
y += 10; |
196 |
} |
|
197 |
} |
|
198 |
} |
|
122
6e56237f536c
(svn r123) Fixed some indentions... btw credits for the last commit go to Celestar
dominik
parents:
121
diff
changeset
|
199 |
|
0 | 200 |
{ |
2639 | 201 |
int i = WP(w,def_d).data_1; |
202 |
||
203 |
if (i != -1) { |
|
7498
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7487
diff
changeset
|
204 |
SetDParam(1, (_price.build_industry >> 8) * _town_action_costs[i]); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
205 |
SetDParam(0, STR_2046_SMALL_ADVERTISING_CAMPAIGN + i); |
0 | 206 |
DrawStringMultiLine(2, 159, STR_204D_INITIATE_A_SMALL_LOCAL + i, 313); |
207 |
} |
|
208 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
209 |
|
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1363
diff
changeset
|
210 |
} break; |
0 | 211 |
|
7505
94a7391e0377
(svn r10265) -Feature: allow double-clicking on certain places: build-vehicle and town-action
truelight
parents:
7498
diff
changeset
|
212 |
case WE_DOUBLE_CLICK: |
0 | 213 |
case WE_CLICK: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4434
diff
changeset
|
214 |
switch (e->we.click.widget) { |
8153
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
215 |
case TWA_COMMAND_LIST: { |
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1363
diff
changeset
|
216 |
const Town *t = GetTown(w->window_number); |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4434
diff
changeset
|
217 |
int y = (e->we.click.pt.y - 0x6B) / 10; |
2639 | 218 |
|
219 |
if (!IS_INT_INSIDE(y, 0, 5)) return; |
|
0 | 220 |
|
1793
8ac8a8c9ec0f
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1363
diff
changeset
|
221 |
y = GetNthSetBit(GetMaskOfTownActions(NULL, _local_player, t), y + w->vscroll.pos - 1); |
0 | 222 |
if (y >= 0) { |
223 |
WP(w,def_d).data_1 = y; |
|
224 |
SetWindowDirty(w); |
|
225 |
} |
|
7523
ad4b2559762b
(svn r10291) -Fix [FS#920]: double click in town-GUI didn't work as expected
truelight
parents:
7505
diff
changeset
|
226 |
/* Fall through to clicking in case we are double-clicked */ |
ad4b2559762b
(svn r10291) -Fix [FS#920]: double click in town-GUI didn't work as expected
truelight
parents:
7505
diff
changeset
|
227 |
if (e->event != WE_DOUBLE_CLICK || y < 0) break; |
0 | 228 |
} |
229 |
||
8153
32f871f7e7f7
(svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents:
7882
diff
changeset
|
230 |
case TWA_EXECUTE: { |
1803
24a94314cfa9
(svn r2307) - Fix (regression): it was not possible to change the drive-side in the intro-game.
Darkvater
parents:
1793
diff
changeset
|
231 |
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)); |
0 | 232 |
break; |
233 |
} |
|
234 |
} |
|
235 |
break; |
|
236 |
||
237 |
case WE_4: |
|
238 |
SetWindowDirty(w); |
|
239 |
break; |
|
240 |
} |
|
241 |
} |
|
242 |
||
243 |
static const WindowDesc _town_authority_desc = { |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7554
diff
changeset
|
244 |
WDP_AUTO, WDP_AUTO, 317, 222, 317, 222, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
245 |
WC_TOWN_AUTHORITY, WC_NONE, |
0 | 246 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
247 |
_town_authority_widgets, |
|
248 |
TownAuthorityWndProc |
|
249 |
}; |
|
250 |
||
410 | 251 |
static void ShowTownAuthorityWindow(uint town) |
0 | 252 |
{ |
4171 | 253 |
Window *w = AllocateWindowDescFront(&_town_authority_desc, town); |
0 | 254 |
|
2639 | 255 |
if (w != NULL) { |
0 | 256 |
w->vscroll.cap = 5; |
257 |
WP(w,def_d).data_1 = -1; |
|
258 |
} |
|
259 |
} |
|
260 |
||
261 |
static void TownViewWndProc(Window *w, WindowEvent *e) |
|
262 |
{ |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
263 |
Town *t = GetTown(w->window_number); |
0 | 264 |
|
2639 | 265 |
switch (e->event) { |
0 | 266 |
case WE_PAINT: |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6573
diff
changeset
|
267 |
/* disable renaming town in network games if you are not the server */ |
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
268 |
SetWindowWidgetDisabledState(w, 8, _networking && !_network_server); |
891
b701cd0b20ae
(svn r1377) -Fix: only a server can rename a town in a MP game
darkvater
parents:
867
diff
changeset
|
269 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
270 |
SetDParam(0, t->index); |
0 | 271 |
DrawWindowWidgets(w); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
272 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
273 |
SetDParam(0, t->population); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
274 |
SetDParam(1, t->num_houses); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8153
diff
changeset
|
275 |
DrawString(2, 107, STR_2006_POPULATION, TC_FROMSTRING); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
276 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
277 |
SetDParam(0, t->act_pass); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
278 |
SetDParam(1, t->max_pass); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8153
diff
changeset
|
279 |
DrawString(2, 117, STR_200D_PASSENGERS_LAST_MONTH_MAX, TC_FROMSTRING); |
0 | 280 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
281 |
SetDParam(0, t->act_mail); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
282 |
SetDParam(1, t->max_mail); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8153
diff
changeset
|
283 |
DrawString(2, 127, STR_200E_MAIL_LAST_MONTH_MAX, TC_FROMSTRING); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
284 |
|
0 | 285 |
DrawWindowViewport(w); |
286 |
break; |
|
287 |
||
288 |
case WE_CLICK: |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4434
diff
changeset
|
289 |
switch (e->we.click.widget) { |
2639 | 290 |
case 6: /* scroll to location */ |
291 |
ScrollMainWindowToTile(t->xy); |
|
292 |
break; |
|
293 |
||
294 |
case 7: /* town authority */ |
|
295 |
ShowTownAuthorityWindow(w->window_number); |
|
296 |
break; |
|
297 |
||
298 |
case 8: /* rename */ |
|
299 |
SetDParam(0, w->window_number); |
|
5682
eeddbbacd4ac
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5568
diff
changeset
|
300 |
ShowQueryString(STR_TOWN, STR_2007_RENAME_TOWN, 31, 130, w, CS_ALPHANUMERAL); |
2639 | 301 |
break; |
302 |
||
303 |
case 9: /* expand town */ |
|
304 |
ExpandTown(t); |
|
305 |
break; |
|
306 |
||
307 |
case 10: /* delete town */ |
|
7882
64cdb1d52f16
(svn r10755) -Codechange: make the town struct use the pool item class as super class.
rubidium
parents:
7837
diff
changeset
|
308 |
delete t; |
2639 | 309 |
break; |
0 | 310 |
} |
311 |
break; |
|
312 |
||
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2406
diff
changeset
|
313 |
case WE_ON_EDIT_TEXT: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4434
diff
changeset
|
314 |
if (e->we.edittext.str[0] != '\0') { |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4434
diff
changeset
|
315 |
_cmd_text = e->we.edittext.str; |
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1803
diff
changeset
|
316 |
DoCommandP(0, w->window_number, 0, NULL, |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1803
diff
changeset
|
317 |
CMD_RENAME_TOWN | CMD_MSG(STR_2008_CAN_T_RENAME_TOWN)); |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1803
diff
changeset
|
318 |
} |
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2406
diff
changeset
|
319 |
break; |
0 | 320 |
} |
321 |
} |
|
322 |
||
323 |
||
324 |
static const Widget _town_view_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
325 |
{ WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
326 |
{ WWT_CAPTION, RESIZE_NONE, 13, 11, 247, 0, 13, STR_2005, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
327 |
{ WWT_STICKYBOX, RESIZE_NONE, 13, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4913
diff
changeset
|
328 |
{ WWT_PANEL, RESIZE_NONE, 13, 0, 259, 14, 105, 0x0, STR_NULL}, |
4939
ede0f6777b3c
(svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents:
4938
diff
changeset
|
329 |
{ WWT_INSET, RESIZE_NONE, 13, 2, 257, 16, 103, 0x0, STR_NULL}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4913
diff
changeset
|
330 |
{ WWT_PANEL, RESIZE_NONE, 13, 0, 259, 106, 137, 0x0, STR_NULL}, |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
331 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 0, 85, 138, 149, STR_00E4_LOCATION, STR_200B_CENTER_THE_MAIN_VIEW_ON}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
332 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 86, 171, 138, 149, STR_2020_LOCAL_AUTHORITY, STR_2021_SHOW_INFORMATION_ON_LOCAL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
333 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 172, 259, 138, 149, STR_0130_RENAME, STR_200C_CHANGE_TOWN_NAME}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
334 |
{ WIDGETS_END}, |
0 | 335 |
}; |
336 |
||
337 |
static const WindowDesc _town_view_desc = { |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7554
diff
changeset
|
338 |
WDP_AUTO, WDP_AUTO, 260, 150, 260, 150, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
339 |
WC_TOWN_VIEW, WC_NONE, |
758
bd9e868b9fae
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents:
727
diff
changeset
|
340 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 341 |
_town_view_widgets, |
342 |
TownViewWndProc |
|
343 |
}; |
|
344 |
||
345 |
static const Widget _town_view_scen_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
346 |
{ WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
347 |
{ WWT_CAPTION, RESIZE_NONE, 13, 11, 172, 0, 13, STR_2005, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
348 |
{ WWT_STICKYBOX, RESIZE_NONE, 13, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4913
diff
changeset
|
349 |
{ WWT_PANEL, RESIZE_NONE, 13, 0, 259, 14, 105, 0x0, STR_NULL}, |
4939
ede0f6777b3c
(svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents:
4938
diff
changeset
|
350 |
{ WWT_INSET, RESIZE_NONE, 13, 2, 257, 16, 103, 0x0, STR_NULL}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4913
diff
changeset
|
351 |
{ WWT_PANEL, RESIZE_NONE, 13, 0, 259, 106, 137, 0x0, STR_NULL}, |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
352 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 0, 85, 138, 149, STR_00E4_LOCATION, STR_200B_CENTER_THE_MAIN_VIEW_ON}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
353 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
354 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 173, 247, 0, 13, STR_0130_RENAME, STR_200C_CHANGE_TOWN_NAME}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
355 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 86, 171, 138, 149, STR_023C_EXPAND, STR_023B_INCREASE_SIZE_OF_TOWN}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
356 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 172, 259, 138, 149, STR_0290_DELETE, STR_0291_DELETE_THIS_TOWN_COMPLETELY}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
357 |
{ WIDGETS_END}, |
0 | 358 |
}; |
359 |
||
360 |
static const WindowDesc _town_view_scen_desc = { |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7554
diff
changeset
|
361 |
WDP_AUTO, WDP_AUTO, 260, 150, 260, 150, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
362 |
WC_TOWN_VIEW, WC_NONE, |
758
bd9e868b9fae
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents:
727
diff
changeset
|
363 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 364 |
_town_view_scen_widgets, |
365 |
TownViewWndProc |
|
366 |
}; |
|
367 |
||
3349
1ad72db34298
(svn r4133) - Some miscellaneous changes (unconverted TownID in function definition, Owner instead of byte, remove obsolete member and compare waypoint index with 0 not STR_NULL)
Darkvater
parents:
2952
diff
changeset
|
368 |
void ShowTownViewWindow(TownID town) |
0 | 369 |
{ |
370 |
Window *w; |
|
371 |
||
372 |
if (_game_mode != GM_EDITOR) { |
|
373 |
w = AllocateWindowDescFront(&_town_view_desc, town); |
|
374 |
} else { |
|
375 |
w = AllocateWindowDescFront(&_town_view_scen_desc, town); |
|
376 |
} |
|
377 |
||
2639 | 378 |
if (w != NULL) { |
0 | 379 |
w->flags4 |= WF_DISABLE_VP_SCROLL; |
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
6918
diff
changeset
|
380 |
AssignWindowViewport(w, 3, 17, 0xFE, 0x56, GetTown(town)->xy, ZOOM_LVL_TOWN); |
0 | 381 |
} |
382 |
} |
|
383 |
||
384 |
static const Widget _town_directory_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
385 |
{ WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
386 |
{ WWT_CAPTION, RESIZE_NONE, 13, 11, 195, 0, 13, STR_2000_TOWNS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
387 |
{ WWT_STICKYBOX, RESIZE_NONE, 13, 196, 207, 0, 13, 0x0, STR_STICKY_BUTTON}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
388 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 0, 98, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
389 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 99, 195, 14, 25, STR_SORT_BY_POPULATION, STR_SORT_ORDER_TIP}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4913
diff
changeset
|
390 |
{ WWT_PANEL, RESIZE_BOTTOM, 13, 0, 195, 26, 189, 0x0, STR_200A_TOWN_NAMES_CLICK_ON_NAME}, |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
391 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 13, 196, 207, 14, 189, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4913
diff
changeset
|
392 |
{ WWT_PANEL, RESIZE_TB, 13, 0, 195, 190, 201, 0x0, STR_NULL}, |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
393 |
{ WWT_RESIZEBOX, RESIZE_TB, 13, 196, 207, 190, 201, 0x0, STR_RESIZE_BUTTON}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
394 |
{ WIDGETS_END}, |
0 | 395 |
}; |
396 |
||
397 |
||
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6573
diff
changeset
|
398 |
/* used to get a sorted list of the towns */ |
0 | 399 |
static uint _num_town_sort; |
400 |
||
401 |
static char _bufcache[64]; |
|
4277
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4171
diff
changeset
|
402 |
static const Town* _last_town; |
0 | 403 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
125
diff
changeset
|
404 |
static int CDECL TownNameSorter(const void *a, const void *b) |
0 | 405 |
{ |
4277
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4171
diff
changeset
|
406 |
const Town* ta = *(const Town**)a; |
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4171
diff
changeset
|
407 |
const Town* tb = *(const Town**)b; |
0 | 408 |
char buf1[64]; |
409 |
int r; |
|
410 |
||
4416
e0e9a72882d0
(svn r6169) -Codechange: Use GetString() instead of GetStringWithArgs() which should be
Darkvater
parents:
4354
diff
changeset
|
411 |
SetDParam(0, ta->index); |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4848
diff
changeset
|
412 |
GetString(buf1, STR_TOWN, lastof(buf1)); |
0 | 413 |
|
1260
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1093
diff
changeset
|
414 |
/* If 'b' is the same town as in the last round, use the cached value |
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1093
diff
changeset
|
415 |
* We do this to speed stuff up ('b' is called with the same value a lot of |
4277
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4171
diff
changeset
|
416 |
* times after eachother) */ |
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4171
diff
changeset
|
417 |
if (tb != _last_town) { |
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4171
diff
changeset
|
418 |
_last_town = tb; |
4416
e0e9a72882d0
(svn r6169) -Codechange: Use GetString() instead of GetStringWithArgs() which should be
Darkvater
parents:
4354
diff
changeset
|
419 |
SetDParam(0, tb->index); |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4848
diff
changeset
|
420 |
GetString(_bufcache, STR_TOWN, lastof(_bufcache)); |
0 | 421 |
} |
422 |
||
423 |
r = strcmp(buf1, _bufcache); |
|
424 |
if (_town_sort_order & 1) r = -r; |
|
425 |
return r; |
|
426 |
} |
|
427 |
||
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
125
diff
changeset
|
428 |
static int CDECL TownPopSorter(const void *a, const void *b) |
0 | 429 |
{ |
4277
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4171
diff
changeset
|
430 |
const Town* ta = *(const Town**)a; |
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4171
diff
changeset
|
431 |
const Town* tb = *(const Town**)b; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
125
diff
changeset
|
432 |
int r = ta->population - tb->population; |
0 | 433 |
if (_town_sort_order & 1) r = -r; |
434 |
return r; |
|
435 |
} |
|
436 |
||
6573 | 437 |
static void MakeSortedTownList() |
0 | 438 |
{ |
2630 | 439 |
const Town* t; |
2639 | 440 |
uint n = 0; |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
441 |
|
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
442 |
/* Create array for sorting */ |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5838
diff
changeset
|
443 |
_town_sort = ReallocT(_town_sort, GetMaxTownIndex() + 1); |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5247
diff
changeset
|
444 |
if (_town_sort == NULL) error("Could not allocate memory for the town-sorting-list"); |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
445 |
|
4346
3f00094f2670
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
446 |
FOR_ALL_TOWNS(t) _town_sort[n++] = t; |
821
4af53631a47a
(svn r1292) -Codechange: also updated the town/industry sort-list to be uint16 compatible
truelight
parents:
758
diff
changeset
|
447 |
|
0 | 448 |
_num_town_sort = n; |
449 |
||
4277
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4171
diff
changeset
|
450 |
_last_town = NULL; // used for "cache" |
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4171
diff
changeset
|
451 |
qsort((void*)_town_sort, n, sizeof(_town_sort[0]), _town_sort_order & 2 ? TownPopSorter : TownNameSorter); |
65
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
16
diff
changeset
|
452 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5247
diff
changeset
|
453 |
DEBUG(misc, 3, "Resorting towns list"); |
0 | 454 |
} |
455 |
||
456 |
||
457 |
static void TownDirectoryWndProc(Window *w, WindowEvent *e) |
|
458 |
{ |
|
2639 | 459 |
switch (e->event) { |
0 | 460 |
case WE_PAINT: { |
461 |
if (_town_sort_dirty) { |
|
462 |
_town_sort_dirty = false; |
|
463 |
MakeSortedTownList(); |
|
464 |
} |
|
465 |
||
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
466 |
SetVScrollCount(w, _num_town_sort); |
0 | 467 |
|
468 |
DrawWindowWidgets(w); |
|
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8153
diff
changeset
|
469 |
DoDrawString(_town_sort_order & 1 ? DOWNARROW : UPARROW, (_town_sort_order <= 1) ? 88 : 187, 15, TC_BLACK); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
470 |
|
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
471 |
{ |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
472 |
int n = 0; |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
473 |
uint16 i = w->vscroll.pos; |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
474 |
int y = 28; |
0 | 475 |
|
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
476 |
while (i < _num_town_sort) { |
4277
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4171
diff
changeset
|
477 |
const Town* t = _town_sort[i]; |
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
478 |
|
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
479 |
assert(t->xy); |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
480 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
481 |
SetDParam(0, t->index); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
482 |
SetDParam(1, t->population); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8153
diff
changeset
|
483 |
DrawString(2, y, STR_2057, TC_FROMSTRING); |
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
484 |
|
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
485 |
y += 10; |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
486 |
i++; |
2549 | 487 |
if (++n == w->vscroll.cap) break; // max number of towns in 1 window |
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
488 |
} |
1080
9695461dc645
(svn r1581) Added a display for the total map population to the town display (Jango)
celestar
parents:
1005
diff
changeset
|
489 |
SetDParam(0, GetWorldPopulation()); |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8153
diff
changeset
|
490 |
DrawString(3, w->height - 12 + 2, STR_TOWN_POPULATION, TC_FROMSTRING); |
0 | 491 |
} |
492 |
} break; |
|
493 |
||
494 |
case WE_CLICK: |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4434
diff
changeset
|
495 |
switch (e->we.click.widget) { |
758
bd9e868b9fae
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents:
727
diff
changeset
|
496 |
case 3: { /* Sort by Name ascending/descending */ |
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
497 |
_town_sort_order = (_town_sort_order == 0) ? 1 : 0; |
0 | 498 |
_town_sort_dirty = true; |
499 |
SetWindowDirty(w); |
|
500 |
} break; |
|
501 |
||
758
bd9e868b9fae
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents:
727
diff
changeset
|
502 |
case 4: { /* Sort by Population ascending/descending */ |
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
503 |
_town_sort_order = (_town_sort_order == 2) ? 3 : 2; |
0 | 504 |
_town_sort_dirty = true; |
505 |
SetWindowDirty(w); |
|
506 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
507 |
|
758
bd9e868b9fae
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents:
727
diff
changeset
|
508 |
case 5: { /* Click on Town Matrix */ |
4277
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4171
diff
changeset
|
509 |
const Town* t; |
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4171
diff
changeset
|
510 |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4434
diff
changeset
|
511 |
uint16 id_v = (e->we.click.pt.y - 28) / 10; |
0 | 512 |
|
2549 | 513 |
if (id_v >= w->vscroll.cap) return; // click out of bounds |
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
514 |
|
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
515 |
id_v += w->vscroll.pos; |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
516 |
|
2549 | 517 |
if (id_v >= _num_town_sort) return; // click out of town bounds |
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
518 |
|
4277
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4171
diff
changeset
|
519 |
t = _town_sort[id_v]; |
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4171
diff
changeset
|
520 |
assert(t->xy); |
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4171
diff
changeset
|
521 |
ScrollMainWindowToTile(t->xy); |
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4171
diff
changeset
|
522 |
break; |
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4171
diff
changeset
|
523 |
} |
0 | 524 |
} |
525 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
526 |
|
0 | 527 |
case WE_4: |
528 |
SetWindowDirty(w); |
|
529 |
break; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
530 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
531 |
case WE_RESIZE: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4434
diff
changeset
|
532 |
w->vscroll.cap += e->we.sizing.diff.y / 10; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
533 |
break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
534 |
} |
0 | 535 |
} |
536 |
||
537 |
static const WindowDesc _town_directory_desc = { |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7554
diff
changeset
|
538 |
WDP_AUTO, WDP_AUTO, 208, 202, 208, 202, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6001
diff
changeset
|
539 |
WC_TOWN_DIRECTORY, WC_NONE, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
540 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 541 |
_town_directory_widgets, |
542 |
TownDirectoryWndProc |
|
543 |
}; |
|
544 |
||
545 |
||
6573 | 546 |
void ShowTownDirectory() |
0 | 547 |
{ |
4171 | 548 |
Window *w = AllocateWindowDescFront(&_town_directory_desc, 0); |
0 | 549 |
|
2639 | 550 |
if (w != NULL) { |
0 | 551 |
w->vscroll.cap = 16; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
552 |
w->resize.step_height = 10; |
1080
9695461dc645
(svn r1581) Added a display for the total map population to the town display (Jango)
celestar
parents:
1005
diff
changeset
|
553 |
w->resize.height = w->height - 10 * 6; // minimum of 10 items in the list, each item 10 high |
0 | 554 |
} |
555 |
} |