From 0fda25d3655cee769d9a543522a627f98f876109 Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Fri, 15 Jun 2018 14:09:14 +0200 Subject: [PATCH 1/2] Add debug option to visualize wide path flags. This implements #7694 --- data/language/en-GB.txt | 1 + distribution/changelog.txt | 1 + src/openrct2-ui/windows/DebugPaint.cpp | 21 +++++++++++++------ src/openrct2/localisation/StringIds.h | 1 + src/openrct2/paint/Paint.h | 1 + .../paint/tile_element/Paint.Path.cpp | 9 ++++++++ 6 files changed, 28 insertions(+), 6 deletions(-) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index 68afae5a52..340e36422b 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -4567,6 +4567,7 @@ STR_6257 :Glassy (translucent) STR_6258 :Clear (transparent) STR_6259 :Disabled STR_6260 :Show blocked tiles +STR_6261 :Show wide paths ############# # Scenarios # diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 3598127006..a2227c586f 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -2,6 +2,7 @@ ------------------------------------------------------------------------ - Feature: [#5993] Ride window prices can now be set via text input. - Feature: [#6998] Guests now wait for passing vehicles before crossing railway tracks. +- Feature: [#7694] Debug option to visualize paths that the game detects as wide. - Fix: [#7628] Always-researched items can be modified in the inventory list. - Fix: [#7643] No Money scenarios with funding set to zero. - Fix: [#7653] Finances money spinner is too narrow for big loans. diff --git a/src/openrct2-ui/windows/DebugPaint.cpp b/src/openrct2-ui/windows/DebugPaint.cpp index f67e545bc2..aeea3646ea 100644 --- a/src/openrct2-ui/windows/DebugPaint.cpp +++ b/src/openrct2-ui/windows/DebugPaint.cpp @@ -27,6 +27,7 @@ enum WINDOW_DEBUG_PAINT_WIDGET_IDX { WIDX_BACKGROUND, + WIDX_TOGGLE_SHOW_WIDE_PATHS, WIDX_TOGGLE_SHOW_BLOCKED_TILES, WIDX_TOGGLE_SHOW_SEGMENT_HEIGHTS, WIDX_TOGGLE_SHOW_BOUND_BOXES, @@ -34,14 +35,15 @@ enum WINDOW_DEBUG_PAINT_WIDGET_IDX }; #define WINDOW_WIDTH (200) -#define WINDOW_HEIGHT (8 + 15 + 15 + 15 + 11 + 8) +#define WINDOW_HEIGHT (8 + 15 + 15 + 15 + 15 + 11 + 8) static rct_widget window_debug_paint_widgets[] = { - { WWT_FRAME, 0, 0, WINDOW_WIDTH - 1, 0, WINDOW_HEIGHT - 1, 0xFFFFFFFF, STR_NONE }, - { WWT_CHECKBOX, 1, 8, WINDOW_WIDTH - 8, 8, 8 + 11, STR_DEBUG_PAINT_SHOW_BLOCKED_TILES, STR_NONE }, - { WWT_CHECKBOX, 1, 8, WINDOW_WIDTH - 8, 8 + 15, 8 + 15 + 11, STR_DEBUG_PAINT_SHOW_SEGMENT_HEIGHTS, STR_NONE }, - { WWT_CHECKBOX, 1, 8, WINDOW_WIDTH - 8, 8 + 15 + 15, 8 + 15 + 15 + 11, STR_DEBUG_PAINT_SHOW_BOUND_BOXES, STR_NONE }, - { WWT_CHECKBOX, 1, 8, WINDOW_WIDTH - 8, 8 + 15 + 15 + 15, 8 + 15 + 15 + 15 + 11, STR_DEBUG_PAINT_SHOW_DIRTY_VISUALS, STR_NONE }, + { WWT_FRAME, 0, 0, WINDOW_WIDTH - 1, 0, WINDOW_HEIGHT - 1, STR_NONE, STR_NONE }, + { WWT_CHECKBOX, 1, 8, WINDOW_WIDTH - 8, 8 + 15 * 0, 8 + 15 * 0 + 11, STR_DEBUG_PAINT_SHOW_WIDE_PATHS, STR_NONE }, + { WWT_CHECKBOX, 1, 8, WINDOW_WIDTH - 8, 8 + 15 * 1, 8 + 15 * 1 + 11, STR_DEBUG_PAINT_SHOW_BLOCKED_TILES, STR_NONE }, + { WWT_CHECKBOX, 1, 8, WINDOW_WIDTH - 8, 8 + 15 * 2, 8 + 15 * 2 + 11, STR_DEBUG_PAINT_SHOW_SEGMENT_HEIGHTS, STR_NONE }, + { WWT_CHECKBOX, 1, 8, WINDOW_WIDTH - 8, 8 + 15 * 3, 8 + 15 * 3 + 11, STR_DEBUG_PAINT_SHOW_BOUND_BOXES, STR_NONE }, + { WWT_CHECKBOX, 1, 8, WINDOW_WIDTH - 8, 8 + 15 * 4, 8 + 15 * 4 + 11, STR_DEBUG_PAINT_SHOW_DIRTY_VISUALS, STR_NONE }, { WIDGETS_END }, }; @@ -102,6 +104,7 @@ rct_window * window_debug_paint_open() window->widgets = window_debug_paint_widgets; window->enabled_widgets = + (1 << WIDX_TOGGLE_SHOW_WIDE_PATHS) | (1 << WIDX_TOGGLE_SHOW_BLOCKED_TILES) | (1 << WIDX_TOGGLE_SHOW_BOUND_BOXES) | (1 << WIDX_TOGGLE_SHOW_SEGMENT_HEIGHTS) | @@ -118,6 +121,11 @@ rct_window * window_debug_paint_open() static void window_debug_paint_mouseup([[maybe_unused]] rct_window * w, rct_widgetindex widgetIndex) { switch (widgetIndex) { + case WIDX_TOGGLE_SHOW_WIDE_PATHS: + gPaintWidePathsAsGhost = !gPaintWidePathsAsGhost; + gfx_invalidate_screen(); + break; + case WIDX_TOGGLE_SHOW_BLOCKED_TILES: gPaintBlockedTiles = !gPaintBlockedTiles; gfx_invalidate_screen(); @@ -142,6 +150,7 @@ static void window_debug_paint_mouseup([[maybe_unused]] rct_window * w, rct_widg static void window_debug_paint_invalidate(rct_window * w) { + widget_set_checkbox_value(w, WIDX_TOGGLE_SHOW_WIDE_PATHS, gPaintWidePathsAsGhost); widget_set_checkbox_value(w, WIDX_TOGGLE_SHOW_BLOCKED_TILES, gPaintBlockedTiles); widget_set_checkbox_value(w, WIDX_TOGGLE_SHOW_SEGMENT_HEIGHTS, gShowSupportSegmentHeights); widget_set_checkbox_value(w, WIDX_TOGGLE_SHOW_BOUND_BOXES, gPaintBoundingBoxes); diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index 8c28232114..568c32ebb4 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -3931,6 +3931,7 @@ enum { STR_VIRTUAL_FLOOR_STYLE_DISABLED = 6259, STR_DEBUG_PAINT_SHOW_BLOCKED_TILES = 6260, + STR_DEBUG_PAINT_SHOW_WIDE_PATHS = 6261, // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working STR_COUNT = 32768 diff --git a/src/openrct2/paint/Paint.h b/src/openrct2/paint/Paint.h index 8b1bed6f7a..dbdf02a74a 100644 --- a/src/openrct2/paint/Paint.h +++ b/src/openrct2/paint/Paint.h @@ -180,6 +180,7 @@ extern LocationXY8 gClipSelectionB; extern bool gShowDirtyVisuals; extern bool gPaintBoundingBoxes; extern bool gPaintBlockedTiles; +extern bool gPaintWidePathsAsGhost; paint_struct * sub_98196C( paint_session * session, diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index fc15f7e4c1..87c28b1109 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -34,6 +34,8 @@ #include "../../world/Map.h" #include "../../drawing/LightFX.h" +bool gPaintWidePathsAsGhost = false; + // clang-format off const uint8 byte_98D800[] = { 12, 9, 3, 6 @@ -802,6 +804,13 @@ void path_paint(paint_session * session, uint16 height, const rct_tile_element * imageFlags = COLOUR_BRIGHT_GREEN << 19 | COLOUR_GREY << 24 | IMAGE_TYPE_REMAP; } + // Draw wide flags as ghosts, leaving only the "walkable" paths to be drawn normally + if (gPaintWidePathsAsGhost && footpath_element_is_wide(tile_element)) + { + imageFlags &= 0x7FFFF; + imageFlags |= CONSTRUCTION_MARKER; + } + sint16 x = session->MapPosition.x, y = session->MapPosition.y; rct_tile_element * surface = map_get_surface_element_at({session->MapPosition.x, session->MapPosition.y}); From 0528a455e982a986f8758c181a615b9a60a6906a Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Fri, 15 Jun 2018 16:07:38 +0200 Subject: [PATCH 2/2] Automatically resize debug window to fit strings --- src/openrct2-ui/windows/DebugPaint.cpp | 47 +++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/src/openrct2-ui/windows/DebugPaint.cpp b/src/openrct2-ui/windows/DebugPaint.cpp index aeea3646ea..c2596ee3e9 100644 --- a/src/openrct2-ui/windows/DebugPaint.cpp +++ b/src/openrct2-ui/windows/DebugPaint.cpp @@ -14,15 +14,19 @@ *****************************************************************************/ #pragma endregion -#include -#include - #include +#include +#include +#include +#include #include -#include +#include #include +#include #include +static sint32 ResizeLanguage = LANGUAGE_UNDEFINED; + // clang-format off enum WINDOW_DEBUG_PAINT_WIDGET_IDX { @@ -115,6 +119,7 @@ rct_window * window_debug_paint_open() window->colours[0] = TRANSLUCENT(COLOUR_BLACK); window->colours[1] = COLOUR_GREY; + ResizeLanguage = LANGUAGE_UNDEFINED; return window; } @@ -150,6 +155,40 @@ static void window_debug_paint_mouseup([[maybe_unused]] rct_window * w, rct_widg static void window_debug_paint_invalidate(rct_window * w) { + const auto& ls = OpenRCT2::GetContext()->GetLocalisationService(); + const auto currentLanguage = ls.GetCurrentLanguage(); + if (ResizeLanguage != currentLanguage) + { + ResizeLanguage = currentLanguage; + window_invalidate(w); + + // Find the width of the longest string + sint16 newWidth = 0; + for (size_t widgetIndex = WIDX_TOGGLE_SHOW_WIDE_PATHS; widgetIndex < WIDX_TOGGLE_SHOW_DIRTY_VISUALS; widgetIndex++) + { + auto stringIdx = w->widgets[widgetIndex].text; + auto string = ls.GetString(stringIdx); + Guard::ArgumentNotNull(string); + auto width = gfx_get_string_width(string); + newWidth = std::max(width, newWidth); + } + + // Add padding for both sides (8) and the offset for the text after the checkbox (15) + newWidth += 8 * 2 + 15; + + w->width = newWidth; + w->max_width = newWidth; + w->min_width = newWidth; + w->widgets[WIDX_BACKGROUND].right = newWidth - 1; + w->widgets[WIDX_TOGGLE_SHOW_WIDE_PATHS].right = newWidth - 8; + w->widgets[WIDX_TOGGLE_SHOW_BLOCKED_TILES].right = newWidth - 8; + w->widgets[WIDX_TOGGLE_SHOW_SEGMENT_HEIGHTS].right = newWidth - 8; + w->widgets[WIDX_TOGGLE_SHOW_BOUND_BOXES].right = newWidth - 8; + w->widgets[WIDX_TOGGLE_SHOW_DIRTY_VISUALS].right = newWidth - 8; + + window_invalidate(w); + } + widget_set_checkbox_value(w, WIDX_TOGGLE_SHOW_WIDE_PATHS, gPaintWidePathsAsGhost); widget_set_checkbox_value(w, WIDX_TOGGLE_SHOW_BLOCKED_TILES, gPaintBlockedTiles); widget_set_checkbox_value(w, WIDX_TOGGLE_SHOW_SEGMENT_HEIGHTS, gShowSupportSegmentHeights);