Skip to content

Commit

Permalink
[cheat] Fixed some bugs, prepared for next release.
Browse files Browse the repository at this point in the history
  • Loading branch information
oxiKKK committed Jun 19, 2023
1 parent 50a0bd9 commit 315cd84
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.vs/
build/
deploy/
.vscode/
.vscode/
src/libs/
4 changes: 1 addition & 3 deletions src/cheat/InCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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();
}
Expand Down
10 changes: 10 additions & 0 deletions src/cheat/hook/MemoryFnDetour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 2 additions & 4 deletions src/cheat/ui/UIKeyBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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); });
}
}

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/cheat/ui/UIMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
2 changes: 1 addition & 1 deletion src/cheat/ui/UIMenuWidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<void()>& 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();

Expand Down
9 changes: 9 additions & 0 deletions src/gui/GLFWApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
1 change: 1 addition & 0 deletions src/loader/loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ int CMainLoader::run(HINSTANCE hinst)
unload_dependencies();

release_handles();

return RET_SUCCESS;
}

Expand Down
2 changes: 2 additions & 0 deletions src/public/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions src/public/DeveloperConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ CDeveloperConsole::CDeveloperConsole()
CDeveloperConsole::~CDeveloperConsole()
{
g_devconsole_i = nullptr;

shutdown();
}

static std::string remove_extension(const std::string& filename) {
Expand Down

0 comments on commit 315cd84

Please sign in to comment.