diff --git a/Runtime/CGameState.cpp b/Runtime/CGameState.cpp index 0cc358e84..148faac8a 100644 --- a/Runtime/CGameState.cpp +++ b/Runtime/CGameState.cpp @@ -23,7 +23,7 @@ union BitsToDouble { double doub; }; -CWorldLayerState::CWorldLayerState(CBitStreamReader& reader, const CSaveWorld& saveWorld) { +CScriptLayerManager::CScriptLayerManager(CBitStreamReader& reader, const CSaveWorld& saveWorld) { const u32 bitCount = reader.ReadEncoded(10); x10_saveLayers.reserve(bitCount); @@ -37,7 +37,7 @@ CWorldLayerState::CWorldLayerState(CBitStreamReader& reader, const CSaveWorld& s } } -void CWorldLayerState::PutTo(CBitStreamWriter& writer) const { +void CScriptLayerManager::PutTo(CBitStreamWriter& writer) const { u32 totalLayerCount = 0; for (size_t i = 0; i < x0_areaLayers.size(); ++i) { totalLayerCount += GetAreaLayerCount(s32(i)) - 1; @@ -53,7 +53,7 @@ void CWorldLayerState::PutTo(CBitStreamWriter& writer) const { } } -void CWorldLayerState::InitializeWorldLayers(const std::vector& layers) { +void CScriptLayerManager::InitializeWorldLayers(const std::vector& layers) { if (!x0_areaLayers.empty()) { return; } @@ -75,24 +75,24 @@ void CWorldLayerState::InitializeWorldLayers(const std::vector(); + x8_mailbox = std::make_shared(); xc_mapWorldInfo = std::make_shared(); x10_desiredAreaAssetId = {}; - x14_layerState = std::make_shared(); + x14_layerState = std::make_shared(); } CWorldState::CWorldState(CBitStreamReader& reader, CAssetId mlvlId, const CSaveWorld& saveWorld) : x0_mlvlId(mlvlId) { x4_areaId = TAreaId(reader.ReadEncoded(32)); x10_desiredAreaAssetId = u32(reader.ReadEncoded(32)); - x8_relayTracker = std::make_shared(reader, saveWorld); + x8_mailbox = std::make_shared(reader, saveWorld); xc_mapWorldInfo = std::make_shared(reader, saveWorld, mlvlId); - x14_layerState = std::make_shared(reader, saveWorld); + x14_layerState = std::make_shared(reader, saveWorld); } void CWorldState::PutTo(CBitStreamWriter& writer, const CSaveWorld& savw) const { writer.WriteEncoded(x4_areaId, 32); writer.WriteEncoded(u32(x10_desiredAreaAssetId.Value()), 32); - x8_relayTracker->PutTo(writer, savw); + x8_mailbox->PutTo(writer, savw); xc_mapWorldInfo->PutTo(writer, savw, x0_mlvlId); x14_layerState->PutTo(writer); } diff --git a/Runtime/CGameState.hpp b/Runtime/CGameState.hpp index 0cacfeaac..6b4b74d28 100644 --- a/Runtime/CGameState.hpp +++ b/Runtime/CGameState.hpp @@ -17,14 +17,14 @@ namespace metaforce { class CSaveWorldMemory; -class CWorldLayerState { +class CScriptLayerManager { friend class CSaveWorldIntermediate; std::vector x0_areaLayers; DataSpec::WordBitmap x10_saveLayers; public: - CWorldLayerState() = default; - CWorldLayerState(CBitStreamReader& reader, const CSaveWorld& saveWorld); + CScriptLayerManager() = default; + CScriptLayerManager(CBitStreamReader& reader, const CSaveWorld& saveWorld); bool IsLayerActive(int areaIdx, int layerIdx) const { return ((x0_areaLayers[areaIdx].m_layerBits >> layerIdx) & 1); } @@ -46,10 +46,10 @@ public: class CWorldState { CAssetId x0_mlvlId; TAreaId x4_areaId = kInvalidAreaId; - std::shared_ptr x8_relayTracker; + std::shared_ptr x8_mailbox; std::shared_ptr xc_mapWorldInfo; CAssetId x10_desiredAreaAssetId; - std::shared_ptr x14_layerState; + std::shared_ptr x14_layerState; public: explicit CWorldState(CAssetId id); @@ -59,9 +59,9 @@ public: TAreaId GetCurrentAreaId() const { return x4_areaId; } CAssetId GetDesiredAreaAssetId() const { return x10_desiredAreaAssetId; } void SetDesiredAreaAssetId(CAssetId id) { x10_desiredAreaAssetId = id; } - const std::shared_ptr& RelayTracker() const { return x8_relayTracker; } + const std::shared_ptr& Mailbox() const { return x8_mailbox; } const std::shared_ptr& MapWorldInfo() const { return xc_mapWorldInfo; } - const std::shared_ptr& GetLayerState() const { return x14_layerState; } + const std::shared_ptr& GetLayerState() const { return x14_layerState; } void PutTo(CBitStreamWriter& writer, const CSaveWorld& savw) const; }; diff --git a/Runtime/CPlayMovieBase.hpp b/Runtime/CPlayMovieBase.hpp deleted file mode 100644 index 3f7014199..000000000 --- a/Runtime/CPlayMovieBase.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Runtime/CIOWin.hpp" -#include "Runtime/Graphics/CMoviePlayer.hpp" - -namespace metaforce { - -class CPlayMovieBase : public CIOWin { - CMoviePlayer x18_moviePlayer; - -public: - CPlayMovieBase(const char* iowName, const char* path) : CIOWin(iowName), x18_moviePlayer(path, 0.0, false, false) {} - EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&) override { return EMessageReturn::Normal; } - void Draw() override {} -}; - -} // namespace metaforce diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index ae4c7c280..605fe1e46 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -62,12 +62,12 @@ hecl::CVar* debugToolDrawPlatformCollision = nullptr; hecl::CVar* sm_logScripting = nullptr; } // namespace logvisor::Module LogModule("metaforce::CStateManager"); -CStateManager::CStateManager(const std::weak_ptr& relayTracker, +CStateManager::CStateManager(const std::weak_ptr& mailbox, const std::weak_ptr& mwInfo, const std::weak_ptr& playerState, const std::weak_ptr& wtMgr, - const std::weak_ptr& layerState) + const std::weak_ptr& layerState) : x8b8_playerState(playerState) -, x8bc_relayTracker(relayTracker) +, x8bc_mailbox(mailbox) , x8c0_mapWorldInfo(mwInfo) , x8c4_worldTransManager(wtMgr) , x8c8_worldLayerState(layerState) { @@ -2677,7 +2677,7 @@ void CStateManager::PrepareAreaUnload(TAreaId aid) { } void CStateManager::AreaLoaded(TAreaId aid) { - x8bc_relayTracker->SendMsgs(aid, *this); + x8bc_mailbox->SendMsgs(aid, *this); x880_envFxManager->AreaLoaded(); } diff --git a/Runtime/CStateManager.hpp b/Runtime/CStateManager.hpp index a78caa9ed..1fb1c9f8b 100644 --- a/Runtime/CStateManager.hpp +++ b/Runtime/CStateManager.hpp @@ -52,7 +52,7 @@ class CRumbleManager; class CSortedListManager; class CTexture; class CWorld; -class CWorldLayerState; +class CScriptLayerManager; class CWorldTransManager; struct CFinalInput; @@ -140,10 +140,10 @@ private: std::map x8a4_loadedScriptObjects; std::shared_ptr x8b8_playerState; - std::shared_ptr x8bc_relayTracker; + std::shared_ptr x8bc_mailbox; std::shared_ptr x8c0_mapWorldInfo; std::shared_ptr x8c4_worldTransManager; - std::shared_ptr x8c8_worldLayerState; + std::shared_ptr x8c8_worldLayerState; TAreaId x8cc_nextAreaId = 0; TAreaId x8d0_prevAreaId = kInvalidAreaId; @@ -222,7 +222,7 @@ private: public: CStateManager(const std::weak_ptr&, const std::weak_ptr&, const std::weak_ptr&, const std::weak_ptr&, - const std::weak_ptr&); + const std::weak_ptr&); ~CStateManager(); u32 GetInputFrameIdx() const { return x8d4_inputFrameIdx; } @@ -396,16 +396,16 @@ public: const CEnvFxManager* GetEnvFxManager() const { return x880_envFxManager; } CWorld* GetWorld() { return x850_world.get(); } const CWorld* GetWorld() const { return x850_world.get(); } - CScriptMailbox* GetRelayTracker() { return x8bc_relayTracker.get(); } - const CScriptMailbox* GetRelayTracker() const { return x8bc_relayTracker.get(); } + CScriptMailbox* GetMailbox() { return x8bc_mailbox.get(); } + const CScriptMailbox* GetRelayTracker() const { return x8bc_mailbox.get(); } CCameraManager* GetCameraManager() const { return x870_cameraManager; } CFluidPlaneManager* GetFluidPlaneManager() const { return x87c_fluidPlaneManager; } CActorModelParticles* GetActorModelParticles() const { return x884_actorModelParticles; } const std::shared_ptr& MapWorldInfo() const { return x8c0_mapWorldInfo; } const std::shared_ptr& WorldTransManager() const { return x8c4_worldTransManager; } - const std::shared_ptr& WorldLayerState() const { return x8c8_worldLayerState; } - std::shared_ptr& WorldLayerState() { return x8c8_worldLayerState; } + const std::shared_ptr& WorldLayerState() const { return x8c8_worldLayerState; } + std::shared_ptr& WorldLayerState() { return x8c8_worldLayerState; } CPlayer& GetPlayer() const { return *x84c_player; } CPlayer* Player() const { return x84c_player.get(); } diff --git a/Runtime/MP1/CCredits.cpp b/Runtime/MP1/CCredits.cpp index b5207f13d..3eb25e9e7 100644 --- a/Runtime/MP1/CCredits.cpp +++ b/Runtime/MP1/CCredits.cpp @@ -65,7 +65,6 @@ CIOWin::EMessageReturn CCredits::Update(float dt, CArchitectureQueue& queue) { CGuiWidget::EGuiModelDrawFlags::Alpha), zeus::CVector2i(0, 0)); x30_text.back().first->SetText(x18_creditsTable->GetString(i)); - x30_text.back().first->SetOutlineColor(g_tweakGui->GetCreditsTextBorderColor()); } // auto tmp = std::make_pair(std::make_unique( @@ -103,7 +102,7 @@ CIOWin::EMessageReturn CCredits::Update(float dt, CArchitectureQueue& queue) { scaleY += (bounds.second.y - bounds.first.y); } - x4c_ = float(scaleY + g_Viewport.xc_height); // * 0.5f; + x4c_ = float(scaleY + g_Viewport.xc_height - 896); // * 0.5f; const float divVal = std::max(g_tweakGui->x310_, g_tweakGui->x30c_); x50_ = x4c_ / (g_tweakGui->x308_ - divVal); x14_ = 1; @@ -159,13 +158,13 @@ CIOWin::EMessageReturn CCredits::Update(float dt, CArchitectureQueue& queue) { } x48_ = std::min(x4c_, (dt * x50_) + x48_); - if (x48_ >= x4c_ || x5c_24_) { + if (x48_ == x4c_ || x5c_24_) { x5c_24_ = true; x54_ = std::max(0.f, x54_ - dt); const float alpha = x54_ / g_tweakGui->x30c_; for (const auto& [text, offset] : x30_text) { zeus::CColor col = zeus::skWhite; - col.a() = alpha; + col.a() *= alpha; text->SetGeometryColor(col); } if (x54_ <= 0.f) { diff --git a/Runtime/MP1/CMFGame.cpp b/Runtime/MP1/CMFGame.cpp index a690ad0d7..e966ca60e 100644 --- a/Runtime/MP1/CMFGame.cpp +++ b/Runtime/MP1/CMFGame.cpp @@ -329,7 +329,7 @@ CIOWin::EMessageReturn CMFGameLoader::OnMessage(const CArchitectureMessage& msg, if (!x14_stateMgr) { CWorldTransManager::WaitForModelsAndTextures(); CWorldState& wldState = g_GameState->CurrentWorldState(); - x14_stateMgr = std::make_shared(wldState.RelayTracker(), wldState.MapWorldInfo(), + x14_stateMgr = std::make_shared(wldState.Mailbox(), wldState.MapWorldInfo(), g_GameState->GetPlayerState(), wtMgr, wldState.GetLayerState()); } diff --git a/Runtime/MP1/CPlayMovie.cpp b/Runtime/MP1/CPlayMovie.cpp index 2405b6762..e71cfe1f1 100644 --- a/Runtime/MP1/CPlayMovie.cpp +++ b/Runtime/MP1/CPlayMovie.cpp @@ -2,14 +2,35 @@ namespace metaforce::MP1 { -const char* kMovies[] = {"Video/wingame.thp", "Video/wingame_best.thp", "Video/wingame_best.thp", +const char* kMovies[] = {"Video/wingame.thp", "Video/wingame_good.thp", "Video/wingame_best.thp", "Video/losegame.thp", "Video/05_tallonText.thp", "Video/AfterCredits.thp", "Video/SpecialEnding.thp", "Video/creditBG.thp"}; bool CPlayMovie::IsResultsScreen(EWhichMovie which) { return int(which) <= 2; } -CPlayMovie::CPlayMovie(EWhichMovie which) : CPlayMovieBase("CPlayMovie", kMovies[int(which)]), x18_which(which) { - (void)x18_which; +CPlayMovie::CPlayMovie(EWhichMovie which) : CIOWin("CPlayMovie"), x18_which(which) {} + +CIOWin::EMessageReturn CPlayMovie::OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue) { + return EMessageReturn::RemoveIOWinAndExit; +} +void CPlayMovie::Draw() { + if (x14_ != 3) { + return; + } + + DrawVideo(); + if (x78_27_) { + x40_quitScreen->Draw(); + } else if (x78_26_resultsScreen) { + DrawText(); + } +} + +void CPlayMovie::DrawVideo() { + +} +void CPlayMovie::DrawText() { + } } // namespace metaforce::MP1 diff --git a/Runtime/MP1/CPlayMovie.hpp b/Runtime/MP1/CPlayMovie.hpp index f83430333..ee48af20e 100644 --- a/Runtime/MP1/CPlayMovie.hpp +++ b/Runtime/MP1/CPlayMovie.hpp @@ -1,25 +1,30 @@ #pragma once -#include "Runtime/CPlayMovieBase.hpp" +#include "Runtime/CIOWin.hpp" +#include "Runtime/Graphics/CMoviePlayer.hpp" #include "Runtime/RetroTypes.hpp" +#include "Runtime/MP1/CQuitGameScreen.hpp" namespace metaforce::MP1 { -class CPlayMovie : public CPlayMovieBase { +class CPlayMovie : public CIOWin { public: enum class EWhichMovie { WinGameBad, WinGameGood, WinGameBest, LoseGame, - TalonTest, + TalonText, AfterCredits, SpecialEnding, CreditBG }; private: + s32 x14_ = 0; EWhichMovie x18_which; + std::unique_ptr x38_moviePlayer; + std::unique_ptr x40_quitScreen; bool x78_24_ : 1 = false; bool x78_25_ : 1 = false; bool x78_26_resultsScreen : 1 = false; @@ -27,8 +32,13 @@ private: static bool IsResultsScreen(EWhichMovie which); + void DrawVideo(); + void DrawText(); public: explicit CPlayMovie(EWhichMovie which); + EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&) override; + void Draw() override; + bool GetIsContinueDraw() const override { return false; } }; } // namespace metaforce::MP1 diff --git a/Runtime/MP1/CStateSetterFlow.cpp b/Runtime/MP1/CStateSetterFlow.cpp index 75a6a308d..857bb52de 100644 --- a/Runtime/MP1/CStateSetterFlow.cpp +++ b/Runtime/MP1/CStateSetterFlow.cpp @@ -27,14 +27,14 @@ CIOWin::EMessageReturn CStateSetterFlow::OnMessage(const CArchitectureMessage& m g_GameState->SetCurrentWorldId(worldId); CWorldState& ws = g_GameState->StateForWorld(worldId); - CWorldLayerState& layers = *ws.GetLayerState(); + CScriptLayerManager& layers = *ws.GetLayerState(); if (m->m_warpAreaId < layers.GetAreaCount()) { ws.SetAreaId(m->m_warpAreaId); if (m->m_warpLayerBits) { for (u32 i = 0; i < layers.GetAreaLayerCount(m->m_warpAreaId); ++i) layers.SetLayerActive(m->m_warpAreaId, i, ((m->m_warpLayerBits >> i) & 1) != 0); } - CScriptMailbox& relays = *ws.RelayTracker(); + CScriptMailbox& relays = *ws.Mailbox(); for (const auto& r : m->m_warpMemoryRelays) relays.AddMsg(r); } diff --git a/Runtime/World/CGameArea.cpp b/Runtime/World/CGameArea.cpp index 5c0f7b220..761dd20bc 100644 --- a/Runtime/World/CGameArea.cpp +++ b/Runtime/World/CGameArea.cpp @@ -894,7 +894,7 @@ void CGameArea::Validate(CStateManager& mgr) { } void CGameArea::LoadScriptObjects(CStateManager& mgr) { - CWorldLayerState& layerState = *mgr.WorldLayerState(); + CScriptLayerManager& layerState = *mgr.WorldLayerState(); u32 layerCount = layerState.GetAreaLayerCount(x4_selfIdx); std::vector objIds; for (u32 i = 0; i < layerCount; ++i) { diff --git a/Runtime/World/CScriptMemoryRelay.cpp b/Runtime/World/CScriptMemoryRelay.cpp index 5848962f2..523c99cad 100644 --- a/Runtime/World/CScriptMemoryRelay.cpp +++ b/Runtime/World/CScriptMemoryRelay.cpp @@ -22,10 +22,10 @@ void CScriptMemoryRelay::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId obj } if (msg == EScriptObjectMessage::Deactivate) { - stateMgr.GetRelayTracker()->RemoveMsg(xc_editorId); + stateMgr.GetMailbox()->RemoveMsg(xc_editorId); return; } else if (msg == EScriptObjectMessage::Activate) { - stateMgr.GetRelayTracker()->AddMsg(xc_editorId); + stateMgr.GetMailbox()->AddMsg(xc_editorId); if (!x34_25_skipSendActive) { SendScriptMsgs(EScriptObjectState::Active, stateMgr, EScriptObjectMessage::None); } diff --git a/Runtime/World/CScriptSpecialFunction.cpp b/Runtime/World/CScriptSpecialFunction.cpp index 2f06d9595..e8ea0fd47 100644 --- a/Runtime/World/CScriptSpecialFunction.cpp +++ b/Runtime/World/CScriptSpecialFunction.cpp @@ -345,7 +345,7 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId if (msg == EScriptObjectMessage::Decrement || msg == EScriptObjectMessage::Increment) { if (x1bc_areaSaveId != -1 && x1c0_layerIdx != -1) { TAreaId aId = mgr.GetWorld()->GetAreaIdForSaveId(x1bc_areaSaveId); - std::shared_ptr worldLayerState; + std::shared_ptr worldLayerState; if (aId != kInvalidAreaId) { worldLayerState = mgr.WorldLayerState(); } else {