Go to the documentation of this file.
27 #include "table/strings.h"
34 static CompanyMask _legend_excluded_companies;
35 static CargoTypes _legend_excluded_cargo;
39 static const uint INVALID_DATAPOINT_POS = UINT_MAX;
98 if (!gui_scope)
return;
101 SetBit(_legend_excluded_companies, data);
123 panel->
SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION_TOOLTIP);
130 static const NWidgetPart _nested_graph_legend_widgets[] = {
146 _nested_graph_legend_widgets,
lengthof(_nested_graph_legend_widgets)
149 static void ShowGraphLegend()
151 AllocateWindowDescFront<GraphLegendWindow>(&_graph_legend_desc, 0);
166 static const int GRAPH_MAX_DATASETS = 64;
167 static const int GRAPH_BASE_COLOUR =
GREY_SCALE(2);
168 static const int GRAPH_GRID_COLOUR =
GREY_SCALE(3);
169 static const int GRAPH_AXIS_LINE_COLOUR =
GREY_SCALE(1);
170 static const int GRAPH_ZERO_LINE_COLOUR =
GREY_SCALE(8);
171 static const int GRAPH_YEAR_LINE_COLOUR =
GREY_SCALE(5);
191 uint16 x_values_start;
192 uint16 x_values_increment;
196 byte colours[GRAPH_MAX_DATASETS];
207 assert(num_hori_lines > 0);
210 current_interval.
highest = INT64_MIN;
211 current_interval.
lowest = INT64_MAX;
213 for (
int i = 0; i < this->num_dataset; i++) {
214 if (
HasBit(this->excluded_data, i))
continue;
215 for (
int j = 0; j < this->num_on_x_axis; j++) {
218 if (datapoint != INVALID_DATAPOINT) {
219 current_interval.
highest = std::max(current_interval.
highest, datapoint);
220 current_interval.
lowest = std::min(current_interval.
lowest, datapoint);
227 current_interval.
lowest = (11 * current_interval.
lowest) / 10;
230 double abs_lower = (current_interval.
lowest > 0) ? 0 : (
double)
abs(current_interval.
lowest);
231 double abs_higher = (current_interval.
highest < 0) ? 0 : (
double)current_interval.
highest;
236 if (abs_lower != 0 || abs_higher != 0) {
238 num_pos_grids = (int)floor(0.5 + num_hori_lines * abs_higher / (abs_higher + abs_lower));
241 if (num_pos_grids == 0 && abs_higher != 0) num_pos_grids++;
242 if (num_pos_grids == num_hori_lines && abs_lower != 0) num_pos_grids--;
245 int64 grid_size_higher = (abs_higher > 0) ? ((int64)abs_higher + num_pos_grids - 1) / num_pos_grids : 0;
246 int64 grid_size_lower = (abs_lower > 0) ? ((int64)abs_lower + num_hori_lines - num_pos_grids - 1) / (num_hori_lines - num_pos_grids) : 0;
247 grid_size = std::max(grid_size_higher, grid_size_lower);
250 num_pos_grids = num_hori_lines / 2;
254 current_interval.
highest = num_pos_grids * grid_size;
255 current_interval.
lowest = -(num_hori_lines - num_pos_grids) * grid_size;
256 return current_interval;
267 int64 y_label = current_interval.
highest;
268 int64 y_label_separation = (current_interval.
highest - current_interval.
lowest) / num_hori_lines;
272 for (
int i = 0; i < (num_hori_lines + 1); i++) {
276 if (d.width > max_width) max_width = d.width;
278 y_label -= y_label_separation;
297 assert(this->num_vert_lines > 0);
316 r.left += label_width;
318 int x_sep = (r.right - r.left) / this->num_vert_lines;
319 int y_sep = (r.bottom - r.top) / num_hori_lines;
323 r.right = r.left + x_sep * this->num_vert_lines;
324 r.bottom = r.top + y_sep * num_hori_lines;
328 x_axis_offset = (int)((r.bottom - r.top) * (double)interval.
highest / (
double)interval_size);
331 GfxFillRect(r.left, r.top, r.right, r.bottom, GRAPH_BASE_COLOUR);
338 for (
int i = 0; i < this->num_vert_lines; i++) {
339 GfxFillRect(x, r.top, x, r.bottom, GRAPH_GRID_COLOUR);
346 for (
int i = 0; i < (num_hori_lines + 1); i++) {
348 GfxFillRect(r.left, y, r.right, y, GRAPH_GRID_COLOUR);
353 GfxFillRect(r.left, r.top, r.left, r.bottom, GRAPH_AXIS_LINE_COLOUR);
356 y = x_axis_offset + r.top;
357 GfxFillRect(r.left, y, r.right, y, GRAPH_ZERO_LINE_COLOUR);
360 if (this->num_on_x_axis == 0)
return;
362 assert(this->num_on_x_axis > 0);
363 assert(this->num_dataset > 0);
366 int64 y_label = interval.
highest;
367 int64 y_label_separation =
abs(interval.
highest - interval.
lowest) / num_hori_lines;
371 for (
int i = 0; i < (num_hori_lines + 1); i++) {
376 y_label -= y_label_separation;
381 if (this->month != 0xFF) {
384 byte month = this->month;
385 Year year = this->year;
386 for (
int i = 0; i < this->num_on_x_axis; i++) {
387 SetDParam(0, month + STR_MONTH_ABBREV_JAN);
397 GfxFillRect(x + x_sep, r.top + 1, x + x_sep, r.bottom - 1, GRAPH_YEAR_LINE_COLOUR);
405 uint16 label = this->x_values_start;
407 for (
int i = 0; i < this->num_on_x_axis; i++) {
411 label += this->x_values_increment;
418 uint pointoffs1 = (linewidth + 1) / 2;
419 uint pointoffs2 = linewidth + 1 - pointoffs1;
420 for (
int i = 0; i < this->num_dataset; i++) {
421 if (!
HasBit(this->excluded_data, i)) {
423 x = r.left + (x_sep / 2);
425 byte colour = this->colours[i];
426 uint prev_x = INVALID_DATAPOINT_POS;
427 uint prev_y = INVALID_DATAPOINT_POS;
429 for (
int j = 0; j < this->num_on_x_axis; j++) {
432 if (datapoint != INVALID_DATAPOINT) {
445 int reduce_range = std::max(mult_range - 31, 0);
449 datapoint = -(
abs(datapoint) >> reduce_range);
451 datapoint >>= reduce_range;
453 y = r.top + x_axis_offset - ((r.bottom - r.top) * datapoint) / (interval_size >> reduce_range);
456 GfxFillRect(x - pointoffs1, y - pointoffs1, x + pointoffs2, y + pointoffs2, colour);
459 if (prev_x != INVALID_DATAPOINT_POS) GfxDrawLine(prev_x, prev_y, x, y, colour, linewidth);
464 prev_x = INVALID_DATAPOINT_POS;
465 prev_y = INVALID_DATAPOINT_POS;
477 format_str_y_axis(format_str_y_axis)
480 this->num_vert_lines = 24;
481 this->graph_widget = widget;
495 if (widget != this->graph_widget)
return;
497 uint x_label_width = 0;
500 if (this->month != 0xFF) {
501 byte month = this->month;
502 Year year = this->year;
503 for (
int i = 0; i < this->num_on_x_axis; i++) {
504 SetDParam(0, month + STR_MONTH_ABBREV_JAN);
506 x_label_width = std::max(x_label_width,
GetStringBoundingBox(month == 0 ? STR_GRAPH_X_LABEL_MONTH_YEAR : STR_GRAPH_X_LABEL_MONTH).
width);
526 size->height = std::max<uint>(size->height, size->width / 3);
531 if (widget != this->graph_widget)
return;
538 return INVALID_DATAPOINT;
559 if (!gui_scope)
return;
569 CompanyMask excluded_companies = _legend_excluded_companies;
578 nums = std::min(this->num_vert_lines, std::max(nums, c->num_valid_stat_ent));
588 if (!initialize && this->excluded_data == excluded_companies && this->num_on_x_axis == nums &&
589 this->year == yr && this->month == mo) {
594 this->excluded_data = excluded_companies;
595 this->num_on_x_axis = nums;
604 for (
int j = this->num_on_x_axis, i = 0; --j >= 0;) {
605 this->cost[numd][i] = (j >= c->
num_valid_stat_ent) ? INVALID_DATAPOINT : GetGraphData(c, j);
612 this->num_dataset = numd;
634 static const NWidgetPart _nested_operating_profit_widgets[] = {
655 WDP_AUTO,
"graph_operating_profit", 0, 0,
658 _nested_operating_profit_widgets,
lengthof(_nested_operating_profit_widgets)
662 void ShowOperatingProfitGraph()
664 AllocateWindowDescFront<OperatingProfitGraphWindow>(&_operating_profit_desc, 0);
685 static const NWidgetPart _nested_income_graph_widgets[] = {
709 _nested_income_graph_widgets,
lengthof(_nested_income_graph_widgets)
712 void ShowIncomeGraph()
714 AllocateWindowDescFront<IncomeGraphWindow>(&_income_graph_desc, 0);
734 static const NWidgetPart _nested_delivered_cargo_graph_widgets[] = {
754 static WindowDesc _delivered_cargo_graph_desc(
755 WDP_AUTO,
"graph_delivered_cargo", 0, 0,
758 _nested_delivered_cargo_graph_widgets,
lengthof(_nested_delivered_cargo_graph_widgets)
761 void ShowDeliveredCargoGraph()
763 AllocateWindowDescFront<DeliveredCargoGraphWindow>(&_delivered_cargo_graph_desc, 0);
789 static const NWidgetPart _nested_performance_history_widgets[] = {
811 WDP_AUTO,
"graph_performance", 0, 0,
814 _nested_performance_history_widgets,
lengthof(_nested_performance_history_widgets)
817 void ShowPerformanceHistoryGraph()
819 AllocateWindowDescFront<PerformanceHistoryGraphWindow>(&_performance_history_desc, 0);
839 static const NWidgetPart _nested_company_value_graph_widgets[] = {
860 WDP_AUTO,
"graph_company_value", 0, 0,
863 _nested_company_value_graph_widgets,
lengthof(_nested_company_value_graph_widgets)
866 void ShowCompanyValueGraph()
868 AllocateWindowDescFront<CompanyValueGraphWindow>(&_company_value_graph_desc, 0);
883 this->num_on_x_axis = 20;
884 this->num_vert_lines = 20;
886 this->x_values_start = 10;
887 this->x_values_increment = 10;
905 void UpdateExcludedData()
932 this->line_height = size->height;
933 size->height = this->line_height * 11;
952 if (pos-- > 0)
continue;
953 if (--max < 0)
break;
955 bool lowered = !
HasBit(_legend_excluded_cargo, cs->Index());
971 line = line.
Translate(0, this->line_height);
980 _legend_excluded_cargo = 0;
989 SetBit(_legend_excluded_cargo, cs->Index());
999 if (row >= this->vscroll->
GetCount())
return;
1002 if (row-- > 0)
continue;
1004 ToggleBit(_legend_excluded_cargo, cs->Index());
1005 this->UpdateExcludedData();
1031 if (!gui_scope)
return;
1037 this->UpdateExcludedData();
1041 this->colours[i] = cs->legend_colour;
1042 for (uint j = 0; j != 20; j++) {
1043 this->
cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 4 + 4, cs->Index());
1047 this->num_dataset = i;
1051 static const NWidgetPart _nested_cargo_payment_rates_widgets[] = {
1062 NWidget(
WWT_TEXT, COLOUR_BROWN,
WID_CPR_HEADER),
SetMinimalSize(0, 6),
SetPadding(2, 0, 2, 0),
SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_TITLE, STR_NULL),
1082 NWidget(
WWT_TEXT, COLOUR_BROWN,
WID_CPR_FOOTER),
SetMinimalSize(0, 6),
SetPadding(2, 0, 2, 0),
SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL, STR_NULL),
1090 WDP_AUTO,
"graph_cargo_payment_rates", 0, 0,
1093 _nested_cargo_payment_rates_widgets,
lengthof(_nested_cargo_payment_rates_widgets)
1097 void ShowCargoPaymentRates()
1099 AllocateWindowDescFront<PaymentRatesGraphWindow>(&_cargo_payment_rates_desc, 0);
1112 this->UpdateCompanyStats();
1118 void UpdateCompanyStats()
1129 uint score_info_left;
1130 uint score_info_right;
1135 uint score_detail_left;
1136 uint score_detail_right;
1145 uint score_info_width = 0;
1146 for (uint i = SCORE_BEGIN; i <
SCORE_END; i++) {
1161 int max = -(999999999 - 500);
1174 if (_currency->rate < 1000) max /= _currency->rate;
1184 this->score_info_left = rtl ? right - score_info_width :
left;
1185 this->score_info_right = rtl ? right :
left + score_info_width;
1187 this->score_detail_left = rtl ?
left : right - score_detail_width;
1188 this->score_detail_right = rtl ?
left + score_detail_width : right;
1191 this->bar_right = this->bar_left + this->bar_width - 1;
1219 int64 val = _score_part[company][score_type];
1229 uint bar_top =
CenterBounds(r.top, r.bottom, this->bar_height);
1232 DrawString(this->score_info_left, this->score_info_right, text_top, STR_PERFORMANCE_DETAIL_VEHICLES + score_type);
1236 DrawString(this->score_info_left, this->score_info_right, text_top, STR_BLACK_COMMA, TC_FROMSTRING,
SA_RIGHT);
1239 uint x = Clamp<int64>(val, 0, needed) * this->bar_width / needed;
1242 x = this->bar_right - x;
1244 x = this->bar_left + x;
1248 if (x != this->bar_left)
GfxFillRect(this->bar_left, bar_top, x, bar_top + this->bar_height - 1, rtl ? colour_notdone : colour_done);
1249 if (x != this->bar_right)
GfxFillRect(x, bar_top, this->bar_right, bar_top + this->bar_height - 1, rtl ? colour_done : colour_notdone);
1252 SetDParam(0, Clamp<int64>(val, 0, needed) * 100 / needed);
1253 DrawString(this->bar_left, this->bar_right, text_top, STR_PERFORMANCE_DETAIL_PERCENT, TC_FROMSTRING,
SA_HOR_CENTER);
1256 if (score_type == SCORE_LOAN) val = needed - val;
1262 switch (score_type) {
1263 case SCORE_MIN_PROFIT:
1264 case SCORE_MIN_INCOME:
1265 case SCORE_MAX_INCOME:
1268 DrawString(this->score_detail_left, this->score_detail_right, text_top, STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY);
1271 DrawString(this->score_detail_left, this->score_detail_right, text_top, STR_PERFORMANCE_DETAIL_AMOUNT_INT);
1292 if (--this->timeout == 0) {
1293 this->UpdateCompanyStats();
1305 if (!gui_scope)
return;
1320 this->company = c->index;
1340 const StringID performance_tips[] = {
1341 STR_PERFORMANCE_DETAIL_VEHICLES_TOOLTIP,
1342 STR_PERFORMANCE_DETAIL_STATIONS_TOOLTIP,
1343 STR_PERFORMANCE_DETAIL_MIN_PROFIT_TOOLTIP,
1344 STR_PERFORMANCE_DETAIL_MIN_INCOME_TOOLTIP,
1345 STR_PERFORMANCE_DETAIL_MAX_INCOME_TOOLTIP,
1346 STR_PERFORMANCE_DETAIL_DELIVERED_TOOLTIP,
1347 STR_PERFORMANCE_DETAIL_CARGO_TOOLTIP,
1348 STR_PERFORMANCE_DETAIL_MONEY_TOOLTIP,
1349 STR_PERFORMANCE_DETAIL_LOAN_TOOLTIP,
1350 STR_PERFORMANCE_DETAIL_TOTAL_TOOLTIP,
1372 static const NWidgetPart _nested_performance_rating_detail_widgets[] = {
1385 static WindowDesc _performance_rating_detail_desc(
1389 _nested_performance_rating_detail_widgets,
lengthof(_nested_performance_rating_detail_widgets)
1392 void ShowPerformanceRatingDetail()
1394 AllocateWindowDescFront<PerformanceRatingDetailWindow>(&_performance_rating_detail_desc, 0);
1397 void InitializeGraphGui()
1399 _legend_excluded_companies = 0;
1400 _legend_excluded_cargo = 0;
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
uint legend_width
Width of legend 'blob'.
const T GetSum() const
Get the sum of all cargo amounts.
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
static constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Money company_value
The value of the company.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Dimensions (a width and height) of a rectangle in 2D.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
uint8 FindLastBit(uint64 x)
Search the last set bit in a 64 bit variable.
@ SCORE_TOTAL
This must always be the last entry.
Year _cur_year
Current year, starting at 0.
uint8 graph_line_thickness
the thickness of the lines in the various graph guis
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
@ WC_PERFORMANCE_HISTORY
Performance history graph; Window numbers:
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
int32 Year
Type for the year, note: 0 based, i.e. starts at the year 0.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
NWidgetBase * MakeCompanyButtonRowsGraphGUI(int *biggest_index)
Make a number of rows with buttons for each company for the performance rating detail window.
ClientSettings _settings_client
The current settings for this game.
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Specification of a cargo type.
int32 WindowNumber
Number to differentiate different windows of the same class.
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
@ SA_RIGHT
Right align the text (must be a single bit).
OverflowSafeInt64 highest
Highest value of this interval. Must be zero or greater.
Owner
Enum for all companies/owners.
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
Rect WithHeight(int height, bool end=false) const
Copy Rect and set its height.
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
@ WC_DELIVERED_CARGO
Delivered cargo graph; Window numbers:
int score
How much score it will give.
High level window description.
@ COMPANY_FIRST
First company, same as owner.
@ WC_GRAPH_LEGEND
Legend for graphs; Window numbers:
static NWidgetBase * MakePerformanceDetailPanels(int *biggest_index)
Make a vertical list of panels for outputting score details.
ValuesInterval GetValuesInterval(int num_hori_lines) const
Get the interval that contains the graph's data.
@ WDP_AUTO
Find a place automatically.
byte colour
Company colour.
ResizeInfo resize
Resize information.
int32 performance_history
Company score (scale 0-1000)
byte num_valid_stat_ent
Number of valid statistical entries in old_economy.
@ FS_NORMAL
Index of the normal font in the font tables.
Rect Translate(int x, int y) const
Copy and translate Rect by x,y pixels.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
void OnInit() override
Notification that the nested widget tree gets initialized.
@ SCORE_END
How many scores are there..
int height
Height of the window (number of pixels down in y direction)
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
@ FS_SMALL
Index of the small font in the font tables.
uint Horizontal() const
Get total horizontal padding of RectPadding.
static const TextColour GRAPH_AXIS_LABEL_COLOUR
colour of the graph axis label.
void UpdateStatistics(bool initialize)
Update the statistics.
uint line_height
Pixel height of each cargo type row.
uint64 excluded_data
bitmask of the datasets that shouldn't be displayed.
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
@ MAX_COMPANIES
Maximum number of companies.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
int left
x position of left edge of the window
Rect Indent(int indent, bool end) const
Copy Rect and indent it from its position.
OverflowSafeInt64 lowest
Lowest value of this interval. Must be zero or less.
int UpdateCompanyRatingAndValue(Company *c, bool update)
if update is set to true, the economy is updated with this score (also the house is updated,...
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
void OnGameTick() override
Called once per (game) tick.
Coordinates of a point in 2D.
@ WC_INCOME_GRAPH
Income graph; Window numbers:
static const uint8 PC_BLACK
Black palette colour.
WindowNumber window_number
Window number within the window class.
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
uint Vertical() const
Get total vertical padding of RectPadding.
@ SCORE_MAX
The max score that can be in the performance history.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ SA_HOR_CENTER
Horizontally center the text.
#define FONT_HEIGHT_SMALL
Height of characters in the small (FS_SMALL) font.
CargoArray delivered_cargo
The amount of delivered cargo.
void DrawCompanyIcon(CompanyID c, int x, int y)
Draw the icon of a company.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
void DrawGraph(Rect r) const
Actually draw the graph.
@ WC_PAYMENT_RATES
Payment rates graph; Window numbers:
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Contains the interval of a graph's data.
@ WC_COMPANY_VALUE
Company value graph; Window numbers:
Money expenses
The amount of expenses.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
span< const CargoSpec * > _sorted_standard_cargo_specs
Standard cargo specifications sorted alphabetically by name.
@ WC_PERFORMANCE_DETAIL
Performance detail window; Window numbers:
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
void SetDParamMaxValue(uint n, uint64 max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
static const int MIN_GRID_PIXEL_SIZE
Minimum distance between graph lines.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
@ NUM_CARGO
Maximal number of cargo types in a game.
int needed
How much you need to get the perfect score.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
uint GetYLabelWidth(ValuesInterval current_interval, int num_hori_lines) const
Get width for Y labels.
static const int MIN_GRAPH_NUM_LINES_Y
Minimal number of horizontal lines to draw.
static T abs(const T a)
Returns the absolute value of (scalar) variable.
ScoreID
Score categories in the detailed performance rating.
Money income
The amount of income.
OverflowSafeInt64 cost[GRAPH_MAX_DATASETS][GRAPH_NUM_MONTHS]
Stored costs for the last GRAPH_NUM_MONTHS months.
@ SA_LEFT
Left align the text.
void OnResize() override
Called after the window got resized.
static int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
static T ToggleBit(T &x, const uint8 y)
Toggles a bit in a variable.
void ToggleWidgetLoweredState(byte widget_index)
Invert the lowered/raised status of a widget.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
#define lengthof(x)
Return the length of an fixed size array.
int width
width of the window (number of pixels to the right in x direction)
static const int GRAPH_NUM_MONTHS
Number of months displayed in the graph.
@ INVALID_COMPANY
An invalid company.
void OnHundredthTick() override
Called once every 100 (game) ticks, or once every 3s, whichever comes last.
#define GREY_SCALE(level)
Return the colour for a particular greyscale level.
Scrollbar * vscroll
Cargo list scrollbar.
Data structure for an opened window.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
void RaiseWidget(byte widget_index)
Marks a widget as raised.
@ ZOOM_LVL_OUT_4X
Zoomed 4 times out.
void OnGameTick() override
Called once per (game) tick.
static NWidgetBase * MakeNWidgetCompanyLines(int *biggest_index)
Construct a vertical list of buttons, one for each company.
@ WC_OPERATING_PROFIT
Operating profit graph; Window numbers:
bool IsWidgetDisabled(byte widget_index) const
Gets the enabled/disabled status of a widget.
Specification of a rectangle with absolute coordinates of all edges.
void LowerWidget(byte widget_index)
Marks a widget as lowered.
Month _cur_month
Current month (0..11)
CompanyEconomyEntry old_economy[MAX_HISTORY_QUARTERS]
Economic data of the company of the last MAX_HISTORY_QUARTERS quarters.
@ TD_RTL
Text is written right-to-left by default.
static const int DAY_TICKS
1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885.
TextDirection _current_text_dir
Text direction of the currently selected language.
GUISettings gui
settings related to the GUI
const ScoreInfo _score_info[]
Score info, values used for computing the detailed performance rating.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.