From fdf55e727263dcc7aa9b9f22661a6f26a20322f0 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Wed, 9 May 2018 19:56:54 -0700 Subject: [PATCH] Implement CScriptHUDMemo, increase render bucket size, initial debug overlay --- Editor/ViewManager.cpp | 23 +++++++++++++++++++ Editor/ViewManager.hpp | 2 ++ Runtime/Graphics/CBooRenderer.cpp | 6 ++--- Runtime/Graphics/CBooRenderer.hpp | 2 +- Runtime/World/CGameArea.cpp | 2 +- Runtime/World/CScriptHUDMemo.cpp | 38 ++++++++++++++++++++++++++++--- Runtime/World/CScriptHUDMemo.hpp | 9 ++++++-- Runtime/World/CTeamAiMgr.cpp | 28 +++++++++++++++++++++++ Runtime/World/CTeamAiMgr.hpp | 26 ++++++++++++++++++--- Runtime/World/ScriptLoader.cpp | 8 ++++++- 10 files changed, 130 insertions(+), 14 deletions(-) diff --git a/Editor/ViewManager.cpp b/Editor/ViewManager.cpp index 9e826f71f..a2b0e238a 100644 --- a/Editor/ViewManager.cpp +++ b/Editor/ViewManager.cpp @@ -18,6 +18,8 @@ #include "Graphics/Shaders/CColoredQuadFilter.hpp" #include "Graphics/Shaders/CTexturedQuadFilter.hpp" #include "Audio/CStreamAudioManager.hpp" +#include "Runtime/CStateManager.hpp" +#include "Runtime/World/CPlayer.hpp" #include using YAMLNode = athena::io::YAMLNode; @@ -44,11 +46,30 @@ void ViewManager::TestGameView::resized(const boo::SWindowRect& root, const boo: { specter::View::resized(root, sub); urde::CGraphics::SetViewportResolution({sub.size[0], sub.size[1]}); + if (m_debugText) + m_debugText->resized(root, sub); } void ViewManager::TestGameView::draw(boo::IGraphicsCommandQueue* gfxQ) { m_vm.m_projManager.mainDraw(); + if (m_debugText && g_StateManager && g_StateManager->Player()) + m_debugText->draw(gfxQ); +} + +void ViewManager::TestGameView::think() +{ + if (!m_debugText) + m_debugText.reset(new specter::MultiLineTextView(m_vm.m_viewResources, *this, m_vm.m_viewResources.m_heading18)); + + if (m_debugText && g_StateManager && g_StateManager->Player()) + { + const CPlayer& pl = g_StateManager->GetPlayer(); + zeus::CQuaternion plQ = zeus::CQuaternion(pl.GetTransform().getRotation().buildMatrix3f()); + m_debugText->typesetGlyphs(hecl::Format("Player Position: x %f, y %f, z %f\n" + " Quaternion: w %f, x %f, y %f, z %f\n", pl.GetTranslation().x, pl.GetTranslation().y, pl.GetTranslation().z, + plQ.w, plQ.x, plQ.y, plQ.z)); + } } specter::View* ViewManager::BuildSpaceViews() @@ -275,6 +296,8 @@ bool ViewManager::proc() m_rootView->internalThink(); if (m_rootSpace) m_rootSpace->think(); + if (m_testGameView) + m_testGameView->think(); if (m_splash) m_splash->think(); diff --git a/Editor/ViewManager.hpp b/Editor/ViewManager.hpp index 6eb5444c1..8bfa8be36 100644 --- a/Editor/ViewManager.hpp +++ b/Editor/ViewManager.hpp @@ -55,11 +55,13 @@ class ViewManager : public specter::IViewManager class TestGameView : public specter::View { ViewManager& m_vm; + std::unique_ptr m_debugText; public: TestGameView(ViewManager& vm, specter::ViewResources& res, specter::View& parent) : View(res, parent), m_vm(vm) {} void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub); void draw(boo::IGraphicsCommandQueue* gfxQ); + void think(); void mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mkey) { diff --git a/Runtime/Graphics/CBooRenderer.cpp b/Runtime/Graphics/CBooRenderer.cpp index 83a0ac5b3..efd210aec 100644 --- a/Runtime/Graphics/CBooRenderer.cpp +++ b/Runtime/Graphics/CBooRenderer.cpp @@ -22,13 +22,13 @@ namespace urde static logvisor::Module Log("CBooRenderer"); -static rstl::reserved_vector sDataHolder; +static rstl::reserved_vector sDataHolder; static rstl::reserved_vector, 50> sBucketsHolder; static rstl::reserved_vector sPlaneObjectDataHolder; static rstl::reserved_vector sPlaneObjectBucketHolder; rstl::reserved_vector Buckets::sBucketIndex; -rstl::reserved_vector* Buckets::sData = nullptr; +rstl::reserved_vector* Buckets::sData = nullptr; rstl::reserved_vector, 50>* Buckets::sBuckets = nullptr; rstl::reserved_vector* Buckets::sPlaneObjectData = nullptr; rstl::reserved_vector* Buckets::sPlaneObjectBucket = nullptr; @@ -283,7 +283,7 @@ void CBooRenderer::RenderBucketItems(CAreaListItem* item) CBooModel* model = surf->m_parent; if (model) { - //ActivateLightsForModel(item, *model); + ActivateLightsForModel(item, *model); model->DrawSurface(*surf, flags); } break; diff --git a/Runtime/Graphics/CBooRenderer.hpp b/Runtime/Graphics/CBooRenderer.hpp index 3a98223d4..9499559dc 100644 --- a/Runtime/Graphics/CBooRenderer.hpp +++ b/Runtime/Graphics/CBooRenderer.hpp @@ -32,7 +32,7 @@ class Buckets friend class CBooRenderer; static rstl::reserved_vector sBucketIndex; - static rstl::reserved_vector* sData; + static rstl::reserved_vector* sData; static rstl::reserved_vector, 50>* sBuckets; static rstl::reserved_vector* sPlaneObjectData; static rstl::reserved_vector* sPlaneObjectBucket; diff --git a/Runtime/World/CGameArea.cpp b/Runtime/World/CGameArea.cpp index a140962a7..da267a1c1 100644 --- a/Runtime/World/CGameArea.cpp +++ b/Runtime/World/CGameArea.cpp @@ -696,7 +696,7 @@ void CGameArea::UpdateThermalVisor(float dt) void CGameArea::UpdateWeaponWorldLighting(float dt) { float newLightingLevel = x12c_postConstructed->x1128_worldLightingLevel; - if (x12c_postConstructed->x112c_xraySpeed != 0) + if (x12c_postConstructed->x112c_xraySpeed != 0.f) { float speed = dt * x12c_postConstructed->x112c_xraySpeed; if (std::fabs(x12c_postConstructed->x1130_xrayTarget - newLightingLevel) < speed) diff --git a/Runtime/World/CScriptHUDMemo.cpp b/Runtime/World/CScriptHUDMemo.cpp index aa20f1dad..a3925559f 100644 --- a/Runtime/World/CScriptHUDMemo.cpp +++ b/Runtime/World/CScriptHUDMemo.cpp @@ -1,13 +1,22 @@ #include "CScriptHUDMemo.hpp" +#include "GameGlobalObjects.hpp" +#include "CSimplePool.hpp" +#include "GuiSys/CStringTable.hpp" +#include "MP1/CSamusHud.hpp" #include "TCastTo.hpp" namespace urde { -CScriptHUDMemo::CScriptHUDMemo(TUniqueId uid, std::string_view name, const CEntityInfo& info, const CHUDMemoParms&, - CScriptHUDMemo::EDisplayType, CAssetId, bool active) - : CEntity(uid, info, active, name) +CScriptHUDMemo::CScriptHUDMemo(TUniqueId uid, std::string_view name, const CEntityInfo& info, + const CHUDMemoParms& parms, EDisplayType disp, CAssetId msg, bool active) +: CEntity(uid, info, active, name) +, x34_parms(parms) +, x3c_dispType(disp) +, x40_stringTableId(msg) { + if (msg.IsValid()) + x44_stringTable.emplace(g_SimplePool->GetObj({FOURCC('STRG'), msg})); } void CScriptHUDMemo::Accept(IVisitor& visitor) @@ -15,4 +24,27 @@ void CScriptHUDMemo::Accept(IVisitor& visitor) visitor.Visit(this); } +void CScriptHUDMemo::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) +{ + if (msg == EScriptObjectMessage::SetToZero) + { + if (GetActive()) + { + if (x3c_dispType == EDisplayType::MessageBox) + mgr.ShowPausedHUDMemo(x40_stringTableId, x34_parms.GetDisplayTime()); + else if (x3c_dispType == EDisplayType::StatusMessage) + { + if (x44_stringTable) + MP1::CSamusHud::DisplayHudMemo((*x44_stringTable)->GetString(0), x34_parms); + else + MP1::CSamusHud::DisplayHudMemo(u"", x34_parms); + } + } + } + else if (msg == EScriptObjectMessage::Deactivate && GetActive() && x3c_dispType == EDisplayType::StatusMessage) + MP1::CSamusHud::DisplayHudMemo(u"", CHUDMemoParms(0.f, false, true, false)); + + CEntity::AcceptScriptMsg(msg, uid, mgr); +} + } diff --git a/Runtime/World/CScriptHUDMemo.hpp b/Runtime/World/CScriptHUDMemo.hpp index 3e4846fb9..6561efce3 100644 --- a/Runtime/World/CScriptHUDMemo.hpp +++ b/Runtime/World/CScriptHUDMemo.hpp @@ -3,9 +3,10 @@ #include "CEntity.hpp" #include "CHUDMemoParms.hpp" - +#include "CToken.hpp" namespace urde { +class CStringTable; class CScriptHUDMemo : public CEntity { public: @@ -14,13 +15,17 @@ public: StatusMessage, MessageBox, }; - + CHUDMemoParms x34_parms; + EDisplayType x3c_dispType; + CAssetId x40_stringTableId; + std::experimental::optional> x44_stringTable; private: public: CScriptHUDMemo(TUniqueId, std::string_view, const CEntityInfo&, const CHUDMemoParms&, CScriptHUDMemo::EDisplayType, CAssetId, bool); void Accept(IVisitor& visitor); + void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); }; } diff --git a/Runtime/World/CTeamAiMgr.cpp b/Runtime/World/CTeamAiMgr.cpp index e69de29bb..0679e2134 100644 --- a/Runtime/World/CTeamAiMgr.cpp +++ b/Runtime/World/CTeamAiMgr.cpp @@ -0,0 +1,28 @@ +#include "CTeamAiMgr.hpp" +#include "TCastTo.hpp" +namespace urde +{ + +CTeamAiData::CTeamAiData(CInputStream& in, s32 propCount) +: x0_(in.readUint32Big()) +, x4_(in.readUint32Big()) +, x8_(in.readUint32Big()) +, xc_(in.readUint32Big()) +, x10_(in.readUint32Big()) +, x14_(in.readUint32Big()) +, x18_(in.readUint32Big()) +, x1c_(propCount > 8 ? in.readFloatBig() : 0.f) +, x20_(propCount > 8 ? in.readFloatBig() : 0.f) +{ +} + +CTeamAiMgr::CTeamAiMgr(TUniqueId uid, std::string_view name, const CEntityInfo& info, const CTeamAiData& data) + : CEntity(uid, info, true, name) +{ +} + +void CTeamAiMgr::Accept(IVisitor& visitor) +{ + visitor.Visit(this); +} +} diff --git a/Runtime/World/CTeamAiMgr.hpp b/Runtime/World/CTeamAiMgr.hpp index 98af078ec..7c871b313 100644 --- a/Runtime/World/CTeamAiMgr.hpp +++ b/Runtime/World/CTeamAiMgr.hpp @@ -1,13 +1,33 @@ #ifndef __URDE_CTEAMAIMGR_HPP__ #define __URDE_CTEAMAIMGR_HPP__ +#include "CEntity.hpp" namespace urde { -class CTeamAiMgr -{ +class CTeamAiData +{ + u32 x0_; + u32 x4_; + u32 x8_; + u32 xc_; + u32 x10_; + u32 x14_; + u32 x18_; + float x1c_; + float x20_; +public: + CTeamAiData(CInputStream& in, s32 propCount); +}; + +class CTeamAiMgr : public CEntity +{ +public: + CTeamAiMgr(TUniqueId, std::string_view name, const CEntityInfo&, const CTeamAiData& data); + + void Accept(IVisitor&); }; } -#endif // __URDE_CTEAMAIMGR_HPP__ \ No newline at end of file +#endif // __URDE_CTEAMAIMGR_HPP__ diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index 1b7796810..63b00b453 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -17,6 +17,7 @@ #include "CScriptCameraHint.hpp" #include "CScriptCameraHintTrigger.hpp" #include "CScriptCameraPitchVolume.hpp" +#include "CTeamAiMgr.hpp" #include "CScriptCameraShaker.hpp" #include "CScriptCameraWaypoint.hpp" #include "CScriptColorModulate.hpp" @@ -2440,7 +2441,12 @@ CEntity* ScriptLoader::LoadMagdolite(CStateManager& mgr, CInputStream& in, int p CEntity* ScriptLoader::LoadTeamAIMgr(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { - return nullptr; + if (!EnsurePropertyCount(propCount, 8, "TeamAiMgr")) + return nullptr; + + std::string_view name = mgr.HashInstanceName(in); + CTeamAiData data(in, propCount); + return new CTeamAiMgr(mgr.AllocateUniqueId(), name, info, data); } CEntity* ScriptLoader::LoadSnakeWeedSwarm(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)