2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-07-14 22:05:53 +00:00

Work on CWorldTransManager

This commit is contained in:
Jack Andersen 2016-08-15 10:58:07 -10:00
parent eb7ce0b84b
commit 0dacc2233c
19 changed files with 264 additions and 108 deletions

View File

@ -7,6 +7,8 @@ namespace urde
CGameState::CGameState() CGameState::CGameState()
{ {
x98_playerState.reset(new CPlayerState());
x9c_transManager.reset(new CWorldTransManager());
x228_25_deferPowerupInit = true; x228_25_deferPowerupInit = true;
} }

View File

@ -24,11 +24,12 @@ class CGameState
{ {
friend class CStateManager; friend class CStateManager;
bool x0_[128] = {};
int m_stateFlag = -1; int m_stateFlag = -1;
ResId x84_mlvlId = -1; ResId x84_mlvlId = -1;
std::vector<CWorldState> x88_worldStates; std::vector<CWorldState> x88_worldStates;
CPlayerState x98_playerState; std::shared_ptr<CPlayerState> x98_playerState;
CWorldTransManager x9c_transManager; std::shared_ptr<CWorldTransManager> x9c_transManager;
float m_gameTime = 0.0; float m_gameTime = 0.0;
CGameOptions m_gameOpts; CGameOptions m_gameOpts;
double xa0_playTime; double xa0_playTime;
@ -46,10 +47,12 @@ public:
CGameState(); CGameState();
CGameState(CBitStreamReader& stream); CGameState(CBitStreamReader& stream);
void SetCurrentWorldId(unsigned int id, const std::string& name); void SetCurrentWorldId(unsigned int id, const std::string& name);
CWorldTransManager& WorldTransitionManager() {return x9c_transManager;} std::shared_ptr<CPlayerState> PlayerState() {return x98_playerState;}
std::shared_ptr<CWorldTransManager> WorldTransitionManager() {return x9c_transManager;}
void SetTotalPlayTime(float time); void SetTotalPlayTime(float time);
CWorldState& StateForWorld(ResId mlvlId); CWorldState& StateForWorld(ResId mlvlId);
CWorldState& CurrentWorldState() { return StateForWorld(x84_mlvlId); } CWorldState& CurrentWorldState() { return StateForWorld(x84_mlvlId); }
ResId CurrentWorldAssetId() const { return x84_mlvlId; }
}; };
} }

View File

@ -13,7 +13,7 @@ class CArchitectureQueue;
class CIOWin class CIOWin
{ {
std::string m_name; std::string x4_name;
size_t m_nameHash; size_t m_nameHash;
public: public:
enum class EMessageReturn enum class EMessageReturn
@ -24,12 +24,12 @@ public:
RemoveIOWin = 3 RemoveIOWin = 3
}; };
virtual ~CIOWin() {} virtual ~CIOWin() {}
CIOWin(const char* name) : m_name(name) {m_nameHash = std::hash<std::string>()(m_name);} CIOWin(const char* name) : x4_name(name) {m_nameHash = std::hash<std::string>()(x4_name);}
virtual EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&)=0; virtual EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&)=0;
virtual bool GetIsContinueDraw() const {return true;} virtual bool GetIsContinueDraw() const {return true;}
virtual void Draw() const {} virtual void Draw() const {}
virtual void PreDraw() const {} virtual void PreDraw() const {}
const std::string& GetName() const {return m_name;} const std::string& GetName() const {return x4_name;}
size_t GetNameHash() const {return m_nameHash;} size_t GetNameHash() const {return m_nameHash;}
}; };

View File

@ -32,10 +32,24 @@ class CObjectList
}; };
SObjectListEntry m_list[1024]; SObjectListEntry m_list[1024];
EGameObjectList m_listEnum; EGameObjectList m_listEnum;
TUniqueId m_firstId = -1; TUniqueId m_firstId = kInvalidUniqueId;
u16 m_count = 0; u16 m_count = 0;
int m_areaIdx = 0; int m_areaIdx = 0;
public: public:
class iterator
{
friend class CObjectList;
CObjectList& m_list;
TUniqueId m_id;
iterator(CObjectList& list, TUniqueId id) : m_list(list), m_id(id) {}
public:
iterator& operator++() { m_id = m_list.GetNextObjectIndex(m_id); return *this; }
bool operator!=(const iterator& other) const { return m_id != other.m_id; }
CEntity* operator*() const { return m_list.GetObjectById(m_id); }
};
iterator begin() { return iterator(*this, m_firstId); }
iterator end() { return iterator(*this, kInvalidUniqueId); }
CObjectList(EGameObjectList listEnum); CObjectList(EGameObjectList listEnum);
void AddObject(CEntity& entity); void AddObject(CEntity& entity);

