diff options
Diffstat (limited to '')
| -rw-r--r-- | src/menu.cpp | 117 |
1 files changed, 71 insertions, 46 deletions
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 { | |||
| 52 | int value_step = 0; | 52 | int value_step = 0; |
| 53 | }; | 53 | }; |
| 54 | 54 | ||
| 55 | // feature data | 55 | // feature data (declared in hl2h.h; shared with the GUI) |
| 56 | struct FeatureState { | 56 | FeatureState g_bhop{true, 0}; |
| 57 | bool active; | 57 | bool g_bhop_autostrafe = true; |
| 58 | int bind; // SDL scancode, 0 = none | 58 | |
| 59 | }; | 59 | FeatureState g_abh{true, 0}; |
| 60 | 60 | FeatureState g_jumpbug{true, 0}; | |
| 61 | static FeatureState g_bhop{true, 0}; | 61 | bool g_jumpbug_assist = false; |
| 62 | static bool g_bhop_autostrafe = true; | 62 | FeatureState g_melee{true, 0}; |
| 63 | 63 | FeatureState g_spread{true, 0}; | |
| 64 | static FeatureState g_abh{true, 0}; | 64 | bool g_spread_no_spread = true; |
| 65 | static FeatureState g_jumpbug{true, 0}; | 65 | FeatureState g_esp{true, 0}; |
| 66 | static bool g_jumpbug_assist = false; | 66 | FeatureState g_aimbot{true, 604}; // default Mouse5, rebindable in menu |
| 67 | static FeatureState g_melee{true, 0}; | 67 | FeatureState g_triggerbot{true, 603}; // default Mouse4 |
| 68 | static FeatureState g_spread{true, 0}; | 68 | FeatureState g_silentaim{true, 602}; // default Mouse3 |
| 69 | static bool g_spread_no_spread = true; | ||
| 70 | static FeatureState g_esp{true, 0}; | ||
| 71 | static FeatureState g_aimbot{true, 604}; // default Mouse5, rebindable in menu | ||
| 72 | static FeatureState g_triggerbot{true, 603}; // default Mouse4 | ||
| 73 | static FeatureState g_silentaim{true, 602}; // default Mouse3 | ||
| 74 | 69 | ||
| 75 | // Aimbot bone checklist. Head defaults on (v1 behaviour). | 70 | // Aimbot bone checklist. Head defaults on (v1 behaviour). |
| 76 | enum { | 71 | bool g_aim_bones[AIM_BONE_COUNT] = {true, false, false, |
| 77 | AIM_BONE_HEAD = 0, | 72 | false, false, false}; |
| 78 | AIM_BONE_TORSO, | 73 | int g_aim_smooth = 5; // degrees per tick |
| 79 | AIM_BONE_LARM, | 74 | bool g_aim_vischeck = true; |
| 80 | AIM_BONE_RARM, | 75 | int g_aim_fov = 60; // angular distance from the crosshair |
| 81 | AIM_BONE_LLEG, | 76 | bool g_aim_fov_circle = true; |
| 82 | AIM_BONE_RLEG, | 77 | int g_silent_fov = 60; |
| 83 | AIM_BONE_COUNT | ||
| 84 | }; | ||
| 85 | static bool g_aim_bones[AIM_BONE_COUNT] = {true, false, false, | ||
| 86 | false, false, false}; | ||
| 87 | static int g_aim_smooth = 5; // degrees per tick | ||
| 88 | static bool g_aim_vischeck = true; | ||
| 89 | static int g_aim_fov = 60; // angular distance from the crosshair | ||
| 90 | static bool g_aim_fov_circle = true; | ||
| 91 | static int g_silent_fov = 60; | ||
| 92 | 78 | ||
| 93 | // ESP sub-options (menu "ESP" children). Defaults match the pre-option | 79 | // ESP sub-options (menu "ESP" children). Defaults match the pre-option |
| 94 | // behaviour: everything on. | 80 | // behaviour: everything on. |
| 95 | static bool g_esp_opt[ESP_OPT_COUNT] = {true, true, true, true, true, true, true}; | 81 | bool g_esp_opt[ESP_OPT_COUNT] = {true, true, true, true, true, true, true}; |
| 96 | 82 | ||
| 97 | // tree | 83 | // tree |
| 98 | static MenuNode g_root{NODE_ROOT, "HL2hake", false, 0, {}, nullptr, nullptr, nullptr}; | 84 | static MenuNode g_root{NODE_ROOT, "HL2hake", false, 0, {}, nullptr, nullptr, nullptr}; |
| @@ -315,18 +301,18 @@ void register_bundled_font() { | |||
| 315 | logf("font: failed to register %s", path.c_str()); | 301 | logf("font: failed to register %s", path.c_str()); |
| 316 | } | 302 | } |
| 317 | 303 | ||
| 318 | static void config_save() { | 304 | void config_save() { |
| 319 | FILE *f = fopen(config_path().c_str(), "w"); | 305 | FILE *f = fopen(config_path().c_str(), "w"); |
| 320 | if (!f) | 306 | if (!f) |
| 321 | return; | 307 | return; |
| 322 | fprintf(f, "[bhop]\nactive=%d\nbind=%d\nautostrafe=%d\n", g_bhop.active, | 308 | fprintf(f, "[bhop]\nactive=%d\nbind=%d\nautostrafe=%d\n", g_bhop.active, |
| 323 | g_bhop.bind, g_bhop_autostrafe); | 309 | g_bhop.bind, g_bhop_autostrafe); |
| 324 | fprintf(f, "[abh]\nactive=%d\nbind=%d\n", g_abh.active, g_abh.bind); | 310 | fprintf(f, "[abh]\nactive=%d\nbind=%d\n", g_abh.active, g_abh.bind); |
| 325 | fprintf(f, "[jumpbug]\nactive=%d\nassist=%d\n", g_jumpbug.active, | 311 | fprintf(f, "[jumpbug]\nactive=%d\nbind=%d\nassist=%d\n", |
| 326 | (int)g_jumpbug_assist); | 312 | g_jumpbug.active, g_jumpbug.bind, (int)g_jumpbug_assist); |
| 327 | fprintf(f, "[melee]\nactive=%d\n", g_melee.active); | 313 | fprintf(f, "[melee]\nactive=%d\nbind=%d\n", g_melee.active, g_melee.bind); |
| 328 | fprintf(f, "[spread]\nactive=%d\nno_spread=%d\n", g_spread.active, | 314 | fprintf(f, "[spread]\nactive=%d\nbind=%d\nno_spread=%d\n", |
| 329 | (int)g_spread_no_spread); | 315 | g_spread.active, g_spread.bind, (int)g_spread_no_spread); |
| 330 | fprintf(f, "[aimbot]\nactive=%d\nbind=%d\nsmooth=%d\nvischeck=%d\n" | 316 | fprintf(f, "[aimbot]\nactive=%d\nbind=%d\nsmooth=%d\nvischeck=%d\n" |
| 331 | "fov=%d\nfov_circle=%d\n" | 317 | "fov=%d\nfov_circle=%d\n" |
| 332 | "bone_head=%d\nbone_torso=%d\nbone_larm=%d\nbone_rarm=%d\n" | 318 | "bone_head=%d\nbone_torso=%d\nbone_larm=%d\nbone_rarm=%d\n" |
| @@ -347,6 +333,7 @@ static void config_save() { | |||
| 347 | g_esp_opt[ESP_OPT_SHOW_HEALTHNUM], g_esp_opt[ESP_OPT_SHOW_NAME], | 333 | g_esp_opt[ESP_OPT_SHOW_HEALTHNUM], g_esp_opt[ESP_OPT_SHOW_NAME], |
| 348 | g_esp_opt[ESP_OPT_SHOW_SKELETON], g_esp_opt[ESP_OPT_SHOW_BOX], | 334 | g_esp_opt[ESP_OPT_SHOW_SKELETON], g_esp_opt[ESP_OPT_SHOW_BOX], |
| 349 | g_esp_opt[ESP_OPT_SHOW_SPEEDGRAPH]); | 335 | g_esp_opt[ESP_OPT_SHOW_SPEEDGRAPH]); |
| 336 | gui_config_write(f); | ||
| 350 | fclose(f); | 337 | fclose(f); |
| 351 | } | 338 | } |
| 352 | 339 | ||
| @@ -462,6 +449,40 @@ static void config_load() { | |||
| 462 | fclose(f); | 449 | fclose(f); |
| 463 | } | 450 | } |
| 464 | 451 | ||
| 452 | void config_reload() { config_load(); } | ||
| 453 | |||
| 454 | const char *config_path_cstr() { | ||
| 455 | static std::string path; | ||
| 456 | path = config_path(); | ||
| 457 | return path.c_str(); | ||
| 458 | } | ||
| 459 | |||
| 460 | void config_reset_defaults() { | ||
| 461 | g_bhop = {true, 0}; | ||
| 462 | g_bhop_autostrafe = true; | ||
| 463 | g_abh = {true, 0}; | ||
| 464 | g_jumpbug = {true, 0}; | ||
| 465 | g_jumpbug_assist = false; | ||
| 466 | g_melee = {true, 0}; | ||
| 467 | g_spread = {true, 0}; | ||
| 468 | g_spread_no_spread = true; | ||
| 469 | g_esp = {true, 0}; | ||
| 470 | for (int i = 0; i < ESP_OPT_COUNT; i++) | ||
| 471 | g_esp_opt[i] = true; | ||
| 472 | g_aimbot = {true, 604}; | ||
| 473 | g_triggerbot = {true, 603}; | ||
| 474 | g_silentaim = {true, 602}; | ||
| 475 | for (int i = 0; i < AIM_BONE_COUNT; i++) | ||
| 476 | g_aim_bones[i] = false; | ||
| 477 | g_aim_bones[AIM_BONE_HEAD] = true; | ||
| 478 | g_aim_smooth = 5; | ||
| 479 | g_aim_vischeck = true; | ||
| 480 | g_aim_fov = 60; | ||
| 481 | g_aim_fov_circle = true; | ||
| 482 | g_silent_fov = 60; | ||
| 483 | config_save(); | ||
| 484 | } | ||
| 485 | |||
| 465 | // --------------------------------------------------------------------------- | 486 | // --------------------------------------------------------------------------- |
| 466 | // menu input handling | 487 | // menu input handling |
| 467 | // --------------------------------------------------------------------------- | 488 | // --------------------------------------------------------------------------- |
| @@ -477,7 +498,7 @@ static constexpr int SCAN_ENTER = 40; | |||
| 477 | static constexpr int SCAN_ESCAPE = 41; | 498 | static constexpr int SCAN_ESCAPE = 41; |
| 478 | 499 | ||
| 479 | // simplified scancode-to-name for common keys | 500 | // simplified scancode-to-name for common keys |
| 480 | static const char *scancode_name(int sc) { | 501 | const char *scancode_name(int sc) { |
| 481 | switch (sc) { | 502 | switch (sc) { |
| 482 | case 0: return "None"; | 503 | case 0: return "None"; |
| 483 | case 4: return "A"; case 5: return "B"; case 6: return "C"; | 504 | case 4: return "A"; case 5: return "B"; case 6: return "C"; |
| @@ -497,9 +518,12 @@ static const char *scancode_name(int sc) { | |||
| 497 | case 43: return "Tab"; case 44: return "Space"; | 518 | case 43: return "Tab"; case 44: return "Space"; |
| 498 | case 79: return "Right"; case 80: return "Left"; | 519 | case 79: return "Right"; case 80: return "Left"; |
| 499 | case 81: return "Down"; case 82: return "Up"; | 520 | case 81: return "Down"; case 82: return "Up"; |
| 500 | case 87: return "F1"; case 88: return "F2"; case 89: return "F3"; | 521 | case 58: return "F1"; case 59: return "F2"; case 60: return "F3"; |
| 501 | case 90: return "F4"; case 91: return "F5"; case 92: return "F6"; | 522 | case 61: return "F4"; case 62: return "F5"; case 63: return "F6"; |
| 502 | case 93: return "F7"; case 94: return "F8"; | 523 | case 64: return "F7"; case 65: return "F8"; case 66: return "F9"; |
| 524 | case 67: return "F10"; case 68: return "F11"; case 69: return "F12"; | ||
| 525 | case 73: return "Insert"; case 74: return "Home"; case 75: return "PgUp"; | ||
| 526 | case 76: return "Delete"; case 77: return "End"; case 78: return "PgDn"; | ||
| 503 | case 600: return "MouseL"; case 601: return "MouseR"; | 527 | case 600: return "MouseL"; case 601: return "MouseR"; |
| 504 | case 602: return "MouseM"; case 603: return "Mouse4"; | 528 | case 602: return "MouseM"; case 603: return "Mouse4"; |
| 505 | case 604: return "Mouse5"; | 529 | case 604: return "Mouse5"; |
| @@ -1009,6 +1033,7 @@ void install_menu() { | |||
| 1009 | register_bundled_font(); | 1033 | register_bundled_font(); |
| 1010 | logf("config: %s", config_path().c_str()); | 1034 | logf("config: %s", config_path().c_str()); |
| 1011 | config_load(); | 1035 | config_load(); |
| 1036 | gui_config_init(); | ||
| 1012 | // resolve ISurface once (used by the DrawPrintText hook in hl2h.cpp and | 1037 | // resolve ISurface once (used by the DrawPrintText hook in hl2h.cpp and |
| 1013 | // by outer_draw). DrawPrintText hook is installed from hkdCreateMove. | 1038 | // by outer_draw). DrawPrintText hook is installed from hkdCreateMove. |
| 1014 | g_surface = find_surface_interface(); | 1039 | g_surface = find_surface_interface(); |
