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();
348 if (wid_offset <= age) {
357 DrawString(r.left, r.right, r.top, STR_FINANCES_TOTAL_CURRENCY, TC_FROMSTRING,
SA_RIGHT);
364 DrawString(r.left, r.right, r.top, STR_FINANCES_TOTAL_CURRENCY, TC_FROMSTRING,
SA_RIGHT);
371 DrawString(r.left, r.right, r.top, STR_FINANCES_TOTAL_CURRENCY, TC_FROMSTRING,
SA_RIGHT);
388 this->GetWidget<NWidgetStacked>(
WID_CF_SEL_PANEL)->SetDisplayedPlane(plane);
402 if (_expenses_list_types[type].GetHeight() != this->GetWidget<NWidgetBase>(
WID_CF_EXPS_CATEGORY)->current_y) {
473 _nested_company_finances_widgets,
lengthof(_nested_company_finances_widgets)
490 static const StringID _colour_dropdown[] = {
491 STR_COLOUR_DARK_BLUE,
492 STR_COLOUR_PALE_GREEN,
496 STR_COLOUR_LIGHT_BLUE,
498 STR_COLOUR_DARK_GREEN,
512 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,
515 LC_AIRCRAFT, LC_AIRCRAFT, LC_AIRCRAFT,
527 return _colour_dropdown[this->
result];
530 uint Height(uint width)
const
535 bool Selectable()
const
540 void Draw(
int left,
int right,
int top,
int bottom,
bool sel,
int bg_colour)
const
543 int height = bottom - top;
544 int icon_y_offset = height / 2;
548 top + icon_y_offset);
551 top + text_y_offset, this->String(), sel ? TC_WHITE : TC_BLACK);
564 void ShowColourDropDownMenu(uint32 widget)
566 uint32 used_colours = 0;
573 FOR_ALL_COMPANIES(c) {
579 for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
580 if (
HasBit(this->sel, scheme))
break;
582 if (scheme == LS_END) scheme = LS_DEFAULT;
586 for (uint i = 0; i <
lengthof(_colour_dropdown); i++) {
596 this->livery_class = LC_OTHER;
604 this->
owner = company;
615 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
623 uint livery_height = 0;
624 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
629 size->height = livery_height * this->line_height;
641 int padding = this->square.width + NWidgetScrollbar::GetVerticalDimension().width + 10;
642 for (
const StringID *
id = _colour_dropdown;
id !=
endof(_colour_dropdown);
id++) {
667 if (this->sel != 0) {
668 for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
669 if (
HasBit(this->sel, scheme))
break;
671 if (scheme == LS_END) scheme = LS_DEFAULT;
687 int sch_left = nwi->
pos_x;
688 int sch_right = sch_left + nwi->
current_x - 1;
691 int pri_left = nwi->
pos_x;
692 int pri_right = pri_left + nwi->
current_x - 1;
695 int sec_left = nwi->
pos_x;
696 int sec_right = sec_left + nwi->
current_x - 1;
701 int box_offs = (this->line_height - this->box.height) / 2;
702 int square_offs = (this->line_height - this->square.height) / 2 + 1;
707 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
709 bool sel =
HasBit(this->sel, scheme) != 0;
712 if (scheme != LS_DEFAULT) {
715 DrawString(sch_left + text_left, sch_right - text_right, y + text_offs, STR_LIVERY_DEFAULT + scheme, sel ? TC_WHITE : TC_BLACK);
719 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);
722 if (sec_right > sec_left) {
724 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);
727 y += this->line_height;
747 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
749 this->sel = 1 << scheme;
769 for (
LiveryScheme scheme = LS_BEGIN; scheme <= j; scheme++) {
771 if (scheme >= LS_END)
return;
773 if (j >= LS_END)
return;
793 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
808 if (!gui_scope)
return;
811 bool current_class_valid = this->livery_class == LC_OTHER;
813 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
815 if (_livery_class[scheme] == this->livery_class) current_class_valid =
true;
818 ClrBit(this->sel, scheme);
823 if (!current_class_valid) {
826 }
else if (data == 0) {
832 static const NWidgetPart _nested_select_company_livery_widgets [] = {
849 SetDataTip(STR_BLACK_STRING, STR_LIVERY_SECONDARY_TOOLTIP),
851 NWidget(
WWT_MATRIX, COLOUR_GREY,
WID_SCL_MATRIX),
SetMinimalSize(275, 15),
SetFill(1, 0),
SetMatrixDataTip(1, 1, STR_LIVERY_PANEL_TOOLTIP),
854 static WindowDesc _select_company_livery_desc(
858 _nested_select_company_livery_widgets,
lengthof(_nested_select_company_livery_widgets)
878 if (
_cmf_info[CMFV_EYE_COLOUR].valid_values[ge] < 2) {
882 default: NOT_REACHED();
883 case 0: pal = PALETTE_TO_BROWN;
break;
884 case 1: pal = PALETTE_TO_BLUE;
break;
885 case 2: pal = PALETTE_TO_GREEN;
break;
890 DrawSprite(SPR_GRADIENT, GENERAL_SPRITE_COLOUR(colour), x, y);
892 for (CompanyManagerFaceVariable cmfv = CMFV_CHEEKS; cmfv < CMFV_END; cmfv++) {
894 case CMFV_MOUSTACHE:
if (!has_moustache)
continue;
break;
896 case CMFV_NOSE:
if (has_moustache)
continue;
break;
897 case CMFV_TIE_EARRING:
if (!has_tie_earring)
continue;
break;
898 case CMFV_GLASSES:
if (!has_glasses)
continue;
break;
1065 const NWidgetCore *nwi_widget = this->GetWidget<NWidgetCore>(widget_index);
1067 if (is_bool_widget) {
1069 str = (val != 0) ? STR_FACE_YES : STR_FACE_NO;
1110 this->GetWidget<NWidgetStacked>(
WID_SCMF_SEL_PARTS)->SetDisplayedPlane(advanced ? 0 : SZSP_NONE);
1112 this->GetWidget<NWidgetCore>(
WID_SCMF_RANDOM_NEW_FACE)->widget_data = advanced ? STR_FACE_RANDOM : STR_FACE_NEW_FACE_BUTTON;
1116 wi->
SetDataTip(STR_FACE_SIMPLE, STR_FACE_SIMPLE_TOOLTIP);
1118 wi->SetDataTip(STR_FACE_ADVANCED, STR_FACE_ADVANCED_TOOLTIP);
1130 for (
int val = 1; val <= 12; val++) {
1138 yesno_dim.width =
max(yesno_dim.width, number_dim.width);
1139 number_dim.width = yesno_dim.width - arrows_width;
1150 size->width =
max(size->width, face_size.width);
1151 size->height =
max(size->height, face_size.height);
1429 CompanyManagerFaceVariable cmfv;
1433 default: NOT_REACHED();
1434 case 0: cmfv = this->
is_female ? CMFV_HAS_TIE_EARRING : CMFV_HAS_MOUSTACHE;
break;
1435 case 1: cmfv = CMFV_HAS_GLASSES;
break;
1441 default: NOT_REACHED();
1442 case 0: cmfv = CMFV_EYE_COLOUR;
break;
1443 case 1: cmfv = CMFV_CHIN;
break;
1444 case 2: cmfv = CMFV_EYEBROWS;
break;
1445 case 3: cmfv = this->
is_moust_male ? CMFV_MOUSTACHE : CMFV_LIPS;
break;
1446 case 4: cmfv = CMFV_NOSE;
break;
1447 case 5: cmfv = CMFV_HAIR;
break;
1448 case 6: cmfv = CMFV_JACKET;
break;
1449 case 7: cmfv = CMFV_COLLAR;
break;
1450 case 8: cmfv = CMFV_TIE_EARRING;
break;
1451 case 9: cmfv = CMFV_GLASSES;
break;
1465 if (str == NULL)
return;
1468 this->
face = strtoul(str, NULL, 10);
1481 STR_FACE_MOUSTACHE, STR_FACE_EARRING,
1482 STR_FACE_TIE, STR_FACE_EARRING,
1503 _nested_select_company_manager_face_widgets,
lengthof(_nested_select_company_manager_face_widgets)
1522 static const NWidgetPart _nested_company_infrastructure_widgets[] = {
1567 this->UpdateRailRoadTypes();
1573 void UpdateRailRoadTypes()
1590 FOR_ALL_ENGINES_OF_TYPE(e,
VEH_ROAD) {
1691 uint32 max_val = 1000;
1692 Money max_cost = 10000;
1717 size->width =
max(size->width, this->total_width);
1723 size->width =
max(size->width, count_width);
1763 DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_RAIL_SECT);
1798 DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_ROAD_SECT);
1820 DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_WATER_SECT);
1839 DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_STATION_SECT);
1858 if (!gui_scope)
return;
1860 this->UpdateRailRoadTypes();
1865 static WindowDesc _company_infrastructure_desc(
1866 WDP_AUTO,
"company_infrastructure", 0, 0,
1869 _nested_company_infrastructure_widgets,
lengthof(_nested_company_infrastructure_widgets)
1879 AllocateWindowDescFront<CompanyInfrastructureWindow>(&_company_infrastructure_desc, company);
1882 static const NWidgetPart _nested_company_widgets[] = {
1986 STR_COMPANY_VIEW_TRAINS, STR_COMPANY_VIEW_ROAD_VEHICLES, STR_COMPANY_VIEW_SHIPS, STR_COMPANY_VIEW_AIRCRAFT
2018 this->owner = (
Owner)this->window_number;
2028 bool reinit =
false;
2096 size->width =
max(size->width, face_size.width);
2097 size->height =
max(size->height, face_size.height);
2104 d.width -= offset.x;
2105 d.height -= offset.y;
2106 *size =
maxdim(*size, d);
2117 for (uint i = 0; i <
lengthof(_company_view_vehicle_count_strings); i++) {
2135 FOR_ALL_COMPANIES(c2) {
2144 #ifdef ENABLE_NETWORK
2168 d.height -= offset.y;
2169 DrawSprite(SPR_VEH_BUS_SW_VIEW, COMPANY_SPRITE_COLOUR(c->
index), r.left - offset.x, (r.top + r.bottom - d.height) / 2 - offset.y);
2181 if (amounts[0] + amounts[1] + amounts[2] + amounts[3] == 0) {
2182 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_VEHICLES_NONE);
2184 assert_compile(
lengthof(amounts) ==
lengthof(_company_view_vehicle_count_strings));
2186 for (uint i = 0; i <
lengthof(amounts); i++) {
2187 if (amounts[i] != 0) {
2189 DrawString(r.left, r.right, y, _company_view_vehicle_count_strings[i]);
2202 uint road_pieces = 0;
2207 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_NONE);
2209 if (rail_pices != 0) {
2211 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_RAIL);
2214 if (road_pieces != 0) {
2216 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_ROAD);
2221 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_WATER);
2226 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_STATION);
2231 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_AIRPORT);
2242 FOR_ALL_COMPANIES(c2) {
2243 uint amt = GetAmountOwnedBy(c, c2->
index);
2248 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_SHARES_OWNED_BY);
2255 #ifdef ENABLE_NETWORK
2258 DrawSprite(SPR_LOCK, PAL_NONE, r.left, r.top);
2352 #ifdef ENABLE_NETWORK
2354 if (this->window_number ==
_local_company) ShowNetworkCompanyPasswordWindow(
this);
2397 if (str == NULL)
return;
2399 switch (this->query_widget) {
2400 default: NOT_REACHED();
2410 #ifdef ENABLE_NETWORK
2453 _nested_company_widgets,
lengthof(_nested_company_widgets)
2464 AllocateWindowDescFront<CompanyWindow>(&_company_desc, company);
2542 static const NWidgetPart _nested_buy_company_widgets[] = {
2565 _nested_buy_company_widgets,
lengthof(_nested_buy_company_widgets)
2574 AllocateWindowDescFront<BuyCompanyWindow>(&_buy_company_desc, company);