From 90d95349fd7dabf0cf7314925c762620eed7f05a Mon Sep 17 00:00:00 2001 From: Tenshi Date: Sun, 12 Nov 2023 04:34:08 +0100 Subject: [PATCH] Add separator for each mod --- src/GUI/EjectPanel.cpp | 31 ++++++++----- src/GUI/Imgui.hpp | 103 ++++++++++++++++++++++------------------- 2 files changed, 76 insertions(+), 58 deletions(-) diff --git a/src/GUI/EjectPanel.cpp b/src/GUI/EjectPanel.cpp index 60fa428..6284cd2 100644 --- a/src/GUI/EjectPanel.cpp +++ b/src/GUI/EjectPanel.cpp @@ -5,6 +5,23 @@ namespace Xash::GUI { + void Imgui::DrawModInfos(const Injector::ModInfos &loadedModInfos, + const std::pair &loadedMod) + { + Injector::ModsManager &modsManager = Injector::ModsManager::getInstance(); + + ImGui::Text("Mod name: %s", loadedModInfos.modClass.c_str()); + ImGui::Text("Mod Namespace: %s", loadedModInfos.modNamespace.c_str()); + ImGui::Text("Mod Path: %s", loadedModInfos.modPath.c_str()); + ImGui::Text("Targeted process: %s", loadedModInfos.targetedProcessName.c_str()); + if (ImGui::Button("Eject")) + { + Injector::ModInfos newModInfos = loadedMod.first; + newModInfos.modUnloadMethod = mModInfos.modUnloadMethod; + modsManager.UnLoadMod(newModInfos); + } + } + void Imgui::DrawEjectPanel() { Injector::ModsManager &modsManager = Injector::ModsManager::getInstance(); @@ -20,20 +37,12 @@ namespace Xash::GUI strcpy_s(unloadMethodNameBuffer, mModInfos.modUnloadMethod.c_str()); ImGui::InputText("Unload method", unloadMethodNameBuffer, sizeof(unloadMethodNameBuffer)); mModInfos.modUnloadMethod = unloadMethodNameBuffer; + ImGui::Separator(); for (auto &loadedMod : loadedMods) { - ImGui::Text("--------------------"); - ImGui::Text("Mod name: %s", loadedMod.first.modClass.c_str()); - ImGui::Text("Mod Namespace: %s", loadedMod.first.modNamespace.c_str()); - ImGui::Text("Mod Path: %s", loadedMod.first.modPath.c_str()); - ImGui::Text("Targeted process: %s", loadedMod.first.targetedProcessName.c_str()); - if (ImGui::Button("Eject")) - { - Injector::ModInfos modInfos = loadedMod.first; - modInfos.modUnloadMethod = mModInfos.modUnloadMethod; - modsManager.UnLoadMod(modInfos); - } + DrawModInfos(loadedMod.first, loadedMod); + ImGui::Separator(); } } } diff --git a/src/GUI/Imgui.hpp b/src/GUI/Imgui.hpp index aa27e49..a598cb1 100644 --- a/src/GUI/Imgui.hpp +++ b/src/GUI/Imgui.hpp @@ -5,59 +5,68 @@ #include #include #include +#include #include "ModInfos.hpp" +#include "MonoModule.hpp" #include "imgui.h" -namespace Xash::GUI +namespace Xash { - class Imgui + namespace GUI { - static constexpr ImVec2 mainWindowPos = ImVec2(120, 0); + class Imgui + { + static constexpr ImVec2 mainWindowPos = ImVec2(120, 0); - public: - Imgui(); - ~Imgui(); + public: + Imgui(); + ~Imgui(); - void InitWin32AndDX11( - const HWND &window, Microsoft::WRL::ComPtr device, - Microsoft::WRL::ComPtr deviceContext - ); - void Draw(); - void Render(); + void InitWin32AndDX11( + const HWND &window, Microsoft::WRL::ComPtr device, + Microsoft::WRL::ComPtr deviceContext + ); + void Draw(); + void Render(); - private: - enum class ActivePanel : uint8_t - { - INJECT, - EJECT, - CONFIG, - SETTINGS - }; + private: + enum class ActivePanel : uint8_t + { + INJECT, + EJECT, + CONFIG, + SETTINGS + }; + + void DrawSideBar(); + void DrawPanels(); + void MaximizeMainWindow(); + + // INJECT + void DrawInjectPanel(); + void DrawProcessesBox(); + void DrawDllBox(); + void DrawInjectInputs(); + void DrawInjectButton(); + void GetProcessesNames(); - void DrawSideBar(); - void DrawPanels(); - void MaximizeMainWindow(); - - // INJECT - void DrawInjectPanel(); - void DrawProcessesBox(); - void DrawDllBox(); - void DrawInjectInputs(); - void DrawInjectButton(); - void GetProcessesNames(); - - // EJECT - void DrawEjectPanel(); - - // CONFIG - void DrawConfigPanel(); - - // SETTINGS - void DrawSettingsPanel(); - - Injector::ModInfos mModInfos; - std::size_t mSelectedProcessIndex = 0; - std::vector mProcessesNames; - ActivePanel mActivePanel = ActivePanel::INJECT; - }; -} // namespace Xash::GUI + // EJECT + void DrawEjectPanel(); + void DrawModInfos( + const Injector::ModInfos &modInfos, + const std::pair &loadedMod + ); + + // CONFIG + void DrawConfigPanel(); + + // SETTINGS + void DrawSettingsPanel(); + + Injector::ModInfos mModInfos; + std::size_t mSelectedProcessIndex = 0; + std::vector mProcessesNames; + ActivePanel mActivePanel = ActivePanel::INJECT; + }; + } // namespace GUI +} // namespace Xash