make fancy file picker function game-specific

This commit is contained in:
2025-03-02 16:30:25 -06:00
committed by Celtic Minstrel
parent 5bc1643be7
commit 18294b4f1b
6 changed files with 28 additions and 10 deletions

View File

@@ -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<fs::path> save_extensions = {".exg", ".boe", ".SAV", ".mac"};
// Return a directory's files sorted by last modified time
std::vector<std::pair<fs::path, std::time_t>> sorted_file_mtimes(fs::path dir, std::set<fs::path> valid_extensions = save_extensions);

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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

View File

@@ -567,3 +567,6 @@ void pick_preferences() {
#endif
}
fs::path run_file_picker(bool saving){
return os_file_picker(saving);
}

View File

@@ -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);
}