31#include "table/strings.h"
37static CompanyMask _legend_excluded_companies;
38static CargoTypes _legend_excluded_cargo_payment_rates;
39static CargoTypes _legend_excluded_cargo_production_history;
43static const uint INVALID_DATAPOINT_POS = UINT_MAX;
108 SetBit(_legend_excluded_companies, data);
119 auto vert = std::make_unique<NWidgetVertical>(
NC_EQUALSIZE);
120 vert->SetPadding(2, 2, 2, 2);
124 auto panel = std::make_unique<NWidgetBackground>(
WWT_PANEL, COLOUR_BROWN, widnum);
127 panel->SetFill(1, 1);
128 panel->SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION_TOOLTIP);
129 vert->Add(std::move(panel));
134static constexpr NWidgetPart _nested_graph_legend_widgets[] = {
150 _nested_graph_legend_widgets
153static void ShowGraphLegend()
155 AllocateWindowDescFront<GraphLegendWindow>(_graph_legend_desc, 0);
170 static const int GRAPH_MAX_DATASETS = 64;
171 static const int GRAPH_BASE_COLOUR =
GREY_SCALE(2);
172 static const int GRAPH_GRID_COLOUR =
GREY_SCALE(3);
173 static const int GRAPH_AXIS_LINE_COLOUR =
GREY_SCALE(1);
174 static const int GRAPH_ZERO_LINE_COLOUR =
GREY_SCALE(8);
175 static const int GRAPH_YEAR_LINE_COLOUR =
GREY_SCALE(5);
207 std::array<OverflowSafeInt64, GRAPH_NUM_MONTHS> values;
213 std::vector<DataSet> data;
215 std::span<const StringID> ranges = {};
224 return {std::begin(
dataset.values), std::begin(
dataset.values) + this->num_on_x_axis};
242 if (
HasBit(this->excluded_data,
dataset.exclude_bit))
continue;
243 if (
HasBit(this->excluded_range,
dataset.range_bit))
continue;
336 assert(this->num_vert_lines > 0);
357 int x_sep = (r.right - r.left) / this->num_vert_lines;
362 r.right = r.left +
x_sep * this->num_vert_lines;
370 GfxFillRect(r.left, r.top, r.right, r.bottom, GRAPH_BASE_COLOUR);
378 for (
int i = 1; i < this->num_vert_lines + 1; i++) {
381 grid_colour = (i % 4 == 0) ? GRAPH_YEAR_LINE_COLOUR : GRAPH_GRID_COLOUR;
392 GfxFillRect(r.left, y, r.right, y, GRAPH_GRID_COLOUR);
397 GfxFillRect(r.left, r.top, r.left, r.bottom, GRAPH_AXIS_LINE_COLOUR);
401 GfxFillRect(r.left, y, r.right, y, GRAPH_ZERO_LINE_COLOUR);
404 if (this->num_on_x_axis == 0)
return;
406 assert(this->num_on_x_axis > 0);
424 if (this->draw_dates) {
429 for (
int i = 0; i < this->num_on_x_axis; i++) {
448 uint16_t label = this->x_values_start;
450 for (
int i = 0; i < this->num_on_x_axis; i++) {
454 label += this->x_values_increment;
465 if (
HasBit(this->excluded_data,
dataset.exclude_bit))
continue;
466 if (
HasBit(this->excluded_range,
dataset.range_bit))
continue;
469 x = r.left + (
x_sep / 2);
471 uint
prev_x = INVALID_DATAPOINT_POS;
472 uint
prev_y = INVALID_DATAPOINT_POS;
508 prev_x = INVALID_DATAPOINT_POS;
509 prev_y = INVALID_DATAPOINT_POS;
519 format_str_y_axis(format_str_y_axis)
523 this->month_increment = 3;
546 for (
const StringID &str : this->ranges) {
554 size.height *=
static_cast<uint
>(std::size(this->ranges));
565 if (this->draw_dates) {
568 for (
int i = 0; i < this->num_on_x_axis; i++) {
591 size.height = std::max<uint>(size.height, size.width / 3);
610 for (
const auto &str : this->ranges) {
631 return INVALID_DATAPOINT;
685 nums = std::min(this->num_vert_lines, std::max(
nums, c->num_valid_stat_ent));
696 this->year ==
yr && this->month ==
mo) {
702 this->num_on_x_axis =
nums;
709 if (c ==
nullptr)
continue;
715 for (
int j = this->num_on_x_axis, i = 0; --j >= 0;) {
717 dataset.values[i] = INVALID_DATAPOINT;
721 dataset.values[i] = std::min(GetGraphData(c, j), INVALID_DATAPOINT - 1);
753static constexpr NWidgetPart _nested_operating_profit_widgets[] = {
767 NWidget(
WWT_TEXT, COLOUR_BROWN,
WID_GRAPH_FOOTER),
SetMinimalSize(0, 6),
SetPadding(2, 0, 2, 0),
SetDataTip(STR_EMPTY, STR_NULL),
776 WDP_AUTO,
"graph_operating_profit", 0, 0,
779 _nested_operating_profit_widgets
783void ShowOperatingProfitGraph()
785 AllocateWindowDescFront<OperatingProfitGraphWindow>(_operating_profit_desc, 0);
812static constexpr NWidgetPart _nested_income_graph_widgets[] = {
826 NWidget(
WWT_TEXT, COLOUR_BROWN,
WID_GRAPH_FOOTER),
SetMinimalSize(0, 6),
SetPadding(2, 0, 2, 0),
SetDataTip(STR_EMPTY, STR_NULL),
838 _nested_income_graph_widgets
841void ShowIncomeGraph()
843 AllocateWindowDescFront<IncomeGraphWindow>(_income_graph_desc, 0);
869static constexpr NWidgetPart _nested_delivered_cargo_graph_widgets[] = {
883 NWidget(
WWT_TEXT, COLOUR_BROWN,
WID_GRAPH_FOOTER),
SetMinimalSize(0, 6),
SetPadding(2, 0, 2, 0),
SetDataTip(STR_EMPTY, STR_NULL),
892 WDP_AUTO,
"graph_delivered_cargo", 0, 0,
895 _nested_delivered_cargo_graph_widgets
898void ShowDeliveredCargoGraph()
900 AllocateWindowDescFront<DeliveredCargoGraphWindow>(_delivered_cargo_graph_desc, 0);
932static constexpr NWidgetPart _nested_performance_history_widgets[] = {
947 NWidget(
WWT_TEXT, COLOUR_BROWN,
WID_GRAPH_FOOTER),
SetMinimalSize(0, 6),
SetPadding(2, 0, 2, 0),
SetDataTip(STR_EMPTY, STR_NULL),
956 WDP_AUTO,
"graph_performance", 0, 0,
959 _nested_performance_history_widgets
962void ShowPerformanceHistoryGraph()
964 AllocateWindowDescFront<PerformanceHistoryGraphWindow>(_performance_history_desc, 0);
990static constexpr NWidgetPart _nested_company_value_graph_widgets[] = {
1004 NWidget(
WWT_TEXT, COLOUR_BROWN,
WID_GRAPH_FOOTER),
SetMinimalSize(0, 6),
SetPadding(2, 0, 2, 0),
SetDataTip(STR_EMPTY, STR_NULL),
1013 WDP_AUTO,
"graph_company_value", 0, 0,
1016 _nested_company_value_graph_widgets
1019void ShowCompanyValueGraph()
1021 AllocateWindowDescFront<CompanyValueGraphWindow>(_company_value_graph_desc, 0);
1036 this->num_on_x_axis = 20;
1037 this->num_vert_lines = 20;
1038 this->draw_dates =
false;
1062 void UpdateExcludedData()
1064 this->excluded_data = 0;
1068 if (
HasBit(_legend_excluded_cargo_payment_rates, cs->Index()))
SetBit(this->excluded_data, i);
1091 this->line_height = size.height;
1092 size.height = this->line_height * 11;
1109 for (
auto it = first; it !=
last; ++it) {
1128 line = line.
Translate(0, this->line_height);
1137 _legend_excluded_cargo_payment_rates = 0;
1138 this->excluded_data = 0;
1146 SetBit(_legend_excluded_cargo_payment_rates, cs->Index());
1147 SetBit(this->excluded_data, i);
1157 ToggleBit(_legend_excluded_cargo_payment_rates, (*it)->Index());
1158 this->UpdateExcludedData();
1201 this->UpdateExcludedData();
1206 dataset.colour = cs->legend_colour;
1207 dataset.exclude_bit = cs->Index();
1209 for (uint j = 0; j != this->num_on_x_axis; j++) {
1210 dataset.values[j] = GetTransportedGoodsIncome(10, 20, j * 4 + 4, cs->Index());
1216static constexpr NWidgetPart _nested_cargo_payment_rates_widgets[] = {
1227 NWidget(
WWT_TEXT, COLOUR_BROWN,
WID_GRAPH_HEADER),
SetMinimalSize(0, 6),
SetPadding(2, 0, 2, 0),
SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_TITLE, STR_NULL),
1238 NWidget(
WWT_MATRIX, COLOUR_BROWN,
WID_GRAPH_MATRIX),
SetFill(1, 0),
SetResize(0, 2),
SetMatrixDataTip(1, 0, STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO),
SetScrollbar(
WID_GRAPH_MATRIX_SCROLLBAR),
1247 NWidget(
WWT_TEXT, COLOUR_BROWN,
WID_GRAPH_FOOTER),
SetMinimalSize(0, 6),
SetPadding(2, 0, 2, 0),
SetDataTip(STR_NULL, STR_NULL),
1255 WDP_AUTO,
"graph_cargo_payment_rates", 0, 0,
1258 _nested_cargo_payment_rates_widgets
1262void ShowCargoPaymentRates()
1264 AllocateWindowDescFront<PaymentRatesGraphWindow>(_cargo_payment_rates_desc, 0);
1277 this->UpdateCompanyStats();
1283 void UpdateCompanyStats()
1294 uint score_info_left;
1295 uint score_info_right;
1300 uint score_detail_left;
1301 uint score_detail_right;
1311 for (uint i = SCORE_BEGIN; i <
SCORE_END; i++) {
1326 int max = -(999999999 - 500);
1356 this->bar_right = this->bar_left + this->bar_width - 1;
1406 x = this->bar_right - x;
1408 x = this->bar_left + x;
1427 case SCORE_MIN_PROFIT:
1428 case SCORE_MIN_INCOME:
1429 case SCORE_MAX_INCOME:
1456 if (--this->timeout == 0) {
1457 this->UpdateCompanyStats();
1484 this->company = c->index;
1507 static inline constexpr StringID RANGE_LABELS[] = {
1517 this->month_increment = 1;
1521 this->ranges = RANGE_LABELS;
1528 for (
const auto &p : i->produced) {
1549 void UpdateExcludedData()
1551 this->excluded_data = 0;
1554 for (
const auto &p : i->produced) {
1556 if (
HasBit(_legend_excluded_cargo_production_history, p.cargo))
SetBit(this->excluded_data, p.cargo);
1569 for (
const auto &p : i->
produced) {
1581 this->line_height = size.height;
1582 size.height = this->line_height * 11;
1603 for (
const auto &p : i->
produced) {
1606 if (pos-- > 0)
continue;
1607 if (--max < 0)
break;
1611 bool lowered = !
HasBit(_legend_excluded_cargo_production_history, p.cargo);
1627 line = line.
Translate(0, this->line_height);
1636 _legend_excluded_cargo_production_history = 0;
1637 this->excluded_data = 0;
1644 for (
const auto &p : i->
produced) {
1647 SetBit(_legend_excluded_cargo_production_history, p.cargo);
1648 SetBit(this->excluded_data, p.cargo);
1659 for (
const auto &p : i->
produced) {
1661 if (
row-- > 0)
continue;
1663 ToggleBit(_legend_excluded_cargo_production_history, p.cargo);
1664 this->UpdateExcludedData();
1690 this->UpdateExcludedData();
1699 if (!
initialize && this->excluded_data ==
excluded_cargo && this->num_on_x_axis == this->num_vert_lines && this->year ==
yr && this->month ==
mo) {
1710 for (
const auto &p : i->
produced) {
1714 DataSet &produced = this->data.emplace_back();
1715 produced.colour = cs->legend_colour;
1716 produced.exclude_bit = cs->
Index();
1717 produced.range_bit = 0;
1723 DataSet &transported = this->data.emplace_back();
1724 transported.colour = cs->legend_colour;
1725 transported.exclude_bit = cs->
Index();
1726 transported.range_bit = 1;
1727 transported.dash = 2;
1734 this->vscroll->
SetCount(std::size(this->data));
1740static constexpr NWidgetPart _nested_industry_production_widgets[] = {
1753 NWidget(
WWT_MATRIX, COLOUR_BROWN,
WID_GRAPH_RANGE_MATRIX),
SetFill(1, 0),
SetResize(0, 0),
SetMatrixDataTip(1, 0, STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO),
1759 NWidget(
WWT_MATRIX, COLOUR_BROWN,
WID_GRAPH_MATRIX),
SetFill(1, 0),
SetResize(0, 2),
SetMatrixDataTip(1, 0, STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO),
SetScrollbar(
WID_GRAPH_MATRIX_SCROLLBAR),
1768 NWidget(
WWT_TEXT, COLOUR_BROWN,
WID_GRAPH_FOOTER),
SetMinimalSize(0, 6),
SetPadding(2, 0, 2, 0),
SetDataTip(STR_EMPTY, STR_NULL),
1776 WDP_AUTO,
"graph_industry_production", 0, 0,
1779 _nested_industry_production_widgets
1782void ShowIndustryProductionGraph(
WindowNumber window_number)
1784 AllocateWindowDescFront<IndustryProductionGraphWindow>(_industry_production_desc, window_number);
1794 const StringID performance_tips[] = {
1795 realtime ? STR_PERFORMANCE_DETAIL_VEHICLES_TOOLTIP_PERIODS : STR_PERFORMANCE_DETAIL_VEHICLES_TOOLTIP_YEARS,
1796 STR_PERFORMANCE_DETAIL_STATIONS_TOOLTIP,
1797 realtime ? STR_PERFORMANCE_DETAIL_MIN_PROFIT_TOOLTIP_PERIODS : STR_PERFORMANCE_DETAIL_MIN_PROFIT_TOOLTIP_YEARS,
1798 STR_PERFORMANCE_DETAIL_MIN_INCOME_TOOLTIP,
1799 STR_PERFORMANCE_DETAIL_MAX_INCOME_TOOLTIP,
1800 STR_PERFORMANCE_DETAIL_DELIVERED_TOOLTIP,
1801 STR_PERFORMANCE_DETAIL_CARGO_TOOLTIP,
1802 STR_PERFORMANCE_DETAIL_MONEY_TOOLTIP,
1803 STR_PERFORMANCE_DETAIL_LOAN_TOOLTIP,
1804 STR_PERFORMANCE_DETAIL_TOTAL_TOOLTIP,
1809 auto vert = std::make_unique<NWidgetVertical>(
NC_EQUALSIZE);
1811 auto panel = std::make_unique<NWidgetBackground>(
WWT_PANEL, COLOUR_BROWN, widnum);
1812 panel->SetFill(1, 1);
1814 vert->Add(std::move(panel));
1825static constexpr NWidgetPart _nested_performance_rating_detail_widgets[] = {
1838static WindowDesc _performance_rating_detail_desc(
1842 _nested_performance_rating_detail_widgets
1845void ShowPerformanceRatingDetail()
1847 AllocateWindowDescFront<PerformanceRatingDetailWindow>(_performance_rating_detail_desc, 0);
1850void InitializeGraphGui()
1852 _legend_excluded_companies = 0;
1853 _legend_excluded_cargo_payment_rates = 0;
1854 _legend_excluded_cargo_production_history = 0;
debug_inline constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
constexpr T ToggleBit(T &x, const uint8_t y)
Toggles a bit in a variable.
bool IsValidCargoID(CargoID t)
Test whether cargo type is not INVALID_CARGO.
static const CargoID NUM_CARGO
Maximum number of cargo types in a game.
std::span< const CargoSpec * > _sorted_standard_cargo_specs
Standard cargo specifications sorted alphabetically by name.
Types/functions related to cargoes.
An interval timer will fire every interval, and will continue to fire until it is deleted.
static constexpr TimerGameTick::Ticks DAY_TICKS
1 day is 74 ticks; TimerGameCalendar::date_fract used to be uint16_t and incremented by 885.
static Year year
Current year, starting at 0.
static Month month
Current month (0..11).
static bool UsingWallclockUnits(bool newgame=false)
Check if we are using wallclock units.
uint8_t Month
Type for the month, note: 0 based, i.e.
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.
GUI Functions related to companies.
Owner
Enum for all companies/owners.
@ INVALID_COMPANY
An invalid company.
@ COMPANY_FIRST
First company, same as owner.
@ MAX_COMPANIES
Maximum number of companies.
Functions to handle different currencies.
const CurrencySpec & GetCurrency()
Get the currently selected currency.
int UpdateCompanyRatingAndValue(Company *c, bool update)
if update is set to true, the economy is updated with this score (also the house is updated,...
const ScoreInfo _score_info[]
Score info, values used for computing the detailed performance rating.
Functions related to the economy.
ScoreID
Score categories in the detailed performance rating.
@ SCORE_END
How many scores are there..
@ SCORE_MAX
The max score that can be in the performance history.
@ SCORE_TOTAL
This must always be the last entry.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
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.
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Functions related to the gfx engine.
int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
@ SA_LEFT
Left align the text.
@ SA_RIGHT
Right align the text (must be a single bit).
@ SA_HOR_CENTER
Horizontally center the text.
@ SA_CENTER
Center both horizontally and vertically.
@ FS_SMALL
Index of the small font in the font tables.
@ FS_NORMAL
Index of the normal font in the font tables.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
constexpr double INT64_MAX_IN_DOUBLE
The biggest double that when cast to int64_t still fits in a int64_t.
static std::unique_ptr< NWidgetBase > MakeNWidgetCompanyLines()
Construct a vertical list of buttons, one for each company.
std::unique_ptr< NWidgetBase > MakeCompanyButtonRowsGraphGUI()
Make a number of rows with buttons for each company for the performance rating detail window.
static std::unique_ptr< NWidgetBase > MakePerformanceDetailPanels()
Make a vertical list of panels for outputting score details.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
constexpr T abs(const T a)
Returns the absolute value of (scalar) variable.
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
uint8_t GetColourGradient(Colours colour, ColourShade shade)
Get colour gradient palette index.
static const uint8_t PC_BLACK
Black palette colour.
#define GREY_SCALE(level)
Return the colour for a particular greyscale level.
A number of safeguards to prevent using unsafe methods.
ClientSettings _settings_client
The current settings for this game.
This file contains all sprite-related enums and defines.
Definition of base types and functions in a cross-platform compatible way.
#define lengthof(array)
Return the length of an fixed size array.
void SetDParamMaxValue(size_t n, uint64_t max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
TextDirection _current_text_dir
Text direction of the currently selected language.
Functions related to OTTD's strings.
@ TD_RTL
Text is written right-to-left by default.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
uint GetYLabelWidth(ValuesInterval current_interval, int num_hori_lines) const
Get width for Y labels.
void OnGameTick() override
Called once per (game) tick.
static const int MIN_GRID_PIXEL_SIZE
Minimum distance between graph lines.
static const int GRAPH_NUM_MONTHS
Number of months displayed in the graph.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
static const int ECONOMY_QUARTER_MINUTES
Minutes per economic quarter.
std::span< const OverflowSafeInt64 > GetDataSetRange(const DataSet &dataset) const
Get appropriate part of dataset values for the current number of horizontal points.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
static const int ECONOMY_MONTH_MINUTES
Minutes per economic month.
uint64_t excluded_data
bitmask of the datasets that shouldn't be displayed.
bool draw_dates
Should we draw months and years on the time axis?
static const int MIN_GRAPH_NUM_LINES_Y
Minimal number of horizontal lines to draw.
uint64_t excluded_range
bitmask of ranges that should not be displayed.
uint8_t month_increment
month increment between vertical lines. must be divisor of 12.
static const int PAYMENT_GRAPH_X_STEP_DAYS
X-axis step label for cargo payment rates "Days in transit".
ValuesInterval GetValuesInterval(int num_hori_lines) const
Get the interval that contains the graph's data.
virtual void UpdateStatistics(bool initialize)
Update the statistics.
static const TextColour GRAPH_AXIS_LABEL_COLOUR
colour of the graph axis label.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void DrawGraph(Rect r) const
Actually draw the graph.
static const int PAYMENT_GRAPH_X_STEP_SECONDS
X-axis step label for cargo payment rates "Seconds in transit".
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.
const T GetSum() const
Get the sum of all cargo amounts.
Specification of a cargo type.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
CargoID Index() const
Determines index of this cargospec.
StringID name
Name of this type of cargo.
GUISettings gui
settings related to the GUI
Money income
The amount of income.
Money expenses
The amount of expenses.
Money company_value
The value of the company.
CargoArray delivered_cargo
The amount of delivered cargo.
int32_t performance_history
Company score (scale 0-1000)
CompanyEconomyEntry old_economy[MAX_HISTORY_QUARTERS]
Economic data of the company of the last MAX_HISTORY_QUARTERS quarters.
Colours colour
Company colour.
uint8_t num_valid_stat_ent
Number of valid statistical entries in old_economy.
uint16_t rate
The conversion rate compared to the base currency.
Dimensions (a width and height) of a rectangle in 2D.
uint8_t graph_line_thickness
the thickness of the lines in the various graph guis
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void UpdateStatistics(bool initialize) override
Update the statistics.
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 OnResize() override
Called after the window got resized.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
uint line_height
Pixel height of each cargo type row.
uint legend_width
Width of legend 'blob'.
void OnInit() override
Notification that the nested widget tree gets initialized.
void SetStringParameters(WidgetID widget) const override
Initialize string parameters for a widget.
Scrollbar * vscroll
Cargo list scrollbar.
Defines the internal data of a functional industry.
ProducedCargoes produced
produced cargo slots
uint line_height
Pixel height of each cargo type row.
void OnResize() override
Called after the window got resized.
void OnInit() override
Notification that the nested widget tree gets initialized.
void OnGameTick() override
Called once per (game) tick.
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 UpdatePaymentRates()
Update the payment rates according to the latest information.
IntervalTimer< TimerWindow > update_payment_interval
Update the payment rates on a regular interval.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
uint legend_width
Width of legend 'blob'.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Scrollbar * vscroll
Cargo list scrollbar.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
Coordinates of a point in 2D.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
static Titem * Get(size_t index)
Returns Titem with given index.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
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 WithHeight(int height, bool end=false) const
Copy Rect and set its height.
Rect Indent(int indent, bool end) const
Copy Rect and indent it from its position.
Rect Translate(int x, int y) const
Copy and translate Rect by x,y pixels.
int needed
How much you need to get the perfect score.
int score
How much score it will give.
Templated helper to make a type-safe 'typedef' representing a single POD value.
Contains the interval of a graph's data.
OverflowSafeInt64 lowest
Lowest value of this interval. Must be zero or less.
OverflowSafeInt64 highest
Highest value of this interval. Must be zero or greater.
High level window description.
Data structure for an opened window.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
ResizeInfo resize
Resize information.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
int left
x position of left edge of the window
int GetRowFromWidget(int clickpos, WidgetID widget, int padding, int line_height=-1) const
Compute the row of a widget that a user clicked in.
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
int height
Height of the window (number of pixels down in y direction)
int width
width of the window (number of pixels to the right in x direction)
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
WindowNumber window_number
Window number within the window class.
Definition of Interval and OneShot timers.
Definition of the game-economy-timer.
Definition of the tick-based game-timer.
Definition of the Window system.
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-...
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
@ WDP_AUTO
Find a place automatically.
int32_t WindowNumber
Number to differentiate different windows of the same class.
@ WC_PERFORMANCE_HISTORY
Performance history graph; Window numbers:
@ WC_PERFORMANCE_DETAIL
Performance detail window; Window numbers:
@ WC_PAYMENT_RATES
Payment rates graph; Window numbers:
@ WC_GRAPH_LEGEND
Legend for graphs; Window numbers:
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ WC_OPERATING_PROFIT
Operating profit graph; Window numbers:
@ WC_INDUSTRY_PRODUCTION
Industry production history graph; Window numbers:
@ WC_INDUSTRY_VIEW
Industry view; Window numbers:
@ WC_INCOME_GRAPH
Income graph; Window numbers:
@ WC_DELIVERED_CARGO
Delivered cargo graph; Window numbers:
@ WC_COMPANY_VALUE
Company value graph; Window numbers:
Functions related to zooming.
@ ZOOM_LVL_NORMAL
The normal zoom level.