-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
452 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "imgui.h" | ||
#include "Imgui.hpp" | ||
|
||
namespace Xash::GUI | ||
{ | ||
void Imgui::DrawConfigPanel() | ||
{ | ||
ImGui::Text("--------CONFIG--------"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "imgui.h" | ||
#include "Imgui.hpp" | ||
#include "System.hpp" | ||
#include "ModsManager.hpp" | ||
|
||
namespace Xash::GUI | ||
{ | ||
void Imgui::DrawEjectPanel() | ||
{ | ||
Injector::ModsManager &modsManager = Injector::ModsManager::getInstance(); | ||
auto &loadedMods = modsManager.getLoadedMods(); | ||
|
||
if (loadedMods.empty()) | ||
{ | ||
ImGui::Text("No mod loaded"); | ||
return; | ||
} | ||
|
||
char unloadMethodNameBuffer[256] = {0}; | ||
strcpy_s(unloadMethodNameBuffer, mModInfos.modUnloadMethod.c_str()); | ||
ImGui::InputText("Unload method", unloadMethodNameBuffer, sizeof(unloadMethodNameBuffer)); | ||
mModInfos.modUnloadMethod = unloadMethodNameBuffer; | ||
|
||
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); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#include "imgui.h" | ||
#include "Imgui.hpp" | ||
#include "System.hpp" | ||
#include "ModsManager.hpp" | ||
|
||
namespace Xash::GUI | ||
{ | ||
|
||
void Imgui::DrawInjectButton() | ||
{ | ||
if (ImGui::Button("Inject")) | ||
{ | ||
Xash::Injector::ModsManager &modsManager = Xash::Injector::ModsManager::getInstance(); | ||
mModInfos.targetedProcessName = mProcessesNames[mSelectedProcessIndex]; | ||
modsManager.LoadMod(mModInfos); | ||
} | ||
} | ||
|
||
void Imgui::DrawProcessesBox() | ||
{ | ||
if (ImGui::BeginCombo("##combo", mProcessesNames[mSelectedProcessIndex].c_str())) | ||
{ | ||
for (int i = 0; i < mProcessesNames.size(); i++) | ||
{ | ||
bool isSelected = (mSelectedProcessIndex == i); | ||
if (ImGui::Selectable(mProcessesNames[i].c_str(), isSelected)) | ||
{ | ||
mSelectedProcessIndex = i; | ||
} | ||
if (isSelected) | ||
{ | ||
ImGui::SetItemDefaultFocus(); | ||
} | ||
} | ||
ImGui::EndCombo(); | ||
} | ||
} | ||
|
||
void Imgui::DrawDllBox() | ||
{ | ||
static std::string selectedFile = "Select mod DLL"; | ||
|
||
if (ImGui::Selectable(selectedFile.c_str())) | ||
{ | ||
OPENFILENAME ofn; | ||
TCHAR filePath[MAX_PATH] = {0}; | ||
TCHAR currentDir[MAX_PATH] = {0}; | ||
GetCurrentDirectory(MAX_PATH, currentDir); | ||
|
||
ZeroMemory(&ofn, sizeof(ofn)); | ||
ofn.lStructSize = sizeof(ofn); | ||
ofn.hwndOwner = NULL; | ||
ofn.lpstrFilter = "DLL\0*.dll\0"; | ||
ofn.lpstrFile = filePath; | ||
ofn.nMaxFile = MAX_PATH; | ||
ofn.lpstrTitle = "Select DLL"; | ||
ofn.Flags = OFN_FILEMUSTEXIST; | ||
|
||
if (GetOpenFileName(&ofn)) | ||
{ | ||
SetCurrentDirectory(currentDir); | ||
selectedFile = ofn.lpstrFile; | ||
mModInfos.modPath = selectedFile; | ||
} | ||
} | ||
} | ||
|
||
void Imgui::DrawInjectInputs() | ||
{ | ||
char namespaceBuffer[256] = {0}; | ||
char classNameBuffer[256] = {0}; | ||
char loadMethodNameBuffer[256] = {0}; | ||
|
||
strcpy_s(namespaceBuffer, mModInfos.modNamespace.c_str()); | ||
strcpy_s(classNameBuffer, mModInfos.modClass.c_str()); | ||
strcpy_s(loadMethodNameBuffer, mModInfos.modInitMethod.c_str()); | ||
|
||
ImGui::InputText("Namespace", namespaceBuffer, IM_ARRAYSIZE(namespaceBuffer)); | ||
ImGui::InputText("Class", classNameBuffer, IM_ARRAYSIZE(classNameBuffer)); | ||
ImGui::InputText( | ||
"Load Method", loadMethodNameBuffer, IM_ARRAYSIZE(loadMethodNameBuffer) | ||
); | ||
|
||
mModInfos.modNamespace = namespaceBuffer; | ||
mModInfos.modClass = classNameBuffer; | ||
mModInfos.modInitMethod = loadMethodNameBuffer; | ||
} | ||
|
||
void Imgui::DrawInjectPanel() | ||
{ | ||
DrawProcessesBox(); | ||
DrawDllBox(); | ||
DrawInjectInputs(); | ||
DrawInjectButton(); | ||
} | ||
} // namespace Xash::GUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "imgui.h" | ||
#include "Imgui.hpp" | ||
|
||
namespace Xash::GUI | ||
{ | ||
void Imgui::DrawSettingsPanel() | ||
{ | ||
ImGui::Text("--------SETTINGS--------"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include <unordered_map> | ||
#include "Imgui.hpp" | ||
#include "imgui.h" | ||
|
||
static void addSideBarStyle() | ||
{ | ||
ImVec4 transparent = ImVec4(0.0f, 0.0f, 0.0f, 0.0f); | ||
ImVec4 hoverColor = ImVec4(0.7f, 0.7f, 0.7f, 1.0f); | ||
ImVec4 selectedColor = ImVec4(0.4f, 0.4f, 0.4f, 1.0f); | ||
|
||
ImGui::PushStyleColor(ImGuiCol_Button, transparent); | ||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, hoverColor); | ||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, selectedColor); | ||
|
||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 5.0f); | ||
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f)); | ||
} | ||
|
||
static void removeSideBarStyle() | ||
{ | ||
ImGui::PopStyleColor(3); | ||
ImGui::PopStyleVar(2); | ||
} | ||
|
||
static void createSideBarWindow() | ||
{ | ||
ImGui::Begin("##sidebar", nullptr, | ||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar); | ||
ImGui::SetWindowSize(ImVec2(120, ImGui::GetIO().DisplaySize.y)); | ||
ImGui::SetWindowPos(ImVec2(0, 0)); | ||
} | ||
|
||
void Xash::GUI::Imgui::DrawSideBar() | ||
{ | ||
static std::unordered_map<ActivePanel, std::string> panelNames = { | ||
{ ActivePanel::INJECT, "Inject" }, | ||
{ ActivePanel::EJECT, "Loaded Dll" }, | ||
{ ActivePanel::CONFIG, "Config" }, | ||
{ ActivePanel::SETTINGS, "Settings" } | ||
}; | ||
|
||
createSideBarWindow(); | ||
addSideBarStyle(); | ||
|
||
for (auto &panel : panelNames) | ||
{ | ||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 20); | ||
ImGui::SetCursorPosX(10); | ||
|
||
if (ImGui::Button(panel.second.c_str(), ImVec2(200, 25))) | ||
{ | ||
mActivePanel = panel.first; | ||
} | ||
} | ||
|
||
removeSideBarStyle(); | ||
ImGui::End(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
namespace Xash::Injector | ||
{ | ||
struct ModInfos | ||
{ | ||
std::string modPath; | ||
std::string modNamespace; | ||
std::string modClass; | ||
std::string modInitMethod; | ||
std::string modUnloadMethod; | ||
std::string targetedProcessName; | ||
|
||
bool operator==(const ModInfos &other) const | ||
{ | ||
if (modPath != other.modPath || | ||
modNamespace != other.modNamespace || | ||
modClass != other.modClass) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
}; | ||
} // namespace Xash::Injector |
Oops, something went wrong.