mirror of https://github.com/OpenTTD/OpenTTD.git
Change: Show 6 or 2 orientation buttons in NewGRF road stop picker as appropriate.
This replaces the normal method of masking unusable buttons.
This commit is contained in:
parent
8c22690ce1
commit
adb796a21a
|
@ -1129,8 +1129,15 @@ private:
|
||||||
|
|
||||||
void CheckOrientationValid()
|
void CheckOrientationValid()
|
||||||
{
|
{
|
||||||
if (_roadstop_gui_settings.orientation >= DIAGDIR_END) return;
|
|
||||||
const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type);
|
const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type);
|
||||||
|
|
||||||
|
/* Raise and lower to ensure the correct widget is lowered after changing displayed orientation plane. */
|
||||||
|
this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
|
||||||
|
this->GetWidget<NWidgetStacked>(WID_BROS_AVAILABLE_ORIENTATIONS)->SetDisplayedPlane((spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) ? 1 : 0);
|
||||||
|
this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
|
||||||
|
|
||||||
|
if (_roadstop_gui_settings.orientation >= DIAGDIR_END) return;
|
||||||
|
|
||||||
if (spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) {
|
if (spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) {
|
||||||
this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
|
this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
|
||||||
_roadstop_gui_settings.orientation = DIAGDIR_END;
|
_roadstop_gui_settings.orientation = DIAGDIR_END;
|
||||||
|
@ -1418,20 +1425,18 @@ public:
|
||||||
case WID_BROS_STATION_Y: {
|
case WID_BROS_STATION_Y: {
|
||||||
StationType st = GetRoadStationTypeByWindowClass(this->window_class);
|
StationType st = GetRoadStationTypeByWindowClass(this->window_class);
|
||||||
const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type);
|
const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type);
|
||||||
bool disabled = (spec != nullptr && widget < WID_BROS_STATION_X && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY));
|
|
||||||
DrawPixelInfo tmp_dpi;
|
DrawPixelInfo tmp_dpi;
|
||||||
Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
|
Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
|
||||||
if (FillDrawPixelInfo(&tmp_dpi, ir)) {
|
if (FillDrawPixelInfo(&tmp_dpi, ir)) {
|
||||||
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
|
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
|
||||||
int x = (ir.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
|
int x = (ir.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
|
||||||
int y = (ir.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
|
int y = (ir.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
|
||||||
if (spec == nullptr || disabled) {
|
if (spec == nullptr) {
|
||||||
StationPickerDrawSprite(x, y, st, INVALID_RAILTYPE, _cur_roadtype, widget - WID_BROS_STATION_NE);
|
StationPickerDrawSprite(x, y, st, INVALID_RAILTYPE, _cur_roadtype, widget - WID_BROS_STATION_NE);
|
||||||
} else {
|
} else {
|
||||||
DrawRoadStopTile(x, y, _cur_roadtype, spec, st, widget - WID_BROS_STATION_NE);
|
DrawRoadStopTile(x, y, _cur_roadtype, spec, st, widget - WID_BROS_STATION_NE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (disabled) GfxFillRect(ir, PC_BLACK, FILLRECT_CHECKER);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1540,11 +1545,11 @@ public:
|
||||||
NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BROS_MATRIX);
|
NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BROS_MATRIX);
|
||||||
matrix->SetCount(_roadstop_gui_settings.roadstop_count);
|
matrix->SetCount(_roadstop_gui_settings.roadstop_count);
|
||||||
matrix->SetClicked(_roadstop_gui_settings.roadstop_type);
|
matrix->SetClicked(_roadstop_gui_settings.roadstop_type);
|
||||||
this->CheckOrientationValid();
|
|
||||||
}
|
}
|
||||||
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
CloseWindowById(WC_SELECT_STATION, 0);
|
CloseWindowById(WC_SELECT_STATION, 0);
|
||||||
|
this->CheckOrientationValid();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1634,20 +1639,30 @@ static constexpr NWidgetPart _nested_road_station_picker_widgets[] = {
|
||||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_SHOW_NEWST_ORIENTATION),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_SHOW_NEWST_ORIENTATION),
|
||||||
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_ORIENTATION, STR_NULL), SetFill(1, 0),
|
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_ORIENTATION, STR_NULL), SetFill(1, 0),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_AVAILABLE_ORIENTATIONS),
|
||||||
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
|
/* 6-orientation plane. */
|
||||||
NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
|
NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
|
||||||
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NW), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
|
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
|
||||||
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NE), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
|
NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
|
||||||
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NW), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
|
||||||
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NE), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
|
||||||
|
EndContainer(),
|
||||||
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
|
||||||
|
EndContainer(),
|
||||||
|
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
|
||||||
|
NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
|
||||||
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SW), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
|
||||||
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SE), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
|
||||||
|
EndContainer(),
|
||||||
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
|
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
|
/* 2-orientation plane. */
|
||||||
NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
|
NWidget(NWID_VERTICAL), SetPIPRatio(0, 0, 1),
|
||||||
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SW), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
|
NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
|
||||||
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SE), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
|
||||||
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
|
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_SHOW_NEWST_TYPE_SEL),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_SHOW_NEWST_TYPE_SEL),
|
||||||
|
|
|
@ -58,6 +58,7 @@ enum BuildRoadStationWidgets : WidgetID {
|
||||||
WID_BROS_MATRIX_SCROLL, ///< Scrollbar of the #WID_BROS_SHOW_NEWST_ADDITIONS.
|
WID_BROS_MATRIX_SCROLL, ///< Scrollbar of the #WID_BROS_SHOW_NEWST_ADDITIONS.
|
||||||
WID_BROS_FILTER_CONTAINER, ///< Container for the filter text box for the road stop class list.
|
WID_BROS_FILTER_CONTAINER, ///< Container for the filter text box for the road stop class list.
|
||||||
WID_BROS_FILTER_EDITBOX, ///< Filter text box for the road stop class list.
|
WID_BROS_FILTER_EDITBOX, ///< Filter text box for the road stop class list.
|
||||||
|
WID_BROS_AVAILABLE_ORIENTATIONS, ///< Selection for selecting 6 or 2 orientations.
|
||||||
WID_BROS_SHOW_NEWST_DEFSIZE, ///< Selection for default-size button for new road stops.
|
WID_BROS_SHOW_NEWST_DEFSIZE, ///< Selection for default-size button for new road stops.
|
||||||
WID_BROS_SHOW_NEWST_ADDITIONS, ///< Selection for new class selection list.
|
WID_BROS_SHOW_NEWST_ADDITIONS, ///< Selection for new class selection list.
|
||||||
WID_BROS_SHOW_NEWST_MATRIX, ///< Selection for new stop image matrix.
|
WID_BROS_SHOW_NEWST_MATRIX, ///< Selection for new stop image matrix.
|
||||||
|
|
Loading…
Reference in New Issue