metaforce/Runtime/MP1/CSaveGameScreen.hpp

115 lines
3.2 KiB
C++
Raw Permalink Normal View History

2018-10-06 20:42:33 -07:00
#pragma once
#include <memory>
#include <vector>
#include "Runtime/CIOWin.hpp"
#include "Runtime/CToken.hpp"
2020-09-15 16:35:22 -07:00
#include "Runtime/GuiSys/CGuiFrame.hpp"
#include "Runtime/MP1/CMemoryCardDriver.hpp"
2020-09-15 16:35:22 -07:00
#include "Runtime/RetroTypes.hpp"
2021-04-10 01:42:06 -07:00
namespace metaforce {
class CGuiTableGroup;
class CGuiTextPane;
class CWorldSaveGameInfo;
class CStringTable;
class CTexture;
2018-02-03 22:46:47 -08:00
struct CFinalInput;
2018-12-07 21:30:43 -08:00
namespace MP1 {
2018-12-07 21:30:43 -08:00
enum class ESaveContext { FrontEnd, InGame };
2016-12-29 22:37:01 -08:00
2018-12-07 21:30:43 -08:00
class CSaveGameScreen {
2016-12-21 12:44:30 -08:00
public:
2018-12-07 21:30:43 -08:00
enum class EUIType {
Empty = 0,
BusyReading = 1,
BusyWriting = 2,
NoCardFound = 3,
NeedsFormatBroken = 4,
NeedsFormatEncoding = 5,
CardDamaged = 6,
WrongDevice = 7,
InsufficientSpaceBadCheck = 8,
InsufficientSpaceOKCheck = 9,
IncompatibleCard = 10,
SaveCorrupt = 11,
StillInsufficientSpace = 12,
ProgressWillBeLost = 13,
NotOriginalCard = 14,
AllDataWillBeLost = 15,
SaveReady = 16,
// Metaforce Addition
CreateDolphinCardFailed
2018-12-07 21:30:43 -08:00
};
bool IsHiddenFromFrontEnd() const {
2018-12-07 21:30:43 -08:00
switch (x10_uiType) {
case EUIType::SaveReady:
case EUIType::Empty:
case EUIType::BusyReading:
case EUIType::BusyWriting:
return false;
default:
return true;
}
2018-12-07 21:30:43 -08:00
}
2016-12-21 12:44:30 -08:00
private:
2018-12-07 21:30:43 -08:00
ESaveContext x0_saveCtx;
u64 x8_serial;
EUIType x10_uiType = EUIType::Empty;
TLockedToken<CTexture> x14_txtrSaveBanner;
TLockedToken<CTexture> x20_txtrSaveIcon0;
TLockedToken<CTexture> x2c_txtrSaveIcon1;
TLockedToken<CStringTable> x38_strgMemoryCard;
TLockedToken<CGuiFrame> x44_frmeGenericMenu;
CGuiFrame* x50_loadedFrame = nullptr;
2020-09-12 18:13:38 -07:00
CGuiTextPane* x54_textpane_message{};
CGuiTableGroup* x58_tablegroup_choices{};
CGuiTextPane* x5c_textpane_choice0{};
CGuiTextPane* x60_textpane_choice1{};
CGuiTextPane* x64_textpane_choice2{};
CGuiTextPane* x68_textpane_choice3{};
2018-12-07 21:30:43 -08:00
std::unique_ptr<CMemoryCardDriver> x6c_cardDriver;
std::vector<TLockedToken<CWorldSaveGameInfo>> x70_saveWorlds;
2018-12-07 21:30:43 -08:00
CIOWin::EMessageReturn x80_iowRet = CIOWin::EMessageReturn::Normal;
u32 x84_navConfirmSfx = SFXui_frontend_save_confirm;
u32 x88_navMoveSfx = SFXui_frontend_save_move;
u32 x8c_navBackSfx = SFXui_frontend_save_back;
bool x90_needsDriverReset = false;
bool x91_uiTextDirty = false;
bool x92_savingDisabled = false;
bool x93_inGame;
2018-12-07 21:30:43 -08:00
void ContinueWithoutSaving();
2016-12-23 16:45:51 -08:00
2016-12-21 12:44:30 -08:00
public:
2018-12-07 21:30:43 -08:00
static std::unique_ptr<CMemoryCardDriver> ConstructCardDriver(bool inGame);
void ResetCardDriver();
CIOWin::EMessageReturn Update(float dt);
void SetInGame(bool v) { x93_inGame = v; }
bool PumpLoad();
2020-09-12 18:13:38 -07:00
[[nodiscard]] EUIType SelectUIType() const;
2018-12-07 21:30:43 -08:00
void SetUIText();
void SetUIColors();
void Draw() const;
2018-12-07 21:30:43 -08:00
void DoAdvance(CGuiTableGroup* caller);
void DoSelectionChange(CGuiTableGroup* caller, int oldSel);
2018-12-07 21:30:43 -08:00
void ProcessUserInput(const CFinalInput& input);
void StartGame(int idx);
void SaveNESState();
void EraseGame(int idx);
2020-09-12 18:13:38 -07:00
[[nodiscard]] const CGameState::GameFileStateInfo* GetGameData(int idx) const;
[[nodiscard]] EUIType GetUIType() const { return x10_uiType; }
[[nodiscard]] bool IsSavingDisabled() const { return x92_savingDisabled; }
explicit CSaveGameScreen(ESaveContext saveCtx, u64 serial);
};
2018-12-07 21:30:43 -08:00
} // namespace MP1
2021-04-10 01:42:06 -07:00
} // namespace metaforce