mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-12-12 11:12:20 -05:00
Update hook debugger to pull from GameInteractor ptrs rather than cloning the data every frame (#4609)
This commit is contained in:
parent
82d70a2029
commit
291561667b
@ -4,14 +4,14 @@
|
||||
#include <string>
|
||||
#include <version>
|
||||
|
||||
static std::unordered_map<const char*, std::unordered_map<HOOK_ID, HookInfo>> hookData;
|
||||
static std::unordered_map<const char*, std::unordered_map<HOOK_ID, HookInfo>*> hookData;
|
||||
|
||||
const ImVec4 grey = ImVec4(0.75, 0.75, 0.75, 1);
|
||||
const ImVec4 yellow = ImVec4(1, 1, 0, 1);
|
||||
const ImVec4 red = ImVec4(1, 0, 0, 1);
|
||||
|
||||
void DrawHookRegisteringInfos(const char* hookName) {
|
||||
if (hookData[hookName].size() == 0) {
|
||||
if ((*hookData[hookName]).size() == 0) {
|
||||
ImGui::TextColored(grey, "No hooks found");
|
||||
return;
|
||||
}
|
||||
@ -27,7 +27,7 @@ void DrawHookRegisteringInfos(const char* hookName) {
|
||||
//ImGui::TableSetupColumn("Stub");
|
||||
ImGui::TableSetupColumn("Number of Calls");
|
||||
ImGui::TableHeadersRow();
|
||||
for (auto& [id, hookInfo] : hookData[hookName]) {
|
||||
for (auto& [id, hookInfo] : (*hookData[hookName])) {
|
||||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
@ -100,12 +100,10 @@ void HookDebuggerWindow::DrawElement() {
|
||||
}
|
||||
}
|
||||
|
||||
void HookDebuggerWindow::UpdateElement() {
|
||||
hookData.clear();
|
||||
|
||||
void HookDebuggerWindow::InitElement() {
|
||||
#define DEFINE_HOOK(name, _) hookData.insert({#name, GameInteractor::Instance->GetHookData<GameInteractor::name>()});
|
||||
|
||||
#include "../game-interactor/GameInteractor_HookTable.h"
|
||||
|
||||
#undef DEFINE_HOOK
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ class HookDebuggerWindow : public Ship::GuiWindow {
|
||||
public:
|
||||
using GuiWindow::GuiWindow;
|
||||
|
||||
void InitElement() override {};
|
||||
void InitElement() override;
|
||||
void DrawElement() override;
|
||||
void UpdateElement() override;
|
||||
void UpdateElement() override {};
|
||||
};
|
||||
|
@ -641,8 +641,8 @@ public:
|
||||
inline static std::vector<HOOK_ID> hooksForFilter;
|
||||
};
|
||||
|
||||
template <typename H> std::unordered_map<uint32_t, HookInfo> GetHookData() {
|
||||
return RegisteredGameHooks<H>::hookData;
|
||||
template <typename H> std::unordered_map<uint32_t, HookInfo>* GetHookData() {
|
||||
return &RegisteredGameHooks<H>::hookData;
|
||||
}
|
||||
|
||||
// General Hooks
|
||||
|
Loading…
Reference in New Issue
Block a user