diff --git a/ZHMModSDK/Include/Common.h b/ZHMModSDK/Include/Common.h index d2295af2..9a635315 100644 --- a/ZHMModSDK/Include/Common.h +++ b/ZHMModSDK/Include/Common.h @@ -9,6 +9,22 @@ #include +#ifdef max +#undef max +#endif + +#ifdef min +#undef min +#endif + +#ifdef MAX +#undef MAX +#endif + +#ifdef MIN +#undef MIN +#endif + #if LOADER_EXPORTS # define ZHMSDK_API __declspec(dllexport) #else diff --git a/ZHMModSDK/Include/IModSDK.h b/ZHMModSDK/Include/IModSDK.h index 03e5cbf8..5268a4c6 100644 --- a/ZHMModSDK/Include/IModSDK.h +++ b/ZHMModSDK/Include/IModSDK.h @@ -7,8 +7,6 @@ #include "imgui.h" #include "D3DUtils.h" -#include "implot.h" - #include "Glacier/ZPrimitives.h" #include "Glacier/ZEntity.h" #include "Glacier/ZResource.h" @@ -25,6 +23,7 @@ class TEntityRef; class ZHitman5; struct ImGuiTexture; +struct ImPlotContext; class IModSDK { public: @@ -52,6 +51,7 @@ class IModSDK { virtual ImFont* GetImGuiBlackFont() = 0; virtual ImPlotContext* GetImPlotContext() = 0; + virtual void SetImPlotContext(struct ImPlotContext*) = 0; /** * Try to get the name of a pin by its ID. diff --git a/ZHMModSDK/Include/IPluginInterface.h b/ZHMModSDK/Include/IPluginInterface.h index 06201ea2..23e6e1bb 100644 --- a/ZHMModSDK/Include/IPluginInterface.h +++ b/ZHMModSDK/Include/IPluginInterface.h @@ -4,6 +4,8 @@ #include "IModSDK.h" #include "IRenderer.h" +static void SetImPlotContext(ImPlotContext*); + class IPluginInterface { public: virtual ~IPluginInterface() = default; @@ -18,7 +20,7 @@ class IPluginInterface { ImGui::SetCurrentContext(s_Context); ImGui::SetAllocatorFunctions(SDK()->GetImGuiAlloc(), SDK()->GetImGuiFree(), SDK()->GetImGuiAllocatorUserData()); - ImPlot::SetCurrentContext(SDK()->GetImPlotContext()); + SDK()->SetImPlotContext(SDK()->GetImPlotContext()); } public: @@ -47,7 +49,7 @@ class IPluginInterface { private: virtual void CleanupUI() { ImGui::SetCurrentContext(nullptr); - ImPlot::SetCurrentContext(nullptr); + SDK()->SetImPlotContext(nullptr); } public: diff --git a/ZHMModSDK/Src/IPluginInterface.cpp b/ZHMModSDK/Src/IPluginInterface.cpp new file mode 100644 index 00000000..ab45c586 --- /dev/null +++ b/ZHMModSDK/Src/IPluginInterface.cpp @@ -0,0 +1,7 @@ +#include "IPluginInterface.h" +#include + +void SetImPlotContext(ImPlotContext* p_Context) +{ + ImPlot::SetCurrentContext(p_Context); +} \ No newline at end of file diff --git a/ZHMModSDK/Src/ModSDK.cpp b/ZHMModSDK/Src/ModSDK.cpp index 795c1d55..1ec4ed41 100644 --- a/ZHMModSDK/Src/ModSDK.cpp +++ b/ZHMModSDK/Src/ModSDK.cpp @@ -68,6 +68,7 @@ G2DefaultRetailExceptionHandler_t GetG2ExceptionHandler() { #include "DebugConsole.h" #endif +#include extern void SetupLogging(spdlog::level::level_enum p_LogLevel); @@ -1327,6 +1328,10 @@ ImPlotContext* ModSDK::GetImPlotContext() { return m_ImguiRenderer->GetImPlotContext(); } +void ModSDK::SetImPlotContext(ImPlotContext* p_Context) { + ImPlot::SetCurrentContext(p_Context); +} + bool ModSDK::GetPinName(int32_t p_PinId, ZString& p_Name) { std::string s_Name; if (TryGetPinName(p_PinId, s_Name)) { diff --git a/ZHMModSDK/Src/ModSDK.h b/ZHMModSDK/Src/ModSDK.h index 0f5c3821..b1f92aba 100644 --- a/ZHMModSDK/Src/ModSDK.h +++ b/ZHMModSDK/Src/ModSDK.h @@ -117,6 +117,7 @@ class ModSDK : public IModSDK { ImFont* GetImGuiBoldFont() override; ImFont* GetImGuiBlackFont() override; ImPlotContext* GetImPlotContext() override; + void SetImPlotContext(struct ImPlotContext* p_Context) override; bool GetPinName(int32_t p_PinId, ZString& p_Name) override; bool WorldToScreen(const SVector3& p_WorldPos, SVector2& p_Out) override; bool ScreenToWorld(const SVector2& p_ScreenPos, SVector3& p_WorldPosOut, SVector3& p_DirectionOut) override;