From 717501c646aa0d075f53278c54bf43becffb6dbd Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Mon, 23 Sep 2024 14:55:04 +0200 Subject: [PATCH] Make smooth strength field clickable --- data/language/en-GB.txt | 2 ++ src/openrct2-ui/UiStringIds.h | 2 ++ src/openrct2-ui/windows/MapGen.cpp | 24 ++++++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index 212e24f223..cc572a5de9 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -3779,6 +3779,8 @@ STR_6704 :{COMMA2DP32} STR_6705 :Browse... STR_6706 :{WINDOW_COLOUR_2}Current image file: {BLACK}{STRING} STR_6707 :(none selected) +STR_6708 :Smooth Strength +STR_6709 :Enter Smooth Strength between {COMMA16} and {COMMA16} ############# # Scenarios # diff --git a/src/openrct2-ui/UiStringIds.h b/src/openrct2-ui/UiStringIds.h index 84e726d306..93f1086549 100644 --- a/src/openrct2-ui/UiStringIds.h +++ b/src/openrct2-ui/UiStringIds.h @@ -908,6 +908,7 @@ namespace OpenRCT2 STR_ENTER_MIN_LAND = 6691, STR_ENTER_MIN_TREE_ALTITUDE = 6695, STR_ENTER_OCTAVES = 6703, + STR_ENTER_SMOOTH_STRENGTH = 6708, STR_ENTER_TREE_TO_LAND_RATIO = 6699, STR_ENTER_WATER_LEVEL = 5186, STR_HEIGHTMAP_FILE = 6681, @@ -943,6 +944,7 @@ namespace OpenRCT2 STR_MIN_TREE_ALTITUDE = 6694, STR_SIMPLEX_BASE_FREQUENCY = 6700, STR_SIMPLEX_OCTAVES = 6702, + STR_SMOOTH_STRENGTH = 6709, STR_TERRAIN_LABEL = 2693, STR_TREE_TO_LAND_RATIO = 6694, STR_WATER_LEVEL = 5185, diff --git a/src/openrct2-ui/windows/MapGen.cpp b/src/openrct2-ui/windows/MapGen.cpp index d77360db06..017fa07e48 100644 --- a/src/openrct2-ui/windows/MapGen.cpp +++ b/src/openrct2-ui/windows/MapGen.cpp @@ -492,6 +492,8 @@ namespace OpenRCT2::Ui::Windows { if (_settings.algorithm == MapGenAlgorithm::simplexNoise) SimplexTextInput(widgetIndex, value); + else if (_settings.algorithm == MapGenAlgorithm::heightmapImage) + HeightmapTextInput(widgetIndex, value); switch (widgetIndex) { @@ -954,11 +956,23 @@ namespace OpenRCT2::Ui::Windows InvalidateWidget(WIDX_HEIGHTMAP_SMOOTH_HEIGHTMAP); InvalidateWidget(WIDX_HEIGHTMAP_STRENGTH); break; + case WIDX_HEIGHTMAP_NORMALIZE: _settings.normalize_height = !_settings.normalize_height; SetCheckboxValue(WIDX_HEIGHTMAP_NORMALIZE, _settings.normalize_height); InvalidateWidget(WIDX_HEIGHTMAP_NORMALIZE); break; + + case WIDX_HEIGHTMAP_STRENGTH: + { + Formatter ft; + ft.Add(1); + ft.Add(20); + WindowTextInputOpen( + this, widgetIndex, STR_SMOOTH_STRENGTH, STR_ENTER_SMOOTH_STRENGTH, ft, STR_FORMAT_INTEGER, + _settings.smooth_strength, 2); + break; + } } } @@ -1000,6 +1014,16 @@ namespace OpenRCT2::Ui::Windows DrawTextEllipsised(dpi, windowPos + pos, textWidth, STR_MAPGEN_CURRENT_HEIGHTMAP_FILE, ft); } + void HeightmapTextInput(WidgetIndex widgetIndex, int32_t value) + { + switch (widgetIndex) + { + case WIDX_HEIGHTMAP_STRENGTH: + _settings.smooth_strength = std::clamp(value, 1, 20); + break; + } + } + #pragma endregion #pragma region Terrain page