View File

@ -536,18 +536,12 @@ void CStateManager::InitializeState(ResId mlvlId, TAreaId aid, ResId mreaId)
x850_world->TravelToArea(x8cc_nextAreaId, *this, true); x850_world->TravelToArea(x8cc_nextAreaId, *this, true);
UpdateRoomAcoustics(x8cc_nextAreaId); UpdateRoomAcoustics(x8cc_nextAreaId);
TUniqueId entId = x80c_allObjs->GetFirstObjectIndex(); for (CEntity* ent : *x80c_allObjs)
while (entId != kInvalidUniqueId)
{
CEntity* ent = x80c_allObjs->GetObjectById(entId);
SendScriptMsg(ent, kInvalidUniqueId, EScriptObjectMessage::InternalMessage14); SendScriptMsg(ent, kInvalidUniqueId, EScriptObjectMessage::InternalMessage14);
entId = x80c_allObjs->GetNextObjectIndex(entId);
}
entId = x80c_allObjs->GetFirstObjectIndex(); for (CEntity* ent : *x80c_allObjs)
while (entId != kInvalidUniqueId)
{ {
CScriptSpawnPoint* sp = dynamic_cast<CScriptSpawnPoint*>(x80c_allObjs->GetObjectById(entId)); CScriptSpawnPoint* sp = dynamic_cast<CScriptSpawnPoint*>(ent);
if (sp && sp->x30_24_active && sp->FirstSpawn()) if (sp && sp->x30_24_active && sp->FirstSpawn())
{ {
const zeus::CTransform& xf = sp->GetTransform(); const zeus::CTransform& xf = sp->GetTransform();
@ -577,7 +571,6 @@ void CStateManager::InitializeState(ResId mlvlId, TAreaId aid, ResId mreaId)
x8b8_playerState->IncrPickup(iType, spawnPu - statePu); x8b8_playerState->IncrPickup(iType, spawnPu - statePu);
} }
} }
entId = x80c_allObjs->GetNextObjectIndex(entId);
} }
x84c_player->AsyncLoadSuit(*this); x84c_player->AsyncLoadSuit(*this);

View File

