Skip to content

Commit 0f4fca4

Browse files
committed
ui: set VMUPath and SavePath options a single path instead of a list
Fix naming of arcade flash save files when using a custom path. Get rid of legacy net:nvmem option. Issue #2111
1 parent f2fe918 commit 0f4fca4

File tree

4 files changed

+30
-57
lines changed

4 files changed

+30
-57
lines changed

core/cfg/option.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ Option<bool> OpenGlChecks("OpenGlChecks", false, "validate");
137137

138138
Option<std::vector<std::string>, false> ContentPath("Dreamcast.ContentPath");
139139
Option<std::vector<std::string>, false> BiosPath("Dreamcast.BiosPath");
140-
Option<std::vector<std::string>, false> VMUPath("Dreamcast.VMUPath");
140+
Option<std::string, false> VMUPath("Dreamcast.VMUPath");
141141
Option<std::vector<std::string>, false> SavestatePath("Dreamcast.SavestatePath");
142-
Option<std::vector<std::string>, false> SavePath("Dreamcast.SavePath");
142+
Option<std::string, false> SavePath("Dreamcast.SavePath");
143143
Option<std::vector<std::string>, false> TexturePath("Dreamcast.TexturePath");
144144
Option<std::string, false> TextureDumpPath("Dreamcast.TextureDumpPath");
145145
Option<std::string, false> BoxartPath("Dreamcast.BoxartPath");

core/cfg/option.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,9 @@ extern Option<bool> OpenGlChecks;
493493

494494
extern Option<std::vector<std::string>, false> ContentPath;
495495
extern Option<std::vector<std::string>, false> BiosPath;
496-
extern Option<std::vector<std::string>, false> VMUPath;
496+
extern Option<std::string, false> VMUPath;
497497
extern Option<std::vector<std::string>, false> SavestatePath;
498-
extern Option<std::vector<std::string>, false> SavePath;
498+
extern Option<std::string, false> SavePath;
499499
extern Option<std::vector<std::string>, false> TexturePath;
500500
extern Option<std::string, false> TextureDumpPath;
501501
extern Option<std::string, false> BoxartPath;

core/oslib/oslib.cpp

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,14 @@ std::string getVmuPath(const std::string& port, bool save)
6969
if (vmuName.empty())
7070
vmuName = "vmu_save_" + port + ".bin";
7171

72-
// Check user-defined VMU paths first
73-
for (const auto& userPath : config::VMUPath.get())
72+
// Check user-defined VMU path first
73+
if (!config::VMUPath.get().empty())
7474
{
75-
if (!userPath.empty())
76-
{
77-
try {
78-
std::string fullpath = hostfs::storage().getSubPath(userPath, vmuName);
79-
if (save || hostfs::storage().exists(fullpath))
80-
return fullpath;
81-
} catch (const hostfs::StorageException& e) {
82-
}
75+
try {
76+
std::string fullpath = hostfs::storage().getSubPath(config::VMUPath, vmuName);
77+
if (save || hostfs::storage().exists(fullpath))
78+
return fullpath;
79+
} catch (const hostfs::StorageException& e) {
8380
}
8481
}
8582

@@ -108,29 +105,12 @@ std::string getVmuPath(const std::string& port, bool save)
108105

109106
std::string getArcadeFlashPath()
110107
{
111-
std::string nvmemSuffix = cfgLoadStr("net", "nvmem", "");
112-
std::string fileName = get_file_basename(settings.content.fileName) + nvmemSuffix;
113-
114-
// Check user-defined save paths first (for writes, use the first path)
115-
for (const auto& userPath : config::SavePath.get())
116-
{
117-
if (!userPath.empty())
118-
{
119-
try {
120-
std::string fullpath = hostfs::storage().getSubPath(userPath, fileName);
121-
// For saves, we use the first valid path for writing
122-
// but check all paths when reading existing files
123-
if (!config::SavePath.get().empty() && userPath == config::SavePath.get()[0])
124-
return fullpath; // Primary save path for new files
125-
if (hostfs::storage().exists(fullpath))
126-
return fullpath; // Existing save found in this path
127-
} catch (const hostfs::StorageException& e) {
128-
}
129-
}
130-
}
131-
132-
// Fall back to default
133-
return get_game_save_prefix() + nvmemSuffix;
108+
// Check user-defined save path first
109+
if (!config::SavePath.get().empty())
110+
return config::SavePath.get() + "/" + settings.content.fileName;
111+
else
112+
// Fall back to default
113+
return get_game_save_prefix();
134114
}
135115

136116
std::string findFlash(const std::string& prefix, const std::string& names)

core/ui/settings_general.cpp

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ static void managePathListCallback(std::string selection)
3535
}
3636
}
3737

