mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-05-13 22:31:21 +00:00
Disable saving on non-NTSC-U versions
This commit is contained in:
parent
d16e758f07
commit
ba3b23edaa
@ -1,50 +1,59 @@
|
|||||||
#include "CMemoryCardSys.hpp"
|
#include "CMemoryCardSys.hpp"
|
||||||
|
#include "Runtime/GameGlobalObjects.hpp"
|
||||||
|
#include "Runtime/IMain.hpp"
|
||||||
|
|
||||||
namespace urde {
|
namespace urde {
|
||||||
|
|
||||||
kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) {
|
kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) {
|
||||||
const char* home = getenv("HOME");
|
if (g_Main->IsUSA() && !g_Main->IsTrilogy()) {
|
||||||
if (!home || home[0] != '/')
|
const char* home = getenv("HOME");
|
||||||
return {};
|
if (!home || home[0] != '/')
|
||||||
const char* dataHome = getenv("XDG_DATA_HOME");
|
|
||||||
|
|
||||||
/* XDG-selected data path */
|
|
||||||
kabufuda::SystemString path =
|
|
||||||
((dataHome && dataHome[0] == '/') ? dataHome : hecl::SystemString(home)) + "/.local/share/dolphin-emu";
|
|
||||||
path += fmt::format(FMT_STRING("/GC/MemoryCard{:c}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
|
|
||||||
|
|
||||||
hecl::Sstat theStat;
|
|
||||||
if (hecl::Stat(path.c_str(), &theStat) || !S_ISREG(theStat.st_mode)) {
|
|
||||||
/* legacy case for older dolphin versions */
|
|
||||||
path = home;
|
|
||||||
path += fmt::format(FMT_STRING("/.dolphin-emu/GC/MemoryCard{:c}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
|
|
||||||
if (hecl::Stat(path.c_str(), &theStat) || !S_ISREG(theStat.st_mode))
|
|
||||||
return {};
|
return {};
|
||||||
}
|
const char* dataHome = getenv("XDG_DATA_HOME");
|
||||||
|
|
||||||
return path;
|
/* XDG-selected data path */
|
||||||
|
kabufuda::SystemString path =
|
||||||
|
((dataHome && dataHome[0] == '/') ? dataHome : hecl::SystemString(home)) + "/.local/share/dolphin-emu";
|
||||||
|
path += fmt::format(FMT_STRING("/GC/MemoryCard{:c}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
|
||||||
|
|
||||||
|
hecl::Sstat theStat;
|
||||||
|
if (hecl::Stat(path.c_str(), &theStat) || !S_ISREG(theStat.st_mode)) {
|
||||||
|
/* legacy case for older dolphin versions */
|
||||||
|
path = home;
|
||||||
|
path += fmt::format(FMT_STRING("/.dolphin-emu/GC/MemoryCard{:c}.USA.raw"),
|
||||||
|
slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
|
||||||
|
if (hecl::Stat(path.c_str(), &theStat) || !S_ISREG(theStat.st_mode))
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot) {
|
kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot) {
|
||||||
const char* home = getenv("HOME");
|
if (g_Main->IsUSA() && !g_Main->IsTrilogy()) {
|
||||||
if (!home || home[0] != '/')
|
const char* home = getenv("HOME");
|
||||||
return {};
|
if (!home || home[0] != '/')
|
||||||
const char* dataHome = getenv("XDG_DATA_HOME");
|
return {};
|
||||||
|
const char* dataHome = getenv("XDG_DATA_HOME");
|
||||||
|
|
||||||
/* XDG-selected data path */
|
/* XDG-selected data path */
|
||||||
kabufuda::SystemString path =
|
kabufuda::SystemString path =
|
||||||
((dataHome && dataHome[0] == '/') ? dataHome : hecl::SystemString(home)) + "/.local/share/dolphin-emu/GC";
|
((dataHome && dataHome[0] == '/') ? dataHome : hecl::SystemString(home)) + "/.local/share/dolphin-emu/GC";
|
||||||
|
|
||||||
if (hecl::RecursiveMakeDir(path.c_str()) < 0)
|
if (hecl::RecursiveMakeDir(path.c_str()) < 0)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
path += fmt::format(FMT_STRING("/MemoryCard{:c}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
|
path += fmt::format(FMT_STRING("/MemoryCard{:c}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
|
||||||
const auto fp = hecl::FopenUnique(path.c_str(), "wb");
|
const auto fp = hecl::FopenUnique(path.c_str(), "wb");
|
||||||
if (fp == nullptr) {
|
if (fp == nullptr) {
|
||||||
return {};
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
return {};
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
@ -1,40 +1,47 @@
|
|||||||
#include "CMemoryCardSys.hpp"
|
#include "CMemoryCardSys.hpp"
|
||||||
|
#include "Runtime/GameGlobalObjects.hpp"
|
||||||
|
#include "Runtime/IMain.hpp"
|
||||||
namespace urde {
|
namespace urde {
|
||||||
|
|
||||||
kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) {
|
kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) {
|
||||||
const char* home = getenv("HOME");
|
if (g_Main->IsUSA() && !g_Main->IsTrilogy()) {
|
||||||
if (!home)
|
const char* home = getenv("HOME");
|
||||||
return {};
|
if (!home)
|
||||||
|
return {};
|
||||||
|
|
||||||
kabufuda::SystemString path = home;
|
kabufuda::SystemString path = home;
|
||||||
path += fmt::format(FMT_STRING("/Library/Application Support/Dolphin/GC/MemoryCard{:c}.USA.raw"),
|
path += fmt::format(FMT_STRING("/Library/Application Support/Dolphin/GC/MemoryCard{:c}.USA.raw"),
|
||||||
slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
|
slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
|
||||||
|
|
||||||
hecl::Sstat theStat;
|
hecl::Sstat theStat;
|
||||||
if (hecl::Stat(path.c_str(), &theStat) || !S_ISREG(theStat.st_mode))
|
if (hecl::Stat(path.c_str(), &theStat) || !S_ISREG(theStat.st_mode))
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
|
}
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot) {
|
kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot) {
|
||||||
const char* home = getenv("HOME");
|
if (g_Main->IsUSA() && !g_Main->IsTrilogy()) {
|
||||||
if (!home)
|
const char* home = getenv("HOME");
|
||||||
return {};
|
if (!home)
|
||||||
|
return {};
|
||||||
|
|
||||||
kabufuda::SystemString path = home;
|
kabufuda::SystemString path = home;
|
||||||
path += "/Library/Application Support/Dolphin/GC";
|
path += "/Library/Application Support/Dolphin/GC";
|
||||||
if (hecl::RecursiveMakeDir(path.c_str()) < 0)
|
if (hecl::RecursiveMakeDir(path.c_str()) < 0)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
path += fmt::format(FMT_STRING("/MemoryCard{:c}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
|
path += fmt::format(FMT_STRING("/MemoryCard{:c}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
|
||||||
const auto fp = hecl::FopenUnique(path.c_str(), "wb");
|
const auto fp = hecl::FopenUnique(path.c_str(), "wb");
|
||||||
if (fp == nullptr) {
|
if (fp == nullptr) {
|
||||||
return {};
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
return {};
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
@ -12,101 +12,109 @@ using namespace Windows::Storage;
|
|||||||
* https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/UICommon/UICommon.cpp
|
* https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/UICommon/UICommon.cpp
|
||||||
* Modified to not use dolphin-binary-relative paths. */
|
* Modified to not use dolphin-binary-relative paths. */
|
||||||
kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) {
|
kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) {
|
||||||
|
if (g_Main->IsUSA() && !g_Main->IsTrilogy()) {
|
||||||
#if !WINDOWS_STORE
|
#if !WINDOWS_STORE
|
||||||
/* Detect where the User directory is. There are two different cases
|
/* Detect where the User directory is. There are two different cases
|
||||||
* 1. HKCU\Software\Dolphin Emulator\UserConfigPath exists
|
* 1. HKCU\Software\Dolphin Emulator\UserConfigPath exists
|
||||||
* -> Use this as the user directory path
|
* -> Use this as the user directory path
|
||||||
* 2. My Documents exists
|
* 2. My Documents exists
|
||||||
* -> Use My Documents\Dolphin Emulator as the User directory path
|
* -> Use My Documents\Dolphin Emulator as the User directory path
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Check our registry keys */
|
/* Check our registry keys */
|
||||||
HKEY hkey;
|
HKEY hkey;
|
||||||
kabufuda::SystemChar configPath[MAX_PATH] = {0};
|
kabufuda::SystemChar configPath[MAX_PATH] = {0};
|
||||||
if (RegOpenKeyEx(HKEY_CURRENT_USER, _SYS_STR("Software\\Dolphin Emulator"), 0, KEY_QUERY_VALUE, &hkey) ==
|
if (RegOpenKeyEx(HKEY_CURRENT_USER, _SYS_STR("Software\\Dolphin Emulator"), 0, KEY_QUERY_VALUE, &hkey) ==
|
||||||
ERROR_SUCCESS) {
|
ERROR_SUCCESS) {
|
||||||
DWORD size = MAX_PATH;
|
DWORD size = MAX_PATH;
|
||||||
if (RegQueryValueEx(hkey, _SYS_STR("UserConfigPath"), nullptr, nullptr, (LPBYTE)configPath, &size) != ERROR_SUCCESS)
|
if (RegQueryValueEx(hkey, _SYS_STR("UserConfigPath"), nullptr, nullptr, (LPBYTE)configPath, &size) !=
|
||||||
configPath[0] = 0;
|
ERROR_SUCCESS)
|
||||||
RegCloseKey(hkey);
|
configPath[0] = 0;
|
||||||
}
|
RegCloseKey(hkey);
|
||||||
|
}
|
||||||
|
|
||||||
/* Get My Documents path in case we need it. */
|
/* Get My Documents path in case we need it. */
|
||||||
kabufuda::SystemChar my_documents[MAX_PATH];
|
kabufuda::SystemChar my_documents[MAX_PATH];
|
||||||
bool my_documents_found =
|
bool my_documents_found =
|
||||||
SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, my_documents));
|
SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, my_documents));
|
||||||
|
|
||||||
kabufuda::SystemString path;
|
kabufuda::SystemString path;
|
||||||
if (configPath[0]) /* Case 1 */
|
if (configPath[0]) /* Case 1 */
|
||||||
path = configPath;
|
path = configPath;
|
||||||
else if (my_documents_found) /* Case 2 */
|
else if (my_documents_found) /* Case 2 */
|
||||||
path = kabufuda::SystemString(my_documents) + _SYS_STR("/Dolphin Emulator");
|
path = kabufuda::SystemString(my_documents) + _SYS_STR("/Dolphin Emulator");
|
||||||
else /* Unable to find */
|
else /* Unable to find */
|
||||||
return {};
|
return {};
|
||||||
#else
|
#else
|
||||||
StorageFolder ^ localFolder = ApplicationData::Current->LocalFolder;
|
StorageFolder ^ localFolder = ApplicationData::Current->LocalFolder;
|
||||||
kabufuda::SystemString path(localFolder->Path->Data());
|
kabufuda::SystemString path(localFolder->Path->Data());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
path += fmt::format(FMT_STRING(_SYS_STR("/GC/MemoryCard{}.USA.raw")),
|
path += fmt::format(FMT_STRING(_SYS_STR("/GC/MemoryCard{}.USA.raw")),
|
||||||
slot == kabufuda::ECardSlot::SlotA ? _SYS_STR('A') : _SYS_STR('B'));
|
slot == kabufuda::ECardSlot::SlotA ? _SYS_STR('A') : _SYS_STR('B'));
|
||||||
|
|
||||||
hecl::Sstat theStat;
|
hecl::Sstat theStat;
|
||||||
if (hecl::Stat(path.c_str(), &theStat) || !S_ISREG(theStat.st_mode))
|
if (hecl::Stat(path.c_str(), &theStat) || !S_ISREG(theStat.st_mode))
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
|
}
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot) {
|
kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot) {
|
||||||
|
if (g_Main->IsUSA() && !g_Main->IsTrilogy()) {
|
||||||
#if !WINDOWS_STORE
|
#if !WINDOWS_STORE
|
||||||
/* Detect where the User directory is. There are two different cases
|
/* Detect where the User directory is. There are two different cases
|
||||||
* 1. HKCU\Software\Dolphin Emulator\UserConfigPath exists
|
* 1. HKCU\Software\Dolphin Emulator\UserConfigPath exists
|
||||||
* -> Use this as the user directory path
|
* -> Use this as the user directory path
|
||||||
* 2. My Documents exists
|
* 2. My Documents exists
|
||||||
* -> Use My Documents\Dolphin Emulator as the User directory path
|
* -> Use My Documents\Dolphin Emulator as the User directory path
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Check our registry keys */
|
/* Check our registry keys */
|
||||||
HKEY hkey;
|
HKEY hkey;
|
||||||
kabufuda::SystemChar configPath[MAX_PATH] = {0};
|
kabufuda::SystemChar configPath[MAX_PATH] = {0};
|
||||||
if (RegOpenKeyEx(HKEY_CURRENT_USER, _SYS_STR("Software\\Dolphin Emulator"), 0, KEY_QUERY_VALUE, &hkey) ==
|
if (RegOpenKeyEx(HKEY_CURRENT_USER, _SYS_STR("Software\\Dolphin Emulator"), 0, KEY_QUERY_VALUE, &hkey) ==
|
||||||
ERROR_SUCCESS) {
|
ERROR_SUCCESS) {
|
||||||
DWORD size = MAX_PATH;
|
DWORD size = MAX_PATH;
|
||||||
if (RegQueryValueEx(hkey, _SYS_STR("UserConfigPath"), nullptr, nullptr, (LPBYTE)configPath, &size) != ERROR_SUCCESS)
|
if (RegQueryValueEx(hkey, _SYS_STR("UserConfigPath"), nullptr, nullptr, (LPBYTE)configPath, &size) !=
|
||||||
configPath[0] = 0;
|
ERROR_SUCCESS)
|
||||||
RegCloseKey(hkey);
|
configPath[0] = 0;
|
||||||
}
|
RegCloseKey(hkey);
|
||||||
|
}
|
||||||
|
|
||||||
/* Get My Documents path in case we need it. */
|
/* Get My Documents path in case we need it. */
|
||||||
kabufuda::SystemChar my_documents[MAX_PATH];
|
kabufuda::SystemChar my_documents[MAX_PATH];
|
||||||
bool my_documents_found =
|
bool my_documents_found =
|
||||||
SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, my_documents));
|
SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, my_documents));
|
||||||
|
|
||||||
kabufuda::SystemString path;
|
kabufuda::SystemString path;
|
||||||
if (configPath[0]) /* Case 1 */
|
if (configPath[0]) /* Case 1 */
|
||||||
path = configPath;
|
path = configPath;
|
||||||
else if (my_documents_found) /* Case 2 */
|
else if (my_documents_found) /* Case 2 */
|
||||||
path = kabufuda::SystemString(my_documents) + _SYS_STR("/Dolphin Emulator");
|
path = kabufuda::SystemString(my_documents) + _SYS_STR("/Dolphin Emulator");
|
||||||
else /* Unable to find */
|
else /* Unable to find */
|
||||||
return {};
|
return {};
|
||||||
#else
|
#else
|
||||||
StorageFolder ^ localFolder = ApplicationData::Current->LocalFolder;
|
StorageFolder ^ localFolder = ApplicationData::Current->LocalFolder;
|
||||||
kabufuda::SystemString path(localFolder->Path->Data());
|
kabufuda::SystemString path(localFolder->Path->Data());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
path += _SYS_STR("/GC");
|
path += _SYS_STR("/GC");
|
||||||
if (hecl::RecursiveMakeDir(path.c_str()) < 0)
|
if (hecl::RecursiveMakeDir(path.c_str()) < 0)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
path += fmt::format(FMT_STRING(_SYS_STR("/MemoryCard{}.USA.raw")),
|
path += fmt::format(FMT_STRING(_SYS_STR("/MemoryCard{}.USA.raw")),
|
||||||
slot == kabufuda::ECardSlot::SlotA ? _SYS_STR('A') : _SYS_STR('B'));
|
slot == kabufuda::ECardSlot::SlotA ? _SYS_STR('A') : _SYS_STR('B'));
|
||||||
const auto fp = hecl::FopenUnique(path.c_str(), _SYS_STR("wb"));
|
const auto fp = hecl::FopenUnique(path.c_str(), _SYS_STR("wb"));
|
||||||
if (fp == nullptr) {
|
if (fp == nullptr) {
|
||||||
return {};
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
return {};
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
@ -1317,7 +1317,7 @@ CFrontEndUI::SNesEmulatorFrame::SNesEmulatorFrame() {
|
|||||||
CGuiTextProperties props(false, true, EJustification::Left, EVerticalJustification::Center);
|
CGuiTextProperties props(false, true, EJustification::Left, EVerticalJustification::Center);
|
||||||
xc_textSupport = std::make_unique<CGuiTextSupport>(deface->id, props, zeus::skWhite, zeus::skBlack, zeus::skWhite, 0,
|
xc_textSupport = std::make_unique<CGuiTextSupport>(deface->id, props, zeus::skWhite, zeus::skBlack, zeus::skWhite, 0,
|
||||||
0, g_SimplePool, CGuiWidget::EGuiModelDrawFlags::Alpha);
|
0, g_SimplePool, CGuiWidget::EGuiModelDrawFlags::Alpha);
|
||||||
xc_textSupport->SetText(g_MainStringTable->GetString(103));
|
xc_textSupport->SetText(g_MainStringTable->GetString((g_Main->IsUSA() && !g_Main->IsTrilogy()) ? 103 : 97));
|
||||||
xc_textSupport->AutoSetExtent();
|
xc_textSupport->AutoSetExtent();
|
||||||
xc_textSupport->ClearRenderBuffer();
|
xc_textSupport->ClearRenderBuffer();
|
||||||
}
|
}
|
||||||
|
@ -190,11 +190,18 @@ void CSaveGameScreen::SetUIText() {
|
|||||||
msgB = 25; // Writing
|
msgB = 25; // Writing
|
||||||
break;
|
break;
|
||||||
case EUIType::NoCardFound:
|
case EUIType::NoCardFound:
|
||||||
msgB = 0; // No card found
|
if (g_Main->IsUSA() && !g_Main->IsTrilogy()) {
|
||||||
opt0 = 17; // Continue without saving
|
msgB = 0; // No card found
|
||||||
opt1 = 18; // Retry
|
opt0 = 17; // Continue without saving
|
||||||
opt2 = -2;
|
opt1 = 18; // Retry
|
||||||
opt2Str = u"Create Dolphin Card";
|
opt2 = -2;
|
||||||
|
opt2Str = u"Create Dolphin Card";
|
||||||
|
} else {
|
||||||
|
msgAStr = u"This version of Metroid Prime\nhas a currently unsupported save format.\n";
|
||||||
|
msgBStr = u"&push;&main-color=$ff0000ff;Saving has been disabled.&pop;\n";
|
||||||
|
opt0 = -2;
|
||||||
|
opt0Str = u"Press &image=SI,1.0,0.68,05AF9CAA; to proceed.\n";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case EUIType::NeedsFormatBroken:
|
case EUIType::NeedsFormatBroken:
|
||||||
msgB = 1; // Needs format (card broken)
|
msgB = 1; // Needs format (card broken)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user