diff --git a/src/openrct2-ui/windows/Options.cpp b/src/openrct2-ui/windows/Options.cpp index 9d2ace0858..8b1d8d140e 100644 --- a/src/openrct2-ui/windows/Options.cpp +++ b/src/openrct2-ui/windows/Options.cpp @@ -2172,37 +2172,35 @@ private: break; case WIDX_PATH_TO_RCT1_BUTTON: { - utf8string rct1path = platform_open_directory_browser(language_get_string(STR_PATH_TO_RCT1_BROWSER)); - if (rct1path != nullptr) + auto rct1path = OpenRCT2::GetContext()->GetUiContext()->ShowDirectoryDialog( + language_get_string(STR_PATH_TO_RCT1_BROWSER)); + if (!rct1path.empty()) { // Check if this directory actually contains RCT1 - if (Csg1datPresentAtLocation(rct1path)) + if (Csg1datPresentAtLocation(rct1path.c_str())) { - if (Csg1idatPresentAtLocation(rct1path)) + if (Csg1idatPresentAtLocation(rct1path.c_str())) { - if (CsgAtLocationIsUsable(rct1path)) + if (CsgAtLocationIsUsable(rct1path.c_str())) { SafeFree(gConfigGeneral.rct1_path); - gConfigGeneral.rct1_path = rct1path; + gConfigGeneral.rct1_path = String::Duplicate(rct1path.c_str()); gConfigInterface.scenarioselect_last_tab = 0; config_save_default(); context_show_error(STR_RESTART_REQUIRED, STR_NONE, {}); } else { - SafeFree(rct1path); context_show_error(STR_PATH_TO_RCT1_IS_WRONG_VERSION, STR_NONE, {}); } } else { - SafeFree(rct1path); context_show_error(STR_PATH_TO_RCT1_DOES_NOT_CONTAIN_CSG1I_DAT, STR_NONE, {}); } } else { - SafeFree(rct1path); context_show_error(STR_PATH_TO_RCT1_WRONG_ERROR, STR_NONE, {}); } } diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index a64056d425..664ebd58dc 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -1537,20 +1537,6 @@ bool platform_open_common_file_dialog(utf8* outFilename, file_dialog_desc* desc, } } -utf8* platform_open_directory_browser(const utf8* title) -{ - try - { - std::string result = GetContext()->GetUiContext()->ShowDirectoryDialog(title); - return String::Duplicate(result.c_str()); - } - catch (const std::exception& ex) - { - log_error(ex.what()); - return nullptr; - } -} - /** * This function is deprecated. * Use IPlatformEnvironment instead. diff --git a/src/openrct2/platform/platform.h b/src/openrct2/platform/platform.h index ace4b5e73e..dee18c31f1 100644 --- a/src/openrct2/platform/platform.h +++ b/src/openrct2/platform/platform.h @@ -97,7 +97,6 @@ uint32_t platform_get_ticks(); void platform_sleep(uint32_t ms); void platform_get_user_directory(utf8* outPath, const utf8* subDirectory, size_t outSize); bool platform_open_common_file_dialog(utf8* outFilename, file_dialog_desc* desc, size_t outSize); -utf8* platform_open_directory_browser(const utf8* title); std::string platform_get_rct1_steam_dir(); std::string platform_get_rct2_steam_dir();