@ -139,16 +139,13 @@ const CGameCamera* CCameraManager::GetCurrentCamera(const CStateManager& stateMg
void CCameraManager::ResetCameras(CStateManager& mgr) void CCameraManager::ResetCameras(CStateManager& mgr)
{ {
CGameCameraList& camList = mgr.GetCameraObjectList();
zeus::CTransform xf = mgr.GetPlayer().CreateTransformFromMovementDirection(); zeus::CTransform xf = mgr.GetPlayer().CreateTransformFromMovementDirection();
xf.origin = mgr.GetPlayer().GetEyePosition(); xf.origin = mgr.GetPlayer().GetEyePosition();
TUniqueId camId = camList.GetFirstObjectIndex(); for (CEntity* ent : mgr.GetCameraObjectList())
while (camId != kInvalidUniqueId)
{ {
CGameCamera* camObj = static_cast<CGameCamera*>(camList.GetObjectById(camId)); CGameCamera* camObj = static_cast<CGameCamera*>(ent);
camObj->Reset(xf, mgr); camObj->Reset(xf, mgr);
camId = camList.GetNextObjectIndex(camId);
} }
} }

View File

@ -2,6 +2,10 @@
namespace urde namespace urde
{ {
namespace MP1
{
class CMain* g_Main = nullptr;
}
class CMemoryCardSys* g_MemoryCardSys = nullptr; class CMemoryCardSys* g_MemoryCardSys = nullptr;
class IFactory* g_ResFactory = nullptr; class IFactory* g_ResFactory = nullptr;

View File

@ -10,6 +10,10 @@
namespace urde namespace urde
{ {
namespace MP1
{
extern class CMain* g_Main;
}
extern class CMemoryCardSys* g_MemoryCardSys; extern class CMemoryCardSys* g_MemoryCardSys;
extern class IFactory* g_ResFactory; extern class IFactory* g_ResFactory;

View File

@ -48,13 +48,13 @@ void CGuiTextPane::Draw(const CGuiWidgetDrawParms& parms) const
zeus::CVector2f dims = GetDimensions(); zeus::CVector2f dims = GetDimensions();
if (x114_textSupport.x28_extentX) if (x114_textSupport.x34_extentX)
dims.x /= float(x114_textSupport.x28_extentX); dims.x /= float(x114_textSupport.x34_extentX);
else else
dims.x = 0.f; dims.x = 0.f;
if (x114_textSupport.x2c_extentY) if (x114_textSupport.x38_extentY)
dims.y /= float(x114_textSupport.x2c_extentY); dims.y /= float(x114_textSupport.x38_extentY);
else else
dims.y = 0.f; dims.y = 0.f;
@ -112,7 +112,7 @@ CGuiTextPane* CGuiTextPane::Create(CGuiFrame* frame, CInputStream& in, bool flag
bool vertical = in.readBool(); bool vertical = in.readBool();
EJustification justification = EJustification(in.readUint32Big()); EJustification justification = EJustification(in.readUint32Big());
EVerticalJustification vJustification = EVerticalJustification(in.readUint32Big()); EVerticalJustification vJustification = EVerticalJustification(in.readUint32Big());
CGuiTextProperties props(wordWrap, vertical, false, justification, vJustification); CGuiTextProperties props(wordWrap, vertical, justification, vJustification, ETextDirection::Horizontal);
zeus::CColor fontCol; zeus::CColor fontCol;
fontCol.readRGBABig(in); fontCol.readRGBABig(in);
zeus::CColor outlineCol; zeus::CColor outlineCol;

View File

@ -20,7 +20,7 @@ public:
const CGuiTextSupport* GetTextSupport() const {return &x114_textSupport;} const CGuiTextSupport* GetTextSupport() const {return &x114_textSupport;}
void Update(float dt); void Update(float dt);
bool GetIsFinishedLoadingWidgetSpecific() const; bool GetIsFinishedLoadingWidgetSpecific() const;
std::vector<ResId> GetFontAssets() const {return {x114_textSupport.x50_fontId};} std::vector<ResId> GetFontAssets() const {return {x114_textSupport.x5c_fontId};}
void SetDimensions(const zeus::CVector2f& dim, bool initVBO); void SetDimensions(const zeus::CVector2f& dim, bool initVBO);
void ScaleDimensions(const zeus::CVector3f& scale); void ScaleDimensions(const zeus::CVector3f& scale);
void Draw(const CGuiWidgetDrawParms& parms) const; void Draw(const CGuiWidgetDrawParms& parms) const;

View File

@ -14,26 +14,26 @@ namespace urde
CGuiTextSupport::CGuiTextSupport(ResId fontId, const CGuiTextProperties& props, CGuiTextSupport::CGuiTextSupport(ResId fontId, const CGuiTextProperties& props,
const zeus::CColor& fontCol, const zeus::CColor& outlineCol, const zeus::CColor& fontCol, const zeus::CColor& outlineCol,
const zeus::CColor& geomCol, s32 padX, s32 padY, CSimplePool* store) const zeus::CColor& geomCol, s32 padX, s32 padY, CSimplePool* store)
: x10_props(props), x1c_fontColor(fontCol), x20_outlineColor(outlineCol), : x14_props(props), x24_fontColor(fontCol), x28_outlineColor(outlineCol),
x24_geometryColor(geomCol), x28_extentX(padX), x2c_extentY(padY) x2c_geometryColor(geomCol), x34_extentX(padX), x38_extentY(padY)
{ {
x2c0_font = store->GetObj({SBIG('FONT'), fontId}); x2cc_font = store->GetObj({SBIG('FONT'), fontId});
} }
float CGuiTextSupport::GetCurrentAnimationOverAge() const float CGuiTextSupport::GetCurrentAnimationOverAge() const
{ {
if (!x2ac_active || !x44_typeEnable) if (!x2ac_active || !x50_typeEnable)
return 0.f; return 0.f;
if (x34_primStartTimes.size()) if (x44_primStartTimes.size())
{ {
float val = (x54_renderBuf->GetPrimitiveCount() - x34_primStartTimes.back().second) / float val = (x60_renderBuf->GetPrimitiveCount() - x44_primStartTimes.back().second) /
x4c_chRate + x34_primStartTimes.back().first; x58_chRate + x44_primStartTimes.back().first;
return std::max(0.f, val); return std::max(0.f, val);
} }
else else
{ {
float val = x54_renderBuf->GetPrimitiveCount() / x4c_chRate; float val = x60_renderBuf->GetPrimitiveCount() / x58_chRate;
return std::max(0.f, val); return std::max(0.f, val);
} }
} }
@ -41,23 +41,23 @@ float CGuiTextSupport::GetCurrentAnimationOverAge() const
float CGuiTextSupport::GetNumCharsPrinted() const float CGuiTextSupport::GetNumCharsPrinted() const
{ {
if (x2ac_active) if (x2ac_active)
return std::min(x30_curTime * x4c_chRate, float(x54_renderBuf->GetPrimitiveCount())); return std::min(x3c_curTime * x58_chRate, float(x60_renderBuf->GetPrimitiveCount()));
return 0.f; return 0.f;
} }
float CGuiTextSupport::GetTotalAnimationTime() const float CGuiTextSupport::GetTotalAnimationTime() const
{ {
if (!x2ac_active || !x44_typeEnable) if (!x2ac_active || !x50_typeEnable)
return 0.f; return 0.f;
return x54_renderBuf->GetPrimitiveCount() / x4c_chRate; return x60_renderBuf->GetPrimitiveCount() / x58_chRate;
} }
void CGuiTextSupport::SetTypeWriteEffectOptions(bool enable, float chFadeTime, float chRate) void CGuiTextSupport::SetTypeWriteEffectOptions(bool enable, float chFadeTime, float chRate)
{ {
x44_typeEnable = enable; x50_typeEnable = enable;
x48_chFadeTime = std::max(chFadeTime, 0.0001f); x54_chFadeTime = std::max(chFadeTime, 0.0001f);
x4c_chRate = std::max(chRate, 1.f); x58_chRate = std::max(chRate, 1.f);
} }
void CGuiTextSupport::Update(float dt) void CGuiTextSupport::Update(float dt)
@ -65,12 +65,12 @@ void CGuiTextSupport::Update(float dt)
if (!x2ac_active) if (!x2ac_active)
return; return;
if (x44_typeEnable) if (x50_typeEnable)
{ {
for (int i=0 ; i<x54_renderBuf->GetPrimitiveCount() ; ++i) for (int i=0 ; i<x60_renderBuf->GetPrimitiveCount() ; ++i)
{ {
float chStartTime = 0.f; float chStartTime = 0.f;
for (const std::pair<float, int>& p : x34_primStartTimes) for (const std::pair<float, int>& p : x44_primStartTimes)
{ {
if (p.second < i) if (p.second < i)
continue; continue;
@ -85,18 +85,18 @@ void CGuiTextSupport::Update(float dt)
prim.x0_color1.a = std::min(std::max(0.f, (x30_curTime - chStartTime) / x48_chFadeTime), 1.f); prim.x0_color1.a = std::min(std::max(0.f, (x30_curTime - chStartTime) / x48_chFadeTime), 1.f);
x54_renderBuf->SetPrimitive(prim, i); x54_renderBuf->SetPrimitive(prim, i);
#else #else
x54_renderBuf->SetPrimitiveOpacity(i, x60_renderBuf->SetPrimitiveOpacity(i,
std::min(std::max(0.f, (x30_curTime - chStartTime) / x48_chFadeTime), 1.f)); std::min(std::max(0.f, (x3c_curTime - chStartTime) / x54_chFadeTime), 1.f));
#endif #endif
} }
} }
x30_curTime += dt; x3c_curTime += dt;
} }
void CGuiTextSupport::ClearBuffer() void CGuiTextSupport::ClearBuffer()
{ {
x54_renderBuf = std::experimental::nullopt; x60_renderBuf = std::experimental::nullopt;
} }
void CGuiTextSupport::CheckAndRebuildTextRenderBuffer() void CGuiTextSupport::CheckAndRebuildTextRenderBuffer()
@ -105,15 +105,15 @@ void CGuiTextSupport::CheckAndRebuildTextRenderBuffer()
return; return;
g_TextExecuteBuf->Clear(); g_TextExecuteBuf->Clear();
g_TextExecuteBuf->x18_textState.x48_enableWordWrap = x10_props.x0_wordWrap; g_TextExecuteBuf->x18_textState.x48_enableWordWrap = x14_props.x0_wordWrap;
g_TextExecuteBuf->BeginBlock(0, 0, x28_extentX, x2c_extentY, ETextDirection(x10_props.x1_vertical), g_TextExecuteBuf->BeginBlock(0, 0, x34_extentX, x38_extentY, ETextDirection(x14_props.x1_vertical),
x10_props.x4_justification, x10_props.x8_vertJustification); x14_props.x4_justification, x14_props.x8_vertJustification);
g_TextExecuteBuf->AddColor(EColorType::Main, x1c_fontColor); g_TextExecuteBuf->AddColor(EColorType::Main, x24_fontColor);
g_TextExecuteBuf->AddColor(EColorType::Outline, x20_outlineColor); g_TextExecuteBuf->AddColor(EColorType::Outline, x28_outlineColor);
std::wstring initStr; std::wstring initStr;
if ((x50_fontId & 0xffff) != 0xffff) if ((x5c_fontId & 0xffff) != 0xffff)
initStr = hecl::WideFormat(L"&font=%08X;", u32(x50_fontId)); initStr = hecl::WideFormat(L"&font=%08X;", u32(x5c_fontId));
initStr += x0_string; initStr += x0_string;
g_TextParser->ParseText(*g_TextExecuteBuf, initStr.c_str(), initStr.size()); g_TextParser->ParseText(*g_TextExecuteBuf, initStr.c_str(), initStr.size());
@ -123,7 +123,7 @@ void CGuiTextSupport::CheckAndRebuildTextRenderBuffer()
if (GetIsTextSupportFinishedLoading()) if (GetIsTextSupportFinishedLoading())
{ {
x54_renderBuf = g_TextExecuteBuf->CreateTextRenderBuffer(); x60_renderBuf = g_TextExecuteBuf->CreateTextRenderBuffer();
g_TextExecuteBuf->Clear(); g_TextExecuteBuf->Clear();
} }
@ -136,31 +136,31 @@ void CGuiTextSupport::Render() const
{ {
zeus::CTransform oldModel = CGraphics::g_GXModelMatrix; zeus::CTransform oldModel = CGraphics::g_GXModelMatrix;
CGraphics::SetModelMatrix(oldModel * zeus::CTransform::Scale(1.f, 1.f, -1.f)); CGraphics::SetModelMatrix(oldModel * zeus::CTransform::Scale(1.f, 1.f, -1.f));
x54_renderBuf->Render(x24_geometryColor, x30_curTime); x60_renderBuf->Render(x2c_geometryColor, x3c_curTime);
CGraphics::SetModelMatrix(oldModel); CGraphics::SetModelMatrix(oldModel);
} }
} }
void CGuiTextSupport::SetGeometryColor(const zeus::CColor& col) void CGuiTextSupport::SetGeometryColor(const zeus::CColor& col)
{ {
x24_geometryColor = col; x2c_geometryColor = col;
} }
void CGuiTextSupport::SetOutlineColor(const zeus::CColor& col) void CGuiTextSupport::SetOutlineColor(const zeus::CColor& col)
{ {
if (col != x20_outlineColor) if (col != x28_outlineColor)
{ {
ClearBuffer(); ClearBuffer();
x20_outlineColor = col; x28_outlineColor = col;
} }
} }
void CGuiTextSupport::SetFontColor(const zeus::CColor& col) void CGuiTextSupport::SetFontColor(const zeus::CColor& col)
{ {
if (col != x1c_fontColor) if (col != x24_fontColor)
{ {
ClearBuffer(); ClearBuffer();
x1c_fontColor = col; x24_fontColor = col;
} }
} }
@ -169,8 +169,8 @@ void CGuiTextSupport::AddText(const std::wstring& str)
if (x2ac_active) if (x2ac_active)
{ {
float t = GetCurrentAnimationOverAge(); float t = GetCurrentAnimationOverAge();
x34_primStartTimes.push_back(std::make_pair(std::max(t, x30_curTime), x44_primStartTimes.push_back(std::make_pair(std::max(t, x3c_curTime),
x54_renderBuf->GetPrimitiveCount())); x60_renderBuf->GetPrimitiveCount()));
} }
x0_string += str; x0_string += str;
ClearBuffer(); ClearBuffer();
@ -180,8 +180,8 @@ void CGuiTextSupport::SetText(const std::wstring& str)
{ {
if (x0_string.compare(str)) if (x0_string.compare(str))
{ {
x34_primStartTimes.clear(); x44_primStartTimes.clear();
x30_curTime = 0.f; x3c_curTime = 0.f;
x0_string = str; x0_string = str;
ClearBuffer(); ClearBuffer();
} }
@ -200,7 +200,7 @@ bool CGuiTextSupport::GetIsTextSupportFinishedLoading() const
if (!tok.IsLoaded()) if (!tok.IsLoaded())
return false; return false;
} }
return x2c0_font.IsLoaded(); return x2cc_font.IsLoaded();
} }
} }

