diff --git a/src/editor.c b/src/editor.c index 4d92429e2c..8c80024260 100644 --- a/src/editor.c +++ b/src/editor.c @@ -602,13 +602,55 @@ static void editor_finalise_main_view() gfx_invalidate_screen(); } +static bool editor_check_object_group_at_least_one_selected(int objectType) +{ + uint32 numObjects = RCT2_GLOBAL(RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS, uint32); + rct_object_entry *entry = RCT2_GLOBAL(RCT2_ADDRESS_INSTALLED_OBJECT_LIST, rct_object_entry*); + uint8 *objectFlag = RCT2_GLOBAL(RCT2_ADDRESS_EDITOR_OBJECT_FLAGS_LIST, uint8*); + for (uint32 i = 0; i < numObjects; i++) { + if ((entry->flags & 0x0F) == objectType && (*objectFlag & 1)) { + return true; + } + entry = object_get_next(entry); + objectFlag++; + } + return false; +} + /** * * rct2: 0x006AB9B8 */ -bool editor_check_object_selection() +int editor_check_object_selection() { - return !(RCT2_CALLPROC_EBPSAFE(0x006AB9B8) & 0x100); + bool isTrackDesignerManager = + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER); + + if (!isTrackDesignerManager) { + if (!editor_check_object_group_at_least_one_selected(OBJECT_TYPE_PATHS)) { + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_AT_LEAST_ONE_PATH_OBJECT_MUST_BE_SELECTED; + return OBJECT_TYPE_PATHS; + } + } + + if (!editor_check_object_group_at_least_one_selected(OBJECT_TYPE_RIDE)) { + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_AT_LEAST_ONE_RIDE_OBJECT_MUST_BE_SELECTED; + return OBJECT_TYPE_RIDE; + } + + if (!isTrackDesignerManager) { + if (!editor_check_object_group_at_least_one_selected(OBJECT_TYPE_PARK_ENTRANCE)) { + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_PARK_ENTRANCE_TYPE_MUST_BE_SELECTED; + return OBJECT_TYPE_PARK_ENTRANCE; + } + + if (!editor_check_object_group_at_least_one_selected(OBJECT_TYPE_WATER)) { + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_WATER_TYPE_MUST_BE_SELECTED; + return OBJECT_TYPE_WATER; + } + } + + return -1; } /** diff --git a/src/editor.h b/src/editor.h index 8c0fd56699..ac83963cd4 100644 --- a/src/editor.h +++ b/src/editor.h @@ -48,6 +48,6 @@ void sub_6BD3A4(); void editor_open_windows_for_current_step(); bool editor_check_park(); -bool editor_check_object_selection(); +int editor_check_object_selection(); #endif diff --git a/src/localisation/string_ids.h b/src/localisation/string_ids.h index 73519e94d6..768315e2a9 100644 --- a/src/localisation/string_ids.h +++ b/src/localisation/string_ids.h @@ -1515,6 +1515,7 @@ enum { STR_UNABLE_TO_SELECT_THIS_OBJECT = 3176, STR_UNABLE_TO_DE_SELECT_THIS_OBJECT = 3177, STR_AT_LEAST_ONE_PATH_OBJECT_MUST_BE_SELECTED = 3178, + STR_AT_LEAST_ONE_RIDE_OBJECT_MUST_BE_SELECTED = 3179, STR_INVALID_SELECTION_OF_OBJECTS = 3180, STR_OBJECT_SELECTION = 3181, diff --git a/src/windows/editor_bottom_toolbar.c b/src/windows/editor_bottom_toolbar.c index b5c15ce0cf..ed530f3469 100644 --- a/src/windows/editor_bottom_toolbar.c +++ b/src/windows/editor_bottom_toolbar.c @@ -218,7 +218,8 @@ bool window_editor_bottom_toolbar_check_object_selection() { rct_window *w; - if (editor_check_object_selection()) { + int missingObjectType = editor_check_object_selection(); + if (missingObjectType < 0) { window_close_by_class(WC_EDITOR_OBJECT_SELECTION); return true; } @@ -226,8 +227,8 @@ bool window_editor_bottom_toolbar_check_object_selection() window_error_open(STR_INVALID_SELECTION_OF_OBJECTS, RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id)); w = window_find_by_class(WC_EDITOR_OBJECT_SELECTION); if (w != NULL) { - // Click first tab (rides) - window_event_mouse_up_call(w, 4); + // Click tab with missing object + window_event_mouse_up_call(w, 4 + missingObjectType); } return false; }