diff --git a/GolemHelper/Common/Globals.cpp b/GolemHelper/Common/Globals.cpp index 28371ff..cd420a1 100644 --- a/GolemHelper/Common/Globals.cpp +++ b/GolemHelper/Common/Globals.cpp @@ -5,5 +5,6 @@ AddonAPI* g_api = nullptr; NexusLinkData* g_nexusLink = nullptr; +Mumble::Data* g_mumbleData = nullptr; GolemHelperState g_state; MenuCoordinates g_coords; \ No newline at end of file diff --git a/GolemHelper/Common/Globals.h b/GolemHelper/Common/Globals.h index b28d476..7f0f4b6 100644 --- a/GolemHelper/Common/Globals.h +++ b/GolemHelper/Common/Globals.h @@ -1,8 +1,10 @@ #pragma once #include "Types.h" #include "../Dependencies/nexus/Nexus.h" +#include "../Dependencies/mumble/mumble.h" extern AddonAPI* g_api; extern NexusLinkData* g_nexusLink; +extern Mumble::Data* g_mumbleData; extern GolemHelperState g_state; extern MenuCoordinates g_coords; \ No newline at end of file diff --git a/GolemHelper/Common/Types.h b/GolemHelper/Common/Types.h index d9f7422..218b94c 100644 --- a/GolemHelper/Common/Types.h +++ b/GolemHelper/Common/Types.h @@ -1,4 +1,5 @@ #pragma once +#include "../Dependencies/mumble/mumble.h" enum HitboxType { HITBOX_SMALL = 0, @@ -32,6 +33,9 @@ struct GolemHelperState { int initialDelay = 390; int stepDelay = 290; + + bool quickAccessVisible = false; + unsigned int lastMapID = 0; }; struct MenuCoordinates { diff --git a/GolemHelper/GolemHelper.cpp b/GolemHelper/GolemHelper.cpp index ae26cb3..00d240b 100644 --- a/GolemHelper/GolemHelper.cpp +++ b/GolemHelper/GolemHelper.cpp @@ -2,6 +2,7 @@ #include #include "Common/Globals.h" #include "Utils/FileUtils.h" +#include "Utils/MapUtils.h" #include "Config/ConfigManager.h" #include "UI/UIManager.h" #include "Input/KeybindManager.h" @@ -15,6 +16,8 @@ void Load(AddonAPI* aApi) { g_nexusLink = (NexusLinkData*)g_api->DataLink.Get("DL_NEXUS_LINK"); + g_mumbleData = (Mumble::Data*)g_api->DataLink.Get("DL_MUMBLE_LINK"); + g_state.enabled = true; ConfigManager::LoadCustomDelaySettings(); @@ -28,21 +31,17 @@ void Load(AddonAPI* aApi) { g_api->Textures.GetOrCreateFromFile("GOLEM_HELPER_ICON", "addons/GolemHelper/icons/GOLEM_HELPER_ICON.png"); g_api->Textures.GetOrCreateFromFile("GOLEM_HELPER_ICON_HOVER", "addons/GolemHelper/icons/GOLEM_HELPER_ICON_HOVER.png"); - g_api->QuickAccess.Add( - "GolemHelper.ToggleUI", - "GOLEM_HELPER_ICON", - "GOLEM_HELPER_ICON_HOVER", - "GolemHelper.ToggleUI", - "GolemHelper UI" - ); + MapUtils::UpdateQuickAccessVisibility(); - g_api->Log(ELogLevel_INFO, "GolemHelper", "=== GolemHelper v1.2.6.0 Loaded ==="); + g_api->Log(ELogLevel_INFO, "GolemHelper", "=== GolemHelper v1.3.0.0 Loaded ==="); g_api->Log(ELogLevel_INFO, "GolemHelper", "GolemHelper addon loaded successfully!"); } void Unload() { if (g_api) { - g_api->QuickAccess.Remove("GolemHelper.ToggleUI"); + if (g_state.quickAccessVisible) { + g_api->QuickAccess.Remove("GolemHelper.ToggleUI"); + } g_api->Renderer.Deregister(UIManager::RenderUI); g_api->Renderer.Deregister(UIManager::RenderOptions); KeybindManager::UnregisterKeybinds(); @@ -50,8 +49,10 @@ void Unload() { g_api->Log(ELogLevel_INFO, "GolemHelper", "GolemHelper signing off, it was an honor commander."); g_api = nullptr; + g_mumbleData = nullptr; g_state.enabled = false; g_state.showUI = false; + g_state.quickAccessVisible = false; } extern "C" __declspec(dllexport) AddonDefinition* GetAddonDef() { @@ -59,7 +60,7 @@ extern "C" __declspec(dllexport) AddonDefinition* GetAddonDef() { def.Signature = -424248; def.APIVersion = NEXUS_API_VERSION; def.Name = "GolemHelper"; - def.Version = { 1, 2, 6, 0 }; + def.Version = { 1, 3, 0, 0 }; def.Author = "Azrub"; def.Description = "Automates the process of setting optimal boon and golem configurations in the training area"; def.Load = Load; diff --git a/GolemHelper/GolemHelper.vcxproj b/GolemHelper/GolemHelper.vcxproj index 31e7ea9..acd3e43 100644 --- a/GolemHelper/GolemHelper.vcxproj +++ b/GolemHelper/GolemHelper.vcxproj @@ -161,6 +161,7 @@ + @@ -213,6 +214,7 @@ + diff --git a/GolemHelper/GolemHelper.vcxproj.filters b/GolemHelper/GolemHelper.vcxproj.filters index 335eb21..347d92d 100644 --- a/GolemHelper/GolemHelper.vcxproj.filters +++ b/GolemHelper/GolemHelper.vcxproj.filters @@ -108,6 +108,9 @@ File di origine + + Utils + @@ -155,6 +158,9 @@ File di origine + + Utils + diff --git a/GolemHelper/UI/UIManager.cpp b/GolemHelper/UI/UIManager.cpp index 0c58e1f..84fbb43 100644 --- a/GolemHelper/UI/UIManager.cpp +++ b/GolemHelper/UI/UIManager.cpp @@ -3,9 +3,12 @@ #include "UIManager.h" #include "../Common/Globals.h" #include "../Config/ConfigManager.h" +#include "../Utils/MapUtils.h" #include "../Dependencies/imgui/imgui.h" void UIManager::RenderUI() { + MapUtils::UpdateQuickAccessVisibility(); + if (!g_state.showUI) return; ImGui::SetNextWindowSize(ImVec2(400, 500), ImGuiCond_FirstUseEver); @@ -13,7 +16,7 @@ void UIManager::RenderUI() { if (ImGui::Begin("GolemHelper", &g_state.showUI, ImGuiWindowFlags_AlwaysAutoResize)) { - ImGui::TextColored(ImVec4(0.2f, 0.8f, 1.0f, 1.0f), "GolemHelper v1.2.6.0"); + ImGui::TextColored(ImVec4(0.2f, 0.8f, 1.0f, 1.0f), "GolemHelper v1.3.0.0"); ImGui::Separator(); ImGui::Text("Status:"); @@ -139,6 +142,13 @@ void UIManager::RenderUI() { ImGui::Text("DPI Scale: %.3f", dpiScale); ImGui::Text("Debug samples: %d", g_state.debugCounter); } + + ImGui::Spacing(); + ImGui::Text("Map Info:"); + unsigned int currentMapID = MapUtils::GetCurrentMapID(); + ImGui::Text("Current MapID: %u", currentMapID); + ImGui::Text("Is Training Area: %s", MapUtils::IsInTrainingArea() ? "YES" : "NO"); + ImGui::Text("QuickAccess Visible: %s", g_state.quickAccessVisible ? "YES" : "NO"); } ImGui::Spacing(); diff --git a/GolemHelper/Utils/MapUtils.cpp b/GolemHelper/Utils/MapUtils.cpp new file mode 100644 index 0000000..a2ef426 --- /dev/null +++ b/GolemHelper/Utils/MapUtils.cpp @@ -0,0 +1,56 @@ +#include +#include +#include +#include +#include "MapUtils.h" +#include "../Common/Globals.h" + +bool MapUtils::IsInTrainingArea() { + return GetCurrentMapID() == 1154; +} + +unsigned int MapUtils::GetCurrentMapID() { + if (g_mumbleData && g_mumbleData->Context.MapID != 0) { + return g_mumbleData->Context.MapID; + } + + return 0; +} + +void MapUtils::UpdateQuickAccessVisibility() { + if (!g_api) return; + + bool shouldBeVisible = IsInTrainingArea(); + unsigned int currentMapID = GetCurrentMapID(); + + if (currentMapID != g_state.lastMapID) { + g_state.lastMapID = currentMapID; + + if (shouldBeVisible && !g_state.quickAccessVisible) { + g_api->QuickAccess.Add( + "GolemHelper.ToggleUI", + "GOLEM_HELPER_ICON", + "GOLEM_HELPER_ICON_HOVER", + "GolemHelper.ToggleUI", + "GolemHelper UI" + ); + g_state.quickAccessVisible = true; + + if (g_state.debugMode) { + char buffer[150]; + sprintf_s(buffer, sizeof(buffer), "QuickAccess icon ADDED - MapID: %u (Training Area)", currentMapID); + g_api->Log(ELogLevel_INFO, "GolemHelper", buffer); + } + } + else if (!shouldBeVisible && g_state.quickAccessVisible) { + g_api->QuickAccess.Remove("GolemHelper.ToggleUI"); + g_state.quickAccessVisible = false; + + if (g_state.debugMode) { + char buffer[150]; + sprintf_s(buffer, sizeof(buffer), "QuickAccess icon REMOVED - MapID: %u (Not Training Area)", currentMapID); + g_api->Log(ELogLevel_INFO, "GolemHelper", buffer); + } + } + } +} \ No newline at end of file diff --git a/GolemHelper/Utils/MapUtils.h b/GolemHelper/Utils/MapUtils.h new file mode 100644 index 0000000..b30155d --- /dev/null +++ b/GolemHelper/Utils/MapUtils.h @@ -0,0 +1,8 @@ +#pragma once + +class MapUtils { +public: + static bool IsInTrainingArea(); + static void UpdateQuickAccessVisibility(); + static unsigned int GetCurrentMapID(); +}; \ No newline at end of file