From 18294b4f1be18544ca1a35ee7241d4af637b8e8d Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Sun, 2 Mar 2025 16:30:25 -0600 Subject: [PATCH] make fancy file picker function game-specific --- src/fileio/fileio.hpp | 4 ++++ src/fileio/fileio_party.cpp | 7 +++++++ src/game/boe.dlgutil.cpp | 16 ++++++++-------- src/game/boe.dlgutil.hpp | 4 ++-- src/pcedit/pc.main.cpp | 3 +++ src/scenedit/scen.core.cpp | 4 ++++ 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/fileio/fileio.hpp b/src/fileio/fileio.hpp index b1df83bd..f5ecedf0 100644 --- a/src/fileio/fileio.hpp +++ b/src/fileio/fileio.hpp @@ -29,6 +29,10 @@ bool load_scenario(fs::path file_to_load, cScenario& scenario, bool only_header fs::path nav_get_or_decode_party(); fs::path nav_put_or_temp_party(fs::path def = ""); +fs::path os_file_picker(bool saving); +// The game implements a fancy file picker, the editors just call the OS picker. +extern fs::path run_file_picker(bool saving); + const std::set save_extensions = {".exg", ".boe", ".SAV", ".mac"}; // Return a directory's files sorted by last modified time std::vector> sorted_file_mtimes(fs::path dir, std::set valid_extensions = save_extensions); diff --git a/src/fileio/fileio_party.cpp b/src/fileio/fileio_party.cpp index a0753425..b3c23ccd 100644 --- a/src/fileio/fileio_party.cpp +++ b/src/fileio/fileio_party.cpp @@ -54,6 +54,13 @@ fs::path nav_put_or_temp_party(fs::path def) { } } +fs::path os_file_picker(bool saving) { + if(saving) + return nav_put_or_temp_party(); + else + return nav_get_or_decode_party(); +} + bool load_party(fs::path file_to_load, cUniverse& univ){ bool town_restore = false; bool maps_there = false; diff --git a/src/game/boe.dlgutil.cpp b/src/game/boe.dlgutil.cpp index ce841b43..03b7aa5f 100644 --- a/src/game/boe.dlgutil.cpp +++ b/src/game/boe.dlgutil.cpp @@ -2017,17 +2017,17 @@ fs::path run_autosave_picker(fs::path auto_folder, cDialog* parent) { return cFilePicker(auto_folder, false, parent, true).run(); } -fs::path run_file_picker(bool saving) { - if(!has_feature_flag("file-picker-dialog", "V1") /* TODO check file picker preference */){ - if(saving) - return nav_put_or_temp_party(); - else - return nav_get_or_decode_party(); - } - +fs::path fancy_file_picker(bool saving) { // TODO this is set up to be configurable, but not yet exposed in preferences. fs::path save_folder = get_string_pref("SaveFolder", saveDir.string()); return run_file_picker(save_folder, saving); } +fs::path run_file_picker(bool saving){ + if(has_feature_flag("file-picker-dialog", "V1") && get_bool_pref("FancyFilePicker", true)){ + return fancy_file_picker(saving); + } + + return os_file_picker(saving); +} diff --git a/src/game/boe.dlgutil.hpp b/src/game/boe.dlgutil.hpp index b7154bae..ce3b3bb9 100644 --- a/src/game/boe.dlgutil.hpp +++ b/src/game/boe.dlgutil.hpp @@ -25,8 +25,8 @@ void pick_preferences(bool record = true); void save_prefs(); void tip_of_day(); struct scen_header_type pick_a_scen(); -fs::path run_file_picker(bool saving); +fs::path fancy_file_picker(bool saving); // Pick from the autosaves made while playing in a given save file -fs::path run_autosave_picker(fs::path save_file, cDialog* parent = nullptr); +fs::path run_autosave_picker(fs::path auto_folder, cDialog* parent = nullptr); #endif diff --git a/src/pcedit/pc.main.cpp b/src/pcedit/pc.main.cpp index 105f196d..7011b151 100644 --- a/src/pcedit/pc.main.cpp +++ b/src/pcedit/pc.main.cpp @@ -567,3 +567,6 @@ void pick_preferences() { #endif } +fs::path run_file_picker(bool saving){ + return os_file_picker(saving); +} \ No newline at end of file diff --git a/src/scenedit/scen.core.cpp b/src/scenedit/scen.core.cpp index f2b46b0b..726f0b80 100644 --- a/src/scenedit/scen.core.cpp +++ b/src/scenedit/scen.core.cpp @@ -3776,3 +3776,7 @@ void edit_custom_sounds() { snd_names.swap(scenario.snd_names); } } + +fs::path run_file_picker(bool saving){ + return os_file_picker(saving); +} \ No newline at end of file