From 88623be8dacdedc1d4a8cc12cb148d8fad82fc6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Mon, 29 Sep 2025 13:47:48 +0300 Subject: [PATCH] Add force redraw debug paint option --- data/language/en-GB.txt | 1 + src/openrct2-ui/UiStringIds.h | 1 + .../engines/opengl/OpenGLDrawingEngine.cpp | 2 +- src/openrct2-ui/windows/DebugPaint.cpp | 10 +++++++++- src/openrct2/drawing/Drawing.cpp | 2 ++ src/openrct2/drawing/Drawing.h | 1 + src/openrct2/drawing/X8DrawingEngine.cpp | 18 +++++++++++++----- 7 files changed, 28 insertions(+), 7 deletions(-) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index aa8a441518..4c49b555b8 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -3842,3 +3842,4 @@ STR_7000 :or STR_7001 :Ride name STR_7002 :{STRINGID} {STRINGID} STR_7003 :Audio file ‘{STRING}’ is truncated. Expected sample {INT32}, but only {INT32} are available. Consider reinstalling RCT2. +STR_7004 :Force Redraw diff --git a/src/openrct2-ui/UiStringIds.h b/src/openrct2-ui/UiStringIds.h index c5d11309aa..eeeb28c011 100644 --- a/src/openrct2-ui/UiStringIds.h +++ b/src/openrct2-ui/UiStringIds.h @@ -474,6 +474,7 @@ namespace OpenRCT2 STR_DEBUG_PAINT_SHOW_SEGMENT_HEIGHTS = 5901, STR_DEBUG_PAINT_SHOW_WIDE_PATHS = 6261, STR_DEBUG_PAINT_STABLE_SORT = 6710, + STR_DEBUG_PAINT_FORCE_REDRAW = 7004, // Window: DemolishRidePrompt STR_DEMOLISH = 994, diff --git a/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp b/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp index f0f09b81f2..01221e9941 100644 --- a/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp @@ -366,7 +366,7 @@ public: void PaintWindows() override { - if (ClimateHasWeatherEffect()) + if (ClimateHasWeatherEffect() || gPaintForceRedraw) { WindowUpdateAllViewports(); // OpenGL doesn't support restoring pixels, always redraw. diff --git a/src/openrct2-ui/windows/DebugPaint.cpp b/src/openrct2-ui/windows/DebugPaint.cpp index ac5924bcae..74f8370998 100644 --- a/src/openrct2-ui/windows/DebugPaint.cpp +++ b/src/openrct2-ui/windows/DebugPaint.cpp @@ -29,9 +29,10 @@ namespace OpenRCT2::Ui::Windows WIDX_TOGGLE_SHOW_BOUND_BOXES, WIDX_TOGGLE_SHOW_DIRTY_VISUALS, WIDX_TOGGLE_STABLE_PAINT_SORT, + WIDX_TOGGLE_FORCE_REDRAW, }; - static constexpr ScreenSize kWindowSize = { 200, 8 + (15 * 6) + 8 }; + static constexpr ScreenSize kWindowSize = { 200, 8 + (15 * 7) + 8 }; // clang-format off static constexpr Widget window_debug_paint_widgets[] = { @@ -42,6 +43,7 @@ namespace OpenRCT2::Ui::Windows makeWidget({8, 8 + 15 * 3}, { 185, 12}, WidgetType::checkbox, WindowColour::secondary, STR_DEBUG_PAINT_SHOW_BOUND_BOXES ), makeWidget({8, 8 + 15 * 4}, { 185, 12}, WidgetType::checkbox, WindowColour::secondary, STR_DEBUG_PAINT_SHOW_DIRTY_VISUALS ), makeWidget({8, 8 + 15 * 5}, { 185, 12}, WidgetType::checkbox, WindowColour::secondary, STR_DEBUG_PAINT_STABLE_SORT ), + makeWidget({8, 8 + 15 * 6}, { 185, 12}, WidgetType::checkbox, WindowColour::secondary, STR_DEBUG_PAINT_FORCE_REDRAW ), }; // clang-format on @@ -97,6 +99,11 @@ namespace OpenRCT2::Ui::Windows gPaintStableSort = !gPaintStableSort; GfxInvalidateScreen(); break; + + case WIDX_TOGGLE_FORCE_REDRAW: + gPaintForceRedraw = !gPaintForceRedraw; + GfxInvalidateScreen(); + break; } } @@ -143,6 +150,7 @@ namespace OpenRCT2::Ui::Windows setCheckboxValue(WIDX_TOGGLE_SHOW_BOUND_BOXES, gPaintBoundingBoxes); setCheckboxValue(WIDX_TOGGLE_SHOW_DIRTY_VISUALS, gShowDirtyVisuals); setCheckboxValue(WIDX_TOGGLE_STABLE_PAINT_SORT, gPaintStableSort); + setCheckboxValue(WIDX_TOGGLE_FORCE_REDRAW, gPaintForceRedraw); } void onDraw(RenderTarget& rt) override diff --git a/src/openrct2/drawing/Drawing.cpp b/src/openrct2/drawing/Drawing.cpp index b4064b3af7..13aa27a688 100644 --- a/src/openrct2/drawing/Drawing.cpp +++ b/src/openrct2/drawing/Drawing.cpp @@ -87,6 +87,8 @@ uint8_t gTextPalette[0x8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; +bool gPaintForceRedraw{ false }; + enum { SPR_PALETTE_3100 = 3100, diff --git a/src/openrct2/drawing/Drawing.h b/src/openrct2/drawing/Drawing.h index e6886d50e4..a39575f7b2 100644 --- a/src/openrct2/drawing/Drawing.h +++ b/src/openrct2/drawing/Drawing.h @@ -505,6 +505,7 @@ extern const TranslucentWindowPalette kTranslucentWindowPalettes[COLOUR_COUNT]; extern ImageId gPickupPeepImage; extern int32_t gPickupPeepX; extern int32_t gPickupPeepY; +extern bool gPaintForceRedraw; bool ClipDrawPixelInfo(RenderTarget& dst, RenderTarget& src, const ScreenCoordsXY& coords, int32_t width, int32_t height); void GfxSetDirtyBlocks(const ScreenRect& rect); diff --git a/src/openrct2/drawing/X8DrawingEngine.cpp b/src/openrct2/drawing/X8DrawingEngine.cpp index b0cc1840c8..021118354d 100644 --- a/src/openrct2/drawing/X8DrawingEngine.cpp +++ b/src/openrct2/drawing/X8DrawingEngine.cpp @@ -184,11 +184,19 @@ void X8DrawingEngine::EndDraw() void X8DrawingEngine::PaintWindows() { - // Redraw dirty regions before updating the viewports, otherwise - // when viewports get panned, they copy dirty pixels - DrawAllDirtyBlocks(); - WindowUpdateAllViewports(); - DrawAllDirtyBlocks(); + if (gPaintForceRedraw) + { + WindowUpdateAllViewports(); + WindowDrawAll(_mainRT, 0, 0, _width, _height); + } + else + { + // Redraw dirty regions before updating the viewports, otherwise + // when viewports get panned, they copy dirty pixels + DrawAllDirtyBlocks(); + WindowUpdateAllViewports(); + DrawAllDirtyBlocks(); + } } void X8DrawingEngine::PaintWeather()