annotate town_gui.c @ 2444:c1145552a533 draft

(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
author peter1138 <peter1138@openttd.org>
date Thu, 22 Sep 2005 20:35:20 +0000
parents 90730a4ce5bc
children 1628110c9dcf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2186
042e6d005cb0 (svn r2701) Insert Id tags into all source files
tron <tron@openttd.org>
parents: 2163
diff changeset
1 /* $Id$ */
042e6d005cb0 (svn r2701) Insert Id tags into all source files
tron <tron@openttd.org>
parents: 2163
diff changeset
2
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
3 #include "stdafx.h"
1891
81b2cb2fc036 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater <Darkvater@openttd.org>
parents: 1820
diff changeset
4 #include "openttd.h"
1299
14b802fe0f85 (svn r1803) Move debugging stuff into files of it's own
tron <tron@openttd.org>
parents: 1260
diff changeset
5 #include "debug.h"
2163
acad95b3c4a2 (svn r2673) Include functions.h directly, not globally via openttd.h
tron <tron@openttd.org>
parents: 2159
diff changeset
6 #include "functions.h"
1309
6794f84df1f3 (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 <tron@openttd.org>
parents: 1299
diff changeset
7 #include "strings.h"
1363
b454e702374d (svn r1867) Include tables/sprites.h only in files which need it
tron <tron@openttd.org>
parents: 1323
diff changeset
8 #include "table/sprites.h"
507
9dcc34b8887e (svn r815) Include strings.h only in the files which need it.
tron <tron@openttd.org>
parents: 410
diff changeset
9 #include "table/strings.h"
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
10 #include "town.h"
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
11 #include "window.h"
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
12 #include "gfx.h"
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
13 #include "viewport.h"
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
14 #include "gui.h"
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
15 #include "command.h"
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
16 #include "player.h"
891
89096b98b68d (svn r1377) -Fix: only a server can rename a town in a MP game
darkvater <darkvater@openttd.org>
parents: 867
diff changeset
17 #include "network.h"
2159
a832c39b4afe (svn r2669) Shuffle some more stuff around to reduce dependencies
tron <tron@openttd.org>
parents: 2070
diff changeset
18 #include "variables.h"
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
19
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
20 static const Widget _town_authority_widgets[] = {
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
21 { WWT_TEXTBTN, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
22 { WWT_CAPTION, RESIZE_NONE, 13, 11, 316, 0, 13, STR_2022_LOCAL_AUTHORITY, STR_018C_WINDOW_TITLE_DRAG_THIS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
23 { WWT_IMGBTN, RESIZE_NONE, 13, 0, 316, 14, 105, 0x0, STR_NULL},
893
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 891
diff changeset
24 { WWT_IMGBTN, RESIZE_NONE, 13, 0, 306, 106, 157, 0x0, STR_2043_LIST_OF_THINGS_TO_DO_AT},
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 891
diff changeset
25 { WWT_SCROLLBAR, RESIZE_NONE, 13, 305, 316, 106, 157, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
26 { WWT_IMGBTN, RESIZE_NONE, 13, 0, 316, 158, 209, 0x0, STR_NULL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
27 { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 0, 316, 210, 221, STR_2042_DO_IT, STR_2044_CARRY_OUT_THE_HIGHLIGHTED},
176
5ff3972188b5 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater <darkvater@openttd.org>
parents: 174
diff changeset
28 { WIDGETS_END},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
29 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
30
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
31 extern const byte _town_action_costs[8];
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
32 extern void DrawPlayerIcon(int p, int x, int y);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
33
1793
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
34 /** Get a list of available actions to do at a town.
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
35 * @param *nump if not NULL add put the number of available actions in it
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
36 * @param pid the player that is querying the town
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
37 * @param *t the town that is queried
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
38 * @return bitmasked value of enabled actions
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
39 */
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
40 uint GetMaskOfTownActions(int *nump, PlayerID pid, const Town *t)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
41 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
42 int32 avail, ref;
1793
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
43 int num = 0;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
44 uint avail_buttons = 0x7F; // by default all buttons except bribe are enabled.
1793
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
45 uint buttons = 0;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
46
1793
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
47 if (pid != OWNER_SPECTATOR) {
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
48 int i;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
49 // bribe option enabled?
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
50 if (_patches.bribe) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
51 // if unwanted, disable everything.
1793
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
52 if (t->unwanted[pid]) {
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
53 avail_buttons = 0;
1793
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
54 } else if (t->ratings[pid] < 600)
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
55 SETBIT(avail_buttons, 7); // only bribe if less than excellent
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
56 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
57
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
58 // Things worth more than this are not shown
1962
24ee3f699d48 (svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar <celestar@openttd.org>
parents: 1891
diff changeset
59 avail = GetPlayer(pid)->player_money + _price.station_value * 200;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
60 ref = _price.build_industry >> 8;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
61
1793
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
62 for (i = 0; i != lengthof(_town_action_costs); i++, avail_buttons >>= 1) {
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
63 if (HASBIT(avail_buttons, 0) && avail >= _town_action_costs[i] * ref) {
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
64 SETBIT(buttons, i);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
65 num++;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
66 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
67 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
68
1793
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
69 /* Disable build statue if already built */
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
70 if (HASBIT(t->statues, pid)) {
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
71 CLRBIT(buttons, 4);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
72 num--;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
73 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
74
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
75 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
76
1793
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
77 if (nump != NULL) *nump = num;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
78 return buttons;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
79 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
80
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
81 static int GetNthSetBit(uint32 bits, int n)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
82 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
83 int i = 0;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
84 if (n >= 0) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
85 do {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
86 if (bits&1 && --n < 0) return i;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
87 i++;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
88 } while (bits>>=1);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
89 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
90 return -1;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
91 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
92
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
93 static void TownAuthorityWndProc(Window *w, WindowEvent *e)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
94 {
1793
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
95 switch (e->event) {
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
96 case WE_PAINT: {
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
97 const Town *t = GetTown(w->window_number);
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
98 int numact;
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
99 uint buttons = GetMaskOfTownActions(&numact, _local_player, t);
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
100
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
101 SetVScrollCount(w, numact + 1);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
102
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
103 if (WP(w,def_d).data_1 != -1 && !HASBIT(buttons, WP(w,def_d).data_1))
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
104 WP(w,def_d).data_1 = -1;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
105
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
106 w->disabled_state = (WP(w,def_d).data_1 == -1) ? (1 << 6) : 0;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
107
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
108 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
109 int y;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
110 Player *p;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
111 int r;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
112 StringID str;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
113
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
114 SetDParam(0, w->window_number);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
115 DrawWindowWidgets(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
116
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
117 DrawString(2, 15, STR_2023_TRANSPORT_COMPANY_RATINGS, 0);
122
d749298b1654 (svn r123) Fixed some indentions... btw credits for the last commit go to Celestar
dominik <dominik@openttd.org>
parents: 121
diff changeset
118
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
119 // Draw list of players
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
120 y = 25;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
121 FOR_ALL_PLAYERS(p) {
121
d8006a13f9ea (svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik <dominik@openttd.org>
parents: 69
diff changeset
122 if (p->is_active && (HASBIT(t->have_ratings, p->index) || t->exclusivity==p->index)) {
125
9116f409ca7f (svn r126) Forgot to remove some test code
dominik <dominik@openttd.org>
parents: 122
diff changeset
123 DrawPlayerIcon(p->index, 2, y);
121
d8006a13f9ea (svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik <dominik@openttd.org>
parents: 69
diff changeset
124
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
125 SetDParam(0, p->name_1);
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
126 SetDParam(1, p->name_2);
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
127 SetDParam(2, GetPlayerNameString(p->index, 3));
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
128
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
129 r = t->ratings[p->index];
1005
81dea216ead6 (svn r1504) enummed town ratings (Jango)
celestar <celestar@openttd.org>
parents: 919
diff changeset
130 (str = STR_3035_APPALLING, r <= RATING_APPALLING) || // Apalling
81dea216ead6 (svn r1504) enummed town ratings (Jango)
celestar <celestar@openttd.org>
parents: 919
diff changeset
131 (str++, r <= RATING_VERYPOOR) || // Very Poor
81dea216ead6 (svn r1504) enummed town ratings (Jango)
celestar <celestar@openttd.org>
parents: 919
diff changeset
132 (str++, r <= RATING_POOR) || // Poor
81dea216ead6 (svn r1504) enummed town ratings (Jango)
celestar <celestar@openttd.org>
parents: 919
diff changeset
133 (str++, r <= RATING_MEDIOCRE) || // Mediocore
81dea216ead6 (svn r1504) enummed town ratings (Jango)
celestar <celestar@openttd.org>
parents: 919
diff changeset
134 (str++, r <= RATING_GOOD) || // Good
81dea216ead6 (svn r1504) enummed town ratings (Jango)
celestar <celestar@openttd.org>
parents: 919
diff changeset
135 (str++, r <= RATING_VERYGOOD) || // Very Good
81dea216ead6 (svn r1504) enummed town ratings (Jango)
celestar <celestar@openttd.org>
parents: 919
diff changeset
136 (str++, r <= RATING_EXCELLENT) || // Excellent
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
137 (str++, true); // Outstanding
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
138
2063
fd2cdcd08d76 (svn r2572) - Codechange: [string] Changed string system so it's not as dependent on decode_parameters
ludde <ludde@openttd.org>
parents: 1962
diff changeset
139 SetDParam(4, str);
246
2ade3a312ce3 (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 <darkvater@openttd.org>
parents: 222
diff changeset
140 if (t->exclusivity == p->index) // red icon for player with exclusive rights
2187
ec59060e9c43 (svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar <celestar@openttd.org>
parents: 2186
diff changeset
141 DrawSprite((SPR_BLOT) | PALETTE_TO_RED, 18, y);
246
2ade3a312ce3 (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 <darkvater@openttd.org>
parents: 222
diff changeset
142
2ade3a312ce3 (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 <darkvater@openttd.org>
parents: 222
diff changeset
143 DrawString(28, y, STR_2024, 0);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
144 y+=10;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
145 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
146 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
147 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
148
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
149 // Draw actions list
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
150 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
151 int y = 107, i;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
152 int pos = w->vscroll.pos;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
153
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
154 if (--pos < 0) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
155 DrawString(2, y, STR_2045_ACTIONS_AVAILABLE, 0);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
156 y+=10;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
157 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
158 for(i=0; buttons; i++,buttons>>=1) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
159 if (pos <= -5)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
160 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
161
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
162 if (buttons&1 && --pos < 0) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
163 DrawString(3, y, STR_2046_SMALL_ADVERTISING_CAMPAIGN + i, 6);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
164 y += 10;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
165 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
166 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
167 }
122
d749298b1654 (svn r123) Fixed some indentions... btw credits for the last commit go to Celestar
dominik <dominik@openttd.org>
parents: 121
diff changeset
168
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
169 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
170 int i;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
171 if ((i=WP(w,def_d).data_1) != -1) {
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
172 SetDParam(1, (_price.build_industry >> 8) * _town_action_costs[i]);
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
173 SetDParam(0, STR_2046_SMALL_ADVERTISING_CAMPAIGN + i);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
174 DrawStringMultiLine(2, 159, STR_204D_INITIATE_A_SMALL_LOCAL + i, 313);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
175 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
176 }
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
177
1793
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
178 } break;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
179
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
180 case WE_CLICK:
1793
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
181 switch (e->click.widget) {
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
182 case 3: { /* listbox */
1793
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
183 const Town *t = GetTown(w->window_number);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
184 int y = (e->click.pt.y - 0x6B) / 10;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
185 if (!IS_INT_INSIDE(y, 0, 5))
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
186 return;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
187
1793
48d8faf0a4de (svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater <Darkvater@openttd.org>
parents: 1363
diff changeset
188 y = GetNthSetBit(GetMaskOfTownActions(NULL, _local_player, t), y + w->vscroll.pos - 1);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
189 if (y >= 0) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
190 WP(w,def_d).data_1 = y;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
191 SetWindowDirty(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
192 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
193 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
194 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
195
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
196 case 6: { /* carry out the action */
1803
5caf69ee7b57 (svn r2307) - Fix (regression): it was not possible to change the drive-side in the intro-game.
Darkvater <Darkvater@openttd.org>
parents: 1793
diff changeset
197 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
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
198 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
199 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
200 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
201 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
202
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
203 case WE_4:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
204 SetWindowDirty(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
205 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
206 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
207 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
208
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
209 static const WindowDesc _town_authority_desc = {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
210 -1, -1, 317, 222,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
211 WC_TOWN_AUTHORITY,0,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
212 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
213 _town_authority_widgets,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
214 TownAuthorityWndProc
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
215 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
216
410
e165d1275350 (svn r607) -Patch: [ 985102 ] static cleanup
tron <tron@openttd.org>
parents: 246
diff changeset
217 static void ShowTownAuthorityWindow(uint town)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
218 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
219 Window *w;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
220
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
221 w = AllocateWindowDescFront(&_town_authority_desc, town);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
222 if (w) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
223 w->vscroll.cap = 5;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
224 WP(w,def_d).data_1 = -1;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
225 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
226 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
227
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
228 static void TownViewWndProc(Window *w, WindowEvent *e)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
229 {
919
a2d3299a67ee (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight <truelight@openttd.org>
parents: 893
diff changeset
230 Town *t = GetTown(w->window_number);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
231
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
232 switch(e->event) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
233 case WE_PAINT:
891
89096b98b68d (svn r1377) -Fix: only a server can rename a town in a MP game
darkvater <darkvater@openttd.org>
parents: 867
diff changeset
234 // disable renaming town in network games if you are not the server
89096b98b68d (svn r1377) -Fix: only a server can rename a town in a MP game
darkvater <darkvater@openttd.org>
parents: 867
diff changeset
235 if (_networking && !_network_server) SETBIT(w->disabled_state, 8);
89096b98b68d (svn r1377) -Fix: only a server can rename a town in a MP game
darkvater <darkvater@openttd.org>
parents: 867
diff changeset
236
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
237 SetDParam(0, t->index);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
238 DrawWindowWidgets(w);
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
239
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
240 SetDParam(0, t->population);
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
241 SetDParam(1, t->num_houses);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
242 DrawString(2,107,STR_2006_POPULATION,0);
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
243
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
244 SetDParam(0, t->act_pass);
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
245 SetDParam(1, t->max_pass);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
246 DrawString(2,117,STR_200D_PASSENGERS_LAST_MONTH_MAX,0);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
247
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
248 SetDParam(0, t->act_mail);
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
249 SetDParam(1, t->max_mail);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
250 DrawString(2,127,STR_200E_MAIL_LAST_MONTH_MAX,0);
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
251
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
252 DrawWindowViewport(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
253 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
254
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
255 case WE_CLICK:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
256 switch(e->click.widget) {
758
73bce34f355f (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 <darkvater@openttd.org>
parents: 727
diff changeset
257 case 6: /* scroll to location */
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
258 ScrollMainWindowToTile(t->xy);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
259 break;
758
73bce34f355f (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 <darkvater@openttd.org>
parents: 727
diff changeset
260 case 7: /* town authority */
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
261 ShowTownAuthorityWindow(w->window_number);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
262 break;
758
73bce34f355f (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 <darkvater@openttd.org>
parents: 727
diff changeset
263 case 8: /* rename */
2070
e0e63cbeb60a (svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde <ludde@openttd.org>
parents: 2063
diff changeset
264 SetDParam(0, w->window_number);
e0e63cbeb60a (svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde <ludde@openttd.org>
parents: 2063
diff changeset
265 ShowQueryString(STR_TOWN, STR_2007_RENAME_TOWN, 31, 130, w->window_class, w->window_number);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
266 break;
758
73bce34f355f (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 <darkvater@openttd.org>
parents: 727
diff changeset
267 case 9: /* expand town */
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
268 ExpandTown(t);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
269 break;
758
73bce34f355f (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 <darkvater@openttd.org>
parents: 727
diff changeset
270 case 10: /* delete town */
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
271 DeleteTown(t);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
272 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
273 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
274 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
275
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
276 case WE_ON_EDIT_TEXT: {
1820
bda7198fe6ba (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 <tron@openttd.org>
parents: 1803
diff changeset
277 if (e->edittext.str[0] != '\0') {
bda7198fe6ba (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 <tron@openttd.org>
parents: 1803
diff changeset
278 _cmd_text = e->edittext.str;
bda7198fe6ba (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 <tron@openttd.org>
parents: 1803
diff changeset
279 DoCommandP(0, w->window_number, 0, NULL,
bda7198fe6ba (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 <tron@openttd.org>
parents: 1803
diff changeset
280 CMD_RENAME_TOWN | CMD_MSG(STR_2008_CAN_T_RENAME_TOWN));
bda7198fe6ba (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 <tron@openttd.org>
parents: 1803
diff changeset
281 }
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
282 } break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
283 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
284 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
285
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
286
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
287 static const Widget _town_view_widgets[] = {
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
288 { WWT_TEXTBTN, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
289 { WWT_CAPTION, RESIZE_NONE, 13, 11, 247, 0, 13, STR_2005, STR_018C_WINDOW_TITLE_DRAG_THIS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
290 { WWT_STICKYBOX, RESIZE_NONE, 13, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
291 { WWT_IMGBTN, RESIZE_NONE, 13, 0, 259, 14, 105, 0x0, STR_NULL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
292 { WWT_6, RESIZE_NONE, 13, 2, 257, 16, 103, 0x0, STR_NULL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
293 { WWT_IMGBTN, RESIZE_NONE, 13, 0, 259, 106, 137, 0x0, STR_NULL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
294 { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 0, 85, 138, 149, STR_00E4_LOCATION, STR_200B_CENTER_THE_MAIN_VIEW_ON},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
295 { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 86, 171, 138, 149, STR_2020_LOCAL_AUTHORITY,STR_2021_SHOW_INFORMATION_ON_LOCAL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
296 { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 172, 259, 138, 149, STR_0130_RENAME, STR_200C_CHANGE_TOWN_NAME},
176
5ff3972188b5 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater <darkvater@openttd.org>
parents: 174
diff changeset
297 { WIDGETS_END},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
298 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
299
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
300 static const WindowDesc _town_view_desc = {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
301 -1, -1, 260, 150,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
302 WC_TOWN_VIEW,0,
758
73bce34f355f (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 <darkvater@openttd.org>
parents: 727
diff changeset
303 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
304 _town_view_widgets,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
305 TownViewWndProc
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
306 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
307
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
308 static const Widget _town_view_scen_widgets[] = {
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
309 { WWT_TEXTBTN, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
310 { WWT_CAPTION, RESIZE_NONE, 13, 11, 172, 0, 13, STR_2005, STR_018C_WINDOW_TITLE_DRAG_THIS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
311 { WWT_STICKYBOX, RESIZE_NONE, 13, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
312 { WWT_IMGBTN, RESIZE_NONE, 13, 0, 259, 14, 105, 0x0, STR_NULL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
313 { WWT_6, RESIZE_NONE, 13, 2, 257, 16, 103, 0x0, STR_NULL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
314 { WWT_IMGBTN, RESIZE_NONE, 13, 0, 259, 106, 137, 0x0, STR_NULL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
315 { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 0, 85, 138, 149, STR_00E4_LOCATION, STR_200B_CENTER_THE_MAIN_VIEW_ON},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
316 { WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
317 { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 173, 247, 0, 13, STR_0130_RENAME, STR_200C_CHANGE_TOWN_NAME},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
318 { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 86, 171, 138, 149, STR_023C_EXPAND, STR_023B_INCREASE_SIZE_OF_TOWN},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
319 { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 172, 259, 138, 149, STR_0290_DELETE, STR_0291_DELETE_THIS_TOWN_COMPLETELY},
176
5ff3972188b5 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater <darkvater@openttd.org>
parents: 174
diff changeset
320 { WIDGETS_END},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
321 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
322
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
323 static const WindowDesc _town_view_scen_desc = {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
324 -1, -1, 260, 150,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
325 WC_TOWN_VIEW,0,
758
73bce34f355f (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 <darkvater@openttd.org>
parents: 727
diff changeset
326 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
327 _town_view_scen_widgets,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
328 TownViewWndProc
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
329 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
330
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
331 void ShowTownViewWindow(uint town)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
332 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
333 Window *w;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
334 Town *t;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
335
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
336 if (_game_mode != GM_EDITOR) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
337 w = AllocateWindowDescFront(&_town_view_desc, town);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
338 } else {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
339 w = AllocateWindowDescFront(&_town_view_scen_desc, town);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
340 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
341
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
342 if (w) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
343 w->flags4 |= WF_DISABLE_VP_SCROLL;
919
a2d3299a67ee (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight <truelight@openttd.org>
parents: 893
diff changeset
344 t = GetTown(w->window_number);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
345 AssignWindowViewport(w, 3, 17, 0xFE, 0x56, t->xy, 1);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
346 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
347 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
348
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
349 static const Widget _town_directory_widgets[] = {
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
350 { WWT_TEXTBTN, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
351 { WWT_CAPTION, RESIZE_NONE, 13, 11, 195, 0, 13, STR_2000_TOWNS, STR_018C_WINDOW_TITLE_DRAG_THIS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
352 { WWT_STICKYBOX, RESIZE_NONE, 13, 196, 207, 0, 13, 0x0, STR_STICKY_BUTTON},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
353 { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 0, 98, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP},
893
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 891
diff changeset
354 { WWT_PUSHTXTBTN, RESIZE_NONE, 13, 99, 195, 14, 25, STR_SORT_BY_POPULATION, STR_SORT_ORDER_TIP},
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 891
diff changeset
355 { WWT_IMGBTN, RESIZE_BOTTOM, 13, 0, 195, 26, 189, 0x0, STR_200A_TOWN_NAMES_CLICK_ON_NAME},
1080
36438048c5e4 (svn r1581) Added a display for the total map population to the town display (Jango)
celestar <celestar@openttd.org>
parents: 1005
diff changeset
356 { WWT_SCROLLBAR, RESIZE_BOTTOM, 13, 196, 207, 14, 189, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
36438048c5e4 (svn r1581) Added a display for the total map population to the town display (Jango)
celestar <celestar@openttd.org>
parents: 1005
diff changeset
357 { WWT_PANEL, RESIZE_TB, 13, 0, 195, 190, 201, 0x0, STR_NULL},
36438048c5e4 (svn r1581) Added a display for the total map population to the town display (Jango)
celestar <celestar@openttd.org>
parents: 1005
diff changeset
358 { WWT_RESIZEBOX, RESIZE_TB, 13, 196, 207, 190, 201, 0x0, STR_RESIZE_BUTTON},
176
5ff3972188b5 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater <darkvater@openttd.org>
parents: 174
diff changeset
359 { WIDGETS_END},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
360 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
361
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
362
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
363 // used to get a sorted list of the towns
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
364 static uint _num_town_sort;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
365
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
366 static char _bufcache[64];
821
e803462c0b42 (svn r1292) -Codechange: also updated the town/industry sort-list to be uint16 compatible
truelight <truelight@openttd.org>
parents: 758
diff changeset
367 static uint16 _last_town_idx;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
368
164
1d9de926a503 (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 <darkvater@openttd.org>
parents: 125
diff changeset
369 static int CDECL TownNameSorter(const void *a, const void *b)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
370 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
371 char buf1[64];
1260
cbe4888dbfc5 (svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight <truelight@openttd.org>
parents: 1093
diff changeset
372 uint16 val;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
373 int r;
2070
e0e63cbeb60a (svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde <ludde@openttd.org>
parents: 2063
diff changeset
374 int32 argv[1];
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
375
2070
e0e63cbeb60a (svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde <ludde@openttd.org>
parents: 2063
diff changeset
376 argv[0] = *(const uint16*)a;
e0e63cbeb60a (svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde <ludde@openttd.org>
parents: 2063
diff changeset
377 GetStringWithArgs(buf1, STR_TOWN, argv);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
378
1260
cbe4888dbfc5 (svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight <truelight@openttd.org>
parents: 1093
diff changeset
379 /* If 'b' is the same town as in the last round, use the cached value
cbe4888dbfc5 (svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight <truelight@openttd.org>
parents: 1093
diff changeset
380 * We do this to speed stuff up ('b' is called with the same value a lot of
cbe4888dbfc5 (svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight <truelight@openttd.org>
parents: 1093
diff changeset
381 * times after eachother) */
cbe4888dbfc5 (svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight <truelight@openttd.org>
parents: 1093
diff changeset
382 val = *(const uint16*)b;
cbe4888dbfc5 (svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight <truelight@openttd.org>
parents: 1093
diff changeset
383 if (val != _last_town_idx) {
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
384 _last_town_idx = val;
2070
e0e63cbeb60a (svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde <ludde@openttd.org>
parents: 2063
diff changeset
385 argv[0] = val;
e0e63cbeb60a (svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde <ludde@openttd.org>
parents: 2063
diff changeset
386 GetStringWithArgs(_bufcache, STR_TOWN, argv);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
387 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
388
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
389 r = strcmp(buf1, _bufcache);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
390 if (_town_sort_order & 1) r = -r;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
391 return r;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
392 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
393
164
1d9de926a503 (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 <darkvater@openttd.org>
parents: 125
diff changeset
394 static int CDECL TownPopSorter(const void *a, const void *b)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
395 {
919
a2d3299a67ee (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight <truelight@openttd.org>
parents: 893
diff changeset
396 const Town *ta = GetTown(*(const uint16*)a);
a2d3299a67ee (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight <truelight@openttd.org>
parents: 893
diff changeset
397 const Town *tb = GetTown(*(const uint16*)b);
164
1d9de926a503 (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 <darkvater@openttd.org>
parents: 125
diff changeset
398 int r = ta->population - tb->population;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
399 if (_town_sort_order & 1) r = -r;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
400 return r;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
401 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
402
1093
5029c37a31c0 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron <tron@openttd.org>
parents: 1080
diff changeset
403 static void MakeSortedTownList(void)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
404 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
405 Town *t;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
406 int n = 0;
919
a2d3299a67ee (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight <truelight@openttd.org>
parents: 893
diff changeset
407
a2d3299a67ee (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight <truelight@openttd.org>
parents: 893
diff changeset
408 /* Create array for sorting */
1260
cbe4888dbfc5 (svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight <truelight@openttd.org>
parents: 1093
diff changeset
409 _town_sort = realloc(_town_sort, GetTownPoolSize() * sizeof(_town_sort[0]));
919
a2d3299a67ee (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight <truelight@openttd.org>
parents: 893
diff changeset
410 if (_town_sort == NULL)
a2d3299a67ee (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight <truelight@openttd.org>
parents: 893
diff changeset
411 error("Could not allocate memory for the town-sorting-list");
a2d3299a67ee (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight <truelight@openttd.org>
parents: 893
diff changeset
412
821
e803462c0b42 (svn r1292) -Codechange: also updated the town/industry sort-list to be uint16 compatible
truelight <truelight@openttd.org>
parents: 758
diff changeset
413 FOR_ALL_TOWNS(t)
1260
cbe4888dbfc5 (svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight <truelight@openttd.org>
parents: 1093
diff changeset
414 if (t->xy)
821
e803462c0b42 (svn r1292) -Codechange: also updated the town/industry sort-list to be uint16 compatible
truelight <truelight@openttd.org>
parents: 758
diff changeset
415 _town_sort[n++] = t->index;
e803462c0b42 (svn r1292) -Codechange: also updated the town/industry sort-list to be uint16 compatible
truelight <truelight@openttd.org>
parents: 758
diff changeset
416
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
417 _num_town_sort = n;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
418
174
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
419 _last_town_idx = 0; // used for "cache"
164
1d9de926a503 (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 <darkvater@openttd.org>
parents: 125
diff changeset
420 qsort(_town_sort, n, sizeof(_town_sort[0]), _town_sort_order & 2 ? TownPopSorter : TownNameSorter);
65
1c2cba90e3bf (svn r66) -Fix Station list updated on station deletion/station rename
darkvater <darkvater@openttd.org>
parents: 16
diff changeset
421
69
5da6e50f8970 (svn r70) -Fix: typo in english.txt
darkvater <darkvater@openttd.org>
parents: 65
diff changeset
422 DEBUG(misc, 1) ("Resorting Towns list...");
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
423 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
424
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
425
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
426 static void TownDirectoryWndProc(Window *w, WindowEvent *e)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
427 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
428 switch(e->event) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
429 case WE_PAINT: {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
430
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
431 if (_town_sort_dirty) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
432 _town_sort_dirty = false;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
433 MakeSortedTownList();
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
434 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
435
174
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
436 SetVScrollCount(w, _num_town_sort);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
437
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
438 DrawWindowWidgets(w);
2406
90730a4ce5bc (svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron <tron@openttd.org>
parents: 2187
diff changeset
439 DoDrawString(_town_sort_order & 1 ? DOWNARROW : UPARROW, (_town_sort_order <= 1) ? 88 : 187, 15, 0x10);
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
440
174
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
441 {
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
442 Town *t;
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
443 int n = 0;
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
444 uint16 i = w->vscroll.pos;
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
445 int y = 28;
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
446
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
447 while (i < _num_town_sort) {
919
a2d3299a67ee (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight <truelight@openttd.org>
parents: 893
diff changeset
448 t = GetTown(_town_sort[i]);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
449
174
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
450 assert(t->xy);
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
451
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
452 SetDParam(0, t->index);
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
453 SetDParam(1, t->population);
174
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
454 DrawString(2, y, STR_2057, 0);
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
455
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
456 y += 10;
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
457 i++;
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
458 if (++n == w->vscroll.cap) { break;} // max number of towns in 1 window
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
459 }
1080
36438048c5e4 (svn r1581) Added a display for the total map population to the town display (Jango)
celestar <celestar@openttd.org>
parents: 1005
diff changeset
460 SetDParam(0, GetWorldPopulation());
36438048c5e4 (svn r1581) Added a display for the total map population to the town display (Jango)
celestar <celestar@openttd.org>
parents: 1005
diff changeset
461 DrawString(3, w->height - 12 + 2, STR_TOWN_POPULATION, 0);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
462 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
463 } break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
464
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
465 case WE_CLICK:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
466 switch(e->click.widget) {
758
73bce34f355f (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 <darkvater@openttd.org>
parents: 727
diff changeset
467 case 3: { /* Sort by Name ascending/descending */
174
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
468 _town_sort_order = (_town_sort_order == 0) ? 1 : 0;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
469 _town_sort_dirty = true;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
470 SetWindowDirty(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
471 } break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
472
758
73bce34f355f (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 <darkvater@openttd.org>
parents: 727
diff changeset
473 case 4: { /* Sort by Population ascending/descending */
174
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
474 _town_sort_order = (_town_sort_order == 2) ? 3 : 2;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
475 _town_sort_dirty = true;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
476 SetWindowDirty(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
477 } break;
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
478
758
73bce34f355f (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 <darkvater@openttd.org>
parents: 727
diff changeset
479 case 5: { /* Click on Town Matrix */
174
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
480 uint16 id_v = (e->click.pt.y - 28) / 10;
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
481
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
482 if (id_v >= w->vscroll.cap) { return;} // click out of bounds
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
483
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
484 id_v += w->vscroll.pos;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
485
174
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
486 if (id_v >= _num_town_sort) { return;} // click out of town bounds
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
487
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
488 {
919
a2d3299a67ee (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight <truelight@openttd.org>
parents: 893
diff changeset
489 Town *t = GetTown(_town_sort[id_v]);
174
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
490 assert(t->xy);
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
491
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
492 ScrollMainWindowToTile(t->xy);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
493 }
174
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
494 } break;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
495 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
496 break;
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
497
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
498 case WE_4:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
499 SetWindowDirty(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
500 break;
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
501
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
502 case WE_RESIZE:
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
503 w->vscroll.cap += e->sizing.diff.y / 10;
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
504 break;
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
505 }
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
506 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
507
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
508 static const WindowDesc _town_directory_desc = {
1080
36438048c5e4 (svn r1581) Added a display for the total map population to the town display (Jango)
celestar <celestar@openttd.org>
parents: 1005
diff changeset
509 -1, -1, 208, 202,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
510 WC_TOWN_DIRECTORY,0,
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
511 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
512 _town_directory_widgets,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
513 TownDirectoryWndProc
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
514 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
515
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
516
1093
5029c37a31c0 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron <tron@openttd.org>
parents: 1080
diff changeset
517 void ShowTownDirectory(void)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
518 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
519 Window *w;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
520
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
521 w = AllocateWindowDescFront(&_town_directory_desc, 0);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
522 if (w) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
523 w->vscroll.cap = 16;
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 821
diff changeset
524 w->resize.step_height = 10;
1080
36438048c5e4 (svn r1581) Added a display for the total map population to the town display (Jango)
celestar <celestar@openttd.org>
parents: 1005
diff changeset
525 w->resize.height = w->height - 10 * 6; // minimum of 10 items in the list, each item 10 high
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
526 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
527 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
528
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
529