1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Remove C strings in ContextOpenCommonFileDialog()

This commit is contained in:
Gymnasiast
2024-10-30 12:47:38 +01:00
parent e46f23702d
commit 95178be1b9
3 changed files with 4 additions and 21 deletions

View File

@@ -1733,22 +1733,6 @@ void ContextQuit()
GetContext()->Quit();
}
bool ContextOpenCommonFileDialog(utf8* outFilename, OpenRCT2::Ui::FileDialogDesc& desc, size_t outSize)
{
try
{
std::string result = GetContext()->GetUiContext()->ShowFileDialog(desc);
String::Set(outFilename, outSize, result.c_str());
return !result.empty();
}
catch (const std::exception& ex)
{
LOG_ERROR(ex.what());
outFilename[0] = '\0';
return false;
}
}
u8string ContextOpenCommonFileDialog(OpenRCT2::Ui::FileDialogDesc& desc)
{
try

View File

@@ -232,5 +232,4 @@ void ContextHandleInput();
void ContextInputHandleKeyboard(bool isTitle);
void ContextQuit();
bool ContextLoadParkFromStream(void* stream);
bool ContextOpenCommonFileDialog(utf8* outFilename, OpenRCT2::Ui::FileDialogDesc& desc, size_t outSize);
u8string ContextOpenCommonFileDialog(OpenRCT2::Ui::FileDialogDesc& desc);

View File

@@ -749,7 +749,7 @@ namespace OpenRCT2::Config
return {};
}
static bool SelectGogInstaller(utf8* installerPath)
static u8string SelectGogInstaller()
{
FileDialogDesc desc{};
desc.Type = FileDialogType::Open;
@@ -760,7 +760,7 @@ namespace OpenRCT2::Config
const auto userHomePath = Platform::GetFolderPath(SPECIAL_FOLDER::USER_HOME);
desc.InitialDirectory = userHomePath;
return ContextOpenCommonFileDialog(installerPath, desc, 4096);
return ContextOpenCommonFileDialog(desc);
}
static bool ExtractGogInstaller(const u8string& installerPath, const u8string& targetPath)
@@ -888,8 +888,8 @@ namespace OpenRCT2::Config
while (true)
{
uiContext->ShowMessageBox(LanguageGetString(STR_PLEASE_SELECT_GOG_INSTALLER));
utf8 gogPath[4096];
if (!SelectGogInstaller(gogPath))
auto gogPath = SelectGogInstaller();
if (gogPath.empty())
{
// The user clicked "Cancel", so stop trying.
return false;