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

Merge old and new FileDialogDesc

This commit is contained in:
Gymnasiast
2022-01-28 23:50:24 +01:00
parent f43a4344ce
commit 55591b1b2f
8 changed files with 42 additions and 78 deletions

View File

@@ -138,7 +138,7 @@ namespace OpenRCT2::Ui
{
case DIALOG_TYPE::KDIALOG:
{
std::string action = (desc.Type == FILE_DIALOG_TYPE::OPEN) ? "--getopenfilename" : "--getsavefilename";
std::string action = (desc.Type == FileDialogType::Open) ? "--getopenfilename" : "--getsavefilename";
std::string filter = GetKDialogFilterString(desc.Filters);
std::string cmd = String::StdFormat(
"%s --title '%s' %s '%s' '%s'", executablePath.c_str(), desc.Title.c_str(), action.c_str(),
@@ -154,7 +154,7 @@ namespace OpenRCT2::Ui
{
std::string action = "--file-selection";
std::string flags;
if (desc.Type == FILE_DIALOG_TYPE::SAVE)
if (desc.Type == FileDialogType::Save)
{
flags = "--confirm-overwrite --save";
}
@@ -165,7 +165,7 @@ namespace OpenRCT2::Ui
std::string output;
if (Platform::Execute(cmd, &output) == 0)
{
if (desc.Type == FILE_DIALOG_TYPE::SAVE)
if (desc.Type == FileDialogType::Save)
{
// The default file extension is taken from the **first** available filter, since
// we cannot obtain it from zenity's output. This means that the FileDialogDesc::Filters
@@ -197,14 +197,14 @@ namespace OpenRCT2::Ui
if (!result.empty())
{
if (desc.Type == FILE_DIALOG_TYPE::OPEN && access(result.c_str(), F_OK) == -1)
if (desc.Type == FileDialogType::Open && access(result.c_str(), F_OK) == -1)
{
std::string msg = String::StdFormat(
"\"%s\" not found: %s, please choose another file\n", result.c_str(), strerror(errno));
ShowMessageBox(window, msg);
return ShowFileDialog(window, desc);
}
if (desc.Type == FILE_DIALOG_TYPE::SAVE && access(result.c_str(), F_OK) != -1 && dtype == DIALOG_TYPE::KDIALOG)
if (desc.Type == FileDialogType::Save && access(result.c_str(), F_OK) != -1 && dtype == DIALOG_TYPE::KDIALOG)
{
std::string cmd = String::StdFormat("%s --yesno \"Overwrite %s?\"", executablePath.c_str(), result.c_str());
if (Platform::Execute(cmd) != 0)