Refactor code
This commit is contained in:
parent
216630d4c1
commit
9c5d399e18
@ -105,134 +105,11 @@ void CheatMenu::DrawWindow()
|
|||||||
Overlay::Draw();
|
Overlay::Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatMenu::ProcessPages()
|
|
||||||
{
|
|
||||||
static void* pCallback;
|
|
||||||
ImVec2 size = Widget::CalcSize(3, false);
|
|
||||||
ImGuiStyle &style = ImGui::GetStyle();
|
|
||||||
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
|
|
||||||
m_nMenuPage = Updater::IsUpdateAvailable() ? eMenuPages::UPDATE : m_nMenuPage;
|
|
||||||
|
|
||||||
// Check once if it's anniversary day
|
|
||||||
static bool aniCheckDone;
|
|
||||||
if (!aniCheckDone)
|
|
||||||
{
|
|
||||||
SYSTEMTIME st;
|
|
||||||
GetSystemTime(&st);
|
|
||||||
|
|
||||||
if (st.wMonth == 3 && st.wDay == 28)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* We don't want to be annoying and
|
|
||||||
* show anniversary screen on every game start
|
|
||||||
*/
|
|
||||||
bool flag = gConfig.Get("Window.AnniversaryShown", false);
|
|
||||||
|
|
||||||
if (!flag)
|
|
||||||
{
|
|
||||||
gConfig.Set("Window.AnniversaryShown", true);
|
|
||||||
m_nMenuPage = eMenuPages::ANNIVERSARY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
aniCheckDone = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImDrawList *pDrawList = ImGui::GetWindowDrawList();
|
|
||||||
for (size_t i = 0; i < m_headerList.size(); ++i)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* For welcome & update pages
|
|
||||||
* They don't need to add item in the header list
|
|
||||||
*/
|
|
||||||
if (m_headerList[i].skipHeader)
|
|
||||||
{
|
|
||||||
if (m_nMenuPage == m_headerList[i].page)
|
|
||||||
{
|
|
||||||
pCallback = m_headerList[i].pFunc;
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* text = m_headerList[i].name.c_str();
|
|
||||||
|
|
||||||
ImVec4 color;
|
|
||||||
if (m_headerList[i].page == m_nMenuPage)
|
|
||||||
{
|
|
||||||
color = style.Colors[ImGuiCol_ButtonActive];
|
|
||||||
pCallback = m_headerList[i].pFunc;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
color = style.Colors[ImGuiCol_Button];
|
|
||||||
|
|
||||||
if (ImGui::InvisibleButton(text, size))
|
|
||||||
{
|
|
||||||
m_nMenuPage = m_headerList[i].page;
|
|
||||||
size_t curPage = static_cast<size_t>(m_headerList[i].page);
|
|
||||||
gConfig.Set("Window.CurrentPage", curPage);
|
|
||||||
pCallback = m_headerList[i].pFunc;
|
|
||||||
Updater::ResetUpdaterState();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui::IsItemHovered())
|
|
||||||
color = style.Colors[ImGuiCol_ButtonHovered];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Window rounding flags
|
|
||||||
* TODO: hardcoded atm
|
|
||||||
*/
|
|
||||||
ImDrawFlags flags = ImDrawFlags_RoundCornersNone;
|
|
||||||
if (i == 0) flags = ImDrawFlags_RoundCornersTopLeft;
|
|
||||||
if (i == 2) flags = ImDrawFlags_RoundCornersTopRight;
|
|
||||||
if (i == 6) flags = ImDrawFlags_RoundCornersBottomLeft;
|
|
||||||
if (i == 8) flags = ImDrawFlags_RoundCornersBottomRight;
|
|
||||||
|
|
||||||
ImVec2 min = ImGui::GetItemRectMin();
|
|
||||||
ImVec2 max = ImGui::GetItemRectMax();
|
|
||||||
ImVec2 size = ImGui::CalcTextSize(text);
|
|
||||||
pDrawList->AddRectFilled(min, max, ImGui::GetColorU32(color), style.FrameRounding, flags);
|
|
||||||
ImGui::RenderTextClipped(min + style.FramePadding, max - style.FramePadding, text, NULL, &size, style.ButtonTextAlign);
|
|
||||||
|
|
||||||
if (i % 3 != 2)
|
|
||||||
{
|
|
||||||
ImGui::SameLine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ImGui::PopStyleVar();
|
|
||||||
ImGui::Dummy(ImVec2(0, 10));
|
|
||||||
|
|
||||||
if (pCallback != nullptr && ImGui::BeginChild("HEADERCONTENT"))
|
|
||||||
{
|
|
||||||
static_cast<void(*)()>(pCallback)();
|
|
||||||
ImGui::EndChild();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CheatMenu::GenHeaderList()
|
|
||||||
{
|
|
||||||
CheatMenu::m_headerList =
|
|
||||||
{
|
|
||||||
{TEXT_S("Window.TeleportPage"), &Teleport::ShowPage, eMenuPages::TELEPORT},
|
|
||||||
{TEXT_S("Window.PlayerPage"), &Player::ShowPage, eMenuPages::PLAYER},
|
|
||||||
{TEXT_S("Window.PedPage"), &Ped::ShowPage, eMenuPages::PED},
|
|
||||||
{TEXT_S("Window.ScenePage"), &ScenePage::Draw, eMenuPages::SCENE},
|
|
||||||
{TEXT_S("Window.VehiclePage"), &Vehicle::ShowPage, eMenuPages::VEHICLE},
|
|
||||||
{TEXT_S("Window.WeaponPage"), &Weapon::ShowPage, eMenuPages::WEAPON},
|
|
||||||
{TEXT_S("Window.GamePage"), &Game::ShowPage, eMenuPages::GAME},
|
|
||||||
{TEXT_S("Window.VisualPage"), &Visual::ShowPage, eMenuPages::VISUAL},
|
|
||||||
{TEXT_S("Window.MenuPage"), &Menu::ShowPage, eMenuPages::MENU},
|
|
||||||
{"Welcome", &ShowWelcomePage, eMenuPages::WELCOME, true},
|
|
||||||
{"Update", &ShowUpdatePage, eMenuPages::UPDATE, true},
|
|
||||||
{"Anniversary", &ShowAnniversaryPage, eMenuPages::ANNIVERSARY, true}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
void CheatMenu::Init()
|
void CheatMenu::Init()
|
||||||
{
|
{
|
||||||
if (!std::filesystem::exists(PLUGIN_PATH((char*)FILE_NAME)))
|
if (!std::filesystem::exists(PLUGIN_PATH((char*)FILE_NAME)))
|
||||||
{
|
{
|
||||||
Log::Print<eLogLevel::Error>(TEXT("Menu.CheatMenuNoDir"));
|
Log::Print<eLogLevel::Error>("Failed to find CheatMenu directory!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +136,7 @@ void CheatMenu::Init()
|
|||||||
Teleport::Init();
|
Teleport::Init();
|
||||||
Vehicle::Init();
|
Vehicle::Init();
|
||||||
Visual::Init();
|
Visual::Init();
|
||||||
Weapon::Init();
|
WeaponPage::Init();
|
||||||
Overlay::Init();
|
Overlay::Init();
|
||||||
|
|
||||||
Events::processScriptsEvent += []()
|
Events::processScriptsEvent += []()
|
||||||
@ -295,88 +172,7 @@ void CheatMenu::Init()
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatMenu::ShowAnniversaryPage()
|
bool CheatMenu::IsBeingDrawn()
|
||||||
{
|
|
||||||
Widget::TextCentered("Happy Anniversary!");
|
|
||||||
ImGui::NewLine();
|
|
||||||
|
|
||||||
ImGui::TextWrapped("On this day, in 2019, the first public version of menu was released in MixMods Forum."
|
|
||||||
" It's been a blast working on it and I've learned a lot in the process.\n\nThanks to you and everyone who used or"
|
|
||||||
" contributed to the modification in any form or shape.");
|
|
||||||
|
|
||||||
ImGui::NewLine();
|
|
||||||
ImGui::TextWrapped("Feel free to star the GitHub repo or join the discord server and provide feedback, ideas, or suggestions.");
|
|
||||||
ImGui::NewLine();
|
|
||||||
|
|
||||||
if (ImGui::Button(TEXT("Menu.DiscordServer"), ImVec2(Widget::CalcSize(3))))
|
|
||||||
{
|
|
||||||
OPEN_LINK(DISCORD_INVITE);
|
|
||||||
}
|
|
||||||
ImGui::SameLine();
|
|
||||||
if (ImGui::Button(TEXT("Menu.GitHubRepo"), ImVec2(Widget::CalcSize(3))))
|
|
||||||
{
|
|
||||||
OPEN_LINK(GITHUB_LINK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CheatMenu::ShowWelcomePage()
|
|
||||||
{
|
|
||||||
ImGui::NewLine();
|
|
||||||
|
|
||||||
Widget::TextCentered(TEXT("Menu.WelcomeMSG"));
|
|
||||||
Widget::TextCentered(std::format("{}: Grinch_",TEXT("Menu.Author")));
|
|
||||||
|
|
||||||
ImGui::NewLine();
|
|
||||||
ImGui::TextWrapped(TEXT("Menu.EnsureLatest"));
|
|
||||||
if (ImGui::Button(TEXT("Menu.DiscordServer"), ImVec2(Widget::CalcSize(2))))
|
|
||||||
{
|
|
||||||
OPEN_LINK(DISCORD_INVITE);
|
|
||||||
}
|
|
||||||
ImGui::SameLine();
|
|
||||||
if (ImGui::Button(TEXT("Menu.GitHubRepo"), ImVec2(Widget::CalcSize(2))))
|
|
||||||
{
|
|
||||||
OPEN_LINK(GITHUB_LINK);
|
|
||||||
}
|
|
||||||
ImGui::NewLine();
|
|
||||||
ImGui::TextWrapped(TEXT("Menu.BugDisclaimer"));
|
|
||||||
ImGui::Dummy(ImVec2(0, 20));
|
|
||||||
Widget::TextCentered(TEXT("Menu.PatreonText"));
|
|
||||||
if (ImGui::Button(TEXT("Menu.Patreon"), ImVec2(Widget::CalcSize(1))))
|
|
||||||
{
|
|
||||||
OPEN_LINK("https://www.patreon.com/grinch_");
|
|
||||||
}
|
|
||||||
ImGui::Dummy(ImVec2(0, 30));
|
|
||||||
Widget::TextCentered(TEXT("Menu.CopyrightDisclaimer"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CheatMenu::ShowUpdatePage()
|
|
||||||
{
|
|
||||||
std::string ver = Updater::GetUpdateVersion();
|
|
||||||
ImGui::Dummy(ImVec2(0, 20));
|
|
||||||
Widget::TextCentered(TEXT("Menu.NewVersion"));
|
|
||||||
Widget::TextCentered(std::format("{}: {}", TEXT("Menu.CurrentVersion"), MENU_VERSION));
|
|
||||||
Widget::TextCentered(TEXT("Menu.LatestVersion") + ver);
|
|
||||||
ImGui::Dummy(ImVec2(0, 10));
|
|
||||||
ImGui::TextWrapped(TEXT("Menu.UpdaterInfo1"));
|
|
||||||
ImGui::Dummy(ImVec2(0, 10));
|
|
||||||
ImGui::TextWrapped(TEXT("Menu.UpdaterInfo2"));
|
|
||||||
|
|
||||||
ImGui::Dummy(ImVec2(0, 5));
|
|
||||||
if (ImGui::Button(TEXT("Menu.DiscordServer"), ImVec2(Widget::CalcSize(2))))
|
|
||||||
{
|
|
||||||
OPEN_LINK(DISCORD_INVITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::SameLine();
|
|
||||||
|
|
||||||
if (ImGui::Button(TEXT("Menu.DownloadPage"), Widget::CalcSize(2)))
|
|
||||||
{
|
|
||||||
ShellExecute(NULL, "open", std::string("https://github.com/user-grinch/Cheat-Menu/releases/tag/" +
|
|
||||||
ver).c_str(), NULL, NULL, SW_SHOWNORMAL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CheatMenu::IsMenuShown()
|
|
||||||
{
|
{
|
||||||
return m_bShowMenu;
|
return m_bShowMenu;
|
||||||
}
|
}
|
||||||
@ -447,7 +243,7 @@ void CheatMenu::ApplyStyle()
|
|||||||
style->Colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.6f);
|
style->Colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.6f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatMenu::ResetMenuSize()
|
void CheatMenu::ResetSize()
|
||||||
{
|
{
|
||||||
m_fMenuSize.x = screen::GetScreenWidth() / 4.0f;
|
m_fMenuSize.x = screen::GetScreenWidth() / 4.0f;
|
||||||
m_fMenuSize.y = screen::GetScreenHeight() / 1.2f;
|
m_fMenuSize.y = screen::GetScreenHeight() / 1.2f;
|
||||||
|
@ -8,38 +8,16 @@
|
|||||||
class CheatMenu
|
class CheatMenu
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
enum class eMenuPages
|
|
||||||
{
|
|
||||||
ANNIVERSARY, GAME, MENU, NONE, PED, PLAYER, SCENE, TELEPORT, UPDATE, VEHICLE, VISUAL, WEAPON, WELCOME
|
|
||||||
};
|
|
||||||
struct HeaderData
|
|
||||||
{
|
|
||||||
std::string name;
|
|
||||||
void *pFunc;
|
|
||||||
eMenuPages page;
|
|
||||||
bool skipHeader = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline eMenuPages m_nMenuPage = eMenuPages::WELCOME; // current visible menu page
|
|
||||||
static inline bool m_bShowMenu = false; // should the menu be drawn
|
|
||||||
static inline ImVec2 m_fMenuSize = ImVec2(screen::GetScreenWidth() / 4, screen::GetScreenHeight() / 1.2);
|
static inline ImVec2 m_fMenuSize = ImVec2(screen::GetScreenWidth() / 4, screen::GetScreenHeight() / 1.2);
|
||||||
static inline bool m_bSizeChangedExternal = false; // Was menu size change requested
|
static inline bool m_bShowMenu = false; // should the menu be drawn
|
||||||
static inline std::vector<HeaderData> m_headerList;
|
static inline bool m_bSizeChangedExternal = false; // Was menu size change requested
|
||||||
|
|
||||||
// Applies imgui theme to the menu
|
// Applies imgui theme to the menu
|
||||||
static void ApplyStyle();
|
static void ApplyStyle();
|
||||||
|
|
||||||
// Draws the window ui each frame
|
// Draws the window ui each frame
|
||||||
// Also handles drawing info, overlay, command window
|
|
||||||
static void DrawWindow();
|
static void DrawWindow();
|
||||||
|
|
||||||
static void ShowAnniversaryPage();
|
|
||||||
static void ShowUpdatePage();
|
|
||||||
static void ShowWelcomePage();
|
|
||||||
|
|
||||||
// Does all the processing required to handle menu pages
|
|
||||||
static void ProcessPages();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CheatMenu() = delete;
|
CheatMenu() = delete;
|
||||||
CheatMenu(const CheatMenu&) = delete;
|
CheatMenu(const CheatMenu&) = delete;
|
||||||
@ -48,12 +26,8 @@ public:
|
|||||||
static void Init();
|
static void Init();
|
||||||
|
|
||||||
// Returns true if the menu is being shown
|
// Returns true if the menu is being shown
|
||||||
static bool IsMenuShown();
|
static bool IsBeingDrawn();
|
||||||
|
|
||||||
// Resets the menu height & width to default
|
// Resets the menu height & width to default
|
||||||
static void ResetMenuSize();
|
static void ResetSize();
|
||||||
|
|
||||||
// Generates menu headers
|
|
||||||
// Needs to be called after language change or adding new headers
|
|
||||||
static void GenHeaderList();
|
|
||||||
};
|
};
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include <CAnimBlendAssociation.h>
|
#include <CAnimBlendAssociation.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
AnimationMgr& Animation = *AnimationMgr::Get();
|
AnimationMgr& Animation = AnimationMgr::Get();
|
||||||
|
|
||||||
#ifdef GTAVC
|
#ifdef GTAVC
|
||||||
// Thanks to codenulls(https://github.com/codenulls/)
|
// Thanks to codenulls(https://github.com/codenulls/)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "cutscene_sa.h"
|
#include "cutscene_sa.h"
|
||||||
|
|
||||||
CutsceneMgr& Cutscene = *CutsceneMgr::Get();
|
CutsceneMgr& Cutscene = CutsceneMgr::Get();
|
||||||
CutsceneMgr::CutsceneMgr()
|
CutsceneMgr::CutsceneMgr()
|
||||||
{
|
{
|
||||||
static CdeclEvent <AddressList<0x5B195F, H_JUMP>, PRIORITY_AFTER, ArgPickNone, void()> skipCutsceneEvent;
|
static CdeclEvent <AddressList<0x5B195F, H_JUMP>, PRIORITY_AFTER, ArgPickNone, void()> skipCutsceneEvent;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "freecam_sa.h"
|
#include "freecam_sa.h"
|
||||||
|
|
||||||
static CVector gTotalMouse;
|
static CVector gTotalMouse;
|
||||||
FreecamMgr& Freecam = *FreecamMgr::Get();
|
FreecamMgr& Freecam = FreecamMgr::Get();
|
||||||
|
|
||||||
void FreecamMgr::Enable()
|
void FreecamMgr::Enable()
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "neon_sa.h"
|
#include "neon_sa.h"
|
||||||
|
|
||||||
NeonMgr& Neon = *NeonMgr::Get();
|
NeonMgr& Neon = NeonMgr::Get();
|
||||||
|
|
||||||
// Neon sprite
|
// Neon sprite
|
||||||
const unsigned char neon_mask[1689] =
|
const unsigned char neon_mask[1689] =
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "particle_sa.h"
|
#include "particle_sa.h"
|
||||||
#include "utils/widget.h"
|
#include "utils/widget.h"
|
||||||
|
|
||||||
ParticleMgr& Particle = *ParticleMgr::Get();
|
ParticleMgr& Particle = ParticleMgr::Get();
|
||||||
void ParticleMgr::Play(std::string& cat, std::string& name, std::string& particle)
|
void ParticleMgr::Play(std::string& cat, std::string& name, std::string& particle)
|
||||||
{
|
{
|
||||||
CPlayerPed* pPlayer = FindPlayerPed();
|
CPlayerPed* pPlayer = FindPlayerPed();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "randomcheats_sa.h"
|
#include "randomcheats_sa.h"
|
||||||
|
|
||||||
RandomCheatsMgr& RandomCheats = *RandomCheatsMgr::Get();
|
RandomCheatsMgr& RandomCheats = RandomCheatsMgr::Get();
|
||||||
|
|
||||||
void RandomCheatsMgr::Process()
|
void RandomCheatsMgr::Process()
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "topdowncam_sa.h"
|
#include "topdowncam_sa.h"
|
||||||
|
|
||||||
TopDownCamera& TopDownCam = *TopDownCamera::Get();
|
TopDownCamera& TopDownCam = TopDownCamera::Get();
|
||||||
|
|
||||||
TopDownCamera::TopDownCamera()
|
TopDownCamera::TopDownCamera()
|
||||||
{
|
{
|
||||||
|
@ -20,10 +20,10 @@ public:
|
|||||||
m_bEnabled = true;
|
m_bEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static T *Get()
|
static T &Get()
|
||||||
{
|
{
|
||||||
static T _instance;
|
static T _instance;
|
||||||
return &_instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the current stae of the cheat
|
// Returns the current stae of the cheat
|
||||||
|
196
src/interface/ipage.cpp
Normal file
196
src/interface/ipage.cpp
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include "ipage.h"
|
||||||
|
#include "utils/updater.h"
|
||||||
|
#include "utils/widget.h"
|
||||||
|
|
||||||
|
static void DrawAnniversaryPage()
|
||||||
|
{
|
||||||
|
Widget::TextCentered("Happy Anniversary!");
|
||||||
|
ImGui::NewLine();
|
||||||
|
|
||||||
|
ImGui::TextWrapped("On this day, in 2019, the first public version of menu was released in MixMods Forum."
|
||||||
|
" It's been a blast working on it and I've learned a lot in the process.\n\nThanks to you and everyone who used or"
|
||||||
|
" contributed to the modification in any form or shape.");
|
||||||
|
|
||||||
|
ImGui::NewLine();
|
||||||
|
ImGui::TextWrapped("Feel free to star the GitHub repo or join the discord server and provide feedback, ideas, or suggestions.");
|
||||||
|
ImGui::NewLine();
|
||||||
|
|
||||||
|
if (ImGui::Button(TEXT("Menu.DiscordServer"), ImVec2(Widget::CalcSize(3))))
|
||||||
|
{
|
||||||
|
OPEN_LINK(DISCORD_INVITE);
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button(TEXT("Menu.GitHubRepo"), ImVec2(Widget::CalcSize(3))))
|
||||||
|
{
|
||||||
|
OPEN_LINK(GITHUB_LINK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DrawWelcomePage()
|
||||||
|
{
|
||||||
|
ImGui::NewLine();
|
||||||
|
|
||||||
|
Widget::TextCentered(TEXT("Menu.WelcomeMSG"));
|
||||||
|
Widget::TextCentered(std::format("{}: Grinch_",TEXT("Menu.Author")));
|
||||||
|
|
||||||
|
ImGui::NewLine();
|
||||||
|
ImGui::TextWrapped(TEXT("Menu.EnsureLatest"));
|
||||||
|
if (ImGui::Button(TEXT("Menu.DiscordServer"), ImVec2(Widget::CalcSize(2))))
|
||||||
|
{
|
||||||
|
OPEN_LINK(DISCORD_INVITE);
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button(TEXT("Menu.GitHubRepo"), ImVec2(Widget::CalcSize(2))))
|
||||||
|
{
|
||||||
|
OPEN_LINK(GITHUB_LINK);
|
||||||
|
}
|
||||||
|
ImGui::NewLine();
|
||||||
|
ImGui::TextWrapped(TEXT("Menu.BugDisclaimer"));
|
||||||
|
ImGui::Dummy(ImVec2(0, 20));
|
||||||
|
Widget::TextCentered(TEXT("Menu.PatreonText"));
|
||||||
|
if (ImGui::Button(TEXT("Menu.Patreon"), ImVec2(Widget::CalcSize(1))))
|
||||||
|
{
|
||||||
|
OPEN_LINK("https://www.patreon.com/grinch_");
|
||||||
|
}
|
||||||
|
ImGui::Dummy(ImVec2(0, 30));
|
||||||
|
Widget::TextCentered(TEXT("Menu.CopyrightDisclaimer"));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DrawUpdatePage()
|
||||||
|
{
|
||||||
|
std::string ver = Updater::GetUpdateVersion();
|
||||||
|
ImGui::Dummy(ImVec2(0, 20));
|
||||||
|
Widget::TextCentered(TEXT("Menu.NewVersion"));
|
||||||
|
Widget::TextCentered(std::format("{}: {}", TEXT("Menu.CurrentVersion"), MENU_VERSION));
|
||||||
|
Widget::TextCentered(TEXT("Menu.LatestVersion") + ver);
|
||||||
|
ImGui::Dummy(ImVec2(0, 10));
|
||||||
|
ImGui::TextWrapped(TEXT("Menu.UpdaterInfo1"));
|
||||||
|
ImGui::Dummy(ImVec2(0, 10));
|
||||||
|
ImGui::TextWrapped(TEXT("Menu.UpdaterInfo2"));
|
||||||
|
|
||||||
|
ImGui::Dummy(ImVec2(0, 5));
|
||||||
|
if (ImGui::Button(TEXT("Menu.DiscordServer"), ImVec2(Widget::CalcSize(2))))
|
||||||
|
{
|
||||||
|
OPEN_LINK(DISCORD_INVITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SameLine();
|
||||||
|
|
||||||
|
if (ImGui::Button(TEXT("Menu.DownloadPage"), Widget::CalcSize(2)))
|
||||||
|
{
|
||||||
|
ShellExecute(NULL, "open", std::string("https://github.com/user-grinch/Cheat-Menu/releases/tag/" +
|
||||||
|
ver).c_str(), NULL, NULL, SW_SHOWNORMAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void IPage<T>::Process()
|
||||||
|
{
|
||||||
|
ImVec2 size = Widget::CalcSize(3, false);
|
||||||
|
ImGuiStyle &style = ImGui::GetStyle();
|
||||||
|
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
|
||||||
|
if (Updater::IsUpdateAvailable())
|
||||||
|
{
|
||||||
|
m_nCurrentPage = eMenuPage::Update;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check once if it's anniversary day
|
||||||
|
static bool aniCheckDone;
|
||||||
|
if (!aniCheckDone)
|
||||||
|
{
|
||||||
|
SYSTEMTIME st;
|
||||||
|
GetSystemTime(&st);
|
||||||
|
|
||||||
|
if (st.wMonth == 3 && st.wDay == 28)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* We don't want to be annoying and
|
||||||
|
* show anniversary screen on every game start
|
||||||
|
*/
|
||||||
|
bool flag = gConfig.Get("Window.AnniversaryShown", false);
|
||||||
|
|
||||||
|
if (!flag)
|
||||||
|
{
|
||||||
|
gConfig.Set("Window.AnniversaryShown", true);
|
||||||
|
m_nMenuPage = eMenuPages::ANNIVERSARY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
aniCheckDone = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImDrawList *pDrawList = ImGui::GetWindowDrawList();
|
||||||
|
for (size_t i = 0; i < m_headerList.size(); ++i)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* For welcome & update pages
|
||||||
|
* They don't need to add item in the header list
|
||||||
|
*/
|
||||||
|
if (m_headerList[i].skipHeader)
|
||||||
|
{
|
||||||
|
if (m_nMenuPage == m_headerList[i].page)
|
||||||
|
{
|
||||||
|
pCallback = m_headerList[i].pFunc;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* text = m_headerList[i].name.c_str();
|
||||||
|
|
||||||
|
ImVec4 color;
|
||||||
|
if (m_headerList[i].page == m_nMenuPage)
|
||||||
|
{
|
||||||
|
color = style.Colors[ImGuiCol_ButtonActive];
|
||||||
|
pCallback = m_headerList[i].pFunc;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
color = style.Colors[ImGuiCol_Button];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::InvisibleButton(text, size))
|
||||||
|
{
|
||||||
|
m_nMenuPage = m_headerList[i].page;
|
||||||
|
size_t curPage = static_cast<size_t>(m_headerList[i].page);
|
||||||
|
gConfig.Set("Window.CurrentPage", curPage);
|
||||||
|
pCallback = m_headerList[i].pFunc;
|
||||||
|
Updater::ResetUpdaterState();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::IsItemHovered())
|
||||||
|
{
|
||||||
|
color = style.Colors[ImGuiCol_ButtonHovered];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Window rounding flags
|
||||||
|
* TODO: hardcoded atm
|
||||||
|
*/
|
||||||
|
ImDrawFlags flags = ImDrawFlags_RoundCornersNone;
|
||||||
|
if (i == 0) flags = ImDrawFlags_RoundCornersTopLeft;
|
||||||
|
if (i == 2) flags = ImDrawFlags_RoundCornersTopRight;
|
||||||
|
if (i == 6) flags = ImDrawFlags_RoundCornersBottomLeft;
|
||||||
|
if (i == 8) flags = ImDrawFlags_RoundCornersBottomRight;
|
||||||
|
|
||||||
|
ImVec2 min = ImGui::GetItemRectMin();
|
||||||
|
ImVec2 max = ImGui::GetItemRectMax();
|
||||||
|
ImVec2 size = ImGui::CalcTextSize(text);
|
||||||
|
pDrawList->AddRectFilled(min, max, ImGui::GetColorU32(color), style.FrameRounding, flags);
|
||||||
|
ImGui::RenderTextClipped(min + style.FramePadding, max - style.FramePadding, text, NULL, &size, style.ButtonTextAlign);
|
||||||
|
|
||||||
|
if (i % 3 != 2)
|
||||||
|
{
|
||||||
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::PopStyleVar();
|
||||||
|
ImGui::Dummy(ImVec2(0, 10));
|
||||||
|
|
||||||
|
if (m_pCurrentPage != nullptr && ImGui::BeginChild("HEADERCONTENT"))
|
||||||
|
{
|
||||||
|
m_pCurrentPage->Draw();
|
||||||
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
|
}
|
72
src/interface/ipage.h
Normal file
72
src/interface/ipage.h
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
enum class eMenuPage
|
||||||
|
{
|
||||||
|
Anniversary,
|
||||||
|
Game,
|
||||||
|
Menu,
|
||||||
|
None,
|
||||||
|
Ped,
|
||||||
|
Player,
|
||||||
|
Scene,
|
||||||
|
Teleport,
|
||||||
|
Update,
|
||||||
|
Vehicle,
|
||||||
|
Visual,
|
||||||
|
Weapon,
|
||||||
|
Welcome
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Interface class for pages
|
||||||
|
Every page must inherit this
|
||||||
|
*/
|
||||||
|
template<typename T>
|
||||||
|
class IPage
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
eMenuPage m_ePage; // Menu page ID
|
||||||
|
bool m_bHasHeader; // Does the page has a header button
|
||||||
|
std::string m_NameKey; // A key to the page name string
|
||||||
|
|
||||||
|
public:
|
||||||
|
static inline std::vector<IPage*> m_nPageList; // Contains list of the created pages
|
||||||
|
static inline IPage* m_pCurrentPage = nullptr; // Currently visible menu page
|
||||||
|
|
||||||
|
IPage(m_ePage page, std::string&& key, bool header = true)
|
||||||
|
: m_ePage(page), m_NameKey(key), m_bHasHeader(header)
|
||||||
|
{
|
||||||
|
m_nPageList.push_back(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Page drawing code goes here
|
||||||
|
virtual void Draw() = 0;
|
||||||
|
|
||||||
|
static T *Get() final
|
||||||
|
{
|
||||||
|
static T _instance;
|
||||||
|
return &_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the ID of the page
|
||||||
|
eMenuPage GetPageID() final
|
||||||
|
{
|
||||||
|
return m_ePage;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true if the page has a visible header button
|
||||||
|
bool HasHeaderButton() final
|
||||||
|
{
|
||||||
|
return m_bHasHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the page name key
|
||||||
|
std::string GetKey() final
|
||||||
|
{
|
||||||
|
return m_NameKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process the menu pages & draw them
|
||||||
|
static void Process() final;
|
||||||
|
};
|
@ -56,7 +56,7 @@ void Menu::ShowPage()
|
|||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
if (ImGui::Button(TEXT("Menu.ResetSize"), ImVec2(Widget::CalcSize(2))))
|
if (ImGui::Button(TEXT("Menu.ResetSize"), ImVec2(Widget::CalcSize(2))))
|
||||||
{
|
{
|
||||||
CheatMenu::ResetMenuSize();
|
CheatMenu::ResetSize();
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button(TEXT("Menu.ReloadFonts"), ImVec2(Widget::CalcSize(2))))
|
if (ImGui::Button(TEXT("Menu.ReloadFonts"), ImVec2(Widget::CalcSize(2))))
|
||||||
|
@ -380,15 +380,15 @@ void Ped::ShowPage()
|
|||||||
ImGui::Text(TEXT("Ped.SelectedWeapon"), weaponName.c_str());
|
ImGui::Text(TEXT("Ped.SelectedWeapon"), weaponName.c_str());
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
#ifdef GTASA
|
#ifdef GTASA
|
||||||
Widget::ImageList(Weapon::m_WeaponData,
|
Widget::ImageList(WeaponPage::m_WeaponData,
|
||||||
[](std::string& str)
|
[](std::string& str)
|
||||||
{
|
{
|
||||||
Spawner::m_nWeaponId = std::stoi(str);
|
Spawner::m_nWeaponId = std::stoi(str);
|
||||||
weaponName = Weapon::m_WeaponData.m_pData->Get(str.c_str(), "Unknown");
|
weaponName = WeaponPage::m_WeaponData.m_pData->Get(str.c_str(), "Unknown");
|
||||||
},
|
},
|
||||||
[](std::string& str)
|
[](std::string& str)
|
||||||
{
|
{
|
||||||
return Weapon::m_WeaponData.m_pData->Get(str.c_str(), "Unknown");
|
return WeaponPage::m_WeaponData.m_pData->Get(str.c_str(), "Unknown");
|
||||||
},
|
},
|
||||||
[](std::string& str)
|
[](std::string& str)
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "utils/util.h"
|
#include "utils/util.h"
|
||||||
#include <CWeaponInfo.h>
|
#include <CWeaponInfo.h>
|
||||||
|
|
||||||
void Weapon::Init()
|
void WeaponPage::Init()
|
||||||
{
|
{
|
||||||
Events::processScriptsEvent += []
|
Events::processScriptsEvent += []
|
||||||
{
|
{
|
||||||
@ -94,7 +94,7 @@ void Weapon::Init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef GTASA
|
#ifdef GTASA
|
||||||
void Weapon::SetGangWeapon(std::string& weapon_type)
|
void WeaponPage::SetGangWeapon(std::string& weapon_type)
|
||||||
{
|
{
|
||||||
m_nGangWeaponList[m_nSelectedGang][m_nSelectedWeapon] = std::stoi(weapon_type);
|
m_nGangWeaponList[m_nSelectedGang][m_nSelectedWeapon] = std::stoi(weapon_type);
|
||||||
CGangs::SetGangWeapons(m_nSelectedGang, m_nGangWeaponList[m_nSelectedGang][0], m_nGangWeaponList[m_nSelectedGang][1],
|
CGangs::SetGangWeapons(m_nSelectedGang, m_nGangWeaponList[m_nSelectedGang][0], m_nGangWeaponList[m_nSelectedGang][1],
|
||||||
@ -162,7 +162,7 @@ static eWeaponType GetWeaponTypeFromModel(int model)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef GTASA
|
#ifdef GTASA
|
||||||
void Weapon::GiveWeaponToPlayer(std::string& weapon_type)
|
void WeaponPage::GiveWeaponToPlayer(std::string& weapon_type)
|
||||||
{
|
{
|
||||||
CPlayerPed* player = FindPlayerPed();
|
CPlayerPed* player = FindPlayerPed();
|
||||||
int hplayer = CPools::GetPedRef(player);
|
int hplayer = CPools::GetPedRef(player);
|
||||||
@ -223,7 +223,7 @@ void Weapon::GiveWeaponToPlayer(std::string& rootkey, std::string& name, std::st
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Weapon::AddWeapon()
|
void WeaponPage::AddNew()
|
||||||
{
|
{
|
||||||
static char name[INPUT_BUFFER_SIZE];
|
static char name[INPUT_BUFFER_SIZE];
|
||||||
static int model = 0;
|
static int model = 0;
|
||||||
@ -240,7 +240,7 @@ void Weapon::AddWeapon()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Weapon::ShowPage()
|
void WeaponPage::Draw()
|
||||||
{
|
{
|
||||||
CPlayerPed* pPlayer = FindPlayerPed();
|
CPlayerPed* pPlayer = FindPlayerPed();
|
||||||
uint hplayer = CPools::GetPedRef(pPlayer);
|
uint hplayer = CPools::GetPedRef(pPlayer);
|
||||||
@ -384,7 +384,7 @@ void Weapon::ShowPage()
|
|||||||
[](std::string& str)
|
[](std::string& str)
|
||||||
{
|
{
|
||||||
return str != "0"; /*Unarmed*/
|
return str != "0"; /*Unarmed*/
|
||||||
}, AddWeapon);
|
}, AddNew);
|
||||||
#else
|
#else
|
||||||
Widget::DataList(m_WeaponData, GiveWeaponToPlayer, AddWeapon);
|
Widget::DataList(m_WeaponData, GiveWeaponToPlayer, AddWeapon);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
|
|
||||||
class Weapon
|
class WeaponPage
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static inline bool m_bFastReload;
|
static inline bool m_bFastReload;
|
||||||
@ -37,13 +37,14 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Weapon() = delete;
|
WeaponPage() = delete;
|
||||||
Weapon(const Weapon&) = delete;
|
WeaponPage(const WeaponPage&) = delete;
|
||||||
|
|
||||||
static void Init();
|
static void Init();
|
||||||
static void ShowPage();
|
|
||||||
|
static void Draw();
|
||||||
|
|
||||||
static void AddWeapon();
|
static void AddNew();
|
||||||
#ifdef GTASA
|
#ifdef GTASA
|
||||||
static inline ResourceStore m_WeaponData { "weapons", eResourceType::TYPE_IMAGE_TEXT, ImVec2(65, 65) };
|
static inline ResourceStore m_WeaponData { "weapons", eResourceType::TYPE_IMAGE_TEXT, ImVec2(65, 65) };
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ void Overlay::ProcessCommands(std::string&& str)
|
|||||||
if (wep_name == "jetpack")
|
if (wep_name == "jetpack")
|
||||||
{
|
{
|
||||||
std::string weapon = "-1";
|
std::string weapon = "-1";
|
||||||
Weapon::GiveWeaponToPlayer(weapon);
|
WeaponPage::GiveWeaponToPlayer(weapon);
|
||||||
Util::SetMessage(TEXT("Menu.WeaponSpawned"));
|
Util::SetMessage(TEXT("Menu.WeaponSpawned"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -337,7 +337,7 @@ void Overlay::ProcessCommands(std::string&& str)
|
|||||||
|
|
||||||
if (wep_name != "" && pweaponinfo->m_nModelId1 != -1)
|
if (wep_name != "" && pweaponinfo->m_nModelId1 != -1)
|
||||||
{
|
{
|
||||||
Weapon::GiveWeaponToPlayer(weapon_name);
|
WeaponPage::GiveWeaponToPlayer(weapon_name);
|
||||||
Util::SetMessage(TEXT("Menu.WeaponSpawned"));
|
Util::SetMessage(TEXT("Menu.WeaponSpawned"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -133,7 +133,7 @@ void RPC::Process()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (CheatMenu::IsMenuShown())
|
if (CheatMenu::IsBeingDrawn())
|
||||||
{
|
{
|
||||||
stateText = TEXT("RPC.BrowsingCheatMenu");
|
stateText = TEXT("RPC.BrowsingCheatMenu");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user