From 70b9d0ca474af533a62b8f754c31ca12fe471864 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Sun, 11 Feb 2024 21:45:31 +0100 Subject: [PATCH] Add button to reload object --- data/language/en-GB.txt | 1 + distribution/changelog.txt | 1 + .../windows/EditorObjectSelection.cpp | 23 ++++++++++++++++++- src/openrct2/interface/Window.h | 2 +- src/openrct2/localisation/StringIds.h | 2 ++ 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index 976b814871..3991e52a8d 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -3715,6 +3715,7 @@ STR_6609 :Track block not found STR_6610 :Path element not found STR_6611 :Wall element not found STR_6612 :Banner element not found +STR_6613 :Reload object ############# # Scenarios # diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 1a81b5cb5a..02b9b3f0c4 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,5 +1,6 @@ 0.4.9 (in development) ------------------------------------------------------------------------ +- Feature: [#21376] Add option to reload an object (for object developers). - Improved: [#21356] Resize the title bar when moving between displays with different scaling factors on Windows systems. - Fix: [#18963] Research table in parks from Loopy Landscapes is imported incorrectly. - Fix: [#20907] RCT1/AA scenarios use the 4-across train for the Inverted Roller Coaster. diff --git a/src/openrct2-ui/windows/EditorObjectSelection.cpp b/src/openrct2-ui/windows/EditorObjectSelection.cpp index 19826fad9d..de84c9bb06 100644 --- a/src/openrct2-ui/windows/EditorObjectSelection.cpp +++ b/src/openrct2-ui/windows/EditorObjectSelection.cpp @@ -183,6 +183,7 @@ enum WINDOW_EDITOR_OBJECT_SELECTION_WIDGET_IDX WIDX_FILTER_RIDE_TAB_STALL, WIDX_LIST_SORT_TYPE, WIDX_LIST_SORT_RIDE, + WIDX_RELOAD_OBJECT, WIDX_TAB_1, }; @@ -211,7 +212,7 @@ static std::vector _window_editor_object_selection_widgets = { MakeTab ({189, 47}, STR_SHOPS_STALLS_TIP ), MakeWidget({ 4, 80}, {145, 14}, WindowWidgetType::TableHeader, WindowColour::Secondary ), MakeWidget({149, 80}, {143, 14}, WindowWidgetType::TableHeader, WindowColour::Secondary ), - + MakeWidget({700, 50}, { 24, 24}, WindowWidgetType::ImgBtn, WindowColour::Primary, SPR_G2_RELOAD, STR_RELOAD_OBJECT_TIP ), MakeTab ({ 3, 17}, STR_STRING_DEFINED_TOOLTIP ), // Copied object type times... @@ -449,6 +450,19 @@ public: } VisibleListRefresh(); break; + case WIDX_RELOAD_OBJECT: + if (_loadedObject != nullptr) + { + auto descriptor = _loadedObject->GetDescriptor(); + auto& objectManager = OpenRCT2::GetContext()->GetObjectManager(); + auto entryIndex = objectManager.GetLoadedObjectEntryIndex(descriptor); + if (entryIndex != OBJECT_ENTRY_INDEX_NULL) + { + objectManager.UnloadObjects({ descriptor }); + objectManager.LoadObject(descriptor, entryIndex); + } + } + break; default: if (widgetIndex >= WIDX_TAB_1 && static_cast(widgetIndex) < WIDX_TAB_1 + std::size(ObjectSelectionPages)) @@ -833,6 +847,8 @@ public: widgets[WIDX_INSTALL_TRACK].right = width - 9; widgets[WIDX_FILTER_DROPDOWN].left = width - 250; widgets[WIDX_FILTER_DROPDOWN].right = width - 137; + widgets[WIDX_RELOAD_OBJECT].left = width - 9 - 24; + widgets[WIDX_RELOAD_OBJECT].right = width - 9; // Set pressed widgets pressed_widgets |= 1uLL << WIDX_PREVIEW; @@ -883,6 +899,11 @@ public: } } + if (gConfigGeneral.DebuggingTools) + widgets[WIDX_RELOAD_OBJECT].type = WindowWidgetType::ImgBtn; + else + widgets[WIDX_RELOAD_OBJECT].type = WindowWidgetType::Empty; + if (gScreenFlags & (SCREEN_FLAGS_TRACK_MANAGER | SCREEN_FLAGS_TRACK_DESIGNER)) { widgets[WIDX_ADVANCED].type = WindowWidgetType::Empty; diff --git a/src/openrct2/interface/Window.h b/src/openrct2/interface/Window.h index cf8e96db8a..067da8083a 100644 --- a/src/openrct2/interface/Window.h +++ b/src/openrct2/interface/Window.h @@ -359,7 +359,7 @@ enum WindowDetail #define WC_TRACK_DESIGN_LIST__WIDX_ROTATE 8 #define WC_TRACK_DESIGN_PLACE__WIDX_ROTATE 3 #define WC_MAP__WIDX_ROTATE_90 24 -#define WC_EDITOR_OBJECT_SELECTION__WIDX_TAB_1 21 +#define WC_EDITOR_OBJECT_SELECTION__WIDX_TAB_1 22 #define WC_STAFF__WIDX_PICKUP 9 #define WC_TILE_INSPECTOR__WIDX_BUTTON_ROTATE 13 #define WC_TILE_INSPECTOR__WIDX_BUTTON_COPY 16 diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index e1c8bf952d..fe80d6e4b3 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -4024,6 +4024,8 @@ enum : uint16_t STR_ERR_WALL_ELEMENT_NOT_FOUND = 6611, STR_ERR_BANNER_ELEMENT_NOT_FOUND = 6612, + STR_RELOAD_OBJECT_TIP = 6613, + // 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 };