CSaveUI work

This commit is contained in:
Jack Andersen 2016-12-17 18:16:04 -10:00
parent a2b07ba357
commit 03a93c52b9
11 changed files with 735 additions and 38 deletions

View File

@ -132,4 +132,29 @@ bool CMemoryCardSys::InitializePump()
return false;
}
CMemoryCardSys::CardProbeResults CMemoryCardSys::CardProbe(EMemoryCardPort port)
{
return {};
}
CMemoryCardSys::ECardResult CMemoryCardSys::MountCard(EMemoryCardPort port)
{
return ECardResult::CARD_RESULT_READY;
}
CMemoryCardSys::ECardResult CMemoryCardSys::CheckCard(EMemoryCardPort port)
{
return ECardResult::CARD_RESULT_READY;
}
CMemoryCardSys::ECardResult CMemoryCardSys::GetNumFreeBytes(EMemoryCardPort port, s32& freeBytes, s32& freeFiles)
{
return ECardResult::CARD_RESULT_READY;
}
CMemoryCardSys::ECardResult CMemoryCardSys::GetSerialNo(EMemoryCardPort port, u64& serialOut)
{
return ECardResult::CARD_RESULT_READY;
}
}

View File

@ -59,6 +59,37 @@ public:
const std::vector<std::pair<ResId, CSaveWorldMemory>>& GetMemoryWorlds() const { return xc_memoryWorlds; }
CMemoryCardSys();
bool InitializePump();
enum class EMemoryCardPort
{
SlotA,
SlotB
};
enum class ECardResult
{
CARD_RESULT_FATAL_ERROR = -128,
CARD_RESULT_ENCODING = -13,
CARD_RESULT_BROKEN = -6,
CARD_RESULT_IOERROR = -5,
CARD_RESULT_NOCARD = -3,
CARD_RESULT_WRONGDEVICE = -2,
CARD_RESULT_BUSY = -1,
CARD_RESULT_READY = 0
};
struct CardProbeResults
{
ECardResult x0_error;
u32 x4_cardSize; // in megabits
u32 x8_sectorSize; // in bytes
};
static CardProbeResults CardProbe(EMemoryCardPort port);
static ECardResult MountCard(EMemoryCardPort port);
static ECardResult CheckCard(EMemoryCardPort port);
static ECardResult GetNumFreeBytes(EMemoryCardPort port, s32& freeBytes, s32& freeFiles);
static ECardResult GetSerialNo(EMemoryCardPort port, u64& serialOut);
};
}

View File

@ -527,7 +527,7 @@ void CBooRenderer::SetPerspective(float fovy, float aspect, float znear, float z
CGraphics::SetPerspective(fovy, aspect, znear, zfar);
}
void CBooRenderer::SetViewportOrtho(bool centered, float znear, float zfar)
zeus::CRectangle CBooRenderer::SetViewportOrtho(bool centered, float znear, float zfar)
{
float left = centered ? CGraphics::g_ViewportResolutionHalf.x : 0;
float bottom = centered ? CGraphics::g_ViewportResolutionHalf.y : 0;
@ -537,6 +537,8 @@ void CBooRenderer::SetViewportOrtho(bool centered, float znear, float zfar)
CGraphics::SetOrtho(left, right, top, bottom, znear, zfar);
CGraphics::SetViewPointMatrix(zeus::CTransform::Identity());
CGraphics::SetModelMatrix(zeus::CTransform::Identity());
return zeus::CRectangle(left, bottom, right, top);
}
void CBooRenderer::SetClippingPlanes(const zeus::CFrustum& frustum)

View File

@ -157,7 +157,7 @@ public:
void SetWorldViewpoint(const zeus::CTransform&);
void SetPerspective(float, float, float, float, float);
void SetPerspective(float, float, float, float);
void SetViewportOrtho(bool, float, float);
zeus::CRectangle SetViewportOrtho(bool, float, float);
void SetClippingPlanes(const zeus::CFrustum& frustum);
void SetViewport(int, int, int, int);
//void SetDepthReadWrite(bool, bool);

View File

@ -164,6 +164,7 @@ public:
const zeus::CVector3f& c, const zeus::CVector3f& d);
void DrawFrame();
void Update(float dt);
std::pair<u32, u32> GetVideoDimensions() const { return {x6c_videoInfo.width, x6c_videoInfo.height}; }
static void Initialize();
static void Shutdown();

View File

@ -8,6 +8,7 @@
#include "zeus/CPlane.hpp"
#include "zeus/CFrustum.hpp"
#include "zeus/CColor.hpp"
#include "zeus/CRectangle.hpp"
#include "CGraphics.hpp"
namespace urde
@ -55,7 +56,7 @@ public:
virtual void SetWorldViewpoint(const zeus::CTransform&)=0;
virtual void SetPerspective(float, float, float, float, float)=0;
virtual void SetPerspective(float, float, float, float)=0;
virtual void SetViewportOrtho(bool, float, float)=0;
virtual zeus::CRectangle SetViewportOrtho(bool, float, float)=0;
virtual void SetClippingPlanes(const zeus::CFrustum&)=0;
virtual void SetViewport(int, int, int, int)=0;
//virtual void SetDepthReadWrite(bool, bool)=0;

View File

