diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 6700cd3bd0..2e146f440d 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -29,6 +29,7 @@ #include "command_func.h" #include "airport_cmd.h" #include "station_cmd.h" +#include "zoom_func.h" #include "widgets/airport_widget.h" @@ -423,11 +424,8 @@ public: { this->DrawWidgets(); - uint16 top = this->GetWidget(WID_AP_BTN_DOHILIGHT)->pos_y + this->GetWidget(WID_AP_BTN_DOHILIGHT)->current_y + WD_PAR_VSEP_NORMAL; - NWidgetBase *panel_nwi = this->GetWidget(WID_AP_BOTTOMPANEL); - - int right = panel_nwi->pos_x + panel_nwi->current_x; - int bottom = panel_nwi->pos_y + panel_nwi->current_y; + Rect r = this->GetWidget(WID_AP_ACCEPTANCE)->GetCurrentRect(); + int top = r.top + ScaleGUITrad(WD_PAR_VSEP_NORMAL); if (_selected_airport_index != -1) { const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index); @@ -437,20 +435,20 @@ public: if (_settings_game.economy.station_noise_level) { /* show the noise of the selected airport */ SetDParam(0, as->noise_level); - DrawString(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, STR_STATION_BUILD_NOISE); - top += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL; + DrawString(r.left, r.right, top, STR_STATION_BUILD_NOISE); + top += FONT_HEIGHT_NORMAL + ScaleGUITrad(WD_PAR_VSEP_NORMAL); } /* strings such as 'Size' and 'Coverage Area' */ - top = DrawStationCoverageAreaText(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL; - top = DrawStationCoverageAreaText(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL; + top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + ScaleGUITrad(WD_PAR_VSEP_NORMAL); + top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true) + ScaleGUITrad(WD_PAR_VSEP_NORMAL); } /* Resize background if the window is too small. * Never make the window smaller to avoid oscillating if the size change affects the acceptance. * (This is the case, if making the window bigger moves the mouse into the window.) */ - if (top > bottom) { - ResizeWindow(this, 0, top - bottom, false); + if (top > r.bottom) { + ResizeWindow(this, 0, top - r.bottom, false); } } @@ -608,7 +606,7 @@ static const NWidgetPart _nested_build_airport_widgets[] = { EndContainer(), NWidget(NWID_SPACER), SetMinimalSize(14, 0), SetFill(1, 0), EndContainer(), - NWidget(NWID_SPACER), SetMinimalSize(0, 10), SetResize(0, 1), SetFill(1, 0), + NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_AP_ACCEPTANCE), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT), SetResize(0, 1), SetFill(1, 0), EndContainer(), }; diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 2ec10fe8ce..d86e3ad068 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -416,6 +416,7 @@ enum BuildDockStationWidgets { BDSW_LT_OFF, ///< 'Off' button of coverage high light. BDSW_LT_ON, ///< 'On' button of coverage high light. BDSW_INFO, ///< 'Coverage highlight' label. + BDSW_ACCEPTANCE, ///< Acceptance info. }; struct BuildDocksStationWindow : public PickerWindowBase { @@ -445,17 +446,15 @@ public: } /* strings such as 'Size' and 'Coverage Area' */ - int top = this->GetWidget(BDSW_LT_OFF)->pos_y + this->GetWidget(BDSW_LT_OFF)->current_y + WD_PAR_VSEP_NORMAL; - NWidgetBase *back_nwi = this->GetWidget(BDSW_BACKGROUND); - int right = back_nwi->pos_x + back_nwi->current_x; - int bottom = back_nwi->pos_y + back_nwi->current_y; - top = DrawStationCoverageAreaText(back_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL; - top = DrawStationCoverageAreaText(back_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL; + Rect r = this->GetWidget(BDSW_ACCEPTANCE)->GetCurrentRect(); + int top = r.top + ScaleGUITrad(WD_PAR_VSEP_NORMAL); + top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + ScaleGUITrad(WD_PAR_VSEP_NORMAL); + top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true) + ScaleGUITrad(WD_PAR_VSEP_NORMAL); /* Resize background if the window is too small. * Never make the window smaller to avoid oscillating if the size change affects the acceptance. * (This is the case, if making the window bigger moves the mouse into the window.) */ - if (top > bottom) { - ResizeWindow(this, 0, top - bottom, false); + if (top > r.bottom) { + ResizeWindow(this, 0, top - r.bottom, false); } } @@ -493,7 +492,7 @@ static const NWidgetPart _nested_build_dock_station_widgets[] = { NWidget(WWT_TEXTBTN, COLOUR_GREY, BDSW_LT_OFF), SetMinimalSize(40, 12), SetFill(1, 0), SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP), NWidget(WWT_TEXTBTN, COLOUR_GREY, BDSW_LT_ON), SetMinimalSize(40, 12), SetFill(1, 0), SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP), EndContainer(), - NWidget(NWID_SPACER), SetMinimalSize(0, 20), SetResize(0, 1), + NWidget(WWT_EMPTY, COLOUR_GREY, BDSW_ACCEPTANCE), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT), SetResize(0, 1), EndContainer(), }; diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 9a813407ba..b73e66da2b 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1179,18 +1179,15 @@ public: if (this->IsShaded()) return; /* 'Accepts' and 'Supplies' texts. */ - NWidgetBase *cov = this->GetWidget(WID_BRAS_COVERAGE_TEXTS); - int top = cov->pos_y + WD_PAR_VSEP_NORMAL; - int left = cov->pos_x + WD_FRAMERECT_LEFT; - int right = cov->pos_x + cov->current_x - WD_FRAMERECT_RIGHT; - int bottom = cov->pos_y + cov->current_y; - top = DrawStationCoverageAreaText(left, right, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL; - top = DrawStationCoverageAreaText(left, right, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL; + Rect r = this->GetWidget(WID_BRAS_COVERAGE_TEXTS)->GetCurrentRect(); + int top = r.top + ScaleGUITrad(WD_PAR_VSEP_NORMAL); + top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + ScaleGUITrad(WD_PAR_VSEP_NORMAL); + top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true) + ScaleGUITrad(WD_PAR_VSEP_NORMAL); /* Resize background if the window is too small. * Never make the window smaller to avoid oscillating if the size change affects the acceptance. * (This is the case, if making the window bigger moves the mouse into the window.) */ - if (top > bottom) { - this->coverage_height += top - bottom; + if (top > r.bottom) { + this->coverage_height += top - r.bottom; this->ReInit(); } } @@ -1637,7 +1634,7 @@ static const NWidgetPart _nested_station_builder_widgets[] = { EndContainer(), EndContainer(), NWidget(NWID_HORIZONTAL), - NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BRAS_COVERAGE_TEXTS), SetPadding(2, 5, 0, 1), SetFill(1, 1), SetResize(1, 0), + NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BRAS_COVERAGE_TEXTS), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT), SetFill(1, 1), SetResize(1, 0), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BRAS_SHOW_NEWST_RESIZE), NWidget(NWID_VERTICAL), NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetFill(0, 1), EndContainer(), diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 80a8ed618c..e57d54b19b 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -1090,17 +1090,15 @@ struct BuildRoadStationWindow : public PickerWindowBase { /* 'Accepts' and 'Supplies' texts. */ StationCoverageType sct = (this->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY; - int top = this->GetWidget(WID_BROS_LT_ON)->pos_y + this->GetWidget(WID_BROS_LT_ON)->current_y + WD_PAR_VSEP_NORMAL; - NWidgetBase *back_nwi = this->GetWidget(WID_BROS_BACKGROUND); - int right = back_nwi->pos_x + back_nwi->current_x; - int bottom = back_nwi->pos_y + back_nwi->current_y; - top = DrawStationCoverageAreaText(back_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, sct, rad, false) + WD_PAR_VSEP_NORMAL; - top = DrawStationCoverageAreaText(back_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, sct, rad, true) + WD_PAR_VSEP_NORMAL; + Rect r = this->GetWidget(WID_BROS_ACCEPTANCE)->GetCurrentRect(); + int top = r.top + ScaleGUITrad(WD_PAR_VSEP_NORMAL); + top = DrawStationCoverageAreaText(r.left, r.right, top, sct, rad, false) + ScaleGUITrad(WD_PAR_VSEP_NORMAL); + top = DrawStationCoverageAreaText(r.left, r.right, top, sct, rad, true) + ScaleGUITrad(WD_PAR_VSEP_NORMAL); /* Resize background if the window is too small. * Never make the window smaller to avoid oscillating if the size change affects the acceptance. * (This is the case, if making the window bigger moves the mouse into the window.) */ - if (top > bottom) { - ResizeWindow(this, 0, top - bottom, false); + if (top > r.bottom) { + ResizeWindow(this, 0, top - r.bottom, false); } } @@ -1194,7 +1192,7 @@ static const NWidgetPart _nested_road_station_picker_widgets[] = { SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP), NWidget(NWID_SPACER), SetFill(1, 0), EndContainer(), - NWidget(NWID_SPACER), SetMinimalSize(0, 10), SetResize(0, 1), + NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_BROS_ACCEPTANCE), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT), SetResize(0, 1), EndContainer(), }; @@ -1219,11 +1217,7 @@ static const NWidgetPart _nested_tram_station_picker_widgets[] = { NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(), NWidget(NWID_SPACER), SetFill(1, 0), EndContainer(), - NWidget(NWID_SPACER), SetMinimalSize(0, 1), - NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2), - NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_INFO), SetMinimalSize(140, 14), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), - NWidget(NWID_SPACER), SetFill(1, 0), - EndContainer(), + NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_INFO), SetPadding(WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT), SetMinimalSize(140, 14), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0), NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2), NWidget(NWID_SPACER), SetFill(1, 0), NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_OFF), SetMinimalSize(60, 12), @@ -1232,7 +1226,7 @@ static const NWidgetPart _nested_tram_station_picker_widgets[] = { SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP), NWidget(NWID_SPACER), SetFill(1, 0), EndContainer(), - NWidget(NWID_SPACER), SetMinimalSize(0, 10), SetResize(0, 1), + NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_BROS_ACCEPTANCE), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT), SetResize(0, 1), EndContainer(), }; diff --git a/src/widgets/airport_widget.h b/src/widgets/airport_widget.h index da0770bcb9..75b805031c 100644 --- a/src/widgets/airport_widget.h +++ b/src/widgets/airport_widget.h @@ -30,6 +30,7 @@ enum AirportPickerWidgets { WID_AP_COVERAGE_LABEL, ///< Label if you want to see the coverage. WID_AP_BTN_DONTHILIGHT, ///< Don't show the coverage button. WID_AP_BTN_DOHILIGHT, ///< Show the coverage button. + WID_AP_ACCEPTANCE, ///< Acceptance info. }; #endif /* WIDGETS_AIRPORT_WIDGET_H */ diff --git a/src/widgets/road_widget.h b/src/widgets/road_widget.h index 3d49e9ae9d..425031e05b 100644 --- a/src/widgets/road_widget.h +++ b/src/widgets/road_widget.h @@ -51,7 +51,8 @@ enum BuildRoadStationWidgets { WID_BROS_STATION_Y, ///< Drive-through station in y-direction. WID_BROS_LT_OFF, ///< Turn off area highlight. WID_BROS_LT_ON, ///< Turn on area highlight. - WID_BROS_INFO, ///< Station acceptance info. + WID_BROS_INFO, ///< Station acceptance toggle. + WID_BROS_ACCEPTANCE, ///< Station acceptance. }; #endif /* WIDGETS_ROAD_WIDGET_H */