Skip to content

Commit

Permalink
add: Cheats + Player + Graphics
Browse files Browse the repository at this point in the history
  • Loading branch information
Asiern committed May 24, 2021
1 parent 982723d commit 06dd866
Show file tree
Hide file tree
Showing 10 changed files with 286 additions and 61 deletions.
36 changes: 36 additions & 0 deletions Source/ReplicantGadget/CheatsPanel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "CheatsPanel.hpp"


wxBEGIN_EVENT_TABLE(CheatsPanel, wxPanel)
wxEND_EVENT_TABLE()

CheatsPanel::CheatsPanel(wxNotebook* parent, ReplicantHook* hook) : wxPanel(parent, wxID_ANY)
{
this->hook = hook;
//Const sizes
const int margin = 10;
const int width = 365;

//Cheats
//m_CheatsBox = new wxStaticBox(this, wxID_ANY, "Cheats", wxPoint(margin, 110), wxSize(width - 30, 130), 1, wxStaticBoxNameStr);
m_InfiniteHealth = new wxCheckBox(this, wxID_ANY, "Infinite Health", wxPoint(margin, margin), wxDefaultSize, 0, wxDefaultValidator, wxCheckBoxNameStr);
m_InfiniteHealth->Bind(wxEVT_CHECKBOX, &CheatsPanel::InfiniteHealth, this);
m_InfiniteMagic = new wxCheckBox(this, wxID_ANY, "Infinite Magic", wxPoint(margin, 40), wxDefaultSize, 0, wxDefaultValidator, wxCheckBoxNameStr);
m_InfiniteMagic->Bind(wxEVT_CHECKBOX, &CheatsPanel::InfiniteMagic, this);

this->SetBackgroundColour(wxColor(255, 255, 255));
}

CheatsPanel::~CheatsPanel()
{
}

void CheatsPanel::InfiniteMagic(wxCommandEvent& evt)
{
hook->InfiniteMagic(m_InfiniteMagic->IsChecked());
}

void CheatsPanel::InfiniteHealth(wxCommandEvent& evt)
{
hook->InfiniteHealth(m_InfiniteHealth->IsChecked());
}
20 changes: 20 additions & 0 deletions Source/ReplicantGadget/CheatsPanel.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once
#include <wx/wx.h>
#include <wx/notebook.h>
#include "ReplicantHook/Source/ReplicantHook/ReplicantHook.hpp"
class CheatsPanel :public wxPanel
{
public:
//wxStaticBox* m_CheatsBox = nullptr;
wxCheckBox* m_InfiniteHealth = nullptr;
wxCheckBox* m_InfiniteMagic = nullptr;

CheatsPanel(wxNotebook* parent, ReplicantHook* hook);
~CheatsPanel();
private:
ReplicantHook* hook = nullptr;
void InfiniteHealth(wxCommandEvent& evt);
void InfiniteMagic(wxCommandEvent& evt);
wxDECLARE_EVENT_TABLE();
};

88 changes: 88 additions & 0 deletions Source/ReplicantGadget/GraphicsPanel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#include "GraphicsPanel.hpp"

wxBEGIN_EVENT_TABLE(GraphicsPanel, wxPanel)
wxEND_EVENT_TABLE()

