From f1794edcc60f6a27e622884c82397bb77e2aa280 Mon Sep 17 00:00:00 2001 From: salmonik Date: Tue, 27 Oct 2026 18:31:27 +0100 Subject: GUI: wire real feature state and config Replace the dummy preview controls with the actual settings: - cards bind directly to the feature state and the existing option variables; Active/Bind now drive the same gates as the text menu; - every feature persists active+bind, including movement, melee and spread; - config path and build info are real; Reload config re-reads the INI; - Reset defaults is two-click, restores feature settings/binds and keeps the GUI layout; - window position, category and expanded cards persist under [gui] in the same config file; layout saves on drag/category/expand/close; - mouse bind capture handles all five buttons and consumes the click so it cannot re-arm immediately; - Active/Bind tooltips and full scancode names. The old text tree stays on F1 for one verification pass. --- src/menu.cpp | 117 ++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 71 insertions(+), 46 deletions(-) (limited to 'src/menu.cpp') diff --git a/src/menu.cpp b/src/menu.cpp index a0cf323..2a96b02 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -52,47 +52,33 @@ struct MenuNode { int value_step = 0; }; -// feature data -struct FeatureState { - bool active; - int bind; // SDL scancode, 0 = none -}; - -static FeatureState g_bhop{true, 0}; -static bool g_bhop_autostrafe = true; - -static FeatureState g_abh{true, 0}; -static FeatureState g_jumpbug{true, 0}; -static bool g_jumpbug_assist = false; -static FeatureState g_melee{true, 0}; -static FeatureState g_spread{true, 0}; -static bool g_spread_no_spread = true; -static FeatureState g_esp{true, 0}; -static FeatureState g_aimbot{true, 604}; // default Mouse5, rebindable in menu -static FeatureState g_triggerbot{true, 603}; // default Mouse4 -static FeatureState g_silentaim{true, 602}; // default Mouse3 +// feature data (declared in hl2h.h; shared with the GUI) +FeatureState g_bhop{true, 0}; +bool g_bhop_autostrafe = true; + +FeatureState g_abh{true, 0}; +FeatureState g_jumpbug{true, 0}; +bool g_jumpbug_assist = false; +FeatureState g_melee{true, 0}; +FeatureState g_spread{true, 0}; +bool g_spread_no_spread = true; +FeatureState g_esp{true, 0}; +FeatureState g_aimbot{true, 604}; // default Mouse5, rebindable in menu +FeatureState g_triggerbot{true, 603}; // default Mouse4 +FeatureState g_silentaim{true, 602}; // default Mouse3 // Aimbot bone checklist. Head defaults on (v1 behaviour). -enum { - AIM_BONE_HEAD = 0, - AIM_BONE_TORSO, - AIM_BONE_LARM, - AIM_BONE_RARM, - AIM_BONE_LLEG, - AIM_BONE_RLEG, - AIM_BONE_COUNT -}; -static bool g_aim_bones[AIM_BONE_COUNT] = {true, false, false, - false, false, false}; -static int g_aim_smooth = 5; // degrees per tick -static bool g_aim_vischeck = true; -static int g_aim_fov = 60; // angular distance from the crosshair -static bool g_aim_fov_circle = true; -static int g_silent_fov = 60; +bool g_aim_bones[AIM_BONE_COUNT] = {true, false, false, + false, false, false}; +int g_aim_smooth = 5; // degrees per tick +bool g_aim_vischeck = true; +int g_aim_fov = 60; // angular distance from the crosshair +bool g_aim_fov_circle = true; +int g_silent_fov = 60; // ESP sub-options (menu "ESP" children). Defaults match the pre-option // behaviour: everything on. -static bool g_esp_opt[ESP_OPT_COUNT] = {true, true, true, true, true, true, true}; +bool g_esp_opt[ESP_OPT_COUNT] = {true, true, true, true, true, true, true}; // tree static MenuNode g_root{NODE_ROOT, "HL2hake", false, 0, {}, nullptr, nullptr, nullptr}; @@ -315,18 +301,18 @@ void register_bundled_font() { logf("font: failed to register %s", path.c_str()); } -static void config_save() { +void config_save() { FILE *f = fopen(config_path().c_str(), "w"); if (!f) return; fprintf(f, "[bhop]\nactive=%d\nbind=%d\nautostrafe=%d\n", g_bhop.active, g_bhop.bind, g_bhop_autostrafe); fprintf(f, "[abh]\nactive=%d\nbind=%d\n", g_abh.active, g_abh.bind); - fprintf(f, "[jumpbug]\nactive=%d\nassist=%d\n", g_jumpbug.active, - (int)g_jumpbug_assist); - fprintf(f, "[melee]\nactive=%d\n", g_melee.active); - fprintf(f, "[spread]\nactive=%d\nno_spread=%d\n", g_spread.active, - (int)g_spread_no_spread); + fprintf(f, "[jumpbug]\nactive=%d\nbind=%d\nassist=%d\n", + g_jumpbug.active, g_jumpbug.bind, (int)g_jumpbug_assist); + fprintf(f, "[melee]\nactive=%d\nbind=%d\n", g_melee.active, g_melee.bind); + fprintf(f, "[spread]\nactive=%d\nbind=%d\nno_spread=%d\n", + g_spread.active, g_spread.bind, (int)g_spread_no_spread); fprintf(f, "[aimbot]\nactive=%d\nbind=%d\nsmooth=%d\nvischeck=%d\n" "fov=%d\nfov_circle=%d\n" "bone_head=%d\nbone_torso=%d\nbone_larm=%d\nbone_rarm=%d\n" @@ -347,6 +333,7 @@ static void config_save() { g_esp_opt[ESP_OPT_SHOW_HEALTHNUM], g_esp_opt[ESP_OPT_SHOW_NAME], g_esp_opt[ESP_OPT_SHOW_SKELETON], g_esp_opt[ESP_OPT_SHOW_BOX], g_esp_opt[ESP_OPT_SHOW_SPEEDGRAPH]); + gui_config_write(f); fclose(f); } @@ -462,6 +449,40 @@ static void config_load() { fclose(f); } +void config_reload() { config_load(); } + +const char *config_path_cstr() { + static std::string path; + path = config_path(); + return path.c_str(); +} + +void config_reset_defaults() { + g_bhop = {true, 0}; + g_bhop_autostrafe = true; + g_abh = {true, 0}; + g_jumpbug = {true, 0}; + g_jumpbug_assist = false; + g_melee = {true, 0}; + g_spread = {true, 0}; + g_spread_no_spread = true; + g_esp = {true, 0}; + for (int i = 0; i < ESP_OPT_COUNT; i++) + g_esp_opt[i] = true; + g_aimbot = {true, 604}; + g_triggerbot = {true, 603}; + g_silentaim = {true, 602}; + for (int i = 0; i < AIM_BONE_COUNT; i++) + g_aim_bones[i] = false; + g_aim_bones[AIM_BONE_HEAD] = true; + g_aim_smooth = 5; + g_aim_vischeck = true; + g_aim_fov = 60; + g_aim_fov_circle = true; + g_silent_fov = 60; + config_save(); +} + // --------------------------------------------------------------------------- // menu input handling // --------------------------------------------------------------------------- @@ -477,7 +498,7 @@ static constexpr int SCAN_ENTER = 40; static constexpr int SCAN_ESCAPE = 41; // simplified scancode-to-name for common keys -static const char *scancode_name(int sc) { +const char *scancode_name(int sc) { switch (sc) { case 0: return "None"; case 4: return "A"; case 5: return "B"; case 6: return "C"; @@ -497,9 +518,12 @@ static const char *scancode_name(int sc) { case 43: return "Tab"; case 44: return "Space"; case 79: return "Right"; case 80: return "Left"; case 81: return "Down"; case 82: return "Up"; - case 87: return "F1"; case 88: return "F2"; case 89: return "F3"; - case 90: return "F4"; case 91: return "F5"; case 92: return "F6"; - case 93: return "F7"; case 94: return "F8"; + case 58: return "F1"; case 59: return "F2"; case 60: return "F3"; + case 61: return "F4"; case 62: return "F5"; case 63: return "F6"; + case 64: return "F7"; case 65: return "F8"; case 66: return "F9"; + case 67: return "F10"; case 68: return "F11"; case 69: return "F12"; + case 73: return "Insert"; case 74: return "Home"; case 75: return "PgUp"; + case 76: return "Delete"; case 77: return "End"; case 78: return "PgDn"; case 600: return "MouseL"; case 601: return "MouseR"; case 602: return "MouseM"; case 603: return "Mouse4"; case 604: return "Mouse5"; @@ -1009,6 +1033,7 @@ void install_menu() { register_bundled_font(); logf("config: %s", config_path().c_str()); config_load(); + gui_config_init(); // resolve ISurface once (used by the DrawPrintText hook in hl2h.cpp and // by outer_draw). DrawPrintText hook is installed from hkdCreateMove. g_surface = find_surface_interface(); -- cgit v1.2.3