Changeset - r28312:af8ce606526d
[Not reviewed]
master
0 3 0
Peter Nelson - 6 months ago 2023-12-20 00:20:51
peter1138@openttd.org
Fix: Draw unavailable mask over picker sprite instead of behind it.

This makes these disabled picker buttons consistent with other disabled buttons.
3 files changed with 11 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/object_gui.cpp
Show inline comments
 
@@ -355,15 +355,12 @@ public:
 
				ObjectClass *objclass = ObjectClass::Get(_selected_object_class);
 
				int obj_index = objclass->GetIndexFromUI(GB(widget, 16, 16));
 
				if (obj_index < 0) break;
 
				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);
 
				if (FillDrawPixelInfo(&tmp_dpi, ir)) {
 
					AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
 
					if (spec->grf_prop.grffile == nullptr) {
 
@@ -372,12 +369,15 @@ public:
 
						DrawOrigTileSeqInGUI(ir.Width() / 2 - 1, ir.Height() - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), dts, PAL_NONE);
 
					} else {
 
						DrawNewObjectTileInGUI(ir.Width() / 2 - 1, ir.Height() - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), spec,
 
								std::min<int>(_selected_object_view, spec->views - 1));
 
					}
 
				}
 
				if (!spec->IsAvailable()) {
 
					GfxFillRect(ir, PC_BLACK, FILLRECT_CHECKER);
 
				}
 
				break;
 
			}
 

	
 
			case WID_BO_INFO: {
 
				ObjectClass *objclass = ObjectClass::Get(_selected_object_class);
 
				const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
src/rail_gui.cpp
Show inline comments
 
@@ -1286,26 +1286,26 @@ public:
 

	
 
			case WID_BRAS_IMAGE: {
 
				uint16_t type = GB(widget, 16, 16);
 
				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);
 
				if (FillDrawPixelInfo(&tmp_dpi, ir)) {
 
					AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
 
					int x = (ir.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
					int y = (ir.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(31);
 
					if (!DrawStationTile(x, y, _cur_railtype, _railstation.orientation, _railstation.station_class, type)) {
 
						StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2 + _railstation.orientation);
 
					}
 
				}
 
				if (!IsStationAvailable(statspec)) {
 
					GfxFillRect(ir, PC_BLACK, FILLRECT_CHECKER);
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void OnResize() override
 
@@ -2107,13 +2107,13 @@ struct BuildRailWaypointWindow : PickerW
 
					int x = (ir.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
					int y = (ir.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(31);
 
					DrawWaypointSprite(x, y, type, _cur_railtype);
 
				}
 

	
 
				if (!IsStationAvailable(statspec)) {
 
					GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK, FILLRECT_CHECKER);
 
					GfxFillRect(ir, PC_BLACK, FILLRECT_CHECKER);
 
				}
 
			}
 
		}
 
	}
 

	
 
	void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
src/road_gui.cpp
Show inline comments
 
@@ -1422,17 +1422,17 @@ public:
 
				if (FillDrawPixelInfo(&tmp_dpi, ir)) {
 
					AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
 
					int x = (ir.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
					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;
 
			}
 

	
 
			case WID_BROS_NEWST_LIST: {
 
				uint statclass = 0;
 
				uint row = 0;
 
@@ -1452,16 +1452,12 @@ public:
 
				uint16_t type = GB(widget, 16, 16);
 
				assert(type < _roadstop_gui_settings.roadstop_count);
 

	
 
				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);
 
				if (FillDrawPixelInfo(&tmp_dpi, ir)) {
 
					AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
 
					int x = (ir.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
@@ -1471,12 +1467,15 @@ public:
 
					} else {
 
						DiagDirection orientation = _roadstop_gui_settings.orientation;
 
						if (orientation < DIAGDIR_END && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) orientation = DIAGDIR_END;
 
						DrawRoadStopTile(x, y, _cur_roadtype, spec, st, (uint8_t)orientation);
 
					}
 
				}
 
				if (!IsRoadStopAvailable(spec, st)) {
 
					GfxFillRect(ir, PC_BLACK, FILLRECT_CHECKER);
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void OnResize() override
0 comments (0 inline, 0 general)