From 62b6241e37ff12341cb9fb5db8c206f90d2b55af Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Sat, 24 Aug 2024 12:40:32 +0300 Subject: [PATCH] fix dialog opening stuff --- loader/src/loader/SettingNodeV3.cpp | 4 +++- loader/src/platform/windows/nfdwin.cpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/loader/src/loader/SettingNodeV3.cpp b/loader/src/loader/SettingNodeV3.cpp index 93e2ad94..d74bf383 100644 --- a/loader/src/loader/SettingNodeV3.cpp +++ b/loader/src/loader/SettingNodeV3.cpp @@ -409,12 +409,14 @@ void FileSettingNodeV3::onPickFile(CCObject*) { )->show(); } }); + std::error_code ec; m_pickListener.setFilter(file::pick( this->getSetting()->isFolder() ? file::PickMode::OpenFolder : (this->getSetting()->useSaveDialog() ? file::PickMode::SaveFile : file::PickMode::OpenFile), { - dirs::getGameDir(), + // Prefer opening the current path directly if possible + m_path.empty() || !std::filesystem::exists(m_path.parent_path(), ec) ? dirs::getGameDir() : m_path, this->getSetting()->getFilters().value_or(std::vector()) } )); diff --git a/loader/src/platform/windows/nfdwin.cpp b/loader/src/platform/windows/nfdwin.cpp index 872963e0..6842135d 100644 --- a/loader/src/platform/windows/nfdwin.cpp +++ b/loader/src/platform/windows/nfdwin.cpp @@ -182,6 +182,7 @@ Result<> nfdPick( } if (options.defaultPath && options.defaultPath.value().wstring().size()) { std::filesystem::path path = options.defaultPath.value(); + path.make_preferred(); if (mode == NFDMode::OpenFile || mode == NFDMode::SaveFile) { if (!std::filesystem::exists(path) || !std::filesystem::is_directory(path)) { if (path.has_filename()) {