99 uint GetHeight()
const
109 bool invalid_expenses_measured =
false;
110 for (uint i = 0; i < this->
length; i++) {
113 if (!invalid_expenses_measured) {
115 invalid_expenses_measured =
true;
143 for (uint i = 0; i < _expenses_list_types[type].
length; i++) {
150 DrawString(r.left, r.right, y, STR_FINANCES_SECTION_CONSTRUCTION + et);
155 DrawString(r.left, r.right, y + EXP_LINESPACE, STR_FINANCES_TOTAL_CAPTION, TC_FROMSTRING,
SA_RIGHT);
167 StringID str = STR_FINANCES_NEGATIVE_INCOME;
194 for (uint i = 0; i < _expenses_list_types[type].
length; i++) {
197 Money cost = subtotal;
204 Money cost = (*tbl)[et];
207 if (cost != 0)
DrawPrice(cost, r.left, r.right, y);
217 static const NWidgetPart _nested_company_finances_widgets[] = {
314 size->height = _expenses_list_types[type].GetHeight();
320 size->height = _expenses_list_types[type].GetHeight();
349 if (wid_offset <= age) {
358 DrawString(r.left, r.right, r.top, STR_FINANCES_TOTAL_CURRENCY, TC_FROMSTRING,
SA_RIGHT);
365 DrawString(r.left, r.right, r.top, STR_FINANCES_TOTAL_CURRENCY, TC_FROMSTRING,
SA_RIGHT);
372 DrawString(r.left, r.right, r.top, STR_FINANCES_TOTAL_CURRENCY, TC_FROMSTRING,
SA_RIGHT);
389 this->GetWidget<NWidgetStacked>(
WID_CF_SEL_PANEL)->SetDisplayedPlane(plane);
403 if (_expenses_list_types[type].GetHeight() != this->GetWidget<NWidgetBase>(
WID_CF_EXPS_CATEGORY)->current_y) {
474 _nested_company_finances_widgets,
lengthof(_nested_company_finances_widgets)
491 static const StringID _colour_dropdown[] = {
492 STR_COLOUR_DARK_BLUE,
493 STR_COLOUR_PALE_GREEN,
497 STR_COLOUR_LIGHT_BLUE,
499 STR_COLOUR_DARK_GREEN,
513 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,
516 LC_AIRCRAFT, LC_AIRCRAFT, LC_AIRCRAFT,
528 return _colour_dropdown[this->
result];
531 uint Height(uint width)
const
536 bool Selectable()
const
541 void Draw(
int left,
int right,
int top,
int bottom,
bool sel,
int bg_colour)
const
544 int height = bottom - top;
545 int icon_y_offset = height / 2;
549 top + icon_y_offset);
552 top + text_y_offset, this->String(), sel ? TC_WHITE : TC_BLACK);
565 void ShowColourDropDownMenu(uint32 widget)
567 uint32 used_colours = 0;
574 FOR_ALL_COMPANIES(c) {
580 for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
581 if (
HasBit(this->sel, scheme))
break;
583 if (scheme == LS_END) scheme = LS_DEFAULT;
587 for (uint i = 0; i <
lengthof(_colour_dropdown); i++) {
597 this->livery_class = LC_OTHER;
605 this->
owner = company;
616 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
624 uint livery_height = 0;
625 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
630 size->height = livery_height * this->line_height;
643 int padding = this->square.width + NWidgetScrollbar::GetVerticalDimension().width + 10;
644 for (
const StringID *
id = _colour_dropdown;
id !=
endof(_colour_dropdown);
id++) {
669 if (this->sel != 0) {
670 for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
671 if (
HasBit(this->sel, scheme))
break;
673 if (scheme == LS_END) scheme = LS_DEFAULT;
689 int sch_left = nwi->
pos_x;
690 int sch_right = sch_left + nwi->
current_x - 1;
693 int pri_left = nwi->
pos_x;
694 int pri_right = pri_left + nwi->
current_x - 1;
697 int sec_left = nwi->
pos_x;
698 int sec_right = sec_left + nwi->
current_x - 1;
703 int box_offs = (this->line_height - this->box.height) / 2;
704 int square_offs = (this->line_height - this->square.height) / 2 + 1;
709 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
711 bool sel =
HasBit(this->sel, scheme) != 0;
714 if (scheme != LS_DEFAULT) {
717 DrawString(sch_left + text_left, sch_right - text_right, y + text_offs, STR_LIVERY_DEFAULT + scheme, sel ? TC_WHITE : TC_BLACK);
721 DrawString(pri_left + text_left, pri_right - text_right, y + text_offs, STR_COLOUR_DARK_BLUE + c->livery[scheme].
colour1, sel ? TC_WHITE : TC_GOLD);
724 if (sec_right > sec_left) {
726 DrawString(sec_left + text_left, sec_right - text_right, y + text_offs, STR_COLOUR_DARK_BLUE + c->livery[scheme].
colour2, sel ? TC_WHITE : TC_GOLD);
729 y += this->line_height;
749 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
751 this->sel = 1 << scheme;
771 for (
LiveryScheme scheme = LS_BEGIN; scheme <= j; scheme++) {
773 if (scheme >= LS_END)
return;
775 if (j >= LS_END)
return;
795 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
810 if (!gui_scope)
return;
813 bool current_class_valid = this->livery_class == LC_OTHER;
815 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
817 if (_livery_class[scheme] == this->livery_class) current_class_valid =
true;
820 ClrBit(this->sel, scheme);
825 if (!current_class_valid) {
828 }
else if (data == 0) {
834 static const NWidgetPart _nested_select_company_livery_widgets [] = {
851 SetDataTip(STR_BLACK_STRING, STR_LIVERY_SECONDARY_TOOLTIP),
853 NWidget(
WWT_MATRIX, COLOUR_GREY,
WID_SCL_MATRIX),
SetMinimalSize(275, 15),
SetFill(1, 0),
SetMatrixDataTip(1, 1, STR_LIVERY_PANEL_TOOLTIP),
856 static WindowDesc _select_company_livery_desc(
860 _nested_select_company_livery_widgets,
lengthof(_nested_select_company_livery_widgets)
880 if (
_cmf_info[CMFV_EYE_COLOUR].valid_values[ge] < 2) {
884 default: NOT_REACHED();
885 case 0: pal = PALETTE_TO_BROWN;
break;
886 case 1: pal = PALETTE_TO_BLUE;
break;
887 case 2: pal = PALETTE_TO_GREEN;
break;
892 DrawSprite(SPR_GRADIENT, GENERAL_SPRITE_COLOUR(colour), x, y);
894 for (CompanyManagerFaceVariable cmfv = CMFV_CHEEKS; cmfv < CMFV_END; cmfv++) {
896 case CMFV_MOUSTACHE:
if (!has_moustache)
continue;
break;
898 case CMFV_NOSE:
if (has_moustache)
continue;
break;
899 case CMFV_TIE_EARRING:
if (!has_tie_earring)
continue;
break;
900 case CMFV_GLASSES:
if (!has_glasses)
continue;
break;
1067 const NWidgetCore *nwi_widget = this->GetWidget<NWidgetCore>(widget_index);
1069 if (is_bool_widget) {
1071 str = (val != 0) ? STR_FACE_YES : STR_FACE_NO;
1112 this->GetWidget<NWidgetStacked>(
WID_SCMF_SEL_PARTS)->SetDisplayedPlane(advanced ? 0 : SZSP_NONE);
1114 this->GetWidget<NWidgetCore>(
WID_SCMF_RANDOM_NEW_FACE)->widget_data = advanced ? STR_FACE_RANDOM : STR_FACE_NEW_FACE_BUTTON;
1118 wi->
SetDataTip(STR_FACE_SIMPLE, STR_FACE_SIMPLE_TOOLTIP);
1120 wi->SetDataTip(STR_FACE_ADVANCED, STR_FACE_ADVANCED_TOOLTIP);
1132 for (
int val = 1; val <= 12; val++) {
1140 yesno_dim.width =
max(yesno_dim.width, number_dim.width);
1141 number_dim.width = yesno_dim.width - arrows_width;
1152 size->width =
max(size->width, face_size.width);
1153 size->height =
max(size->height, face_size.height);
1431 CompanyManagerFaceVariable cmfv;
1435 default: NOT_REACHED();
1436 case 0: cmfv = this->
is_female ? CMFV_HAS_TIE_EARRING : CMFV_HAS_MOUSTACHE;
break;
1437 case 1: cmfv = CMFV_HAS_GLASSES;
break;
1443 default: NOT_REACHED();
1444 case 0: cmfv = CMFV_EYE_COLOUR;
break;
1445 case 1: cmfv = CMFV_CHIN;
break;
1446 case 2: cmfv = CMFV_EYEBROWS;
break;
1447 case 3: cmfv = this->
is_moust_male ? CMFV_MOUSTACHE : CMFV_LIPS;
break;
1448 case 4: cmfv = CMFV_NOSE;
break;
1449 case 5: cmfv = CMFV_HAIR;
break;
1450 case 6: cmfv = CMFV_JACKET;
break;
1451 case 7: cmfv = CMFV_COLLAR;
break;
1452 case 8: cmfv = CMFV_TIE_EARRING;
break;
1453 case 9: cmfv = CMFV_GLASSES;
break;
1467 if (str == NULL)
return;
1470 this->
face = strtoul(str, NULL, 10);
1483 STR_FACE_MOUSTACHE, STR_FACE_EARRING,
1484 STR_FACE_TIE, STR_FACE_EARRING,
1505 _nested_select_company_manager_face_widgets,
lengthof(_nested_select_company_manager_face_widgets)
1524 static const NWidgetPart _nested_company_infrastructure_widgets[] = {
1569 this->UpdateRailRoadTypes();
1575 void UpdateRailRoadTypes()
1592 FOR_ALL_ENGINES_OF_TYPE(e,
VEH_ROAD) {
1693 uint32 max_val = 1000;
1694 Money max_cost = 10000;
1719 size->width =
max(size->width, this->total_width);
1725 size->width =
max(size->width, count_width);
1765 DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_RAIL_SECT);
1800 DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_ROAD_SECT);
1822 DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_WATER_SECT);
1841 DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_STATION_SECT);
1860 if (!gui_scope)
return;
1862 this->UpdateRailRoadTypes();
1867 static WindowDesc _company_infrastructure_desc(
1868 WDP_AUTO,
"company_infrastructure", 0, 0,
1871 _nested_company_infrastructure_widgets,
lengthof(_nested_company_infrastructure_widgets)
1881 AllocateWindowDescFront<CompanyInfrastructureWindow>(&_company_infrastructure_desc, company);
1884 static const NWidgetPart _nested_company_widgets[] = {
1988 STR_COMPANY_VIEW_TRAINS, STR_COMPANY_VIEW_ROAD_VEHICLES, STR_COMPANY_VIEW_SHIPS, STR_COMPANY_VIEW_AIRCRAFT
2020 this->owner = (
Owner)this->window_number;
2030 bool reinit =
false;
2098 size->width =
max(size->width, face_size.width);
2099 size->height =
max(size->height, face_size.height);
2106 d.width -= offset.x;
2107 d.height -= offset.y;
2108 *size =
maxdim(*size, d);
2119 for (uint i = 0; i <
lengthof(_company_view_vehicle_count_strings); i++) {
2137 FOR_ALL_COMPANIES(c2) {
2146 #ifdef ENABLE_NETWORK
2170 d.height -= offset.y;
2171 DrawSprite(SPR_VEH_BUS_SW_VIEW, COMPANY_SPRITE_COLOUR(c->
index), r.left - offset.x, (r.top + r.bottom - d.height) / 2 - offset.y);
2183 if (amounts[0] + amounts[1] + amounts[2] + amounts[3] == 0) {
2184 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_VEHICLES_NONE);
2186 assert_compile(
lengthof(amounts) ==
lengthof(_company_view_vehicle_count_strings));
2188 for (uint i = 0; i <
lengthof(amounts); i++) {
2189 if (amounts[i] != 0) {
2191 DrawString(r.left, r.right, y, _company_view_vehicle_count_strings[i]);
2204 uint road_pieces = 0;
2209 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_NONE);
2211 if (rail_pices != 0) {
2213 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_RAIL);
2216 if (road_pieces != 0) {
2218 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_ROAD);
2223 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_WATER);
2228 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_STATION);
2233 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_AIRPORT);
2244 FOR_ALL_COMPANIES(c2) {
2245 uint amt = GetAmountOwnedBy(c, c2->
index);
2250 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_SHARES_OWNED_BY);
2257 #ifdef ENABLE_NETWORK
2260 DrawSprite(SPR_LOCK, PAL_NONE, r.left, r.top);
2354 #ifdef ENABLE_NETWORK
2356 if (this->window_number ==
_local_company) ShowNetworkCompanyPasswordWindow(
this);
2399 if (str == NULL)
return;
2401 switch (this->query_widget) {
2402 default: NOT_REACHED();
2412 #ifdef ENABLE_NETWORK
2455 _nested_company_widgets,
lengthof(_nested_company_widgets)
2466 AllocateWindowDescFront<CompanyWindow>(&_company_desc, company);
2544 static const NWidgetPart _nested_buy_company_widgets[] = {
2567 _nested_buy_company_widgets,
lengthof(_nested_buy_company_widgets)
2576 AllocateWindowDescFront<BuyCompanyWindow>(&_buy_company_desc, company);