2017-02-12 03:17:18 +00:00
|
|
|
#include "CSaveGameScreen.hpp"
|
2016-12-19 19:20:30 +00:00
|
|
|
#include "CSimplePool.hpp"
|
|
|
|
#include "GameGlobalObjects.hpp"
|
|
|
|
#include "CMemoryCardSys.hpp"
|
|
|
|
#include "GuiSys/CGuiFrame.hpp"
|
|
|
|
#include "GuiSys/CGuiTableGroup.hpp"
|
|
|
|
#include "GuiSys/CGuiTextPane.hpp"
|
2016-12-26 07:58:44 +00:00
|
|
|
#include "GuiSys/CGuiWidgetDrawParms.hpp"
|
2016-12-29 05:53:00 +00:00
|
|
|
#include "Audio/CSfxManager.hpp"
|
2016-12-30 06:37:01 +00:00
|
|
|
#include "MP1/MP1.hpp"
|
2016-12-19 19:20:30 +00:00
|
|
|
|
2017-12-29 08:08:12 +00:00
|
|
|
namespace urde::MP1
|
2016-12-19 19:20:30 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
using EState = CMemoryCardDriver::EState;
|
2016-12-24 00:45:51 +00:00
|
|
|
using EError = CMemoryCardDriver::EError;
|
|
|
|
|
2017-02-12 03:17:18 +00:00
|
|
|
void CSaveGameScreen::ResetCardDriver()
|
2016-12-24 00:45:51 +00:00
|
|
|
{
|
2016-12-31 00:51:51 +00:00
|
|
|
x92_savingDisabled = false;
|
2016-12-24 00:45:51 +00:00
|
|
|
x6c_cardDriver.reset();
|
2016-12-30 06:37:01 +00:00
|
|
|
bool importState = (x0_saveCtx == ESaveContext::FrontEnd && !x90_needsDriverReset);
|
2016-12-24 05:23:50 +00:00
|
|
|
x6c_cardDriver = ConstructCardDriver(importState);
|
|
|
|
x6c_cardDriver->StartCardProbe();
|
2016-12-30 06:37:01 +00:00
|
|
|
x10_uiType = EUIType::Empty;
|
2016-12-29 05:53:00 +00:00
|
|
|
SetUIText();
|
2016-12-24 00:45:51 +00:00
|
|
|
}
|
2016-12-19 19:20:30 +00:00
|
|
|
|
2017-02-12 03:17:18 +00:00
|
|
|
CIOWin::EMessageReturn CSaveGameScreen::Update(float dt)
|
2016-12-19 19:20:30 +00:00
|
|
|
{
|
2017-01-24 07:41:33 +00:00
|
|
|
if (!PumpLoad())
|
2016-12-24 00:45:51 +00:00
|
|
|
return CIOWin::EMessageReturn::Normal;
|
|
|
|
|
|
|
|
x50_loadedFrame->Update(dt);
|
|
|
|
x6c_cardDriver->Update();
|
|
|
|
|
2016-12-24 05:23:50 +00:00
|
|
|
if (x6c_cardDriver->x10_state == EState::DriverClosed)
|
2016-12-24 00:45:51 +00:00
|
|
|
{
|
|
|
|
if (x90_needsDriverReset)
|
|
|
|
{
|
|
|
|
ResetCardDriver();
|
|
|
|
x90_needsDriverReset = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
x80_iowRet = CIOWin::EMessageReturn::Exit;
|
|
|
|
}
|
2016-12-30 06:37:01 +00:00
|
|
|
else if (x6c_cardDriver->x10_state == EState::CardCheckDone && x10_uiType != EUIType::NotOriginalCard)
|
2016-12-24 00:45:51 +00:00
|
|
|
{
|
2016-12-29 05:53:00 +00:00
|
|
|
if (x6c_cardDriver->x28_cardSerial != x8_serial)
|
2016-12-24 00:45:51 +00:00
|
|
|
{
|
2016-12-30 06:37:01 +00:00
|
|
|
if (x93_inGame)
|
2016-12-24 00:45:51 +00:00
|
|
|
{
|
2016-12-30 06:37:01 +00:00
|
|
|
x10_uiType = EUIType::NotOriginalCard;
|
2016-12-29 05:53:00 +00:00
|
|
|
x91_uiTextDirty = true;
|
2016-12-24 00:45:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x8_serial = x6c_cardDriver->x28_cardSerial;
|
2016-12-24 05:23:50 +00:00
|
|
|
x6c_cardDriver->IndexFiles();
|
2016-12-24 00:45:51 +00:00
|
|
|
}
|
|
|
|
}
|
2017-01-24 07:41:33 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
x6c_cardDriver->IndexFiles();
|
|
|
|
}
|
2016-12-24 00:45:51 +00:00
|
|
|
}
|
|
|
|
else if (x6c_cardDriver->x10_state == EState::Ready)
|
|
|
|
{
|
|
|
|
if (x90_needsDriverReset)
|
2016-12-24 05:23:50 +00:00
|
|
|
x6c_cardDriver->StartFileCreateTransactional();
|
2016-12-24 00:45:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (x80_iowRet != CIOWin::EMessageReturn::Normal)
|
|
|
|
return x80_iowRet;
|
|
|
|
|
2016-12-30 06:37:01 +00:00
|
|
|
EUIType oldTp = x10_uiType;
|
2016-12-24 00:45:51 +00:00
|
|
|
x10_uiType = SelectUIType();
|
2016-12-29 05:53:00 +00:00
|
|
|
if (oldTp != x10_uiType || x91_uiTextDirty)
|
|
|
|
SetUIText();
|
2016-12-24 00:45:51 +00:00
|
|
|
|
|
|
|
if (x6c_cardDriver->x10_state == EState::NoCard)
|
|
|
|
{
|
2016-12-28 08:51:28 +00:00
|
|
|
auto res = CMemoryCardSys::CardProbe(kabufuda::ECardSlot::SlotA);
|
2016-12-24 05:23:50 +00:00
|
|
|
if (res.x0_error == CMemoryCardSys::ECardResult::READY ||
|
|
|
|
res.x0_error == CMemoryCardSys::ECardResult::WRONGDEVICE)
|
2016-12-24 00:45:51 +00:00
|
|
|
ResetCardDriver();
|
|
|
|
}
|
|
|
|
else if (x6c_cardDriver->x10_state == EState::CardFormatted)
|
|
|
|
{
|
|
|
|
ResetCardDriver();
|
|
|
|
}
|
2016-12-24 05:23:50 +00:00
|
|
|
else if (x6c_cardDriver->x10_state == EState::FileBad &&
|
|
|
|
x6c_cardDriver->x14_error == EError::FileMissing)
|
2016-12-24 00:45:51 +00:00
|
|
|
{
|
2016-12-24 05:23:50 +00:00
|
|
|
x6c_cardDriver->StartFileCreate();
|
2016-12-24 00:45:51 +00:00
|
|
|
}
|
|
|
|
|
2016-12-21 19:27:15 +00:00
|
|
|
return CIOWin::EMessageReturn::Normal;
|
2016-12-19 19:20:30 +00:00
|
|
|
}
|
|
|
|
|
2017-02-12 03:17:18 +00:00
|
|
|
bool CSaveGameScreen::PumpLoad()
|
2016-12-19 19:20:30 +00:00
|
|
|
{
|
|
|
|
if (x50_loadedFrame)
|
|
|
|
return true;
|
|
|
|
if (!x14_txtrSaveBanner.IsLoaded())
|
|
|
|
return false;
|
|
|
|
if (!x20_txtrSaveIcon0.IsLoaded())
|
|
|
|
return false;
|
|
|
|
if (!x2c_txtrSaveIcon1.IsLoaded())
|
|
|
|
return false;
|
|
|
|
if (!x38_strgMemoryCard.IsLoaded())
|
|
|
|
return false;
|
|
|
|
for (TLockedToken<CSaveWorld>& savw : x70_saveWorlds)
|
|
|
|
if (!savw.IsLoaded())
|
|
|
|
return false;
|
|
|
|
if (!x44_frmeGenericMenu.IsLoaded())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
x50_loadedFrame = x44_frmeGenericMenu.GetObj();
|
2017-01-30 04:16:20 +00:00
|
|
|
x50_loadedFrame->SetAspectConstraint(1.78f);
|
2016-12-19 19:20:30 +00:00
|
|
|
x54_textpane_message = static_cast<CGuiTextPane*>(x50_loadedFrame->FindWidget("textpane_message"));
|
|
|
|
x58_tablegroup_choices = static_cast<CGuiTableGroup*>(x50_loadedFrame->FindWidget("tablegroup_choices"));
|
|
|
|
x5c_textpane_choice0 = static_cast<CGuiTextPane*>(x50_loadedFrame->FindWidget("textpane_choice0"));
|
|
|
|
x60_textpane_choice1 = static_cast<CGuiTextPane*>(x50_loadedFrame->FindWidget("textpane_choice1"));
|
|
|
|
x64_textpane_choice2 = static_cast<CGuiTextPane*>(x50_loadedFrame->FindWidget("textpane_choice2"));
|
|
|
|
x68_textpane_choice3 = static_cast<CGuiTextPane*>(x50_loadedFrame->FindWidget("textpane_choice3"));
|
|
|
|
|
|
|
|
x58_tablegroup_choices->SetMenuAdvanceCallback(
|
2017-02-12 03:17:18 +00:00
|
|
|
std::bind(&CSaveGameScreen::DoAdvance, this, std::placeholders::_1));
|
2016-12-19 19:20:30 +00:00
|
|
|
x58_tablegroup_choices->SetMenuSelectionChangeCallback(
|
2017-02-12 03:17:18 +00:00
|
|
|
std::bind(&CSaveGameScreen::DoSelectionChange, this, std::placeholders::_1, std::placeholders::_2));
|
2016-12-19 19:20:30 +00:00
|
|
|
|
2016-12-30 06:37:01 +00:00
|
|
|
if (x0_saveCtx == ESaveContext::InGame)
|
2016-12-24 05:23:50 +00:00
|
|
|
x6c_cardDriver->StartCardProbe();
|
2016-12-19 19:20:30 +00:00
|
|
|
|
|
|
|
x10_uiType = SelectUIType();
|
2016-12-29 05:53:00 +00:00
|
|
|
SetUIText();
|
2016-12-19 19:20:30 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-02-12 03:17:18 +00:00
|
|
|
CSaveGameScreen::EUIType CSaveGameScreen::SelectUIType() const
|
2016-12-19 19:20:30 +00:00
|
|
|
{
|
2016-12-23 06:41:39 +00:00
|
|
|
if (x6c_cardDriver->x10_state == EState::NoCard)
|
2016-12-30 06:37:01 +00:00
|
|
|
return EUIType::NoCardFound;
|
2016-12-19 19:20:30 +00:00
|
|
|
|
|
|
|
switch (x10_uiType)
|
|
|
|
{
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::ProgressWillBeLost:
|
|
|
|
case EUIType::NotOriginalCard:
|
|
|
|
case EUIType::AllDataWillBeLost:
|
2016-12-19 19:20:30 +00:00
|
|
|
return x10_uiType;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
2016-12-24 05:23:50 +00:00
|
|
|
if (CMemoryCardDriver::IsCardBusy(x6c_cardDriver->x10_state))
|
2016-12-19 19:20:30 +00:00
|
|
|
{
|
2016-12-29 05:53:00 +00:00
|
|
|
if (CMemoryCardDriver::IsCardWriting(x6c_cardDriver->x10_state))
|
2016-12-30 06:37:01 +00:00
|
|
|
return EUIType::BusyWriting;
|
|
|
|
return EUIType::BusyReading;
|
2016-12-19 19:20:30 +00:00
|
|
|
}
|
|
|
|
|
2016-12-23 06:41:39 +00:00
|
|
|
if (x6c_cardDriver->x10_state == EState::Ready)
|
2016-12-19 19:20:30 +00:00
|
|
|
{
|
2016-12-24 05:23:50 +00:00
|
|
|
if (x6c_cardDriver->x14_error == CMemoryCardDriver::EError::CardStillFull)
|
2016-12-30 06:37:01 +00:00
|
|
|
return EUIType::StillInsufficientSpace;
|
2017-01-09 03:44:00 +00:00
|
|
|
return EUIType::SaveReady;
|
2016-12-19 19:20:30 +00:00
|
|
|
}
|
|
|
|
|
2016-12-24 05:23:50 +00:00
|
|
|
if (x6c_cardDriver->x14_error == CMemoryCardDriver::EError::CardBroken)
|
2016-12-30 06:37:01 +00:00
|
|
|
return EUIType::NeedsFormatBroken;
|
2016-12-19 19:20:30 +00:00
|
|
|
|
2016-12-24 05:23:50 +00:00
|
|
|
if (x6c_cardDriver->x14_error == CMemoryCardDriver::EError::CardWrongCharacterSet)
|
2016-12-30 06:37:01 +00:00
|
|
|
return EUIType::NeedsFormatEncoding;
|
2016-12-19 19:20:30 +00:00
|
|
|
|
2016-12-24 05:23:50 +00:00
|
|
|
if (x6c_cardDriver->x14_error == CMemoryCardDriver::EError::CardWrongDevice)
|
2016-12-30 06:37:01 +00:00
|
|
|
return EUIType::WrongDevice;
|
2016-12-19 19:20:30 +00:00
|
|
|
|
2016-12-24 05:23:50 +00:00
|
|
|
if (x6c_cardDriver->x14_error == CMemoryCardDriver::EError::CardFull)
|
2016-12-19 19:20:30 +00:00
|
|
|
{
|
2016-12-24 05:23:50 +00:00
|
|
|
if (x6c_cardDriver->x10_state == EState::CardCheckFailed)
|
2016-12-30 06:37:01 +00:00
|
|
|
return EUIType::InsufficientSpaceBadCheck;
|
|
|
|
return EUIType::InsufficientSpaceOKCheck;
|
2016-12-19 19:20:30 +00:00
|
|
|
}
|
|
|
|
|
2016-12-24 05:23:50 +00:00
|
|
|
if (x6c_cardDriver->x14_error == CMemoryCardDriver::EError::CardNon8KSectors)
|
2016-12-30 06:37:01 +00:00
|
|
|
return EUIType::IncompatibleCard;
|
2016-12-19 19:20:30 +00:00
|
|
|
|
2016-12-24 05:23:50 +00:00
|
|
|
if (x6c_cardDriver->x14_error == CMemoryCardDriver::EError::FileCorrupted)
|
2016-12-30 06:37:01 +00:00
|
|
|
return EUIType::SaveCorrupt;
|
2016-12-19 19:20:30 +00:00
|
|
|
|
2016-12-24 05:23:50 +00:00
|
|
|
if (x6c_cardDriver->x14_error == CMemoryCardDriver::EError::CardIOError)
|
2016-12-30 06:37:01 +00:00
|
|
|
return EUIType::CardDamaged;
|
2016-12-19 19:20:30 +00:00
|
|
|
|
2016-12-30 06:37:01 +00:00
|
|
|
return EUIType::Empty;
|
2016-12-19 19:20:30 +00:00
|
|
|
}
|
|
|
|
|
2017-02-12 03:17:18 +00:00
|
|
|
void CSaveGameScreen::SetUIText()
|
2016-12-19 19:20:30 +00:00
|
|
|
{
|
2016-12-29 05:53:00 +00:00
|
|
|
x91_uiTextDirty = false;
|
|
|
|
|
2017-02-04 03:46:12 +00:00
|
|
|
s32 msgA = -1;
|
|
|
|
s32 msgB = -1;
|
|
|
|
s32 opt0 = -1;
|
|
|
|
s32 opt1 = -1;
|
|
|
|
s32 opt2 = -1;
|
|
|
|
|
|
|
|
std::u16string msgAStr;
|
|
|
|
std::u16string msgBStr;
|
|
|
|
std::u16string opt0Str;
|
|
|
|
std::u16string opt1Str;
|
|
|
|
std::u16string opt2Str;
|
|
|
|
std::u16string opt3Str;
|
2016-12-29 05:53:00 +00:00
|
|
|
|
|
|
|
switch (x10_uiType)
|
|
|
|
{
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::BusyReading:
|
2016-12-29 05:53:00 +00:00
|
|
|
msgB = 24; // Reading
|
|
|
|
break;
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::BusyWriting:
|
2016-12-29 05:53:00 +00:00
|
|
|
msgB = 25; // Writing
|
|
|
|
break;
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::NoCardFound:
|
2016-12-29 05:53:00 +00:00
|
|
|
msgB = 0; // No card found
|
|
|
|
opt0 = 17; // Continue without saving
|
|
|
|
opt1 = 18; // Retry
|
2017-02-04 03:46:12 +00:00
|
|
|
opt2 = -2;
|
|
|
|
opt2Str = u"Create Dolphin Card";
|
2016-12-29 05:53:00 +00:00
|
|
|
break;
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::NeedsFormatBroken:
|
2016-12-29 05:53:00 +00:00
|
|
|
msgB = 1; // Needs format (card broken)
|
|
|
|
opt0 = 17; // Continue without saving
|
|
|
|
opt1 = 18; // Retry
|
|
|
|
opt2 = 20; // Format
|
|
|
|
break;
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::NeedsFormatEncoding:
|
2016-12-29 05:53:00 +00:00
|
|
|
msgB = 2; // Needs format (wrong char set)
|
|
|
|
opt0 = 17; // Continue without saving
|
|
|
|
opt1 = 18; // Retry
|
|
|
|
opt2 = 20; // Format
|
|
|
|
break;
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::CardDamaged:
|
2016-12-29 05:53:00 +00:00
|
|
|
msgB = 3; // Damaged
|
|
|
|
opt0 = 17; // Continue without saving
|
|
|
|
opt1 = 18; // Retry
|
|
|
|
break;
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::WrongDevice:
|
2016-12-29 05:53:00 +00:00
|
|
|
msgB = 5; // Invalid device
|
|
|
|
opt0 = 17; // Continue without saving
|
|
|
|
opt1 = 18; // Retry
|
|
|
|
break;
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::InsufficientSpaceOKCheck:
|
2016-12-29 05:53:00 +00:00
|
|
|
msgB = 6; // Insufficient space (completely filled)
|
|
|
|
opt0 = 17; // Continue without saving
|
|
|
|
opt1 = 18; // Retry
|
|
|
|
opt2 = 19; // Manage memory card
|
|
|
|
break;
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::InsufficientSpaceBadCheck:
|
|
|
|
msgB = bool(x0_saveCtx) + 9; // Insufficient space A or B
|
2016-12-29 05:53:00 +00:00
|
|
|
opt0 = 17; // Continue without saving
|
|
|
|
opt1 = 18; // Retry
|
|
|
|
opt2 = 19; // Manage memory card
|
|
|
|
break;
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::IncompatibleCard:
|
2016-12-29 05:53:00 +00:00
|
|
|
msgB = 7; // Incompatible card
|
|
|
|
opt0 = 17; // Continue without saving
|
|
|
|
opt1 = 18; // Retry
|
|
|
|
break;
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::SaveCorrupt:
|
2016-12-29 05:53:00 +00:00
|
|
|
msgB = 4; // Save corrupt
|
|
|
|
opt0 = 22; // Delete corrupt file
|
|
|
|
opt1 = 17; // Continue without saving
|
|
|
|
opt2 = 18; // Retry
|
|
|
|
break;
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::StillInsufficientSpace:
|
|
|
|
if (x0_saveCtx == ESaveContext::InGame)
|
2016-12-29 05:53:00 +00:00
|
|
|
{
|
|
|
|
msgB = 10; // Insufficient space B
|
|
|
|
opt0 = 17; // Continue without saving
|
|
|
|
opt1 = 18; // Retry
|
|
|
|
opt2 = 19; // Manage memory card
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
msgB = 9; // Insufficient space A
|
|
|
|
opt0 = 17; // Continue without saving
|
|
|
|
opt1 = 18; // Retry
|
|
|
|
opt2 = 19; // Manage memory card
|
|
|
|
}
|
|
|
|
break;
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::ProgressWillBeLost:
|
2016-12-29 05:53:00 +00:00
|
|
|
msgA = 28; // Warning
|
|
|
|
msgB = 11; // Progress will be lost
|
|
|
|
opt0 = 21; // Cancel
|
|
|
|
opt1 = 16; // Continue
|
|
|
|
break;
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::NotOriginalCard:
|
2016-12-29 05:53:00 +00:00
|
|
|
msgA = 28; // Warning
|
|
|
|
msgB = 12; // Not the original card
|
2016-12-30 06:37:01 +00:00
|
|
|
opt0 = x0_saveCtx == ESaveContext::InGame ? 21 : 17; // Cancel : continue without saving
|
2016-12-29 05:53:00 +00:00
|
|
|
opt1 = 16; // Continue
|
|
|
|
break;
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::AllDataWillBeLost:
|
2016-12-29 05:53:00 +00:00
|
|
|
msgA = 28; // Warning
|
|
|
|
msgB = 13; // All card data will be erased
|
|
|
|
opt0 = 16; // Continue
|
|
|
|
opt1 = 21; // Cancel
|
|
|
|
break;
|
2017-01-09 03:44:00 +00:00
|
|
|
case EUIType::SaveReady:
|
2016-12-30 06:37:01 +00:00
|
|
|
if (x0_saveCtx == ESaveContext::InGame)
|
2016-12-29 05:53:00 +00:00
|
|
|
{
|
|
|
|
msgB = 8; // Save progress?
|
|
|
|
opt0 = 14; // Yes
|
|
|
|
opt1 = 15; // No
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
2017-02-04 03:46:12 +00:00
|
|
|
if (msgA > -1)
|
2016-12-29 05:53:00 +00:00
|
|
|
msgAStr = x38_strgMemoryCard->GetString(msgA);
|
2017-02-04 03:46:12 +00:00
|
|
|
if (msgB > -1)
|
2016-12-29 05:53:00 +00:00
|
|
|
msgBStr = x38_strgMemoryCard->GetString(msgB);
|
2017-05-31 21:26:50 +00:00
|
|
|
x54_textpane_message->TextSupport().SetText(msgAStr + msgBStr);
|
2016-12-29 05:53:00 +00:00
|
|
|
|
2017-02-04 03:46:12 +00:00
|
|
|
if (opt0 > -1)
|
2016-12-29 05:53:00 +00:00
|
|
|
opt0Str = x38_strgMemoryCard->GetString(opt0);
|
2017-05-31 21:26:50 +00:00
|
|
|
x5c_textpane_choice0->TextSupport().SetText(opt0Str);
|
2016-12-29 05:53:00 +00:00
|
|
|
|
2017-02-04 03:46:12 +00:00
|
|
|
if (opt1 > -1)
|
2016-12-29 05:53:00 +00:00
|
|
|
opt1Str = x38_strgMemoryCard->GetString(opt1);
|
2017-05-31 21:26:50 +00:00
|
|
|
x60_textpane_choice1->TextSupport().SetText(opt1Str);
|
2016-12-29 05:53:00 +00:00
|
|
|
|
2017-02-04 03:46:12 +00:00
|
|
|
if (opt2 > -1)
|
2016-12-29 05:53:00 +00:00
|
|
|
opt2Str = x38_strgMemoryCard->GetString(opt2);
|
2017-05-31 21:26:50 +00:00
|
|
|
x64_textpane_choice2->TextSupport().SetText(opt2Str);
|
2016-12-29 05:53:00 +00:00
|
|
|
|
2017-05-31 21:26:50 +00:00
|
|
|
x68_textpane_choice3->TextSupport().SetText(opt3Str);
|
2016-12-29 05:53:00 +00:00
|
|
|
|
2017-02-10 23:58:05 +00:00
|
|
|
m_touchBar->SetUIOpts(opt0Str, opt1Str, opt2Str);
|
|
|
|
|
2017-01-09 03:44:00 +00:00
|
|
|
x5c_textpane_choice0->SetIsSelectable(opt0 != -1);
|
|
|
|
x60_textpane_choice1->SetIsSelectable(opt1 != -1);
|
|
|
|
x64_textpane_choice2->SetIsSelectable(opt2 != -1);
|
|
|
|
x68_textpane_choice3->SetIsSelectable(false);
|
2016-12-29 05:53:00 +00:00
|
|
|
|
|
|
|
x58_tablegroup_choices->SetIsActive(opt0 != -1 || opt1 != -1 || opt2 != -1);
|
2017-02-04 03:46:12 +00:00
|
|
|
x58_tablegroup_choices->SetUserSelection(0);
|
2016-12-29 05:53:00 +00:00
|
|
|
SetUIColors();
|
|
|
|
}
|
|
|
|
|
2017-02-12 03:17:18 +00:00
|
|
|
void CSaveGameScreen::SetUIColors()
|
2016-12-29 05:53:00 +00:00
|
|
|
{
|
|
|
|
x58_tablegroup_choices->SetColors(zeus::CColor::skWhite,
|
|
|
|
zeus::CColor{0.627450f, 0.627450f, 0.627450f, 0.784313f});
|
2016-12-19 19:20:30 +00:00
|
|
|
}
|
|
|
|
|
2017-02-12 03:17:18 +00:00
|
|
|
void CSaveGameScreen::Draw() const
|
2016-12-19 19:20:30 +00:00
|
|
|
{
|
2016-12-29 05:53:00 +00:00
|
|
|
if (x50_loadedFrame)
|
|
|
|
x50_loadedFrame->Draw(CGuiWidgetDrawParms::Default);
|
|
|
|
}
|
|
|
|
|
2017-02-12 03:17:18 +00:00
|
|
|
void CSaveGameScreen::ContinueWithoutSaving()
|
2016-12-29 05:53:00 +00:00
|
|
|
{
|
|
|
|
x80_iowRet = CIOWin::EMessageReturn::RemoveIOWin;
|
|
|
|
g_GameState->SetCardSerial(0);
|
2016-12-19 19:20:30 +00:00
|
|
|
}
|
|
|
|
|
2017-02-12 03:17:18 +00:00
|
|
|
void CSaveGameScreen::DoAdvance(CGuiTableGroup* caller)
|
2016-12-19 19:20:30 +00:00
|
|
|
{
|
2016-12-29 05:53:00 +00:00
|
|
|
int userSel = x58_tablegroup_choices->GetUserSelection();
|
2016-12-30 06:37:01 +00:00
|
|
|
int sfx = -1;
|
2016-12-29 05:53:00 +00:00
|
|
|
|
|
|
|
switch (x10_uiType)
|
|
|
|
{
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::NoCardFound:
|
|
|
|
case EUIType::CardDamaged:
|
|
|
|
case EUIType::WrongDevice:
|
|
|
|
case EUIType::IncompatibleCard:
|
2016-12-29 05:53:00 +00:00
|
|
|
if (userSel == 0)
|
|
|
|
{
|
|
|
|
/* Continue without saving */
|
2016-12-30 06:37:01 +00:00
|
|
|
if (x0_saveCtx == ESaveContext::InGame)
|
2016-12-29 05:53:00 +00:00
|
|
|
x80_iowRet = CIOWin::EMessageReturn::RemoveIOWinAndExit;
|
|
|
|
else
|
|
|
|
ContinueWithoutSaving();
|
|
|
|
sfx = x8c_navBackSfx;
|
|
|
|
}
|
|
|
|
else if (userSel == 1)
|
|
|
|
{
|
|
|
|
/* Retry */
|
|
|
|
ResetCardDriver();
|
|
|
|
sfx = x84_navConfirmSfx;
|
|
|
|
}
|
2017-02-04 03:46:12 +00:00
|
|
|
else if (userSel == 2 && x10_uiType == EUIType::NoCardFound)
|
|
|
|
{
|
|
|
|
/* Create Dolphin Card */
|
|
|
|
CMemoryCardSys::CreateDolphinCard(kabufuda::ECardSlot::SlotA);
|
|
|
|
ResetCardDriver();
|
|
|
|
sfx = x84_navConfirmSfx;
|
|
|
|
}
|
2016-12-29 05:53:00 +00:00
|
|
|
break;
|
|
|
|
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::NeedsFormatBroken:
|
|
|
|
case EUIType::NeedsFormatEncoding:
|
|
|
|
if (userSel == 0)
|
|
|
|
{
|
|
|
|
/* Continue without saving */
|
|
|
|
if (x0_saveCtx == ESaveContext::InGame)
|
|
|
|
x80_iowRet = CIOWin::EMessageReturn::RemoveIOWinAndExit;
|
|
|
|
else
|
|
|
|
ContinueWithoutSaving();
|
|
|
|
sfx = x8c_navBackSfx;
|
|
|
|
}
|
|
|
|
else if (userSel == 1)
|
|
|
|
{
|
|
|
|
/* Retry */
|
|
|
|
ResetCardDriver();
|
|
|
|
sfx = x84_navConfirmSfx;
|
|
|
|
}
|
|
|
|
else if (userSel == 2)
|
|
|
|
{
|
|
|
|
/* Format */
|
|
|
|
x10_uiType = EUIType::AllDataWillBeLost;
|
|
|
|
x91_uiTextDirty = true;
|
|
|
|
sfx = x84_navConfirmSfx;
|
|
|
|
}
|
|
|
|
break;
|
2016-12-29 05:53:00 +00:00
|
|
|
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::InsufficientSpaceBadCheck:
|
|
|
|
case EUIType::InsufficientSpaceOKCheck:
|
|
|
|
if (userSel == 0)
|
|
|
|
{
|
|
|
|
/* Continue without saving */
|
|
|
|
if (x0_saveCtx == ESaveContext::InGame)
|
|
|
|
x80_iowRet = CIOWin::EMessageReturn::RemoveIOWinAndExit;
|
|
|
|
else
|
|
|
|
ContinueWithoutSaving();
|
|
|
|
sfx = x8c_navBackSfx;
|
|
|
|
}
|
|
|
|
else if (userSel == 1)
|
|
|
|
{
|
|
|
|
/* Retry */
|
|
|
|
ResetCardDriver();
|
|
|
|
sfx = x84_navConfirmSfx;
|
|
|
|
}
|
|
|
|
else if (userSel == 2)
|
|
|
|
{
|
|
|
|
/* Manage memory card */
|
|
|
|
if (x0_saveCtx == ESaveContext::InGame)
|
|
|
|
{
|
|
|
|
x10_uiType = EUIType::ProgressWillBeLost;
|
|
|
|
x91_uiTextDirty = true;
|
|
|
|
sfx = x84_navConfirmSfx;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
static_cast<MP1::CMain*>(g_Main)->SetManageCard(true);
|
|
|
|
}
|
|
|
|
break;
|
2016-12-29 05:53:00 +00:00
|
|
|
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::SaveCorrupt:
|
|
|
|
if (userSel == 0)
|
|
|
|
{
|
|
|
|
/* Delete corrupt file */
|
|
|
|
x6c_cardDriver->StartFileDeleteBad();
|
|
|
|
sfx = x84_navConfirmSfx;
|
|
|
|
}
|
|
|
|
else if (userSel == 1)
|
|
|
|
{
|
|
|
|
/* Continue without saving */
|
|
|
|
if (x0_saveCtx == ESaveContext::InGame)
|
|
|
|
x80_iowRet = CIOWin::EMessageReturn::RemoveIOWinAndExit;
|
|
|
|
else
|
|
|
|
ContinueWithoutSaving();
|
|
|
|
sfx = x8c_navBackSfx;
|
|
|
|
}
|
|
|
|
else if (userSel == 2)
|
|
|
|
{
|
|
|
|
/* Retry */
|
|
|
|
ResetCardDriver();
|
|
|
|
sfx = x84_navConfirmSfx;
|
|
|
|
}
|
|
|
|
break;
|
2016-12-29 05:53:00 +00:00
|
|
|
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::StillInsufficientSpace:
|
|
|
|
if (x0_saveCtx == ESaveContext::InGame)
|
|
|
|
{
|
|
|
|
if (userSel == 0)
|
|
|
|
{
|
|
|
|
/* Continue without saving */
|
|
|
|
x80_iowRet = CIOWin::EMessageReturn::RemoveIOWinAndExit;
|
|
|
|
sfx = x8c_navBackSfx;
|
|
|
|
}
|
|
|
|
else if (userSel == 1)
|
|
|
|
{
|
|
|
|
/* Retry */
|
|
|
|
ResetCardDriver();
|
|
|
|
sfx = x84_navConfirmSfx;
|
|
|
|
}
|
|
|
|
else if (userSel == 2)
|
|
|
|
{
|
|
|
|
/* Manage memory card */
|
|
|
|
x10_uiType = EUIType::ProgressWillBeLost;
|
|
|
|
x91_uiTextDirty = true;
|
|
|
|
sfx = x84_navConfirmSfx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (userSel == 0)
|
|
|
|
{
|
|
|
|
/* Continue without saving */
|
|
|
|
if (x93_inGame)
|
|
|
|
{
|
|
|
|
x80_iowRet = CIOWin::EMessageReturn::RemoveIOWinAndExit;
|
|
|
|
sfx = x8c_navBackSfx;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x6c_cardDriver->ClearError();
|
2016-12-31 00:51:51 +00:00
|
|
|
x92_savingDisabled = true;
|
2016-12-30 06:37:01 +00:00
|
|
|
sfx = x84_navConfirmSfx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (userSel == 1)
|
|
|
|
{
|
|
|
|
/* Retry */
|
|
|
|
ResetCardDriver();
|
|
|
|
sfx = x84_navConfirmSfx;
|
|
|
|
}
|
|
|
|
else if (userSel == 2)
|
|
|
|
{
|
|
|
|
/* Manage memory card */
|
|
|
|
static_cast<MP1::CMain*>(g_Main)->SetManageCard(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2016-12-29 05:53:00 +00:00
|
|
|
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::ProgressWillBeLost:
|
|
|
|
if (userSel == 1)
|
|
|
|
{
|
|
|
|
/* Continue */
|
|
|
|
static_cast<MP1::CMain*>(g_Main)->SetManageCard(true);
|
|
|
|
}
|
|
|
|
else if (userSel == 0)
|
|
|
|
{
|
|
|
|
/* Cancel */
|
|
|
|
x80_iowRet = CIOWin::EMessageReturn::RemoveIOWinAndExit;
|
|
|
|
sfx = x8c_navBackSfx;
|
|
|
|
}
|
|
|
|
break;
|
2016-12-29 05:53:00 +00:00
|
|
|
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::NotOriginalCard:
|
|
|
|
if (userSel == 1)
|
|
|
|
{
|
|
|
|
/* Continue */
|
|
|
|
x8_serial = x6c_cardDriver->x28_cardSerial;
|
|
|
|
x10_uiType = EUIType::Empty;
|
|
|
|
x6c_cardDriver->IndexFiles();
|
|
|
|
sfx = x84_navConfirmSfx;
|
|
|
|
}
|
|
|
|
else if (userSel == 0)
|
|
|
|
{
|
|
|
|
/* Cancel */
|
|
|
|
x80_iowRet = CIOWin::EMessageReturn::RemoveIOWinAndExit;
|
|
|
|
sfx = x8c_navBackSfx;
|
|
|
|
}
|
|
|
|
break;
|
2016-12-29 05:53:00 +00:00
|
|
|
|
2016-12-30 06:37:01 +00:00
|
|
|
case EUIType::AllDataWillBeLost:
|
|
|
|
if (userSel == 0)
|
|
|
|
{
|
|
|
|
/* Continue */
|
|
|
|
x6c_cardDriver->StartCardFormat();
|
|
|
|
x10_uiType = EUIType::Empty;
|
|
|
|
sfx = x84_navConfirmSfx;
|
|
|
|
}
|
|
|
|
else if (userSel == 1)
|
|
|
|
{
|
|
|
|
/* Cancel */
|
|
|
|
ResetCardDriver();
|
|
|
|
sfx = x8c_navBackSfx;
|
|
|
|
}
|
|
|
|
break;
|
2016-12-29 05:53:00 +00:00
|
|
|
|
2017-01-09 03:44:00 +00:00
|
|
|
case EUIType::SaveReady:
|
2016-12-30 06:37:01 +00:00
|
|
|
if (x0_saveCtx == ESaveContext::InGame)
|
|
|
|
{
|
|
|
|
if (userSel == 0)
|
|
|
|
{
|
|
|
|
/* Yes */
|
|
|
|
x6c_cardDriver->BuildExistingFileSlot(g_GameState->GetFileIdx());
|
|
|
|
x6c_cardDriver->StartFileCreateTransactional();
|
|
|
|
sfx = x84_navConfirmSfx;
|
|
|
|
}
|
|
|
|
else if (userSel == 1)
|
|
|
|
{
|
|
|
|
/* No */
|
|
|
|
x80_iowRet = CIOWin::EMessageReturn::RemoveIOWinAndExit;
|
|
|
|
sfx = x8c_navBackSfx;
|
|
|
|
}
|
|
|
|
}
|
2016-12-29 05:53:00 +00:00
|
|
|
|
|
|
|
default: break;
|
|
|
|
}
|
2016-12-19 19:20:30 +00:00
|
|
|
|
2016-12-29 05:53:00 +00:00
|
|
|
if (sfx >= 0)
|
|
|
|
CSfxManager::SfxStart(sfx, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
2016-12-19 19:20:30 +00:00
|
|
|
}
|
|
|
|
|
2017-02-12 03:17:18 +00:00
|
|
|
void CSaveGameScreen::DoSelectionChange(CGuiTableGroup* caller, int userSel)
|
2016-12-19 19:20:30 +00:00
|
|
|
{
|
2016-12-30 06:37:01 +00:00
|
|
|
SetUIColors();
|
|
|
|
CSfxManager::SfxStart(x88_navMoveSfx, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
2016-12-19 19:20:30 +00:00
|
|
|
}
|
|
|
|
|
2017-02-12 03:17:18 +00:00
|
|
|
void CSaveGameScreen::ProcessUserInput(const CFinalInput& input)
|
2016-12-19 19:20:30 +00:00
|
|
|
{
|
2016-12-30 06:37:01 +00:00
|
|
|
if (x50_loadedFrame)
|
2017-02-10 23:58:05 +00:00
|
|
|
{
|
2016-12-30 06:37:01 +00:00
|
|
|
x50_loadedFrame->ProcessUserInput(input);
|
2017-02-10 23:58:05 +00:00
|
|
|
|
|
|
|
int tbOpt = m_touchBar->PopOption();
|
|
|
|
if (tbOpt != -1)
|
|
|
|
{
|
|
|
|
x58_tablegroup_choices->SetUserSelection(tbOpt);
|
|
|
|
SetUIColors();
|
|
|
|
DoAdvance(x58_tablegroup_choices);
|
|
|
|
}
|
|
|
|
}
|
2016-12-19 19:20:30 +00:00
|
|
|
}
|
|
|
|
|
2017-02-12 03:17:18 +00:00
|
|
|
void CSaveGameScreen::StartGame(int idx)
|
2016-12-19 19:20:30 +00:00
|
|
|
{
|
2016-12-30 06:37:01 +00:00
|
|
|
const CGameState::GameFileStateInfo* info = x6c_cardDriver->GetGameFileStateInfo(idx);
|
|
|
|
x6c_cardDriver->ExportPersistentOptions();
|
|
|
|
x6c_cardDriver->BuildNewFileSlot(idx);
|
2017-02-07 02:25:58 +00:00
|
|
|
if (!info)
|
2016-12-30 06:37:01 +00:00
|
|
|
x6c_cardDriver->StartFileCreateTransactional();
|
|
|
|
else
|
|
|
|
x80_iowRet = CIOWin::EMessageReturn::Exit;
|
2016-12-19 19:20:30 +00:00
|
|
|
}
|
|
|
|
|
2017-02-12 03:17:18 +00:00
|
|
|
void CSaveGameScreen::SaveNESState()
|
2016-12-19 19:20:30 +00:00
|
|
|
{
|
2016-12-31 00:51:51 +00:00
|
|
|
if (!x92_savingDisabled)
|
2016-12-30 06:37:01 +00:00
|
|
|
{
|
|
|
|
x90_needsDriverReset = true;
|
|
|
|
x8_serial = x6c_cardDriver->x28_cardSerial;
|
|
|
|
x6c_cardDriver->StartFileCreateTransactional();
|
|
|
|
}
|
2016-12-19 19:20:30 +00:00
|
|
|
}
|
|
|
|
|
2017-02-12 03:17:18 +00:00
|
|
|
void CSaveGameScreen::EraseGame(int idx)
|
2016-12-31 00:51:51 +00:00
|
|
|
{
|
|
|
|
x6c_cardDriver->EraseFileSlot(idx);
|
|
|
|
x90_needsDriverReset = true;
|
|
|
|
x6c_cardDriver->StartFileCreateTransactional();
|
|
|
|
}
|
|
|
|
|
2017-02-12 03:17:18 +00:00
|
|
|
const CGameState::GameFileStateInfo* CSaveGameScreen::GetGameData(int idx) const
|
2016-12-19 19:20:30 +00:00
|
|
|
{
|
2016-12-30 06:37:01 +00:00
|
|
|
return x6c_cardDriver->GetGameFileStateInfo(idx);
|
2016-12-19 19:20:30 +00:00
|
|
|
}
|
|
|
|
|
2017-02-12 03:17:18 +00:00
|
|
|
CSaveGameScreen::CSaveGameScreen(ESaveContext saveCtx, u64 serial)
|
2017-02-10 23:58:05 +00:00
|
|
|
: x0_saveCtx(saveCtx), x8_serial(serial), m_touchBar(NewSaveUITouchBar())
|
2016-12-19 19:20:30 +00:00
|
|
|
{
|
|
|
|
x14_txtrSaveBanner = g_SimplePool->GetObj("TXTR_SaveBanner");
|
|
|
|
x20_txtrSaveIcon0 = g_SimplePool->GetObj("TXTR_SaveIcon0");
|
|
|
|
x2c_txtrSaveIcon1 = g_SimplePool->GetObj("TXTR_SaveIcon1");
|
|
|
|
x38_strgMemoryCard = g_SimplePool->GetObj("STRG_MemoryCard");
|
|
|
|
x44_frmeGenericMenu = g_SimplePool->GetObj("FRME_GenericMenu");
|
|
|
|
|
2017-02-04 03:46:12 +00:00
|
|
|
x6c_cardDriver = ConstructCardDriver(x0_saveCtx == ESaveContext::FrontEnd);
|
2016-12-19 19:20:30 +00:00
|
|
|
|
2016-12-30 06:37:01 +00:00
|
|
|
if (saveCtx == ESaveContext::InGame)
|
2016-12-19 19:20:30 +00:00
|
|
|
{
|
|
|
|
x84_navConfirmSfx = 1432;
|
|
|
|
x88_navMoveSfx = 1436;
|
|
|
|
x8c_navBackSfx = 1431;
|
|
|
|
}
|
2016-12-30 06:37:01 +00:00
|
|
|
x93_inGame = bool(saveCtx);
|
2016-12-19 19:20:30 +00:00
|
|
|
|
|
|
|
x70_saveWorlds.reserve(g_MemoryCardSys->GetMemoryWorlds().size());
|
2017-08-13 05:26:14 +00:00
|
|
|
for (const std::pair<CAssetId, CSaveWorldMemory>& wld : g_MemoryCardSys->GetMemoryWorlds())
|
2016-12-19 19:20:30 +00:00
|
|
|
{
|
|
|
|
x70_saveWorlds.push_back(
|
|
|
|
g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), wld.second.GetSaveWorldAssetId()}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-12 03:17:18 +00:00
|
|
|
std::unique_ptr<CMemoryCardDriver> CSaveGameScreen::ConstructCardDriver(bool importPersistent)
|
2016-12-19 19:20:30 +00:00
|
|
|
{
|
2016-12-28 08:51:28 +00:00
|
|
|
return std::make_unique<CMemoryCardDriver>(kabufuda::ECardSlot::SlotA,
|
2016-12-19 19:20:30 +00:00
|
|
|
g_ResFactory->GetResourceIdByName("TXTR_SaveBanner")->id,
|
|
|
|
g_ResFactory->GetResourceIdByName("TXTR_SaveIcon0")->id,
|
2017-02-04 03:46:12 +00:00
|
|
|
g_ResFactory->GetResourceIdByName("TXTR_SaveIcon1")->id, importPersistent);
|
2016-12-19 19:20:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|