87 const std::initializer_list<ExpensesType> &
items;
93 uint GetHeight()
const
166 DrawString(tr, STR_FINANCES_SECTION_CONSTRUCTION + et);
190 y += list.GetHeight();
218 StringID str = STR_FINANCES_NEGATIVE_INCOME;
220 str = STR_FINANCES_ZERO_INCOME;
221 }
else if (amount < 0) {
223 str = STR_FINANCES_POSITIVE_INCOME;
239 Money cost = tbl[et];
241 if (cost != 0)
DrawPrice(cost, r.left, r.right, y, TC_BLACK);
248 if (sum != 0)
DrawPrice(sum, r.left, r.right, y, TC_WHITE);
283 DrawPrice(sum, r.left, r.right, y, TC_WHITE);
286static constexpr NWidgetPart _nested_company_finances_widgets[] = {
496 this->small = !this->
small;
521 void RefreshVisibleColumns()
523 for (uint period = 0; period < this->
first_visible; ++period) {
527 if (std::ranges::any_of(expenses, [](
const Money &value) {
return value != 0; })) {
528 this->first_visible = period;
536 this->RefreshVisibleColumns();
560 _nested_company_finances_widgets
579 LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL, LC_RAIL,
582 LC_AIRCRAFT, LC_AIRCRAFT, LC_AIRCRAFT,
590template <SpriteID TSprite = SPR_SQUARE>
609 void ShowColourDropDownMenu(
uint32_t widget)
617 if (this->livery_class < LC_GROUP_RAIL &&
HasBit(this->sel, LS_DEFAULT) &&
primary) {
625 if (this->livery_class < LC_GROUP_RAIL) {
632 livery = &c->livery[
scheme];
651 for (Colours colour = COLOUR_BEGIN; colour != COLOUR_END; colour++) {
668 this->groups.clear();
670 if (this->livery_class >= LC_GROUP_RAIL) {
680 if (this->livery_class < LC_GROUP_RAIL) {
688 this->rows = (uint)this->groups.size();
691 this->vscroll->
SetCount(this->rows);
701 this->livery_class = LC_OTHER;
704 this->BuildGroupList(company);
707 this->SetSelectedGroup(company, group);
711 this->owner = company;
720 case VEH_TRAIN: this->livery_class = LC_GROUP_RAIL;
break;
721 case VEH_ROAD: this->livery_class = LC_GROUP_ROAD;
break;
722 case VEH_SHIP: this->livery_class = LC_GROUP_SHIP;
break;
723 case VEH_AIRCRAFT: this->livery_class = LC_GROUP_AIRCRAFT;
break;
724 default: NOT_REACHED();
730 this->BuildGroupList(company);
734 for (uint i = 0; i < this->rows; i++) {
735 if (this->groups[i].group->index == sel) {
760 size.width = std::max(size.width, 5 +
d.width + padding.width);
769 size.height = 5 * this->line_height;
771 resize.height = this->line_height;
785 for (Colours colour = COLOUR_BEGIN; colour != COLOUR_END; colour++) {
799 bool disabled = this->livery_class < LC_GROUP_RAIL ? (this->sel == 0) : (this->sel ==
INVALID_GROUP);
821 if (this->livery_class < LC_GROUP_RAIL) {
822 if (this->sel != 0) {
886 if (
sec.right >
sec.left) {
891 y += this->line_height;
896 if (livery_class < LC_GROUP_RAIL) {
900 if (pos-- > 0)
continue;
906 for (
auto it = first; it !=
last; ++it) {
907 const Group *g = it->group;
912 if (this->vscroll->
GetCount() == 0) {
938 if (this->livery_class < LC_GROUP_RAIL) {
951 if (!this->groups.empty()) {
952 this->sel = this->groups[0].group->index;
969 if (this->livery_class < LC_GROUP_RAIL) {
971 if (
row >= this->rows)
return;
987 if (it == std::end(this->groups))
return;
989 this->sel = it->group->index;
1007 Colours colour =
static_cast<Colours
>(index);
1008 if (colour >= COLOUR_END) colour = INVALID_COLOUR;
1010 if (this->livery_class < LC_GROUP_RAIL) {
1035 if (this->livery_class == data + LC_GROUP_RAIL) {
1042 if (!this->groups.empty()) this->sel = this->groups[0].group->index;
1052 bool current_class_valid = this->livery_class == LC_OTHER || this->livery_class >= LC_GROUP_RAIL;
1058 }
else if (this->livery_class < LC_GROUP_RAIL) {
1071static constexpr NWidgetPart _nested_select_company_livery_widgets[] = {
1092 NWidget(
WWT_MATRIX, COLOUR_GREY,
WID_SCL_MATRIX),
SetMinimalSize(275, 0),
SetResize(1, 0),
SetFill(1, 1),
SetMatrixDataTip(1, 0, STR_LIVERY_PANEL_TOOLTIP),
SetScrollbar(
WID_SCL_MATRIX_SCROLLBAR),
1103static WindowDesc _select_company_livery_desc(
1104 WDP_AUTO,
"company_color_scheme", 0, 0,
1107 _nested_select_company_livery_widgets
1116 w->SetSelectedGroup(company, group);
1141 if (
_cmf_info[CMFV_EYE_COLOUR].valid_values[ge] < 2) {
1145 default: NOT_REACHED();
1146 case 0: pal = PALETTE_TO_BROWN;
break;
1147 case 1: pal = PALETTE_TO_BLUE;
break;
1148 case 2: pal = PALETTE_TO_GREEN;
break;
1153 DrawSprite(SPR_GRADIENT, GENERAL_SPRITE_COLOUR(colour), x, y);
1157 case CMFV_MOUSTACHE:
if (!has_moustache)
continue;
break;
1159 case CMFV_NOSE:
if (has_moustache)
continue;
break;
1160 case CMFV_TIE_EARRING:
if (!has_tie_earring)
continue;
break;
1161 case CMFV_GLASSES:
if (!has_glasses)
continue;
break;
1376 this->advanced =
false;
1536 if (this->is_female) {
1548 if (this->is_moust_male) {
1681 default: NOT_REACHED();
1682 case 0:
cmfv = this->is_female ? CMFV_HAS_TIE_EARRING : CMFV_HAS_MOUSTACHE;
break;
1683 case 1:
cmfv = CMFV_HAS_GLASSES;
break;
1689 default: NOT_REACHED();
1690 case 0:
cmfv = CMFV_EYE_COLOUR;
break;
1691 case 1:
cmfv = CMFV_CHIN;
break;
1692 case 2:
cmfv = CMFV_EYEBROWS;
break;
1693 case 3:
cmfv = this->is_moust_male ? CMFV_MOUSTACHE : CMFV_LIPS;
break;
1694 case 4:
cmfv = CMFV_NOSE;
break;
1695 case 5:
cmfv = CMFV_HAIR;
break;
1696 case 6:
cmfv = CMFV_JACKET;
break;
1697 case 7:
cmfv = CMFV_COLLAR;
break;
1698 case 8:
cmfv = CMFV_TIE_EARRING;
break;
1699 case 9:
cmfv = CMFV_GLASSES;
break;
1713 if (!str.has_value())
return;
1715 if (!str->empty()) {
1716 this->face = std::strtoul(str->c_str(),
nullptr, 10);
1748static constexpr NWidgetPart _nested_company_infrastructure_widgets[] = {
1797 this->UpdateRailRoadTypes();
1803 void UpdateRailRoadTypes()
1874 for (
const auto &
rt : _sorted_railtypes) {
1895 for (
const auto &
rt : _sorted_roadtypes) {
1925 Money max_cost = 10000;
1954 size.width = std::max(size.width,
this->total_width);
1960 size.width = std::max(size.width, count_width);
2005 for (
const auto &
rt : _sorted_railtypes) {
2021 for (
const auto &
rt : _sorted_railtypes) {
2037 for (
const auto &
rt : _sorted_roadtypes) {
2049 for (
const auto &
rt : _sorted_roadtypes) {
2100 this->UpdateRailRoadTypes();
2105static WindowDesc _company_infrastructure_desc(
2106 WDP_AUTO,
"company_infrastructure", 0, 0,
2109 _nested_company_infrastructure_widgets
2119 AllocateWindowDescFront<CompanyInfrastructureWindow>(_company_infrastructure_desc, company);
2122static constexpr NWidgetPart _nested_company_widgets[] = {
2200 STR_COMPANY_VIEW_TRAINS, STR_COMPANY_VIEW_ROAD_VEHICLES, STR_COMPANY_VIEW_SHIPS, STR_COMPANY_VIEW_AIRCRAFT
2275 d.width -= offset.x;
2276 d.height -= offset.y;
2301 size.width += padding.width;
2318 size.width += padding.width;
2323 void DrawVehicleCountsWidget(
const Rect &r,
const Company *c)
const
2343 void DrawInfrastructureCountsWidget(
const Rect &r,
const Company *c)
const
2402 d.height -= offset.y;
2403 DrawSprite(SPR_VEH_BUS_SW_VIEW, COMPANY_SPRITE_COLOUR(c->
index), r.left - offset.x,
CenterBounds(r.top, r.bottom,
d.height) - offset.y);
2408 DrawVehicleCountsWidget(r, c);
2412 DrawInfrastructureCountsWidget(r, c);
2447 if (
wid->UpdateVerticalSize(y)) this->
ReInit(0, 0);
2554 if (!str.has_value())
return;
2556 switch (this->query_widget) {
2557 default: NOT_REACHED();
2588 _nested_company_widgets
2599 AllocateWindowDescFront<CompanyWindow>(_company_desc, company);
2684 if (!this->hostile_takeover)
return;
2699static constexpr NWidgetPart _nested_buy_company_widgets[] = {
2722 _nested_buy_company_widgets
2733 if (window ==
nullptr) {
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.
debug_inline static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
constexpr T ToggleBit(T &x, const uint8_t y)
Toggles a bit in a variable.
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
Drop down icon component.
Colour selection list item, with icon and string components.
bool masked
Masked and unselectable item.
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.
An interval timer will fire every interval, and will continue to fire until it is deleted.
RailTypes introduces_railtypes
Bitmask of which other railtypes are introduced when this railtype is introduced.
StringID name
Name of this rail type.
RoadTypes introduces_roadtypes
Bitmask of which other roadtypes are introduced when this roadtype is introduced.
StringID name
Name of this rail type.
Management class for customizing the face of the company manager.
void SelectDisplayPlanes(bool advanced)
Select planes to display to the user with the NWID_SELECTION widgets WID_SCMF_SEL_LOADSAVE,...
bool is_female
Female face.
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.
bool advanced
advanced company manager face selection window
bool is_moust_male
Male face with a moustache.
GenderEthnicity ge
Gender and ethnicity.
void SetFaceStringParameters(WidgetID widget_index, uint8_t val, bool is_bool_widget) const
Set parameters for value of face control buttons.
Dimension yesno_dim
Dimension of a yes/no button of a part in the advanced face window.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
CompanyManagerFace face
company manager face bits
void OnQueryTextFinished(std::optional< std::string > str) override
The query window opened from this window has closed.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void SetStringParameters(WidgetID widget) const override
Initialize string parameters for a widget.
void OnInit() override
Notification that the nested widget tree gets initialized.
void OnPaint() override
The window must be repainted.
Dimension number_dim
Dimension of a number widget of a part in the advanced face window.
static constexpr TimerGame< struct Calendar >::Date MAX_DATE
The date of the last day of the max year.
static Year year
Current year, starting at 0.
static bool UsingWallclockUnits(bool newgame=false)
Check if we are using wallclock units.
Functions related to commands.
Definition of stuff that is very close to a company, like the company struct itself.
Money CalculateHostileTakeoverValue(const Company *c)
Calculate what you have to pay to take over a company.
Money CalculateCompanyValue(const Company *c, bool including_loan=true)
Calculate the value of the company.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
CompanyManagerFace _company_manager_face
for company manager face storage in openttd.cfg
Command definitions related to companies.
Functions related to companies.
void ShowCompanyFinances(CompanyID company)
Open the finances window of a company.
static Money DrawYearCategory(const Rect &r, int start_y, const ExpensesList &list, const Expenses &tbl)
Draw a category of expenses/revenues in the year column.
static uint GetMaxCategoriesWidth()
Get the required width of the "categories" column, equal to the widest element.
static void DrawYearColumn(const Rect &r, TimerGameEconomy::Year year, const Expenses &tbl)
Draw a column with prices.
static const std::initializer_list< ExpensesType > _expenses_list_capital_costs
List of capital expenses.
void ShowBuyCompanyDialog(CompanyID company, bool hostile_takeover)
Show the query to buy another company.
static const StringID _company_view_vehicle_count_strings[]
Strings for the company vehicle counts.
static const std::initializer_list< ExpensesList > _expenses_list_types
Types of expense lists.
static void DrawPrice(Money amount, int left, int right, int top, TextColour colour)
Draw an amount of money.
static WindowDesc _select_company_manager_face_desc(WDP_AUTO, nullptr, 0, 0, WC_COMPANY_MANAGER_FACE, WC_NONE, WDF_CONSTRUCTION, _nested_select_company_manager_face_widgets)
Company manager face selection window description.
static void ShowCompanyInfrastructure(CompanyID company)
Open the infrastructure window of a company.
static void DrawCategories(const Rect &r)
Draw the expenses categories.
static void DoSelectCompanyManagerFace(Window *parent)
Company GUI constants.
void ShowCompany(CompanyID company)
Show the window with the overview of the company.
static constexpr NWidgetPart _nested_select_company_manager_face_widgets[]
Nested widget description for the company manager face selection dialog.
static const std::initializer_list< ExpensesType > _expenses_list_operating_costs
List of operating expenses.
static uint GetTotalCategoriesHeight()
Get the total height of the "categories" column.
static const std::initializer_list< ExpensesType > _expenses_list_revenue
List of revenues.
void DirtyCompanyInfrastructureWindows(CompanyID company)
Redraw all windows with company infrastructure counts.
void DrawCompanyManagerFace(CompanyManagerFace cmf, Colours colour, const Rect &r)
Draws the face of a company manager's face.
static void DrawCategory(const Rect &r, int start_y, const ExpensesList &list)
Draw a category of expenses (revenue, operating expenses, capital expenses).
Functionality related to the company manager's face.
uint GetCompanyManagerFaceBits(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
Make sure the table's size is right.
GenderEthnicity
The gender/race combinations that we have faces for.
@ GE_WM
A male of Caucasian origin (white)
@ ETHNICITY_BLACK
This bit set means black, otherwise white.
@ GENDER_FEMALE
This bit set means a female, otherwise male.
void SetCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, uint val)
Sets the company manager's face bits for the given company manager's face variable.
void RandomCompanyManagerFaceBits(CompanyManagerFace &cmf, GenderEthnicity ge, bool adv, Randomizer &randomizer)
Make a random new face.
void ScaleAllCompanyManagerFaceBits(CompanyManagerFace &cmf)
Scales all company manager's face bits to the correct scope.
static const CompanyManagerFaceBitsInfo _cmf_info[]
Lookup table for indices into the CompanyManagerFace, valid ranges and sprites.
void IncreaseCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, int8_t amount)
Increase/Decrease the company manager's face variable by the given amount.
CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
SpriteID GetCompanyManagerFaceSprite(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
Gets the sprite to draw for the given company manager's face variable.
static const uint MAX_LENGTH_PRESIDENT_NAME_CHARS
The maximum length of a president name in characters including '\0'.
static const uint MAX_LENGTH_COMPANY_NAME_CHARS
The maximum length of a company name in characters including '\0'.
uint32_t CompanyManagerFace
Company manager face bits, info see in company_manager_face.h.
Owner
Enum for all companies/owners.
@ COMPANY_SPECTATOR
The client is spectating.
Functions to handle different currencies.
const CurrencySpec & GetCurrency()
Get the currently selected currency.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close, bool persist)
Show a drop down list.
Common drop down list components.
Types related to the drop down widget.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
Command definitions related to the economy.
std::array< Money, EXPENSES_END > Expenses
Data type for storage of Money for each ExpensesType category.
ExpensesType
Types of expenses.
@ EXPENSES_ROADVEH_RUN
Running costs road vehicles.
@ EXPENSES_TRAIN_RUN
Running costs trains.
@ EXPENSES_AIRCRAFT_REVENUE
Revenue from aircraft.
@ EXPENSES_CONSTRUCTION
Construction costs.
@ EXPENSES_AIRCRAFT_RUN
Running costs aircraft.
@ EXPENSES_ROADVEH_REVENUE
Revenue from road vehicles.
@ EXPENSES_PROPERTY
Property costs.
@ EXPENSES_OTHER
Other expenses.
@ EXPENSES_SHIP_REVENUE
Revenue from ships.
@ EXPENSES_LOAN_INTEREST
Interest payments over the loan.
@ EXPENSES_TRAIN_REVENUE
Revenue from trains.
@ EXPENSES_SHIP_RUN
Running costs ships.
@ EXPENSES_NEW_VEHICLES
New vehicles.
static const int LOAN_INTERVAL
The "steps" in loan size, in British Pounds!
Functions related to errors.
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
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.
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
bool _shift_pressed
Is Shift pressed?
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.
bool _ctrl_pressed
Is Ctrl pressed?
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.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
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.
Dimension GetScaledSpriteSize(SpriteID sprid)
Scale sprite size for GUI.
int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
@ SA_TOP
Top align the text.
@ 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.
@ SA_VERT_CENTER
Vertically center the text.
@ FS_NORMAL
Index of the normal font in the font tables.
uint32_t PaletteID
The number of the palette.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Command definitions related to engine groups.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
void BuildGuiGroupList(GUIGroupList &dst, bool fold, Owner owner, VehicleType veh_type)
Build GUI group list, a sorted hierarchical list of groups for owner and vehicle type.
Functions/definitions that have something to do with groups.
uint16_t GroupID
Type for all group identifiers.
static const GroupID INVALID_GROUP
Sentinel for invalid groups.
GUI functions that shouldn't be here.
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
static const uint8_t LIT_ALL
Show the liveries of all companies.
LiveryScheme
List of different livery schemes.
static const uint8_t LIT_COMPANY
Show the liveries of your own company.
LiveryClass
List of different livery classes, used only by the livery GUI.
Miscellaneous command definitions.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
bool _networking
are we in networking mode?
bool _network_server
network-server is active
bool NetworkCanJoinCompany(CompanyID company_id)
Returns whether the given company can be joined by this client.
Basic functions/variables used all over the place.
void NetworkClientRequestMove(CompanyID company_id)
Notify the server of this client wanting to be moved to another company.
Network functions used by other parts of OpenTTD.
void NetworkServerDoMove(ClientID client_id, CompanyID company_id)
Handle the tid-bits of moving a client from one company to another.
GUIs related to networking.
@ CLIENT_ID_SERVER
Servers always have this ID.
GRFLoadedFeatures _loaded_newgrf_features
Indicates which are the newgrf features currently loaded ingame.
Base for the NewGRF implementation.
Command definitions related to objects.
Types related to object tiles.
static const ObjectType OBJECT_HQ
HeadQuarter of a player.
static const uint8_t PC_WHITE
White palette colour.
static const uint8_t PC_BLACK
Black palette colour.
RailTypes AddDateIntroducedRailTypes(RailTypes current, TimerGameCalendar::Date date)
Add the rail types that are to be introduced at the given date.
Money RailMaintenanceCost(RailType railtype, uint32_t num, uint32_t total_num)
Calculates the maintenance cost of a number of track bits.
Money SignalMaintenanceCost(uint32_t num)
Calculates the maintenance cost of a number of signals.
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
RailTypes
Allow incrementing of Track variables.
@ RAILTYPES_NONE
No rail types.
RailType
Enumeration for all possible railtypes.
@ RAILTYPE_BEGIN
Used for iterations.
@ RAILTYPE_END
Used for iterations.
Randomizer _interactive_random
Random used everywhere else, where it does not (directly) influence the game state.
RoadTypes AddDateIntroducedRoadTypes(RoadTypes current, TimerGameCalendar::Date date)
Add the road types that are to be introduced at the given date.
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
Functions related to roads.
Money RoadMaintenanceCost(RoadType roadtype, uint32_t num, uint32_t total_num)
Calculates the maintenance cost of a number of road bits.
RoadTypes
The different roadtypes we support, but then a bitmask of them.
@ ROADTYPES_NONE
No roadtypes.
RoadType
The different roadtypes we support.
@ ROADTYPE_END
Used for iterations.
@ ROADTYPE_BEGIN
Used for iterations.
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
ClientSettings _settings_client
The current settings for this game.
Base types for having sorted lists in GUIs.
Money AirportMaintenanceCost(Owner owner)
Calculates the maintenance cost of all airports of a company.
Functions related to stations.
Money StationMaintenanceCost(uint32_t num)
Calculates the maintenance cost of a number of station tiles.
Definition of base types and functions in a cross-platform compatible way.
#define lengthof(array)
Return the length of an fixed size array.
@ CS_NUMERAL
Only numeric ones.
@ CS_ALPHANUMERAL
Both numeric and alphabetic and spaces and stuff.
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.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
Money company_value
The value of the company for which the user can buy it.
IntervalTimer< TimerWindow > rescale_interval
Check on a regular interval if the company value has changed.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
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.
bool hostile_takeover
Whether the window is showing a hostile takeover.
void SetStringParameters(WidgetID widget) const override
Initialize string parameters for a widget.
GUISettings gui
settings related to the GUI
Window class displaying the company finances.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
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 OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void OnInvalidateData(int, bool) override
Some data on this window has become invalid.
bool small
Window is toggled to 'small'.
static Money max_money
The maximum amount of money a company has had this 'run'.
uint8_t first_visible
First visible expenses column. The last column (current) is always visible.
void SetupWidgets()
Setup the widgets in the nested tree, such that the finances window is displayed properly.
IntervalTimer< TimerWindow > rescale_interval
Check on a regular interval if the maximum amount of money has changed.
void OnPaint() override
The window must be repainted.
void SetStringParameters(WidgetID widget) const override
Initialize string parameters for a widget.
Window with detailed information about the company's infrastructure.
Money GetTotalMaintenanceCost() const
Get total infrastructure maintenance cost.
void DrawCountLine(const Rect &r, int &y, int count, Money monthly_cost) const
Helper for drawing the counts line.
RoadTypes roadtypes
Valid roadtypes.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
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.
uint total_width
String width of the total cost line.
RailTypes railtypes
Valid railtypes.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void SetStringParameters(WidgetID widget) const override
Initialize string parameters for a widget.
std::array< uint32_t, ROADTYPE_END > road
Count of company owned track bits for each road type.
uint32_t GetRailTotal() const
Get total sum of all owned track bits.
uint32_t GetRoadTotal() const
Get total sum of all owned road bits.
uint32_t station
Count of company owned station tiles.
uint32_t signal
Count of company owned signals.
std::array< uint32_t, RAILTYPE_END > rail
Count of company owned track bits for each rail type.
uint32_t GetTramTotal() const
Get total sum of all owned tram bits.
uint32_t airport
Count of company owned airports.
uint32_t water
Count of company owned track bits for canals.
uint8_t valid_values[GE_END]
The number of valid values per gender/ethnicity.
TileIndex location_of_HQ
Northern tile of HQ; INVALID_TILE when there is none.
bool is_ai
If true, the company is (also) controlled by the computer (a NoAI program).
Money current_loan
Amount of money borrowed from the bank.
Colours colour
Company colour.
CompanyManagerFace face
Face description of the president.
std::array< Expenses, 3 > yearly_expenses
Expenses of the company for the last three years.
Money money
Money owned by the company.
Window with general information about a company.
void OnResize() override
Called after the window got resized.
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.
IntervalTimer< TimerWindow > redraw_interval
Redraw the window 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.
CompanyWindowPlanes
Display planes in the company window.
@ CWP_RELOCATE_SHOW
Show the relocate HQ button.
@ CWP_RELOCATE_HIDE
Hide the relocate HQ button.
@ CWP_VB_BUILD
Display the build button.
@ CWP_VB_VIEW
Display the view button.
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
void SetStringParameters(WidgetID widget) const override
Initialize string parameters for a widget.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void OnQueryTextFinished(std::optional< std::string > str) override
The query window opened from this window has closed.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void OnPaint() override
The window must be repainted.
Money GetMaxLoan() const
Calculate the max allowed loan for this company.
CompanyInfrastructure infrastructure
NOSAVE: Counts of company owned infrastructure.
GroupStatistics group_all[VEH_COMPANY_END]
NOSAVE: Statistics for the ALL_GROUP group.
uint16_t rate
The conversion rate compared to the base currency.
uint8_t initial_interest
amount of interest (to pay over the loan)
Dimensions (a width and height) of a rectangle in 2D.
bool infrastructure_maintenance
enable monthly maintenance fee for owner infrastructure
bool give_money
allow giving other companies money
uint GetListWidth() const
Compute width of the expenses categories in pixels.
const std::initializer_list< ExpensesType > & items
List of expenses types.
const StringID title
StringID of list title.
bool has_2CC
Set if any vehicle is loaded which uses 2cc (two company colours).
uint64_t used_liveries
Bitmask of LiveryScheme used by the defined engines.
uint8_t liveries
options for displaying company liveries, 0=none, 1=self, 2=all
uint8_t landscape
the landscape we're currently in
EconomySettings economy
settings to change the economy
DifficultySettings difficulty
settings related to the difficulty
GameCreationSettings game_creation
settings used during the creation of a game (map)
uint16_t num_vehicle
Number of vehicles.
Livery livery
Custom colour scheme for vehicles in this group.
GroupID parent
Parent group.
VehicleType vehicle_type
Vehicle type of the group.
Information about a particular livery.
Colours colour2
Second colour, for vehicles with 2CC support.
Colours colour1
First colour, for all vehicles.
uint8_t in_use
Bit 0 set if this livery should override the default livery first colour, Bit 1 for the second colour...
Coordinates of a point in 2D.
Tindex index
Index of this pool item.
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 * 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.
uint step_height
Step-size of height resize changes.
Company livery colour scheme window.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void OnDropdownSelect(WidgetID widget, int index) override
A dropdown option associated to this window has been selected.
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 DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void SetStringParameters(WidgetID widget) const override
Initialize string parameters for a widget.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void OnResize() override
Called after the window got resized.
High level window description.
Data structure for an opened window.
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void DrawWidgets() const
Paint all widgets of a window.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Window * parent
Parent window.
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
ResizeInfo resize
Resize information.
void SetShaded(bool make_shaded)
Set the shaded state of the window to make_shaded.
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
void SetWidgetsLoweredState(bool lowered_stat, Args... widgets)
Sets the lowered/raised status of a list of widgets.
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
void EnableWidget(WidgetID widget_index)
Sets a widget to Enabled.
bool IsShaded() const
Is window shaded currently?
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 width
width of the window (number of pixels to the right in x direction)
WindowNumber window_number
Window number within the window class.
Stuff related to the text buffer GUI.
@ QSF_ENABLE_DEFAULT
enable the 'Default' button ("\0" is returned)
@ QSF_LEN_IN_CHARS
the length of the string is counted in characters
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Functions related to tile highlights.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
void SetObjectToPlaceWnd(CursorID icon, PaletteID pal, HighLightStyle mode, Window *w)
Change the cursor and mouse click/drag handling to a mode for performing special operations like tile...
@ HT_RECT
rectangle (stations, depots, ...)
Definition of Interval and OneShot timers.
Definition of the game-economy-timer.
Definition of the Window system.
VehicleType
Available vehicle types.
@ VEH_ROAD
Road vehicle type.
@ VEH_AIRCRAFT
Aircraft vehicle type.
@ VEH_SHIP
Ship vehicle type.
@ VEH_TRAIN
Train vehicle type.
@ VEH_COMPANY_END
Last company-ownable type.
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
Functions related to (drawing on) viewports.
Functions related to water (management)
Money CanalMaintenanceCost(uint32_t num)
Calculates the maintenance cost of a number of canal tiles.
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
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.
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
@ WDP_AUTO
Find a place automatically.
int32_t WindowNumber
Number to differentiate different windows of the same class.
@ WC_BUY_COMPANY
Buyout company (merger); Window numbers:
@ WC_COMPANY_INFRASTRUCTURE
Company infrastructure overview; Window numbers:
@ WC_COMPANY_COLOUR
Company colour selection; Window numbers:
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ WC_FINANCES
Finances of a company; Window numbers:
@ WC_COMPANY_MANAGER_FACE
Alter company face window; Window numbers:
@ WC_COMPANY
Company view; Window numbers:
Functions related to zooming.