From 9c06699dcedfe84cdf6d699edf0aad9900f8a814 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Wed, 11 Feb 2015 16:02:57 +0000 Subject: [PATCH 1/5] implement more events for object selection window --- src/localisation/string_ids.h | 21 ++ src/object.c | 2 +- src/windows/editor_object_selection.c | 495 +++++++++++++++++++------- 3 files changed, 383 insertions(+), 135 deletions(-) diff --git a/src/localisation/string_ids.h b/src/localisation/string_ids.h index 16a169154f..65841a46a9 100644 --- a/src/localisation/string_ids.h +++ b/src/localisation/string_ids.h @@ -1204,6 +1204,20 @@ enum { STR_AT_LEAST_ONE_PATH_OBJECT_MUST_BE_SELECTED = 3178, STR_INVALID_SELECTION_OF_OBJECTS = 3180, + STR_OBJECT_SELECTION = 3181, + STR_PARK_ENTRANCE_TYPE_MUST_BE_SELECTED = 3182, + STR_WATER_TYPE_MUST_BE_SELECTED = 3183, + STR_OBJECT_SELECTION_RIDE_VEHICLES_ATTRACTIONS = 3184, + STR_OBJECT_SELECTION_SMALL_SCENERY = 3185, + STR_OBJECT_SELECTION_LARGE_SCENERY = 3186, + STR_OBJECT_SELECTION_WALLS_FENCES = 3187, + STR_OBJECT_SELECTION_PATH_SIGNS = 3188, + STR_OBJECT_SELECTION_FOOTPATHS = 3189, + STR_OBJECT_SELECTION_PATH_EXTRAS = 3190, + STR_OBJECT_SELECTION_SCENERY_GROUPS = 3191, + STR_OBJECT_SELECTION_PARK_ENTRANCE = 3192, + STR_OBJECT_SELECTION_WATER = 3193, + STR_OBJECT_SELECTION_SCENARIO_DESCRIPTION = 3194, STR_INVENTION_LIST = 3195, @@ -1298,6 +1312,8 @@ enum { STR_PARK_ENTRANCE_WRONG_DIRECTION_OR_NO_PATH = 3332, STR_SAVE_PLUGIN_DATA = 3333, STR_SAVE_PLUGIN_DATA_TIP = 3334, + STR_ROLLER_COASTER_DESIGNER_SELECT_RIDE_TYPES_VEHICLES = 3335, + STR_TRACK_DESIGNS_MANAGER_SELECT_RIDE_TYPE = 3336, STR_SIX_FLAGS_PARK = 3337, STR_GAME_TOOLS = 3341, @@ -1319,9 +1335,14 @@ enum { STR_SOUND_FORCED_SOFTWARE_BUFFER_MIXING = 3362, STR_SOUND_FORCED_SOFTWARE_BUFFER_MIXING_TIP = 3363, + STR_OBJECT_SELECTION_ADVANCED = 3364, + STR_OBJECT_SELECTION_ADVANCED_TIP = 3365, STR_MAP_RIDE = 3366, + STR_INSTALL_NEW_TRACK_DESIGN = 3376, + STR_INSTALL_NEW_TRACK_DESIGN_TIP = 3377, + STR_TUTORIAL_BEGINNERS = 3385, STR_TUTORIAL_CUSTOM_RIDES = 3386, STR_TUTORIAL_ROLLER_COASTER = 3387, diff --git a/src/object.c b/src/object.c index f055b4a6b4..0dbe65a8e1 100644 --- a/src/object.c +++ b/src/object.c @@ -495,7 +495,7 @@ int object_get_scenario_text(rct_object_entry *entry) void object_free_scenario_text() { if (RCT2_GLOBAL(0x009ADAF8, void*) != NULL) { - free(RCT2_GLOBAL(0x009ADAF8, void*)); + rct2_free(RCT2_GLOBAL(0x009ADAF8, void*)); RCT2_GLOBAL(0x009ADAF8, void*) = NULL; } } diff --git a/src/windows/editor_object_selection.c b/src/windows/editor_object_selection.c index 366ab00d24..813e7a5636 100644 --- a/src/windows/editor_object_selection.c +++ b/src/windows/editor_object_selection.c @@ -19,36 +19,75 @@ *****************************************************************************/ #include "../addresses.h" +#include "../audio/audio.h" #include "../game.h" #include "../interface/widget.h" #include "../interface/window.h" +#include "../localisation/localisation.h" #include "../object.h" -#include "../audio/audio.h" #include "../ride/track.h" #include "error.h" +enum { + WINDOW_OBJECT_SELECTION_PAGE_RIDE_VEHICLES_ATTRACTIONS, + WINDOW_OBJECT_SELECTION_PAGE_SMALL_SCENERY, + WINDOW_OBJECT_SELECTION_PAGE_LARGE_SCENERY, + WINDOW_OBJECT_SELECTION_PAGE_WALLS_FENCES, + WINDOW_OBJECT_SELECTION_PAGE_PATH_SIGNS, + WINDOW_OBJECT_SELECTION_PAGE_FOOTPATHS, + WINDOW_OBJECT_SELECTION_PAGE_PATH_EXTRAS, + WINDOW_OBJECT_SELECTION_PAGE_SCENERY_GROUPS, + WINDOW_OBJECT_SELECTION_PAGE_PARK_ENTRANCE, + WINDOW_OBJECT_SELECTION_PAGE_WATER, + WINDOW_OBJECT_SELECTION_PAGE_SCENARIO_DESCRIPTION, + WINDOW_OBJECT_SELECTION_PAGE_COUNT +}; + #pragma region Widgets enum WINDOW_STAFF_LIST_WIDGET_IDX { - WIDX_EDITOR_OBJECT_SELECTION_BACKGROUND, // 0, 1 - WIDX_EDITOR_OBJECT_SELECTION_TITLE, // 1, 2 - WIDX_EDITOR_OBJECT_SELECTION_CLOSE, // 2, 4 - WIDX_EDITOR_OBJECT_SELECTION_TAB_CONTENT_PANEL, // 3, 8 - WIDX_EDITOR_OBJECT_SELECTION_TAB_1, // 4, 10 - WIDX_EDITOR_OBJECT_SELECTION_TAB_2, // 5, 20 - WIDX_EDITOR_OBJECT_SELECTION_TAB_3, // 6, 40 - WIDX_EDITOR_OBJECT_SELECTION_TAB_4, // 7, 80 - WIDX_EDITOR_OBJECT_SELECTION_TAB_5, // 8, 100 - WIDX_EDITOR_OBJECT_SELECTION_TAB_6, // 9, 200 - WIDX_EDITOR_OBJECT_SELECTION_TAB_7, // 10, 400 - WIDX_EDITOR_OBJECT_SELECTION_TAB_8, // 11, 800 - WIDX_EDITOR_OBJECT_SELECTION_TAB_9, // 12, 1000 - WIDX_EDITOR_OBJECT_SELECTION_TAB_10, // 13, 2000 - WIDX_EDITOR_OBJECT_SELECTION_TAB_11, // 14, 4000 - WIDX_EDITOR_OBJECT_SELECTION_DROPDOWN1, // 15, 8000 - WIDX_EDITOR_OBJECT_SELECTION_LIST, // 16, 10000 - WIDX_EDITOR_OBJECT_SELECTION_FLATBTN, // 17, 20000 - WIDX_EDITOR_OBJECT_SELECTION_DROPDOWN2, // 18, 40000 + WIDX_BACKGROUND, // 0, 1 + WIDX_TITLE, // 1, 2 + WIDX_CLOSE, // 2, 4 + WIDX_TAB_CONTENT_PANEL, // 3, 8 + WIDX_TAB_1, // 4, 10 + WIDX_TAB_2, // 5, 20 + WIDX_TAB_3, // 6, 40 + WIDX_TAB_4, // 7, 80 + WIDX_TAB_5, // 8, 100 + WIDX_TAB_6, // 9, 200 + WIDX_TAB_7, // 10, 400 + WIDX_TAB_8, // 11, 800 + WIDX_TAB_9, // 12, 1000 + WIDX_TAB_10, // 13, 2000 + WIDX_TAB_11, // 14, 4000 + WIDX_DROPDOWN1, // 15, 8000 + WIDX_LIST, // 16, 10000 + WIDX_PREVIEW, // 17, 20000 + WIDX_DROPDOWN2, // 18, 40000 +}; + +static rct_widget window_editor_object_selection_widgets[] = { + { WWT_FRAME, 0, 0, 599, 0, 399, 0xFFFFFFFF, STR_NONE }, + { WWT_CAPTION, 0, 1, 598, 1, 14, 3181, STR_WINDOW_TITLE_TIP }, + { WWT_CLOSEBOX, 0, 587, 597, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, + { WWT_RESIZE, 1, 0, 599, 43, 399, 0xFFFFFFFF, STR_NONE }, + { WWT_TAB, 1, 3, 33, 17, 43, 0x2000144E, 1812 }, + { WWT_TAB, 1, 34, 64, 17, 43, 0x2000144E, 1812 }, + { WWT_TAB, 1, 65, 95, 17, 43, 0x2000144E, 1812 }, + { WWT_TAB, 1, 96, 126, 17, 43, 0x2000144E, 1812 }, + { WWT_TAB, 1, 127, 157, 17, 43, 0x2000144E, 1812 }, + { WWT_TAB, 1, 158, 188, 17, 43, 0x2000144E, 1812 }, + { WWT_TAB, 1, 189, 219, 17, 43, 0x2000144E, 1812 }, + { WWT_TAB, 1, 220, 250, 17, 43, 0x2000144E, 1812 }, + { WWT_TAB, 1, 251, 281, 17, 43, 0x2000144E, 1812 }, + { WWT_TAB, 1, 282, 312, 17, 43, 0x2000144E, 1812 }, + { WWT_TAB, 1, 313, 343, 17, 43, 0x2000144E, 1812 }, + { WWT_DROPDOWN_BUTTON, 0, 470, 591, 23, 34, STR_OBJECT_SELECTION_ADVANCED, STR_OBJECT_SELECTION_ADVANCED_TIP }, + { WWT_SCROLL, 1, 4, 291, 46, 386, 2, STR_NONE }, + { WWT_FLATBTN, 1, 391, 504, 46, 159, 0xFFFFFFFF, STR_NONE }, + { WWT_DROPDOWN_BUTTON, 0, 384, 595, 24, 35, STR_INSTALL_NEW_TRACK_DESIGN, STR_INSTALL_NEW_TRACK_DESIGN_TIP }, + { WIDGETS_END } }; #pragma endregion @@ -57,9 +96,13 @@ enum WINDOW_STAFF_LIST_WIDGET_IDX { static void window_editor_object_selection_emptysub() { } -static void window_editor_object_selection_mouseup(); -static void window_editor_object_selection_scroll_mousedown(); static void window_editor_object_selection_close(); +static void window_editor_object_selection_mouseup(); +static void window_editor_object_selection_scrollgetsize(); +static void window_editor_object_selection_scroll_mousedown(); +static void window_editor_object_selection_scroll_mouseover(); +static void window_editor_object_selection_tooltip(); +static void window_editor_object_selection_invalidate(); static void* window_editor_object_selection_events[] = { window_editor_object_selection_close, @@ -77,17 +120,17 @@ static void* window_editor_object_selection_events[] = { (void*)window_editor_object_selection_emptysub, (void*)window_editor_object_selection_emptysub, (void*)window_editor_object_selection_emptysub, - (void*)0x006AB031, - window_editor_object_selection_scroll_mousedown, + (void*)window_editor_object_selection_scrollgetsize, + (void*)window_editor_object_selection_scroll_mousedown, (void*)window_editor_object_selection_emptysub, - (void*)0x006AB079, + (void*)window_editor_object_selection_scroll_mouseover, (void*)window_editor_object_selection_emptysub, (void*)window_editor_object_selection_emptysub, (void*)window_editor_object_selection_emptysub, - (void*)0x006AB058, + (void*)window_editor_object_selection_tooltip, (void*)window_editor_object_selection_emptysub, (void*)window_editor_object_selection_emptysub, - (void*)0x006AA9FD, + (void*)window_editor_object_selection_invalidate, (void*)0x006AAB56, (void*)0x006AADA3 }; @@ -95,6 +138,10 @@ static void* window_editor_object_selection_events[] = { #pragma endregion static void window_editor_object_set_page(rct_window *w, int page); +static void window_editor_object_selection_set_pressed_tab(rct_window *w); +static int get_object_from_object_selection(uint8 object_type, int y, uint8 *object_selection_flags, rct_object_entry **installed_entry); +static void sub_6D33E2(); +static void editor_load_selected_objects(); /** * @@ -120,14 +167,14 @@ void window_editor_object_selection_open() WC_EDITOR_OBJECT_SELECTION, WF_STICK_TO_FRONT ); - window->widgets = (rct_widget*)0x009ADB00; + window->widgets = window_editor_object_selection_widgets; window->enabled_widgets = - (1 << WIDX_EDITOR_OBJECT_SELECTION_DROPDOWN1) | - (1 << WIDX_EDITOR_OBJECT_SELECTION_DROPDOWN2) | - (1 << WIDX_EDITOR_OBJECT_SELECTION_CLOSE); + (1 << WIDX_DROPDOWN1) | + (1 << WIDX_DROPDOWN2) | + (1 << WIDX_CLOSE); - for (int i = WIDX_EDITOR_OBJECT_SELECTION_TAB_1; i <= WIDX_EDITOR_OBJECT_SELECTION_TAB_11; i++) + for (int i = WIDX_TAB_1; i <= WIDX_TAB_11; i++) window->enabled_widgets |= (1LL << i); window_init_scroll_widgets(window); @@ -140,6 +187,35 @@ void window_editor_object_selection_open() window->colours[2] = 1; } +/** + * + * rct2: 0x006AB199 + */ +static void window_editor_object_selection_close() +{ + rct_window* w; + window_get_register(w); + + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & + (SCREEN_FLAGS_SCENARIO_EDITOR | + SCREEN_FLAGS_TRACK_DESIGNER | + SCREEN_FLAGS_TRACK_MANAGER)) + )return; + + RCT2_CALLPROC_EBPSAFE(0x6ABB66); + editor_load_selected_objects(); + sub_6A9FC0(); + object_free_scenario_text(); + RCT2_CALLPROC_EBPSAFE(0x6AB316); + RCT2_CALLPROC_EBPSAFE(0x685675); + RCT2_CALLPROC_EBPSAFE(0x68585B); + window_new_ride_init_vars(); +} + +/** + * + * rct2: 0x006AAFAB + */ static void window_editor_object_selection_mouseup() { rct_window *w; @@ -148,33 +224,33 @@ static void window_editor_object_selection_mouseup() window_widget_get_registers(w, widgetIndex); switch (widgetIndex) { - case WIDX_EDITOR_OBJECT_SELECTION_CLOSE: + case WIDX_CLOSE: game_do_command(0, 1, 0, 0, GAME_COMMAND_LOAD_OR_QUIT, 1, 0); break; - case WIDX_EDITOR_OBJECT_SELECTION_TAB_1: - case WIDX_EDITOR_OBJECT_SELECTION_TAB_2: - case WIDX_EDITOR_OBJECT_SELECTION_TAB_3: - case WIDX_EDITOR_OBJECT_SELECTION_TAB_4: - case WIDX_EDITOR_OBJECT_SELECTION_TAB_5: - case WIDX_EDITOR_OBJECT_SELECTION_TAB_6: - case WIDX_EDITOR_OBJECT_SELECTION_TAB_7: - case WIDX_EDITOR_OBJECT_SELECTION_TAB_8: - case WIDX_EDITOR_OBJECT_SELECTION_TAB_9: - case WIDX_EDITOR_OBJECT_SELECTION_TAB_10: - case WIDX_EDITOR_OBJECT_SELECTION_TAB_11: - window_editor_object_set_page(w, widgetIndex - WIDX_EDITOR_OBJECT_SELECTION_TAB_1); + case WIDX_TAB_1: + case WIDX_TAB_2: + case WIDX_TAB_3: + case WIDX_TAB_4: + case WIDX_TAB_5: + case WIDX_TAB_6: + case WIDX_TAB_7: + case WIDX_TAB_8: + case WIDX_TAB_9: + case WIDX_TAB_10: + case WIDX_TAB_11: + window_editor_object_set_page(w, widgetIndex - WIDX_TAB_1); break; - case WIDX_EDITOR_OBJECT_SELECTION_DROPDOWN1: + case WIDX_DROPDOWN1: w->list_information_type ^= 1; window_invalidate(w); break; - case WIDX_EDITOR_OBJECT_SELECTION_DROPDOWN2: + case WIDX_DROPDOWN2: if (w->selected_list_item != -1) { w->selected_list_item = -1; - RCT2_CALLPROC_EBPSAFE(0x006A982D); // object_free_scenario_text(); + object_free_scenario_text(); } window_invalidate(w); @@ -188,6 +264,211 @@ static void window_editor_object_selection_mouseup() } } +/** + * + * rct2: 0x006AB031 + */ +static void window_editor_object_selection_scrollgetsize() +{ + rct_window *w; + short scrollIndex; + int numItems, width, height; + + window_scroll_get_registers(w, scrollIndex); + + numItems = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER) ? + RCT2_GLOBAL(0x00F43412, uint16) : + RCT2_ADDRESS(0x00F433E1, uint16)[w->selected_tab]; + + width = 0; + height = numItems * 12; + window_scrollsize_set_registers(width, height); +} + +/** + * + * rct2: 0x006AB0B6 + */ +static void window_editor_object_selection_scroll_mousedown() +{ + short x, y, scrollIndex; + rct_window *w; + + window_scrollmouse_get_registers(w, scrollIndex, x, y); + + uint8 object_selection_flags; + rct_object_entry* installed_entry; + int selected_object = get_object_from_object_selection((w->selected_tab & 0xFF), y, &object_selection_flags, &installed_entry); + if (selected_object == -1 || (object_selection_flags & 0x20)) + return; + + window_invalidate(w); + + sound_play_panned(SOUND_CLICK_1, RCT2_GLOBAL(0x142406C,uint32), 0, 0, 0); + + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) { + if (RCT2_CALLPROC_X(0x6AB54F, 0, 1, 0, 0, 0, 0, (int)installed_entry) & 0x100)return; + + window_close(w); + + //This function calls window_track_list_open + sub_6D33E2(); + return; + } + + int ebx = 6; + // If already selected + if (!(object_selection_flags & 1)) + ebx = 7; + + RCT2_GLOBAL(0xF43411, uint8) = 0; + if (0x100 & RCT2_CALLPROC_X(0x6AB54F, 0, ebx, 0, 0, 0, 0, (int)installed_entry)){ + + rct_string_id error_title; + if (ebx & 1) + error_title = 3176; + else + error_title = 3177; + + window_error_open(error_title, RCT2_GLOBAL(0x141E9AC, uint16)); + return; + } + + if (!RCT2_GLOBAL(0xF43411, uint8) & 1)return; + + window_error_open(3374, 3375); +} + +/** + * + * rct2: 0x006AB079 + */ +static void window_editor_object_selection_scroll_mouseover() +{ + rct_window *w; + rct_object_entry *installedEntry; + int selectedObject; + short x, y, scrollIndex; + uint8 objectSelectionFlags; + + window_scrollmouse_get_registers(w, scrollIndex, x, y); + + selectedObject = get_object_from_object_selection( + w->selected_tab & 0xFF, y, &objectSelectionFlags, &installedEntry + ); + if (objectSelectionFlags & 0x20) + selectedObject = -1; + + if (selectedObject == w->selected_list_item) + return; + + w->selected_list_item = selectedObject; + w->var_494 = (uint32)installedEntry; + object_free_scenario_text(); + if (selectedObject != -1) + object_get_scenario_text(installedEntry); + + window_invalidate(w); +} + +/** + * + * rct2: 0x006AB058 + */ +static void window_editor_object_selection_tooltip() +{ + rct_window *w; + short widgetIndex; + + window_scroll_get_registers(w, widgetIndex); + + switch (widgetIndex) { + case WIDX_TAB_1: + case WIDX_TAB_2: + case WIDX_TAB_3: + case WIDX_TAB_4: + case WIDX_TAB_5: + case WIDX_TAB_6: + case WIDX_TAB_7: + case WIDX_TAB_8: + case WIDX_TAB_9: + case WIDX_TAB_10: + case WIDX_TAB_11: + RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, rct_string_id) = + STR_OBJECT_SELECTION_RIDE_VEHICLES_ATTRACTIONS + (widgetIndex - WIDX_TAB_1); + break; + default: + RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, rct_string_id) = STR_LIST; + break; + } +} + +/** + * + * rct2: 0x006AA9FD + */ +static void window_editor_object_selection_invalidate() +{ + int i, x; + rct_window *w; + rct_widget *widget; + + window_get_register(w); + + // Set pressed widgets + w->pressed_widgets |= 1 << WIDX_PREVIEW; + window_editor_object_selection_set_pressed_tab(w); + if (w->list_information_type & 1) + w->pressed_widgets |= (1 << WIDX_DROPDOWN1); + else + w->pressed_widgets &= ~(1 << WIDX_DROPDOWN1); + + // Set window title and buttons + RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, rct_string_id) = STR_OBJECT_SELECTION_RIDE_VEHICLES_ATTRACTIONS + w->selected_tab; + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) { + w->widgets[WIDX_TITLE].image = STR_TRACK_DESIGNS_MANAGER_SELECT_RIDE_TYPE; + w->widgets[WIDX_CLOSE].type = WWT_EMPTY; + w->widgets[WIDX_DROPDOWN2].type = WWT_DROPDOWN_BUTTON; + } else if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_DESIGNER) { + w->widgets[WIDX_TITLE].image = STR_ROLLER_COASTER_DESIGNER_SELECT_RIDE_TYPES_VEHICLES; + w->widgets[WIDX_CLOSE].type = WWT_CLOSEBOX; + w->widgets[WIDX_DROPDOWN2].type = WWT_EMPTY; + } else { + w->widgets[WIDX_TITLE].image = STR_OBJECT_SELECTION; + w->widgets[WIDX_CLOSE].type = WWT_CLOSEBOX; + w->widgets[WIDX_DROPDOWN2].type = WWT_EMPTY; + } + + // Align tabs, hide advanced ones + x = 3; + for (i = 0; i < WINDOW_OBJECT_SELECTION_PAGE_COUNT; i++) { + widget = &w->widgets[WIDX_TAB_1 + i]; + + if (!(w->list_information_type & 1) && ((1 << i) & 0x5E)) { + widget->type = WWT_EMPTY; + } else { + widget->type = WWT_TAB; + widget->left = x; + widget->right = x + 30; + x += 31; + } + } + + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & (SCREEN_FLAGS_TRACK_MANAGER | SCREEN_FLAGS_TRACK_DESIGNER)) { + w->widgets[WIDX_DROPDOWN1].type = WWT_EMPTY; + for (i = 1; i < WINDOW_OBJECT_SELECTION_PAGE_COUNT; i++) + w->widgets[WIDX_TAB_1 + i].type = WWT_EMPTY; + x = 150; + } else { + w->widgets[WIDX_DROPDOWN1].type = WWT_DROPDOWN_BUTTON; + x = 300; + } + + w->widgets[WIDX_LIST].right = 587 - x; + w->widgets[WIDX_PREVIEW].left = 537 - (x >> 1); + w->widgets[WIDX_PREVIEW].right = w->widgets[WIDX_PREVIEW].left + 113; +} + static void window_editor_object_set_page(rct_window *w, int page) { if (w->selected_tab == page) @@ -197,17 +478,28 @@ static void window_editor_object_set_page(rct_window *w, int page) w->selected_list_item = -1; w->var_494 = 0xFFFFFFFF; w->scrolls[0].v_top = 0; - RCT2_CALLPROC_EBPSAFE(0x006A982D); // object_free_scenario_text(); + object_free_scenario_text(); window_invalidate(w); } -/* rct2: 0x006AA703 +static void window_editor_object_selection_set_pressed_tab(rct_window *w) +{ + int i; + for (i = 0; i < WINDOW_OBJECT_SELECTION_PAGE_COUNT; i++) + w->pressed_widgets &= ~(1 << (WIDX_TAB_1 + i)); + w->pressed_widgets |= 1LL << (WIDX_TAB_1 + w->selected_tab); +} + +/** * Takes the y coordinate of the clicked on scroll list * and converts this into an object selection. * Returns the position in the list. * Object_selection_flags, installed_entry also populated + * + * rct2: 0x006AA703 */ -int get_object_from_object_selection(uint8 object_type, int y, uint8* object_selection_flags, rct_object_entry** installed_entry){ +static int get_object_from_object_selection(uint8 object_type, int y, uint8 *object_selection_flags, rct_object_entry **installed_entry) +{ *installed_entry = RCT2_GLOBAL(RCT2_ADDRESS_INSTALLED_OBJECT_LIST, rct_object_entry*); uint8* selection_flags = RCT2_GLOBAL(RCT2_ADDRESS_EDITOR_OBJECT_FLAGS_LIST, uint8*); int object_count = 0; @@ -227,8 +519,12 @@ int get_object_from_object_selection(uint8 object_type, int y, uint8* object_sel return -1; } -/* rct2: 0x006D33E2 */ -void sub_6d33e2(){ +/** + * + * rct2: 0x006D33E2 + */ +static void sub_6D33E2() +{ RCT2_GLOBAL(0x1357404, sint32) = -1; RCT2_GLOBAL(0x1357408, sint32) = -1; RCT2_GLOBAL(0x135740C, sint32) = -1; @@ -262,72 +558,24 @@ void sub_6d33e2(){ window_track_list_open(item); } -/* rct2: 0x006AB0B6 */ -static void window_editor_object_selection_scroll_mousedown(){ - short x, y, scrollIndex; - rct_window *w; +/** + * + * rct2: 0x006ABBBE + */ +static void editor_load_selected_objects() +{ + uint8 *selection_flags = RCT2_GLOBAL(RCT2_ADDRESS_EDITOR_OBJECT_FLAGS_LIST, uint8*); + rct_object_entry *installed_entry = RCT2_GLOBAL(RCT2_ADDRESS_INSTALLED_OBJECT_LIST, rct_object_entry*); - window_scrollmouse_get_registers(w, scrollIndex, x, y); - - uint8 object_selection_flags; - rct_object_entry* installed_entry; - int selected_object = get_object_from_object_selection((w->selected_tab & 0xFF), y, &object_selection_flags, &installed_entry); - if (selected_object == -1) return; - - if (object_selection_flags & 0x20)return; - - window_invalidate(w); - - sound_play_panned(SOUND_CLICK_1, RCT2_GLOBAL(0x142406C,uint32), 0, 0, 0); - - if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER){ - if (RCT2_CALLPROC_X(0x6AB54F, 0, 1, 0, 0, 0, 0, (int)installed_entry) & 0x100)return; - - window_close(w); - - //This function calls window_track_list_open - sub_6d33e2(); + if (RCT2_GLOBAL(RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS, uint32) == 0) return; - } - - int ebx = 6; - // If already selected - if (!(object_selection_flags & 1)) - ebx = 7; - - RCT2_GLOBAL(0xF43411, uint8) = 0; - if (0x100 & RCT2_CALLPROC_X(0x6AB54F, 0, ebx, 0, 0, 0, 0, (int)installed_entry)){ - - rct_string_id error_title; - if (ebx & 1) - error_title = 3176; - else - error_title = 3177; - - window_error_open(error_title, RCT2_GLOBAL(0x141E9AC, uint16)); - return; - } - - if (!RCT2_GLOBAL(0xF43411, uint8) & 1)return; - - window_error_open(3374, 3375); -} - -/* rct2:0x006ABBBE */ -static void editor_load_selected_objects(){ - uint8* selection_flags = RCT2_GLOBAL(RCT2_ADDRESS_EDITOR_OBJECT_FLAGS_LIST, uint8*); - rct_object_entry* installed_entry = RCT2_GLOBAL(RCT2_ADDRESS_INSTALLED_OBJECT_LIST, rct_object_entry*); - - if (RCT2_GLOBAL(RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS, uint32) == 0)return; - - for (int i = RCT2_GLOBAL(RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS, uint32); i != 0; --i, selection_flags++){ - - if (*selection_flags & 1){ + for (int i = RCT2_GLOBAL(RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS, uint32); i != 0; i--, selection_flags++) { + if (*selection_flags & 1) { uint8 entry_index, entry_type; if (!find_object_in_entry_group(installed_entry, &entry_type, &entry_index)){ int chunk_size; - if (!object_load(-1, installed_entry, &chunk_size)){ + if (!object_load(-1, installed_entry, &chunk_size)) { log_error("Failed to load entry %.8s", installed_entry->name); } } @@ -335,25 +583,4 @@ static void editor_load_selected_objects(){ installed_entry = object_get_next(installed_entry); } -} - -/* rct2: 0x006AB199 */ -static void window_editor_object_selection_close(){ - rct_window* w; - window_get_register(w); - - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & - (SCREEN_FLAGS_SCENARIO_EDITOR | - SCREEN_FLAGS_TRACK_DESIGNER | - SCREEN_FLAGS_TRACK_MANAGER)) - )return; - - RCT2_CALLPROC_EBPSAFE(0x6ABB66); - editor_load_selected_objects(); - sub_6A9FC0(); - RCT2_CALLPROC_EBPSAFE(0x6A982D); - RCT2_CALLPROC_EBPSAFE(0x6AB316); - RCT2_CALLPROC_EBPSAFE(0x685675); - RCT2_CALLPROC_EBPSAFE(0x68585B); - window_new_ride_init_vars(); } \ No newline at end of file From 59eff1f57264ab0ccc183173b3617314cc6f5508 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Wed, 11 Feb 2015 17:50:52 +0000 Subject: [PATCH 2/5] implement window_editor_object_selection_paint --- src/windows/editor_object_selection.c | 119 +++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 1 deletion(-) diff --git a/src/windows/editor_object_selection.c b/src/windows/editor_object_selection.c index 813e7a5636..8f99f20661 100644 --- a/src/windows/editor_object_selection.c +++ b/src/windows/editor_object_selection.c @@ -103,6 +103,7 @@ static void window_editor_object_selection_scroll_mousedown(); static void window_editor_object_selection_scroll_mouseover(); static void window_editor_object_selection_tooltip(); static void window_editor_object_selection_invalidate(); +static void window_editor_object_selection_paint(); static void* window_editor_object_selection_events[] = { window_editor_object_selection_close, @@ -131,7 +132,7 @@ static void* window_editor_object_selection_events[] = { (void*)window_editor_object_selection_emptysub, (void*)window_editor_object_selection_emptysub, (void*)window_editor_object_selection_invalidate, - (void*)0x006AAB56, + (void*)window_editor_object_selection_paint, (void*)0x006AADA3 }; @@ -469,6 +470,122 @@ static void window_editor_object_selection_invalidate() w->widgets[WIDX_PREVIEW].right = w->widgets[WIDX_PREVIEW].left + 113; } +/** + * + * rct2: 0x006AAB56 + */ +static void window_editor_object_selection_paint() +{ + int i, x, y, width, numSelected, totalSelectable, type; + rct_window *w; + rct_drawpixelinfo *dpi; + rct_widget *widget; + rct_object_entry *highlightedEntry; + rct_string_id stringId; + uint8 *text; + char *name, *stringBuffer; + + window_paint_get_registers(w, dpi); + + window_draw_widgets(w, dpi); + + // Draw tabs + for (i = 0; i < WINDOW_OBJECT_SELECTION_PAGE_COUNT; i++) { + widget = &w->widgets[WIDX_TAB_1 + i]; + if (widget->type == WWT_EMPTY) + continue; + + x = w->x + widget->left; + y = w->y + widget->top; + gfx_draw_sprite(dpi, 5458 + i, x, y, 0); + } + + // Preview background + widget = &w->widgets[WIDX_PREVIEW]; + gfx_fill_rect( + dpi, + w->x + widget->left + 1, + w->y + widget->top + 1, + w->x + widget->right - 1, + w->y + widget->bottom - 1, + RCT2_ADDRESS(0x0141FC44, uint8)[w->colours[1] * 8] + ); + + // Draw number of selected items + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER)) { + x = w->x + 3; + y = w->y + w->height - 12; + + numSelected = RCT2_ADDRESS(0x00F433F7, uint16)[w->selected_tab]; + totalSelectable = object_entry_group_counts[w->selected_tab]; + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_DESIGNER) + totalSelectable = 4; + + RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 0, uint16) = numSelected; + RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 2, uint16) = totalSelectable; + gfx_draw_string_left(dpi, 3164, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 0, x, y); + } + + if (w->selected_list_item == -1 || RCT2_GLOBAL(0x009ADAF8, sint32) == -1) + return; + + highlightedEntry = (rct_object_entry*)w->var_494; + type = highlightedEntry->flags & 0x0F; + + // Draw preview + widget = &w->widgets[WIDX_PREVIEW]; + x = w->x + (widget->left + widget->right) / 2 + 1; + y = w->y + (widget->top + widget->bottom) / 2 + 1; + object_paint(type, 3, type, x, y, 0, (int)dpi, RCT2_GLOBAL(0x009ADAF8, sint32)); + + // Draw name of object + x = w->x + (widget->left + widget->right) / 2 + 1; + y = w->y + widget->bottom + 3; + width = w->width - w->widgets[WIDX_LIST].right - 6; + + // Skip object dat name + text = (char*)(highlightedEntry + 1); + do { + text++; + } while (*(text - 1) != 0); + text += 4; + name = text; + + RCT2_GLOBAL(0x009BC677, uint8) = 14; + + stringId = 3165; + stringBuffer = (char*)language_get_string(3165) + 1; + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)) { + // Skip name + do { + text++; + } while (*(text - 1) != 0); + text += 4; + text += *text++ * 16; + text += *text++ * 16; + + if (RCT2_GLOBAL(text, uint32) & 0x1000000) { + strcpy(stringBuffer, name); + } else { + int eax = *text; + if (*text == 0xFF) { + eax = *(text + 1); + if (*(text + 1) == 0xFF) + eax = *(text + 2); + } + format_string(stringBuffer, eax + 2, NULL); + } + } else { + strcpy(stringBuffer, name); + } + gfx_draw_string_centred_clipped(dpi, stringId, NULL, 0, x, y, width); + + // Draw description of object + x = w->x + w->widgets[WIDX_LIST].right + 4; + y += 15; + object_paint(type, 259, type, x, y, (int)w, (int)dpi, RCT2_GLOBAL(0x009ADAF8, sint32)); +} + static void window_editor_object_set_page(rct_window *w, int page) { if (w->selected_tab == page) From 51802aac454c4c8132f413516be31ed06b974144 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Wed, 11 Feb 2015 18:54:31 +0000 Subject: [PATCH 3/5] fix object order and add object dat name to object selection window, closes #440 --- src/object.c | 16 ++++++++ src/object.h | 2 + src/object_list.c | 55 ++++++++++++++++++++++++++- src/windows/editor_object_selection.c | 7 +++- 4 files changed, 77 insertions(+), 3 deletions(-) diff --git a/src/object.c b/src/object.c index 0dbe65a8e1..1c35c22076 100644 --- a/src/object.c +++ b/src/object.c @@ -534,4 +534,20 @@ rct_object_entry *object_get_next(rct_object_entry *entry) pos += 4; return (rct_object_entry*)pos; +} + +char *object_get_name(rct_object_entry *entry) +{ + uint8 *pos = (uint8*)entry; + + // Skip sizeof(rct_object_entry) + pos += 16; + + // Skip filename + while (*pos++); + + // Skip + pos += 4; + + return pos; } \ No newline at end of file diff --git a/src/object.h b/src/object.h index 239ce2658b..dfe8e6fbc9 100644 --- a/src/object.h +++ b/src/object.h @@ -92,4 +92,6 @@ int find_object_in_entry_group(rct_object_entry* entry, uint8* entry_type, uint8 rct_object_entry *object_list_find(rct_object_entry *entry); +char *object_get_name(rct_object_entry *entry); + #endif \ No newline at end of file diff --git a/src/object_list.c b/src/object_list.c index 6bbd6fc705..5015e6cc05 100644 --- a/src/object_list.c +++ b/src/object_list.c @@ -79,7 +79,7 @@ rct_object_entry_group object_entry_groups[] = { (uint8**)(0x009ACFA4 + (699 * 4)), (rct_object_entry_extended*)(0x00F3F03C + (699 * 20)), // scenery sets (uint8**)(0x009ACFA4 + (718 * 4)), (rct_object_entry_extended*)(0x00F3F03C + (718 * 20)), // park entrance (uint8**)(0x009ACFA4 + (719 * 4)), (rct_object_entry_extended*)(0x00F3F03C + (719 * 20)), // water - (uint8**)(0x009ACFA4 + (720 * 4)), (rct_object_entry_extended*)(0x00F3F03C + (720 * 20)) // scenario text + (uint8**)(0x009ACFA4 + (720 * 4)), (rct_object_entry_extended*)(0x00F3F03C + (720 * 20)) // scenario text }; static int object_list_cache_load(int totalFiles, uint64 totalFileSize, int fileDateModifiedChecksum); @@ -95,6 +95,56 @@ static void get_plugin_path(char *path) free(homePath); } +static void object_list_sort() +{ + rct_object_entry **objectBuffer, *newBuffer, *entry, *destEntry, *lowestEntry; + int numObjects, i, j, bufferSize, entrySize, lowestIndex; + char *objectName, *lowestString; + uint8 *copied; + + objectBuffer = &RCT2_GLOBAL(RCT2_ADDRESS_INSTALLED_OBJECT_LIST, rct_object_entry*); + numObjects = RCT2_GLOBAL(RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS, sint32); + copied = calloc(numObjects, sizeof(uint8)); + + // Get buffer size + entry = *objectBuffer; + for (i = 0; i < numObjects; i++) + entry = object_get_next(entry); + bufferSize = (int)entry - (int)*objectBuffer; + + // Create new buffer + newBuffer = rct2_malloc(bufferSize); + destEntry = newBuffer; + + // Copy over sorted objects + for (i = 0; i < numObjects; i++) { + // Find next lowest string + lowestString = NULL; + entry = *objectBuffer; + for (j = 0; j < numObjects; j++) { + if (!copied[j]) { + objectName = object_get_name(entry); + if (lowestString == NULL || strcmp(objectName, lowestString) < 0) { + lowestEntry = entry; + lowestString = objectName; + lowestIndex = j; + } + } + entry = object_get_next(entry); + } + entrySize = object_get_length(lowestEntry); + memcpy(destEntry, lowestEntry, entrySize); + destEntry = (rct_object_entry*)((int)destEntry + entrySize); + copied[lowestIndex] = 1; + } + + // Replace old buffer + rct2_free(*objectBuffer); + *objectBuffer = newBuffer; + + free(copied); +} + /** * * rct2: 0x006A93CD @@ -111,6 +161,7 @@ static void object_list_examine() object = object_get_next(object); } + object_list_sort(); // Create a search index object_list_create_hash_table(); @@ -488,7 +539,7 @@ void object_list_create_hash_table() // Set hash table slot _installedObjectHashTable[index] = installedObject; - // Next installde object + // Next installed object installedObject = object_get_next(installedObject); } } diff --git a/src/windows/editor_object_selection.c b/src/windows/editor_object_selection.c index 8f99f20661..31c6ee8859 100644 --- a/src/windows/editor_object_selection.c +++ b/src/windows/editor_object_selection.c @@ -483,7 +483,7 @@ static void window_editor_object_selection_paint() rct_object_entry *highlightedEntry; rct_string_id stringId; uint8 *text; - char *name, *stringBuffer; + char *datName, *name, *stringBuffer; window_paint_get_registers(w, dpi); @@ -545,6 +545,7 @@ static void window_editor_object_selection_paint() // Skip object dat name text = (char*)(highlightedEntry + 1); + datName = text; do { text++; } while (*(text - 1) != 0); @@ -584,6 +585,10 @@ static void window_editor_object_selection_paint() x = w->x + w->widgets[WIDX_LIST].right + 4; y += 15; object_paint(type, 259, type, x, y, (int)w, (int)dpi, RCT2_GLOBAL(0x009ADAF8, sint32)); + + // Draw object dat name + strcpy(stringBuffer, datName); + gfx_draw_string_right(dpi, stringId, NULL, 0, w->x + w->width - 5, w->y + w->height - 3 - 12); } static void window_editor_object_set_page(rct_window *w, int page) From 74e1c0923f2800e0215445d0abb8aa7ae1e896a4 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Wed, 11 Feb 2015 19:42:10 +0000 Subject: [PATCH 4/5] implement window_editor_object_selection_scrollpaint --- src/windows/editor_object_selection.c | 75 ++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/src/windows/editor_object_selection.c b/src/windows/editor_object_selection.c index 31c6ee8859..ad19777db7 100644 --- a/src/windows/editor_object_selection.c +++ b/src/windows/editor_object_selection.c @@ -104,6 +104,7 @@ static void window_editor_object_selection_scroll_mouseover(); static void window_editor_object_selection_tooltip(); static void window_editor_object_selection_invalidate(); static void window_editor_object_selection_paint(); +static void window_editor_object_selection_scrollpaint(); static void* window_editor_object_selection_events[] = { window_editor_object_selection_close, @@ -133,7 +134,7 @@ static void* window_editor_object_selection_events[] = { (void*)window_editor_object_selection_emptysub, (void*)window_editor_object_selection_invalidate, (void*)window_editor_object_selection_paint, - (void*)0x006AADA3 + (void*)window_editor_object_selection_scrollpaint }; #pragma endregion @@ -591,6 +592,78 @@ static void window_editor_object_selection_paint() gfx_draw_string_right(dpi, stringId, NULL, 0, w->x + w->width - 5, w->y + w->height - 3 - 12); } +/** + * + * rct2: 0x006AADA3 + */ +static void window_editor_object_selection_scrollpaint() +{ + int x, y, i, colour, colour2, numObjects, type; + short scrollIndex; + rct_object_entry *entry; + rct_window *w; + rct_drawpixelinfo *dpi; + uint8 *itemFlags; + + window_scrollpaint_get_registers(w, dpi, scrollIndex); + + colour = RCT2_ADDRESS(0x0141FC48, uint8)[w->colours[1] * 8]; + colour = (colour << 24) | (colour << 16) | (colour << 8) | colour; + gfx_clear(dpi, colour); + + numObjects = RCT2_GLOBAL(RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS, sint32); + entry = RCT2_GLOBAL(RCT2_ADDRESS_INSTALLED_OBJECT_LIST, rct_object_entry*); + itemFlags = RCT2_GLOBAL(0x009ADAEC, uint8*); + y = 0; + for (i = 0; i < numObjects; i++) { + type = entry->flags & 0x0F; + if (type == w->selected_tab && !(*itemFlags & 0x20)) { + if (y + 12 >= dpi->y && y <= dpi->y + dpi->height) { + // Draw checkbox + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) && !(*itemFlags & 0x20)) + gfx_fill_rect_inset(dpi, 2, y, 11, y + 10, w->colours[1], 0xE0); + + // Highlight background + colour = 142; + if (entry == (rct_object_entry*)w->var_494 && !(*itemFlags & 0x20)) { + gfx_fill_rect(dpi, 0, y, w->width, y + 11, 0x2000031); + colour = 14; + } + + // Draw checkmark + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) && (*itemFlags & 1)) { + x = 2; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, sint16) = colour == 14 ? -2 : -1; + colour2 = w->colours[1] & 0x7F; + if (*itemFlags & 0x1C) + colour2 |= 0x40; + + gfx_draw_string(dpi, (char*)0x009DED72, colour2, x, y); + } + + // Draw text + char *buffer = (char*)0x0141ED68; + *buffer = colour; + strcpy(buffer + 1, object_get_name(entry)); + + if (*itemFlags & 0x20) { + colour = w->colours[1] & 0x7F; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, sint16) = -1; + } else { + colour = 0; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, sint16) = 224; + } + x = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER ? 0 : 15; + gfx_draw_string(dpi, (char*)0x0141ED68, colour, x, y); + } + y += 12; + } + + entry = object_get_next(entry); + itemFlags++; + } +} + static void window_editor_object_set_page(rct_window *w, int page) { if (w->selected_tab == page) From fadeff9dda7af5b165a60288d5574ea8d6eeb13a Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Wed, 11 Feb 2015 21:03:23 +0000 Subject: [PATCH 5/5] fix a few issues with object selection and track manage --- src/ride/track.c | 4 ++-- src/windows/editor_object_selection.c | 15 +++++++++++---- src/windows/text_input.c | 2 +- src/windows/track_manage.c | 13 ++++++++----- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/ride/track.c b/src/ride/track.c index 401a4f09b6..5fd5c48622 100644 --- a/src/ride/track.c +++ b/src/ride/track.c @@ -1049,7 +1049,7 @@ rct_track_design *track_get_info(int index, uint8** preview) */ int track_rename(const char *text) { - return (RCT2_CALLPROC_X(0x006D3664, 0, 0, 0, (int)text, 0, 0, 0) & 0x100) != 0; + return (RCT2_CALLPROC_X(0x006D3664, 0, 0, 0, 0, 0, (int)text, 0) & 0x100) == 0; } /** @@ -1058,5 +1058,5 @@ int track_rename(const char *text) */ int track_delete() { - return (RCT2_CALLPROC_X(0x006D3761, 0, 0, 0, 0, 0, 0, 0) & 0x100) != 0; + return (RCT2_CALLPROC_X(0x006D3761, 0, 0, 0, 0, 0, 0, 0) & 0x100) == 0; } diff --git a/src/windows/editor_object_selection.c b/src/windows/editor_object_selection.c index ad19777db7..ea33086ac2 100644 --- a/src/windows/editor_object_selection.c +++ b/src/windows/editor_object_selection.c @@ -309,7 +309,8 @@ static void window_editor_object_selection_scroll_mousedown() sound_play_panned(SOUND_CLICK_1, RCT2_GLOBAL(0x142406C,uint32), 0, 0, 0); if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) { - if (RCT2_CALLPROC_X(0x6AB54F, 0, 1, 0, 0, 0, 0, (int)installed_entry) & 0x100)return; + if (RCT2_CALLPROC_X(0x6AB54F, 0, 1, 0, 0, 0, 0, (int)installed_entry) & 0x100) + return; window_close(w); @@ -324,8 +325,7 @@ static void window_editor_object_selection_scroll_mousedown() ebx = 7; RCT2_GLOBAL(0xF43411, uint8) = 0; - if (0x100 & RCT2_CALLPROC_X(0x6AB54F, 0, ebx, 0, 0, 0, 0, (int)installed_entry)){ - + if (0x100 & RCT2_CALLPROC_X(0x6AB54F, 0, ebx, 0, 0, 0, 0, (int)installed_entry)) { rct_string_id error_title; if (ebx & 1) error_title = 3176; @@ -336,7 +336,8 @@ static void window_editor_object_selection_scroll_mousedown() return; } - if (!RCT2_GLOBAL(0xF43411, uint8) & 1)return; + if (!RCT2_GLOBAL(0xF43411, uint8) & 1) + return; window_error_open(3374, 3375); } @@ -645,6 +646,12 @@ static void window_editor_object_selection_scrollpaint() char *buffer = (char*)0x0141ED68; *buffer = colour; strcpy(buffer + 1, object_get_name(entry)); + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) { + while (*buffer != 0 && *buffer != 9) + buffer++; + + *buffer = 0; + } if (*itemFlags & 0x20) { colour = w->colours[1] & 0x7F; diff --git a/src/windows/text_input.c b/src/windows/text_input.c index c66ae6f5d8..7fda03eecf 100644 --- a/src/windows/text_input.c +++ b/src/windows/text_input.c @@ -136,7 +136,7 @@ void window_text_input_open(rct_window* call_w, int call_widget, rct_string_id t height, (uint32*)window_text_input_events, WC_TEXTINPUT, - 0 + WF_STICK_TO_FRONT ); w->widgets = window_text_input_widgets; diff --git a/src/windows/track_manage.c b/src/windows/track_manage.c index f636a57c42..17a60a0818 100644 --- a/src/windows/track_manage.c +++ b/src/windows/track_manage.c @@ -146,15 +146,13 @@ static void window_track_delete_prompt_open(); */ void window_track_manage_open() { - // RCT2_CALLPROC_EBPSAFE(0x006D348F); - rct_window *w, *trackDesignListWindow; window_close_by_class(WC_MANAGE_TRACK_DESIGN); w = window_create( max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - 250) / 2), - (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - 44) / 2, + (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 44) / 2, 250, 44, (uint32*)window_track_manage_events, @@ -199,6 +197,7 @@ static void window_track_manage_mouseup() uint8 *trackDesignList = (uint8*)0x00F441EC; rct_window *w, *trackDesignListWindow; short widgetIndex; + char *dst, *src; window_widget_get_registers(w, widgetIndex); @@ -209,8 +208,12 @@ static void window_track_manage_mouseup() case WIDX_RENAME: trackDesignListWindow = window_find_by_class(WC_TRACK_DESIGN_LIST); if (trackDesignListWindow != NULL) { - strcpy((char*)0x009BC677, (char*)trackDesignList[trackDesignListWindow->track_list.var_482 * 128]); - window_show_textinput(w, widgetIndex, 3350, 3351, 3165); + src = &trackDesignList[trackDesignListWindow->track_list.var_482 * 128]; + dst = (char*)0x009BC677; + while (*src != 0 && *src != '.') + *dst++ = *src++; + *dst = 0; + window_text_input_open(w, widgetIndex, 3350, 3351, 3165, 0, 127); } break; case WIDX_DELETE: