diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 382077c178..ebb0a41f35 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -2,6 +2,7 @@ ------------------------------------------------------------------------ - Feature: [#7956, #7964] Add sprite font glyphs for Hungarian and some Czech letters. - Fix: [#7975] Inspection flag not cleared for rides which are set to never be inspected (Original bug). +- Improved: [#7730] Draw extreme vertical and lateral Gs red in the ride window's graph tab. - Improved: [#7930] Automatically create folders for custom content. - Removed: [#7929] Support for scenario text objects. diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 4c182367b8..d77cafd0f3 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -1202,6 +1202,10 @@ static constexpr const rct_window_graphs_y_axis window_graphs_y_axi[] = { { 13, -4, 1, STR_RIDE_STATS_G_FORCE_FORMAT }, // GRAPH_LATERAL }; +static constexpr auto RIDE_G_FORCES_RED_POS_VERTICAL = FIXED_2DP(5, 00); +static constexpr auto RIDE_G_FORCES_RED_NEG_VERTICAL = -FIXED_2DP(2, 00); +static constexpr auto RIDE_G_FORCES_RED_LATERAL = FIXED_2DP(2, 80); + // Used for sorting the ride type cheat dropdown. struct RideTypeLabel { @@ -5595,21 +5599,21 @@ static void window_ride_measurements_paint(rct_window* w, rct_drawpixelinfo* dpi { // Max. positive vertical G's maxPositiveVerticalGs = ride->max_positive_vertical_g; - stringId = maxPositiveVerticalGs >= FIXED_2DP(5, 00) ? STR_MAX_POSITIVE_VERTICAL_G_RED - : STR_MAX_POSITIVE_VERTICAL_G; + stringId = maxPositiveVerticalGs >= RIDE_G_FORCES_RED_POS_VERTICAL ? STR_MAX_POSITIVE_VERTICAL_G_RED + : STR_MAX_POSITIVE_VERTICAL_G; gfx_draw_string_left(dpi, stringId, &maxPositiveVerticalGs, COLOUR_BLACK, x, y); y += LIST_ROW_HEIGHT; // Max. negative vertical G's maxNegativeVerticalGs = ride->max_negative_vertical_g; - stringId = maxNegativeVerticalGs <= -FIXED_2DP(2, 00) ? STR_MAX_NEGATIVE_VERTICAL_G_RED - : STR_MAX_NEGATIVE_VERTICAL_G; + stringId = maxNegativeVerticalGs <= RIDE_G_FORCES_RED_NEG_VERTICAL ? STR_MAX_NEGATIVE_VERTICAL_G_RED + : STR_MAX_NEGATIVE_VERTICAL_G; gfx_draw_string_left(dpi, stringId, &maxNegativeVerticalGs, COLOUR_BLACK, x, y); y += LIST_ROW_HEIGHT; // Max lateral G's maxLateralGs = ride->max_lateral_g; - stringId = maxLateralGs >= FIXED_2DP(2, 80) ? STR_MAX_LATERAL_G_RED : STR_MAX_LATERAL_G; + stringId = maxLateralGs >= RIDE_G_FORCES_RED_LATERAL ? STR_MAX_LATERAL_G_RED : STR_MAX_LATERAL_G; gfx_draw_string_left(dpi, stringId, &maxLateralGs, COLOUR_BLACK, x, y); y += LIST_ROW_HEIGHT; @@ -5974,6 +5978,9 @@ static void window_ride_graphs_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi // Plot int32_t x = dpi->x; int32_t top, bottom; + // Uses the force limits (used to draw extreme G's in red on measurement tab) to determine if line should be drawn red. + int32_t intensityThresholdPositive = 0; + int32_t intensityThresholdNegative = 0; for (int32_t width = 0; width < dpi->width; width++, x++) { if (x < 0 || x >= measurement->num_items - 1) @@ -5992,25 +5999,62 @@ static void window_ride_graphs_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi case GRAPH_VERTICAL: top = measurement->vertical[x] + 39; bottom = measurement->vertical[x + 1] + 39; + intensityThresholdPositive = (RIDE_G_FORCES_RED_POS_VERTICAL / 8) + 39; + intensityThresholdNegative = (RIDE_G_FORCES_RED_NEG_VERTICAL / 8) + 39; break; case GRAPH_LATERAL: top = measurement->lateral[x] + 52; bottom = measurement->lateral[x + 1] + 52; + intensityThresholdPositive = (RIDE_G_FORCES_RED_LATERAL / 8) + 52; + intensityThresholdNegative = -(RIDE_G_FORCES_RED_LATERAL / 8) + 52; break; default: log_error("Wrong graph type %d", listType); top = bottom = 0; + break; } + // Adjust line to match graph widget position. top = widget->bottom - widget->top - top - 13; bottom = widget->bottom - widget->top - bottom - 13; if (top > bottom) { - int32_t tmp = top; - top = bottom; - bottom = tmp; + std::swap(top, bottom); + } + + // Adjust threshold line position as well + if (listType == GRAPH_VERTICAL || listType == GRAPH_LATERAL) + { + intensityThresholdPositive = widget->bottom - widget->top - intensityThresholdPositive - 13; + intensityThresholdNegative = widget->bottom - widget->top - intensityThresholdNegative - 13; + } + + const bool previousMeasurement = x > measurement->current_item; + + // Draw the current line in gray. + gfx_fill_rect(dpi, x, top, x, bottom, previousMeasurement ? PALETTE_INDEX_17 : PALETTE_INDEX_21); + + // Draw red over extreme values (if supported by graph type). + if (listType == GRAPH_VERTICAL || listType == GRAPH_LATERAL) + { + const auto redLineColour = previousMeasurement ? PALETTE_INDEX_171 : PALETTE_INDEX_173; + + // Line exceeds negative threshold (at bottom of graph). + if (bottom >= intensityThresholdNegative) + { + const auto redLineTop = std::max(top, intensityThresholdNegative); + const auto redLineBottom = std::max(bottom, intensityThresholdNegative); + gfx_fill_rect(dpi, x, redLineTop, x, redLineBottom, redLineColour); + } + + // Line exceeds positive threshold (at top of graph). + if (top <= intensityThresholdPositive) + { + const auto redLineTop = std::min(top, intensityThresholdPositive); + const auto redLineBottom = std::min(bottom, intensityThresholdPositive); + gfx_fill_rect(dpi, x, redLineTop, x, redLineBottom, redLineColour); + } } - gfx_fill_rect(dpi, x, top, x, bottom, x > measurement->current_item ? PALETTE_INDEX_17 : PALETTE_INDEX_21); } } diff --git a/src/openrct2/interface/Colour.h b/src/openrct2/interface/Colour.h index a8c8f874bc..2364d4302c 100644 --- a/src/openrct2/interface/Colour.h +++ b/src/openrct2/interface/Colour.h @@ -97,6 +97,7 @@ enum PALETTE_INDEX_162 = 162, // PALETTE_INDEX_171 = 171, // Saturated Red (lightest) Bright Red (middark) PALETTE_INDEX_172 = 172, // Saturated Red (10-11), Bright Red (midlight) + PALETTE_INDEX_173 = 173, // Used to draw intense lines in the Ride Graphs window PALETTE_INDEX_183 = 183, // Used to draw rides in the Map window PALETTE_INDEX_186 = 186, // PALETTE_INDEX_194 = 194, //