From 3a909e8aba3d01a11c4930a0dd15b757d798ef59 Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Sat, 16 Jan 2021 23:48:06 +0600 Subject: [PATCH] Improved hotkeys & more 1. Improved hotkey code #46 2. Added airbreak mode hotkey #47 3. Refactored code --- .vscode/c_cpp_properties.json | 1 - .vscode/settings.json | 3 +- src/CheatMenu.cpp | 12 ++---- src/Game.cpp | 58 ++++++++++++++++------------ src/Game.h | 4 +- src/Menu.cpp | 71 ++++++++++++++++++++--------------- src/Menu.h | 13 ++++--- src/MenuInfo.h | 2 +- src/Paint.cpp | 1 - src/Paint.h | 2 - src/Player.cpp | 4 +- src/Teleport.cpp | 4 +- src/Ui.cpp | 31 ++++++++------- src/Ui.h | 6 +-- src/Util.h | 1 - src/Vehicle.cpp | 4 +- src/Vehicle.h | 4 +- src/Visual.cpp | 10 ++--- src/pch.cpp | 2 - src/pch.h | 9 ++++- src/tests/CMakeLists.txt | 7 ---- src/tests/Dllmain.cpp | 31 --------------- src/tests/Test.cpp | 17 --------- 23 files changed, 131 insertions(+), 166 deletions(-) delete mode 100644 src/tests/Dllmain.cpp diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 79c095a..655de58 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -5,7 +5,6 @@ "includePath": [ "${workspaceFolder}/src/", "${DIRECTX9_SDK_DIR}/Include", - "C:/Program Files (x86)/DirectXSDK/Include", "${PLUGIN_SDK_DIR}/plugin_sa", "${PLUGIN_SDK_DIR}/plugin_sa/game_sa", "${PLUGIN_SDK_DIR}/shared", diff --git a/.vscode/settings.json b/.vscode/settings.json index 975f7e2..4af6456 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -75,7 +75,8 @@ "shared_mutex": "cpp", "thread": "cpp", "trampoline.h": "c", - "minhook.h": "c" + "minhook.h": "c", + "*.rh": "cpp" }, "C_Cpp.errorSquiggles": "Enabled", "C_Cpp.intelliSenseEngineFallback": "Enabled" diff --git a/src/CheatMenu.cpp b/src/CheatMenu.cpp index fbdd3d4..72ef016 100644 --- a/src/CheatMenu.cpp +++ b/src/CheatMenu.cpp @@ -59,16 +59,12 @@ CheatMenu::CheatMenu() Events::processScriptsEvent += [this] { - if (Globals::init_done && !FrontEndMenuManager.m_bMenuActive - && CTimer::m_snTimeInMilliseconds - Globals::last_key_timer > 250*CTimer::ms_fTimeScale) + if (Globals::init_done && !FrontEndMenuManager.m_bMenuActive) { - if (Ui::HotKeyPressed(hotkey::menu_open)) - { + if (Ui::HotKeyPressed(hotkeys::menu_open)) Globals::show_menu = !Globals::show_menu; - Globals::last_key_timer = CTimer::m_snTimeInMilliseconds; - } - if (Ui::HotKeyPressed(hotkey::command_window)) + if (Ui::HotKeyPressed(hotkeys::command_window)) { if (Menu::commands::show_menu) { @@ -76,8 +72,6 @@ CheatMenu::CheatMenu() strcpy(commands::input_buffer,""); } Menu::commands::show_menu = !Menu::commands::show_menu; - - Globals::last_key_timer = CTimer::m_snTimeInMilliseconds; } if (Hook::show_mouse != Globals::show_menu) diff --git a/src/Game.cpp b/src/Game.cpp index a3c467b..3501041 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -94,7 +94,7 @@ Game::Game() if (ss_shortcut) { - if (Ui::HotKeyPressed(Menu::hotkey::quick_ss) && timer - ss_shotcut_timer > 1000) + if (Ui::HotKeyPressed(Menu::hotkeys::quick_ss) && timer - ss_shotcut_timer > 1000) { Command(); CHud::SetHelpMessage("Screenshot taken", false, false, false); @@ -160,11 +160,18 @@ Game::Game() } } } - - if (airbreak::enable) + + if (Ui::HotKeyPressed(Menu::hotkeys::airbreak)) { - AirbreakMode(player,hplayer); + if (airbreak::enable) + { + airbreak::enable = false; + ClearAirbreakStuff(); + } + else airbreak::enable = true; } + if (airbreak::enable) + AirbreakMode(player,hplayer); }; } @@ -250,6 +257,28 @@ void Game::AirbreakMode(CPlayerPed* player, int hplayer) player->SetPosn(pos); } +void Game::ClearAirbreakStuff() +{ + CPlayerPed *player = FindPlayerPed(); + uint hplayer = CPools::GetPedRef(player); + + airbreak::init_done = false; + Command(0, false); + Command(hplayer, false); + Command(hplayer, true); + Command(hplayer, true); + player->m_nPedFlags.bDontRender = false; + + CHud::bScriptDontDisplayRadar = false; + CHud::m_Wants_To_Draw_Hud = true; + + CVector pos = player->GetPosition(); + CEntity* player_entity = FindPlayerEntity(-1); + pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, 0, &player_entity) + 0.5f; + player->SetPosn(pos); + Command(); +} + void Game::Main() { ImGui::Spacing(); @@ -308,7 +337,7 @@ of LS without completing missions")) Command(keep_stuff); Command(keep_stuff); } - Ui::CheckboxWithHint("Screenshot shortcut", &ss_shortcut, (("Take screenshot using ") + Ui::GetHotKeyNameString(Menu::hotkey::quick_ss) + Ui::CheckboxWithHint("Screenshot shortcut", &ss_shortcut, (("Take screenshot using ") + Ui::GetHotKeyNameString(Menu::hotkeys::quick_ss) + "\nSaved inside 'GTA San Andreas User Files\\Gallery'").c_str()); if (Ui::CheckboxWithHint("Solid water", &solid_water, "Player can walk on water")) { @@ -320,7 +349,6 @@ of LS without completing missions")) } if (ImGui::Checkbox("Sync system time", &sync_time)) { - Globals::gsync_time = sync_time; if (sync_time) patch::RedirectCall(0x53BFBD, &RealTimeClock); else @@ -338,23 +366,7 @@ of LS without completing missions")) \nLeft: J\t\t Right: L\n\nSlower: RCtrl\tFaster: RShift")) { if (!airbreak::enable) - { - airbreak::init_done = false; - Command(0, false); - Command(hplayer, false); - Command(hplayer, true); - Command(hplayer, true); - player->m_nPedFlags.bDontRender = false; - - CHud::bScriptDontDisplayRadar = false; - CHud::m_Wants_To_Draw_Hud = true; - - CVector pos = player->GetPosition(); - CEntity* player_entity = FindPlayerEntity(-1); - pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, 0, &player_entity) + 0.5f; - player->SetPosn(pos); - Command(); - } + ClearAirbreakStuff(); } ImGui::Spacing(); diff --git a/src/Game.h b/src/Game.h index e52ae67..ced21af 100644 --- a/src/Game.h +++ b/src/Game.h @@ -1,7 +1,7 @@ #pragma once class Game { -private: +public: static CJson json; static ImGuiTextFilter filter; static std::vector search_categories; @@ -49,10 +49,10 @@ private: static std::string selected_item; }; -public: Game(); ~Game(); static void Main(); static void AirbreakMode(CPlayerPed* player, int hplayer); + static void ClearAirbreakStuff(); }; diff --git a/src/Menu.cpp b/src/Menu.cpp index 03d95a2..e7fa9da 100644 --- a/src/Menu.cpp +++ b/src/Menu.cpp @@ -18,11 +18,12 @@ int Menu::overlay::selected_pos = 4; float Menu::overlay::posX = NULL; float Menu::overlay::posY = NULL; -int Menu::hotkey::command_window[]{ VK_LMENU ,VK_KEY_C }; -int Menu::hotkey::menu_open[]{VK_LCONTROL ,VK_KEY_M}; -int Menu::hotkey::aim_skin_changer[]{ VK_RETURN ,VK_RETURN }; -int Menu::hotkey::quick_ss[]{ VK_LCONTROL ,VK_KEY_S }; -int Menu::hotkey::quick_tp[]{ VK_KEY_X ,VK_KEY_Y }; +HotKeyData Menu::hotkeys::command_window{}; +HotKeyData Menu::hotkeys::menu_open{}; +HotKeyData Menu::hotkeys::aim_skin_changer{}; +HotKeyData Menu::hotkeys::quick_ss{}; +HotKeyData Menu::hotkeys::quick_tp{}; +HotKeyData Menu::hotkeys::airbreak{}; bool Menu::commands::show_menu = false; char Menu::commands::input_buffer[INPUT_BUFFER_SIZE] = ""; @@ -44,20 +45,23 @@ Menu::Menu() overlay::posY = config.GetValue("overlay.posY", 0); // Hotkeys - hotkey::aim_skin_changer[0] = config.GetValue("hotkey.aim_skin_changer.key1", VK_RETURN); - hotkey::aim_skin_changer[1] = config.GetValue("hotkey.aim_skin_changer.key2", VK_RETURN); + hotkeys::aim_skin_changer.key1 = config.GetValue("hotkey.aim_skin_changer.key1", VK_RETURN); + hotkeys::aim_skin_changer.key2 = config.GetValue("hotkey.aim_skin_changer.key2", VK_RETURN); - hotkey::quick_ss[0] = config.GetValue("hotkey.quick_screenshot.key1", VK_LCONTROL); - hotkey::quick_ss[1] = config.GetValue("hotkey.quick_screenshot.key2", VK_KEY_S); + hotkeys::airbreak.key1 = config.GetValue("hotkey.airbreak.key1", VK_LMENU); + hotkeys::airbreak.key2 = config.GetValue("hotkey.airbreak.key2", VK_KEY_A); - hotkey::quick_tp[0] = config.GetValue("hotkey.quick_tp.key1", VK_KEY_X); - hotkey::quick_tp[1] = config.GetValue("hotkey.quick_tp.key2", VK_KEY_Y); + hotkeys::quick_ss.key1 = config.GetValue("hotkey.quick_screenshot.key1", VK_LCONTROL); + hotkeys::quick_ss.key2 = config.GetValue("hotkey.quick_screenshot.key2", VK_KEY_S); - hotkey::menu_open[0] = config.GetValue("hotkey.menu_open.key1", VK_LCONTROL); - hotkey::menu_open[1] = config.GetValue("hotkey.menu_open.key2", VK_KEY_M); + hotkeys::quick_tp.key1 = config.GetValue("hotkey.quick_tp.key1", VK_KEY_X); + hotkeys::quick_tp.key2 = config.GetValue("hotkey.quick_tp.key2", VK_KEY_Y); - hotkey::command_window[0] = config.GetValue("hotkey.command_window.key1", VK_LMENU); - hotkey::command_window[1] = config.GetValue("hotkey.command_window.key2", VK_KEY_C); + hotkeys::menu_open.key1 = config.GetValue("hotkey.menu_open.key1", VK_LCONTROL); + hotkeys::menu_open.key2 = config.GetValue("hotkey.menu_open.key2", VK_KEY_M); + + hotkeys::command_window.key1 = config.GetValue("hotkey.command_window.key1", VK_LMENU); + hotkeys::command_window.key2 = config.GetValue("hotkey.command_window.key2", VK_KEY_C); }; } @@ -315,33 +319,38 @@ void Menu::Main() ImGui::Spacing(); ImGui::BeginChild("Hotkeys"); - if (Ui::HotKey("Open/ close cheat menu", hotkey::menu_open)) + if (Ui::HotKey("Open/ close cheat menu", hotkeys::menu_open)) { - config.SetValue("hotkey.menu_open.key1", hotkey::menu_open[0]); - config.SetValue("hotkey.menu_open.key2", hotkey::menu_open[1]); + config.SetValue("hotkey.menu_open.key1", hotkeys::menu_open.key1); + config.SetValue("hotkey.menu_open.key2", hotkeys::menu_open.key2); } - if (Ui::HotKey("Open/ close command window", hotkey::command_window)) + if (Ui::HotKey("Open/ close command window", hotkeys::command_window)) { - config.SetValue("hotkey.command_window.key1", hotkey::command_window[0]); - config.SetValue("hotkey.command_window.key2", hotkey::command_window[1]); + config.SetValue("hotkey.command_window.key1", hotkeys::command_window.key1); + config.SetValue("hotkey.command_window.key2", hotkeys::command_window.key2); } ImGui::Dummy(ImVec2(0,10)); - if (Ui::HotKey("Activate aim skin changer", hotkey::aim_skin_changer)) + if (Ui::HotKey("Activate aim skin changer", hotkeys::aim_skin_changer)) { - config.SetValue("hotkey.aim_skin_changer.key1", hotkey::aim_skin_changer[0]); - config.SetValue("hotkey.aim_skin_changer.key2", hotkey::aim_skin_changer[1]); + config.SetValue("hotkey.aim_skin_changer.key1", hotkeys::aim_skin_changer.key1); + config.SetValue("hotkey.aim_skin_changer.key2", hotkeys::aim_skin_changer.key2); } - if (Ui::HotKey("Take quick screenshot", hotkey::quick_ss)) + if (Ui::HotKey("Airbreak mode", hotkeys::airbreak)) { - config.SetValue("hotkey.quick_screenshot.key1", hotkey::quick_ss[0]); - config.SetValue("hotkey.quick_screenshot.key2", hotkey::quick_ss[1]); + config.SetValue("hotkey.airbreak.key1", hotkeys::airbreak.key1); + config.SetValue("hotkey.airbreak.key2", hotkeys::airbreak.key2); } - if (Ui::HotKey("Toggle quick teleport", hotkey::quick_tp)) + if (Ui::HotKey("Take quick screenshot", hotkeys::quick_ss)) { - config.SetValue("hotkey.quick_tp.key1", hotkey::quick_tp[0]); - config.SetValue("hotkey.quick_tp.key2", hotkey::quick_tp[1]); + config.SetValue("hotkey.quick_screenshot.key1", hotkeys::quick_ss.key1); + config.SetValue("hotkey.quick_screenshot.key2", hotkeys::quick_ss.key2); + } + if (Ui::HotKey("Toggle quick teleport", hotkeys::quick_tp)) + { + config.SetValue("hotkey.quick_tp.key1", hotkeys::quick_tp.key1); + config.SetValue("hotkey.quick_tp.key2", hotkeys::quick_tp.key2); } ImGui::Dummy(ImVec2(0, 10)); @@ -353,7 +362,7 @@ void Menu::Main() { if (ImGui::BeginChild("CommandsChild")) { - ImGui::TextWrapped(std::string("Open or close command window using " + Ui::GetHotKeyNameString(hotkey::command_window)).c_str()); + ImGui::TextWrapped(std::string("Open or close command window using " + Ui::GetHotKeyNameString(hotkeys::command_window)).c_str()); ImGui::Spacing(); if (ImGui::CollapsingHeader("Set health")) { diff --git a/src/Menu.h b/src/Menu.h index 5ba8c94..cc3688c 100644 --- a/src/Menu.h +++ b/src/Menu.h @@ -17,13 +17,14 @@ private: static float posY; }; public: - struct hotkey + struct hotkeys { - static int command_window[2]; - static int menu_open[2]; - static int aim_skin_changer[2]; - static int quick_ss[2]; - static int quick_tp[2]; + static HotKeyData command_window; + static HotKeyData menu_open; + static HotKeyData aim_skin_changer; + static HotKeyData quick_ss; + static HotKeyData quick_tp; + static HotKeyData airbreak; }; struct commands { diff --git a/src/MenuInfo.h b/src/MenuInfo.h index 384bc18..0812d5c 100644 --- a/src/MenuInfo.h +++ b/src/MenuInfo.h @@ -1,5 +1,5 @@ #pragma once #define MENU_NAME "Cheat Menu" -#define MENU_VERSION "2.5-beta" +#define MENU_VERSION "2.6-beta" #define BUILD_NUMBER "20210114" #define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")" \ No newline at end of file diff --git a/src/Paint.cpp b/src/Paint.cpp index 25301c1..d4719ac 100644 --- a/src/Paint.cpp +++ b/src/Paint.cpp @@ -10,7 +10,6 @@ std::map> Paint::textures; Paint::Paint() { - Events::initGameEvent += [] { for (auto &p : fs::recursive_directory_iterator(PLUGIN_PATH((char*)"\\CheatMenu\\vehicles\\paintjobs\\"))) diff --git a/src/Paint.h b/src/Paint.h index 85af5f9..94ea338 100644 --- a/src/Paint.h +++ b/src/Paint.h @@ -14,8 +14,6 @@ public: }; static std::map> textures; -protected: - static void UpdateNodeListRecursive(CVehicle* pVeh); static void NodeWrapperRecursive(RwFrame * frame, CVehicle* pVeh, std::function func); static void SetNodeColor(CVehicle* pVeh, std::string node_name, CRGBA color, bool filter_mat = false); diff --git a/src/Player.cpp b/src/Player.cpp index 54d1bdf..65ea7a6 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -98,7 +98,7 @@ Player::Player() player->m_nPhysicalFlags.bMeeleProof = 1; } - if (aim_skin_changer && Ui::HotKeyPressed(Menu::hotkey::aim_skin_changer)) + if (aim_skin_changer && Ui::HotKeyPressed(Menu::hotkeys::aim_skin_changer)) { CPed *target_ped = player->m_pPlayerTargettedPed; if (target_ped) @@ -343,7 +343,7 @@ void Player::Main() if (ImGui::BeginTabItem("Appearance")) { ImGui::Spacing(); - if (Ui::CheckboxWithHint("Aim skin changer", &aim_skin_changer,(("Activate using Aim ped + ") + Ui::GetHotKeyNameString(Menu::hotkey::aim_skin_changer)).c_str())) + if (Ui::CheckboxWithHint("Aim skin changer", &aim_skin_changer,(("Activate using Aim ped + ") + Ui::GetHotKeyNameString(Menu::hotkeys::aim_skin_changer)).c_str())) config.SetValue("aim_skin_changer", aim_skin_changer); if (ImGui::BeginTabBar("AppearanceTabBar")) diff --git a/src/Teleport.cpp b/src/Teleport.cpp index f2be523..84c98e9 100644 --- a/src/Teleport.cpp +++ b/src/Teleport.cpp @@ -85,7 +85,7 @@ Teleport::Teleport() if (quick_teleport) { - if (Ui::HotKeyPressed(Menu::hotkey::quick_tp) + if (Ui::HotKeyPressed(Menu::hotkeys::quick_tp) && ((CTimer::m_snTimeInMilliseconds - quick_teleport_timer) > 500)) { quick_teleport_timer = CTimer::m_snTimeInMilliseconds; @@ -195,7 +195,7 @@ void Teleport::Main() ImGui::Checkbox("Insert coordinates", &insert_coord); ImGui::NextColumn(); if (Ui::CheckboxWithHint("Quick teleport", &quick_teleport, - (std::string("Teleport to marker using ") + Ui::GetHotKeyNameString(Menu::hotkey::quick_tp)).c_str())) + (std::string("Teleport to marker using ") + Ui::GetHotKeyNameString(Menu::hotkeys::quick_tp)).c_str())) { config.SetValue("quick_teleport", quick_teleport); } diff --git a/src/Ui.cpp b/src/Ui.cpp index d91d503..62045e7 100644 --- a/src/Ui.cpp +++ b/src/Ui.cpp @@ -782,7 +782,7 @@ void Ui::EditFloat(const char *label, const int address, const float min, const } } -bool Ui::HotKey(const char* label, int* key_array) +bool Ui::HotKey(const char* label, HotKeyData& key_data) { bool active = current_hotkey == label; bool state = false; @@ -795,7 +795,7 @@ bool Ui::HotKey(const char* label, int* key_array) { if (KeyPressed(key)) { - key_array[0] = key; + key_data.key1 = key; break; } } @@ -804,16 +804,16 @@ bool Ui::HotKey(const char* label, int* key_array) { if (KeyPressed(key)) { - key_array[1] = key; + key_data.key2 = key; break; } } } - std::string text = key_names[key_array[0]-1]; + std::string text = key_names[key_data.key1-1]; - if (key_array[0] != key_array[1]) - text += (" + " + key_names[key_array[1]-1]); + if (key_data.key1 != key_data.key2) + text += (" + " + key_names[key_data.key2-1]); if (ImGui::Button((text + std::string("##") + std::string(label)).c_str(), ImVec2(ImGui::GetWindowContentRegionWidth() / 3, ImGui::GetFrameHeight()))) { @@ -837,22 +837,27 @@ bool Ui::HotKey(const char* label, int* key_array) return state; } -bool Ui::HotKeyPressed(int *hotkey) +bool Ui::HotKeyPressed(HotKeyData& hotkey) { - return current_hotkey == "" && KeyPressed(hotkey[0]) && KeyPressed(hotkey[1]); + if (CTimer::m_snTimeInMilliseconds - hotkey.timer > 250*CTimer::ms_fTimeScale) + { + hotkey.timer = CTimer::m_snTimeInMilliseconds; + return current_hotkey == "" && KeyPressed(hotkey.key1) && KeyPressed(hotkey.key2); + } + else + return false; } -std::string Ui::GetHotKeyNameString(int *hotkey) +std::string Ui::GetHotKeyNameString(HotKeyData& hotkey) { - std::string text = key_names[hotkey[0] - 1]; + std::string text = key_names[hotkey.key1 - 1]; - if (hotkey[0] != hotkey[1]) - text += (" + " + key_names[hotkey[1] - 1]); + if (hotkey.key1 != hotkey.key2) + text += (" + " + key_names[hotkey.key2 - 1]); return text; } - bool Ui::ColorButton(int color_id, std::vector &color, ImVec2 size) { bool rtn = false; diff --git a/src/Ui.h b/src/Ui.h index fb731e3..a9ff772 100644 --- a/src/Ui.h +++ b/src/Ui.h @@ -61,9 +61,9 @@ public: static ImVec2 GetSize(short count = 1, bool spacing = true); - static bool HotKey(const char* label, int* key_array); - static bool HotKeyPressed(int *hotkey); - static std::string GetHotKeyNameString(int *hotkey); + static bool HotKey(const char* label, HotKeyData& key_data); + static bool HotKeyPressed(HotKeyData& hotkey); + static std::string GetHotKeyNameString(HotKeyData& hotkey); static bool ListBox(const char* label, std::vector& all_items, int& selected); static bool ListBoxStr(const char* label, std::vector& all_items, std::string& selected); diff --git a/src/Util.h b/src/Util.h index 63be040..76219d3 100644 --- a/src/Util.h +++ b/src/Util.h @@ -15,7 +15,6 @@ public: static std::string GetLocationName(CVector *pos); static void RainbowValues(int &r, int&g, int &b, float speed); - // This below source is taken from MoonAdditions https://github.com/THE-FYP/MoonAdditions // MIT License diff --git a/src/Vehicle.cpp b/src/Vehicle.cpp index d228012..7fc1740 100644 --- a/src/Vehicle.cpp +++ b/src/Vehicle.cpp @@ -156,8 +156,8 @@ Vehicle::Vehicle() if (veh->m_nVehicleClass == CLASS_EXECUTIVE) // Executive chance = rand() % 3 + 1; - if (chance == 1 && !IsNeonInstalled(veh) && veh->m_pDriver != player) - InstallNeon(veh, rand() % 255, rand() % 255, rand() % 255); + if (chance == 1 && !NeonAPI::IsNeonInstalled(veh) && veh->m_pDriver != player) + NeonAPI::InstallNeon(veh, rand() % 255, rand() % 255, rand() % 255); } neon::traffic_timer = timer; } diff --git a/src/Vehicle.h b/src/Vehicle.h index 81ecde6..6520fef 100644 --- a/src/Vehicle.h +++ b/src/Vehicle.h @@ -1,8 +1,8 @@ +#pragma once #include "NeonAPI.h" #include "Paint.h" -#pragma once -class Vehicle : NeonAPI, Paint +class Vehicle : Paint, NeonAPI { private: static bool bike_fly; diff --git a/src/Visual.cpp b/src/Visual.cpp index 76827d8..6c59c84 100644 --- a/src/Visual.cpp +++ b/src/Visual.cpp @@ -2,6 +2,7 @@ #include "Visual.h" #include "Ui.h" #include "Util.h" +#include "Game.h" bool Visual::lock_weather = false; int Visual::weather_type_backup = 0; @@ -257,28 +258,27 @@ void Visual::Main() int hour = CClock::ms_nGameClockHours; int minute = CClock::ms_nGameClockMinutes; - if (Globals::gsync_time) + if (Game::sync_time) { ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f); } - - if (ImGui::InputInt("Hour", &hour) & !Globals::gsync_time) + if (ImGui::InputInt("Hour", &hour) & !Game::sync_time) { if (hour < 0) hour = 23; if (hour > 23) hour = 0; CClock::ms_nGameClockHours = hour; } - if (ImGui::InputInt("Minute", &minute) & !Globals::gsync_time) + if (ImGui::InputInt("Minute", &minute) & !Game::sync_time) { if (minute < 0) minute = 59; if (minute > 59) minute = 0; CClock::ms_nGameClockMinutes = minute; } - if (Globals::gsync_time) + if (Game::sync_time) { ImGui::PopStyleVar(); ImGui::PopItemFlag(); diff --git a/src/pch.cpp b/src/pch.cpp index 45472bb..44d7943 100644 --- a/src/pch.cpp +++ b/src/pch.cpp @@ -1,13 +1,11 @@ #include "pch.h" std::string Globals::header_id = ""; -int Globals::last_key_timer = 0; ImVec2 Globals::menu_size = ImVec2(screen::GetScreenWidth()/4, screen::GetScreenHeight()/1.2); ImVec2 Globals::screen_size = ImVec2(-1, -1); bool Globals::show_menu = false; bool Globals::init_done = false; Renderer Globals::renderer = Render_Unknown; -bool Globals::gsync_time = false; void *Globals::device = nullptr; std::ofstream flog = std::ofstream("CheatMenu.log"); diff --git a/src/pch.h b/src/pch.h index 3b849f4..2f954ef 100644 --- a/src/pch.h +++ b/src/pch.h @@ -81,13 +81,11 @@ enum Renderer struct Globals { static std::string header_id; - static int last_key_timer; static ImVec2 menu_size; static ImVec2 screen_size; static bool show_menu; static bool init_done; static Renderer renderer; - static bool gsync_time; static void* device; }; @@ -98,5 +96,12 @@ struct TextureStructure void *texture = nullptr; }; +struct HotKeyData +{ + int key1; + int key2; + uint timer = 0; +}; + extern CJson config; extern std::ofstream flog; \ No newline at end of file diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 8189086..f0f5b29 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -11,14 +11,7 @@ project(Test) ################################################################################ set(test_files - "../vendor/fla/Main.h" - "../vendor/fla/Main.cpp" - "../vendor/fla/IDaccess.h" - "../vendor/fla/IDaccess.cpp" - "../vendor/fla/Library/Library.h" - "../vendor/fla/Library/Library.cpp" "Test.cpp" - "Dllmain.cpp" ) add_library(${PROJECT_NAME} SHARED ${test_files}) diff --git a/src/tests/Dllmain.cpp b/src/tests/Dllmain.cpp deleted file mode 100644 index 2bcaf01..0000000 --- a/src/tests/Dllmain.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include "../vendor\fla\Main.h" - -BOOL WINAPI DllMain( - HINSTANCE hinstDLL, // handle to DLL module - DWORD fdwReason, // reason for calling function - LPVOID lpReserved ) // reserved -{ - // Perform actions based on the reason for calling. - switch( fdwReason ) - { - case DLL_PROCESS_ATTACH: - // Initialize once for each new process. - // Return FALSE to fail DLL load. - CFastman92limitAdjuster::Init(); - break; - - case DLL_THREAD_ATTACH: - // Do thread-specific initialization. - break; - - case DLL_THREAD_DETACH: - // Do thread-specific cleanup. - break; - - case DLL_PROCESS_DETACH: - // Perform any necessary cleanup. - break; - } - return TRUE; // Successful DLL_PROCESS_ATTACH. -} \ No newline at end of file diff --git a/src/tests/Test.cpp b/src/tests/Test.cpp index 7cca001..da0141e 100644 --- a/src/tests/Test.cpp +++ b/src/tests/Test.cpp @@ -1,5 +1,4 @@ #include "plugin.h" -#include "../vendor/fla/IDaccess.h" #include "CHud.h" using namespace plugin; @@ -9,25 +8,9 @@ class Test public: Test() { - Events::initRwEvent += [] - { - CFastman92limitAdjuster::Init(); - }; - Events::processScriptsEvent += [] { - CPlayerPed *player = FindPlayerPed(); - if(KeyPressed(VK_UP) && player && player->m_pVehicle) - { - uint8_replacement &primary_color = *(uint8_replacement*)&player->m_pVehicle->m_nPrimaryColor; - primary_color = 74; - CHud::SetHelpMessage("Color changed",false,false,false); - } - if(KeyPressed(VK_DOWN)) - { - - } }; } } test;