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 "Runtime/GameGlobalObjects.hpp"
#include "Runtime/IMain.hpp"
namespace urde {
kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) {
if (g_Main->IsUSA() && !g_Main->IsTrilogy()) {
const char* home = getenv("HOME");
if (!home || home[0] != '/')
return {};
@ -17,15 +20,19 @@ kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlo
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');
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) {
if (g_Main->IsUSA() && !g_Main->IsTrilogy()) {
const char* home = getenv("HOME");
if (!home || home[0] != '/')
return {};
@ -46,5 +53,7 @@ kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot sl
return path;
}
return {};
}
} // namespace urde

View File

@ -1,8 +1,10 @@
#include "CMemoryCardSys.hpp"
#include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/IMain.hpp"
namespace urde {
kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) {
if (g_Main->IsUSA() && !g_Main->IsTrilogy()) {
const char* home = getenv("HOME");
if (!home)
return {};
@ -17,8 +19,11 @@ kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlo
return path;
}
return {};
}
kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot) {
if (g_Main->IsUSA() && !g_Main->IsTrilogy()) {
const char* home = getenv("HOME");
if (!home)
return {};
@ -36,5 +41,7 @@ kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot sl
return path;
}
return {};
}
} // 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
* Modified to not use dolphin-binary-relative paths. */
kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) {
if (g_Main->IsUSA() && !g_Main->IsTrilogy()) {
#if !WINDOWS_STORE
/* Detect where the User directory is. There are two different cases
* 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) ==
ERROR_SUCCESS) {
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;
RegCloseKey(hkey);
}
@ -57,8 +59,11 @@ kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlo
return path;
}
return {};
}
kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot) {
if (g_Main->IsUSA() && !g_Main->IsTrilogy()) {
#if !WINDOWS_STORE
/* Detect where the User directory is. There are two different cases
* 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) ==
ERROR_SUCCESS) {
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;
RegCloseKey(hkey);
}
@ -108,5 +114,7 @@ kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot sl
return path;
}
return {};
}
} // namespace urde

View File

@ -1317,7 +1317,7 @@ CFrontEndUI::SNesEmulatorFrame::SNesEmulatorFrame() {
CGuiTextProperties props(false, true, EJustification::Left, EVerticalJustification::Center);
xc_textSupport = std::make_unique<CGuiTextSupport>(deface->id, props, zeus::skWhite, zeus::skBlack, zeus::skWhite, 0,
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->ClearRenderBuffer();
}

View File

@ -190,11 +190,18 @@ void CSaveGameScreen::SetUIText() {
msgB = 25; // Writing
break;
case EUIType::NoCardFound:
if (g_Main->IsUSA() && !g_Main->IsTrilogy()) {
msgB = 0; // No card found
opt0 = 17; // Continue without saving
opt1 = 18; // Retry
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;
case EUIType::NeedsFormatBroken:
msgB = 1; // Needs format (card broken)