Go to the documentation of this file.
89 uint GetHeight()
const
99 for (uint i = 0; i < this->
length; i++) {
163 for (uint i = 0; i < list.
length; i++) {
165 DrawString(tr, STR_FINANCES_SECTION_CONSTRUCTION + et);
182 DrawString(r.left, r.right, y, (STR_FINANCES_REVENUE_TITLE + i), TC_FROMSTRING,
SA_LEFT);
215 StringID str = STR_FINANCES_NEGATIVE_INCOME;
217 str = STR_FINANCES_ZERO_INCOME;
218 }
else if (amount < 0) {
220 str = STR_FINANCES_POSITIVE_INCOME;
236 for (uint i = 0; i < list.
length; i++) {
238 Money cost = (*tbl)[et];
240 if (cost != 0)
DrawPrice(cost, r.left, r.right, y, TC_BLACK);
247 if (sum != 0)
DrawPrice(sum, r.left, r.right, y, TC_WHITE);
282 DrawPrice(sum, r.left, r.right, y, TC_WHITE);
285 static const NWidgetPart _nested_company_finances_widgets[] = {
437 if (wid_offset <= age) {
456 this->GetWidget<NWidgetStacked>(
WID_CF_SEL_PANEL)->SetDisplayedPlane(plane);
497 this->small = !this->
small;
540 _nested_company_finances_widgets,
lengthof(_nested_company_finances_widgets)
557 static const StringID _colour_dropdown[] = {
558 STR_COLOUR_DARK_BLUE,
559 STR_COLOUR_PALE_GREEN,
563 STR_COLOUR_LIGHT_BLUE,
565 STR_COLOUR_DARK_GREEN,
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,
592 return this->result >= COLOUR_END ? STR_COLOUR_DEFAULT : _colour_dropdown[this->
result];
595 uint Height(uint width)
const override
600 bool Selectable()
const override
605 void Draw(
const Rect &r,
bool sel, Colours bg_colour)
const override
615 DrawString(tr.left, tr.right, text_y, this->String(), sel ? TC_WHITE : TC_BLACK);
630 std::vector<int> indents;
633 void ShowColourDropDownMenu(uint32 widget)
635 uint32 used_colours = 0;
637 const Livery *livery, *default_livery =
nullptr;
642 if (this->livery_class < LC_GROUP_RAIL &&
HasBit(this->sel, LS_DEFAULT) && primary) {
650 if (this->livery_class < LC_GROUP_RAIL) {
653 for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
654 if (
HasBit(this->sel, scheme))
break;
656 if (scheme == LS_END) scheme = LS_DEFAULT;
657 livery = &c->livery[scheme];
658 if (scheme != LS_DEFAULT) default_livery = &c->livery[LS_DEFAULT];
663 default_livery = &c->livery[LS_DEFAULT];
666 default_livery = &pg->
livery;
671 if (default_livery !=
nullptr) {
673 default_col = (primary ? default_livery->
colour1 : default_livery->
colour2) + COLOUR_END;
676 for (uint i = 0; i <
lengthof(_colour_dropdown); i++) {
680 byte sel = (default_livery ==
nullptr ||
HasBit(livery->
in_use, primary ? 0 : 1)) ? (primary ? livery->
colour1 : livery->
colour2) : default_col;
686 for (
const Group *g : *source) {
687 if (g->parent !=
parent)
continue;
688 this->groups.push_back(g);
689 this->indents.push_back(indent);
690 AddChildren(source, g->index, indent + 1);
698 this->groups.clear();
699 this->indents.clear();
701 if (this->livery_class >= LC_GROUP_RAIL) {
706 if (g->owner ==
owner && g->vehicle_type == vtype) {
714 const Group *last_group[2] = {
nullptr,
nullptr };
715 char last_name[2][64] = {
"",
"" };
716 list.
Sort([&](
const Group *
const &a,
const Group *
const &b) ->
bool {
717 if (a != last_group[0]) {
720 GetString(last_name[0], STR_GROUP_NAME,
lastof(last_name[0]));
723 if (b != last_group[1]) {
726 GetString(last_name[1], STR_GROUP_NAME,
lastof(last_name[1]));
729 int r =
strnatcmp(last_name[0], last_name[1]);
737 this->groups.shrink_to_fit();
743 if (this->livery_class < LC_GROUP_RAIL) {
745 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
751 this->rows = (uint)this->groups.size();
754 this->vscroll->
SetCount(this->rows);
764 this->livery_class = LC_OTHER;
767 this->BuildGroupList(company);
770 this->SetSelectedGroup(company, group);
774 this->owner = company;
783 case VEH_TRAIN: this->livery_class = LC_GROUP_RAIL;
break;
784 case VEH_ROAD: this->livery_class = LC_GROUP_ROAD;
break;
785 case VEH_SHIP: this->livery_class = LC_GROUP_SHIP;
break;
786 case VEH_AIRCRAFT: this->livery_class = LC_GROUP_AIRCRAFT;
break;
787 default: NOT_REACHED();
793 this->BuildGroupList(company);
797 for (uint i = 0; i < this->rows; i++) {
798 if (this->groups[i]->index == sel) {
811 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
817 if (g->owner == (
CompanyID)this->window_number) {
823 size->width = std::max(size->width, 5 + d.width + padding.width);
830 this->line_height = std::max(this->square.height, (uint)
FONT_HEIGHT_NORMAL) + padding.height;
832 size->height = 11 * this->line_height;
834 resize->height = this->line_height;
848 for (
const StringID *
id = _colour_dropdown;
id !=
endof(_colour_dropdown);
id++) {
862 bool disabled = this->livery_class < LC_GROUP_RAIL ? (this->sel == 0) : (this->sel ==
INVALID_GROUP);
882 StringID colour = STR_COLOUR_DEFAULT;
884 if (this->livery_class < LC_GROUP_RAIL) {
885 if (this->sel != 0) {
887 for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
888 if (
HasBit(this->sel, scheme))
break;
890 if (scheme == LS_END) scheme = LS_DEFAULT;
891 const Livery *livery = &c->livery[scheme];
892 if (scheme == LS_DEFAULT ||
HasBit(livery->
in_use, primary ? 0 : 1)) {
893 colour = STR_COLOUR_DARK_BLUE + (primary ? livery->
colour1 : livery->
colour2);
901 colour = STR_COLOUR_DARK_BLUE + (primary ? livery->
colour1 : livery->
colour2);
934 int square_offs = (ir.
Height() - this->square.height) / 2;
940 auto draw_livery = [&](
StringID str,
const Livery &liv,
bool sel,
bool def,
int indent) {
942 DrawString(sch.left + (rtl ? 0 : indent), sch.right - (rtl ? indent : 0), y + text_offs, str, sel ? TC_WHITE : TC_BLACK);
945 DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOUR(liv.colour1), pri_squ.left, y + square_offs);
946 DrawString(pri.left, pri.right, y + text_offs, (def ||
HasBit(liv.in_use, 0)) ? STR_COLOUR_DARK_BLUE + liv.colour1 : STR_COLOUR_DEFAULT, sel ? TC_WHITE : TC_GOLD);
949 if (sec.right > sec.left) {
950 DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOUR(liv.colour2), sec_squ.left, y + square_offs);
951 DrawString(sec.left, sec.right, y + text_offs, (def ||
HasBit(liv.in_use, 1)) ? STR_COLOUR_DARK_BLUE + liv.colour2 : STR_COLOUR_DEFAULT, sel ? TC_WHITE : TC_GOLD);
954 y += this->line_height;
957 if (livery_class < LC_GROUP_RAIL) {
960 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
962 if (pos-- > 0)
continue;
963 draw_livery(STR_LIVERY_DEFAULT + scheme, c->livery[scheme],
HasBit(this->sel, scheme), scheme == LS_DEFAULT, 0);
967 uint max =
static_cast<uint
>(std::min<size_t>(this->vscroll->
GetPosition() + this->vscroll->GetCapacity(), this->groups.size()));
968 for (uint i = this->vscroll->
GetPosition(); i < max; ++i) {
969 const Group *g = this->groups[i];
994 if (this->livery_class < LC_GROUP_RAIL) {
996 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
998 this->sel = 1 << scheme;
1007 if (this->groups.size() > 0) {
1008 this->sel = this->groups[0]->index;
1026 if (row >= this->rows)
return;
1028 if (this->livery_class < LC_GROUP_RAIL) {
1031 for (
LiveryScheme scheme = LS_BEGIN; scheme <= j && scheme < LS_END; scheme++) {
1042 this->sel = this->groups[row]->index;
1060 if (index >= COLOUR_END) index = INVALID_COLOUR;
1062 if (this->livery_class < LC_GROUP_RAIL) {
1064 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
1083 if (!gui_scope)
return;
1087 if (this->livery_class == data + LC_GROUP_RAIL) {
1094 if (this->groups.size() > 0) this->sel = this->groups[0]->index;
1104 bool current_class_valid = this->livery_class == LC_OTHER || this->livery_class >= LC_GROUP_RAIL;
1106 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
1108 if (_livery_class[scheme] == this->livery_class) current_class_valid =
true;
1110 }
else if (this->livery_class < LC_GROUP_RAIL) {
1111 ClrBit(this->sel, scheme);
1116 if (!current_class_valid) {
1123 static const NWidgetPart _nested_select_company_livery_widgets [] = {
1144 SetDataTip(STR_BLACK_STRING, STR_LIVERY_SECONDARY_TOOLTIP),
1147 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),
1155 static WindowDesc _select_company_livery_desc(
1159 _nested_select_company_livery_widgets,
lengthof(_nested_select_company_livery_widgets)
1168 w->SetSelectedGroup(company, group);
1189 if (
_cmf_info[CMFV_EYE_COLOUR].valid_values[ge] < 2) {
1193 default: NOT_REACHED();
1194 case 0: pal = PALETTE_TO_BROWN;
break;
1195 case 1: pal = PALETTE_TO_BLUE;
break;
1196 case 2: pal = PALETTE_TO_GREEN;
break;
1201 DrawSprite(SPR_GRADIENT, GENERAL_SPRITE_COLOUR(colour), x, y);
1203 for (CompanyManagerFaceVariable cmfv = CMFV_CHEEKS; cmfv < CMFV_END; cmfv++) {
1205 case CMFV_MOUSTACHE:
if (!has_moustache)
continue;
break;
1207 case CMFV_NOSE:
if (has_moustache)
continue;
break;
1208 case CMFV_TIE_EARRING:
if (!has_tie_earring)
continue;
break;
1209 case CMFV_GLASSES:
if (!has_glasses)
continue;
break;
1384 const NWidgetCore *nwi_widget = this->GetWidget<NWidgetCore>(widget_index);
1388 if (is_bool_widget) {
1390 SetDParam(0, (val != 0) ? STR_FACE_YES : STR_FACE_NO);
1406 this->GetWidget<NWidgetCore>(
WID_SCMF_TIE_EARRING_TEXT)->widget_data = this->is_female ? STR_FACE_EARRING : STR_FACE_TIE;
1413 this->advanced =
false;
1437 wi->
SetDataTip(STR_FACE_SIMPLE, STR_FACE_SIMPLE_TOOLTIP);
1439 wi->
SetDataTip(STR_FACE_ADVANCED, STR_FACE_ADVANCED_TOOLTIP);
1451 for (
int val = 1; val <= 12; val++) {
1486 size->width = std::max(size->width, face_size.width);
1487 size->height = std::max(size->height, face_size.height);
1576 if (this->is_female) {
1588 if (this->is_moust_male) {
1717 CompanyManagerFaceVariable cmfv;
1721 default: NOT_REACHED();
1722 case 0: cmfv = this->is_female ? CMFV_HAS_TIE_EARRING : CMFV_HAS_MOUSTACHE;
break;
1723 case 1: cmfv = CMFV_HAS_GLASSES;
break;
1729 default: NOT_REACHED();
1730 case 0: cmfv = CMFV_EYE_COLOUR;
break;
1731 case 1: cmfv = CMFV_CHIN;
break;
1732 case 2: cmfv = CMFV_EYEBROWS;
break;
1733 case 3: cmfv = this->is_moust_male ? CMFV_MOUSTACHE : CMFV_LIPS;
break;
1734 case 4: cmfv = CMFV_NOSE;
break;
1735 case 5: cmfv = CMFV_HAIR;
break;
1736 case 6: cmfv = CMFV_JACKET;
break;
1737 case 7: cmfv = CMFV_COLLAR;
break;
1738 case 8: cmfv = CMFV_TIE_EARRING;
break;
1739 case 9: cmfv = CMFV_GLASSES;
break;
1753 if (str ==
nullptr)
return;
1756 this->face = strtoul(str,
nullptr, 10);
1788 static const NWidgetPart _nested_company_infrastructure_widgets[] = {
1837 this->UpdateRailRoadTypes();
1843 void UpdateRailRoadTypes()
1867 this->roadtypes &= ~_roadtypes_hidden_mask;
1912 size->width = std::max(size->width,
GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_RAIL_SECT).
width + padding.width);
1914 for (
const auto &rt : _sorted_railtypes) {
1915 if (
HasBit(this->railtypes, rt)) {
1936 for (
const auto &rt : _sorted_roadtypes) {
1949 size->width = std::max(size->width,
GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_WATER_SECT).
width + padding.width);
1954 size->width = std::max(size->width,
GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_STATION_SECT).
width + padding.width);
1966 uint32 max_val = 1000;
1967 Money max_cost = 10000;
1995 size->width = std::max(size->width, this->total_width);
2001 size->width = std::max(size->width, count_width);
2027 DrawString(tr.left, tr.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL, TC_FROMSTRING,
SA_RIGHT);
2040 DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_RAIL_SECT);
2044 for (
const auto &rt : _sorted_railtypes) {
2045 if (
HasBit(this->railtypes, rt)) {
2061 for (
const auto &rt : _sorted_railtypes) {
2062 if (
HasBit(this->railtypes, rt)) {
2074 DrawString(r.left, r.right, y, widget ==
WID_CI_ROAD_DESC ? STR_COMPANY_INFRASTRUCTURE_VIEW_ROAD_SECT : STR_COMPANY_INFRASTRUCTURE_VIEW_TRAM_SECT);
2077 for (
const auto &rt : _sorted_roadtypes) {
2090 for (
const auto &rt : _sorted_roadtypes) {
2099 DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_WATER_SECT);
2113 DrawString(tr.left, tr.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL, TC_FROMSTRING,
SA_RIGHT);
2118 DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_STATION_SECT);
2137 if (!gui_scope)
return;
2139 this->UpdateRailRoadTypes();
2144 static WindowDesc _company_infrastructure_desc(
2145 WDP_AUTO,
"company_infrastructure", 0, 0,
2148 _nested_company_infrastructure_widgets,
lengthof(_nested_company_infrastructure_widgets)
2158 AllocateWindowDescFront<CompanyInfrastructureWindow>(&_company_infrastructure_desc, company);
2161 static const NWidgetPart _nested_company_widgets[] = {
2263 auto share_owned_by = [owner](
auto share_owner) {
return share_owner == owner; };
2269 STR_COMPANY_VIEW_TRAINS, STR_COMPANY_VIEW_ROAD_VEHICLES, STR_COMPANY_VIEW_SHIPS, STR_COMPANY_VIEW_AIRCRAFT
2311 bool reinit =
false;
2380 size->width = std::max(size->width, face_size.width);
2381 size->height = std::max(size->height, face_size.height);
2388 d.width -= offset.x;
2389 d.height -= offset.y;
2390 *size =
maxdim(*size, d);
2414 size->width += padding.width;
2441 size->width += padding.width;
2466 d.height -= offset.y;
2467 DrawSprite(SPR_VEH_BUS_SW_VIEW, COMPANY_SPRITE_COLOUR(c->
index), r.left - offset.x,
CenterBounds(r.top, r.bottom, d.height) - offset.y);
2479 if (amounts[0] + amounts[1] + amounts[2] + amounts[3] == 0) {
2480 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_VEHICLES_NONE);
2484 for (uint i = 0; i <
lengthof(amounts); i++) {
2485 if (amounts[i] != 0) {
2500 uint road_pieces = 0;
2505 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_NONE);
2507 if (rail_pieces != 0) {
2509 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_RAIL);
2512 if (road_pieces != 0) {
2514 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_ROAD);
2519 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_WATER);
2524 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_STATION);
2529 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_AIRPORT);
2540 uint amt = GetAmountOwnedBy(c, c2->
index);
2545 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_SHARES_OWNED_BY);
2554 DrawSprite(SPR_LOCK, PAL_NONE, r.left, r.top);
2652 if (this->window_number ==
_local_company) ShowNetworkCompanyPasswordWindow(
this);
2694 if (str ==
nullptr)
return;
2696 switch (this->query_widget) {
2697 default: NOT_REACHED();
2700 Money money = (
Money)(strtoull(str,
nullptr, 10) / _currency->rate);
2756 _nested_company_widgets,
lengthof(_nested_company_widgets)
2767 AllocateWindowDescFront<CompanyWindow>(&_company_desc, company);
2845 static const NWidgetPart _nested_buy_company_widgets[] = {
2868 _nested_buy_company_widgets,
lengthof(_nested_buy_company_widgets)
2877 AllocateWindowDescFront<BuyCompanyWindow>(&_buy_company_desc, company);
@ VEH_AIRCRAFT
Aircraft vehicle type.
bool give_money
allow giving other companies money
static const uint8 PC_WHITE
White palette colour.
GenderEthnicity ge
Gender and ethnicity.
static void DrawYearColumn(const Rect &r, int year, const Money(*tbl)[EXPENSES_END])
Draw a column with prices.
RailTypes AddDateIntroducedRailTypes(RailTypes current, Date date)
Add the rail types that are to be introduced at the given date.
void OnPaint() override
The window must be repainted.
uint GetListWidth() const
Compute width of the expenses categories in pixels.
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
static const ExpensesList _expenses_list_types[]
Types of expense lists.
bool is_ai
If true, the company is (also) controlled by the computer (a NoAI program).
@ CWP_RELOCATE_SHOW
Show the relocate HQ button.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
static int32 ClampToI32(const int64 a)
Reduce a signed 64-bit int to a signed 32-bit one.
@ CWP_BUTTONS_LOCAL
Buttons of the local company.
@ EXPENSES_ROADVEH_RUN
Running costs road vehicles.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
@ ROADTYPE_END
Used for iterations.
static Pool::IterateWrapperFiltered< Engine, EngineTypeFilter > IterateType(VehicleType vt, size_t from=0)
Returns an iterable ensemble of all valid engines of the given type.
int Height() const
Get height of Rect.
static Titem * Get(size_t index)
Returns Titem with given index.
int result
Result code to return to window on selection.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
static void DrawCategory(const Rect &r, int start_y, ExpensesList list)
Draw a category of expenses (revenue, operating expenses, capital expenses).
@ EXPENSES_END
Number of expense types.
static Money SignalMaintenanceCost(uint32 num)
Calculates the maintenance cost of a number of signals.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
bool allow_shares
allow the buying/selling of shares
GroupStatistics group_all[VEH_COMPANY_END]
NOSAVE: Statistics for the ALL_GROUP group.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
@ QSF_PASSWORD
password entry box, show warning about password security
Dimensions (a width and height) of a rectangle in 2D.
bool Sort(Comp compare)
Sort the list.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
@ CWP_MP_C_JOIN
Display the join company button.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
bool advanced
advanced company manager face selection window
byte landscape
the landscape we're currently in
uint32 CompanyManagerFace
Company manager face bits, info see in company_manager_face.h.
RoadTypes introduces_roadtypes
Bitmask of which other roadtypes are introduced when this roadtype is introduced.
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Year _cur_year
Current year, starting at 0.
@ EXPENSES_OTHER
Other expenses.
void SetupWidgets()
Setup the widgets in the nested tree, such that the finances window is displayed properly.
static const int LOAN_INTERVAL
The "steps" in loan size, in British Pounds!
@ WC_COMPANY_COLOUR
Company colour selection; Window numbers:
Year inaugurated_year
Year of starting the company.
void OnResize() override
Called after the window got resized.
void NetworkClientRequestMove(CompanyID company_id, const std::string &pass)
Notify the server of this client wanting to be moved to another company.
bool _network_server
network-server is active
@ EXPENSES_TRAIN_REVENUE
Revenue from trains.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
static SpriteID GetCompanyManagerFaceSprite(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
Gets the sprite to draw for the given company manager's face variable.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
CompanyManagerFace face
company manager face bits
GroupID parent
Parent group.
GenderEthnicity
The gender/race combinations that we have faces for.
uint32 water
Count of company owned track bits for canals.
Tindex index
Index of this pool item.
@ WC_COMPANY_MANAGER_FACE
Alter company face window; Window numbers:
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
static void DrawPrice(Money amount, int left, int right, int top, TextColour colour)
Draw an amount of money.
DifficultySettings difficulty
settings related to the difficulty
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
static constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
uint32 station
Count of company owned station tiles.
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
void NetworkServerDoMove(ClientID client_id, CompanyID company_id)
Handle the tid-bits of moving a client from one company to another.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
bool _ctrl_pressed
Is Ctrl pressed?
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
@ EXPENSES_AIRCRAFT_RUN
Running costs aircraft.
Livery livery
Custom colour scheme for vehicles in this group.
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Money max_loan
NOSAVE: Maximum possible loan.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Base list item class from which others are derived.
Company livery colour scheme window.
ClientSettings _settings_client
The current settings for this game.
LiveryScheme
List of different livery schemes.
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.
RoadTypes AddDateIntroducedRoadTypes(RoadTypes current, Date date)
Add the road types that are to be introduced at the given date.
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
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.
CompanyInfrastructure infrastructure
NOSAVE: Counts of company owned infrastructure.
int32 WindowNumber
Number to differentiate different windows of the same class.
@ WC_COMPANY
Company view; Window numbers:
CompanyManagerFace face
Face description of the president.
uint64 used_liveries
Bitmask of LiveryScheme used by the defined engines.
@ SA_RIGHT
Right align the text (must be a single bit).
@ SA_VERT_CENTER
Vertically center the text.
#define MAX_DAY
The number of days till the last day.
@ VEH_ROAD
Road vehicle type.
@ RAILTYPES_NONE
No rail types.
Owner
Enum for all companies/owners.
Money CalculateCompanyValue(const Company *c, bool including_loan=true)
Calculate the value of the company.
VehicleType vehicle_type
Vehicle type of the group.
Management class for customizing the face of the company manager.
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...
byte initial_interest
amount of interest (to pay over the loan)
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Money current_loan
Amount of money borrowed from the bank.
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
uint32 GetRoadTotal() const
Get total sum of all owned road bits.
uint16 num_vehicle
Number of vehicles.
@ CWP_MP_C_PWD
Display the company password button.
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=nullptr, uint textref_stack_size=0, const uint32 *textref_stack=nullptr)
Display an error message in a window.
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.
GameCreationSettings game_creation
settings used during the creation of a game (map)
@ QSF_LEN_IN_CHARS
the length of the string is counted in characters
static const uint MAX_LENGTH_COMPANY_NAME_CHARS
The maximum length of a company name in characters including '\0'.
@ GENDER_FEMALE
This bit set means a female, otherwise male.
static uint GetCompanyManagerFaceBits(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
Make sure the table's size is right.
High level window description.
StringID name
Name of this rail type.
void OnPaint() override
The window must be repainted.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
static const NWidgetPart _nested_select_company_manager_face_widgets[]
Nested widget description for the company manager face selection dialog.
void SetShaded(bool make_shaded)
Set the shaded state of the window to make_shaded.
void ShowCompanyFinances(CompanyID company)
Open the finances window of a company.
uint total_width
String width of the total cost line.
bool has_2CC
Set if any vehicle is loaded which uses 2cc (two company colours).
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.
uint32 GetTramTotal() const
Get total sum of all owned tram bits.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
@ WDP_AUTO
Find a place automatically.
static const GroupID INVALID_GROUP
Sentinel for invalid groups.
@ EXPENSES_CONSTRUCTION
Construction costs.
byte colour
Company colour.
RailType
Enumeration for all possible railtypes.
ResizeInfo resize
Resize information.
static void DrawCategories(const Rect &r)
Draw the expenses categories.
static const uint MAX_LENGTH_PRESIDENT_NAME_CHARS
The maximum length of a president name in characters including '\0'.
@ WC_BUY_COMPANY
Buyout company (merger); Window numbers:
void EnableWidget(byte widget_index)
Sets a widget to Enabled.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
static const byte LIT_ALL
Show the liveries of all companies.
void DirtyCompanyInfrastructureWindows(CompanyID company)
Redraw all windows with company infrastructure counts.
static void DoSelectCompanyManagerFace(Window *parent)
Company GUI constants.
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 SetDirty() const
Mark entire window as dirty (in need of re-paint)
static void ShowCompanyInfrastructure(CompanyID company)
Open the infrastructure window of a company.
uint Horizontal() const
Get total horizontal padding of RectPadding.
@ INVALID_OWNER
An invalid owner.
Money money
Money owned by the company.
RoadTypes roadtypes
Valid roadtypes.
void OnHundredthTick() override
Called once every 100 (game) ticks, or once every 3s, whichever comes last.
bool small
Window is toggled to 'small'.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
RoadTypes
The different roadtypes we support, but then a bitmask of them.
static const byte LIT_COMPANY
Show the liveries of your own company.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
byte in_use
Bit 0 set if this livery should override the default livery first colour, Bit 1 for the second colour...
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
const uint length
Number of items in list.
EconomySettings economy
settings to change the economy
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Window * parent
Parent window.
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
static uint GetTotalCategoriesHeight()
Get the total height of the "categories" column.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
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.
Rect Indent(int indent, bool end) const
Copy Rect and indent it from its position.
static Money RoadMaintenanceCost(RoadType roadtype, uint32 num, uint32 total_num)
Calculates the maintenance cost of a number of road bits.
@ CLIENT_ID_SERVER
Servers always have this ID.
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
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.
TileIndex location_of_HQ
Northern tile of HQ; INVALID_TILE when there is none.
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
bool _networking
are we in networking mode?
bool _shift_pressed
Is Shift pressed?
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
static Money max_money
The maximum amount of money a company has had this 'run'.
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.
Money AirportMaintenanceCost(Owner owner)
Calculates the maintenance cost of all airports of a company.
static Money RailMaintenanceCost(RailType railtype, uint32 num, uint32 total_num)
Calculates the maintenance cost of a number of track bits.
uint32 road[ROADTYPE_END]
Count of company owned track bits for each road type.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
uint32 signal
Count of company owned signals.
Money yearly_expenses[3][EXPENSES_END]
Expenses of the company for the last three years, in every ExpensesType category.
Coordinates of a point in 2D.
StringID name
Name of this rail type.
GRFLoadedFeatures _loaded_newgrf_features
Indicates which are the newgrf features currently loaded ingame.
static Money StationMaintenanceCost(uint32 num)
Calculates the maintenance cost of a number of station tiles.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
void ShowBuyCompanyDialog(CompanyID company)
Show the query to buy another company.
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
static const uint8 PC_BLACK
Black palette colour.
WindowNumber window_number
Window number within the window class.
VehicleType
Available vehicle types.
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 step_height
Step-size of height resize changes.
uint Vertical() const
Get total vertical padding of RectPadding.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
@ CS_ALPHANUMERAL
Both numeric and alphabetic and spaces and stuff.
bool NetworkCompanyIsPassworded(CompanyID company_id)
Check if the company we want to join requires a password.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ SA_HOR_CENTER
Horizontally center the text.
static const uint NETWORK_PASSWORD_LENGTH
The maximum length of the password, in bytes including '\0' (must be >= NETWORK_SERVER_ID_LENGTH)
int GetStringHeight(const char *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.
const ExpensesType * et
Expenses items.
bool NeedRebuild() const
Check if a rebuild is needed.
static void IncreaseCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, int8 amount)
Increase/Decrease the company manager's face variable by the given amount.
bool infrastructure_maintenance
enable monthly maintenance fee for owner infrastructure
uint32 StringID
Numeric value that represents a string, independent of the selected language.
static ExpensesType _expenses_list_capital_costs[]
List of capital expenses.
static const PaletteID PALETTE_RECOLOUR_START
First recolour sprite for company colours.
std::array< Owner, MAX_COMPANY_SHARE_OWNERS > share_owners
Owners of the shares of the company. INVALID_OWNER if nobody has bought them yet.
static WindowDesc _select_company_manager_face_desc(WDP_AUTO, "company_face", 0, 0, WC_COMPANY_MANAGER_FACE, WC_NONE, WDF_CONSTRUCTION, _nested_select_company_manager_face_widgets, lengthof(_nested_select_company_manager_face_widgets))
Company manager face selection window description.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
void SetFaceStringParameters(byte widget_index, uint8 val, bool is_bool_widget) const
Set parameters for value of face control buttons.
uint16 GroupID
Type for all group identifiers.
bool IsShaded() const
Is window shaded currently?
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.
void OnInit() override
Notification that the nested widget tree gets initialized.
Window class displaying the company finances.
void CDECL SetWidgetsLoweredState(bool lowered_stat, int widgets,...)
Sets the lowered/raised status of a list of widgets.
CompanyManagerFace _company_manager_face
for company manager face storage in openttd.cfg
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
@ COMPANY_SPECTATOR
The client is spectating.
@ RAILTYPE_END
Used for iterations.
CompanyWindowPlanes
Display planes in the company window.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
uint32 PaletteID
The number of the palette.
#define endof(x)
Get the end element of an fixed size array.
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 Money CanalMaintenanceCost(uint32 num)
Calculates the maintenance cost of a number of canal tiles.
bool is_moust_male
Male face with a moustache.
void DrawCompanyManagerFace(CompanyManagerFace cmf, int colour, int x, int y)
Draws the face of a company manager's face.
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
uint32 rail[RAILTYPE_END]
Count of company owned track bits for each rail type.
void OnPaint() override
The window must be repainted.
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
uint32 airport
Count of company owned airports.
@ WC_COMPANY_INFRASTRUCTURE
Company infrastructure overview; Window numbers:
@ HT_RECT
rectangle (stations, depots, ...)
static ExpensesType _expenses_list_revenue[]
List of revenues.
static ExpensesType _expenses_list_operating_costs[]
List of operating expenses.
static Money DrawYearCategory(const Rect &r, int start_y, ExpensesList list, const Money(*tbl)[EXPENSES_END])
Draw a category of expenses/revenues in the year column.
static const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
RoadType
The different roadtypes we support.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
bool is_female
Female face.
@ EXPENSES_PROPERTY
Property costs.
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
@ EXPENSES_NEW_VEHICLES
New vehicles.
void ForceResort()
Force a resort next Sort call Reset the resort timer if used too.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
@ SA_LEFT
Left align the text.
void ForceRebuild()
Force that a rebuild is needed.
static int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
@ SA_CENTER
Center both horizontally and vertically.
static T ToggleBit(T &x, const uint8 y)
Toggles a bit in a variable.
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)
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
@ EXPENSES_TRAIN_RUN
Running costs trains.
static const StringID _company_view_vehicle_count_strings[]
Strings for the company vehicle counts.
@ CWP_VB_BUILD
Display the build button.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
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...
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
@ INVALID_COMPANY
An invalid company.
int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
LiveryClass
List of different livery classes, used only by the livery GUI.
Dimension yesno_dim
Dimension of a yes/no button of a part in the advanced face window.
void DrawCountLine(const Rect &r, int &y, int count, Money monthly_cost) const
Helper for drawing the counts line.
static 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.
Data structure for an opened window.
void RebuildDone()
Notify the sortlist that the rebuild is done.
@ VEH_TRAIN
Train vehicle type.
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.
@ GE_WM
A male of Caucasian origin (white)
void DrawWidgets() const
Paint all widgets of a window.
static const uint MAX_COMPANY_SHARE_OWNERS
The maximum number of shares of a company that can be owned by another company.
@ CWP_BUTTONS_OTHER
Buttons of the other companies.
static void ScaleAllCompanyManagerFaceBits(CompanyManagerFace &cmf)
Scales all company manager's face bits to the correct scope.
Money GetTotalMaintenanceCost() const
Get total infrastructure maintenance cost.
@ WC_FINANCES
Finances of a company; Window numbers:
Window with detailed information about the company's infrastructure.
ExpensesType
Types of expenses.
static const ObjectType OBJECT_HQ
HeadQuarter of a player.
Dimension number_dim
Dimension of a number widget of a part in the advanced face window.
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
void ShowCompany(CompanyID company)
Show the window with the overview of the company.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
byte liveries
options for displaying company liveries, 0=none, 1=self, 2=all
@ VEH_SHIP
Ship vehicle type.
@ ROADTYPES_NONE
No roadtypes.
Specification of a rectangle with absolute coordinates of all edges.
void LowerWidget(byte widget_index)
Marks a widget as lowered.
RailTypes
The different railtypes we support, but then a bitmask of them.
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
void SelectDisplayPlanes(bool advanced)
Select planes to display to the user with the NWID_SELECTION widgets WID_SCMF_SEL_LOADSAVE,...
static const CompanyManagerFaceBitsInfo _cmf_info[]
Lookup table for indices into the CompanyManagerFace, valid ranges and sprites.
@ QSF_ENABLE_DEFAULT
enable the 'Default' button ("\0" is returned)
void DisableWidget(byte widget_index)
Sets a widget to disabled.
@ ETHNICITY_BLACK
This bit set means black, otherwise white.
void OnHundredthTick() override
Called once every 100 (game) ticks, or once every 3s, whichever comes last.
#define lastof(x)
Get the last element of an fixed size array.
@ EXPENSES_ROADVEH_REVENUE
Revenue from road vehicles.
@ ROADTYPE_BEGIN
Used for iterations.
bool masked
Masked and unselectable item.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Information about a particular livery.
static uint GetMaxCategoriesWidth()
Get the required width of the "categories" column, equal to the widest element.
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
@ EXPENSES_AIRCRAFT_REVENUE
Revenue from aircraft.
@ TD_RTL
Text is written right-to-left by default.
TextDirection _current_text_dir
Text direction of the currently selected language.
@ CS_NUMERAL
Only numeric ones.
@ EXPENSES_SHIP_RUN
Running costs ships.
@ EXPENSES_LOAN_INTEREST
Interest payments over the loan.
@ CWP_VB_VIEW
Display the view button.
uint32 GetRailTotal() const
Get total sum of all owned track bits.
RailTypes railtypes
Valid railtypes.
static void RandomCompanyManagerFaceBits(CompanyManagerFace &cmf, GenderEthnicity ge, bool adv, bool interactive=true)
Make a random new face.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
GUISettings gui
settings related to the GUI
@ EXPENSES_SHIP_REVENUE
Revenue from ships.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
byte colour2
Second colour, for vehicles with 2CC support.
byte colour1
First colour, for all vehicles.
RailTypes introduces_railtypes
Bitmask of which other railtypes are introduced when this railtype is introduced.
virtual void Close()
Hide the window and all its child windows, and mark them for a later deletion.
@ RAILTYPE_BEGIN
Used for iterations.
@ CWP_RELOCATE_HIDE
Hide the relocate HQ button.
Window with general information about a company.