From 315cd84724770aad40742f4328c3579c49d5197e Mon Sep 17 00:00:00 2001 From: oxiKKK Date: Mon, 19 Jun 2023 23:41:29 +0200 Subject: [PATCH] [cheat] Fixed some bugs, prepared for next release. --- .gitignore | 3 ++- src/cheat/InCommands.cpp | 4 +--- src/cheat/hook/MemoryFnDetour.cpp | 10 ++++++++++ src/cheat/ui/UIKeyBinding.cpp | 6 ++---- src/cheat/ui/UIMenu.cpp | 2 +- src/cheat/ui/UIMenuWidgets.cpp | 2 +- src/gui/GLFWApp.cpp | 9 +++++++++ src/loader/loader.cpp | 1 + src/public/Console.cpp | 2 ++ src/public/DeveloperConsole.cpp | 2 -- 10 files changed, 29 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index d1b7094..fe303b7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ .vs/ build/ deploy/ -.vscode/ \ No newline at end of file +.vscode/ +src/libs/ \ No newline at end of file diff --git a/src/cheat/InCommands.cpp b/src/cheat/InCommands.cpp index 0bc66e0..7956e4a 100644 --- a/src/cheat/InCommands.cpp +++ b/src/cheat/InCommands.cpp @@ -274,7 +274,7 @@ void CInCommands::update() if (did_start_key_binding_mode) { int vk_pressed = g_user_input_i->get_bound_key(); - if (vk_pressed != NULL && g_user_input_i->is_in_key_binding_mode()) + if (vk_pressed != NULL) { // a key was just bound from the UserInput code @@ -300,8 +300,6 @@ void CInCommands::add_keyscan_button(BaseInCommand* in_cmd, const Vector2D& size bool b = g_gui_widgets_i->add_button(std::format("{}##{}", key_name, in_cmd->get_name()), size, false, BUTTONFLAG_CenterLabel); if (b) { - assert(m_in_cmd_to_be_rebound == nullptr && "InCommand binding wasn't finished! m_in_cmd_to_be_rebound isn't null!"); - m_in_cmd_to_be_rebound = in_cmd; g_user_input_i->activate_key_binding_mode(); } diff --git a/src/cheat/hook/MemoryFnDetour.cpp b/src/cheat/hook/MemoryFnDetour.cpp index 1020311..c34e2a4 100644 --- a/src/cheat/hook/MemoryFnDetour.cpp +++ b/src/cheat/hook/MemoryFnDetour.cpp @@ -783,6 +783,11 @@ bool R_StudioDrawPlayer_FnDetour_t::install() int R_StudioDrawPlayer_FnDetour_t::R_StudioDrawPlayer(int flags, hl::entity_state_t* pplayer) { + if (CMemoryFnDetourMgr::the().exit_if_uninstalling()) + { + return CMemoryFnDetourMgr::the().R_StudioDrawPlayer().call(flags, pplayer); + } + if (CRemovals::the().remove_player(pplayer->number)) { return 0; @@ -851,6 +856,11 @@ bool SCR_DrawFPS_FnDetour_t::install() void SCR_DrawFPS_FnDetour_t::SCR_DrawFPS() { + if (CMemoryFnDetourMgr::the().exit_if_uninstalling()) + { + return; + } + // this is in fact a good place to render custom engine stuff from CEngineRendering::the().repaint(); diff --git a/src/cheat/ui/UIKeyBinding.cpp b/src/cheat/ui/UIKeyBinding.cpp index 3d0782e..e8cd7db 100644 --- a/src/cheat/ui/UIKeyBinding.cpp +++ b/src/cheat/ui/UIKeyBinding.cpp @@ -394,12 +394,12 @@ void CUIKeyBinding::render_interactible_bind_list() g_gui_widgets_i->add_text("Use the \"bind\" or \"bind_on_push_and_release\" command to bind command to a key. Example:", TEXTPROP_Wrapped); g_gui_widgets_i->add_bullet_text("bind \"f4\" \"ui_toggle_menu\" - This command binds the UI toggle command to f4.", TEXTPROP_Wrapped); - g_gui_widgets_i->add_bullet_text("bind_on_push_and_release\"f5\" \"print pushed!\" \"print unpushed!\" - As soon as f4 is pressed, \"pushed!\" is printed to the console. As soon as it is unpressed, \"unpushed!\" is printed.", TEXTPROP_Wrapped); + g_gui_widgets_i->add_bullet_text("bind_on_push_and_release \"f5\" \"print pushed!\" \"print unpushed!\" - As soon as f5 is pressed, \"pushed!\" is printed to the console. As soon as it is unpressed, \"unpushed!\" is printed.", TEXTPROP_Wrapped); g_gui_widgets_i->add_padding({ 0.0f, 10.0f }); g_gui_widgets_i->add_separtor_with_text("Binding through the UI"); - g_gui_widgets_i->add_text("Use the UI to bind any command sequence to a key. Inside the \"bind\" tab, there are all of the current binds listed.", TEXTPROP_Wrapped); }); + g_gui_widgets_i->add_text("Use the UI to bind any command sequence to a key. Inside the \"Binds\" tab, there are all of the current binds listed.", TEXTPROP_Wrapped); }); } } @@ -499,8 +499,6 @@ void CUIKeyBinding::update_keyscan_button_title(int new_vk) void CUIKeyBinding::switch_to_key_binding_mode(key_scan_button_info_t* info, const fnOnKeyBoundCallback& on_key_bound_callback) { - assert(!m_current_key_bound && "Tried to bind new key while the old one was still in the process of binding!"); - m_current_key_bound = info; if (!m_on_key_bound_callback) diff --git a/src/cheat/ui/UIMenu.cpp b/src/cheat/ui/UIMenu.cpp index 504f614..e815bce 100644 --- a/src/cheat/ui/UIMenu.cpp +++ b/src/cheat/ui/UIMenu.cpp @@ -204,7 +204,7 @@ void CUIMenu::on_render() window_flags &= ~ImGuiWindowFlags_NoResize; } - auto segoeui_extra = g_gui_fontmgr_i->get_font(FID_SegoeUI, FontSize::UIText.extra(), FDC_Bold); + auto segoeui_extra = g_gui_fontmgr_i->get_font(FID_SegoeUI, FontSize::UIText.extra(1.1f), FDC_Bold); auto segoeui_small = g_gui_fontmgr_i->get_font(FID_SegoeUI, FontSize::UIText.small(), FDC_Bold); g_gui_widgets_i->push_stylevar(ImGuiStyleVar_WindowPadding, { 0.0f, 0.0f }); diff --git a/src/cheat/ui/UIMenuWidgets.cpp b/src/cheat/ui/UIMenuWidgets.cpp index f357919..fd8bb09 100644 --- a/src/cheat/ui/UIMenuWidgets.cpp +++ b/src/cheat/ui/UIMenuWidgets.cpp @@ -315,7 +315,7 @@ void CUIMenuWidgets::feature_enabled_section(VarBoolean* var_boolean, const std: void CUIMenuWidgets::feature_enabled_section(VarBoolean* var_boolean, VarColor* colors_var, const std::function& callback, bool alpha, const std::string& title, bool see_if_enabled) { - add_checkbox(std::format("{}##{}", title, var_boolean->get_name()), var_boolean); + add_checkbox_with_color(std::format("{}##{}", title, var_boolean->get_name()), var_boolean, colors_var, alpha); bool enabled = var_boolean->get_value(); diff --git a/src/gui/GLFWApp.cpp b/src/gui/GLFWApp.cpp index 7ca4ab2..b3f55af 100644 --- a/src/gui/GLFWApp.cpp +++ b/src/gui/GLFWApp.cpp @@ -170,6 +170,15 @@ void CGLFWApp::glfw_update() // GLFW code goes here... glfwSetWindowTitle(m_glfw_window, m_app_title.c_str()); + // always keep the window at the same size. There was some bug where the window would randomly + // resize due to CS resolution change or whatever, just random things. prevent that from happening. + int w, h; + glfwGetWindowSize(m_glfw_window, &w, &h); + if (w != m_app_width || h != m_app_height) + { + glfwSetWindowSize(m_glfw_window, m_app_width, m_app_height); + } + // Renderer code goes here... g_imgui_platform_layer_i->render(); diff --git a/src/loader/loader.cpp b/src/loader/loader.cpp index f9e2bfd..19457a1 100644 --- a/src/loader/loader.cpp +++ b/src/loader/loader.cpp @@ -103,6 +103,7 @@ int CMainLoader::run(HINSTANCE hinst) unload_dependencies(); release_handles(); + return RET_SUCCESS; } diff --git a/src/public/Console.cpp b/src/public/Console.cpp index 01e60a4..675da49 100644 --- a/src/public/Console.cpp +++ b/src/public/Console.cpp @@ -68,6 +68,8 @@ void CConsole::destroy() if (m_devcon_i) { m_devcon_i->unregister_module(m_current_module); + + m_devcon_i->shutdown(); } m_initialized = false; diff --git a/src/public/DeveloperConsole.cpp b/src/public/DeveloperConsole.cpp index 1351849..09fd7cf 100644 --- a/src/public/DeveloperConsole.cpp +++ b/src/public/DeveloperConsole.cpp @@ -196,8 +196,6 @@ CDeveloperConsole::CDeveloperConsole() CDeveloperConsole::~CDeveloperConsole() { g_devconsole_i = nullptr; - - shutdown(); } static std::string remove_extension(const std::string& filename) {