1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-20 21:43:06 +01:00

Merge pull request #8491 from ZehMatt/preview-placement-hints

Use different colours for entrance/exit on track design previews.
This commit is contained in:
Michael Steenbeek
2018-12-21 20:46:22 +01:00
committed by GitHub
3 changed files with 60 additions and 12 deletions

View File

@@ -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.

View File

@@ -31,12 +31,13 @@
#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 {
WIDX_BACKGROUND,
@@ -137,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);
}
/**
@@ -524,7 +526,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;
@@ -560,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++)
{
@@ -598,6 +599,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 +669,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 = _PaletteIndexColourTrack;
// 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++)
{

View File

@@ -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,
};