Codechange: Draw station acceptance text in its own widget.

This commit is contained in:
Peter Nelson
2021-05-04 12:35:27 +01:00
committed by PeterN
parent f011a559d0
commit 8626090b24
6 changed files with 37 additions and 47 deletions

View File

@@ -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<NWidgetBase>(BDSW_LT_OFF)->pos_y + this->GetWidget<NWidgetBase>(BDSW_LT_OFF)->current_y + WD_PAR_VSEP_NORMAL;
NWidgetBase *back_nwi = this->GetWidget<NWidgetBase>(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<NWidgetBase>(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(),
};