Code cleanup
This commit is contained in:
parent
0bd77dbf79
commit
fcda4d500b
@ -9,16 +9,16 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "Animation.h"
|
||||
#include "Hook.h"
|
||||
#include "Menu.h"
|
||||
#include "Teleport.h"
|
||||
#include "Player.h"
|
||||
#include "Ped.h"
|
||||
#include "Vehicle.h"
|
||||
#include "Weapon.h"
|
||||
#include "Game.h"
|
||||
#include "Visual.h"
|
||||
#include "animation.h"
|
||||
#include "hook.h"
|
||||
#include "menu.h"
|
||||
#include "teleport.h"
|
||||
#include "player.h"
|
||||
#include "ped.h"
|
||||
#include "vehicle.h"
|
||||
#include "weapon.h"
|
||||
#include "game.h"
|
||||
#include "visual.h"
|
||||
|
||||
class CheatMenu : Hook, Animation, Game, Menu, Ped, Player, Teleport, Vehicle, Visual, Weapon
|
||||
{
|
||||
|
@ -6,17 +6,24 @@
|
||||
|
||||
void MenuThread(void* param)
|
||||
{
|
||||
/*
|
||||
Had to put this in place since some people put the folder in root
|
||||
directory and the asi in modloader. Why??
|
||||
|
||||
TODO: Unlikely they'd even read the log so have to do something else
|
||||
*/
|
||||
if (!std::filesystem::is_directory(PLUGIN_PATH((char*)"CheatMenu")))
|
||||
{
|
||||
gLog << "CheatMenu folder not found. You need to put both \"CheatMenu.asi\" & \"CheatMenu\" folder in the same directory" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
static bool bGameInit = false;
|
||||
#ifdef GTASA
|
||||
Hook::ApplyMouseFix();
|
||||
#endif
|
||||
|
||||
static bool bGameInit = false;
|
||||
|
||||
// Wait till game init
|
||||
Events::initRwEvent += []
|
||||
{
|
||||
@ -43,11 +50,13 @@ void MenuThread(void* param)
|
||||
CFastman92limitAdjuster::Init();
|
||||
CheatMenu menu;
|
||||
|
||||
|
||||
// Checking for updates once a day
|
||||
time_t now = time(0);
|
||||
struct tm tstruct = *localtime(&now);
|
||||
int last_check_date = gConfig.GetValue("config.last_update_checked", 0);
|
||||
int lastCheckDate = gConfig.GetValue("config.last_update_checked", 0);
|
||||
|
||||
if (last_check_date != tstruct.tm_mday)
|
||||
if (lastCheckDate != tstruct.tm_mday)
|
||||
{
|
||||
Updater::CheckForUpdate();
|
||||
gConfig.SetValue("config.last_update_checked", tstruct.tm_mday);
|
||||
@ -70,7 +79,7 @@ BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved)
|
||||
{
|
||||
uint gameVersion = GetGameVersion();
|
||||
#ifdef GTASA
|
||||
if (gameVersion == GAME_10US_HOODLUM || gameVersion == GAME_10US_COMPACT)
|
||||
if (gameVersion == GAME_10US_HOODLUM)
|
||||
{
|
||||
CreateThread(nullptr, NULL, (LPTHREAD_START_ROUTINE)&MenuThread, nullptr, NULL, nullptr);
|
||||
}
|
||||
@ -79,7 +88,6 @@ BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved)
|
||||
MessageBox(HWND_DESKTOP, "Unknown game version. GTA SA v1.0 US is required.", "CheatMenu", MB_ICONERROR);
|
||||
}
|
||||
#elif GTAVC
|
||||
|
||||
if (gameVersion == GAME_10EN)
|
||||
{
|
||||
CreateThread(nullptr, NULL, (LPTHREAD_START_ROUTINE)&MenuThread, nullptr, NULL, nullptr);
|
||||
|
36
src/game.cpp
36
src/game.cpp
@ -107,6 +107,7 @@ Game::Game()
|
||||
CStats::SetStatValue(STAT_STAMINA, 0.0f);
|
||||
}
|
||||
|
||||
static int m_nSolidWaterObj;
|
||||
if (m_bSolidWater)
|
||||
{
|
||||
CVector pos = pPlayer->GetPosition();
|
||||
@ -130,13 +131,13 @@ Game::Game()
|
||||
Command<Commands::SET_OBJECT_COORDINATES>(m_nSolidWaterObj, pos.x, pos.y, waterHeight);
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_nSolidWaterObj)
|
||||
{
|
||||
if (m_nSolidWaterObj != 0)
|
||||
{
|
||||
Command<Commands::DELETE_OBJECT>(m_nSolidWaterObj);
|
||||
m_nSolidWaterObj = 0;
|
||||
}
|
||||
Command<Commands::DELETE_OBJECT>(m_nSolidWaterObj);
|
||||
m_nSolidWaterObj = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,7 +161,8 @@ Game::Game()
|
||||
#endif
|
||||
|
||||
// improve this later
|
||||
if (m_bSyncTime && timer - m_nSyncTimer > 50)
|
||||
static uint syncTimer;
|
||||
if (m_bSyncTime && timer - syncTimer > 50)
|
||||
{
|
||||
std::time_t t = std::time(nullptr);
|
||||
std::tm* now = std::localtime(&t);
|
||||
@ -168,7 +170,7 @@ Game::Game()
|
||||
CClock::ms_nGameClockHours = now->tm_hour;
|
||||
CClock::ms_nGameClockMinutes = now->tm_min;
|
||||
|
||||
m_nSyncTimer = timer;
|
||||
syncTimer = timer;
|
||||
}
|
||||
|
||||
#ifdef GTASA
|
||||
@ -492,15 +494,8 @@ Lowers armour, health, stamina etc."))
|
||||
Ui::CheckboxWithHint("Screenshot shortcut", &m_bScreenShot,
|
||||
(("Take screenshot using ") + quickSceenShot.GetNameString()
|
||||
+ "\nSaved inside 'GTA San Andreas User Files\\Gallery'").c_str());
|
||||
if (Ui::CheckboxWithHint("Solid water", &m_bSolidWater,
|
||||
"Player can walk on water\nTurn this off if you want to swim."))
|
||||
{
|
||||
if (!m_bSolidWater && m_nSolidWaterObj != 0)
|
||||
{
|
||||
Command<Commands::DELETE_OBJECT>(m_nSolidWaterObj);
|
||||
m_nSolidWaterObj = 0;
|
||||
}
|
||||
}
|
||||
Ui::CheckboxWithHint("Solid water", &m_bSolidWater,
|
||||
"Player can walk on water\nTurn this off if you want to swim.");
|
||||
#endif
|
||||
if (ImGui::Checkbox("Sync system time", &m_bSyncTime))
|
||||
{
|
||||
@ -652,7 +647,8 @@ Lowers armour, health, stamina etc."))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
|
||||
if (!m_bMissionLoaderWarningShown)
|
||||
static bool bMissionLoaderWarningShown;
|
||||
if (!bMissionLoaderWarningShown)
|
||||
{
|
||||
ImGui::TextWrapped("Mission loader may cause,\n\
|
||||
1. Game crashes\n\
|
||||
@ -662,7 +658,9 @@ Lowers armour, health, stamina etc."))
|
||||
It's recommanded not to save after using the mission loader. Use it at your own risk!");
|
||||
ImGui::Spacing();
|
||||
if (ImGui::Button("Show mission loader", ImVec2(Ui::GetSize())))
|
||||
m_bMissionLoaderWarningShown = true;
|
||||
{
|
||||
bMissionLoaderWarningShown = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
18
src/game.h
18
src/game.h
@ -5,11 +5,15 @@ class Game
|
||||
public:
|
||||
static inline ResourceStore m_MissionData{ "mission", eResourceType::TYPE_TEXT };
|
||||
|
||||
static inline bool m_bDisableCheats;
|
||||
static inline bool m_bDisableReplay;
|
||||
static inline bool m_bMissionTimer;
|
||||
static inline bool m_bFreezeTime;
|
||||
static inline bool m_bSyncTime;
|
||||
#ifdef GTASA
|
||||
static inline bool m_bForbiddenArea = true;
|
||||
static inline bool m_bSolidWater;
|
||||
static inline bool m_bForbiddenArea = true; // wanted level when going outside playable aea
|
||||
static inline bool m_bSolidWater; // walk on water hack
|
||||
static inline bool m_bScreenShot;
|
||||
static inline uint m_nSolidWaterObj;
|
||||
static inline bool m_bKeepStuff;
|
||||
static inline ResourceStore m_StatData{ "stat", eResourceType::TYPE_TEXT };
|
||||
|
||||
@ -50,19 +54,13 @@ public:
|
||||
};
|
||||
|
||||
#endif
|
||||
static inline bool m_bDisableCheats;
|
||||
static inline bool m_bDisableReplay;
|
||||
static inline bool m_bMissionTimer;
|
||||
static inline bool m_bFreezeTime;
|
||||
static inline bool m_bSyncTime;
|
||||
static inline uint m_nSyncTimer;
|
||||
static inline bool m_bMissionLoaderWarningShown;
|
||||
|
||||
Game();
|
||||
static void Draw();
|
||||
static void RealTimeClock();
|
||||
|
||||
#ifdef GTASA
|
||||
// TODO: Update freecam with aap's code
|
||||
static void FreeCam();
|
||||
static void ClearFreecamStuff();
|
||||
#endif
|
||||
|
@ -21,11 +21,16 @@ Visual::Visual()
|
||||
Events::processScriptsEvent += []
|
||||
{
|
||||
// TODO: Needs improvement
|
||||
static short m_nBacWeatherType;
|
||||
if (m_bLockWeather)
|
||||
{
|
||||
CWeather::OldWeatherType = m_nBacWeatherType;
|
||||
CWeather::NewWeatherType = m_nBacWeatherType;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nBacWeatherType = CWeather::OldWeatherType;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -320,11 +325,7 @@ void Visual::Draw()
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Ui::CheckboxWithHint("Lock weather", &m_bLockWeather))
|
||||
{
|
||||
m_nBacWeatherType = CWeather::OldWeatherType;
|
||||
}
|
||||
|
||||
Ui::CheckboxWithHint("Lock weather", &m_bLockWeather);
|
||||
if (Ui::CheckboxWithHint("No water", &m_bNoWater))
|
||||
{
|
||||
if (m_bNoWater)
|
||||
@ -357,10 +358,7 @@ void Visual::Draw()
|
||||
Ui::CheckboxAddressEx("Unfog map", 0xBA372C, 0x50, 0x0);
|
||||
#elif GTAVC
|
||||
Ui::CheckboxAddress("Hide radar", 0xA10AB6);
|
||||
if (Ui::CheckboxWithHint("Lock weather", &m_bLockWeather))
|
||||
{
|
||||
m_nBacWeatherType = CWeather::OldWeatherType;
|
||||
}
|
||||
Ui::CheckboxWithHint("Lock weather", &m_bLockWeather);
|
||||
Ui::CheckboxAddress("Show hud", 0x86963A);
|
||||
|
||||
ImGui::NextColumn();
|
||||
|
@ -1,17 +1,18 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
|
||||
class Visual
|
||||
{
|
||||
private:
|
||||
static inline bool m_bLockWeather;
|
||||
static inline int m_nBacWeatherType;
|
||||
|
||||
#ifdef GTASA
|
||||
static inline bool m_bInvisibleWater;
|
||||
static inline bool m_bNoWater;
|
||||
static inline bool m_bDisableHydrant;
|
||||
#endif
|
||||
// Timecyc
|
||||
|
||||
// Timecyc stuff
|
||||
static inline int m_nTimecycHour = 8;
|
||||
static inline std::vector<std::string> m_WeatherNames
|
||||
{
|
||||
@ -25,8 +26,7 @@ private:
|
||||
static void GenerateTimecycFile();
|
||||
static int CalcArrayIndex();
|
||||
static bool TimeCycColorEdit3(const char* label, uchar* r, uchar* g, uchar* b, ImGuiColorEditFlags flags = 0);
|
||||
static bool TimeCycColorEdit4(const char* label, uchar* r, uchar* g, uchar* b, uchar* a,
|
||||
ImGuiColorEditFlags flags = 0);
|
||||
static bool TimeCycColorEdit4(const char* label, uchar* r, uchar* g, uchar* b, uchar* a, ImGuiColorEditFlags flags = 0);
|
||||
template <typename T>
|
||||
static void TimecycSlider(const char* label, T* data, int min, int max);
|
||||
public:
|
||||
@ -39,6 +39,7 @@ void Visual::TimecycSlider(const char* label, T* ptr, int min, int max)
|
||||
{
|
||||
int val = CalcArrayIndex();
|
||||
#ifdef GTASA
|
||||
// Compatable with 24h TimeCyc
|
||||
T* arr = static_cast<T*>(patch::GetPointer(int(ptr)));
|
||||
#elif GTAVC
|
||||
T* arr = static_cast<T*>(ptr);
|
||||
|
Loading…
Reference in New Issue
Block a user