From 8d14016c3f2b3dab8f51c5ae47cc17006ae8a3fc Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Sun, 15 May 2022 22:25:45 +0200 Subject: [PATCH] Allow maps to be resized to non-rectangular shapes --- data/language/en-GB.txt | 3 +- resources/g2/icons/link_chain.png | Bin 0 -> 154 bytes resources/g2/sprites.json | 5 + src/openrct2-ui/windows/Map.cpp | 167 ++++++++++++++++++-------- src/openrct2/interface/Window.h | 2 +- src/openrct2/localisation/StringIds.h | 4 +- src/openrct2/sprites.h | 4 +- 7 files changed, 129 insertions(+), 56 deletions(-) create mode 100644 resources/g2/icons/link_chain.png diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index 8351bebb4b..49a03d001c 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -2258,7 +2258,7 @@ STR_3208 :Track Designs Manager STR_3209 :Back to Previous Step: STR_3210 :Forward to Next Step: STR_3211 :Map size: -STR_3212 :{COMMA16} × {COMMA16} +STR_3212 :{POP16}{COMMA16} STR_3213 :Can’t decrease map size any further STR_3214 :Can’t increase map size any further STR_3215 :Too close to edge of map @@ -3603,6 +3603,7 @@ STR_6494 :Group by ride type STR_6495 :Group rides by ride types instead of showing each vehicle separately. STR_6496 :{WINDOW_COLOUR_2}{STRINGID} STR_6497 :Click on a tile to show its tile elements.{NEWLINE}Ctrl + click a tile element to select it directly. +STR_6498 :Enable to maintain square map shape. ############# # Scenarios # diff --git a/resources/g2/icons/link_chain.png b/resources/g2/icons/link_chain.png new file mode 100644 index 0000000000000000000000000000000000000000..7edf3872be58a218941ebc6df5bb9886616856fd GIT binary patch literal 154 zcmeAS@N?(olHy`uVBq!ia0y~yU=U(gMapSize.x - 2); ft.Add(gMapSize.y - 2); + ft.Add(gMapSize.x - 2); } void InputLandSize() @@ -1267,12 +1318,17 @@ private: TextInputOpen(WIDX_LAND_TOOL, STR_SELECTION_SIZE, STR_ENTER_SELECTION_SIZE, ft, STR_NONE, STR_NONE, 3); } - void InputMapSize() + void InputMapSize(rct_widgetindex callingWidget) { + if (IsWidgetPressed(WIDX_MAP_SIZE_LINK)) + _resizeDirection = ResizeDirection::Both; + else + _resizeDirection = (callingWidget == WIDX_MAP_SIZE_SPINNER_Y) ? ResizeDirection::Y : ResizeDirection::X; + Formatter ft; ft.Add(MINIMUM_MAP_SIZE_PRACTICAL); ft.Add(MAXIMUM_MAP_SIZE_PRACTICAL); - TextInputOpen(WIDX_MAP_SIZE_SPINNER, STR_MAP_SIZE_2, STR_ENTER_MAP_SIZE, ft, STR_NONE, STR_NONE, 4); + TextInputOpen(callingWidget, STR_MAP_SIZE_2, STR_ENTER_MAP_SIZE, ft, STR_NONE, STR_NONE, 4); } CoordsXY ScreenToMap(ScreenCoordsXY screenCoords) @@ -1327,6 +1383,13 @@ private: uint32_t _currentLine; uint16_t _landRightsToolSize; std::vector _mapImageData; + bool _mapWidthAndHeightLinked{ true }; + enum class ResizeDirection + { + Both, + X, + Y, + } _resizeDirection{ ResizeDirection::Both }; static constexpr const uint16_t RideKeyColours[] = { MapColour(PALETTE_INDEX_61), // COLOUR_KEY_RIDE diff --git a/src/openrct2/interface/Window.h b/src/openrct2/interface/Window.h index 6ec65ce72f..12d29cab80 100644 --- a/src/openrct2/interface/Window.h +++ b/src/openrct2/interface/Window.h @@ -527,7 +527,7 @@ enum #define WC_PEEP__WIDX_PICKUP 14 #define WC_TRACK_DESIGN_LIST__WIDX_ROTATE 8 #define WC_TRACK_DESIGN_PLACE__WIDX_ROTATE 3 -#define WC_MAP__WIDX_ROTATE_90 20 +#define WC_MAP__WIDX_ROTATE_90 24 #define WC_EDITOR_OBJECT_SELECTION__WIDX_TAB_1 21 #define WC_STAFF__WIDX_PICKUP 9 #define WC_TILE_INSPECTOR__WIDX_BUTTON_ROTATE 13 diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index 3f67339641..04466e12f4 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -2379,7 +2379,7 @@ enum : uint16_t STR_BACK_TO_PREVIOUS_STEP = 3209, STR_FORWARD_TO_NEXT_STEP = 3210, STR_MAP_SIZE = 3211, - STR_MAP_SIZE_VALUE = 3212, + STR_POP16_COMMA16 = 3212, STR_CANT_DECREASE_MAP_SIZE_ANY_FURTHER = 3213, STR_CANT_INCREASE_MAP_SIZE_ANY_FURTHER = 3214, STR_TOO_CLOSE_TO_EDGE_OF_MAP = 3215, @@ -3875,6 +3875,8 @@ enum : uint16_t STR_TILE_INSPECTOR_SELECT_TILE_HINT = 6497, + STR_MAINTAIN_SQUARE_MAP_TOOLTIP = 6498, + // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working /* MAX_STR_COUNT = 32768 */ // MAX_STR_COUNT - upper limit for number of strings, not the current count strings }; diff --git a/src/openrct2/sprites.h b/src/openrct2/sprites.h index fee025c4e0..3527d17eb2 100644 --- a/src/openrct2/sprites.h +++ b/src/openrct2/sprites.h @@ -895,7 +895,9 @@ enum SPR_G2_BUTTON_HIDE_PARTIAL = SPR_G2_BEGIN + 147, SPR_G2_BUTTON_HIDE_FULL = SPR_G2_BEGIN + 148, - SPR_G2_CHAR_BEGIN = SPR_G2_BEGIN + 149, + SPR_G2_LINK_CHAIN = SPR_G2_BEGIN + 149, + + SPR_G2_CHAR_BEGIN = SPR_G2_BEGIN + 150, SPR_G2_AE_UPPER = SPR_G2_CHAR_BEGIN, SPR_G2_AE_LOWER = SPR_G2_CHAR_BEGIN + 1,