2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-05-14 02:31:21 +00:00

Disable saving on non-NTSC-U versions

This commit is contained in:
Phillip Stephens 2020-04-16 17:19:55 -07:00
parent d16e758f07
commit ba3b23edaa
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
5 changed files with 160 additions and 129 deletions

View File

@ -1,8 +1,11 @@
#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) {
if (g_Main->IsUSA() && !g_Main->IsTrilogy()) {
const char* home = getenv("HOME"); const char* home = getenv("HOME");
if (!home || home[0] != '/') if (!home || home[0] != '/')
return {}; return {};
@ -17,15 +20,19 @@ kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlo
if (hecl::Stat(path.c_str(), &theStat) || !S_ISREG(theStat.st_mode)) { if (hecl::Stat(path.c_str(), &theStat) || !S_ISREG(theStat.st_mode)) {
/* legacy case for older dolphin versions */ /* legacy case for older dolphin versions */
path = home; path = home;
path += fmt::format(FMT_STRING("/.dolphin-emu/GC/MemoryCard{:c}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B'); 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)) 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()) {
const char* home = getenv("HOME"); const char* home = getenv("HOME");
if (!home || home[0] != '/') if (!home || home[0] != '/')
return {}; return {};
@ -45,6 +52,8 @@ kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot sl
} }
return path; return path;
}
return {};
} }
} // namespace urde } // namespace urde

View File

@ -1,8 +1,10 @@
#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) {
if (g_Main->IsUSA() && !g_Main->IsTrilogy()) {
const char* home = getenv("HOME"); const char* home = getenv("HOME");
if (!home) if (!home)
return {}; return {};
@ -16,9 +18,12 @@ kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlo
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()) {
const char* home = getenv("HOME"); const char* home = getenv("HOME");
if (!home) if (!home)
return {}; return {};
@ -35,6 +40,8 @@ kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot sl
} }
return path; return path;
}
return {};
} }
} // namespace urde } // namespace urde

View File

@ -12,6 +12,7 @@ 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
@ -26,7 +27,8 @@ kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlo
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) !=
ERROR_SUCCESS)
configPath[0] = 0; configPath[0] = 0;
RegCloseKey(hkey); RegCloseKey(hkey);
} }
@ -56,9 +58,12 @@ kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlo
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
@ -73,7 +78,8 @@ kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot sl
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) !=
ERROR_SUCCESS)
configPath[0] = 0; configPath[0] = 0;
RegCloseKey(hkey); RegCloseKey(hkey);
} }
@ -107,6 +113,8 @@ kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot sl
} }
return path; return path;
}
return {};
} }
} // namespace urde } // namespace urde

View File

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

View File

@ -190,11 +190,18 @@ void CSaveGameScreen::SetUIText() {
msgB = 25; // Writing msgB = 25; // Writing
break; break;
case EUIType::NoCardFound: case EUIType::NoCardFound:
if (g_Main->IsUSA() && !g_Main->IsTrilogy()) {
msgB = 0; // No card found msgB = 0; // No card found
opt0 = 17; // Continue without saving opt0 = 17; // Continue without saving
opt1 = 18; // Retry opt1 = 18; // Retry
opt2 = -2; opt2 = -2;
opt2Str = u"Create Dolphin Card"; 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)