From a008dcb1861ea21cd51c52cacbf2a1f179e961fa Mon Sep 17 00:00:00 2001 From: zaxcav Date: Fri, 6 Jan 2017 20:46:04 +0100 Subject: [PATCH] Display clip height in METRIC/SI units with 1DP. --- data/language/en-GB.txt | 1 + src/openrct2/localisation/string_ids.h | 1 + src/openrct2/windows/view_clipping.c | 26 +++++++------------------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index f3ee404d33..2b0d7d9c0f 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -4316,6 +4316,7 @@ STR_6004 :Enable cut-away view STR_6005 :Cut-away view only displays map elements at or below the cut height STR_6006 :Cut height STR_6007 :Select cut height +STE_6008 :{COMMA1DP16}m ############# # Scenarios # diff --git a/src/openrct2/localisation/string_ids.h b/src/openrct2/localisation/string_ids.h index 26f4dd03fc..f4c19a08b3 100644 --- a/src/openrct2/localisation/string_ids.h +++ b/src/openrct2/localisation/string_ids.h @@ -3659,6 +3659,7 @@ enum { STR_VIEW_CLIPPING_HEIGHT_ENABLE_TIP = 6005, STR_VIEW_CLIPPING_HEIGHT_VALUE = 6006, STR_VIEW_CLIPPING_HEIGHT_SCROLL_TIP = 6007, + STR_UNIT1DP_SUFFIX_METRES = 6008, // 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/windows/view_clipping.c b/src/openrct2/windows/view_clipping.c index 3f70389f8b..f1b58950ee 100644 --- a/src/openrct2/windows/view_clipping.c +++ b/src/openrct2/windows/view_clipping.c @@ -210,8 +210,6 @@ static void window_view_clipping_paint(rct_window *w, rct_drawpixelinfo *dpi) window_draw_widgets(w, dpi); // Clip height value - // Currently as a spinner. - // Alternately could try putting the value on the scrollbar. int x; int y; x = w->x + 8; @@ -222,31 +220,21 @@ static void window_view_clipping_paint(rct_window *w, rct_drawpixelinfo *dpi) y = w->y + w->widgets[WIDX_CLIP_HEIGHT_VALUE].top; gfx_draw_string_left(dpi, STR_FORMAT_INTEGER, &gClipHeight, w->colours[1], x, y); //Printing the raw value. - // Set the height units symbol - rct_string_id clipHeight_Units_StringId; + // Print the value in the configured game units. + fixed16_1dp clipHeightValueInMeters; + sint16 clipHeightValueInFeet; switch (gConfigGeneral.measurement_format) { case MEASUREMENT_FORMAT_METRIC: case MEASUREMENT_FORMAT_SI: - clipHeight_Units_StringId = STR_UNIT_SUFFIX_METRES; + clipHeightValueInMeters = FIXED_1DP(gClipHeight, 0) / 2 * 1.5 - FIXED_1DP(10,5); + gfx_draw_string_left(dpi, STR_UNIT1DP_SUFFIX_METRES, &clipHeightValueInMeters, w->colours[1], x + 30, y); break; case MEASUREMENT_FORMAT_IMPERIAL: default: - clipHeight_Units_StringId = STR_UNIT_SUFFIX_FEET; + clipHeightValueInFeet = gClipHeight / 2 * 5 - 35; + gfx_draw_string_left(dpi, STR_UNIT_SUFFIX_FEET, &clipHeightValueInFeet, w->colours[1], x + 30, y); break; } - - fixed16_1dp clipHeightValueInUnits; // The clip height in the unit type - feet or meters. For value in meters a fixed point number is needed. - switch (clipHeight_Units_StringId) { - case STR_UNIT_SUFFIX_FEET: - clipHeightValueInUnits = FIXED_1DP(gClipHeight, 0) / 2 * 5 - FIXED_1DP(35,0); - break; - case STR_UNIT_SUFFIX_METRES: - default: - clipHeightValueInUnits = FIXED_1DP(gClipHeight, 0) / 2 * 1.5 - FIXED_1DP(10,5); - break; - } - // TODO: Display fixed point value correctly. - gfx_draw_string_left(dpi, clipHeight_Units_StringId, &clipHeightValueInUnits, w->colours[1], x + 30, y); } static void window_view_clipping_scrollgetsize(rct_window *w, int scrollIndex, int *width, int *height)