Fix errors
This commit is contained in:
parent
6bd401afa0
commit
50c4e4235d
@ -60,7 +60,7 @@ static bool DrawTitleBar()
|
||||
return pressed;
|
||||
}
|
||||
|
||||
void CheatMenu::DrawWindow()
|
||||
void CheatMenu::Draw()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
static bool bRunning = true;
|
||||
@ -77,26 +77,30 @@ void CheatMenu::DrawWindow()
|
||||
else
|
||||
{
|
||||
bRunning = true;
|
||||
if (m_bShowMenu)
|
||||
if (m_bVisible)
|
||||
{
|
||||
ImGui::SetNextWindowSize(m_fMenuSize);
|
||||
ImGui::SetNextWindowSize(m_fSize);
|
||||
|
||||
if (ImGui::Begin(MENU_TITLE, NULL, ImGuiWindowFlags_NoCollapse || ImGuiWindowFlags_NoTitleBar))
|
||||
{
|
||||
m_bShowMenu = !DrawTitleBar();
|
||||
m_bVisible = !DrawTitleBar();
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(250, 350));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,
|
||||
ImVec2(ImGui::GetWindowWidth() / 85, ImGui::GetWindowHeight() / 200));
|
||||
|
||||
PageHandler::DrawPages();
|
||||
|
||||
if (m_bSizeChangedExternal)
|
||||
m_bSizeChangedExternal = false;
|
||||
if (m_bSizeUpdated)
|
||||
{
|
||||
m_bSizeUpdated = false;
|
||||
}
|
||||
else
|
||||
m_fMenuSize = ImGui::GetWindowSize();
|
||||
{
|
||||
m_fSize = ImGui::GetWindowSize();
|
||||
}
|
||||
|
||||
gConfig.Set("Window.SizeX", m_fMenuSize.x);
|
||||
gConfig.Set("Window.SizeY", m_fMenuSize.y);
|
||||
gConfig.Set("Window.SizeX", m_fSize.x);
|
||||
gConfig.Set("Window.SizeY", m_fSize.y);
|
||||
|
||||
ImGui::PopStyleVar(2);
|
||||
ImGui::End();
|
||||
@ -114,15 +118,14 @@ void CheatMenu::Init()
|
||||
return;
|
||||
}
|
||||
|
||||
if (!D3dHook::Init(DrawWindow))
|
||||
if (!D3dHook::Init(Draw))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Load menu settings
|
||||
// m_nMenuPage = (eMenuPages)gConfig.Get("Window.CurrentPage", (size_t)eMenuPages::WELCOME);
|
||||
m_fMenuSize.x = gConfig.Get("Window.SizeX", screen::GetScreenWidth() / 4.0f);
|
||||
m_fMenuSize.y = gConfig.Get("Window.SizeY", screen::GetScreenHeight() / 1.2f);
|
||||
m_fSize.x = gConfig.Get("Window.SizeX", screen::GetScreenWidth() / 4.0f);
|
||||
m_fSize.y = gConfig.Get("Window.SizeY", screen::GetScreenHeight() / 1.2f);
|
||||
srand(CTimer::m_snTimeInMilliseconds);
|
||||
|
||||
ApplyStyle();
|
||||
@ -135,7 +138,7 @@ void CheatMenu::Init()
|
||||
{
|
||||
if (menuOpen.Pressed())
|
||||
{
|
||||
m_bShowMenu = !m_bShowMenu;
|
||||
m_bVisible = !m_bVisible;
|
||||
}
|
||||
|
||||
if (commandWindow.Pressed())
|
||||
@ -144,14 +147,14 @@ void CheatMenu::Init()
|
||||
}
|
||||
|
||||
bool mouseState = D3dHook::GetMouseState();
|
||||
if (mouseState != m_bShowMenu)
|
||||
if (mouseState != m_bVisible)
|
||||
{
|
||||
if (mouseState) // Only write when the menu closes
|
||||
{
|
||||
gConfig.Save();
|
||||
}
|
||||
|
||||
D3dHook::SetMouseState(m_bShowMenu);
|
||||
D3dHook::SetMouseState(m_bVisible);
|
||||
}
|
||||
|
||||
if (teleportPage.IsQuickTeleportActive() && quickTeleport.PressedRealtime())
|
||||
@ -162,9 +165,9 @@ void CheatMenu::Init()
|
||||
};
|
||||
}
|
||||
|
||||
bool CheatMenu::IsBeingDrawn()
|
||||
bool CheatMenu::IsVisible()
|
||||
{
|
||||
return m_bShowMenu;
|
||||
return m_bVisible;
|
||||
}
|
||||
|
||||
void CheatMenu::ApplyStyle()
|
||||
@ -235,7 +238,7 @@ void CheatMenu::ApplyStyle()
|
||||
|
||||
void CheatMenu::ResetSize()
|
||||
{
|
||||
m_fMenuSize.x = screen::GetScreenWidth() / 4.0f;
|
||||
m_fMenuSize.y = screen::GetScreenHeight() / 1.2f;
|
||||
m_bSizeChangedExternal = true;
|
||||
m_fSize.x = screen::GetScreenWidth() / 4.0f;
|
||||
m_fSize.y = screen::GetScreenHeight() / 1.2f;
|
||||
m_bSizeUpdated = true;
|
||||
}
|
||||
|
@ -8,15 +8,15 @@
|
||||
class CheatMenu
|
||||
{
|
||||
private:
|
||||
static inline ImVec2 m_fMenuSize = ImVec2(screen::GetScreenWidth() / 4, screen::GetScreenHeight() / 1.2);
|
||||
static inline bool m_bShowMenu = false; // should the menu be drawn
|
||||
static inline bool m_bSizeChangedExternal = false; // Was menu size change requested
|
||||
static inline ImVec2 m_fSize = ImVec2(screen::GetScreenWidth() / 4, screen::GetScreenHeight() / 1.2);
|
||||
static inline bool m_bVisible = false; // should the menu be drawn
|
||||
static inline bool m_bSizeUpdated = false; // Was menu size change requested
|
||||
|
||||
// Applies imgui theme to the menu
|
||||
static void ApplyStyle();
|
||||
|
||||
// Draws the window ui each frame
|
||||
static void DrawWindow();
|
||||
static void Draw();
|
||||
|
||||
public:
|
||||
CheatMenu() = delete;
|
||||
@ -26,7 +26,7 @@ public:
|
||||
static void Init();
|
||||
|
||||
// Returns true if the menu is being shown
|
||||
static bool IsBeingDrawn();
|
||||
static bool IsVisible();
|
||||
|
||||
// Resets the menu height & width to default
|
||||
static void ResetSize();
|
||||
|
@ -1,26 +1,13 @@
|
||||
#include "pch.h"
|
||||
#include "cheatmenu.h"
|
||||
#include "menu.h"
|
||||
#include "utils/updater.h"
|
||||
#include "utils/rpc.h"
|
||||
#include "pages/menu.h"
|
||||
|
||||
void MenuThread(void* param)
|
||||
{
|
||||
/*
|
||||
Wait for game init
|
||||
// Sleep(3000);
|
||||
Doing it like this doesn't prevent from attaching a debugger
|
||||
*/
|
||||
static bool gameStarted = false;
|
||||
Events::processScriptsEvent +=[]
|
||||
Events::initGameEvent +=[]
|
||||
{
|
||||
gameStarted = true;
|
||||
};
|
||||
|
||||
while (!gameStarted)
|
||||
{
|
||||
Sleep(500);
|
||||
}
|
||||
|
||||
/*
|
||||
Had to put this in place since some people put the folder in root
|
||||
@ -97,7 +84,7 @@ void MenuThread(void* param)
|
||||
Log::Print<eLogLevel::None>("Renderhook installed: {}", GetModuleHandle("_gtaRenderHook.asi") ? "True" : "False");
|
||||
Log::Print<eLogLevel::None>("Widescreen Fix installed: {}\n", GetModuleHandle("GTASA.WidescreenFix.asi") ? "True" : "False");
|
||||
|
||||
CheatMenu::Init();
|
||||
MenuMgr::Init();
|
||||
|
||||
// Checking for updates once a day
|
||||
if (menuPage.m_bAutoCheckUpdate && gConfig.Get("Menu.LastUpdateChecked", 0) != st.wDay)
|
||||
@ -110,12 +97,13 @@ void MenuThread(void* param)
|
||||
{
|
||||
Log::Print<eLogLevel::Info>("New update available: %s", Updater::GetUpdateVersion().c_str());
|
||||
}
|
||||
};
|
||||
|
||||
while (true)
|
||||
{
|
||||
FontMgr::DrawPages();
|
||||
RPC::DrawPages();
|
||||
Updater::DrawPages();
|
||||
FontMgr::Process();
|
||||
RPC::Process();
|
||||
Updater::Process();
|
||||
Sleep(1000);
|
||||
}
|
||||
}
|
||||
|
@ -135,3 +135,16 @@ void PageHandler::DrawPages()
|
||||
ImGui::EndChild();
|
||||
}
|
||||
}
|
||||
|
||||
PagePtr PageHandler::FindPagePtr(ePageID id)
|
||||
{
|
||||
for (void* ptr : m_PageList)
|
||||
{
|
||||
IPageStatic* page = reinterpret_cast<IPageStatic*>(ptr);
|
||||
if (page->GetPageID() == id)
|
||||
{
|
||||
return reinterpret_cast<PagePtr>(page);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
@ -42,7 +42,9 @@ public:
|
||||
|
||||
// Add a new page
|
||||
static void AddPage(PagePtr page, size_t index);
|
||||
static PagePtr FindPagePtr(ePageID id);
|
||||
static void SetCurrentPage(PagePtr page);
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
@ -84,4 +86,5 @@ public:
|
||||
{
|
||||
return m_NameKey;
|
||||
}
|
||||
|
||||
};
|
@ -10,10 +10,13 @@
|
||||
MenuPage& menuPage = MenuPage::Get();
|
||||
MenuPage::MenuPage()
|
||||
: IPage<MenuPage>(ePageID::Menu, "Window.MenuPage", true)
|
||||
{
|
||||
Events::initGameEvent += [this]()
|
||||
{
|
||||
m_bDiscordRPC = gConfig.Get("Menu.DiscordRPC", false);
|
||||
m_bAutoCheckUpdate = gConfig.Get("Menu.AutoCheckUpdate", true);
|
||||
m_bTextOnlyMode = gConfig.Get("Menu.TextOnlyMode", false);
|
||||
};
|
||||
|
||||
if (m_bDiscordRPC)
|
||||
{
|
||||
|
@ -36,7 +36,10 @@ PlayerPage::PlayerPage()
|
||||
#ifdef GTASA
|
||||
// Fix player model being broken after rebuild
|
||||
patch::RedirectCall(0x5A834D, &PlayerModelBrokenFix);
|
||||
Events::initGameEvent += [this]()
|
||||
{
|
||||
m_bAimSkinChanger = gConfig.Get("Features.AimSkinChanger", false);
|
||||
};
|
||||
#endif
|
||||
|
||||
Events::processScriptsEvent += [this]
|
||||
|
@ -44,11 +44,14 @@ TeleportPage& teleportPage = TeleportPage::Get();
|
||||
|
||||
TeleportPage::TeleportPage()
|
||||
: IPage<TeleportPage>(ePageID::Teleport, "Window.TeleportPage", true)
|
||||
{
|
||||
Events::initGameEvent += [this]()
|
||||
{
|
||||
m_bTeleportMarker = gConfig.Get("Features.TeleportMarker", false);
|
||||
m_bQuickTeleport = gConfig.Get("Features.QuickTeleport", false);
|
||||
m_fMapSize.x = gConfig.Get("Game.MapSizeX", 6000.0f);
|
||||
m_fMapSize.y = gConfig.Get("Game.MapSizeY", 6000.0f);
|
||||
};
|
||||
|
||||
Events::drawingEvent += [this]
|
||||
{
|
||||
|
@ -20,8 +20,12 @@ VehiclePage::VehiclePage()
|
||||
: IPage<VehiclePage>(ePageID::Vehicle, "Window.VehiclePage", true)
|
||||
{
|
||||
// Get config data
|
||||
Events::initGameEvent += [this]()
|
||||
{
|
||||
m_Spawner.m_bInAir = gConfig.Get("Features.SpawnAircraftInAir", true);
|
||||
m_Spawner.m_bAsDriver = gConfig.Get("Features.SpawnInsideVehicle", true);
|
||||
};
|
||||
|
||||
|
||||
Events::processScriptsEvent += [this]
|
||||
{
|
||||
|
@ -8,7 +8,15 @@ private:
|
||||
friend class IFeature;
|
||||
WelcomePage() : IPage<WelcomePage>(ePageID::Welcome, "Welcome", false)
|
||||
{
|
||||
PageHandler::SetCurrentPage(this);
|
||||
Events::initGameEvent += [this]()
|
||||
{
|
||||
ePageID pageID = static_cast<ePageID>(gConfig.Get("Window.CurrentPage", static_cast<size_t>(ePageID::Welcome)));
|
||||
PagePtr ptr = PageHandler::FindPagePtr(pageID);
|
||||
if (ptr)
|
||||
{
|
||||
PageHandler::SetCurrentPage(ptr);
|
||||
}
|
||||
};
|
||||
}
|
||||
WelcomePage(const WelcomePage&);
|
||||
|
||||
|
@ -71,7 +71,7 @@ void FontMgr::ReloadAll()
|
||||
m_bFontReloadRequired = false;
|
||||
}
|
||||
|
||||
void FontMgr::DrawPages()
|
||||
void FontMgr::Process()
|
||||
{
|
||||
if (curState == eStates::Idle)
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
static ImFont* Load(const char* fontID, const char* path = 0, float fontMul = 1.0f);
|
||||
|
||||
// Handles font downloading
|
||||
static void DrawPages();
|
||||
static void Process();
|
||||
|
||||
// Reloads all the fonts
|
||||
static void ReloadAll();
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "utils/util.h"
|
||||
#include "pages/menu.h"
|
||||
#include "pages/vehicle.h"
|
||||
#include "cheatmenu.h"
|
||||
#include "menu.h"
|
||||
|
||||
// discord server ids
|
||||
const char* id = BY_GAME("951199292981403669", "951448264195059712", "951457540573655080");
|
||||
@ -66,7 +66,7 @@ void RPC::Init()
|
||||
}
|
||||
}
|
||||
|
||||
void RPC::DrawPages()
|
||||
void RPC::Process()
|
||||
{
|
||||
if (!(menuPage.m_bDiscordRPC && bInit))
|
||||
{
|
||||
@ -133,7 +133,7 @@ void RPC::DrawPages()
|
||||
}
|
||||
|
||||
|
||||
if (CheatMenu::IsBeingDrawn())
|
||||
if (MenuMgr::IsBeingDrawn())
|
||||
{
|
||||
stateText = TEXT("RPC.BrowsingCheatMenu");
|
||||
}
|
||||
|
@ -36,6 +36,6 @@ public:
|
||||
RPC(RPC&) = delete;
|
||||
|
||||
static void Init();
|
||||
static void DrawPages();
|
||||
static void Process();
|
||||
static void Shutdown();
|
||||
};
|
@ -24,7 +24,7 @@ void Updater::CheckUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
void Updater::DrawPages()
|
||||
void Updater::Process()
|
||||
{
|
||||
if (Updater::curState != States::CHECKING)
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
static bool IsUpdateAvailable();
|
||||
|
||||
// Needs to run in it's own thread to prevent the game from freezing
|
||||
static void DrawPages();
|
||||
static void Process();
|
||||
|
||||
// Resets updater state to IDLE
|
||||
static void ResetUpdaterState();
|
||||
|
Loading…
Reference in New Issue
Block a user