View File

@ -62,36 +62,46 @@ class CGuiTextProperties
friend class CGuiTextSupport; friend class CGuiTextSupport;
bool x0_wordWrap; bool x0_wordWrap;
bool x1_vertical; bool x1_vertical;
bool x2_c;
EJustification x4_justification; EJustification x4_justification;
EVerticalJustification x8_vertJustification; EVerticalJustification x8_vertJustification;
ETextDirection xc_direction;
public: public:
CGuiTextProperties(bool wordWrap, bool vertical, bool c, EJustification justification, CGuiTextProperties(bool wordWrap, bool vertical, EJustification justification,
EVerticalJustification vertJustification) EVerticalJustification vertJustification, ETextDirection dir)
: x0_wordWrap(wordWrap), x1_vertical(vertical), x2_c(c), x4_justification(justification), : x0_wordWrap(wordWrap), x1_vertical(vertical), x4_justification(justification),
x8_vertJustification(vertJustification) {} x8_vertJustification(vertJustification), xc_direction(dir) {}
}; };
class CGuiTextSupport class CGuiTextSupport
{ {
friend class CGuiTextPane; friend class CGuiTextPane;
std::wstring x0_string; std::wstring x0_string;
CGuiTextProperties x10_props; float x10_ = 0.f;
zeus::CColor x1c_fontColor; CGuiTextProperties x14_props;
zeus::CColor x20_outlineColor; zeus::CColor x24_fontColor;
zeus::CColor x24_geometryColor; zeus::CColor x28_outlineColor;
s32 x28_extentX; zeus::CColor x2c_geometryColor;
s32 x2c_extentY; s32 x34_extentX;
float x30_curTime = 0.f; s32 x38_extentY;
std::vector<std::pair<float, int>> x34_primStartTimes; float x3c_curTime = 0.f;
bool x44_typeEnable = false; std::vector<std::pair<float, int>> x44_primStartTimes;
float x48_chFadeTime = 0.1f; bool x50_typeEnable = false;
float x4c_chRate = 10.0f; float x54_chFadeTime = 0.1f;
ResId x50_fontId; float x58_chRate = 10.0f;
std::experimental::optional<CTextRenderBuffer> x54_renderBuf; ResId x5c_fontId;
std::experimental::optional<CTextRenderBuffer> x60_renderBuf;
bool x2ac_active = false; bool x2ac_active = false;
std::vector<CToken> x2b0_assets; std::vector<CToken> x2b0_assets;
TLockedToken<CRasterFont> x2c0_font; TLockedToken<CRasterFont> x2cc_font;
zeus::CVector2f x2dc_;
zeus::CVector2f x2e4_;
std::list<u8> x2f0_;
u32 x300_ = 0;
u32 x304_ = 0;
u32 x308_ = 0;
public: public:
CGuiTextSupport(ResId fontId, const CGuiTextProperties& props, CGuiTextSupport(ResId fontId, const CGuiTextProperties& props,
const zeus::CColor& fontCol, const zeus::CColor& outlineCol, const zeus::CColor& fontCol, const zeus::CColor& outlineCol,

View File

@ -2,20 +2,40 @@
#include "CArchitectureQueue.hpp" #include "CArchitectureQueue.hpp"
#include "GameGlobalObjects.hpp" #include "GameGlobalObjects.hpp"
#include "CGameState.hpp" #include "CGameState.hpp"
#include "MP1.hpp"
namespace urde namespace urde
{ {
namespace MP1 namespace MP1
{ {
CMFGameLoader::CMFGameLoader()
: CMFGameLoaderBase("CMFGameLoader")
{
switch (g_Main->GetFlowState())
{
case CMain::FlowState::Five:
case CMain::FlowState::Six:
{
ResId mlvlId = g_GameState->CurrentWorldAssetId();
//g_GameState->WorldTransitionManager()->
//g_MemoryCardSys->
}
default:
{
}
}
}
CIOWin::EMessageReturn CMFGameLoader::OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue) CIOWin::EMessageReturn CMFGameLoader::OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue)
{ {
std::shared_ptr<CWorldTransManager> wtMgr = g_GameState->WorldTransitionManager();
switch (msg.GetType()) switch (msg.GetType())
{ {
case EArchMsgType::TimerTick: case EArchMsgType::TimerTick:
{ {
const CArchMsgParmReal32& tick = MakeMsg::GetParmTimerTick(msg); const CArchMsgParmReal32& tick = MakeMsg::GetParmTimerTick(msg);
g_GameState->WorldTransitionManager();
} }
default: break; default: break;
} }
@ -24,7 +44,7 @@ CIOWin::EMessageReturn CMFGameLoader::OnMessage(const CArchitectureMessage& msg,
void CMFGameLoader::Draw() const void CMFGameLoader::Draw() const
{ {
g_GameState->WorldTransitionManager().Draw(); g_GameState->WorldTransitionManager()->Draw();
} }
} }

View File

@ -5,6 +5,10 @@
namespace urde namespace urde
{ {
class CStateManager;
class CInGameGuiManager;
class CToken;
namespace MP1 namespace MP1
{ {
@ -18,8 +22,22 @@ public:
class CMFGameLoader : public CMFGameLoaderBase class CMFGameLoader : public CMFGameLoaderBase
{ {
std::shared_ptr<CStateManager> x14_stateMgr;
std::shared_ptr<CInGameGuiManager> x18_guiMgr;
std::vector<CToken> x1c_;
union
{
struct
{
bool x2c_24_ : 1;
bool x2c_25_ : 1;
};
u8 _dummy = 0;
};
public: public:
CMFGameLoader() : CMFGameLoaderBase("CMFGameLoader") {} CMFGameLoader();
EMessageReturn OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue); EMessageReturn OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue);
void Draw() const; void Draw() const;
}; };

View File

@ -35,9 +35,9 @@ void CMainFlow::SetGameState(EClientFlowStates state, CArchitectureQueue& queue)
{ {
case EClientFlowStates::FrontEnd: case EClientFlowStates::FrontEnd:
{ {
if (g_main->GetGameplayResult() == EGameplayResult::None) if (g_Main->GetGameplayResult() == EGameplayResult::None)
{ {
g_main->SetGameplayResult(EGameplayResult::Playing); g_Main->SetGameplayResult(EGameplayResult::Playing);
break; break;
} }
/* TODO: URDE handling /* TODO: URDE handling
@ -45,8 +45,8 @@ void CMainFlow::SetGameState(EClientFlowStates state, CArchitectureQueue& queue)
while (!loader.AreAllPaksLoaded()) while (!loader.AreAllPaksLoaded())
loader.AsyncIdlePakLoading(); loader.AsyncIdlePakLoading();
*/ */
g_main->LoadAudio(); g_Main->LoadAudio();
g_main->RegisterResourceTweaks(); g_Main->RegisterResourceTweaks();
queue.Push(std::move(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, new CFrontEndUI()))); queue.Push(std::move(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, new CFrontEndUI())));
break; break;
} }
@ -57,7 +57,7 @@ void CMainFlow::SetGameState(EClientFlowStates state, CArchitectureQueue& queue)
} }
case EClientFlowStates::MoviePlay: case EClientFlowStates::MoviePlay:
{ {
switch (g_main->GetGameplayResult()) switch (g_Main->GetGameplayResult())
{ {
case EGameplayResult::Win: case EGameplayResult::Win:
queue.Push(std::move(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, new CPlayMovie(CPlayMovie::EWhichMovie::WinGame)))); queue.Push(std::move(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, new CPlayMovie(CPlayMovie::EWhichMovie::WinGame))));

View File

@ -12,13 +12,12 @@ URDE_DECL_SPECIALIZE_SHADER(CSpaceWarpFilter)
namespace MP1 namespace MP1
{ {
class CMain* g_main = nullptr;
CMain::CMain(IFactory& resFactory, CSimplePool& resStore) CMain::CMain(IFactory& resFactory, CSimplePool& resStore)
: m_globalObjects(resFactory, resStore) : x128_globalObjects(resFactory, resStore)
{ {
g_main = this;
xe4_gameplayResult = EGameplayResult::Playing; xe4_gameplayResult = EGameplayResult::Playing;
g_Main = this;
} }
void CMain::RegisterResourceTweaks() void CMain::RegisterResourceTweaks()
@ -60,7 +59,7 @@ void CMain::Init(boo::IGraphicsDataFactory* factory,
boo::IAudioVoiceEngine* voiceEngine) boo::IAudioVoiceEngine* voiceEngine)
{ {
InitializeSubsystems(factory, cc, renderTex, storeMgr, voiceEngine); InitializeSubsystems(factory, cc, renderTex, storeMgr, voiceEngine);
m_globalObjects.PostInitialize(); x128_globalObjects.PostInitialize();
x70_tweaks.RegisterTweaks(); x70_tweaks.RegisterTweaks();
//g_TweakManager->ReadFromMemoryCard("AudioTweaks"); //g_TweakManager->ReadFromMemoryCard("AudioTweaks");
FillInAssetIDs(); FillInAssetIDs();

View File

@ -207,6 +207,18 @@ class CMain
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
#endif #endif
public:
enum class FlowState
{
Zero,
One,
Two,
Three,
Four,
Five,
Six,
};
private:
//CMemorySys x6c_memSys; //CMemorySys x6c_memSys;
CTweaks x70_tweaks; CTweaks x70_tweaks;
@ -214,9 +226,32 @@ class CMain
bool xe8_b24_finished = false; bool xe8_b24_finished = false;
/* urde addition: these are simply initialized along with everything else */ /* urde addition: these are simply initialized along with everything else */
CGameGlobalObjects m_globalObjects; CGameGlobalObjects x128_globalObjects;
CGameArchitectureSupport m_archSupport; CGameArchitectureSupport m_archSupport;
FlowState x12c_ = FlowState::Five;
u32 x130_[10] = { 1000000 };
union
{
struct
{
bool x160_24_ : 1;
bool x160_25_ : 1;
bool x160_26_ : 1;
bool x160_27_ : 1;
bool x160_28_ : 1;
bool x160_29_ : 1;
bool x160_30_ : 1;
bool x160_31_ : 1;
bool x161_24_ : 1;
};
u16 _dummy = 0;
};
u32 x164_ = 0;
void InitializeSubsystems(boo::IGraphicsDataFactory* factory, void InitializeSubsystems(boo::IGraphicsDataFactory* factory,
boo::IGraphicsCommandQueue* cc, boo::IGraphicsCommandQueue* cc,
boo::ITextureR* renderTex, boo::ITextureR* renderTex,
@ -248,9 +283,10 @@ public:
void ShutdownSubsystems(); void ShutdownSubsystems();
EGameplayResult GetGameplayResult() const {return xe4_gameplayResult;} EGameplayResult GetGameplayResult() const {return xe4_gameplayResult;}
void SetGameplayResult(EGameplayResult wl) {xe4_gameplayResult = wl;} void SetGameplayResult(EGameplayResult wl) {xe4_gameplayResult = wl;}
FlowState GetFlowState() const { return x12c_; }
}; };
extern CMain* g_main;
} }
} }

View File

@ -1,4 +1,7 @@
#include "CWorldTransManager.hpp" #include "CWorldTransManager.hpp"
#include "GuiSys/CGuiTextSupport.hpp"
#include "CSimplePool.hpp"
#include "GameGlobalObjects.hpp"
namespace urde namespace urde
{ {
@ -11,4 +14,27 @@ void CWorldTransManager::DrawDisabled() const
{ {
} }
void CWorldTransManager::StartTextTransition(ResId fontId, ResId stringId, bool b1, bool b2,
float chFadeTime, float chFadeRate, float f3)
{
x40_ = b1;
x38_ = f3;
x44_25_ = false;
x30_type = ETransType::Text;
x4_modelData.reset();
x44_27_ = b2;
CGuiTextProperties props(false, true, EJustification::Center,
EVerticalJustification::Center, ETextDirection::Horizontal);
x8_textData.reset(new CGuiTextSupport(fontId, props, zeus::CColor::skWhite,
zeus::CColor::skBlack, zeus::CColor::skWhite,
640, 448, g_SimplePool));
x8_textData->SetTypeWriteEffectOptions(true, chFadeTime, chFadeRate);
xc_strTable = g_SimplePool->GetObj(SObjectTag{FOURCC('STRG'), stringId});
x8_textData->SetText(L"");
StartTransition();
}
} }

View File

@ -3,15 +3,42 @@
#include "RetroTypes.hpp" #include "RetroTypes.hpp"
#include "CRandom16.hpp" #include "CRandom16.hpp"
#include "Character/CModelData.hpp"
#include "GuiSys/CGuiTextSupport.hpp"
namespace urde namespace urde
{ {
class CSimplePool;
class CStringTable;
class CWorldTransManager class CWorldTransManager
{ {
public:
enum class ETransType
{
Blank,
LiftScene,
Text
};
struct CWorldTransModelData
{
CModelData x1c_;
CModelData x68_;
CModelData xb4_;
CModelData x100_;
CToken x14c_;
CToken x158_;
CToken x164_;
std::vector<u32> x1a0_;
std::unique_ptr<u8> x1b0_;
};
private:
float x0_ = 0.f; float x0_ = 0.f;
u32 x4_ = 0; std::unique_ptr<CWorldTransModelData> x4_modelData;
u32 x8_ = 0; std::unique_ptr<CGuiTextSupport> x8_textData;
TLockedToken<CStringTable> xc_strTable;
u8 x14_ = 0; u8 x14_ = 0;
float x18_; float x18_;
CRandom16 x20_ = CRandom16(99); CRandom16 x20_ = CRandom16(99);
@ -19,8 +46,9 @@ class CWorldTransManager
u32 x28_ = 0; u32 x28_ = 0;
u8 x2c_ = 127; u8 x2c_ = 127;
u8 x2d_ = 64; u8 x2d_ = 64;
u32 x30_ = 0; ETransType x30_type = ETransType::Blank;
float x38_ = 0.f; float x38_ = 0.f;
bool x40_;
union union
{ {
struct struct
@ -48,11 +76,11 @@ public:
void sub_80209280() const {} void sub_80209280() const {}
void Draw() const void Draw() const
{ {
if (x30_ == 0) if (x30_type == ETransType::Blank)
DrawDisabled(); DrawDisabled();
else if (x30_ == 1) else if (x30_type == ETransType::LiftScene)
DrawEnabled(); DrawEnabled();
else if (x30_ == 2) else if (x30_type == ETransType::Text)
sub_80209280(); sub_80209280();
} }
@ -61,9 +89,11 @@ public:
x0_ = 0.f; x0_ = 0.f;
x18_ = 0.f; x18_ = 0.f;
x44_24_ = false; x44_24_ = false;
x44_24_ = true; x44_28_ = true;
} }
void StartTextTransition(ResId fontId, ResId stringId, bool, bool, float, float, float);
void EndTransition() {} void EndTransition() {}
void PleaseStopSoon() {} void PleaseStopSoon() {}
bool IsTransitionEnabled() const { return false; } bool IsTransitionEnabled() const { return false; }