Partial ratio text implementation

This commit is contained in:
RadiantDerg 2025-01-19 04:22:12 -06:00
parent fc51d0e7ae
commit c357062de8
5 changed files with 85 additions and 15 deletions

View file

@ -78,6 +78,8 @@
#include "SWA/Inspire/InspireTextureOverlayInfo.h" #include "SWA/Inspire/InspireTextureOverlayInfo.h"
#include "SWA/Movie/MovieDisplayer.h" #include "SWA/Movie/MovieDisplayer.h"
#include "SWA/Movie/MovieManager.h" #include "SWA/Movie/MovieManager.h"
#include "SWA/Path/PathController.h"
#include "SWA/Path/Animation/PathAnimation.h"
#include "SWA/Player/Character/EvilSonic/EvilSonic.h" #include "SWA/Player/Character/EvilSonic/EvilSonic.h"
#include "SWA/Player/Character/EvilSonic/EvilSonicContext.h" #include "SWA/Player/Character/EvilSonic/EvilSonicContext.h"
#include "SWA/Player/Character/EvilSonic/Hud/EvilHudGuide.h" #include "SWA/Player/Character/EvilSonic/Hud/EvilHudGuide.h"

View file

@ -0,0 +1,22 @@
#pragma once
namespace SWA::PathAnimation
{
class Entity
{
public:
xpointer<void> m_pVftable;
SWA_INSERT_PADDING(0x18);
};
class Controller
{
public:
xpointer<void> m_pVftable;
SWA_INSERT_PADDING(0x1C);
be<float> m_DistanceAlongPath;
};
SWA_ASSERT_OFFSETOF(Controller, m_DistanceAlongPath, 0x20);
}

View file

@ -0,0 +1,13 @@
#pragma once
#include "Animation/PathAnimation.h"
namespace SWA
{
class CPathController
{
public:
be<uint32_t> m_Field000;
be<uint32_t> m_Field004;
boost::shared_ptr<PathAnimation::Controller> m_spPathAnimationController;
};
}

View file

@ -11,16 +11,20 @@ namespace SWA
class CStageManager //: public SWA::CGameObject, public Hedgehog::Base::CSynchronizedObject class CStageManager //: public SWA::CGameObject, public Hedgehog::Base::CSynchronizedObject
{ {
public: public:
SWA_INSERT_PADDING(0xD0); SWA_INSERT_PADDING(0xC4);
Hedgehog::Math::CVector m_PlayerPosition; //0xD0 boost::shared_ptr<SWA::CPathController> m_spStageGuidePathController; //xpointer<SWA::CPathController> m_pStageGuidePathController;
SWA_INSERT_PADDING(0x40); SWA_INSERT_PADDING(0x4);
be<float> m_StageGuidePathRatioMaybe; // @ 0x11C Hedgehog::Math::CVector m_PlayerPosition;
be<float> m_StageGuidePathLength; // @ 0x120 be<float> m_Field0DC; // Sonic's air distance from path??
SWA_INSERT_PADDING(0x3C);
be<float> m_StageGuidePathRatio; // Not updated in retail
be<float> m_StageGuidePathLength;
SWA_INSERT_PADDING(0x9C); SWA_INSERT_PADDING(0x9C);
}; };
SWA_ASSERT_OFFSETOF(CStageManager, m_spStageGuidePathController, 0xC4);
SWA_ASSERT_OFFSETOF(CStageManager, m_PlayerPosition, 0xD0); SWA_ASSERT_OFFSETOF(CStageManager, m_PlayerPosition, 0xD0);
SWA_ASSERT_OFFSETOF(CStageManager, m_StageGuidePathRatioMaybe, 0x11C); SWA_ASSERT_OFFSETOF(CStageManager, m_StageGuidePathRatio, 0x11C);
SWA_ASSERT_OFFSETOF(CStageManager, m_StageGuidePathLength, 0x120); SWA_ASSERT_OFFSETOF(CStageManager, m_StageGuidePathLength, 0x120);
SWA_ASSERT_SIZEOF(CStageManager, 0x1C0); SWA_ASSERT_SIZEOF(CStageManager, 0x1C0);
} }

View file

@ -41,24 +41,53 @@ PPC_FUNC(sub_82522040)
{ {
auto a1 = static_cast<SWA::CStageManager*>(g_memory.Translate(ctx.r3.u32)); auto a1 = static_cast<SWA::CStageManager*>(g_memory.Translate(ctx.r3.u32));
__imp__sub_82522040(ctx, base);
// Draw player position // Draw player position
if (Reddog::DebugDraw::GetIsDrawPosition()) if (Reddog::DebugDraw::GetIsDrawPosition())
{ {
// TODO (RadiantDerg): Reimplement SWA::CStageManager ability to draw progress ratio
// NOTE: Currently does not work, is the API mapping horribly misaligned/misunderstood?
if (a1->m_spStageGuidePathController)
{
if (a1->m_spStageGuidePathController->m_spPathAnimationController)
{
auto PAC = a1->m_spStageGuidePathController->m_spPathAnimationController;
//Reddog::DebugDraw::DrawTextLog(fmt::format("m_DistanceAlongPath = {:.2f}", PAC->m_DistanceAlongPath.get()).c_str());
}
// Ratio
if (a1->m_StageGuidePathLength.get() > 0.0f)
{
//float distance = 0; // GetDistanceAlongPath(a1->m_StageGuidePathController)
//a1->m_StageGuidePathRatio = distance / a1->m_StageGuidePathLength;
const Reddog::SDrawText ratioText{
{Scale(g_aspectRatioOffsetX + 720), Scale(g_aspectRatioOffsetY + 36)},
fmt::format("{:.1f}m [{:.1f}/100.0]", a1->m_StageGuidePathLength.get(), a1->m_StageGuidePathRatio.get()),
0,
3.25f,
0xFFFFFFFF,
Reddog::eDrawTextFlags_NoShadow
};
Reddog::DebugDraw::DrawText2D(ratioText);
}
}
// Position
const Reddog::SDrawText positionText{ const Reddog::SDrawText positionText{
{Scale(g_aspectRatioOffsetX + 750), Scale(g_aspectRatioOffsetY + 120)}, {Scale(g_aspectRatioOffsetX + 750), Scale(g_aspectRatioOffsetY + 120)},
fmt::format("( {:.2f}, {:.2f}, {:.2f} )", a1->m_PlayerPosition.X.get(), a1->m_PlayerPosition.Y.get(), a1->m_PlayerPosition.Z.get()), fmt::format("( {:.2f}, {:.2f}, {:.2f} )", a1->m_PlayerPosition.X.get(), a1->m_PlayerPosition.Y.get(), a1->m_PlayerPosition.Z.get()),
0, 0,
1.5f, 2.0f,
0xFFFFFFFF, 0xFFFFFFFF,
Reddog::eDrawTextFlags_NoShadow Reddog::eDrawTextFlags_NoShadow
}; };
Reddog::DebugDraw::DrawText2D(positionText); Reddog::DebugDraw::DrawText2D(positionText);
} }
// TODO (RadiantDerg): Reimplement SWA::CStageManager ability to draw progress ratio
__imp__sub_82522040(ctx, base);
} }
// GetIsDebugRenderForGameObject() // GetIsDebugRenderForGameObject()