From c4c4f46b787d0914e0acb84f243f4d12a9eacfd1 Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 18 Dec 2018 18:43:03 +0100 Subject: [PATCH 1/2] Use different colours for entrance/exit on track design previews. --- src/openrct2-ui/windows/TrackDesignPlace.cpp | 54 ++++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index e6815471bc..bd19ba5526 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -37,6 +37,9 @@ struct rct_track_td6; +static constexpr uint8_t _PaletteIndexColourEntrance = PALETTE_INDEX_20; // White +static constexpr uint8_t _PaletteIndexColourExit = PALETTE_INDEX_10; // Black + // clang-format off enum { WIDX_BACKGROUND, @@ -524,7 +527,6 @@ static void window_track_place_draw_mini_preview_track( const rct_preview_track** trackBlockArray = (ride_type_has_flag(td6->type, RIDE_TYPE_FLAG_HAS_TRACK)) ? TrackBlocks : FlatRideTrackBlocks; - while (trackElement->type != 255) { int32_t trackType = trackElement->type; @@ -598,6 +600,46 @@ static void window_track_place_draw_mini_preview_track( } trackElement++; } + + // Draw entrance and exit preview. + rct_td6_entrance_element* entrance = td6->entrance_elements; + for (; entrance->z != -1; entrance++) + { + int16_t x = origin.x; + int16_t y = origin.y; + map_offset_with_rotation(&x, &y, entrance->x, entrance->y, rotation); + + if (pass == 0) + { + min->x = std::min(min->x, x); + max->x = std::max(max->x, x); + min->y = std::min(min->y, y); + max->y = std::max(max->y, y); + } + else + { + LocationXY16 pixelPosition = draw_mini_preview_get_pixel_position(x, y); + if (draw_mini_preview_is_pixel_in_bounds(pixelPosition)) + { + uint8_t* pixel = draw_mini_preview_get_pixel_ptr(pixelPosition); + + bool isExit = false; + if (entrance->direction & (1 << 7)) + { + isExit = true; + } + + uint8_t colour = isExit ? _PaletteIndexColourExit : _PaletteIndexColourEntrance; + for (int32_t i = 0; i < 4; i++) + { + pixel[338 + i] = colour; // x + 2, y + 2 + pixel[168 + i] = colour; // y + 1 + pixel[2 + i] = colour; // x + 2 + pixel[172 + i] = colour; // x + 4, y + 1 + } + } + } + } } static void window_track_place_draw_mini_preview_maze( @@ -628,9 +670,13 @@ static void window_track_place_draw_mini_preview_maze( { uint8_t* pixel = draw_mini_preview_get_pixel_ptr(pixelPosition); - // Entrance or exit is a lighter colour - uint8_t colour = mazeElement->type == 8 || mazeElement->type == 128 ? PALETTE_INDEX_PRIMARY_LIGHTEST - : PALETTE_INDEX_PRIMARY_MID_DARK; + uint8_t colour = PALETTE_INDEX_PRIMARY_MID_DARK; + + // Draw entrance and exit with different colours. + if (mazeElement->type == MAZE_ELEMENT_TYPE_ENTRANCE) + colour = _PaletteIndexColourEntrance; + else if (mazeElement->type == MAZE_ELEMENT_TYPE_EXIT) + colour = _PaletteIndexColourExit; for (int32_t i = 0; i < 4; i++) { From 4dce91e027d48712a7d5c5d07285b5d2c0fecaa8 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 19 Dec 2018 14:20:40 +0100 Subject: [PATCH 2/2] Move defines into Colour.h --- distribution/changelog.txt | 1 + src/openrct2-ui/windows/TrackDesignPlace.cpp | 15 +++++++-------- src/openrct2/interface/Colour.h | 4 +++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 691e712f44..a086349110 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -53,6 +53,7 @@ - Improved: [#7980] Show the full path of the scenario in the scenario select window. - Improved: [#7993] Allow assigning a keyboard shortcut for opening the tile inspector. - Improved: [#8107] Support Discord release of RCT2. +- Improved: [#8491] Highlight entrance and exit with different colours in track design previews. - Improved: Almost completely new Hungarian translation. - Removed: [#7929] Support for scenario text objects. diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index bd19ba5526..60739391c0 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -31,14 +31,12 @@ #define TRACK_MINI_PREVIEW_HEIGHT 78 #define TRACK_MINI_PREVIEW_SIZE (TRACK_MINI_PREVIEW_WIDTH * TRACK_MINI_PREVIEW_HEIGHT) -#define PALETTE_INDEX_TRANSPARENT (0) -#define PALETTE_INDEX_PRIMARY_MID_DARK (248) -#define PALETTE_INDEX_PRIMARY_LIGHTEST (252) - struct rct_track_td6; static constexpr uint8_t _PaletteIndexColourEntrance = PALETTE_INDEX_20; // White static constexpr uint8_t _PaletteIndexColourExit = PALETTE_INDEX_10; // Black +static constexpr uint8_t _PaletteIndexColourTrack = PALETTE_INDEX_248; // Grey (dark) +static constexpr uint8_t _PaletteIndexColourStation = PALETTE_INDEX_252; // Grey (light) // clang-format off enum { @@ -140,7 +138,8 @@ static uint8_t* draw_mini_preview_get_pixel_ptr(LocationXY16 pixel); */ static void window_track_place_clear_mini_preview() { - std::fill(_window_track_place_mini_preview.begin(), _window_track_place_mini_preview.end(), PALETTE_INDEX_TRANSPARENT); + // Fill with transparent colour. + std::fill(_window_track_place_mini_preview.begin(), _window_track_place_mini_preview.end(), PALETTE_INDEX_0); } /** @@ -562,8 +561,8 @@ static void window_track_place_draw_mini_preview_track( // Station track is a lighter colour uint8_t colour = (TrackSequenceProperties[trackType][0] & TRACK_SEQUENCE_FLAG_ORIGIN) - ? PALETTE_INDEX_PRIMARY_LIGHTEST - : PALETTE_INDEX_PRIMARY_MID_DARK; + ? _PaletteIndexColourStation + : _PaletteIndexColourTrack; for (int32_t i = 0; i < 4; i++) { @@ -670,7 +669,7 @@ static void window_track_place_draw_mini_preview_maze( { uint8_t* pixel = draw_mini_preview_get_pixel_ptr(pixelPosition); - uint8_t colour = PALETTE_INDEX_PRIMARY_MID_DARK; + uint8_t colour = _PaletteIndexColourTrack; // Draw entrance and exit with different colours. if (mazeElement->type == MAZE_ELEMENT_TYPE_ENTRANCE) diff --git a/src/openrct2/interface/Colour.h b/src/openrct2/interface/Colour.h index 2364d4302c..14df38630c 100644 --- a/src/openrct2/interface/Colour.h +++ b/src/openrct2/interface/Colour.h @@ -64,7 +64,7 @@ enum enum { - PALETTE_INDEX_0 = 0, // + PALETTE_INDEX_0 = 0, // Transparent PALETTE_INDEX_10 = 10, // Black (0-dark), Dark gray (0) PALETTE_INDEX_11 = 11, // Black (middark) PALETTE_INDEX_12 = 12, // Black (midlight), Dark gray (1-darkest) @@ -106,6 +106,8 @@ enum PALETTE_INDEX_222 = 222, // PALETTE_INDEX_230 = 230, // PALETTE_INDEX_245 = 245, // + PALETTE_INDEX_248 = 248, // Grey (dark) + PALETTE_INDEX_252 = 252, // Grey (light) PALETTE_COUNT = 256, };