OpenTTD Source 20260621-master-g720d10536d
league_gui.cpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#include "stdafx.h"
11#include "league_gui.h"
12#include "company_base.h"
13#include "company_gui.h"
14#include "gui.h"
15#include "industry.h"
16#include "league_base.h"
17#include "sortlist_type.h"
18#include "story_base.h"
19#include "strings_func.h"
20#include "tile_map.h"
21#include "town.h"
22#include "viewport_func.h"
23#include "window_gui.h"
24
26
27#include "table/strings.h"
28#include "table/sprites.h"
29
30#include "safeguards.h"
31
32
33static const StringID _performance_titles[] = {
34 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_ENGINEER,
35 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_ENGINEER,
36 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_TRAFFIC_MANAGER,
37 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_TRAFFIC_MANAGER,
38 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_TRANSPORT_COORDINATOR,
39 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_TRANSPORT_COORDINATOR,
40 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_ROUTE_SUPERVISOR,
41 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_ROUTE_SUPERVISOR,
42 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_DIRECTOR,
43 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_DIRECTOR,
44 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_CHIEF_EXECUTIVE,
45 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_CHIEF_EXECUTIVE,
46 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_CHAIRMAN,
47 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_CHAIRMAN,
48 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_PRESIDENT,
49 STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_TYCOON,
50};
51
52static inline StringID GetPerformanceTitleFromValue(uint value)
53{
54 return _performance_titles[std::min(value, 1000u) >> 6];
55}
56
57class PerformanceLeagueWindow : public Window {
58private:
59 GUIList<const Company *> companies{};
60 uint rank_width = 0;
61 uint text_width = 0;
62 int line_height = 0;
64
69 {
70 if (!this->companies.NeedRebuild()) return;
71
72 this->companies.clear();
73 this->companies.reserve(Company::GetNumItems());
74
75 for (const Company *c : Company::Iterate()) {
76 this->companies.push_back(c);
77 }
78
79 this->companies.RebuildDone();
80 }
81
83 static bool PerformanceSorter(const Company * const &a, const Company * const &b)
84 {
85 return b->old_economy[0].performance_history < a->old_economy[0].performance_history;
86 }
87
88public:
90 {
91 this->InitNested(window_number);
92 this->companies.ForceRebuild();
93 this->companies.NeedResort();
94 }
95
96 void OnPaint() override
97 {
98 this->BuildCompanyList();
99 this->companies.Sort(&PerformanceSorter);
100
101 this->DrawWidgets();
102 }
103
104 void DrawWidget(const Rect &r, WidgetID widget) const override
105 {
106 if (widget != WID_PLT_BACKGROUND) return;
107
108 Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
109 int icon_y_offset = (this->line_height - this->icon.height) / 2;
110 int text_y_offset = (this->line_height - GetCharacterHeight(FontSize::Normal)) / 2;
111
112 bool rtl = _current_text_dir == TD_RTL;
113 Rect rank_rect = ir.WithWidth(this->rank_width, rtl);
114 Rect icon_rect = ir.Indent(this->rank_width + WidgetDimensions::scaled.hsep_wide, rtl).WithWidth(this->icon.width, rtl);
115 Rect text_rect = ir.Indent(this->rank_width + this->icon.width + WidgetDimensions::scaled.hsep_wide * 2, rtl);
116
117 for (uint i = 0; i != this->companies.size(); i++) {
118 const Company *c = this->companies[i];
119 DrawString(rank_rect.left, rank_rect.right, ir.top + text_y_offset, GetString(STR_COMPANY_LEAGUE_COMPANY_RANK, i + 1));
120
121 DrawCompanyIcon(c->index, icon_rect.left, ir.top + icon_y_offset);
122
123 DrawString(text_rect.left, text_rect.right, ir.top + text_y_offset, GetString(STR_COMPANY_LEAGUE_COMPANY_NAME, c->index, c->index, GetPerformanceTitleFromValue(c->old_economy[0].performance_history)));
124 ir.top += this->line_height;
125 }
126 }
127
128 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
129 {
130 if (widget != WID_PLT_BACKGROUND) return;
131
132 this->rank_width = 0;
133 for (uint i = 0; i < MAX_COMPANIES; i++) {
134 this->rank_width = std::max(this->rank_width, GetStringBoundingBox(GetString(STR_COMPANY_LEAGUE_COMPANY_RANK, i + 1)).width);
135 }
136
137 uint widest_width = 0;
138 StringID widest_title = STR_NULL;
139 for (auto title : _performance_titles) {
140 uint width = GetStringBoundingBox(title).width;
141 if (width > widest_width) {
142 widest_title = title;
143 widest_width = width;
144 }
145 }
146
147 this->icon = GetSpriteSize(SPR_COMPANY_ICON);
148 this->line_height = std::max<int>(this->icon.height + WidgetDimensions::scaled.vsep_normal, GetCharacterHeight(FontSize::Normal));
149
150 for (const Company *c : Company::Iterate()) {
151 widest_width = std::max(widest_width, GetStringBoundingBox(GetString(STR_COMPANY_LEAGUE_COMPANY_NAME, c->index, c->index, widest_title)).width);
152 }
153
154 this->text_width = widest_width + WidgetDimensions::scaled.hsep_indent * 3; // Keep some extra spacing
155
156 size.width = WidgetDimensions::scaled.framerect.Horizontal() + this->rank_width + WidgetDimensions::scaled.hsep_wide + this->icon.width + WidgetDimensions::scaled.hsep_wide + this->text_width;
157 size.height = this->line_height * MAX_COMPANIES + WidgetDimensions::scaled.framerect.Vertical();
158 }
159
160 void OnGameTick() override
161 {
162 if (this->companies.NeedResort()) {
163 this->SetDirty();
164 }
165 }
166
172 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
173 {
174 if (data == 0) {
175 /* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
176 this->companies.ForceRebuild();
177 } else {
178 this->companies.ForceResort();
179 }
180 }
181};
182
183static constexpr std::initializer_list<NWidgetPart> _nested_performance_league_widgets = {
186 NWidget(WWT_CAPTION, Colours::Brown), SetStringTip(STR_COMPANY_LEAGUE_TABLE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
189 EndContainer(),
191 EndContainer(),
192};
193
196 WindowPosition::Automatic, "performance_league", 0, 0,
197 WindowClass::CompanyLeague, WindowClass::None,
198 {},
199 _nested_performance_league_widgets
200);
201
202void ShowPerformanceLeagueTable()
203{
205}
206
207static void HandleLinkClick(Link link)
208{
209 TileIndex xy;
210 switch (link.type) {
211 case LinkType::None:
212 return;
213
214 case LinkType::Tile:
215 if (!IsValidTile(link.target)) return;
216 xy = TileIndex{link.target};
217 break;
218
220 if (!Industry::IsValidID(link.target)) return;
221 xy = Industry::Get(link.target)->location.tile;
222 break;
223
224 case LinkType::Town:
225 if (!Town::IsValidID(link.target)) return;
226 xy = Town::Get(link.target)->xy;
227 break;
228
230 ShowCompany((CompanyID)link.target);
231 return;
232
233 case LinkType::StoryPage: {
234 if (!StoryPage::IsValidID(link.target)) return;
235 CompanyID story_company = StoryPage::Get(link.target)->company;
236 ShowStoryBook(story_company, static_cast<StoryPageID>(link.target));
237 return;
238 }
239
240 default: NOT_REACHED();
241 }
242
243 if (_ctrl_pressed) {
245 } else {
247 }
248}
249
250
251class ScriptLeagueWindow : public Window {
252private:
253 LeagueTableID table{};
254 std::vector<std::pair<uint, const LeagueTableElement *>> rows{};
255 uint rank_width = 0;
256 uint text_width = 0;
257 uint score_width = 0;
258 uint header_height = 0;
259 int line_height = 0;
261 EncodedString title{};
262
267 {
268 this->rows.clear();
269 this->title = {};
270
271 const LeagueTable *lt = LeagueTable::GetIfValid(this->table);
272 if (lt == nullptr) return;
273
274 /* We store title in the window class so we can safely reference the string later */
275 this->title = lt->title;
276
277 std::vector<const LeagueTableElement *> elements;
279 if (lte->table != this->table) continue;
280 elements.push_back(lte);
281 }
282 std::ranges::sort(elements, [](const LeagueTableElement *a, const LeagueTableElement *b) { return a->rating > b->rating; });
283
284 /* Calculate rank, companies with the same rating share the ranks */
285 uint rank = 0;
286 for (uint i = 0; i != elements.size(); i++) {
287 const LeagueTableElement *lte = elements[i];
288 if (i > 0 && elements[i - 1]->rating != lte->rating) rank = i;
289 this->rows.emplace_back(rank, lte);
290 }
291 }
292
293public:
294 ScriptLeagueWindow(WindowDesc &desc, WindowNumber table) : Window(desc), table(table)
295 {
296 this->BuildTable();
297 this->InitNested(table);
298 }
299
300 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
301 {
302 if (widget != WID_SLT_CAPTION) return this->Window::GetWidgetString(widget, stringid);
303
304 return this->title.GetDecodedString();
305 }
306
307 void OnPaint() override
308 {
309 this->DrawWidgets();
310 }
311
312 void DrawWidget(const Rect &r, WidgetID widget) const override
313 {
314 if (widget != WID_SLT_BACKGROUND) return;
315
316 const LeagueTable *lt = LeagueTable::GetIfValid(this->table);
317 if (lt == nullptr) return;
318
319 Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
320
321 if (!lt->header.empty()) {
323 }
324
325 int icon_y_offset = (this->line_height - this->icon_size.height) / 2;
326 int text_y_offset = (this->line_height - GetCharacterHeight(FontSize::Normal)) / 2;
327
328 /* Calculate positions.of the columns */
329 bool rtl = _current_text_dir == TD_RTL;
330 int spacer = WidgetDimensions::scaled.hsep_wide;
331 Rect rank_rect = ir.WithWidth(this->rank_width, rtl);
332 Rect icon_rect = ir.Indent(this->rank_width + (rtl ? 0 : spacer), rtl).WithWidth(this->icon_size.width, rtl);
333 Rect text_rect = ir.Indent(this->rank_width + spacer + this->icon_size.width, rtl).WithWidth(this->text_width, rtl);
334 Rect score_rect = ir.Indent(this->rank_width + 2 * spacer + this->icon_size.width + this->text_width, rtl).WithWidth(this->score_width, rtl);
335
336 for (const auto &[rank, lte] : this->rows) {
337 DrawString(rank_rect.left, rank_rect.right, ir.top + text_y_offset, GetString(STR_COMPANY_LEAGUE_COMPANY_RANK, rank + 1));
338 if (this->icon_size.width > 0 && lte->company != CompanyID::Invalid()) DrawCompanyIcon(lte->company, icon_rect.left, ir.top + icon_y_offset);
339 DrawString(text_rect.left, text_rect.right, ir.top + text_y_offset, lte->text.GetDecodedString(), TextColour::Black);
340 DrawString(score_rect.left, score_rect.right, ir.top + text_y_offset, lte->score.GetDecodedString(), TextColour::Black, SA_RIGHT | SA_FORCE);
341 ir.top += this->line_height;
342 }
343
344 if (!lt->footer.empty()) {
345 ir.top += WidgetDimensions::scaled.vsep_wide;
347 }
348 }
349
350 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
351 {
352 if (widget != WID_SLT_BACKGROUND) return;
353
354 const LeagueTable *lt = LeagueTable::GetIfValid(this->table);
355 if (lt == nullptr) return;
356
357 this->icon_size = GetSpriteSize(SPR_COMPANY_ICON);
358 this->line_height = std::max<int>(this->icon_size.height + WidgetDimensions::scaled.fullbevel.Vertical(), GetCharacterHeight(FontSize::Normal));
359
360 /* Calculate maximum width of every column */
361 this->rank_width = this->text_width = this->score_width = 0;
362 bool show_icon_column = false;
363 for (const auto &[rank, lte] : this->rows) {
364 this->rank_width = std::max(this->rank_width, GetStringBoundingBox(GetString(STR_COMPANY_LEAGUE_COMPANY_RANK, rank + 1)).width);
365 this->text_width = std::max(this->text_width, GetStringBoundingBox(lte->text.GetDecodedString()).width);
366 this->score_width = std::max(this->score_width, GetStringBoundingBox(lte->score.GetDecodedString()).width);
367 if (lte->company != CompanyID::Invalid()) show_icon_column = true;
368 }
369
370 if (!show_icon_column) {
371 this->icon_size.width = 0;
372 } else {
373 this->icon_size.width += WidgetDimensions::scaled.hsep_wide;
374 }
375
376 uint non_text_width = this->rank_width + this->icon_size.width + this->score_width + WidgetDimensions::scaled.framerect.Horizontal() + WidgetDimensions::scaled.hsep_wide * 2;
377 size.width = std::max(size.width, non_text_width + this->text_width);
378 uint used_height = this->line_height * std::max<uint>(3u, static_cast<uint>(this->rows.size())) + WidgetDimensions::scaled.framerect.Vertical();
379
380 /* Adjust text_width to fill any space left over if the preset minimal width is larger than our calculated width. */
381 this->text_width = size.width - non_text_width;
382
383 if (!lt->header.empty()) {
384 this->header_height = GetStringHeight(lt->header.GetDecodedString(), size.width - WidgetDimensions::scaled.framerect.Horizontal()) + WidgetDimensions::scaled.vsep_wide;
385 } else {
386 this->header_height = 0;
387 }
388 used_height += this->header_height;
389
390 if (!lt->footer.empty()) {
391 used_height += GetStringHeight(lt->footer.GetDecodedString(), size.width - WidgetDimensions::scaled.framerect.Horizontal()) + WidgetDimensions::scaled.vsep_wide;
392 }
393
394 size.height = std::max(size.height, used_height);
395 }
396
397 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
398 {
399 if (widget != WID_SLT_BACKGROUND) return;
400
402 int index = (pt.y - WidgetDimensions::scaled.framerect.top - wid->pos_y - this->header_height) / this->line_height;
403 if (index >= 0 && static_cast<uint>(index) < this->rows.size()) {
404 const LeagueTableElement *lte = this->rows[index].second;
405 HandleLinkClick(lte->link);
406 }
407 }
408
414 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
415 {
416 this->BuildTable();
417 this->ReInit();
418 }
419};
420
421static constexpr std::initializer_list<NWidgetPart> _nested_script_league_widgets = {
427 EndContainer(),
429 EndContainer(),
430};
431
434 WindowPosition::Automatic, "script_league", 0, 0,
435 WindowClass::CompanyLeague, WindowClass::None,
436 {},
437 _nested_script_league_widgets
438);
439
440void ShowScriptLeagueTable(LeagueTableID table)
441{
442 if (!LeagueTable::IsValidID(table)) return;
444}
445
446void ShowFirstLeagueTable()
447{
448 auto it = LeagueTable::Iterate();
449 if (!it.empty()) {
450 ShowScriptLeagueTable((*it.begin())->index);
451 } else {
452 ShowPerformanceLeagueTable();
453 }
454}
Container for an encoded string, created by GetEncodedString.
std::string GetDecodedString() const
Decode the encoded string.
Definition strings.cpp:207
List template of 'things' T to sort in a GUI.
void RebuildDone()
Notify the sortlist that the rebuild is done.
bool NeedRebuild() const
Check if a rebuild is needed.
void ForceRebuild()
Force that a rebuild is needed.
bool Sort(Comp compare)
Sort the list.
void ForceResort()
Force a resort next Sort call Reset the resort timer if used too.
bool NeedResort()
Check if a resort is needed next loop If used the resort timer will decrease every call till 0.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
uint rank_width
The width of the rank.
int line_height
Height of the text lines.
void BuildCompanyList()
(Re)Build the company league list
static bool PerformanceSorter(const Company *const &a, const Company *const &b)
Sort the company league by performance history.
void OnPaint() override
The window must be repainted.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Dimension icon
Dimension of the company icon.
void OnGameTick() override
Called once per (game) tick.
uint text_width
The width of the actual text.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
int line_height
Height of the text lines.
uint header_height
Height of the table header.
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
uint text_width
The width of the actual text.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
void OnPaint() override
The window must be repainted.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
uint score_width
The width of the score text.
uint rank_width
The width of the rank ordinal.
Dimension icon_size
Dimension of the company icon.
void BuildTable()
Rebuild the company league list.
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition window_gui.h:30
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:95
Definition of stuff that is very close to a company, like the company struct itself.
void DrawCompanyIcon(CompanyID c, int x, int y)
Draw the icon of a company.
void ShowCompany(CompanyID company)
Show the window with the overview of the company.
GUI Functions related to companies.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition fontcache.cpp:88
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Definition gfx.cpp:716
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition gfx.cpp:971
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition gfx.cpp:899
bool _ctrl_pressed
Is Ctrl pressed?
Definition gfx.cpp:39
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, ExtendedTextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition gfx.cpp:787
int DrawString(int left, int right, int top, std::string_view str, ExtendedTextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition gfx.cpp:668
@ Normal
Index of the normal font in the font tables.
Definition gfx_type.h:249
@ SA_RIGHT
Right align the text (must be a single bit).
Definition gfx_type.h:438
@ SA_FORCE
Force the alignment, i.e. don't swap for RTL languages.
Definition gfx_type.h:448
@ Brown
Brown.
Definition gfx_type.h:299
@ Black
Black colour.
Definition gfx_type.h:335
constexpr NWidgetPart SetStringTip(StringID string, StringID tip={})
Widget part function for setting the string and tooltip.
constexpr NWidgetPart SetMinimalTextLines(uint8_t lines, uint8_t spacing, FontSize size=FontSize::Normal)
Widget part function for setting the minimal text lines.
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=INVALID_WIDGET)
Widget part function for starting a new 'real' widget.
void SetDirty() const
Mark entire window as dirty (in need of re-paint).
Definition window.cpp:972
GUI functions that shouldn't be here.
void ShowStoryBook(CompanyID company, StoryPageID page_id=StoryPageID::Invalid(), bool centered=false)
Raise or create the story book window for company, at page page_id.
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
Base of all industries.
LeagueTable base class.
static WindowDesc _performance_league_desc(WindowPosition::Automatic, "performance_league", 0, 0, WindowClass::CompanyLeague, WindowClass::None, {}, _nested_performance_league_widgets)
Window definition for the performance league window.
static WindowDesc _script_league_desc(WindowPosition::Automatic, "script_league", 0, 0, WindowClass::CompanyLeague, WindowClass::None, {}, _nested_script_league_widgets)
Window definition for the script league window.
League table GUI functions.
@ Company
Link a company.
Definition league_type.h:21
@ Industry
Link an industry.
Definition league_type.h:19
@ None
No link.
Definition league_type.h:17
@ StoryPage
Link a story page.
Definition league_type.h:22
@ Town
Link a town.
Definition league_type.h:20
@ Tile
Link a tile.
Definition league_type.h:18
PoolID< uint8_t, struct LeagueTableIDTag, 255, 0xFF > LeagueTableID
ID of a league table.
Definition league_type.h:35
Types related to the graph widgets.
@ WID_PLT_BACKGROUND
Background of the window.
@ WID_SLT_BACKGROUND
Background of the window.
@ WID_SLT_CAPTION
Caption of the window.
#define Point
Macro that prevents name conflicts between included headers.
A number of safeguards to prevent using unsafe methods.
Base types for having sorted lists in GUIs.
This file contains all sprite-related enums and defines.
Definition of base types and functions in a cross-platform compatible way.
StoryPage base class.
PoolID< uint16_t, struct StoryPageIDTag, 64000, 0xFFFF > StoryPageID
ID of a story page.
Definition story_type.h:16
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Definition strings.cpp:424
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition strings.cpp:56
Functions related to OTTD's strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
@ TD_RTL
Text is written right-to-left by default.
std::array< CompanyEconomyEntry, MAX_HISTORY_QUARTERS > old_economy
Economic data of the company of the last MAX_HISTORY_QUARTERS quarters.
Dimensions (a width and height) of a rectangle in 2D.
Struct about league table elements.
Definition league_base.h:32
int64_t rating
Value that determines ordering of elements in the table (higher=better).
Definition league_base.h:34
Link link
What opens when element is clicked.
Definition league_base.h:38
Struct about custom league tables.
Definition league_base.h:52
EncodedString header
Text to show above the table.
Definition league_base.h:54
EncodedString title
Title of the table.
Definition league_base.h:53
EncodedString footer
Text to show below the table.
Definition league_base.h:55
static Pool::IterateWrapper< Company > Iterate(size_t from=0)
static Industry * Get(auto index)
static LeagueTable * GetIfValid(auto index)
Specification of a rectangle with absolute coordinates of all edges.
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Rect Indent(int indent, bool end) const
Copy Rect and indent it from its position.
High level window description.
Definition window_gui.h:172
Number to differentiate different windows of the same class.
Data structure for an opened window.
Definition window_gui.h:273
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
Definition window.cpp:984
void DrawWidgets() const
Paint all widgets of a window.
Definition widget.cpp:786
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
Definition window.cpp:510
ResizeInfo resize
Resize information.
Definition window_gui.h:314
Window(WindowDesc &desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition window.cpp:1838
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
Definition window_gui.h:989
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition window.cpp:1828
int width
width of the window (number of pixels to the right in x direction)
Definition window_gui.h:311
WindowNumber window_number
Window number within the window class.
Definition window_gui.h:302
Map writing/reading functions for tiles.
bool IsValidTile(Tile tile)
Checks if a tile is valid.
Definition tile_map.h:161
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
Definition tile_type.h:92
Base of the town class.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
Functions related to (drawing on) viewports.
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:66
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:39
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX).
Definition widget_type.h:57
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX).
Definition widget_type.h:55
@ WWT_CAPTION
Window caption (window title between closebox and stickybox).
Definition widget_type.h:52
@ WWT_CLOSEBOX
Close box (at top-left of a window).
Definition widget_type.h:60
Functions, definitions and such used only by the GUI.
Twindow * AllocateWindowDescFront(WindowDesc &desc, WindowNumber window_number, Targs... extra_arguments)
Open a new window.
@ Automatic
Find a place automatically.
Definition window_gui.h:146
int WidgetID
Widget ID.
Definition window_type.h:21