From 7466c3c39e2fa32e55a599aa792011b62bfcb54a Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Wed, 20 Dec 2023 00:20:51 +0000 Subject: [PATCH] Fix: Draw unavailable mask over picker sprite instead of behind it. This makes these disabled picker buttons consistent with other disabled buttons. --- src/object_gui.cpp | 6 +++--- src/rail_gui.cpp | 8 ++++---- src/road_gui.cpp | 9 ++++----- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/object_gui.cpp b/src/object_gui.cpp index 7e84be8c16..084cd0caed 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -358,9 +358,6 @@ public: const ObjectSpec *spec = objclass->GetSpec(obj_index); if (spec == nullptr) break; - if (!spec->IsAvailable()) { - GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK, FILLRECT_CHECKER); - } DrawPixelInfo tmp_dpi; /* Set up a clipping area for the preview. */ Rect ir = r.Shrink(WidgetDimensions::scaled.bevel); @@ -375,6 +372,9 @@ public: std::min(_selected_object_view, spec->views - 1)); } } + if (!spec->IsAvailable()) { + GfxFillRect(ir, PC_BLACK, FILLRECT_CHECKER); + } break; } diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 82e67da2ca..c655852820 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1289,9 +1289,6 @@ public: assert(type < _railstation.station_count); /* Check station availability callback */ const StationSpec *statspec = StationClass::Get(_railstation.station_class)->GetSpec(type); - if (!IsStationAvailable(statspec)) { - GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK, FILLRECT_CHECKER); - } /* Set up a clipping area for the station preview. */ Rect ir = r.Shrink(WidgetDimensions::scaled.bevel); @@ -1303,6 +1300,9 @@ public: StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2 + _railstation.orientation); } } + if (!IsStationAvailable(statspec)) { + GfxFillRect(ir, PC_BLACK, FILLRECT_CHECKER); + } break; } } @@ -2110,7 +2110,7 @@ struct BuildRailWaypointWindow : PickerWindowBase { } if (!IsStationAvailable(statspec)) { - GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK, FILLRECT_CHECKER); + GfxFillRect(ir, PC_BLACK, FILLRECT_CHECKER); } } } diff --git a/src/road_gui.cpp b/src/road_gui.cpp index cd00b7ad3e..1364a0c94a 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -1425,11 +1425,11 @@ public: int y = (ir.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31); if (spec == nullptr || disabled) { StationPickerDrawSprite(x, y, st, INVALID_RAILTYPE, _cur_roadtype, widget - WID_BROS_STATION_NE); - if (disabled) GfxFillRect(0, 0, ir.Width(), ir.Height(), PC_BLACK, FILLRECT_CHECKER); } else { DrawRoadStopTile(x, y, _cur_roadtype, spec, st, widget - WID_BROS_STATION_NE); } } + if (disabled) GfxFillRect(ir, PC_BLACK, FILLRECT_CHECKER); break; } @@ -1455,10 +1455,6 @@ public: const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(type); StationType st = GetRoadStationTypeByWindowClass(this->window_class); - if (!IsRoadStopAvailable(spec, st)) { - GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK, FILLRECT_CHECKER); - } - /* Set up a clipping area for the sprite preview. */ DrawPixelInfo tmp_dpi; Rect ir = r.Shrink(WidgetDimensions::scaled.bevel); @@ -1474,6 +1470,9 @@ public: DrawRoadStopTile(x, y, _cur_roadtype, spec, st, (uint8_t)orientation); } } + if (!IsRoadStopAvailable(spec, st)) { + GfxFillRect(ir, PC_BLACK, FILLRECT_CHECKER); + } break; } }