Skip to content

Commit

Permalink
Add separator for each mod
Browse files Browse the repository at this point in the history
  • Loading branch information
TTENSHII committed Nov 16, 2023
1 parent 43398b3 commit 90d9534
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 58 deletions.
31 changes: 20 additions & 11 deletions src/GUI/EjectPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@

namespace Xash::GUI
{
void Imgui::DrawModInfos(const Injector::ModInfos &loadedModInfos,
const std::pair<Injector::ModInfos, Injector::MonoModule> &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();
Expand All @@ -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();
}
}
}
103 changes: 56 additions & 47 deletions src/GUI/Imgui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,59 +5,68 @@
#include <d3d11.h>
#include <vector>
#include <string>
#include <utility>
#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<ID3D11Device> device,
Microsoft::WRL::ComPtr<ID3D11DeviceContext> deviceContext
);
void Draw();
void Render();
void InitWin32AndDX11(
const HWND &window, Microsoft::WRL::ComPtr<ID3D11Device> device,
Microsoft::WRL::ComPtr<ID3D11DeviceContext> 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<std::string> mProcessesNames;
ActivePanel mActivePanel = ActivePanel::INJECT;
};
} // namespace Xash::GUI
// EJECT
void DrawEjectPanel();
void DrawModInfos(
const Injector::ModInfos &modInfos,
const std::pair<Injector::ModInfos, Injector::MonoModule> &loadedMod
);

// CONFIG
void DrawConfigPanel();

// SETTINGS
void DrawSettingsPanel();

Injector::ModInfos mModInfos;
std::size_t mSelectedProcessIndex = 0;
std::vector<std::string> mProcessesNames;
ActivePanel mActivePanel = ActivePanel::INJECT;
};
} // namespace GUI
} // namespace Xash

0 comments on commit 90d9534

Please sign in to comment.