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;
547 DrawString(rtl ? left + 2 : left +
UnScaleByZoom(4 * 28, ZOOM_LVL_GUI) + 4, rtl ? right -
UnScaleByZoom(4 * 28, ZOOM_LVL_GUI) - 4 : right - 2, top + text_y_offset, this->String(), sel ? TC_WHITE : TC_BLACK);
560 void ShowColourDropDownMenu(uint32 widget)
562 uint32 used_colours = 0;
569 FOR_ALL_COMPANIES(c) {
575 for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
576 if (
HasBit(this->sel, scheme))
break;
578 if (scheme == LS_END) scheme = LS_DEFAULT;
582 for (uint i = 0; i <
lengthof(_colour_dropdown); i++) {
592 this->livery_class = LC_OTHER;
600 this->
owner = company;
611 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
619 uint livery_height = 0;
620 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
625 size->height = livery_height * this->line_height;
637 int padding = this->square.width + NWidgetScrollbar::GetVerticalDimension().width + 10;
638 for (
const StringID *
id = _colour_dropdown;
id !=
endof(_colour_dropdown);
id++) {
663 if (this->sel != 0) {
664 for (scheme = LS_BEGIN; scheme < LS_END; scheme++) {
665 if (
HasBit(this->sel, scheme))
break;
667 if (scheme == LS_END) scheme = LS_DEFAULT;
683 int sch_left = nwi->
pos_x;
684 int sch_right = sch_left + nwi->
current_x - 1;
687 int pri_left = nwi->
pos_x;
688 int pri_right = pri_left + nwi->
current_x - 1;
691 int sec_left = nwi->
pos_x;
692 int sec_right = sec_left + nwi->
current_x - 1;
697 int box_offs = (this->line_height - this->box.height) / 2;
698 int square_offs = (this->line_height - this->square.height) / 2 + 1;
703 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
705 bool sel =
HasBit(this->sel, scheme) != 0;
708 if (scheme != LS_DEFAULT) {
711 DrawString(sch_left + text_left, sch_right - text_right, y + text_offs, STR_LIVERY_DEFAULT + scheme, sel ? TC_WHITE : TC_BLACK);
715 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);
718 if (sec_right > sec_left) {
720 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);
723 y += this->line_height;
743 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
745 this->sel = 1 << scheme;
765 for (
LiveryScheme scheme = LS_BEGIN; scheme <= j; scheme++) {
767 if (scheme >= LS_END)
return;
769 if (j >= LS_END)
return;
789 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
804 if (!gui_scope)
return;
807 bool current_class_valid = this->livery_class == LC_OTHER;
809 for (
LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
811 if (_livery_class[scheme] == this->livery_class) current_class_valid =
true;
814 ClrBit(this->sel, scheme);
819 if (!current_class_valid) {
822 }
else if (data == 0) {
828 static const NWidgetPart _nested_select_company_livery_widgets [] = {
845 SetDataTip(STR_BLACK_STRING, STR_LIVERY_SECONDARY_TOOLTIP),
847 NWidget(
WWT_MATRIX, COLOUR_GREY,
WID_SCL_MATRIX),
SetMinimalSize(275, 15),
SetFill(1, 0),
SetMatrixDataTip(1, 1, STR_LIVERY_PANEL_TOOLTIP),
850 static WindowDesc _select_company_livery_desc(
854 _nested_select_company_livery_widgets,
lengthof(_nested_select_company_livery_widgets)
874 if (
_cmf_info[CMFV_EYE_COLOUR].valid_values[ge] < 2) {
878 default: NOT_REACHED();
879 case 0: pal = PALETTE_TO_BROWN;
break;
880 case 1: pal = PALETTE_TO_BLUE;
break;
881 case 2: pal = PALETTE_TO_GREEN;
break;
886 DrawSprite(SPR_GRADIENT, GENERAL_SPRITE_COLOUR(colour), x, y);
888 for (CompanyManagerFaceVariable cmfv = CMFV_CHEEKS; cmfv < CMFV_END; cmfv++) {
890 case CMFV_MOUSTACHE:
if (!has_moustache)
continue;
break;
892 case CMFV_NOSE:
if (has_moustache)
continue;
break;
893 case CMFV_TIE_EARRING:
if (!has_tie_earring)
continue;
break;
894 case CMFV_GLASSES:
if (!has_glasses)
continue;
break;
1061 const NWidgetCore *nwi_widget = this->GetWidget<NWidgetCore>(widget_index);
1063 if (is_bool_widget) {
1065 str = (val != 0) ? STR_FACE_YES : STR_FACE_NO;
1106 this->GetWidget<NWidgetStacked>(
WID_SCMF_SEL_PARTS)->SetDisplayedPlane(advanced ? 0 : SZSP_NONE);
1108 this->GetWidget<NWidgetCore>(
WID_SCMF_RANDOM_NEW_FACE)->widget_data = advanced ? STR_FACE_RANDOM : STR_FACE_NEW_FACE_BUTTON;
1112 wi->
SetDataTip(STR_FACE_SIMPLE, STR_FACE_SIMPLE_TOOLTIP);
1114 wi->SetDataTip(STR_FACE_ADVANCED, STR_FACE_ADVANCED_TOOLTIP);
1126 for (
int val = 1; val <= 12; val++) {
1134 yesno_dim.width =
max(yesno_dim.width, number_dim.width);
1135 number_dim.width = yesno_dim.width - arrows_width;
1146 size->width =
max(size->width, face_size.width);
1147 size->height =
max(size->height, face_size.height);
1425 CompanyManagerFaceVariable cmfv;
1429 default: NOT_REACHED();
1430 case 0: cmfv = this->
is_female ? CMFV_HAS_TIE_EARRING : CMFV_HAS_MOUSTACHE;
break;
1431 case 1: cmfv = CMFV_HAS_GLASSES;
break;
1437 default: NOT_REACHED();
1438 case 0: cmfv = CMFV_EYE_COLOUR;
break;
1439 case 1: cmfv = CMFV_CHIN;
break;
1440 case 2: cmfv = CMFV_EYEBROWS;
break;
1441 case 3: cmfv = this->
is_moust_male ? CMFV_MOUSTACHE : CMFV_LIPS;
break;
1442 case 4: cmfv = CMFV_NOSE;
break;
1443 case 5: cmfv = CMFV_HAIR;
break;
1444 case 6: cmfv = CMFV_JACKET;
break;
1445 case 7: cmfv = CMFV_COLLAR;
break;
1446 case 8: cmfv = CMFV_TIE_EARRING;
break;
1447 case 9: cmfv = CMFV_GLASSES;
break;
1461 if (str == NULL)
return;
1464 this->
face = strtoul(str, NULL, 10);
1477 STR_FACE_MOUSTACHE, STR_FACE_EARRING,
1478 STR_FACE_TIE, STR_FACE_EARRING,
1499 _nested_select_company_manager_face_widgets,
lengthof(_nested_select_company_manager_face_widgets)
1518 static const NWidgetPart _nested_company_infrastructure_widgets[] = {
1563 this->UpdateRailRoadTypes();
1569 void UpdateRailRoadTypes()
1586 FOR_ALL_ENGINES_OF_TYPE(e,
VEH_ROAD) {
1687 uint32 max_val = 1000;
1688 Money max_cost = 10000;
1713 size->width =
max(size->width, this->total_width);
1719 size->width =
max(size->width, count_width);
1759 DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_RAIL_SECT);
1792 DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_ROAD_SECT);
1814 DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_WATER_SECT);
1833 DrawString(r.left, r.right, y, STR_COMPANY_INFRASTRUCTURE_VIEW_STATION_SECT);
1852 if (!gui_scope)
return;
1854 this->UpdateRailRoadTypes();
1859 static WindowDesc _company_infrastructure_desc(
1860 WDP_AUTO,
"company_infrastructure", 0, 0,
1863 _nested_company_infrastructure_widgets,
lengthof(_nested_company_infrastructure_widgets)
1873 AllocateWindowDescFront<CompanyInfrastructureWindow>(&_company_infrastructure_desc, company);
1876 static const NWidgetPart _nested_company_widgets[] = {
1980 STR_COMPANY_VIEW_TRAINS, STR_COMPANY_VIEW_ROAD_VEHICLES, STR_COMPANY_VIEW_SHIPS, STR_COMPANY_VIEW_AIRCRAFT
2012 this->owner = (
Owner)this->window_number;
2022 bool reinit =
false;
2090 size->width =
max(size->width, face_size.width);
2091 size->height =
max(size->height, face_size.height);
2098 d.width -= offset.x;
2099 d.height -= offset.y;
2100 *size =
maxdim(*size, d);
2111 for (uint i = 0; i <
lengthof(_company_view_vehicle_count_strings); i++) {
2129 FOR_ALL_COMPANIES(c2) {
2138 #ifdef ENABLE_NETWORK
2162 d.height -= offset.y;
2163 DrawSprite(SPR_VEH_BUS_SW_VIEW, COMPANY_SPRITE_COLOUR(c->
index), r.left - offset.x, (r.top + r.bottom - d.height) / 2 - offset.y);
2175 if (amounts[0] + amounts[1] + amounts[2] + amounts[3] == 0) {
2176 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_VEHICLES_NONE);
2178 assert_compile(
lengthof(amounts) ==
lengthof(_company_view_vehicle_count_strings));
2180 for (uint i = 0; i <
lengthof(amounts); i++) {
2181 if (amounts[i] != 0) {
2183 DrawString(r.left, r.right, y, _company_view_vehicle_count_strings[i]);
2196 uint road_pieces = 0;
2201 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_NONE);
2203 if (rail_pices != 0) {
2205 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_RAIL);
2208 if (road_pieces != 0) {
2210 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_ROAD);
2215 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_WATER);
2220 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_STATION);
2225 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_AIRPORT);
2236 FOR_ALL_COMPANIES(c2) {
2237 uint amt = GetAmountOwnedBy(c, c2->
index);
2242 DrawString(r.left, r.right, y, STR_COMPANY_VIEW_SHARES_OWNED_BY);
2249 #ifdef ENABLE_NETWORK
2252 DrawSprite(SPR_LOCK, PAL_NONE, r.left, r.top);
2312 ResetObjectToPlace();
2316 SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE,
HT_RECT,
this);
2324 ResetObjectToPlace();
2328 SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE,
HT_RECT,
this);
2346 #ifdef ENABLE_NETWORK
2348 if (this->window_number ==
_local_company) ShowNetworkCompanyPasswordWindow(
this);
2379 ResetObjectToPlace();
2391 if (str == NULL)
return;
2393 switch (this->query_widget) {
2394 default: NOT_REACHED();
2404 #ifdef ENABLE_NETWORK
2447 _nested_company_widgets,
lengthof(_nested_company_widgets)
2458 AllocateWindowDescFront<CompanyWindow>(&_company_desc, company);
2536 static const NWidgetPart _nested_buy_company_widgets[] = {
2559 _nested_buy_company_widgets,
lengthof(_nested_buy_company_widgets)
2568 AllocateWindowDescFront<BuyCompanyWindow>(&_buy_company_desc, company);