Replace platform_open_directory_browser() with ShowDirectoryDialog()

This commit is contained in:
Michael Steenbeek 2022-01-25 10:54:12 +01:00 committed by GitHub
parent 98fa424e7b
commit c903d95512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 24 deletions

View File

@ -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, {});
}
}

View File

@ -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.

View File

@ -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();