GraphicsPanel::GraphicsPanel(wxNotebook* parent, ReplicantHook* hook) : wxPanel(parent, wxID_ANY)
{
this->hook = hook;
//Const sizes
const int margin = 10;
const int width = 365;

//Load Models
models.insert(std::pair<wxString, wxString>(wxString("Kaine"), wxString("kaineE")));
models.insert(std::pair<wxString, wxString>(wxString("Nier young"), wxString("nierB")));
models.insert(std::pair<wxString, wxString>(wxString("Nier old"), wxString("nierY")));
models.insert(std::pair<wxString, wxString>(wxString("Nier Father"), wxString("nierF")));
models.insert(std::pair<wxString, wxString>(wxString("Nier shadowlord"), wxString("nierT")));

modelsLabel = new wxStaticText(this, wxID_ANY, "Models", wxPoint(20, 30), wxDefaultSize, 0, wxStaticTextNameStr);

wxArrayString choices = getItems();
m_models = new wxListBox(this, wxID_ANY, wxPoint(20, 60), wxSize(315, 100), choices, 0, wxDefaultValidator, wxListBoxNameStr);

m_setModel = new wxButton(this, wxID_ANY, "Set Model", wxPoint(20, 180), wxDefaultSize, 0, wxDefaultValidator, wxButtonNameStr);
m_setModel->Bind(wxEVT_BUTTON, &GraphicsPanel::loadModel, this);

//Timer
m_Timer = new wxTimer();
m_Timer->Bind(wxEVT_TIMER, &GraphicsPanel::OnTimer, this);

this->SetBackgroundColour(wxColor(255, 255, 255));
m_Timer->Start(1000, wxTIMER_CONTINUOUS);
}

GraphicsPanel::~GraphicsPanel()
{
m_Timer->Stop();
delete m_Timer;
}

void GraphicsPanel::OnTimer(wxTimerEvent&)
{
if (hook->isHooked()) {

}
else {
}
}

void GraphicsPanel::loadModel(wxCommandEvent& evt)
{
if (wxNOT_FOUND == m_models->GetSelection()) {
wxMessageBox("Please select a model");
return;
}
wxString ID = getItemID(m_models->GetString(m_models->GetSelection()));
if (ID == "") {
wxMessageBox("Could not change the model");
return;
}
hook->setActorModel(std::string(ID));
}

wxArrayString GraphicsPanel::getItems()
{
std::map<wxString, wxString>::iterator it = models.begin();
std::map<wxString, wxString>::iterator end = models.end();
wxArrayString choices;

for (;it != end;it++) {
choices.Add(it->first);
}
return choices;
}

wxString GraphicsPanel::getItemID(wxString name)
{
std::map<wxString, wxString>::iterator it = models.begin();
std::map<wxString, wxString>::iterator end = models.end();

for (;it != end;it++) {
if (it->first == name) {
return it->second;
}
}
return "";
}
33 changes: 33 additions & 0 deletions Source/ReplicantGadget/GraphicsPanel.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#pragma once
#include <wx/wx.h>
#include <wx/notebook.h>
#include "ReplicantHook/Source/ReplicantHook/ReplicantHook.hpp"
#include <map>
class GraphicsPanel :public wxPanel
{
public:
//Timer
wxTimer* m_Timer = nullptr;

GraphicsPanel(wxNotebook* parent, ReplicantHook* hook);
~GraphicsPanel();

protected:
//TIMER
void OnTimer(wxTimerEvent&);
//POSITION EVT
void loadModel(wxCommandEvent& evt);
wxDECLARE_EVENT_TABLE();

private:
ReplicantHook* hook = nullptr;
std::map<wxString, wxString> models;
wxListBox* m_models = nullptr;
wxStaticText* modelsLabel = nullptr;
wxButton* m_setModel = nullptr;
wxArrayString getItems();
wxString getItemID(wxString name);

};


14 changes: 14 additions & 0 deletions Source/ReplicantGadget/Main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "Main.hpp"
#include "PlayerPanel.hpp"
#include "GraphicsPanel.hpp"
#include "CheatsPanel.hpp"

