author | rubidium |
Thu, 18 Dec 2008 12:23:08 +0000 | |
changeset 10436 | 8d3a9fbe8f19 |
parent 10207 | c291a21b304e |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
9094
diff
changeset
|
3 |
/** @file subsidy_gui.cpp GUI for subsidies. */ |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6328
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1093
diff
changeset
|
6 |
#include "openttd.h" |
8785
871586967963
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
8264
diff
changeset
|
7 |
#include "station_base.h" |
0 | 8 |
#include "industry.h" |
9 |
#include "town.h" |
|
8116
8da76dcb3287
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8114
diff
changeset
|
10 |
#include "economy_func.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1962
diff
changeset
|
11 |
#include "variables.h" |
6328
1a886da998fa
(svn r9300) -Codechange: Use cargo's town effect property in the subsidy gui
peter1138
parents:
6247
diff
changeset
|
12 |
#include "cargotype.h" |
8106
e6790dd9e750
(svn r11667) -Codechange: split window.h into a header that defines some 'global' window related types, on that defined 'global' window functions and one that defines functions and types only used by *_gui.cpps.
rubidium
parents:
7956
diff
changeset
|
13 |
#include "window_gui.h" |
8114
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8106
diff
changeset
|
14 |
#include "strings_func.h" |
8140
0d0d8c94f84b
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents:
8131
diff
changeset
|
15 |
#include "date_func.h" |
8224
c5a64d87cc54
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8140
diff
changeset
|
16 |
#include "viewport_func.h" |
c5a64d87cc54
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8140
diff
changeset
|
17 |
#include "gfx_func.h" |
9094
48004fcef409
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
8852
diff
changeset
|
18 |
#include "gui.h" |
0 | 19 |
|
8264
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
20 |
#include "table/strings.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
21 |
|
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
22 |
struct SubsidyListWindow : Window { |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
23 |
SubsidyListWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
24 |
{ |
9333
2da01b3b71d8
(svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents:
9317
diff
changeset
|
25 |
this->FindWindowPlacementAndResize(desc); |
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
26 |
} |
0 | 27 |
|
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
28 |
virtual void OnClick(Point pt, int widget) |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
29 |
{ |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
30 |
if (widget != 3) return; |
0 | 31 |
|
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
32 |
int y = pt.y - 25; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
33 |
|
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
34 |
if (y < 0) return; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
35 |
|
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
36 |
uint num = 0; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
37 |
for (const Subsidy *s = _subsidies; s != endof(_subsidies); s++) { |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
38 |
if (s->cargo_type != CT_INVALID && s->age < 12) { |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
39 |
y -= 10; |
9448
1c58609bae95
(svn r13366) -Fix: clicking in the Subsidies window was broken
smatz
parents:
9362
diff
changeset
|
40 |
if (y < 0) { |
1c58609bae95
(svn r13366) -Fix: clicking in the Subsidies window was broken
smatz
parents:
9362
diff
changeset
|
41 |
this->HandleClick(s); |
1c58609bae95
(svn r13366) -Fix: clicking in the Subsidies window was broken
smatz
parents:
9362
diff
changeset
|
42 |
return; |
1c58609bae95
(svn r13366) -Fix: clicking in the Subsidies window was broken
smatz
parents:
9362
diff
changeset
|
43 |
} |
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
44 |
num++; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
45 |
} |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
46 |
} |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
47 |
|
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
48 |
if (num == 0) { |
9455
955a7bd9027f
(svn r13373) -Fix (r10210): loading of very old savegames was broken
smatz
parents:
9448
diff
changeset
|
49 |
y -= 10; // "None" |
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
50 |
if (y < 0) return; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
51 |
} |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
52 |
|
9455
955a7bd9027f
(svn r13373) -Fix (r10210): loading of very old savegames was broken
smatz
parents:
9448
diff
changeset
|
53 |
y -= 11; // "Services already subsidised:" |
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
54 |
if (y < 0) return; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
55 |
|
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
56 |
for (const Subsidy *s = _subsidies; s != endof(_subsidies); s++) { |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
57 |
if (s->cargo_type != CT_INVALID && s->age >= 12) { |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
58 |
y -= 10; |
9448
1c58609bae95
(svn r13366) -Fix: clicking in the Subsidies window was broken
smatz
parents:
9362
diff
changeset
|
59 |
if (y < 0) { |
1c58609bae95
(svn r13366) -Fix: clicking in the Subsidies window was broken
smatz
parents:
9362
diff
changeset
|
60 |
this->HandleClick(s); |
1c58609bae95
(svn r13366) -Fix: clicking in the Subsidies window was broken
smatz
parents:
9362
diff
changeset
|
61 |
return; |
1c58609bae95
(svn r13366) -Fix: clicking in the Subsidies window was broken
smatz
parents:
9362
diff
changeset
|
62 |
} |
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
63 |
} |
0 | 64 |
} |
65 |
} |
|
66 |
||
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
67 |
void HandleClick(const Subsidy *s) |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
68 |
{ |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
69 |
TownEffect te = GetCargo(s->cargo_type)->town_effect; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
70 |
TileIndex xy; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
71 |
|
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
72 |
/* determine from coordinate for subsidy and try to scroll to it */ |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
73 |
uint offs = s->from; |
0 | 74 |
if (s->age >= 12) { |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
867
diff
changeset
|
75 |
xy = GetStation(offs)->xy; |
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
76 |
} else if (te == TE_PASSENGERS || te == TE_MAIL) { |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
867
diff
changeset
|
77 |
xy = GetTown(offs)->xy; |
0 | 78 |
} else { |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
867
diff
changeset
|
79 |
xy = GetIndustry(offs)->xy; |
0 | 80 |
} |
9094
48004fcef409
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
8852
diff
changeset
|
81 |
|
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
82 |
if (_ctrl_pressed || !ScrollMainWindowToTile(xy)) { |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
83 |
if (_ctrl_pressed) ShowExtraViewPortWindow(xy); |
0 | 84 |
|
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
85 |
/* otherwise determine to coordinate for subsidy and scroll to it */ |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
86 |
offs = s->to; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
87 |
if (s->age >= 12) { |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
88 |
xy = GetStation(offs)->xy; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
89 |
} else if (te == TE_PASSENGERS || te == TE_MAIL || te == TE_GOODS || te == TE_FOOD) { |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
90 |
xy = GetTown(offs)->xy; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
91 |
} else { |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
92 |
xy = GetIndustry(offs)->xy; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
93 |
} |
0 | 94 |
|
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
95 |
if (_ctrl_pressed) { |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
96 |
ShowExtraViewPortWindow(xy); |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
97 |
} else { |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
98 |
ScrollMainWindowToTile(xy); |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
99 |
} |
0 | 100 |
} |
101 |
} |
|
102 |
||
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
103 |
virtual void OnPaint() |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
104 |
{ |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
105 |
YearMonthDay ymd; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
106 |
const Subsidy *s; |
0 | 107 |
|
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
108 |
this->DrawWidgets(); |
0 | 109 |
|
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
110 |
ConvertDateToYMD(_date, &ymd); |
2639 | 111 |
|
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
112 |
int width = this->width - 13; // scroll bar = 11 + pixel each side |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
113 |
int y = 15; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
114 |
int x = 1; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
115 |
|
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
116 |
/* Section for drawing the offered subisidies */ |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
117 |
DrawStringTruncated(x, y, STR_2026_SUBSIDIES_ON_OFFER_FOR, TC_FROMSTRING, width); |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
118 |
y += 10; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
119 |
uint num = 0; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
120 |
|
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
121 |
for (s = _subsidies; s != endof(_subsidies); s++) { |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
122 |
if (s->cargo_type != CT_INVALID && s->age < 12) { |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
123 |
int x2; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
124 |
|
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
125 |
/* Displays the two offered towns */ |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
126 |
SetupSubsidyDecodeParam(s, 1); |
9362
ee98b0755c52
(svn r13259) -Fix: Subsidy text could still overflow
peter1138
parents:
9333
diff
changeset
|
127 |
x2 = DrawStringTruncated(x + 2, y, STR_2027_FROM_TO, TC_FROMSTRING, width - 2); |
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
128 |
|
9362
ee98b0755c52
(svn r13259) -Fix: Subsidy text could still overflow
peter1138
parents:
9333
diff
changeset
|
129 |
if (width - x2 > 10) { |
ee98b0755c52
(svn r13259) -Fix: Subsidy text could still overflow
peter1138
parents:
9333
diff
changeset
|
130 |
/* Displays the deadline before voiding the proposal */ |
ee98b0755c52
(svn r13259) -Fix: Subsidy text could still overflow
peter1138
parents:
9333
diff
changeset
|
131 |
SetDParam(0, _date - ymd.day + 384 - s->age * 32); |
ee98b0755c52
(svn r13259) -Fix: Subsidy text could still overflow
peter1138
parents:
9333
diff
changeset
|
132 |
DrawStringTruncated(x2, y, STR_2028_BY, TC_FROMSTRING, width - x2); |
ee98b0755c52
(svn r13259) -Fix: Subsidy text could still overflow
peter1138
parents:
9333
diff
changeset
|
133 |
} |
ee98b0755c52
(svn r13259) -Fix: Subsidy text could still overflow
peter1138
parents:
9333
diff
changeset
|
134 |
|
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
135 |
y += 10; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
136 |
num++; |
2639 | 137 |
} |
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
138 |
} |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
139 |
|
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
140 |
if (num == 0) { |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
141 |
DrawStringTruncated(x + 2, y, STR_202A_NONE, TC_FROMSTRING, width - 2); |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
142 |
y += 10; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
143 |
} |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
144 |
|
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
145 |
/* Section for drawing the already granted subisidies */ |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
146 |
DrawStringTruncated(x, y + 1, STR_202B_SERVICES_ALREADY_SUBSIDISED, TC_FROMSTRING, width); |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
147 |
y += 10; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
148 |
num = 0; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
149 |
|
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
150 |
for (s = _subsidies; s != endof(_subsidies); s++) { |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
151 |
if (s->cargo_type != CT_INVALID && s->age >= 12) { |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
152 |
int xt; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
153 |
|
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
154 |
SetupSubsidyDecodeParam(s, 1); |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
155 |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
9778
diff
changeset
|
156 |
SetDParam(3, GetStation(s->to)->owner); |
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
157 |
|
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
158 |
/* Displays the two connected stations */ |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
159 |
xt = DrawStringTruncated(x + 2, y, STR_202C_FROM_TO, TC_FROMSTRING, width - 2); |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
160 |
|
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
161 |
/* Displays the date where the granted subsidy will end */ |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
162 |
if ((xt > 3) && (width - xt) > 9 ) { // do not draw if previous drawing failed or if it will overlap on scrollbar |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
163 |
SetDParam(0, _date - ymd.day + 768 - s->age * 32); |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
164 |
DrawStringTruncated(xt, y, STR_202D_UNTIL, TC_FROMSTRING, width - xt); |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
165 |
} |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
166 |
y += 10; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
167 |
num++; |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
168 |
} |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
169 |
} |
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
170 |
|
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
171 |
if (num == 0) DrawStringTruncated(x + 2, y, STR_202A_NONE, TC_FROMSTRING, width - 2); |
0 | 172 |
} |
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
173 |
}; |
0 | 174 |
|
175 |
static const Widget _subsidies_list_widgets[] = { |
|
9778
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9455
diff
changeset
|
176 |
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_BROWN, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9455
diff
changeset
|
177 |
{ WWT_CAPTION, RESIZE_RIGHT, COLOUR_BROWN, 11, 307, 0, 13, STR_2025_SUBSIDIES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9455
diff
changeset
|
178 |
{ WWT_STICKYBOX, RESIZE_LR, COLOUR_BROWN, 308, 319, 0, 13, STR_NULL, STR_STICKY_BUTTON}, |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9455
diff
changeset
|
179 |
{ WWT_PANEL, RESIZE_RB, COLOUR_BROWN, 0, 307, 14, 126, 0x0, STR_01FD_CLICK_ON_SERVICE_TO_CENTER}, |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9455
diff
changeset
|
180 |
{ WWT_SCROLLBAR, RESIZE_LRB, COLOUR_BROWN, 308, 319, 14, 114, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9455
diff
changeset
|
181 |
{ WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_BROWN, 308, 319, 115, 126, 0x0, STR_RESIZE_BUTTON}, |
8813
80db9335a3f2
(svn r12558) -Feature: subsidy window can now be resized.
belugas
parents:
8785
diff
changeset
|
182 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
0
diff
changeset
|
183 |
{ WIDGETS_END}, |
0 | 184 |
}; |
185 |
||
186 |
static const WindowDesc _subsidies_list_desc = { |
|
8813
80db9335a3f2
(svn r12558) -Feature: subsidy window can now be resized.
belugas
parents:
8785
diff
changeset
|
187 |
WDP_AUTO, WDP_AUTO, 320, 127, 320, 127, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5584
diff
changeset
|
188 |
WC_SUBSIDIES_LIST, WC_NONE, |
8813
80db9335a3f2
(svn r12558) -Feature: subsidy window can now be resized.
belugas
parents:
8785
diff
changeset
|
189 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 190 |
_subsidies_list_widgets, |
191 |
}; |
|
192 |
||
193 |
||
6247 | 194 |
void ShowSubsidiesList() |
0 | 195 |
{ |
9286
041f0027ca74
(svn r13152) -Codechange: make a class of the subsidy window.
rubidium
parents:
9273
diff
changeset
|
196 |
AllocateWindowDescFront<SubsidyListWindow>(&_subsidies_list_desc, 0); |
0 | 197 |
} |