38-
static bool manageSinglePath(const char* label, config::Option<std::string, false>& pathOption, const char* helpText)
38+
static void manageSinglePath(const char* label, config::Option<std::string, false>& pathOption, const char* helpText)
3939
{
40-
const std::string popupName = std::string("Select ") + label;
4140
ImVec2 size;
4241
size.x = 0.0f;
4342
size.y = ImGui::GetTextLineHeightWithSpacing() + ImGui::GetStyle().FramePadding.y * 2.f;
@@ -65,10 +64,16 @@ static bool manageSinglePath(const char* label, config::Option<std::string, fals
6564
ImGui::SameLine();
6665
ShowHelpMarker(helpText);
6766

67+
static std::string *pCurrentPath;
68+
pCurrentPath = &pathOption.get();
69+
const std::string popupName = std::string("Select ") + label;
70+
select_file_popup(popupName.c_str(), [](bool cancelled, std::string selection) {
71+
if (!cancelled)
72+
*pCurrentPath = selection;
73+
return true;
74+
});
6875
if (openPopup)
6976
ImGui::OpenPopup(popupName.c_str());
70-
71-
return openPopup;
7277
}
7378

7479
static void managePathList(const char* label, std::vector<std::string>& paths, const char* helpText)
@@ -419,16 +424,16 @@ void gui_settings_general()
419424
ImGui::Spacing();
420425

421426
#if !defined(__ANDROID__)
422-
managePathList("VMU Folders", config::VMUPath.get(),
423-
"Folders where VMU (.bin) saves are stored. First path is used for new saves; all are searched when loading");
427+
manageSinglePath("VMU Folder", config::VMUPath,
428+
"Folder where VMU (.bin) saves are stored");
424429
ImGui::Spacing();
425430

426431
managePathList("Savestate Folders", config::SavestatePath.get(),
427432
"Folders for save states. First path is used for new states; all are searched when loading");
428433
ImGui::Spacing();
429434

430-
managePathList("Game Save Folders", config::SavePath.get(),
431-
"Folders for game save data (e.g. arcade NVRAM). First path is used for new saves; all are searched when loading");
435+
manageSinglePath("Game Save Folder", config::SavePath,
436+
"Folder for game save data (e.g. arcade NVRAM)");
432437
ImGui::Spacing();
433438
#endif
434439

@@ -439,22 +444,10 @@ void gui_settings_general()
439444
#if !defined(__ANDROID__)
440445
manageSinglePath("Texture Dump Folder", config::TextureDumpPath,
441446
"Folder where texture dumps are saved. Game-specific subfolders will be created automatically");
442-
// Handle texture dump folder popup
443-
select_file_popup("Select Texture Dump Folder", [](bool cancelled, std::string selection) {
444-
if (!cancelled)
445-
config::TextureDumpPath = selection;
446-
return true;
447-
});
448447
ImGui::Spacing();
449448

450449
manageSinglePath("Box Art Folder", config::BoxartPath,
451450
"Folder containing box art images (png/jpg). If empty, Flycast will use the default Home Folder/boxart for downloads and generated art");
452-
// Handle box art folder popup
453-
select_file_popup("Select Box Art Folder", [](bool cancelled, std::string selection) {
454-
if (!cancelled)
455-
config::BoxartPath = selection;
456-
return true;
457-
});
458451
ImGui::Spacing();
459452

460453
managePathList("Controller Mapping Folders", config::MappingsPath.get(),

0 commit comments

Comments
 (0)