Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ZHMModSDK/Include/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@

#include <Windows.h>

#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
Expand Down
4 changes: 2 additions & 2 deletions ZHMModSDK/Include/IModSDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -25,6 +23,7 @@ class TEntityRef;
class ZHitman5;

struct ImGuiTexture;
struct ImPlotContext;

class IModSDK {
public:
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions ZHMModSDK/Include/IPluginInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "IModSDK.h"
#include "IRenderer.h"

static void SetImPlotContext(ImPlotContext*);

class IPluginInterface {
public:
virtual ~IPluginInterface() = default;
Expand All @@ -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:
Expand Down Expand Up @@ -47,7 +49,7 @@ class IPluginInterface {
private:
virtual void CleanupUI() {
ImGui::SetCurrentContext(nullptr);
ImPlot::SetCurrentContext(nullptr);
SDK()->SetImPlotContext(nullptr);
}

public:
Expand Down
7 changes: 7 additions & 0 deletions ZHMModSDK/Src/IPluginInterface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "IPluginInterface.h"
#include <implot.h>

void SetImPlotContext(ImPlotContext* p_Context)
{
ImPlot::SetCurrentContext(p_Context);
}
5 changes: 5 additions & 0 deletions ZHMModSDK/Src/ModSDK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ G2DefaultRetailExceptionHandler_t GetG2ExceptionHandler() {
#include "DebugConsole.h"

#endif
#include <implot.h>

extern void SetupLogging(spdlog::level::level_enum p_LogLevel);

Expand Down Expand Up @@ -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)) {
Expand Down
1 change: 1 addition & 0 deletions ZHMModSDK/Src/ModSDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading