From b1bd899fb8902c556a8eccbd68b7bb6f5ca10f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=BCller?= Date: Tue, 22 Nov 2016 14:58:48 +0100 Subject: [PATCH] Add menu option for path to RCT 1 --- data/language/en-GB.txt | 9 +++- src/openrct2/localisation/string_ids.h | 6 +++ src/openrct2/windows/options.c | 68 ++++++++++++++++++++++++-- 3 files changed, 78 insertions(+), 5 deletions(-) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index fffe321d4b..7b14e4b757 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -2748,7 +2748,7 @@ STR_2739 :None STR_2740 :RollerCoaster Tycoon 1 STR_2741 :RollerCoaster Tycoon 2 STR_2742 :css50.dat not found -STR_2743 :Copy data\css17.dat from your RCT1 installation to data\css50.dat in your RCT2 installation. +STR_2743 :Copy data\css17.dat from your RCT1 installation to data\css50.dat in your RCT2 installation, or make sure the path to RCT1 in the Miscellaneous tab is correct. STR_2744 :[ STR_2745 :\ STR_2746 :] @@ -4144,7 +4144,7 @@ STR_5832 :{SMALLFONT}{BLACK}Show height as generic units instead of measureme STR_5833 :{SMALLFONT}{BLACK}Changes what date format is used STR_5834 :{SMALLFONT}{BLACK}Select which audio device OpenRCT2 will use STR_5835 :{SMALLFONT}{BLACK}Mute the game if the window loses focus -STR_5836 :{SMALLFONT}{BLACK}Select music to use on the main menu.{NEWLINE}Selecting RCT1 theme requires that you copy 'data/css17.dat' from your RCT1 game folder to 'data/css50.dat' in your RCT2 folder. +STR_5836 :{SMALLFONT}{BLACK}Select music to use on the main menu.{NEWLINE}Selecting RCT1 theme requires that you copy 'data/css17.dat' from your RCT1 game folder to 'data/css50.dat' in your RCT2 folder, or set the path to RCT1 in the Miscellaneous tab. STR_5837 :{SMALLFONT}{BLACK}Create and manage custom UI themes STR_5838 :{SMALLFONT}{BLACK}Show a separate button for the finance window in the toolbar STR_5839 :{SMALLFONT}{BLACK}Show a separate button for the research and development window in the toolbar @@ -4341,6 +4341,11 @@ STR_6029 :Ride construction - Demolish current STR_6030 :{SMALLFONT}{BLACK}Scenery picker. Click any scenery on the map to select the same piece for construction. STR_6031 :Server Description: STR_6032 :Server Greeting: +STR_6033 :Path to RCT1 installation: +STR_6034 :{SMALLFONT}{BLACK}{STRING} +STR_6035 :Please select your RCT1 directory +STR_6036 :{SMALLFONT}{BLACK}Clear +STR_6037 :Please select a valid RCT1 directory ############# # Scenarios # diff --git a/src/openrct2/localisation/string_ids.h b/src/openrct2/localisation/string_ids.h index 469c312960..8d7057db30 100644 --- a/src/openrct2/localisation/string_ids.h +++ b/src/openrct2/localisation/string_ids.h @@ -3687,6 +3687,12 @@ enum { STR_SERVER_DESCRIPTION = 6031, STR_SERVER_GREETING = 6032, + STR_PATH_TO_RCT1 = 6033, + STR_STRING_TOOLTIP = 6034, + STR_PATH_TO_RCT1_BROWSER = 6035, + STR_PATH_TO_RCT1_CLEAR_TIP = 6036, + STR_PATH_TO_RCT1_WRONG_ERROR = 6037, + // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working STR_COUNT = 32768 }; diff --git a/src/openrct2/windows/options.c b/src/openrct2/windows/options.c index db33f67030..ffacae64ab 100644 --- a/src/openrct2/windows/options.c +++ b/src/openrct2/windows/options.c @@ -33,6 +33,7 @@ #include "../interface/window.h" #include "../localisation/currency.h" #include "../localisation/date.h" +#include "../localisation/language.h" #include "../localisation/localisation.h" #include "../platform/platform.h" #include "../rct2.h" @@ -169,6 +170,8 @@ enum WINDOW_OPTIONS_WIDGET_IDX { WIDX_WINDOW_LIMIT, WIDX_WINDOW_LIMIT_UP, WIDX_WINDOW_LIMIT_DOWN, + WIDX_PATH_TO_RCT1_BUTTON, + WIDX_PATH_TO_RCT1_CLEAR, // Twitch WIDX_CHANNEL_BUTTON = WIDX_PAGE_START, @@ -327,9 +330,11 @@ static rct_widget window_options_misc_widgets[] = { { WWT_CHECKBOX, 2, 10, 299, 219, 230, STR_AUTO_OPEN_SHOPS, STR_AUTO_OPEN_SHOPS_TIP }, // Automatically open shops & stalls { WWT_DROPDOWN, 1, 155, 299, 234, 245, STR_NONE, STR_NONE }, // Default inspection time dropdown { WWT_DROPDOWN_BUTTON, 1, 288, 298, 235, 244, STR_DROPDOWN_GLYPH, STR_DEFAULT_INSPECTION_INTERVAL_TIP }, // Default inspection time dropdown button - { WWT_SPINNER, 1, 155, 299, 249, 260, STR_NONE, STR_NONE }, // Window limit + { WWT_SPINNER, 1, 155, 299, 249, 260, STR_NONE, STR_NONE }, // Window limit { WWT_DROPDOWN_BUTTON, 1, 288, 298, 250, 254, STR_NUMERIC_UP, STR_NONE }, // Window limit up { WWT_DROPDOWN_BUTTON, 1, 288, 298, 255, 259, STR_NUMERIC_DOWN, STR_NONE }, // Window limit down + { WWT_DROPDOWN_BUTTON, 1, 10, 289, 278, 289, STR_NONE, STR_STRING_TOOLTIP }, // RCT 1 path button + { WWT_DROPDOWN_BUTTON, 1, 289, 299, 278, 289, STR_CLOSE_X, STR_PATH_TO_RCT1_CLEAR_TIP }, // RCT 1 path clear button { WIDGETS_END }, }; @@ -404,6 +409,7 @@ static void window_options_invalidate(rct_window *w); static void window_options_paint(rct_window *w, rct_drawpixelinfo *dpi); static void window_options_scrollgetsize(rct_window *w, sint32 scrollIndex, sint32 *width, sint32 *height); static void window_options_text_input(rct_window *w, sint32 widgetIndex, char *text); +static void window_options_tooltip(rct_window *w, sint32 widgetIndex, rct_string_id *stringid); static rct_window_event_list window_options_events = { NULL, @@ -428,7 +434,7 @@ static rct_window_event_list window_options_events = { window_options_text_input, NULL, NULL, - NULL, + window_options_tooltip, NULL, NULL, window_options_invalidate, @@ -542,7 +548,9 @@ static uint32 window_options_page_enabled_widgets[] = { (1 << WIDX_DEFAULT_INSPECTION_INTERVAL_DROPDOWN) | (1 << WIDX_WINDOW_LIMIT) | (1 << WIDX_WINDOW_LIMIT_UP) | - (1 << WIDX_WINDOW_LIMIT_DOWN), + (1 << WIDX_WINDOW_LIMIT_DOWN) | + (1 << WIDX_PATH_TO_RCT1_BUTTON) | + (1 << WIDX_PATH_TO_RCT1_CLEAR), MAIN_OPTIONS_ENABLED_WIDGETS | (1 << WIDX_CHANNEL_BUTTON) | @@ -828,6 +836,35 @@ static void window_options_mouseup(rct_window *w, sint32 widgetIndex) config_save_default(); window_invalidate(w); break; + case WIDX_PATH_TO_RCT1_BUTTON: + { + utf8string rct1path = platform_open_directory_browser(language_get_string(STR_PATH_TO_RCT1_BROWSER)); + if (rct1path) { + // Check if this directory actually contains RCT1 + utf8 checkpath[MAX_PATH]; + safe_strcpy(checkpath, rct1path, MAX_PATH); + safe_strcat_path(checkpath, "Data", MAX_PATH); + safe_strcat_path(checkpath, "csg1.1", MAX_PATH); + if (platform_file_exists(checkpath)) + { + SafeFree(gConfigGeneral.rct1_path); + gConfigGeneral.rct1_path = rct1path; + config_save_default(); + } else { + SafeFree(rct1path); + window_error_open(STR_PATH_TO_RCT1_WRONG_ERROR, STR_NONE); + } + } + window_invalidate(w); + break; + } + case WIDX_PATH_TO_RCT1_CLEAR: + if (!str_is_null_or_empty(gConfigGeneral.rct1_path)) { + SafeFree(gConfigGeneral.rct1_path); + config_save_default(); + } + window_invalidate(w); + break; } break; @@ -1674,6 +1711,8 @@ static void window_options_invalidate(rct_window *w) window_options_misc_widgets[WIDX_WINDOW_LIMIT].type = WWT_SPINNER; window_options_misc_widgets[WIDX_WINDOW_LIMIT_UP].type = WWT_DROPDOWN_BUTTON; window_options_misc_widgets[WIDX_WINDOW_LIMIT_DOWN].type = WWT_DROPDOWN_BUTTON; + window_options_misc_widgets[WIDX_PATH_TO_RCT1_BUTTON].type = WWT_DROPDOWN_BUTTON; + window_options_misc_widgets[WIDX_PATH_TO_RCT1_CLEAR].type = WWT_DROPDOWN_BUTTON; break; case WINDOW_OPTIONS_PAGE_TWITCH: @@ -1909,6 +1948,17 @@ static void window_options_paint(rct_window *w, rct_drawpixelinfo *dpi) w->x + window_options_misc_widgets[WIDX_WINDOW_LIMIT].left + 1, w->y + window_options_misc_widgets[WIDX_WINDOW_LIMIT].top ); + gfx_draw_string_left(dpi, STR_PATH_TO_RCT1, w, w->colours[1], w->x + 10, w->y + window_options_misc_widgets[WIDX_PATH_TO_RCT1_BUTTON].top - 14); + set_format_arg(0, uintptr_t, (uintptr_t)gConfigGeneral.rct1_path); + gfx_draw_string_left_clipped( + dpi, + STR_STRING, + gCommonFormatArgs, + w->colours[1], + w->x + window_options_misc_widgets[WIDX_PATH_TO_RCT1_BUTTON].left + 1, + w->y + window_options_misc_widgets[WIDX_PATH_TO_RCT1_BUTTON].top, + 277 + ); break; } } @@ -1954,6 +2004,18 @@ static void window_options_text_input(rct_window *w, sint32 widgetIndex, char *t } } +static void window_options_tooltip(rct_window *w, sint32 widgetIndex, rct_string_id *stringid) +{ + if (widgetIndex == WIDX_PATH_TO_RCT1_BUTTON && w->page == WINDOW_OPTIONS_PAGE_MISC) { + if (str_is_null_or_empty(gConfigGeneral.rct1_path)) { + // No tooltip if the path is empty + *stringid = STR_NONE; + } else { + set_format_arg(0, uintptr_t, (uintptr_t)gConfigGeneral.rct1_path); + } + } +} + #pragma region Common static void window_options_set_page(rct_window *w, sint32 page)