2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-11 15:01:49 +00:00

Fix memcard path CVars and add menu notifying player when they've been reset

This commit is contained in:
2021-06-02 08:06:22 -07:00
parent 561e54527b
commit c6db983c41
7 changed files with 161 additions and 79 deletions

View File

@@ -22,24 +22,38 @@ kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlo
return {};
}
kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot) {
kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot, bool dolphin) {
if (g_Main->IsUSA() && !g_Main->IsTrilogy()) {
const char* home = getenv("HOME");
if (!home)
return {};
if (dolphin) {
const char* home = getenv("HOME");
if (!home)
return {};
kabufuda::SystemString path = home;
path += "/Library/Application Support/Dolphin/GC";
if (hecl::RecursiveMakeDir(path.c_str()) < 0)
return {};
kabufuda::SystemString path = home;
path += "/Library/Application Support/Dolphin/GC";
if (hecl::RecursiveMakeDir(path.c_str()) < 0)
return {};
path += fmt::format(FMT_STRING("/MemoryCard{:c}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
const auto fp = hecl::FopenUnique(path.c_str(), "wb");
if (fp == nullptr) {
return {};
path += fmt::format(FMT_STRING("/MemoryCard{:c}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
const auto fp = hecl::FopenUnique(path.c_str(), "wb");
if (fp == nullptr) {
return {};
}
return path;
} else {
kabufuda::SystemString path = _GetDolphinCardPath(slot);
hecl::SanitizePath(path);
if (path.find('/') == kabufuda::SystemString::npos) {
path = hecl::GetcwdStr() + _SYS_STR("/") + _GetDolphinCardPath(slot);
}
hecl::SystemString tmpPath = path.substr(0, path.find_last_of(_SYS_STR("/")));
hecl::RecursiveMakeDir(tmpPath.c_str());
const auto fp = hecl::FopenUnique(path.c_str(), "wb");
if (fp) {
return path;
}
}
return path;
}
return {};
}