diff --git a/.gitignore b/.gitignore index a5eec74..1dd6bcf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,34 +1,43 @@ # Prerequisites *.d + # Compiled Object files *.slo *.lo *.o *.obj + # Precompiled Headers *.gch *.pch + # Linker files *.ilk + # Debugger Files *.pdb + # Compiled Dynamic libraries *.so *.dylib *.dll + # Fortran module files *.mod *.smod + # Compiled Static libraries *.lai *.la *.a *.lib + # Executables *.exe *.out *.app -# debug information files + +# Debug information files *.dwo # Visual Studio specific files @@ -45,6 +54,16 @@ *.svclog *.scc +# Visual Studio additional files +*.vcxproj.user +*.vcxproj.filters +*.sdf +*.opensdf +*.db +*.opendb +*.idb +*.exp + # Build folders [Dd]ebug/ [Dd]ebugPublic/ @@ -67,4 +86,38 @@ bld/ *.command.* *.read.* *.write.* -link-* \ No newline at end of file +link-* + +# Backup files +*.bak +*~ + +# OS generated files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Temporary files +*.tmp +*.temp + +# IDE files +*.swp +*.swo + +# Package files (vcpkg, NuGet) +packages/ +vcpkg_installed/ + +# Visual Studio Code +.vscode/ + +# JetBrains IDEs +.idea/ + +# Resource compiled files +*.aps \ No newline at end of file diff --git a/GolemHelper/GolemHelper.rc b/GolemHelper/GolemHelper.rc new file mode 100644 index 0000000..1d2667e Binary files /dev/null and b/GolemHelper/GolemHelper.rc differ diff --git a/GolemHelper/GolemHelper.vcxproj b/GolemHelper/GolemHelper.vcxproj index 017a68e..8fecd22 100644 --- a/GolemHelper/GolemHelper.vcxproj +++ b/GolemHelper/GolemHelper.vcxproj @@ -151,6 +151,7 @@ + @@ -196,6 +197,13 @@ Create + + + + + + + diff --git a/GolemHelper/GolemHelper.vcxproj.filters b/GolemHelper/GolemHelper.vcxproj.filters index cdf6328..3b02c57 100644 --- a/GolemHelper/GolemHelper.vcxproj.filters +++ b/GolemHelper/GolemHelper.vcxproj.filters @@ -25,6 +25,9 @@ {9474c716-f028-4778-8cd0-b5d8292d1586} + + {07fb10f3-1f9b-483c-8721-e22bfe687792} + @@ -81,4 +84,12 @@ Dependencies\imgui + + + Resources + + + Resources + + \ No newline at end of file diff --git a/GolemHelper/Resources/GOLEM_HELPER_ICON.png b/GolemHelper/Resources/GOLEM_HELPER_ICON.png new file mode 100644 index 0000000..212a85f Binary files /dev/null and b/GolemHelper/Resources/GOLEM_HELPER_ICON.png differ diff --git a/GolemHelper/Resources/GOLEM_HELPER_ICON_HOVER.png b/GolemHelper/Resources/GOLEM_HELPER_ICON_HOVER.png new file mode 100644 index 0000000..e56995b Binary files /dev/null and b/GolemHelper/Resources/GOLEM_HELPER_ICON_HOVER.png differ diff --git a/GolemHelper/dllmain.cpp b/GolemHelper/dllmain.cpp index 6d0975a..cbf8fde 100644 --- a/GolemHelper/dllmain.cpp +++ b/GolemHelper/dllmain.cpp @@ -8,6 +8,7 @@ #include "Dependencies/imgui/imgui.h" #include "Dependencies/nexus/Nexus.h" #include "Dependencies/mumble/Mumble.h" +#include "resource.h" AddonAPI* g_api = nullptr; NexusLinkData* NexusLink = nullptr; @@ -91,10 +92,11 @@ void HandleUIToggleKeybind(const char* id, bool release); void HandleDebugKeybind(const char* id, bool release); void SaveCustomDelaySettings(); void LoadCustomDelaySettings(); +void CopyResourceIcons(); void Load(AddonAPI* aApi); void Unload(); -std::string GetConfigFilePath() { +std::string GetAddonPath() { char gameDir[MAX_PATH]; GetModuleFileNameA(NULL, gameDir, MAX_PATH); @@ -107,7 +109,11 @@ std::string GetConfigFilePath() { std::string addonPath = gamePath + "\\addons\\GolemHelper"; CreateDirectoryA(addonPath.c_str(), NULL); - std::string configPath = addonPath + "\\config.ini"; + return addonPath; +} + +std::string GetConfigFilePath() { + std::string configPath = GetAddonPath() + "\\config.ini"; if (g_api) { char logBuffer[500]; @@ -118,6 +124,69 @@ std::string GetConfigFilePath() { return configPath; } +bool ExtractResourceToFile(HMODULE hModule, int resourceID, const std::string& filePath) { + HRSRC hRes = FindResourceA(hModule, MAKEINTRESOURCEA(resourceID), "PNG"); + if (!hRes) return false; + + HGLOBAL hData = LoadResource(hModule, hRes); + if (!hData) return false; + + LPVOID pData = LockResource(hData); + if (!pData) return false; + + DWORD dataSize = SizeofResource(hModule, hRes); + if (!dataSize) return false; + + std::ofstream file(filePath, std::ios::binary); + if (!file.is_open()) return false; + + file.write(static_cast(pData), dataSize); + file.close(); + + return true; +} + +void CopyResourceIcons() { + if (!g_api) return; + + std::string addonPath = GetAddonPath(); + std::string iconsPath = addonPath + "\\icons"; + CreateDirectoryA(iconsPath.c_str(), NULL); + + std::string iconDestPath = iconsPath + "\\GOLEM_HELPER_ICON.png"; + std::string iconHoverDestPath = iconsPath + "\\GOLEM_HELPER_ICON_HOVER.png"; + + if (GetFileAttributesA(iconDestPath.c_str()) != INVALID_FILE_ATTRIBUTES && + GetFileAttributesA(iconHoverDestPath.c_str()) != INVALID_FILE_ATTRIBUTES) { + g_api->Log(ELogLevel_INFO, "GolemHelper", "Icons already exist, skipping unpack"); + return; + } + + HMODULE hModule = GetModuleHandleA("GolemHelper.dll"); + if (!hModule) { + g_api->Log(ELogLevel_WARNING, "GolemHelper", "Failed to get module handle"); + return; + } + + if (ExtractResourceToFile(hModule, IDB_PNG1, iconDestPath)) { + char logBuffer[300]; + sprintf_s(logBuffer, "Extracted icon from resources: %s", iconDestPath.c_str()); + g_api->Log(ELogLevel_INFO, "GolemHelper", logBuffer); + } + else { + g_api->Log(ELogLevel_WARNING, "GolemHelper", "Failed to extract normal icon from resources"); + } + + if (ExtractResourceToFile(hModule, IDB_PNG2, iconHoverDestPath)) { + char logBuffer[300]; + sprintf_s(logBuffer, "Extracted hover icon from resources: %s", iconHoverDestPath.c_str()); + g_api->Log(ELogLevel_INFO, "GolemHelper", logBuffer); + } + else { + g_api->Log(ELogLevel_WARNING, "GolemHelper", "Failed to extract hover icon from resources"); + } +} + void SaveCustomDelaySettings() { if (!g_api) return; @@ -201,7 +270,7 @@ void RenderUI() { if (ImGui::Begin("GolemHelper", &g_state.showUI, ImGuiWindowFlags_AlwaysAutoResize)) { - ImGui::TextColored(ImVec4(0.2f, 0.8f, 1.0f, 1.0f), "GolemHelper v1.2.1.0"); + ImGui::TextColored(ImVec4(0.2f, 0.8f, 1.0f, 1.0f), "GolemHelper v1.2.2.0"); ImGui::Separator(); ImGui::Text("Status:"); @@ -826,6 +895,8 @@ void Load(AddonAPI* aApi) { LoadCustomDelaySettings(); + CopyResourceIcons(); + g_api->Renderer.Register(ERenderType_Render, RenderUI); g_api->Renderer.Register(ERenderType_OptionsRender, RenderOptions); @@ -838,10 +909,8 @@ void Load(AddonAPI* aApi) { g_api->InputBinds.RegisterWithStruct("GolemHelper.ToggleUI", HandleUIToggleKeybind, kb_empty); g_api->InputBinds.RegisterWithStruct("GolemHelper.DebugMouse", HandleDebugKeybind, kb_empty); - /* COMMENTO IN ATTESA DI CUSTOM ICON - g_api->Textures.GetOrCreateFromFile("GOLEM_HELPER_ICON", "addons/GolemHelper/GOLEM_HELPER_ICON.png"); - g_api->Textures.GetOrCreateFromFile("GOLEM_HELPER_ICON_HOVER", "addons/GolemHelper/GOLEM_HELPER_ICON_HOVER.png"); - */ + 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", @@ -851,7 +920,7 @@ void Load(AddonAPI* aApi) { "Toggle GolemHelper UI" ); - g_api->Log(ELogLevel_INFO, "GolemHelper", "=== GolemHelper v1.2.1.0 Loaded ==="); + g_api->Log(ELogLevel_INFO, "GolemHelper", "=== GolemHelper v1.2.2.0 Loaded ==="); g_api->Log(ELogLevel_INFO, "GolemHelper", "GolemHelper addon loaded successfully!"); } @@ -880,7 +949,7 @@ extern "C" __declspec(dllexport) AddonDefinition* GetAddonDef() { def.Signature = -424248; def.APIVersion = NEXUS_API_VERSION; def.Name = "GolemHelper"; - def.Version = { 1, 2, 1, 0 }; + def.Version = { 1, 2, 2, 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/resource.h b/GolemHelper/resource.h new file mode 100644 index 0000000..efee13e --- /dev/null +++ b/GolemHelper/resource.h @@ -0,0 +1,17 @@ +//{{NO_DEPENDENCIES}} +// File di inclusione generato con Microsoft Visual C++. +// Utilizzato da GolemHelper.rc +// +#define IDB_PNG1 104 +#define IDB_PNG2 105 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 106 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif