mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-10 09:32:29 +01:00
Merge pull request #7695 from Broxzier/wide-path-debug
Add debug option to visualize wide path flags.
This commit is contained in:
@@ -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 #
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -7,19 +7,24 @@
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2-ui/windows/Window.h>
|
||||
|
||||
#include <openrct2-ui/interface/Widget.h>
|
||||
#include <openrct2-ui/windows/Window.h>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/core/Guard.hpp>
|
||||
#include <openrct2/localisation/Language.h>
|
||||
#include <openrct2/localisation/Localisation.h>
|
||||
#include <openrct2/paint/tile_element/Paint.TileElement.h>
|
||||
#include <openrct2/localisation/LocalisationService.h>
|
||||
#include <openrct2/paint/Paint.h>
|
||||
#include <openrct2/paint/tile_element/Paint.TileElement.h>
|
||||
#include <openrct2/ride/TrackPaint.h>
|
||||
|
||||
static sint32 ResizeLanguage = LANGUAGE_UNDEFINED;
|
||||
|
||||
// clang-format off
|
||||
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,
|
||||
@@ -27,14 +32,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 },
|
||||
};
|
||||
|
||||
@@ -95,6 +101,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) |
|
||||
@@ -105,12 +112,18 @@ rct_window * window_debug_paint_open()
|
||||
window->colours[0] = TRANSLUCENT(COLOUR_BLACK);
|
||||
window->colours[1] = COLOUR_GREY;
|
||||
|
||||
ResizeLanguage = LANGUAGE_UNDEFINED;
|
||||
return window;
|
||||
}
|
||||
|
||||
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();
|
||||
@@ -135,6 +148,41 @@ 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<sint16>(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);
|
||||
widget_set_checkbox_value(w, WIDX_TOGGLE_SHOW_BOUND_BOXES, gPaintBoundingBoxes);
|
||||
|
||||
@@ -3924,6 +3924,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
|
||||
|
||||
@@ -173,6 +173,7 @@ extern LocationXY8 gClipSelectionB;
|
||||
extern bool gShowDirtyVisuals;
|
||||
extern bool gPaintBoundingBoxes;
|
||||
extern bool gPaintBlockedTiles;
|
||||
extern bool gPaintWidePathsAsGhost;
|
||||
|
||||
paint_struct * sub_98196C(
|
||||
paint_session * session,
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "../../world/Map.h"
|
||||
#include "../../drawing/LightFX.h"
|
||||
|
||||
bool gPaintWidePathsAsGhost = false;
|
||||
|
||||
// clang-format off
|
||||
const uint8 byte_98D800[] = {
|
||||
12, 9, 3, 6
|
||||
@@ -795,6 +797,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});
|
||||
|
||||
Reference in New Issue
Block a user