100 uint GetHeight()
const 110 bool invalid_expenses_measured =
false;
111 for (uint i = 0; i < this->
length; i++) {
114 if (!invalid_expenses_measured) {
116 invalid_expenses_measured =
true;
144 for (uint i = 0; i < _expenses_list_types[type].
length; i++) {
151 DrawString(r.left, r.right, y, STR_FINANCES_SECTION_CONSTRUCTION + et);
156 DrawString(r.left, r.right, y + EXP_LINESPACE, STR_FINANCES_TOTAL_CAPTION, TC_FROMSTRING,
SA_RIGHT);
168 StringID str = STR_FINANCES_NEGATIVE_INCOME;
195 for (uint i = 0; i < _expenses_list_types[type].
length; i++) {
198 Money cost = subtotal;
208 if (cost != 0)
DrawPrice(cost, r.left, r.right, y);
218 static const NWidgetPart _nested_company_finances_widgets[] = {
280 this->CreateNestedTree();
281 this->SetupWidgets();
282 this->FinishInitNested(company);
284 this->owner = (
Owner)this->window_number;
312 size->height = _expenses_list_types[type].GetHeight();
318 size->height = _expenses_list_types[type].GetHeight();
347 if (wid_offset <= age) {
356 DrawString(r.left, r.right, r.top, STR_FINANCES_TOTAL_CURRENCY, TC_FROMSTRING,
SA_RIGHT);
363 DrawString(r.left, r.right, r.top, STR_FINANCES_TOTAL_CURRENCY, TC_FROMSTRING,
SA_RIGHT);
370 DrawString(r.left, r.right, r.top, STR_FINANCES_TOTAL_CURRENCY, TC_FROMSTRING,
SA_RIGHT);
387 this->GetWidget<NWidgetStacked>(
WID_CF_SEL_PANEL)->SetDisplayedPlane(plane);
397 if (!this->IsShaded()) {
401 if (_expenses_list_types[type].GetHeight() != this->GetWidget<NWidgetBase>(
WID_CF_EXPS_CATEGORY)->current_y) {
402 this->SetupWidgets();
412 this->SetupWidgets();
429 this->small = !this->small;
430 this->SetupWidgets();
431 if (this->IsShaded()) {
434 this->SetShaded(
false);
459 this->SetupWidgets();
472 _nested_company_finances_widgets,
lengthof(_nested_company_finances_widgets)
489 static const StringID _colour_dropdown[] = {
490 STR_COLOUR_DARK_BLUE,
491 STR_COLOUR_PALE_GREEN,
495 STR_COLOUR_LIGHT_BLUE,
497 STR_COLOUR_DARK_GREEN,
511 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,
514 LC_AIRCRAFT, LC_AIRCRAFT, LC_AIRCRAFT,
526 return this->result >= COLOUR_END ? STR_COLOUR_DEFAULT : _colour_dropdown[this->result];
529 uint Height(uint width)
const 534 bool Selectable()
const 539 void Draw(
int left,
int right,
int top,
int bottom,
bool sel,
int bg_colour)
const 542 int height = bottom - top;
543 int icon_y_offset = height / 2;
547 top + icon_y_offset);
550 top + text_y_offset, this->String(), sel ? TC_WHITE : TC_BLACK);
570 void ShowColourDropDownMenu(uint32 widget)
572 uint32 used_colours = 0;
574 const Livery *livery, *default_livery = NULL;
579 if (this->livery_class < LC_GROUP_RAIL &&
HasBit(this->sel, LS_DEFAULT) && primary) {
580 FOR_ALL_COMPANIES(c) {
587 if (this->livery_class < LC_GROUP_RAIL) {
590 for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
591 if (
HasBit(this->sel, scheme))
break;
593 if (scheme == LS_END) scheme = LS_DEFAULT;
594 livery = &c->livery[scheme];
595 if (scheme != LS_DEFAULT) default_livery = &c->livery[LS_DEFAULT];
600 default_livery = &c->livery[LS_DEFAULT];
603 default_livery = &pg->
livery;
608 if (default_livery != NULL) {
610 default_col = (primary ? default_livery->
colour1 : default_livery->
colour2) + COLOUR_END;
613 for (uint i = 0; i <
lengthof(_colour_dropdown); i++) {
617 byte sel = (default_livery == NULL ||
HasBit(livery->
in_use, primary ? 0 : 1)) ? (primary ? livery->
colour1 : livery->
colour2) : default_col;
621 static int CDECL GroupNameSorter(
const Group *
const *a,
const Group *
const *b)
623 static const Group *last_group[2] = { NULL, NULL };
624 static char last_name[2][64] = {
"",
"" };
626 if (*a != last_group[0]) {
629 GetString(last_name[0], STR_GROUP_NAME,
lastof(last_name[0]));
632 if (*b != last_group[1]) {
635 GetString(last_name[1], STR_GROUP_NAME,
lastof(last_name[1]));
638 int r =
strnatcmp(last_name[0], last_name[1]);
639 if (r == 0)
return (*a)->index - (*b)->index;
643 void AddChildren(GUIGroupList *source,
GroupID parent,
int indent)
645 for (
const Group **g = source->
Begin(); g != source->
End(); g++) {
646 if ((*g)->parent != parent)
continue;
647 *this->groups.
Append() = *g;
648 *this->indents.
Append() = indent;
649 AddChildren(source, (*g)->index, indent + 1);
657 this->groups.
Clear();
658 this->indents.
Clear();
660 if (this->livery_class >= LC_GROUP_RAIL) {
672 list.
Sort(&GroupNameSorter);
683 if (this->livery_class < LC_GROUP_RAIL) {
685 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
691 this->rows = this->groups.
Length();
694 this->vscroll->
SetCount(this->rows);
700 this->CreateNestedTree();
704 this->livery_class = LC_OTHER;
707 this->BuildGroupList(company);
710 this->SetSelectedGroup(company, group);
713 this->FinishInitNested(company);
714 this->owner = company;
715 this->InvalidateData(1);
723 case VEH_TRAIN: this->livery_class = LC_GROUP_RAIL;
break;
724 case VEH_ROAD: this->livery_class = LC_GROUP_ROAD;
break;
725 case VEH_SHIP: this->livery_class = LC_GROUP_SHIP;
break;
726 case VEH_AIRCRAFT: this->livery_class = LC_GROUP_AIRCRAFT;
break;
727 default: NOT_REACHED();
733 this->BuildGroupList(company);
737 for (uint i = 0; i < this->rows; i++) {
738 if (this->groups[i]->index == sel) {
751 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
773 size->height = 11 * this->line_height;
775 resize->height = this->line_height;
788 int padding = this->square.width + NWidgetScrollbar::GetVerticalDimension().width + 10;
789 for (
const StringID *
id = _colour_dropdown;
id !=
endof(_colour_dropdown);
id++) {
803 bool disabled = this->livery_class < LC_GROUP_RAIL ? (this->sel == 0) : (this->sel ==
INVALID_GROUP);
807 this->BuildGroupList((
CompanyID)this->window_number);
823 StringID colour = STR_COLOUR_DEFAULT;
825 if (this->livery_class < LC_GROUP_RAIL) {
826 if (this->sel != 0) {
828 for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
829 if (
HasBit(this->sel, scheme))
break;
831 if (scheme == LS_END) scheme = LS_DEFAULT;
832 const Livery *livery = &c->livery[scheme];
833 if (scheme == LS_DEFAULT ||
HasBit(livery->
in_use, primary ? 0 : 1)) {
834 colour = STR_COLOUR_DARK_BLUE + (primary ? livery->
colour1 : livery->
colour2);
842 colour = STR_COLOUR_DARK_BLUE + (primary ? livery->
colour1 : livery->
colour2);
860 int sch_left = nwi->
pos_x;
861 int sch_right = sch_left + nwi->
current_x - 1;
864 int pri_left = nwi->
pos_x;
865 int pri_right = pri_left + nwi->
current_x - 1;
868 int sec_left = nwi->
pos_x;
869 int sec_right = sec_left + nwi->
current_x - 1;
874 int square_offs = (this->line_height - this->square.height) / 2 + 1;
880 auto draw_livery = [&](
StringID str,
const Livery &liv,
bool sel,
bool def,
int indent) {
886 DrawString(pri_left + text_left, pri_right - text_right, y + text_offs, (def ||
HasBit(liv.in_use, 0)) ? STR_COLOUR_DARK_BLUE + liv.colour1 : STR_COLOUR_DEFAULT, sel ? TC_WHITE : TC_GOLD);
889 if (sec_right > sec_left) {
891 DrawString(sec_left + text_left, sec_right - text_right, y + text_offs, (def ||
HasBit(liv.in_use, 1)) ? STR_COLOUR_DARK_BLUE + liv.colour2 : STR_COLOUR_DEFAULT, sel ? TC_WHITE : TC_GOLD);
894 y += this->line_height;
897 if (livery_class < LC_GROUP_RAIL) {
900 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
902 if (pos-- > 0)
continue;
903 draw_livery(STR_LIVERY_DEFAULT + scheme, c->livery[scheme],
HasBit(this->sel, scheme), scheme == LS_DEFAULT, 0);
909 const Group *g = this->groups[i];
911 draw_livery(STR_GROUP_NAME, g->
livery, this->sel == g->
index,
false, this->indents[i] * LEVEL_WIDTH);
934 if (this->livery_class < LC_GROUP_RAIL) {
936 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
938 this->sel = 1 << scheme;
945 this->BuildGroupList((
CompanyID)this->window_number);
947 if (this->groups.
Length() > 0) {
948 this->sel = this->groups[0]->index;
966 if (row >= this->rows)
return;
968 if (this->livery_class < LC_GROUP_RAIL) {
971 for (
LiveryScheme scheme = LS_BEGIN; scheme <= j && scheme < LS_END; scheme++) {
982 this->sel = this->groups[row]->index;
1000 if (index >= COLOUR_END) index = INVALID_COLOUR;
1002 if (this->livery_class < LC_GROUP_RAIL) {
1004 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
1023 if (!gui_scope)
return;
1027 if (this->livery_class == data + LC_GROUP_RAIL) {
1029 this->BuildGroupList((
CompanyID)this->window_number);
1034 if (this->groups.
Length() > 0) this->sel = this->groups[0]->index;
1044 bool current_class_valid = this->livery_class == LC_OTHER || this->livery_class >= LC_GROUP_RAIL;
1046 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
1048 if (_livery_class[scheme] == this->livery_class) current_class_valid =
true;
1050 }
else if (this->livery_class < LC_GROUP_RAIL) {
1051 ClrBit(this->sel, scheme);
1056 if (!current_class_valid) {
1063 static const NWidgetPart _nested_select_company_livery_widgets [] = {
1084 SetDataTip(STR_BLACK_STRING, STR_LIVERY_SECONDARY_TOOLTIP),
1087 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),
1095 static WindowDesc _select_company_livery_desc(
1099 _nested_select_company_livery_widgets,
lengthof(_nested_select_company_livery_widgets)
1108 w->SetSelectedGroup(company, group);
1129 if (
_cmf_info[CMFV_EYE_COLOUR].valid_values[ge] < 2) {
1133 default: NOT_REACHED();
1134 case 0: pal = PALETTE_TO_BROWN;
break;
1135 case 1: pal = PALETTE_TO_BLUE;
break;
1136 case 2: pal = PALETTE_TO_GREEN;
break;
1141 DrawSprite(SPR_GRADIENT, GENERAL_SPRITE_COLOUR(colour), x, y);
1143 for (CompanyManagerFaceVariable cmfv = CMFV_CHEEKS; cmfv < CMFV_END; cmfv++) {
1145 case CMFV_MOUSTACHE:
if (!has_moustache)
continue;
break;
1147 case CMFV_NOSE:
if (has_moustache)
continue;
break;
1148 case CMFV_TIE_EARRING:
if (!has_tie_earring)
continue;
break;
1149 case CMFV_GLASSES:
if (!has_glasses)
continue;
break;
1316 const NWidgetCore *nwi_widget = this->GetWidget<NWidgetCore>(widget_index);
1318 if (is_bool_widget) {
1320 str = (val != 0) ? STR_FACE_YES : STR_FACE_NO;
1343 this->advanced =
false;
1344 this->CreateNestedTree();
1345 this->SelectDisplayPlanes(this->advanced);
1347 this->parent = parent;
1348 this->owner = (
Owner)this->window_number;
1361 this->GetWidget<NWidgetStacked>(
WID_SCMF_SEL_PARTS)->SetDisplayedPlane(advanced ? 0 : SZSP_NONE);
1363 this->GetWidget<NWidgetCore>(
WID_SCMF_RANDOM_NEW_FACE)->widget_data = advanced ? STR_FACE_RANDOM : STR_FACE_NEW_FACE_BUTTON;
1367 wi->
SetDataTip(STR_FACE_SIMPLE, STR_FACE_SIMPLE_TOOLTIP);
1369 wi->SetDataTip(STR_FACE_ADVANCED, STR_FACE_ADVANCED_TOOLTIP);
1381 for (
int val = 1; val <= 12; val++) {
1389 yesno_dim.width =
max(yesno_dim.width, number_dim.width);
1390 number_dim.width = yesno_dim.width - arrows_width;
1392 this->yesno_dim = yesno_dim;
1393 this->number_dim = number_dim;
1401 size->width =
max(size->width, face_size.width);
1402 size->height =
max(size->height, face_size.height);
1437 *size = this->yesno_dim;
1450 *size = this->number_dim;
1473 this->SetWidgetsDisabledState(
_cmf_info[CMFV_EYE_COLOUR].valid_values[this->ge] < 2,
1477 this->SetWidgetsDisabledState(
_cmf_info[CMFV_CHIN].valid_values[this->ge] < 2,
1481 this->SetWidgetsDisabledState(
_cmf_info[CMFV_EYEBROWS].valid_values[this->ge] < 2,
1485 this->SetWidgetsDisabledState(
_cmf_info[this->is_moust_male ? CMFV_MOUSTACHE : CMFV_LIPS].valid_values[this->ge] < 2,
1489 this->SetWidgetsDisabledState(
_cmf_info[CMFV_NOSE].valid_values[this->ge] < 2 || this->is_moust_male,
1493 this->SetWidgetsDisabledState(
_cmf_info[CMFV_HAIR].valid_values[this->ge] < 2,
1497 this->SetWidgetsDisabledState(
_cmf_info[CMFV_JACKET].valid_values[this->ge] < 2,
1501 this->SetWidgetsDisabledState(
_cmf_info[CMFV_COLLAR].valid_values[this->ge] < 2,
1505 this->SetWidgetsDisabledState(
_cmf_info[CMFV_TIE_EARRING].valid_values[this->ge] < 2 ||
1513 this->DrawWidgets();
1544 if (this->is_female) {
1556 if (this->is_moust_male) {
1611 this->advanced = !this->advanced;
1612 this->SelectDisplayPlanes(this->advanced);
1680 CompanyManagerFaceVariable cmfv;
1684 default: NOT_REACHED();
1685 case 0: cmfv = this->is_female ? CMFV_HAS_TIE_EARRING : CMFV_HAS_MOUSTACHE;
break;
1686 case 1: cmfv = CMFV_HAS_GLASSES;
break;
1692 default: NOT_REACHED();
1693 case 0: cmfv = CMFV_EYE_COLOUR;
break;
1694 case 1: cmfv = CMFV_CHIN;
break;
1695 case 2: cmfv = CMFV_EYEBROWS;
break;
1696 case 3: cmfv = this->is_moust_male ? CMFV_MOUSTACHE : CMFV_LIPS;
break;
1697 case 4: cmfv = CMFV_NOSE;
break;
1698 case 5: cmfv = CMFV_HAIR;
break;
1699 case 6: cmfv = CMFV_JACKET;
break;
1700 case 7: cmfv = CMFV_COLLAR;
break;
1701 case 8: cmfv = CMFV_TIE_EARRING;
break;
1702 case 9: cmfv = CMFV_GLASSES;
break;
1716 if (str == NULL)
return;
1719 this->face = strtoul(str, NULL, 10);
1732 STR_FACE_MOUSTACHE, STR_FACE_EARRING,
1733 STR_FACE_TIE, STR_FACE_EARRING,
1754 _nested_select_company_manager_face_widgets,
lengthof(_nested_select_company_manager_face_widgets)
1770 static const NWidgetPart _nested_company_infrastructure_widgets[] = {
1815 this->UpdateRailRoadTypes();
1817 this->InitNested(window_number);
1818 this->owner = (
Owner)this->window_number;
1821 void UpdateRailRoadTypes()
1838 FOR_ALL_ENGINES_OF_TYPE(e,
VEH_ROAD) {
1889 if (
HasBit(this->railtypes, rt)) {
1939 uint32 max_val = 1000;
1940 Money max_cost = 10000;
1965 size->width =
max(size->width, this->total_width);
1971 size->width =
max(size->width, count_width);
1997 DrawString(left, left + this->total_width, y, STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL, TC_FROMSTRING,
SA_RIGHT);
2011 DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_RAIL_SECT);
2017 if (
HasBit(this->railtypes, rt)) {
2035 if (
HasBit(this->railtypes, rt)) {
2046 DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_ROAD_SECT);
2068 DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_WATER_SECT);
2081 SetDParam(0, this->GetTotalMaintenanceCost() * 12);
2082 DrawString(left, left + this->total_width, y, STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL, TC_FROMSTRING,
SA_RIGHT);
2087 DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_STATION_SECT);
2106 if (!gui_scope)
return;
2108 this->UpdateRailRoadTypes();
2113 static WindowDesc _company_infrastructure_desc(
2114 WDP_AUTO,
"company_infrastructure", 0, 0,
2117 _nested_company_infrastructure_widgets,
lengthof(_nested_company_infrastructure_widgets)
2127 AllocateWindowDescFront<CompanyInfrastructureWindow>(&_company_infrastructure_desc, company);
2130 static const NWidgetPart _nested_company_widgets[] = {
2234 STR_COMPANY_VIEW_TRAINS, STR_COMPANY_VIEW_ROAD_VEHICLES, STR_COMPANY_VIEW_SHIPS, STR_COMPANY_VIEW_AIRCRAFT
2255 CWP_RELOCATE_SHOW = 0,
2259 CWP_BUTTONS_LOCAL = 0,
2265 this->InitNested(window_number);
2266 this->owner = (
Owner)this->window_number;
2267 this->OnInvalidateData();
2275 if (!this->IsShaded()) {
2276 bool reinit =
false;
2279 int plane = local ? CWP_BUTTONS_LOCAL : CWP_BUTTONS_OTHER;
2283 this->InvalidateData();
2336 this->DrawWidgets();
2344 size->width =
max(size->width, face_size.width);
2345 size->height =
max(size->height, face_size.height);
2352 d.width -= offset.x;
2353 d.height -= offset.y;
2354 *size =
maxdim(*size, d);
2365 for (uint i = 0; i <
lengthof(_company_view_vehicle_count_strings); i++) {
2383 FOR_ALL_COMPANIES(c2) {
2392 #ifdef ENABLE_NETWORK 2416 d.height -= offset.y;
2417 DrawSprite(SPR_VEH_BUS_SW_VIEW, COMPANY_SPRITE_COLOUR(c->
index), r.left - offset.x, (r.top + r.bottom - d.height) / 2 - offset.y);
2429 if (amounts[0] + amounts[1] + amounts[2] + amounts[3] == 0) {
2430 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_VEHICLES_NONE);
2432 assert_compile(
lengthof(amounts) ==
lengthof(_company_view_vehicle_count_strings));
2434 for (uint i = 0; i <
lengthof(amounts); i++) {
2435 if (amounts[i] != 0) {
2437 DrawString(r.left, r.right, y, _company_view_vehicle_count_strings[i]);
2450 uint road_pieces = 0;
2455 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_NONE);
2457 if (rail_pieces != 0) {
2459 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_RAIL);
2462 if (road_pieces != 0) {
2464 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_ROAD);
2469 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_WATER);
2474 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_STATION);
2479 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_AIRPORT);
2490 FOR_ALL_COMPANIES(c2) {
2491 uint amt = GetAmountOwnedBy(c, c2->
index);
2496 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_SHARES_OWNED_BY);
2503 #ifdef ENABLE_NETWORK 2506 DrawSprite(SPR_LOCK, PAL_NONE, r.left, r.top);
2566 this->RaiseButtons();
2578 this->RaiseButtons();
2599 #ifdef ENABLE_NETWORK 2601 if (this->window_number ==
_local_company) ShowNetworkCompanyPasswordWindow(
this);
2633 this->RaiseButtons();
2639 this->RaiseButtons();
2644 if (str == NULL)
return;
2646 switch (this->query_widget) {
2647 default: NOT_REACHED();
2657 #ifdef ENABLE_NETWORK 2700 _nested_company_widgets,
lengthof(_nested_company_widgets)
2711 AllocateWindowDescFront<CompanyWindow>(&_company_desc, company);
2727 this->InitNested(window_number);
2789 static const NWidgetPart _nested_buy_company_widgets[] = {
2812 _nested_buy_company_widgets,
lengthof(_nested_buy_company_widgets)
2821 AllocateWindowDescFront<BuyCompanyWindow>(&_buy_company_desc, company);
Functions related to OTTD's strings.
Base types for having sorted lists in GUIs.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
uint32 PaletteID
The number of the palette.
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
void RebuildDone()
Notify the sortlist that the rebuild is done.
Dimension number_dim
Dimension of a number widget of a part in the advanced face window.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition of stuff that is very close to a company, like the company struct itself.
#define FOR_ALL_SORTED_RAILTYPES(var)
Loop header for iterating over railtypes, sorted by sortorder.
bool _networking
are we in networking mode?
void ShowBuyCompanyDialog(CompanyID company)
Show the query to buy another company.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
static const uint8 PC_WHITE
White palette colour.
Horizontally center the text.
Window with detailed information about the company's infrastructure.
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...
LiveryScheme
List of different livery schemes.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
byte landscape
the landscape we're currently in
RailType
Enumeration for all possible railtypes.
High level window description.
Functions related to roads.
EconomySettings economy
settings to change the economy
bool expenses_layout
layout of expenses window
static Titem * Get(size_t index)
Returns Titem with given index.
Functions related to dates.
const uint length
Number of items in list.
GUIs related to networking.
static T ToggleBit(T &x, const uint8 y)
Toggles a bit in a variable.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
Management class for customizing the face of the company manager.
CompanyManagerFace _company_manager_face
for company manager face storage in openttd.cfg
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
uint32 GetRailTotal() const
Get total sum of all owned track bits.
Year inaugurated_year
Year of starting the company.
Offset at top to draw the frame rectangular area.
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 SetBit(T &x, const uint8 y)
Set a bit in a variable.
This bit set means a female, otherwise male.
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
void ShowDropDownList(Window *w, const DropDownList *list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
Company livery colour scheme window.
Display the join company button.
static const int LOAN_INTERVAL
The "steps" in loan size, in British Pounds!
const ExpensesType * et
Expenses items.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
Buyout company (merger); Window numbers:
void Clear()
Remove all items from the list.
static const StringID _company_view_vehicle_count_strings[]
Strings for the company vehicle counts.
static const uint EXP_LINESPACE
Company GUI constants.
void DrawCompanyManagerFace(CompanyManagerFace cmf, int colour, int x, int y)
Draws the face of a company manager's face.
set the livery for a group
buy a company which is bankrupt
void Compact()
Compact the list down to the smallest block size boundary.
const T * Begin() const
Get the pointer to the first item (const)
void NetworkClientRequestMove(CompanyID company_id, const char *pass)
Notify the server of this client wanting to be moved to another company.
Tindex index
Index of this pool item.
static Money SignalMaintenanceCost(uint32 num)
Calculates the maintenance cost of a number of signals.
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
void NetworkServerDoMove(ClientID client_id, CompanyID company_id)
Handle the tid-bits of moving a client from one company to another.
static const uint MAX_LENGTH_PRESIDENT_NAME_CHARS
The maximum length of a president name in characters including '\0'.
#define lastof(x)
Get the last element of an fixed size array.
The client is spectating.
bool NetworkCompanyIsPassworded(CompanyID company_id)
Check if the company we want to join requires a password.
Stuff related to the text buffer GUI.
virtual void OnResize()
Called after the window got resized.
static const byte LIT_COMPANY
Show the liveries of your own company.
A male of Caucasian origin (white)
uint32 station
Count of company owned station tiles.
CompanyWindowPlanes
Display planes in the company window.
RoadType
The different roadtypes we support.
static T max(const T a, const T b)
Returns the maximum of two values.
Year _cur_year
Current year, starting at 0.
bool infrastructure_maintenance
enable monthly maintenance fee for owner infrastructure
const T * End() const
Get the pointer behind the last valid item (const)
bool is_female
Female face.
bool NeedRebuild() const
Check if a rebuild is needed.
Functions, definitions and such used only by the GUI.
Servers always have this ID.
T * Append(uint to_add=1)
Append an item and return it.
void DrawCountLine(const Rect &r, int &y, int count, Money monthly_cost) const
Helper for drawing the counts line.
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
bool allow_shares
allow the buying/selling of shares
Functions related to (drawing on) viewports.
void ForceRebuild()
Force that a rebuild is needed.
static const int LEVEL_WIDTH
Indenting width of a sub-group in pixels.
static const CompanyManagerFaceBitsInfo _cmf_info[]
Lookup table for indices into the CompanyManagerFace, valid ranges and sprites.
Data structure for an opened window.
bool _ctrl_pressed
Is Ctrl pressed?
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=NULL, uint textref_stack_size=0, const uint32 *textref_stack=NULL)
Display an error message in a window.
Bottom offset of the text of the frame.
enable the 'Default' button ("\0" is returned)
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
uint32 CompanyManagerFace
Company manager face bits, info see in company_manager_face.h.
uint32 signal
Count of company owned signals.
decrease the loan from the bank
Types related to object tiles.
Functions related to errors.
void ShowCompany(CompanyID company)
Show the window with the overview of the company.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
uint Length() const
Get the number of items in the list.
This window is used for construction; close it whenever changing company.
Income from road vehicles.
static const StringID PART_TEXTS[]
Fixed strings to describe parts of the face.
void DirtyCompanyInfrastructureWindows(CompanyID company)
Redraw all windows with company infrastructure counts.
VehicleType
Available vehicle types.
increase the loan from the bank
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
static const uint EXP_BLOCKSPACE
Amount of vertical space between two blocks of numbers.
Money GetTotalMaintenanceCost() const
Get total infrastructure maintenance cost.
Money current_loan
Amount of money borrowed from the bank.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Simple vector template class, with automatic delete.
ClientSettings _settings_client
The current settings for this game.
Money AirportMaintenanceCost(Owner owner)
Calculates the maintenance cost of all airports of a company.
virtual void OnPlaceObjectAbort()
The user cancelled a tile highlight mode that has been set.
TileIndex location_of_HQ
Northern tile of HQ; INVALID_TILE when there is none.
Definition of base types and functions in a cross-platform compatible way.
Center both horizontally and vertically.
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'.
uint32 road[ROADTYPE_END]
Count of company owned track bits for each road type.
A number of safeguards to prevent using unsafe methods.
GenderEthnicity ge
Gender and ethnicity.
RailTypes introduces_railtypes
Bitmask of which other railtypes are introduced when this railtype is introduced. ...
static void RandomCompanyManagerFaceBits(CompanyManagerFace &cmf, GenderEthnicity ge, bool adv, bool interactive=true)
Make a random new face.
rectangle (stations, depots, ...)
Window class displaying the company finances.
uint16 GroupID
Type for all group identifiers.
static ExpensesType _expenses_list_2[]
Grouped list of expenses.
static void DrawCategories(const Rect &r)
Draw the expenses categories.
static ExpensesType _expenses_list_1[]
Standard unsorted list of expenses.
set the manager's face of the company
Finances of a company; Window numbers:
Information about a particular livery.
VehicleTypeByte vehicle_type
Vehicle type of the group.
RailTypes railtypes
Valid railtypes.
static const byte LIT_ALL
Show the liveries of all companies.
static void IncreaseCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, int8 amount)
Increase/Decrease the company manager's face variable by the given amount.
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.
Company colour selection; Window numbers:
GroupStatistics group_all[VEH_COMPANY_END]
NOSAVE: Statistics for the ALL_GROUP group.
virtual void OnPaint()
The window must be repainted.
Money CalculateCompanyValue(const Company *c, bool including_loan=true)
Calculate the value of the company.
set the colour of the company
byte misc_flags
Miscellaneous flags.
ExpensesType
Types of expenses.
bool is_ai
If true, the company is (also) controlled by the computer (a NoAI program).
Money money
Money owned by the company.
Offset at bottom to draw the frame rectangular area.
static const GroupID INVALID_GROUP
Sentinel for invalid groups.
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.
Basic functions/variables used all over the place.
uint16 num_vehicle
Number of vehicles.
Functions related to stations.
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
uint32 airport
Count of company owned airports.
#define lengthof(x)
Return the length of an fixed size array.
static void DoSelectCompanyManagerFace(Window *parent)
Open the simple/advanced company manager face selection window.
static T min(const T a, const T b)
Returns the minimum of two values.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
Right offset of the image in the button.
RailTypes
The different railtypes we support, but then a bitmask of them.
uint GetCategoriesWidth() const
Compute width of the expenses categories in pixels.
Types related to the drop down widget.
void DrawFaceStringLabel(byte widget_index, uint8 val, bool is_bool_widget) const
Draw dynamic a label to the left of the button and a value in the button.
bool Sort(SortFunction *compare)
Sort the list.
Money max_loan
NOSAVE: Maximum possible loan.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Text is written left-to-right by default.
static const uint8 PC_BLACK
Black palette colour.
byte colour2
Second colour, for vehicles with 2CC support.
virtual void OnPaint()
The window must be repainted.
virtual void OnInit()
Notification that the nested widget tree gets initialized.
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
CompanyManagerFace face
Face description of the president.
const uint num_subtotals
Number of sub-totals in the list.
RoadTypes
The different roadtypes we support, but then a bitmask of them.
static void DrawPrice(Money amount, int left, int right, int top)
Draw an amount of money.
virtual void OnPlaceObject(Point pt, TileIndex tile)
The user clicked some place on the map when a tile highlight mode has been set.
virtual void OnPaint()
The window must be repainted.
static SpriteID GetCompanyManagerFaceSprite(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
Gets the sprite to draw for the given company manager's face variable.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
bool _shift_pressed
Is Shift pressed?
void ShowExtraViewPortWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
bool advanced
advanced company manager face selection window
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
void ForceResort()
Force a resort next Sort call Reset the resort timer if used too.
Livery livery
Custom colour scheme for vehicles in this group.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
virtual void OnHundredthTick()
Called once every 100 (game) ticks.
CompanyInfrastructure infrastructure
NOSAVE: Counts of company owned infrastructure.
uint32 rail[RAILTYPE_END]
Count of company owned track bits for each rail type.
No window, redirects to WC_MAIN_WINDOW.
void SetupWidgets()
Setup the widgets in the nested tree, such that the finances window is displayed properly.
Company infrastructure overview; Window numbers:
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
Functions related to companies.
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...
static const PaletteID PALETTE_RECOLOUR_START
First recolour sprite for company colours.
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
Both numeric and alphabetic and spaces and stuff.
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
Running costs road vehicles.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
Functionality related to the company manager's face.
CompanyManagerFace face
company manager face bits
GUISettings gui
settings related to the GUI
GroupID parent
Parent group.
int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
static Money StationMaintenanceCost(uint32 num)
Calculates the maintenance cost of a number of station tiles.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
uint32 TileIndex
The index/ID of a Tile.
virtual void OnDropdownSelect(int widget, int index)
A dropdown option associated to this window has been selected.
OwnerByte share_owners[4]
Owners of the 4 shares of the company. INVALID_OWNER if nobody has bought them yet.
sell a share from a company
TextDirection _current_text_dir
Text direction of the currently selected language.
byte colour
Company colour.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
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.
void SelectDisplayPlanes(bool advanced)
Select planes to display to the user with the NWID_SELECTION widgets WID_SCMF_SEL_LOADSAVE, WID_SCMF_SEL_MALEFEMALE, and WID_SCMF_SEL_PARTS.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
Display the build button.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
change the president name
Functions related to zooming.
#define endof(x)
Get the end element of an fixed size array.
LiveryClass
List of different livery classes, used only by the livery GUI.
#define MAX_DAY
The number of days till the last day.
bool has_2CC
Set if any vehicle is loaded which uses 2cc (two company colours).
static Money CanalMaintenanceCost(uint32 num)
Calculates the maintenance cost of a number of canal tiles.
Alter company face window; Window numbers:
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
Functions related to commands.
Network functions used by other parts of OpenTTD.
byte in_use
Bit 0 set if this livery should override the default livery first colour, Bit 1 for the second colour...
bool _network_server
network-server is active
Coordinates of a point in 2D.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
void ShowCompanyFinances(CompanyID company)
Open the finances window of a company.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
This bit set means black, otherwise white.
uint64 used_liveries
Bitmask of LiveryScheme used by the defined engines.
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
Buttons of the other companies.
virtual void OnHundredthTick()
Called once every 100 (game) ticks.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
static void ScaleAllCompanyManagerFaceBits(CompanyManagerFace &cmf)
Scales all company manager's face bits to the correct scope.
Money yearly_expenses[3][EXPENSES_END]
Expenses of the company for the last three years, in every ExpensesType category. ...
GenderEthnicity
The gender/race combinations that we have faces for.
StringID name
Name of this rail type.
Offset at right to draw the frame rectangular area.
byte liveries
options for displaying company liveries, 0=none, 1=self, 2=all
OwnerByte owner
Group Owner.
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
static const uint NETWORK_PASSWORD_LENGTH
The maximum length of the password, in bytes including '\0' (must be >= NETWORK_SERVER_ID_LENGTH) ...
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
byte colour1
First colour, for all vehicles.
#define CMD_MSG(x)
Used to combine a StringID with the command.
int32 WindowNumber
Number to differentiate different windows of the same class.
GameCreationSettings game_creation
settings used during the creation of a game (map)
buy a share from a company
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows)...
Specification of a rectangle with absolute coordinates of all edges.
RoadTypes roadtypes
Valid roadtypes.
Text is written right-to-left by default.
Right align the text (must be a single bit).
WindowNumber window_number
Window number within the window class.
Road vehicle is a tram/light rail vehicle.
static void DrawYearColumn(const Rect &r, int year, const Money(*tbl)[EXPENSES_END])
Draw a column with prices.
Functions related to tile highlights.
uint total_width
String width of the total cost line.
Owner
Enum for all companies/owners.
Window functions not directly related to making/drawing windows.
virtual void OnPaint()
The window must be repainted.
GRFLoadedFeatures _loaded_newgrf_features
Indicates which are the newgrf features currently loaded ingame.
Find a place automatically.
Functions related to water (management)
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
static const NWidgetPart _nested_select_company_manager_face_widgets[]
Nested widget description for the company manager face selection dialog.
GUI functions that shouldn't be here.
static Money RailMaintenanceCost(RailType railtype, uint32 num, uint32 total_num)
Calculates the maintenance cost of a number of track bits.
byte climates
Climates supported by the engine.
Hide the relocate HQ button.
Window with general information about a company.
static uint GetCompanyManagerFaceBits(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
Gets the company manager's face bits for the given company manager's face variable.
Company view; Window numbers:
Left offset of the image in the button.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
Base list item class from which others are derived.
Dimensions (a width and height) of a rectangle in 2D.
RailTypes AddDateIntroducedRailTypes(RailTypes current, Date date)
Add the rail types that are to be introduced at the given date.
Offset at left to draw the frame rectangular area.
static void ShowCompanyInfrastructure(CompanyID company)
Open the infrastructure window of a company.
static const StringID PART_TEXTS_IS_FEMALE[]
Strings depending on is_female, used to describe parts (2 entries for a part).
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
static const ObjectType OBJECT_HQ
HeadQuarter of a player.
Dimension yesno_dim
Dimension of a yes/no button of a part in the advanced face window.
static Money RoadMaintenanceCost(RoadType roadtype, uint32 num)
Calculates the maintenance cost of a number of road bits.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
bool is_moust_male
Male face with a moustache.
static Money max_money
The maximum amount of money a company has had this 'run'.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
AutoDeleteSmallVector< const DropDownListItem *, 4 > DropDownList
A drop down list is a collection of drop down list items.
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.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
bool small
Window is toggled to 'small'.
Interest payments over the loan.
uint32 water
Count of company owned track bits for canals.
Base for the NewGRF implementation.