@ -2,10 +2,197 @@
#include "CSimplePool.hpp"
#include "GameGlobalObjects.hpp"
#include "CMemoryCardSys.hpp"
#include "GuiSys/CGuiFrame.hpp"
#include "GuiSys/CGuiTableGroup.hpp"
#include "GuiSys/CGuiTextPane.hpp"
#include "MP1/MP1.hpp"
namespace urde
{
CSaveUI::SBannerInfo::SMemoryCardSlotInfo::SMemoryCardSlotInfo(CMemoryCardSys::EMemoryCardPort parentIdx,
const std::string& name)
: x0_cardPort(parentIdx), x14_name(name)
{}
CSaveUI::SBannerInfo::SBannerInfo(CMemoryCardSys::EMemoryCardPort cardPort, ResId saveBanner,
ResId saveIcon0, ResId saveIcon1, bool flag)
: x0_cardPort(cardPort), x4_saveBanner(saveBanner),
x8_saveIcon0(saveIcon0), xc_saveIcon1(saveIcon1), x19d_flag(flag)
{
x100_mcSlotInfos.reserve(2);
x100_mcSlotInfos.emplace_back(0, SMemoryCardSlotInfo(x0_cardPort, "MetroidPrime A"));
x100_mcSlotInfos.emplace_back(0, SMemoryCardSlotInfo(x0_cardPort, "MetroidPrime B"));
}
void CSaveUI::SBannerInfo::FinishedLoading()
{
x10_state = EState::TwentyFive;
x14_error = EError::Zero;
FinishedLoading2();
}
void CSaveUI::SBannerInfo::FinishedLoading2()
{
auto result = CMemoryCardSys::CardProbe(x0_cardPort);
switch (result.x0_error)
{
case CMemoryCardSys::ECardResult::CARD_RESULT_READY:
if (result.x8_sectorSize != 0x2000)
{
x10_state = EState::Twelve;
x14_error = EError::Seven;
return;
}
x10_state = EState::Five;
MountCard();
break;
case CMemoryCardSys::ECardResult::CARD_RESULT_BUSY:
break;
case CMemoryCardSys::ECardResult::CARD_RESULT_WRONGDEVICE:
x10_state = EState::Twelve;
x14_error = EError::Four;
break;
default:
NoCardFound();
break;
}
}
void CSaveUI::SBannerInfo::NoCardFound()
{
x10_state = EState::Two;
static_cast<MP1::CMain*>(g_Main)->SetCardInserted(false);
}
void CSaveUI::SBannerInfo::MountCard()
{
x10_state = EState::TwentySix;
x14_error = EError::Zero;
CMemoryCardSys::ECardResult result = CMemoryCardSys::MountCard(x0_cardPort);
if (result != CMemoryCardSys::ECardResult::CARD_RESULT_READY)
MountCardFailed(result);
}
void CSaveUI::SBannerInfo::MountCardFailed(CMemoryCardSys::ECardResult result)
{
switch (result)
{
case CMemoryCardSys::ECardResult::CARD_RESULT_READY:
x10_state = EState::Six;
CheckCard();
break;
case CMemoryCardSys::ECardResult::CARD_RESULT_BROKEN:
x10_state = EState::Six;
x14_error = EError::One;
CheckCard();
break;
default:
HandleCardError(result, EState::Thirteen);
break;
}
}
void CSaveUI::SBannerInfo::CheckCard()
{
CMemoryCardSys::ECardResult result = CMemoryCardSys::CheckCard(x0_cardPort);
if (result != CMemoryCardSys::ECardResult::CARD_RESULT_READY)
CheckCardFailed(result);
}
void CSaveUI::SBannerInfo::CheckCardFailed(CMemoryCardSys::ECardResult result)
{
switch (result)
{
case CMemoryCardSys::ECardResult::CARD_RESULT_READY:
x10_state = EState::Seven;
if (!GetCardFreeBytes())
return;
if (CMemoryCardSys::GetSerialNo(x0_cardPort, x28_cardSerial) ==
CMemoryCardSys::ECardResult::CARD_RESULT_READY)
return;
NoCardFound();
break;
case CMemoryCardSys::ECardResult::CARD_RESULT_BROKEN:
x10_state = EState::Fourteen;
x14_error = EError::One;
break;
default:
HandleCardError(result, EState::Fourteen);
}
}
bool CSaveUI::SBannerInfo::GetCardFreeBytes()
{
CMemoryCardSys::ECardResult result = CMemoryCardSys::GetNumFreeBytes(x0_cardPort,
x18_cardFreeBytes,
x1c_cardFreeFiles);
if (result == CMemoryCardSys::ECardResult::CARD_RESULT_READY)
return true;
NoCardFound();
return false;
}
void CSaveUI::SBannerInfo::HandleCardError(CMemoryCardSys::ECardResult result, EState state)
{
switch (result)
{
case CMemoryCardSys::ECardResult::CARD_RESULT_WRONGDEVICE:
x10_state = state;
x14_error = EError::Four;
break;
case CMemoryCardSys::ECardResult::CARD_RESULT_NOCARD:
NoCardFound();
break;
case CMemoryCardSys::ECardResult::CARD_RESULT_IOERROR:
x10_state = state;
x14_error = EError::Three;
case CMemoryCardSys::ECardResult::CARD_RESULT_ENCODING:
x10_state = state;
x14_error = EError::Two;
break;
default: break;
}
}
void CSaveUI::SBannerInfo::Update()
{
auto result = CMemoryCardSys::CardProbe(x0_cardPort);
if (result.x0_error == CMemoryCardSys::ECardResult::CARD_RESULT_NOCARD)
{
if (x10_state != EState::Two)
NoCardFound();
static_cast<MP1::CMain*>(g_Main)->SetCardInserted(false);
return;
}
switch (x10_state)
{
case EState::TwentySix:
case EState::TwentySeven:
case EState::TwentyEight:
case EState::TwentyNine:
case EState::Thirty:
case EState::ThirtyOne:
case EState::ThirtyTwo:
case EState::ThirtyThree:
case EState::ThirtyFour:
case EState::ThirtyFive:
case EState::ThirtySix:
case EState::ThirtySeven:
default: break;
}
}
std::unique_ptr<CSaveUI::SBannerInfo> CSaveUI::ConstructBannerInfo(bool flag)
{
return std::make_unique<SBannerInfo>(CMemoryCardSys::EMemoryCardPort::SlotA,
g_ResFactory->GetResourceIdByName("TXTR_SaveBanner")->id,
g_ResFactory->GetResourceIdByName("TXTR_SaveIcon0")->id,
g_ResFactory->GetResourceIdByName("TXTR_SaveIcon1")->id, flag);
}
CIOWin::EMessageReturn CSaveUI::Update(float dt)
{
@ -13,7 +200,135 @@ CIOWin::EMessageReturn CSaveUI::Update(float dt)
bool CSaveUI::PumpLoad()
{
return false;
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();
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(
std::bind(&CSaveUI::DoAdvance, this, std::placeholders::_1));
x58_tablegroup_choices->SetMenuSelectionChangeCallback(
std::bind(&CSaveUI::DoSelectionChange, this, std::placeholders::_1));
if (x0_instIdx == 1)
x6c_bannerInfo->FinishedLoading();
x10_uiType = SelectUIType();
FinishedLoading();
return true;
}
using EState = CSaveUI::SBannerInfo::EState;
static bool InRange1(EState v)
{
return v >= EState::TwentySix && v <= EState::ThirtySeven;
}
static bool InRange2(EState v)
{
if (v < EState::TwentyFive)
return false;
if (v == EState::TwentySeven)
return false;
if (v == EState::TwentyNine)
return false;
return true;
}
CSaveUI::UIType CSaveUI::SelectUIType() const
{
if (x6c_bannerInfo->x10_state == SBannerInfo::EState::Two)
return UIType::Three;
switch (x10_uiType)
{
case UIType::Thirteen:
case UIType::Fourteen:
case UIType::Fifteen:
return x10_uiType;
default: break;
}
if (InRange1(x6c_bannerInfo->x10_state))
{
if (!InRange2(x6c_bannerInfo->x10_state))
return UIType::Two;
return UIType::One;
}
if (x6c_bannerInfo->x10_state == SBannerInfo::EState::One)
{
if (x6c_bannerInfo->x14_error == SBannerInfo::EError::Six)
return UIType::Twelve;
return UIType::Sixteen;
}
if (x6c_bannerInfo->x14_error == SBannerInfo::EError::One)
return UIType::Four;
if (x6c_bannerInfo->x14_error == SBannerInfo::EError::Two)
return UIType::Five;
if (x6c_bannerInfo->x14_error == SBannerInfo::EError::Four)
return UIType::Seven;
if (x6c_bannerInfo->x14_error == SBannerInfo::EError::Five)
{
if (x6c_bannerInfo->x10_state == SBannerInfo::EState::Fourteen)
return UIType::Eight;
return UIType::Nine;
}
if (x6c_bannerInfo->x14_error == SBannerInfo::EError::Seven)
return UIType::Ten;
if (x6c_bannerInfo->x14_error == SBannerInfo::EError::Nine)
return UIType::Eleven;
if (x6c_bannerInfo->x14_error == SBannerInfo::EError::Three)
return UIType::Six;
return UIType::Zero;
}
void CSaveUI::FinishedLoading()
{
}
void CSaveUI::Draw() const
{
}
void CSaveUI::DoAdvance(CGuiTableGroup* caller)
{
}
void CSaveUI::DoSelectionChange(CGuiTableGroup* caller)
{
}
void CSaveUI::ProcessUserInput(const CFinalInput& input)
@ -45,7 +360,9 @@ CSaveUI::CSaveUI(u32 instIdx, u32 a, u32 b)
x38_strgMemoryCard = g_SimplePool->GetObj("STRG_MemoryCard");
x44_frmeGenericMenu = g_SimplePool->GetObj("FRME_GenericMenu");
if (instIdx)
x6c_bannerInfo = ConstructBannerInfo(x0_instIdx / 32);
if (instIdx == 1)
{
x84_navConfirmSfx = 1432;
x88_navMoveSfx = 1436;

View File

@ -4,6 +4,7 @@
#include "RetroTypes.hpp"
#include "CToken.hpp"
#include "CIOWin.hpp"
#include "CMemoryCardSys.hpp"
namespace urde
{
@ -12,20 +13,148 @@ class CStringTable;
class CGuiFrame;
class CSaveWorld;
class CFinalInput;
class CGuiTextPane;
class CGuiTableGroup;
struct CSaveUI
{
enum class UIType
{
Zero,
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Ten,
Eleven,
Twelve,
Thirteen,
Fourteen,
Fifteen,
Sixteen
};
bool IsDrawConditional()
{
switch (x10_uiType)
{
case UIType::Sixteen:
case UIType::Zero:
case UIType::One:
case UIType::Two:
return false;
default:
return true;
}
}
struct SBannerInfo
{
struct SMemoryCardSlotInfo
{
CMemoryCardSys::EMemoryCardPort x0_cardPort;
u32 x4_ = -1;
std::string x14_name;
std::vector<u8> x24_;
std::vector<u8> x34_;
SMemoryCardSlotInfo(CMemoryCardSys::EMemoryCardPort cardPort, const std::string& name);
};
enum class EState
{
Zero,
One = 1,
Two = 2,
Five = 5,
Six = 6,
Seven = 7,
Twelve = 12,
Thirteen = 13,
Fourteen = 14,
TwentyFive = 26,
TwentySix = 26,
TwentySeven = 27,
TwentyEight = 28,
TwentyNine = 29,
Thirty = 30,
ThirtyOne = 31,
ThirtyTwo = 32,
ThirtyThree = 33,
ThirtyFour = 34,
ThirtyFive = 35,
ThirtySix = 36,
ThirtySeven = 37
};
enum class EError
{
Zero,
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine
};
CMemoryCardSys::EMemoryCardPort x0_cardPort;
ResId x4_saveBanner;
ResId x8_saveIcon0;
ResId xc_saveIcon1;
EState x10_state = EState::Zero;
EError x14_error = EError::Zero;
s32 x18_cardFreeBytes = 0;
s32 x1c_cardFreeFiles = 0;
u32 x20_ = 0;
u32 x24_ = 0;
u64 x28_cardSerial = 0;
u8 x30_[174];
std::unique_ptr<u8> xe4_[3];
std::vector<std::pair<u32, SMemoryCardSlotInfo>> x100_mcSlotInfos;
u32 x194_ = -1;
u32 x198_ = 0;
bool x19c_ = false;
bool x19d_flag;
SBannerInfo(CMemoryCardSys::EMemoryCardPort cardPort, ResId saveBanner,
ResId saveIcon0, ResId saveIcon1, bool flag);
void FinishedLoading();
void FinishedLoading2();
void NoCardFound();
void MountCard();
void MountCardFailed(CMemoryCardSys::ECardResult result);
void CheckCard();
void CheckCardFailed(CMemoryCardSys::ECardResult result);
bool GetCardFreeBytes();
void HandleCardError(CMemoryCardSys::ECardResult result, EState state);
void Update();
};
u32 x0_instIdx;
u32 x8_a;
u32 xc_b;
u32 x10_ = 0;
UIType x10_uiType = UIType::Zero;
TLockedToken<CTexture> x14_txtrSaveBanner;
TLockedToken<CTexture> x20_txtrSaveIcon0;
TLockedToken<CTexture> x2c_txtrSaveIcon1;
TLockedToken<CStringTable> x38_strgMemoryCard;
TLockedToken<CGuiFrame> x44_frmeGenericMenu;
u32 x50_ = 0;
std::unique_ptr<u32> x6c_bannerInfo;
CGuiFrame* x50_loadedFrame = nullptr;
CGuiTextPane* x54_textpane_message;
CGuiTableGroup* x58_tablegroup_choices;
CGuiTextPane* x5c_textpane_choice0;
CGuiTextPane* x60_textpane_choice1;
CGuiTextPane* x64_textpane_choice2;
CGuiTextPane* x68_textpane_choice3;
std::unique_ptr<SBannerInfo> x6c_bannerInfo;
std::vector<TLockedToken<CSaveWorld>> x70_saveWorlds;
u32 x80_ = 0;
u32 x84_navConfirmSfx = 1460;
@ -36,8 +165,16 @@ struct CSaveUI
bool x92_ = false;
bool x93_secondaryInst;
static std::unique_ptr<SBannerInfo> ConstructBannerInfo(bool flag);
CIOWin::EMessageReturn Update(float dt);
bool PumpLoad();
UIType SelectUIType() const;
void FinishedLoading();
void Draw() const;
void DoAdvance(CGuiTableGroup* caller);
void DoSelectionChange(CGuiTableGroup* caller);
void ProcessUserInput(const CFinalInput& input);
void StartGame(int idx);
void EraseGame(int idx);

View File

@ -102,11 +102,11 @@ void CFrontEndUI::SNewFileSelectFrame::FinishedLoading()
worker->SetVisibility(false, ETraversalMode::Children);
x20_tablegroup_fileselect->SetMenuAdvanceCallback(
std::bind(&SNewFileSelectFrame::DoFileselectAdvance, this, std::placeholders::_1));
std::bind(&SNewFileSelectFrame::DoFileMenuAdvance, this, std::placeholders::_1));
x20_tablegroup_fileselect->SetMenuSelectionChangeCallback(
std::bind(&SNewFileSelectFrame::DoSelectionChange, this, std::placeholders::_1));
x20_tablegroup_fileselect->SetMenuCancelCallback(
std::bind(&SNewFileSelectFrame::DoFileselectCancel, this, std::placeholders::_1));
std::bind(&SNewFileSelectFrame::DoFileMenuCancel, this, std::placeholders::_1));
x40_tablegroup_popup->SetMenuAdvanceCallback(
std::bind(&SNewFileSelectFrame::DoPopupAdvance, this, std::placeholders::_1));
@ -153,14 +153,18 @@ bool CFrontEndUI::SNewFileSelectFrame::IsTextDoneAnimating() const
CFrontEndUI::SNewFileSelectFrame::EPhase
CFrontEndUI::SNewFileSelectFrame::ProcessUserInput(const CFinalInput& input)
{
if (x8_ != 2)
if (x8_subMenu != ESubMenu::Two)
x4_saveUI->ProcessUserInput(input);
if (IsTextDoneAnimating())
x108_curTime = std::min(0.5f, x108_curTime + input.DeltaTime());
if (x108_curTime < 0.5f)
return xc_phase;
if (x10c_inputEnable)
x1c_loadedFrame->ProcessUserInput(input);
if (x10d_needsExistingToggle)
{
if (x40_tablegroup_popup->GetIsActive())
@ -169,6 +173,7 @@ CFrontEndUI::SNewFileSelectFrame::ProcessUserInput(const CFinalInput& input)
ActivateExistingGamePopup();
x10d_needsExistingToggle = false;
}
if (x10e_needsNewToggle)
{
if (x40_tablegroup_popup->GetIsActive())
@ -177,13 +182,20 @@ CFrontEndUI::SNewFileSelectFrame::ProcessUserInput(const CFinalInput& input)
ActivateNewGamePopup();
x10e_needsNewToggle = false;
}
return xc_phase;
}
void CFrontEndUI::SNewFileSelectFrame::Draw() const
{
}
void CFrontEndUI::SNewFileSelectFrame::HandleActiveChange(CGuiTableGroup* active)
{
if (!active)
return;
active->SetColors(zeus::CColor::skWhite,
zeus::CColor{0.627450f, 0.627450f, 0.627450f, 0.784313f});
@ -191,7 +203,7 @@ void CFrontEndUI::SNewFileSelectFrame::HandleActiveChange(CGuiTableGroup* active
x24_model_erase->SetLocalTransform(zeus::CTransform::Translate(
zeus::CVector3f{0.f, 0.f, active->GetUserSelection() * x104_rowPitch} + xf8_model_erase_position));
if (x8_ == 0 || x8_ == 3)
if (x8_subMenu == ESubMenu::Zero || x8_subMenu == ESubMenu::Three)
x24_model_erase->SetIsVisible(false);
else
x24_model_erase->SetIsVisible(true);
@ -202,7 +214,9 @@ void CFrontEndUI::SNewFileSelectFrame::DeactivateExistingGamePopup()
x40_tablegroup_popup->SetIsActive(false);
x40_tablegroup_popup->SetIsVisible(false);
x20_tablegroup_fileselect->SetIsActive(true);
HandleActiveChange(x20_tablegroup_fileselect);
x64_fileSelections[x20_tablegroup_fileselect->GetUserSelection()].
x0_base->SetColor(zeus::CColor::skWhite);
}
@ -215,10 +229,13 @@ void CFrontEndUI::SNewFileSelectFrame::ActivateExistingGamePopup()
zeus::CTransform::Translate(0.f, 0.f, x20_tablegroup_fileselect->GetUserSelection() * x104_rowPitch) *
x40_tablegroup_popup->GetTransform());
x20_tablegroup_fileselect->SetIsActive(false);
x8_ = 2;
x8_subMenu = ESubMenu::Two;
HandleActiveChange(x40_tablegroup_popup);
x48_textpane_popupadvance.SetPairText(g_MainStringTable->GetString(95));
x50_textpane_popupcancel.SetPairText(g_MainStringTable->GetString(38));
x64_fileSelections[x20_tablegroup_fileselect->GetUserSelection()].
x0_base->SetColor(zeus::CColor{1.f, 1.f, 1.f, 0.f});
x44_model_dash7->SetVisibility(false, ETraversalMode::Children);
@ -229,11 +246,15 @@ void CFrontEndUI::SNewFileSelectFrame::DeactivateNewGamePopup()
x40_tablegroup_popup->SetIsActive(false);
x40_tablegroup_popup->SetIsVisible(false);
x20_tablegroup_fileselect->SetIsActive(true);
CGuiWidget* worker = x40_tablegroup_popup->GetWorkerWidget(2);
worker->SetB627(false);
worker->SetVisibility(false, ETraversalMode::Children);
x44_model_dash7->SetVisibility(false, ETraversalMode::Children);
HandleActiveChange(x20_tablegroup_fileselect);
x64_fileSelections[x20_tablegroup_fileselect->GetUserSelection()].
x0_base->SetColor(zeus::CColor::skWhite);
x60_textpane_cancel->TextSupport()->SetText("");
@ -248,11 +269,14 @@ void CFrontEndUI::SNewFileSelectFrame::ActivateNewGamePopup()
zeus::CTransform::Translate(0.f, 0.f, x20_tablegroup_fileselect->GetUserSelection() * x104_rowPitch) *
x40_tablegroup_popup->GetTransform());
x20_tablegroup_fileselect->SetIsActive(false);
x8_ = 3;
x8_subMenu = ESubMenu::Three;
HandleActiveChange(x40_tablegroup_popup);
x64_fileSelections[x20_tablegroup_fileselect->GetUserSelection()].
x0_base->SetColor(zeus::CColor{1.f, 1.f, 1.f, 0.f});
PlayAdvanceSfx();
if (g_GameState->SystemOptions().PlayerHasHardMode())
{
x48_textpane_popupadvance.SetPairText(g_MainStringTable->GetString(102));
@ -274,12 +298,16 @@ void CFrontEndUI::SNewFileSelectFrame::ActivateNewGamePopup()
void CFrontEndUI::SNewFileSelectFrame::ResetFrame()
{
x8_ = 0;
x8_subMenu = ESubMenu::Zero;
x38_textpane_gba.x0_panes[0]->SetB627(true);
x38_textpane_gba.x0_panes[0]->TextSupport()->SetFontColor(zeus::CColor::skWhite);
x30_textpane_cheats.x0_panes[0]->SetB627(true);
x30_textpane_cheats.x0_panes[0]->TextSupport()->SetFontColor(zeus::CColor::skWhite);
ClearFrameContents();
for (int i=2 ; i>=0 ; --i)
x20_tablegroup_fileselect->GetWorkerWidget(i)->SetB627(true);
x60_textpane_cancel->TextSupport()->SetText("");
@ -293,8 +321,8 @@ void CFrontEndUI::SNewFileSelectFrame::ClearFrameContents()
{
if (x4_saveUI->GetGameData(i))
hasSave = true;
SFileSelectOption& option = x64_fileSelections[i];
option.x2c_ = SFileSelectOption::ComputeRandom();
SFileMenuOption& option = x64_fileSelections[i];
option.x2c_ = SFileMenuOption::ComputeRandom();
option.x28_ = -1;
for (int j=0 ; j<4 ; ++j)
option.x4_textpanes[j].SetPairText(L"");
@ -343,7 +371,7 @@ void CFrontEndUI::SNewFileSelectFrame::SetupFrameContents()
{
for (int i=0 ; i<3 ; ++i)
{
SFileSelectOption& option = x64_fileSelections[i];
SFileMenuOption& option = x64_fileSelections[i];
if (option.x28_ == 4)
continue;
SGuiTextPair* pair = (option.x28_ == -1) ? nullptr : &option.x4_textpanes[option.x28_];
@ -357,23 +385,23 @@ void CFrontEndUI::SNewFileSelectFrame::SetupFrameContents()
void CFrontEndUI::SNewFileSelectFrame::DoPopupCancel(CGuiTableGroup* caller)
{
if (x8_ == 2)
if (x8_subMenu == ESubMenu::Two)
{
CSfxManager::SfxStart(1094, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
x8_ = 1;
x8_subMenu = ESubMenu::One;
x10d_needsExistingToggle = true;
}
else
{
CSfxManager::SfxStart(1094, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
x8_ = 0;
x8_subMenu = ESubMenu::Zero;
x10e_needsNewToggle = true;
}
}
void CFrontEndUI::SNewFileSelectFrame::DoPopupAdvance(CGuiTableGroup* caller)
{
if (x8_ == 2)
if (x8_subMenu == ESubMenu::Two)
{
if (x40_tablegroup_popup->GetUserSelection() == 1)
{
@ -381,7 +409,7 @@ void CFrontEndUI::SNewFileSelectFrame::DoPopupAdvance(CGuiTableGroup* caller)
ResetFrame();
}
else
x8_ = 1;
x8_subMenu = ESubMenu::One;
x10d_needsExistingToggle = true;
}
else
@ -410,9 +438,9 @@ void CFrontEndUI::SNewFileSelectFrame::DoPopupAdvance(CGuiTableGroup* caller)
}
}
void CFrontEndUI::SNewFileSelectFrame::DoFileselectCancel(CGuiTableGroup* caller)
void CFrontEndUI::SNewFileSelectFrame::DoFileMenuCancel(CGuiTableGroup* caller)
{
if (x8_ == 1)
if (x8_subMenu == ESubMenu::One)
{
CSfxManager::SfxStart(1094, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
ResetFrame();
@ -425,14 +453,14 @@ void CFrontEndUI::SNewFileSelectFrame::DoSelectionChange(CGuiTableGroup* caller)
CSfxManager::SfxStart(1093, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
}
void CFrontEndUI::SNewFileSelectFrame::DoFileselectAdvance(CGuiTableGroup* caller)
void CFrontEndUI::SNewFileSelectFrame::DoFileMenuAdvance(CGuiTableGroup* caller)
{
}
CFrontEndUI::SFileSelectOption CFrontEndUI::SNewFileSelectFrame::FindFileSelectOption(CGuiFrame* frame, int idx)
CFrontEndUI::SFileMenuOption CFrontEndUI::SNewFileSelectFrame::FindFileSelectOption(CGuiFrame* frame, int idx)
{
SFileSelectOption ret;
SFileMenuOption ret;
ret.x0_base = frame->FindWidget(hecl::Format("basewidget_file%d", idx).c_str());
ret.x4_textpanes[0] = FindTextPanePair(frame, hecl::Format("textpane_filename%d", idx).c_str());
ret.x4_textpanes[1] = FindTextPanePair(frame, hecl::Format("textpane_world%d", idx).c_str());
@ -459,15 +487,18 @@ void CFrontEndUI::SGBASupportFrame::FinishedLoading()
x28_tablegroup_options = static_cast<CGuiTableGroup*>(x24_loadedFrame->FindWidget("tablegroup_options"));
x2c_tablegroup_fusionsuit = static_cast<CGuiTableGroup*>(x24_loadedFrame->FindWidget("tablegroup_fusionsuit"));
x30_textpane_instructions = FindTextPanePair(x24_loadedFrame, "textpane_instructions");
FindAndSetPairText(x24_loadedFrame, "textpane_nes", g_MainStringTable->GetString(66));
FindAndSetPairText(x24_loadedFrame, "textpane_fusionsuit", g_MainStringTable->GetString(63));
FindAndSetPairText(x24_loadedFrame, "textpane_fusionsuitno", g_MainStringTable->GetString(65));
FindAndSetPairText(x24_loadedFrame, "textpane_fusionsuityes", g_MainStringTable->GetString(64));
FindAndSetPairText(x24_loadedFrame, "textpane_title", g_MainStringTable->GetString(100));
static_cast<CGuiTextPane*>(x24_loadedFrame->FindWidget("textpane_proceed"))->
TextSupport()->SetText(g_MainStringTable->GetString(85));
static_cast<CGuiTextPane*>(x24_loadedFrame->FindWidget("textpane_cancel"))->
TextSupport()->SetText(g_MainStringTable->GetString(82));
x2c_tablegroup_fusionsuit->SetIsActive(false);
x2c_tablegroup_fusionsuit->SetIsVisible(false);
x2c_tablegroup_fusionsuit->SetD1(false);
@ -514,6 +545,11 @@ void CFrontEndUI::SGBASupportFrame::ProcessUserInput(const CFinalInput& input, C
}
void CFrontEndUI::SGBASupportFrame::Draw() const
{
}
void CFrontEndUI::SGBASupportFrame::DoOptionsCancel(CGuiTableGroup* caller)
{
@ -558,9 +594,11 @@ void CFrontEndUI::SFrontEndFrame::FinishedLoading()
x1c_gbaPair.SetPairText(g_MainStringTable->GetString(37));
x24_cheatPair = FindTextPanePair(x14_loadedFrme, "textpane_cheats");
x24_cheatPair.SetPairText(g_MainStringTable->GetString(96));
FindAndSetPairText(x14_loadedFrme, "textpane_start", g_MainStringTable->GetString(67));
FindAndSetPairText(x14_loadedFrme, "textpane_options", g_MainStringTable->GetString(94));
FindAndSetPairText(x14_loadedFrme, "textpane_title", g_MainStringTable->GetString(98));
CGuiTextPane* proceed = static_cast<CGuiTextPane*>(x14_loadedFrme->FindWidget("textpane_proceed"));
if (proceed)
proceed->TextSupport()->SetText(g_MainStringTable->GetString(85));
@ -597,6 +635,11 @@ void CFrontEndUI::SFrontEndFrame::ProcessUserInput(const CFinalInput& input)
}
void CFrontEndUI::SFrontEndFrame::Draw() const
{
}
void CFrontEndUI::SFrontEndFrame::DoCancel(CGuiTableGroup* caller)
{
@ -633,7 +676,7 @@ CFrontEndUI::SFusionBonusFrame::SFusionBonusFrame()
bool CFrontEndUI::SFusionBonusFrame::DoUpdateWithSaveUI(float dt, CSaveUI* saveUi)
{
bool flag = (saveUi && saveUi->x10_ != 16) ? false : true;
bool flag = (saveUi && saveUi->x10_uiType != CSaveUI::UIType::Sixteen) ? false : true;
x10_remTime = std::max(x10_remTime - dt, 0.f);
zeus::CColor geomCol(zeus::CColor::skWhite);
@ -645,12 +688,27 @@ bool CFrontEndUI::SFusionBonusFrame::DoUpdateWithSaveUI(float dt, CSaveUI* saveU
}
}
void CFrontEndUI::SFusionBonusFrame::Draw(CSaveUI* saveUi) const
{
}
CFrontEndUI::SOptionsFrontEndFrame::SOptionsFrontEndFrame()
{
x4_frme = g_SimplePool->GetObj("FRME_OptionsFrontEnd");
x10_pauseScreen = g_SimplePool->GetObj("STRG_PauseScreen");
}
void CFrontEndUI::SOptionsFrontEndFrame::ProcessUserInput(const CFinalInput& input, CSaveUI* sui)
{
}
void CFrontEndUI::SOptionsFrontEndFrame::Draw() const
{
}
CFrontEndUI::CFrontEndUI(CArchitectureQueue& queue)
: CIOWin("FrontEndUI")
{
@ -831,6 +889,88 @@ void CFrontEndUI::HandleDebugMenuReturnValue(CGameDebug::EReturnValue val, CArch
void CFrontEndUI::Draw() const
{
//printf("DRAW\n");
if (x14_phase < EPhase::Four)
return;
if (xec_fusionFrme)
xec_fusionFrme->Draw(xdc_saveUI.get());
else
{
//g_Renderer->SetDepthReadWrite(false, false);
g_Renderer->SetViewportOrtho(false, -4096.f, 4096.f);
if (xcc_curMoviePtr && xcc_curMoviePtr->GetIsFullyCached())
{
auto vidDimensions = xcc_curMoviePtr->GetVideoDimensions();
float aspectRatio = vidDimensions.first / float(vidDimensions.second);
float verticalOff = (CGraphics::g_ViewportResolution.x / aspectRatio - CGraphics::g_ViewportResolution.y) * 0.5f;
xcc_curMoviePtr->SetFrame({0.f, -verticalOff, 0.f},
{CGraphics::g_ViewportResolution.x, verticalOff, 0.f},
{0.f, CGraphics::g_ViewportResolution.y + verticalOff, 0.f},
{CGraphics::g_ViewportResolution.x, CGraphics::g_ViewportResolution.y + verticalOff, 0.f});
xcc_curMoviePtr->DrawFrame();
}
if (x50_curScreen == EScreen::Three && x54_nextScreen == EScreen::Three)
{
if (xf0_optionsFrme)
xf0_optionsFrme->Draw();
else if (xe0_newFileSel)
xe0_newFileSel->Draw();
else
xe8_frontendFrme->Draw();
}
else if (x50_curScreen == EScreen::Four && x54_nextScreen == EScreen::Four)
xe4_gbaSupportFrme->Draw();
if (x64_pressStartAlpha > 0.f && x38_pressStart.IsLoaded() && m_pressStartQuad)
{
float nativeRatio = CGraphics::g_ViewportResolution.x / 640.f;
float hOffset = x38_pressStart->GetWidth() / 2.f * nativeRatio;
float vOffset = x38_pressStart->GetHeight() / 2.f * nativeRatio;
zeus::CRectangle rect(CGraphics::g_ViewportResolutionHalf.x - hOffset, 72.f * nativeRatio - vOffset,
x38_pressStart->GetWidth() * nativeRatio, x38_pressStart->GetHeight() * nativeRatio);
zeus::CColor color = zeus::CColor::skWhite;
color.a = x64_pressStartAlpha;
const_cast<CTexturedQuadFilterAlpha&>(*m_pressStartQuad).draw(color, 1.f, rect);
}
if (xc0_attractCount > 0)
{
if (((x50_curScreen == EScreen::One && x54_nextScreen == EScreen::One) ||
x54_nextScreen == EScreen::Two) && x58_movieSeconds < 1.f)
{
zeus::CColor color = zeus::CColor::skBlack;
color.a = 1.f - x58_movieSeconds;
const_cast<CColoredQuadFilter&>(m_fadeToBlack).draw(color);
}
}
if (xd0_)
{
if (x54_nextScreen == EScreen::One && x50_curScreen == EScreen::Zero)
{
zeus::CColor color = zeus::CColor::skBlack;
color.a = zeus::clamp(0.f, 1.f - x58_movieSeconds, 1.f);
const_cast<CColoredQuadFilter&>(m_fadeToBlack).draw(color);
}
else if (x54_nextScreen == EScreen::One && x50_curScreen == EScreen::One)
{
zeus::CColor color = zeus::CColor::skBlack;
color.a = 1.f - zeus::clamp(0.f, 30.f - x58_movieSeconds, 1.f);
const_cast<CColoredQuadFilter&>(m_fadeToBlack).draw(color);
}
}
if (xdc_saveUI)
{
if ((IsSaveUIConditional() && !xdc_saveUI->IsDrawConditional()) ||
((x50_curScreen == EScreen::Three && x54_nextScreen == EScreen::Three) ||
(x50_curScreen == EScreen::Four && x54_nextScreen == EScreen::Four)))
xdc_saveUI->Draw();
}
}
}
void CFrontEndUI::UpdateMovies(float dt)
@ -851,11 +991,25 @@ void CFrontEndUI::UpdateMovies(float dt)
void CFrontEndUI::FinishedLoadingDepsGroup()
{
const CDependencyGroup* dgrp = x20_depsGroup.GetObj();
x2c_deps.reserve(dgrp->GetObjectTagVector().size());
for (const SObjectTag& tag : dgrp->GetObjectTagVector())
x2c_deps.push_back(g_SimplePool->GetObj(tag));
x44_frontendAudioGrp.Lock();
}
bool CFrontEndUI::PumpLoad()
{
return false;
for (CToken& tok : x2c_deps)
if (!tok.IsLoaded())
return false;
if (!x44_frontendAudioGrp.IsLoaded())
return false;
/* Ready to construct texture quads */
m_pressStartQuad.emplace(CCameraFilterPass::EFilterType::Blend, x38_pressStart);
return true;
}
bool CFrontEndUI::PumpMovieLoad()

View File

@ -10,6 +10,8 @@
#include "zeus/CVector3f.hpp"
#include "Input/CRumbleGenerator.hpp"
#include "GuiSys/CGuiTextSupport.hpp"
#include "Graphics/Shaders/CTexturedQuadFilter.hpp"
#include "Graphics/Shaders/CColoredQuadFilter.hpp"
namespace urde
{
@ -80,7 +82,7 @@ public:
static SGuiTextPair FindTextPanePair(CGuiFrame* frame, const char* name);
static void FindAndSetPairText(CGuiFrame* frame, const char* name, const std::wstring& str);
struct SFileSelectOption
struct SFileMenuOption
{
CGuiWidget* x0_base;
@ -98,6 +100,14 @@ public:
struct SNewFileSelectFrame
{
enum class ESubMenu
{
Zero,
One,
Two,
Three
};
enum class EPhase
{
Zero,
@ -107,7 +117,7 @@ public:
u32 x0_rnd;
CSaveUI* x4_saveUI;
u32 x8_ = 0;
ESubMenu x8_subMenu = ESubMenu::Zero;
EPhase xc_phase = EPhase::Zero;
TLockedToken<CGuiFrame> x10_frme;
CGuiFrame* x1c_loadedFrame = nullptr;
@ -122,7 +132,7 @@ public:
SGuiTextPair x50_textpane_popupcancel;
SGuiTextPair x58_textpane_popupextra;
CGuiTextPane* x60_textpane_cancel = nullptr;
SFileSelectOption x64_fileSelections[3];
SFileMenuOption x64_fileSelections[3];
zeus::CVector3f xf8_model_erase_position;
float x104_rowPitch = 0.f;
float x108_curTime = 0.f;
@ -135,6 +145,7 @@ public:
bool PumpLoad();
bool IsTextDoneAnimating() const;
EPhase ProcessUserInput(const CFinalInput& input);
void Draw() const;
void HandleActiveChange(CGuiTableGroup* active);
void DeactivateExistingGamePopup();
@ -148,11 +159,11 @@ public:
void DoPopupCancel(CGuiTableGroup* caller);
void DoPopupAdvance(CGuiTableGroup* caller);
void DoFileselectCancel(CGuiTableGroup* caller);
void DoFileMenuCancel(CGuiTableGroup* caller);
void DoSelectionChange(CGuiTableGroup* caller);
void DoFileselectAdvance(CGuiTableGroup* caller);
void DoFileMenuAdvance(CGuiTableGroup* caller);
static SFileSelectOption FindFileSelectOption(CGuiFrame* frame, int idx);
static SFileMenuOption FindFileSelectOption(CGuiFrame* frame, int idx);
static void StartTextAnimating(CGuiTextPane* text, const std::wstring& str, float chRate);
};
@ -175,6 +186,7 @@ public:
bool PumpLoad();
void SetTableColors(CGuiTableGroup* tbgp) const;
void ProcessUserInput(const CFinalInput& input, CSaveUI* sui);
void Draw() const;
void DoOptionsCancel(CGuiTableGroup* caller);
void DoSelectionChange(CGuiTableGroup* caller);
@ -193,6 +205,7 @@ public:
void FinishedLoading();
bool PumpLoad();
void ProcessUserInput(const CFinalInput& input);
void Draw() const;
void DoCancel(CGuiTableGroup* caller);
void DoSelectionChange(CGuiTableGroup* caller);
@ -211,6 +224,7 @@ public:
SFusionBonusFrame();
void ProcessUserInput(const CFinalInput& input, CSaveUI* sui);
bool DoUpdateWithSaveUI(float dt, CSaveUI* saveUi);
void Draw(CSaveUI* saveUi) const;
};
struct SOptionsFrontEndFrame
@ -239,13 +253,24 @@ public:
};
SOptionsFrontEndFrame();
void ProcessUserInput(const CFinalInput& input, CSaveUI* sui);
void Draw() const;
};
bool IsSaveUIConditional() const
{
if (x50_curScreen != EScreen::Three && x50_curScreen != EScreen::Four)
return false;
if (x54_nextScreen != EScreen::Three && x54_nextScreen != EScreen::Four)
return false;
return true;
}
private:
EPhase x14_phase = EPhase::Zero;
u32 x18_rndA;
u32 x1c_rndB;
TLockedToken<CDependencyGroup> x20_depsGroup;
std::vector<CToken> x2c_deps;
TLockedToken<CTexture> x38_pressStart;
TLockedToken<CAudioGroupSet> x44_frontendAudioGrp;
EScreen x50_curScreen = EScreen::Zero;
@ -253,7 +278,7 @@ private:
float x58_movieSeconds = 0.f;
bool x5c_movieSecondsNeeded = false;
float x60_ = 0.f;
float x64_ = 0.f;
float x64_pressStartAlpha = 0.f;
float x68_musicVol = 1.f;
u32 x6c_;
std::unique_ptr<CMoviePlayer> x70_menuMovies[9];
@ -275,6 +300,9 @@ private:
std::unique_ptr<SOptionsFrontEndFrame> xf0_optionsFrme;
CStaticAudioPlayer* xf4_curAudio = nullptr;
CColoredQuadFilter m_fadeToBlack = {CCameraFilterPass::EFilterType::Blend};
std::experimental::optional<CTexturedQuadFilterAlpha> m_pressStartQuad;
void SetMovieSecondsDeferred()
{
x58_movieSeconds = 1000000.f;

View File

@ -214,7 +214,7 @@ private:
bool x160_28_ : 1;
bool x160_29_ : 1;
bool x160_30_ : 1;
bool x160_31_ : 1;
bool x160_31_cardInserted : 1;
bool x161_24_ : 1;
};
u16 _dummy = 0;
@ -251,6 +251,7 @@ public:
void ShutdownSubsystems() {}
EGameplayResult GetGameplayResult() const {return xe4_gameplayResult;}
void SetGameplayResult(EGameplayResult wl) {xe4_gameplayResult = wl;}
void SetCardInserted(bool v) {x160_31_cardInserted = v;}
EFlowState GetFlowState() const { return x12c_flowState; }
};