mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-12-30 16:22:58 -06:00
Draw position, Move patches to debug_patches.cpp
This commit is contained in:
@@ -153,7 +153,8 @@ set(SWA_PATCHES_CXX_SOURCES
|
||||
"patches/ui/CTitleStateMenu_patches.cpp"
|
||||
"patches/ui/frontend_listener.cpp"
|
||||
"patches/audio_patches.cpp"
|
||||
"patches/camera_patches.cpp"
|
||||
"patches/camera_patches.cpp"
|
||||
"patches/debug_patches.cpp"
|
||||
"patches/fps_patches.cpp"
|
||||
"patches/inspire_patches.cpp"
|
||||
"patches/misc_patches.cpp"
|
||||
|
||||
@@ -103,6 +103,7 @@
|
||||
#include "SWA/System/GammaController.h"
|
||||
#include "SWA/System/InputState.h"
|
||||
#include "SWA/System/PadState.h"
|
||||
#include "SWA/System/StageManager.h"
|
||||
#include "SWA/System/World.h"
|
||||
#include "boost/smart_ptr/make_shared_object.h"
|
||||
#include "boost/smart_ptr/shared_ptr.h"
|
||||
|
||||
26
UnleashedRecomp/api/SWA/System/StageManager.h
Normal file
26
UnleashedRecomp/api/SWA/System/StageManager.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "SWA.inl"
|
||||
#include "Hedgehog/Base/Thread/hhSynchronizedObject.h"
|
||||
#include "Hedgehog/Universe/Engine/hhMessageActor.h"
|
||||
#include "SWA/System/GameObject.h"
|
||||
|
||||
|
||||
namespace SWA
|
||||
{
|
||||
class CStageManager //: public SWA::CGameObject, public Hedgehog::Base::CSynchronizedObject
|
||||
{
|
||||
public:
|
||||
SWA_INSERT_PADDING(0xD0);
|
||||
Hedgehog::Math::CVector m_PlayerPosition; //0xD0
|
||||
SWA_INSERT_PADDING(0x40);
|
||||
be<float> m_StageGuidePathRatioMaybe; // @ 0x11C
|
||||
be<float> m_StageGuidePathLength; // @ 0x120
|
||||
SWA_INSERT_PADDING(0x9C);
|
||||
};
|
||||
|
||||
SWA_ASSERT_OFFSETOF(CStageManager, m_PlayerPosition, 0xD0);
|
||||
SWA_ASSERT_OFFSETOF(CStageManager, m_StageGuidePathRatioMaybe, 0x11C);
|
||||
SWA_ASSERT_OFFSETOF(CStageManager, m_StageGuidePathLength, 0x120);
|
||||
SWA_ASSERT_SIZEOF(CStageManager, 0x1C0);
|
||||
}
|
||||
67
UnleashedRecomp/patches/debug_patches.cpp
Normal file
67
UnleashedRecomp/patches/debug_patches.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
#include <api/SWA.h>
|
||||
#include <ui/game_window.h>
|
||||
#include <user/config.h>
|
||||
#include <ui/reddog/debug_draw.h>
|
||||
#include <ui/imgui_utils.h>
|
||||
|
||||
|
||||
// boost::~::SWA::CDebugDraw::CMember::SDrawLine
|
||||
PPC_FUNC_IMPL(__imp__sub_822C9398);
|
||||
PPC_FUNC(sub_822C9398)
|
||||
{
|
||||
auto a2 = (Hedgehog::Math::CVector*)g_memory.Translate(ctx.r4.u32);
|
||||
auto a3 = (Hedgehog::Math::CVector*)g_memory.Translate(ctx.r5.u32);
|
||||
auto a4 = (be<unsigned int>*)g_memory.Translate(ctx.r6.u32);
|
||||
|
||||
Reddog::Vector3 start(a2->X, a2->Y, a2->Z);
|
||||
Reddog::Vector3 end(a3->X, a3->Y, a3->Z);
|
||||
|
||||
const Reddog::SDrawLine line{
|
||||
start, end, a4->value
|
||||
};
|
||||
|
||||
Reddog::DebugDraw::DrawLine(line);
|
||||
|
||||
__imp__sub_822C9398(ctx, base);
|
||||
}
|
||||
|
||||
|
||||
// SWA::CStageManager::UpdateParallel
|
||||
//PPC_FUNC_IMPL(__imp__sub_82521C68);
|
||||
//PPC_FUNC(sub_82521C68)
|
||||
//{
|
||||
// __imp__sub_82521C68(ctx, base);
|
||||
//}
|
||||
|
||||
|
||||
// SWA::CStageManager::UpdateSerial
|
||||
PPC_FUNC_IMPL(__imp__sub_82522040);
|
||||
PPC_FUNC(sub_82522040)
|
||||
{
|
||||
auto a1 = static_cast<SWA::CStageManager*>(g_memory.Translate(ctx.r3.u32));
|
||||
|
||||
// Draw player position
|
||||
if (Reddog::DebugDraw::GetIsDrawPosition())
|
||||
{
|
||||
const Reddog::SDrawText positionText{
|
||||
{Scale(750), Scale(120)},
|
||||
fmt::format("( {:.2f}, {:.2f}, {:.2f} )", a1->m_PlayerPosition.X.get(), a1->m_PlayerPosition.Y.get(), a1->m_PlayerPosition.Z.get()),
|
||||
0,
|
||||
Scale(1.0f),
|
||||
0xFFFFFFFF,
|
||||
Reddog::eDrawTextFlags_NoShadow
|
||||
};
|
||||
|
||||
Reddog::DebugDraw::DrawText2D(positionText);
|
||||
}
|
||||
|
||||
// TODO (RadiantDerg): Reimplement SWA::CStageManager ability to draw progress ratio
|
||||
|
||||
__imp__sub_82522040(ctx, base);
|
||||
}
|
||||
|
||||
// GetIsDebugRenderForGameObject()
|
||||
PPC_FUNC(sub_82512BF8)
|
||||
{
|
||||
ctx.r3.u8 = 1; // Always return true
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <ui/game_window.h>
|
||||
#include <user/achievement_data.h>
|
||||
#include <user/config.h>
|
||||
#include <ui/reddog/debug_draw.h>
|
||||
|
||||
void AchievementManagerUnlockMidAsmHook(PPCRegister& id)
|
||||
{
|
||||
@@ -125,4 +124,4 @@ PPC_FUNC(sub_822C9398)
|
||||
Reddog::DebugDraw::DrawLine(line);
|
||||
|
||||
__imp__sub_822C9398(ctx, base);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ namespace Reddog
|
||||
return result;
|
||||
}
|
||||
|
||||
static ImVec2 GetNDCCoordinate(const Vector3& in_rVec)
|
||||
static ImVec2 GetNDCCoordinate(const Vector3& in_rPosition)
|
||||
{
|
||||
auto& res = ImGui::GetIO().DisplaySize;
|
||||
|
||||
@@ -90,9 +90,9 @@ namespace Reddog
|
||||
if (freeText->Position >= ImVec2(0, 0) && freeText->Position <= canvasSize)
|
||||
{
|
||||
if ((freeText->Flags & eDrawTextFlags_NoShadow) == eDrawTextFlags_NoShadow)
|
||||
drawList->AddText(font, fontSize * freeText->Scale, freeText->Position, freeText->Colour, freeText->Text);
|
||||
drawList->AddText(font, fontSize * freeText->Scale, freeText->Position, freeText->Colour, freeText->Text.c_str());
|
||||
else
|
||||
DrawTextWithShadow(drawList, font, fontSize * freeText->Scale, freeText->Position, freeText->Colour, freeText->Text, 1.0f, 1.0f, IM_COL32(0, 0, 0, 128));
|
||||
DrawTextWithShadow(drawList, font, fontSize * freeText->Scale, freeText->Position, freeText->Colour, freeText->Text.c_str(), 1.0f, 1.0f, IM_COL32(0, 0, 0, 128));
|
||||
}
|
||||
|
||||
// Decrement timer
|
||||
@@ -134,7 +134,7 @@ namespace Reddog
|
||||
if (useColor)
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, logText->Colour);
|
||||
|
||||
ImGui::TextUnformatted(logText->Text);
|
||||
ImGui::TextUnformatted(logText->Text.c_str());
|
||||
|
||||
if (useColor)
|
||||
ImGui::PopStyleColor();
|
||||
@@ -160,35 +160,35 @@ namespace Reddog
|
||||
|
||||
void DebugDraw::DrawLine(const SDrawLine& in_rLine)
|
||||
{
|
||||
if (!ms_IsRendering && ms_IsDrawLine)
|
||||
if (!ms_IsRendering && GetIsDrawDebug())
|
||||
ms_LineList.push_back(in_rLine);
|
||||
}
|
||||
|
||||
void DebugDraw::DrawText2D(const SDrawText& in_rText)
|
||||
{
|
||||
if (!ms_IsRendering && ms_IsDrawText)
|
||||
if (!ms_IsRendering && GetIsDrawText())
|
||||
ms_FreeTextList.push_back(in_rText);
|
||||
}
|
||||
|
||||
void DebugDraw::DrawText2D(const SDrawText& in_rText, const Vector3& in_rVec)
|
||||
void DebugDraw::DrawText2D(const SDrawText& in_rText, const Vector3& in_rPosition)
|
||||
{
|
||||
if (!ms_IsRendering && ms_IsDrawText)
|
||||
if (!ms_IsRendering && GetIsDrawText())
|
||||
{
|
||||
auto txt = in_rText;
|
||||
txt.Position = GetNDCCoordinate(in_rVec);
|
||||
txt.Position = GetNDCCoordinate(in_rPosition);
|
||||
ms_FreeTextList.push_back(txt);
|
||||
}
|
||||
}
|
||||
|
||||
void DebugDraw::DrawTextLog(const SDrawText& in_rText)
|
||||
{
|
||||
if (!ms_IsRendering && ms_IsDrawText)
|
||||
if (!ms_IsRendering && GetIsDrawText())
|
||||
ms_LogTextList.push_back(in_rText);
|
||||
}
|
||||
|
||||
void DebugDraw::DrawTextLog(const char* in_Text, float in_Time, ImU32 in_Colour, ImU16 in_Priority)
|
||||
{
|
||||
if (!ms_IsRendering && ms_IsDrawText)
|
||||
if (!ms_IsRendering && GetIsDrawText())
|
||||
ms_LogTextList.push_back({ ImVec2(0,0), in_Text, in_Time, 0, in_Colour, eDrawTextFlags_None, in_Priority});
|
||||
}
|
||||
|
||||
@@ -204,12 +204,12 @@ namespace Reddog
|
||||
DrawText2D({ ImVec2(Scale(50), Scale(350)), "TEST3 SCALE", 0, 5, 0xFF37C800 });
|
||||
|
||||
DrawTextLog("TEST1 NORMAL");
|
||||
DrawTextLog("TEST2 COLORED", 0, 0xFF37C800);
|
||||
|
||||
auto form = fmt::format("- Stats -\nLines: {}\nTexts: {}\nLogs: {}", ms_LineList.size(), ms_FreeTextList.size(), ms_LogTextList.size());
|
||||
SDrawText text = { ImVec2(Scale(40), Scale(75)), form.c_str(), 0, 0.75f };
|
||||
DrawText2D(text);*/
|
||||
DrawTextLog("TEST2 COLORED", 0, 0xFF37C800);*/
|
||||
|
||||
auto stats = fmt::format("== Stats ==\nLines: {}\nTexts: {}\nLogs: {}", ms_LineList.size(), ms_FreeTextList.size(), ms_LogTextList.size());
|
||||
SDrawText text = { ImVec2(Scale(40), Scale(75)), stats, 0, 0.75f };
|
||||
DrawText2D(text);
|
||||
|
||||
ms_IsRendering = true;
|
||||
|
||||
Exec_DrawLines(drawList, res, deltaTime);
|
||||
@@ -218,4 +218,19 @@ namespace Reddog
|
||||
|
||||
ms_IsRendering = false;
|
||||
}
|
||||
|
||||
bool DebugDraw::GetIsDrawDebug()
|
||||
{
|
||||
return *SWA::SGlobals::ms_IsRenderDebugDraw;
|
||||
}
|
||||
|
||||
bool DebugDraw::GetIsDrawText()
|
||||
{
|
||||
return *SWA::SGlobals::ms_IsRenderDebugDrawText;
|
||||
}
|
||||
|
||||
bool DebugDraw::GetIsDrawPosition()
|
||||
{
|
||||
return *SWA::SGlobals::ms_IsRenderDebugPositionDraw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,12 +28,12 @@ namespace Reddog
|
||||
struct SDrawText
|
||||
{
|
||||
ImVec2 Position { 0,0 };
|
||||
const char* Text { "" };
|
||||
std::string Text;
|
||||
float Time { 0 };
|
||||
float Scale { 1 };
|
||||
ImU32 Colour { IM_COL32(255, 255, 255, 255) };
|
||||
SDrawTextFlags Flags { eDrawTextFlags_None };
|
||||
ImU16 Priority { 0xFFFF };
|
||||
ImU16 Priority { 0 };
|
||||
};
|
||||
|
||||
|
||||
@@ -44,21 +44,23 @@ namespace Reddog
|
||||
{
|
||||
public:
|
||||
static inline bool ms_IsRendering = false;
|
||||
static inline bool ms_IsDrawLine = false;
|
||||
static inline bool ms_IsDrawText = false;
|
||||
|
||||
static inline std::vector<SDrawLine> ms_LineList = {};
|
||||
static inline std::vector<SDrawText> ms_FreeTextList = {};
|
||||
static inline std::vector<SDrawText> ms_LogTextList = {};
|
||||
|
||||
static void DrawLine(const SDrawLine& in_Line);
|
||||
static void DrawLine(const SDrawLine& in_rLine);
|
||||
|
||||
static void DrawText2D(const SDrawText& in_Text);
|
||||
static void DrawText2D(const SDrawText& in_Text, const Vector3& in_Position);
|
||||
static void DrawText2D(const SDrawText& in_rText);
|
||||
static void DrawText2D(const SDrawText& in_rText, const Vector3& in_rPosition);
|
||||
|
||||
static void DrawTextLog(const SDrawText& in_Text);
|
||||
static void DrawTextLog(const char* in_Text, float in_Time = 0, ImU32 in_Colour = IM_COL32(255, 255, 255, 255), ImU16 in_Priority = 0xFFFF);
|
||||
static void DrawTextLog(const SDrawText& in_rText);
|
||||
static void DrawTextLog(const char* in_Text, float in_Time = 0, ImU32 in_Colour = IM_COL32(255, 255, 255, 255), ImU16 in_Priority = 0);
|
||||
|
||||
static void Render(ImFont* font);
|
||||
|
||||
static bool GetIsDrawDebug();
|
||||
static bool GetIsDrawText();
|
||||
static bool GetIsDrawPosition();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -23,13 +23,9 @@ void ViewWindow::Draw()
|
||||
|
||||
Reddog::Separator();
|
||||
|
||||
Reddog::Checkbox("Render Debug Lines", &Reddog::DebugDraw::ms_IsDrawLine);
|
||||
Reddog::Checkbox("Render Debug Text", &Reddog::DebugDraw::ms_IsDrawText);
|
||||
|
||||
// TODO (RadiantDerg): respect these in Reddog::DebugDraw, rather than duplicating them.
|
||||
// Reddog::Checkbox("Render Debug Draw", SWA::SGlobals::ms_IsRenderDebugDraw);
|
||||
// Reddog::Checkbox("Render Debug Draw Text", SWA::SGlobals::ms_IsRenderDebugDrawText);
|
||||
// Reddog::Checkbox("Render Debug Position Draw", SWA::SGlobals::ms_IsRenderDebugPositionDraw);
|
||||
Reddog::Checkbox("Render Debug Draw", SWA::SGlobals::ms_IsRenderDebugDraw);
|
||||
Reddog::Checkbox("Render Debug Draw Text", SWA::SGlobals::ms_IsRenderDebugDrawText);
|
||||
Reddog::Checkbox("Render Debug Position Draw", SWA::SGlobals::ms_IsRenderDebugPositionDraw);
|
||||
|
||||
Reddog::Separator();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user