wxBEGIN_EVENT_TABLE(Main, wxFrame)
EVT_CLOSE(Main::OnClose)
Expand Down Expand Up @@ -27,9 +29,16 @@ Main::Main() : wxFrame(nullptr, wxID_ANY, "NieR Replicant Gadget", wxPoint(30, 3
//Create Notebook
notebook = new wxNotebook(this, wxID_ANY, wxPoint(margin, margin * 6), wxSize(width, 485), 0, wxNotebookNameStr);
Player = new PlayerPanel(notebook, hook);
Graphics = new GraphicsPanel(notebook, hook);
Cheats = new CheatsPanel(notebook, hook);

notebook->AddPage(Player, wxT("Player"), false, 0);
notebook->AddPage(Graphics, wxT("Graphics"), false, 1);
notebook->AddPage(Cheats, wxT("Cheats"), false, 2);

Player->Enable(false);
Graphics->Enable(false);
Cheats->Enable(false);

//Timer
m_Timer = new wxTimer();
Expand Down Expand Up @@ -59,12 +68,17 @@ void Main::updateComponents(void)
m_hooked->SetLabelText("Hooked: Yes");
m_status->SetLabel("Process: " + wxString::Format(wxT("%i"), hook->getProcessID()));
Player->Enable(true);
Graphics->Enable(true);
Cheats->Enable(true);

}
else {
m_hooked->SetForegroundColour(wxColor(244, 67, 54));
m_hooked->SetLabelText("Hooked: No");
m_status->SetLabel("Process: None");
Player->Enable(false);
Graphics->Enable(false);
Cheats->Enable(false);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Source/ReplicantGadget/Main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class Main : public wxFrame, public wxThreadHelper
//Tabs
wxNotebook* notebook = nullptr;
wxPanel* Player = nullptr;
wxPanel* Inventory = nullptr;
wxPanel* Weapons = nullptr;
wxPanel* Misc = nullptr;
wxPanel* Graphics = nullptr;
wxPanel* Cheats = nullptr;


public:
Main();
Expand Down
114 changes: 63 additions & 51 deletions Source/ReplicantGadget/PlayerPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,51 @@ PlayerPanel::PlayerPanel(wxNotebook* parent, ReplicantHook* hook) : wxPanel(pare
m_Timer->Bind(wxEVT_TIMER, &PlayerPanel::OnTimer, this);

//Status
m_StatsBox = new wxStaticBox(this, wxID_ANY, "Status", wxPoint(margin, margin), wxSize(width - 30, 90), 1, wxStaticBoxNameStr);
m_StatsBox = new wxStaticBox(this, wxID_ANY, "Status", wxPoint(margin, margin), wxSize(width - 30, 150), 1, wxStaticBoxNameStr);

m_Health = new wxStaticText(this, wxID_ANY, "Health: 0/0", wxPoint(margin * 3, margin + 30), wxDefaultSize, 0, wxStaticTextNameStr);
m_Level = new wxStaticText(this, wxID_ANY, "Level: 0", wxPoint(margin + (width - 2 * margin) / 2, margin + 30), wxDefaultSize, 0, wxStaticTextNameStr);
m_Funds = new wxStaticText(this, wxID_ANY, "Funds(G): 0", wxPoint(margin + (width - 2 * margin) / 2, margin + 60), wxDefaultSize, 0, wxStaticTextNameStr);
m_Zone = new wxStaticText(this, wxID_ANY, "Zone: ", wxPoint(margin * 3, margin + 60), wxDefaultSize, 0, wxStaticTextNameStr);

//Cheats
m_CheatsBox = new wxStaticBox(this, wxID_ANY, "Cheats", wxPoint(margin, 110), wxSize(width - 30, 130), 1, wxStaticBoxNameStr);
m_InfiniteHealth = new wxCheckBox(this, wxID_ANY, "Infinite Health", wxPoint(3 * margin, 140), wxDefaultSize, 0, wxDefaultValidator, wxCheckBoxNameStr);
m_InfiniteHealth->Bind(wxEVT_CHECKBOX, &PlayerPanel::InfiniteHealth, this);
m_InfiniteMagic = new wxCheckBox(this, wxID_ANY, "Infinite Magic", wxPoint(3 * margin, 170), wxDefaultSize, 0, wxDefaultValidator, wxCheckBoxNameStr);
m_InfiniteMagic->Bind(wxEVT_CHECKBOX, &PlayerPanel::InfiniteMagic, this);

//Position
wxSize TextCtrlSize = wxSize(80, 20);
m_PositionBox = new wxStaticBox(this, wxID_ANY, "Position", wxPoint(margin, 250), wxSize(width - 30, 200), 1, wxStaticBoxNameStr);
m_XText = new wxStaticText(this, wxID_ANY, "X", wxPoint(20, 303), wxDefaultSize, 0, wxStaticTextNameStr);
m_YText = new wxStaticText(this, wxID_ANY, "Y", wxPoint(20, 338), wxDefaultSize, 0, wxStaticTextNameStr);
m_ZText = new wxStaticText(this, wxID_ANY, "Z", wxPoint(20, 373), wxDefaultSize, 0, wxStaticTextNameStr);
m_XposTextCtrl = new wxTextCtrl(this, wxID_ANY, "0.000000", wxPoint(4 * margin, 300), TextCtrlSize, 0, wxDefaultValidator, wxTextCtrlNameStr);
m_YposTextCtrl = new wxTextCtrl(this, wxID_ANY, "0.000000", wxPoint(4 * margin, 335), TextCtrlSize, 0, wxDefaultValidator, wxTextCtrlNameStr);
m_ZposTextCtrl = new wxTextCtrl(this, wxID_ANY, "0.000000", wxPoint(4 * margin, 370), TextCtrlSize, 0, wxDefaultValidator, wxTextCtrlNameStr);
m_XposStoredTextCtrl = new wxTextCtrl(this, wxID_ANY, "0.000000", wxPoint(width / 2 - 4 * margin, 300), TextCtrlSize, 0, wxDefaultValidator, wxTextCtrlNameStr);
m_YposStoredTextCtrl = new wxTextCtrl(this, wxID_ANY, "0.000000", wxPoint(width / 2 - 4 * margin, 335), TextCtrlSize, 0, wxDefaultValidator, wxTextCtrlNameStr);
m_ZposStoredTextCtrl = new wxTextCtrl(this, wxID_ANY, "0.000000", wxPoint(width / 2 - 4 * margin, 370), TextCtrlSize, 0, wxDefaultValidator, wxTextCtrlNameStr);
m_CurrentPosText = new wxStaticText(this, wxID_ANY, "Current", wxPoint(4 * margin, 280), wxDefaultSize, 0, wxStaticTextNameStr);
m_StoredPosText = new wxStaticText(this, wxID_ANY, "Stored", wxPoint(width / 2 - 4 * margin, 280), wxDefaultSize, 0, wxStaticTextNameStr);
m_StorePosition = new wxButton(this, wxID_ANY, "Store", wxPoint(240, 300), wxSize(90, 25), 1, wxDefaultValidator, wxStaticBoxNameStr);
m_StorePosition->Bind(wxEVT_BUTTON, &PlayerPanel::StorePosition, this);
m_RestorePosition = new wxButton(this, wxID_ANY, "Restore", wxPoint(240, 335), wxSize(90, 25), 1, wxDefaultValidator, wxStaticBoxNameStr);
m_RestorePosition->Bind(wxEVT_BUTTON, &PlayerPanel::RestorePosition, this);
m_WarpButton = new wxButton(this, wxID_ANY, "Warp", wxPoint(240, 410), wxSize(90, 25), 1, wxDefaultValidator, wxStaticBoxNameStr);
m_WarpButton->Bind(wxEVT_BUTTON, &PlayerPanel::onWarpCLicked, this);
wxArrayString* Locations = new wxArrayString();
Locations->Add("Amusement (Beauvoir)", 1);
m_WarpComboBox = new wxComboBox(this, wxID_ANY, "", wxPoint(2 * margin, 410), wxSize((width - (6 * margin)) * 2 / 3, 20), *Locations, 0, wxDefaultValidator, wxComboBoxNameStr);

delete Locations;

m_Funds = new wxStaticText(this, wxID_ANY, "Gold(G): 0", wxPoint(margin * 3, margin + 60), wxDefaultSize, 0, wxStaticTextNameStr);
m_Magic = new wxStaticText(this, wxID_ANY, "Magic: ", wxPoint(margin + (width - 2 * margin) / 2, margin + 60), wxDefaultSize, 0, wxStaticTextNameStr);

m_Name = new wxStaticText(this, wxID_ANY, "Name: ", wxPoint(margin * 3, margin + 90), wxDefaultSize, 0, wxStaticTextNameStr);
m_Playtime = new wxStaticText(this, wxID_ANY, "Playtime: ", wxPoint(margin + (width - 2 * margin) / 2, margin + 90), wxDefaultSize, 0, wxStaticTextNameStr);

m_Zone = new wxStaticText(this, wxID_ANY, "Zone: ", wxPoint(margin * 3, margin + 120), wxDefaultSize, 0, wxStaticTextNameStr);

////Position
//wxSize TextCtrlSize = wxSize(80, 20);
//m_PositionBox = new wxStaticBox(this, wxID_ANY, "Position", wxPoint(margin, 250), wxSize(width - 30, 200), 1, wxStaticBoxNameStr);
//m_XText = new wxStaticText(this, wxID_ANY, "X", wxPoint(20, 303), wxDefaultSize, 0, wxStaticTextNameStr);
//m_YText = new wxStaticText(this, wxID_ANY, "Y", wxPoint(20, 338), wxDefaultSize, 0, wxStaticTextNameStr);
//m_ZText = new wxStaticText(this, wxID_ANY, "Z", wxPoint(20, 373), wxDefaultSize, 0, wxStaticTextNameStr);
//m_XposTextCtrl = new wxTextCtrl(this, wxID_ANY, "0.000000", wxPoint(4 * margin, 300), TextCtrlSize, 0, wxDefaultValidator, wxTextCtrlNameStr);
//m_YposTextCtrl = new wxTextCtrl(this, wxID_ANY, "0.000000", wxPoint(4 * margin, 335), TextCtrlSize, 0, wxDefaultValidator, wxTextCtrlNameStr);
//m_ZposTextCtrl = new wxTextCtrl(this, wxID_ANY, "0.000000", wxPoint(4 * margin, 370), TextCtrlSize, 0, wxDefaultValidator, wxTextCtrlNameStr);
//m_XposStoredTextCtrl = new wxTextCtrl(this, wxID_ANY, "0.000000", wxPoint(width / 2 - 4 * margin, 300), TextCtrlSize, 0, wxDefaultValidator, wxTextCtrlNameStr);
//m_YposStoredTextCtrl = new wxTextCtrl(this, wxID_ANY, "0.000000", wxPoint(width / 2 - 4 * margin, 335), TextCtrlSize, 0, wxDefaultValidator, wxTextCtrlNameStr);
//m_ZposStoredTextCtrl = new wxTextCtrl(this, wxID_ANY, "0.000000", wxPoint(width / 2 - 4 * margin, 370), TextCtrlSize, 0, wxDefaultValidator, wxTextCtrlNameStr);
//m_CurrentPosText = new wxStaticText(this, wxID_ANY, "Current", wxPoint(4 * margin, 280), wxDefaultSize, 0, wxStaticTextNameStr);
//m_StoredPosText = new wxStaticText(this, wxID_ANY, "Stored", wxPoint(width / 2 - 4 * margin, 280), wxDefaultSize, 0, wxStaticTextNameStr);
//m_StorePosition = new wxButton(this, wxID_ANY, "Store", wxPoint(240, 300), wxSize(90, 25), 1, wxDefaultValidator, wxStaticBoxNameStr);
//m_StorePosition->Bind(wxEVT_BUTTON, &PlayerPanel::StorePosition, this);
//m_RestorePosition = new wxButton(this, wxID_ANY, "Restore", wxPoint(240, 335), wxSize(90, 25), 1, wxDefaultValidator, wxStaticBoxNameStr);
//m_RestorePosition->Bind(wxEVT_BUTTON, &PlayerPanel::RestorePosition, this);
//m_WarpButton = new wxButton(this, wxID_ANY, "Warp", wxPoint(240, 410), wxSize(90, 25), 1, wxDefaultValidator, wxStaticBoxNameStr);
//m_WarpButton->Bind(wxEVT_BUTTON, &PlayerPanel::onWarpCLicked, this);
//wxArrayString* Locations = new wxArrayString();
//Locations->Add("Amusement (Beauvoir)", 1);
//m_WarpComboBox = new wxComboBox(this, wxID_ANY, "", wxPoint(2 * margin, 410), wxSize((width - (6 * margin)) * 2 / 3, 20), *Locations, 0, wxDefaultValidator, wxComboBoxNameStr);

//delete Locations;

//Attributes
m_AttributesBox = new wxStaticBox(this, wxID_ANY, "Attributes", wxPoint(margin, 180), wxSize(width - 30, 260), 1, wxStaticBoxNameStr);
m_SetLevel = new wxStaticText(this, wxID_ANY, "Level", wxPoint(margin * 3, 210), wxDefaultSize, 0, wxStaticTextNameStr);
m_LevelTextCtrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxPoint(margin * 2 + 100, 210), wxDefaultSize, 0, wxDefaultValidator, wxTextCtrlNameStr);
m_setLevelBtn = new wxButton(this, wxID_ANY, "Set Level", wxPoint(240, 210), wxDefaultSize, 0, wxDefaultValidator, wxButtonNameStr);
m_setLevelBtn->Bind(wxEVT_BUTTON, &PlayerPanel::setLevel, this);

this->SetBackgroundColour(wxColor(255, 255, 255));
m_Timer->Start(1000, wxTIMER_CONTINUOUS);
Expand All @@ -68,28 +75,23 @@ void PlayerPanel::OnTimer(wxTimerEvent&)
{
if (hook->isHooked()) {
//Player
m_Level->SetLabel("Level: " + wxString::Format(wxT("%i"), hook->getLevel()));
m_Level->SetLabel("Level: " + wxString::Format(wxT("%i"), hook->getLevel() + 1));
m_Health->SetLabel("Health: " + wxString::Format(wxT("%i"), hook->getHealth()));
m_Funds->SetLabel("Funds(G): " + wxString::Format(wxT("%i"), hook->getGold()));
m_Zone->SetLabel("Zone: " + wxString::Format(wxT("%i"), hook->getLevel()));
//Position
m_XposTextCtrl->SetLabel(wxString::Format(wxT("%f"), hook->getX()));
m_YposTextCtrl->SetLabel(wxString::Format(wxT("%f"), hook->getY()));
m_ZposTextCtrl->SetLabel(wxString::Format(wxT("%f"), hook->getZ()));
m_Funds->SetLabel("Gold(G): " + wxString::Format(wxT("%i"), hook->getGold()));
m_Magic->SetLabel("Magic: " + wxString::Format(wxT("%f"), (float)hook->getMagic()));
m_Name->SetLabel("Name: " + hook->getName());
m_Playtime->SetLabel("Playtime: " + wxString::Format(wxT("%f"), hook->getPlaytime()));
m_Zone->SetLabel("Zone: " + hook->getZone());
////Position
//m_XposTextCtrl->SetLabel(wxString::Format(wxT("%f"), hook->getX()));
//m_YposTextCtrl->SetLabel(wxString::Format(wxT("%f"), hook->getY()));
//m_ZposTextCtrl->SetLabel(wxString::Format(wxT("%f"), hook->getZ()));
}
else {
}
}

void PlayerPanel::InfiniteMagic(wxCommandEvent& evt)
{
hook->InfiniteMagic(m_InfiniteMagic->IsChecked());
}

void PlayerPanel::InfiniteHealth(wxCommandEvent& evt)
{
hook->InfiniteHealth(m_InfiniteHealth->IsChecked());
}


void PlayerPanel::StorePosition(wxCommandEvent& evt)
Expand All @@ -112,6 +114,16 @@ void PlayerPanel::RestorePosition(wxCommandEvent& evt)
hook->setPosition(this->StoredX, this->StoredY, this->StoredZ);
}

void PlayerPanel::setLevel(wxCommandEvent& evt)
{
long level;
if (!m_LevelTextCtrl->GetValue().ToLong(&level)) {
wxMessageBox("Could not set the level");
return;
}
hook->setLevel(level - 1);
}

constexpr unsigned int str2int(const char* str, int h = 0)
{
return !str[h] ? 5381 : (str2int(str, h + 1) * 33) ^ str[h];
Expand Down
Loading

0 comments on commit 06dd866

Please sign in to comment.