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 1/4] 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) From da1f618732938d77aa0968380f1de5493cd85019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=BCller?= Date: Sat, 3 Dec 2016 12:39:18 +0100 Subject: [PATCH 2/4] If path to RCT1 is available, load "css50" from there --- src/openrct2/rct2.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/openrct2/rct2.c b/src/openrct2/rct2.c index e1e8318407..ff5761e6f8 100644 --- a/src/openrct2/rct2.c +++ b/src/openrct2/rct2.c @@ -417,8 +417,13 @@ void rct2_update() const utf8 *get_file_path(sint32 pathId) { static utf8 path[MAX_PATH]; - safe_strcpy(path, gRCT2AddressAppPath, sizeof(path)); - safe_strcat_path(path, RCT2FilePaths[pathId], sizeof(path)); + if (pathId == PATH_ID_CSS50 && !str_is_null_or_empty(gConfigGeneral.rct1_path)) { + safe_strcpy(path, gConfigGeneral.rct1_path, sizeof(path)); + safe_strcat_path(path, RCT2FilePaths[PATH_ID_CSS17], sizeof(path)); + } else { + safe_strcpy(path, gRCT2AddressAppPath, sizeof(path)); + safe_strcat_path(path, RCT2FilePaths[pathId], sizeof(path)); + } return path; } From 3409da9aa141ffd749e2ca3a3c9ac3e9774dc249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=BCller?= Date: Tue, 4 Apr 2017 15:27:22 +0200 Subject: [PATCH 3/4] Only load csg1 if necessary --- src/openrct2/drawing/sprite.cpp | 5 +++++ src/openrct2/rct2.c | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/openrct2/drawing/sprite.cpp b/src/openrct2/drawing/sprite.cpp index f58c1752ad..e4f031d1b4 100644 --- a/src/openrct2/drawing/sprite.cpp +++ b/src/openrct2/drawing/sprite.cpp @@ -629,6 +629,11 @@ extern "C" { return &_g2.elements[image_id - SPR_G2_BEGIN]; } + + if (_csg.data == nullptr) + { + gfx_load_csg(); + } return &_csg.elements[image_id - SPR_CSG_BEGIN]; } diff --git a/src/openrct2/rct2.c b/src/openrct2/rct2.c index ff5761e6f8..873d70be2a 100644 --- a/src/openrct2/rct2.c +++ b/src/openrct2/rct2.c @@ -163,7 +163,6 @@ bool rct2_init() if (!gfx_load_g2()) { return false; } - gfx_load_csg(); font_sprite_initialise_characters(); if (!gOpenRCT2Headless) { From ae0c85f009bde785e4f6999b695282cf2bed7b63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=BCller?= Date: Tue, 4 Apr 2017 17:19:52 +0200 Subject: [PATCH 4/4] Add tooltip to the label and warn that restart is required --- data/language/en-GB.txt | 1 + src/openrct2/localisation/string_ids.h | 1 + src/openrct2/windows/options.c | 8 +++++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index 7b14e4b757..83c2119a92 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -4346,6 +4346,7 @@ 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 +STR_6038 :{SMALLFONT}{BLACK}If you have RCT1 installed, set this option to its directory to load scenarios, music, etc. ############# # Scenarios # diff --git a/src/openrct2/localisation/string_ids.h b/src/openrct2/localisation/string_ids.h index 8d7057db30..d5af1cd6e7 100644 --- a/src/openrct2/localisation/string_ids.h +++ b/src/openrct2/localisation/string_ids.h @@ -3692,6 +3692,7 @@ enum { STR_PATH_TO_RCT1_BROWSER = 6035, STR_PATH_TO_RCT1_CLEAR_TIP = 6036, STR_PATH_TO_RCT1_WRONG_ERROR = 6037, + STR_PATH_TO_RCT1_TIP = 6038, // 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 ffacae64ab..6d3e45930b 100644 --- a/src/openrct2/windows/options.c +++ b/src/openrct2/windows/options.c @@ -170,6 +170,7 @@ enum WINDOW_OPTIONS_WIDGET_IDX { WIDX_WINDOW_LIMIT, WIDX_WINDOW_LIMIT_UP, WIDX_WINDOW_LIMIT_DOWN, + WIDX_PATH_TO_RCT1_TEXT, WIDX_PATH_TO_RCT1_BUTTON, WIDX_PATH_TO_RCT1_CLEAR, @@ -333,6 +334,7 @@ static rct_widget window_options_misc_widgets[] = { { 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_12, 1, 10, 142, 264, 275, STR_PATH_TO_RCT1, STR_PATH_TO_RCT1_TIP }, // RCT 1 path text { 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 }, @@ -456,7 +458,7 @@ static rct_window_event_list window_options_events = { (1 << WIDX_TAB_6) | \ (1 << WIDX_TAB_7) -static uint32 window_options_page_enabled_widgets[] = { +static uint64 window_options_page_enabled_widgets[] = { MAIN_OPTIONS_ENABLED_WIDGETS | (1 << WIDX_RESOLUTION) | (1 << WIDX_RESOLUTION_DROPDOWN) | @@ -550,7 +552,7 @@ static uint32 window_options_page_enabled_widgets[] = { (1 << WIDX_WINDOW_LIMIT_UP) | (1 << WIDX_WINDOW_LIMIT_DOWN) | (1 << WIDX_PATH_TO_RCT1_BUTTON) | - (1 << WIDX_PATH_TO_RCT1_CLEAR), + (1ULL << WIDX_PATH_TO_RCT1_CLEAR), MAIN_OPTIONS_ENABLED_WIDGETS | (1 << WIDX_CHANNEL_BUTTON) | @@ -850,6 +852,7 @@ static void window_options_mouseup(rct_window *w, sint32 widgetIndex) SafeFree(gConfigGeneral.rct1_path); gConfigGeneral.rct1_path = rct1path; config_save_default(); + window_error_open(STR_RESTART_REQUIRED, STR_NONE); } else { SafeFree(rct1path); window_error_open(STR_PATH_TO_RCT1_WRONG_ERROR, STR_NONE); @@ -1948,7 +1951,6 @@ 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,