From 13c191d0dde7c67fdafb5f23dabd3523cf39cca4 Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Sun, 11 Jul 2021 15:05:17 +0600 Subject: [PATCH] Check updates once a day, fix config save issue --- CheatMenu/CheatMenu.cpp | 24 ++++++++++++++++++++++-- CheatMenu/Json.h | 1 + CheatMenu/Updater.cpp | 1 + CheatMenu/Visual.cpp | 2 +- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/CheatMenu/CheatMenu.cpp b/CheatMenu/CheatMenu.cpp index 9467114..e0590d8 100644 --- a/CheatMenu/CheatMenu.cpp +++ b/CheatMenu/CheatMenu.cpp @@ -7,11 +7,20 @@ void CheatMenu::DrawWindow() { ImGuiIO& io = ImGui::GetIO(); + static bool game_running = true; if (FrontEndMenuManager.m_bMenuActive) - m_bShowMouse = false; + { + if (game_running) + { + config.WriteToDisk(); + game_running = false; + m_bShowMouse = false; + } + } else { + game_running = true; if (Globals::m_bShowMenu || m_Commands::m_bShowMenu) { if (Globals::m_bShowMenu) @@ -75,7 +84,9 @@ CheatMenu::CheatMenu() if (m_bShowMouse != Globals::m_bShowMenu) { if (m_bShowMouse) // Only write when the menu closes + { config.WriteToDisk(); + } m_bShowMouse = Globals::m_bShowMenu; } @@ -187,7 +198,16 @@ void MenuThread(void* param) GITHUB_LINK "\n" << std::endl; CFastman92limitAdjuster::Init(); CheatMenu menu; - Updater::CheckForUpdate(); + + time_t now = time(0); + struct tm tstruct = *localtime(&now); + int last_check_date = config.GetValue("config.last_update_checked", 0); + + if (last_check_date != tstruct.tm_mday) + { + Updater::CheckForUpdate(); + config.SetValue("config.last_update_checked", tstruct.tm_mday); + } while (true) { diff --git a/CheatMenu/Json.h b/CheatMenu/Json.h index 7e1565d..6de8e25 100644 --- a/CheatMenu/Json.h +++ b/CheatMenu/Json.h @@ -5,6 +5,7 @@ class CJson { private: std::string m_FilePath; + public: nlohmann::json m_Data; diff --git a/CheatMenu/Updater.cpp b/CheatMenu/Updater.cpp index 290319e..ef2bf48 100644 --- a/CheatMenu/Updater.cpp +++ b/CheatMenu/Updater.cpp @@ -2,6 +2,7 @@ #include "Updater.h" #include "Ui.h" #include "MenuInfo.h" +#include "Util.h" void Updater::CheckForUpdate() { diff --git a/CheatMenu/Visual.cpp b/CheatMenu/Visual.cpp index 00471e4..c67f956 100644 --- a/CheatMenu/Visual.cpp +++ b/CheatMenu/Visual.cpp @@ -300,7 +300,7 @@ void Visual::Draw() ImGui::TextWrapped( "These options won't work if you got any mods that drastically changes the game hud. i.e. Mobile Hud, GTA 5 Hud etc."); ImGui::Spacing(); - Ui::ColorPickerAddress("Armourbar color", *(int*)0x5890FC, ImVec4(180, 25, 29, 255)); + Ui::ColorPickerAddress("Armourbar color", *(int*)0x5890FC, ImVec4(225, 225, 225, 255)); Ui::EditAddress("Armourbar posX", 0x866B78, -999, 94, 999); Ui::EditAddress("Armourbar posY", 0x862D38, -999, 48, 999); Ui::ColorPickerAddress("Breathbar color", *(int*)0x5891EB, ImVec4(172, 203, 241, 255));