Get MP1 Trilogy loading, implement version difference in CGuiTextPane, harden FrontEnd for Trilogy missing files

This commit is contained in:
Phillip Stephens 2022-02-23 00:18:50 -08:00
parent 0108ae12b5
commit 1685489303
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
10 changed files with 84 additions and 57 deletions

View File

@ -163,13 +163,13 @@ void CGuiFrame::Initialize() {
xc_headWidget->DispatchInitialize();
}
void CGuiFrame::LoadWidgetsInGame(CInputStream& in, CSimplePool* sp) {
void CGuiFrame::LoadWidgetsInGame(CInputStream& in, CSimplePool* sp, u32 version) {
u32 count = in.ReadLong();
x2c_widgets.reserve(count);
for (u32 i = 0; i < count; ++i) {
FourCC type;
in.Get(reinterpret_cast<u8*>(&type), 4);
std::shared_ptr<CGuiWidget> widget = CGuiSys::CreateWidgetInGame(type.toUint32(), in, this, sp);
std::shared_ptr<CGuiWidget> widget = CGuiSys::CreateWidgetInGame(type.toUint32(), in, this, sp, version);
switch (widget->GetWidgetTypeID().toUint32()) {
case SBIG('CAMR'):
case SBIG('LITE'):
@ -263,13 +263,13 @@ void CGuiFrame::ResetMouseState() {
}
std::unique_ptr<CGuiFrame> CGuiFrame::CreateFrame(CAssetId frmeId, CGuiSys& sys, CInputStream& in, CSimplePool* sp) {
in.ReadLong();
u32 version = in.ReadLong();
int a = in.ReadLong();
int b = in.ReadLong();
int c = in.ReadLong();
std::unique_ptr<CGuiFrame> ret = std::make_unique<CGuiFrame>(frmeId, sys, a, b, c, sp);
ret->LoadWidgetsInGame(in, sp);
ret->LoadWidgetsInGame(in, sp, version);
return ret;
}

View File

@ -94,7 +94,7 @@ public:
void Draw(const CGuiWidgetDrawParms& parms) const;
CGuiWidget* BestCursorHit(const zeus::CVector2f& point, const CGuiWidgetDrawParms& parms) const;
void Initialize();
void LoadWidgetsInGame(CInputStream& in, CSimplePool* sp);
void LoadWidgetsInGame(CInputStream& in, CSimplePool* sp, u32 version);
void ProcessUserInput(const CFinalInput& input) const;
bool ProcessMouseInput(const CFinalInput& input, const CGuiWidgetDrawParms& parms);
void ResetMouseState();

View File

@ -25,7 +25,7 @@ CTextExecuteBuffer* g_TextExecuteBuf = nullptr;
CTextParser* g_TextParser = nullptr;
std::shared_ptr<CGuiWidget> CGuiSys::CreateWidgetInGame(FourCC type, CInputStream& in, CGuiFrame* frame,
CSimplePool* sp) {
CSimplePool* sp, u32 version) {
switch (type.toUint32()) {
case SBIG('BWIG'):
return CGuiWidget::Create(frame, in, sp);
@ -50,7 +50,7 @@ std::shared_ptr<CGuiWidget> CGuiSys::CreateWidgetInGame(FourCC type, CInputStrea
case SBIG('SLGP'):
return CGuiSliderGroup::Create(frame, in, sp);
case SBIG('TXPN'):
return CGuiTextPane::Create(frame, in, sp);
return CGuiTextPane::Create(frame, in, sp, version);
case SBIG('ENRG'):
return CAuiEnergyBarT01::Create(frame, in, sp);
default:

View File

@ -34,7 +34,7 @@ private:
std::unordered_set<CGuiFrame*> m_registeredFrames;
static std::shared_ptr<CGuiWidget> CreateWidgetInGame(FourCC type, CInputStream& in, CGuiFrame* frame,
CSimplePool* sp);
CSimplePool* sp, u32 version);
public:
CGuiSys(IFactory& resFactory, CSimplePool& resStore, EUsageMode mode);

View File

@ -26,7 +26,8 @@ bool testProjectedLine(const zeus::CVector2f& a, const zeus::CVector2f& b, const
bool CGuiTextPane::sDrawPaneRects = true;
CGuiTextPane::CGuiTextPane(const CGuiWidgetParms& parms, CSimplePool* sp, const zeus::CVector2f& dim,
const zeus::CVector3f& vec, CAssetId fontId, const CGuiTextProperties& props,
const zeus::CColor& fontCol, const zeus::CColor& outlineCol, s32 extentX, s32 extentY)
const zeus::CColor& fontCol, const zeus::CColor& outlineCol, s32 extentX, s32 extentY,
CAssetId jpFontId, s32 jpExtentX, s32 jpExtentY)
: CGuiPane(parms, dim, vec)
, xd4_textSupport(fontId, props, fontCol, outlineCol, zeus::skWhite, extentX, extentY, sp, xac_drawFlags) {}
@ -133,7 +134,7 @@ bool CGuiTextPane::TestCursorHit(const zeus::CMatrix4f& vp, const zeus::CVector2
return j == 3 && testProjectedLine(projPoints[3], projPoints[0], point);
}
std::shared_ptr<CGuiWidget> CGuiTextPane::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp) {
std::shared_ptr<CGuiWidget> CGuiTextPane::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp, u32 version) {
const CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
const zeus::CVector2f dim = in.Get<zeus::CVector2f>();
const zeus::CVector3f vec = in.Get<zeus::CVector3f>();
@ -147,7 +148,16 @@ std::shared_ptr<CGuiWidget> CGuiTextPane::Create(CGuiFrame* frame, CInputStream&
const zeus::CColor outlineCol = in.Get<zeus::CColor>();
const int extentX = static_cast<int>(in.ReadFloat());
const int extentY = static_cast<int>(in.ReadFloat());
auto ret = std::make_shared<CGuiTextPane>(parms, sp, dim, vec, fontId, props, fontCol, outlineCol, extentX, extentY);
int jpExtentX = extentX;
int jpExtentY = extentY;
CAssetId jpFontId = fontId;
if (version != 0) {
jpFontId = in.Get<CAssetId>();
jpExtentX = in.ReadLong();
jpExtentY = in.ReadLong();
}
auto ret = std::make_shared<CGuiTextPane>(parms, sp, dim, vec, fontId, props, fontCol, outlineCol, extentX, extentY,
jpFontId, jpExtentY, jpExtentY);
ret->ParseBaseInfo(frame, in, parms);
ret->InitializeBuffers();
ret->TextSupport().SetText(u"");

View File

@ -15,7 +15,7 @@ class CGuiTextPane : public CGuiPane {
public:
CGuiTextPane(const CGuiWidgetParms& parms, CSimplePool* sp, const zeus::CVector2f& dim, const zeus::CVector3f& vec,
CAssetId fontId, const CGuiTextProperties& props, const zeus::CColor& col1, const zeus::CColor& col2,
s32 padX, s32 padY);
s32 padX, s32 padY, CAssetId jpFontId, s32 jpExtentX, s32 jpExtentY);
FourCC GetWidgetTypeID() const override { return FOURCC('TXPN'); }
CGuiTextSupport& TextSupport() { return xd4_textSupport; }
@ -28,7 +28,7 @@ public:
void Draw(const CGuiWidgetDrawParms& parms) override;
bool TestCursorHit(const zeus::CMatrix4f& vp, const zeus::CVector2f& point) const override;
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp, u32 version);
};
} // namespace metaforce

View File

@ -713,10 +713,12 @@ void CFrontEndUI::SNewFileSelectFrame::StartTextAnimating(CGuiTextPane* text, st
}
CFrontEndUI::SFusionBonusFrame::SFusionBonusFrame(CFrontEndUITouchBar& touchBar) : m_touchBar(touchBar) {
if (!g_Main->IsTrilogy()) {
x4_gbaSupport = std::make_unique<CGBASupport>();
xc_gbaScreen = g_SimplePool->GetObj("FRME_GBAScreen");
x18_gbaLink = g_SimplePool->GetObj("FRME_GBALink");
}
}
void CFrontEndUI::SFusionBonusFrame::SGBALinkFrame::SetUIText(EUIType tp) {
int instructions = -1;
@ -1871,7 +1873,7 @@ void CFrontEndUI::SetCurrentMovie(EMenuMovie movie) {
}
StopAttractMovie();
if (!g_Main->IsTrilogy()) {
if (xb8_curMovie != EMenuMovie::Stopped) {
xcc_curMoviePtr->SetPlayMode(CMoviePlayer::EPlayMode::Stopped);
xcc_curMoviePtr->Rewind();
@ -1886,6 +1888,7 @@ void CFrontEndUI::SetCurrentMovie(EMenuMovie movie) {
xcc_curMoviePtr = nullptr;
}
}
}
void CFrontEndUI::StopAttractMovie() {
if (!xc4_attractMovie)
@ -1908,15 +1911,15 @@ void CFrontEndUI::StartStateTransition(EScreen screen) {
if (screen != EScreen::FileSelect)
break;
SetCurrentMovie(EMenuMovie::StartFileSelectA);
SetFadeBlackTimer(xcc_curMoviePtr->GetTotalSeconds());
SetFadeBlackTimer(!g_Main->IsTrilogy() ? xcc_curMoviePtr->GetTotalSeconds() : 5);
break;
case EScreen::FileSelect:
if (screen == EScreen::ToPlayGame) {
SetCurrentMovie(EMenuMovie::FileSelectPlayGameA);
SetFadeBlackTimer(xcc_curMoviePtr->GetTotalSeconds());
SetFadeBlackTimer(!g_Main->IsTrilogy() ? xcc_curMoviePtr->GetTotalSeconds() : 5);
} else if (screen == EScreen::FusionBonus) {
SetCurrentMovie(EMenuMovie::FileSelectGBA);
SetFadeBlackTimer(xcc_curMoviePtr->GetTotalSeconds());
SetFadeBlackTimer(!g_Main->IsTrilogy() ? xcc_curMoviePtr->GetTotalSeconds() : 5);
CSfxManager::SfxStart(SFXfnt_tofusion_L, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
CSfxManager::SfxStart(SFXfnt_tofusion_R, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
}
@ -1924,10 +1927,10 @@ void CFrontEndUI::StartStateTransition(EScreen screen) {
case EScreen::FusionBonus:
if (screen == EScreen::ToPlayGame) {
SetCurrentMovie(EMenuMovie::GBAFileSelectB);
SetFadeBlackTimer(xcc_curMoviePtr->GetTotalSeconds());
SetFadeBlackTimer(!g_Main->IsTrilogy() ? xcc_curMoviePtr->GetTotalSeconds() : 5);
} else if (screen == EScreen::FileSelect) {
SetCurrentMovie(EMenuMovie::GBAFileSelectA);
SetFadeBlackTimer(xcc_curMoviePtr->GetTotalSeconds());
SetFadeBlackTimer(!g_Main->IsTrilogy() ? xcc_curMoviePtr->GetTotalSeconds() : 5);
CSfxManager::SfxStart(SFXfnt_fromfusion_L, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
CSfxManager::SfxStart(SFXfnt_fromfusion_R, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
}
@ -1940,7 +1943,7 @@ void CFrontEndUI::StartStateTransition(EScreen screen) {
case EScreen::OpenCredits:
case EScreen::Title:
SetCurrentMovie(EMenuMovie::FirstStart);
SetFadeBlackTimer(xcc_curMoviePtr->GetTotalSeconds());
SetFadeBlackTimer(!g_Main->IsTrilogy() ? xcc_curMoviePtr->GetTotalSeconds() : 5);
break;
case EScreen::AttractMovie:
StartAttractMovie();
@ -2136,6 +2139,9 @@ bool CFrontEndUI::PumpMovieLoad() {
if (xd1_moviesLoaded) {
return true;
}
if (g_Main->IsTrilogy()) {
return true;
}
for (size_t i = 0; i < x70_menuMovies.size(); ++i) {
if (x70_menuMovies[i] != nullptr) {
@ -2156,8 +2162,10 @@ bool CFrontEndUI::PumpMovieLoad() {
}
}
if (CDvdFile::FileExists(path)) {
x70_menuMovies[i] = std::make_unique<CMoviePlayer>(path.c_str(), 0.05f, movie.loop, false);
x70_menuMovies[i]->SetPlayMode(CMoviePlayer::EPlayMode::Stopped);
}
return false;
}
@ -2348,7 +2356,9 @@ CIOWin::EMessageReturn CFrontEndUI::Update(float dt, CArchitectureQueue& queue)
/* Poll loading DGRP resources */
if (PumpLoad()) {
xe0_frontendCardFrme = std::make_unique<SNewFileSelectFrame>(xdc_saveUI.get(), x1c_rndB, *m_touchBar);
if (!g_Main->IsTrilogy()) {
xe4_fusionBonusFrme = std::make_unique<SFusionBonusFrame>(*m_touchBar);
}
xe8_frontendNoCardFrme = std::make_unique<SFrontEndFrame>(x1c_rndB, *m_touchBar);
x38_pressStart.GetObj();
CAudioSys::AddAudioGroup(x44_frontendAudioGrp->GetAudioGroupData());
@ -2361,9 +2371,12 @@ CIOWin::EMessageReturn CFrontEndUI::Update(float dt, CArchitectureQueue& queue)
[[fallthrough]];
case EPhase::LoadFrames:
if (!g_Main->IsTrilogy() && !xe4_fusionBonusFrme->PumpLoad()) {
return EMessageReturn::Exit;
}
/* Poll loading music and FRME resources */
if (!xd4_audio1->IsReady() || !xd8_audio2->IsReady() || !xe0_frontendCardFrme->PumpLoad() ||
!xe4_fusionBonusFrme->PumpLoad() || !xe8_frontendNoCardFrme->PumpLoad() || !xdc_saveUI->PumpLoad())
!xe8_frontendNoCardFrme->PumpLoad() || !xdc_saveUI->PumpLoad())
return EMessageReturn::Exit;
xf4_curAudio = xd4_audio1.get();
xf4_curAudio->StartMixing();
@ -2377,8 +2390,12 @@ CIOWin::EMessageReturn CFrontEndUI::Update(float dt, CArchitectureQueue& queue)
/* Prime first frame of movies */
UpdateMovies(dt);
if (!g_Main->IsTrilogy()) {
moviesReady = std::all_of(x70_menuMovies.cbegin(), x70_menuMovies.cend(),
[](const auto& movie) { return movie->GetIsFullyCached(); });
} else {
moviesReady = true;
}
} else {
moviesReady = false;
}
@ -2487,15 +2504,23 @@ CIOWin::EMessageReturn CFrontEndUI::Update(float dt, CArchitectureQueue& queue)
if (x50_curScreen == EScreen::Title && x54_nextScreen == EScreen::FileSelect) {
/* Fade out title music */
if (!g_Main->IsTrilogy()) {
x68_musicVol =
1.f - zeus::clamp(0.f, (xcc_curMoviePtr->GetPlayedSeconds() - AudioFadeTimeA[x18_rndA]) / 2.5f, 1.f);
} else {
x68_musicVol -= dt;
}
} else if (x54_nextScreen == EScreen::ToPlayGame) {
/* Fade out menu music */
if (!g_Main->IsTrilogy()) {
float delay = AudioFadeTimeB[x1c_rndB];
x68_musicVol =
1.f -
zeus::clamp(0.f, (xcc_curMoviePtr->GetPlayedSeconds() - delay) / (xcc_curMoviePtr->GetTotalSeconds() - delay),
1.f);
zeus::clamp(
0.f, (xcc_curMoviePtr->GetPlayedSeconds() - delay) / (xcc_curMoviePtr->GetTotalSeconds() - delay), 1.f);
} else {
x68_musicVol -= dt;
}
} else {
/* Full music volume */
x68_musicVol = 1.f;

View File

@ -68,7 +68,7 @@ void CTweaks::RegisterTweaks(CVarManager* cvarMgr) {
u8* Args = g_ResFactory->LoadResourceSync(*tag).release();
u32 size = g_ResFactory->ResourceSize(*tag);
strm.emplace(Args, size, CMemoryInStream::EOwnerShip::Owned);
g_tweakTargeting = new MP1::CTweakTargeting(*strm, g_Main->IsTrilogy() || g_Main->IsPAL() || g_Main->IsJapanese());
g_tweakTargeting = new MP1::CTweakTargeting(*strm);
g_tweakTargeting->initCVars(cvarMgr);
/* Game */
tag = g_ResFactory->GetResourceIdByName("Game");

View File

@ -2,7 +2,7 @@
#include "Runtime/Streams/IOStreams.hpp"
namespace metaforce::MP1 {
CTweakTargeting::CTweakTargeting(CInputStream& in, bool hasNewFields) {
CTweakTargeting::CTweakTargeting(CInputStream& in) {
x4_targetRadiusMode = in.ReadLong();
x8_currLockOnExitDuration = in.ReadFloat();
xc_currLockOnEnterDuration = in.ReadFloat();
@ -127,11 +127,6 @@ CTweakTargeting::CTweakTargeting(CInputStream& in, bool hasNewFields) {
x220_scanTargetClampMax = in.ReadFloat();
x224_angularLagSpeed = in.ReadFloat();
if (hasNewFields) {
x218_ = in.ReadFloat();
x21c_ = in.ReadFloat();
}
x124_chargeTickAnglePitch = -zeus::degToRad(x124_chargeTickAnglePitch);
x140_lockDaggerAngle0 = zeus::degToRad(x140_lockDaggerAngle0);
x144_lockDaggerAngle1 = zeus::degToRad(x144_lockDaggerAngle1);

View File

@ -125,9 +125,6 @@ struct CTweakTargeting final : public Tweaks::ITweakTargeting {
float x220_scanTargetClampMax{};
float x224_angularLagSpeed{};
// RS5
float x218_{};
float x21c_{};
bool x224_ = true;
bool x225_ = false;
bool x226_ = true;
@ -189,7 +186,7 @@ struct CTweakTargeting final : public Tweaks::ITweakTargeting {
zeus::CColor x380_ = static_cast<zeus::Comp32>(0xff6b60ff);
CTweakTargeting() = default;
CTweakTargeting(CInputStream& r, bool hasNewFields);
CTweakTargeting(CInputStream& r);
u32 GetTargetRadiusMode() const override { return x4_targetRadiusMode; }
float GetCurrLockOnExitDuration() const override { return x8_currLockOnExitDuration; }
float GetCurrLockOnEnterDuration() const override { return xc_currLockOnEnterDuration; }