fix dialog opening stuff

This commit is contained in:
HJfod 2024-08-24 12:40:32 +03:00
parent 56f878ccb3
commit 62b6241e37
2 changed files with 4 additions and 1 deletions

View file

@ -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<file::FilePickOptions::Filter>())
}
));

View file

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