summaryrefslogtreecommitdiffstats
path: root/src/menu.cpp
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-09-14 16:47:32 +0200
committersalmonik <salmonik@tuta.io>2026-09-14 16:47:32 +0200
commit8af245ae414cb548a2188030ed8a52b31986252f (patch)
tree0c77362c60b3441ddbb9d4da80944e667f24a927 /src/menu.cpp
parentRemove Climb feature; keep bind system for aimbot prep (mouse buttons bindable) (diff)
downloadhl2h-8af245ae414cb548a2188030ed8a52b31986252f.tar.gz
hl2h-8af245ae414cb548a2188030ed8a52b31986252f.zip
Default map d1_town_01 (intro-less, enemies spawned)
Diffstat (limited to '')
-rw-r--r--src/menu.cpp35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/menu.cpp b/src/menu.cpp
index 6dccf1c..302eab3 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -52,29 +52,32 @@ struct FeatureState {
52}; 52};
53 53
54static FeatureState g_bhop{true, 0}; 54static FeatureState g_bhop{true, 0};
55static FeatureState g_abh{true, 0};
56 55
56static FeatureState g_abh{true, 0};
57static FeatureState g_esp{true, 0};
57// tree 58// tree
58static MenuNode g_root{NODE_ROOT, "HL2hake", true, 0, {}, nullptr, nullptr, nullptr}; 59static MenuNode g_root{NODE_ROOT, "HL2hake", true, 0, {}, nullptr, nullptr, nullptr};
59static MenuNode g_bhop_feat{NODE_FEATURE, "Bunnyhop", true, 1, {}, nullptr, nullptr, nullptr}; 60static MenuNode g_bhop_feat{NODE_FEATURE, "Bunnyhop", true, 1, {}, nullptr, nullptr, nullptr};
60static MenuNode g_bhop_active{NODE_TOGGLE, "Active", false, 0, {}, &g_bhop.active, nullptr, nullptr}; 61static MenuNode g_bhop_active{NODE_TOGGLE, "Active", false, 0, {}, &g_bhop.active, nullptr, nullptr};
61static MenuNode g_abh_feat{NODE_FEATURE, "ABH", true, 1, {}, nullptr, nullptr, nullptr}; 62static MenuNode g_abh_feat{NODE_FEATURE, "ABH", true, 1, {}, nullptr, nullptr, nullptr};
62static MenuNode g_abh_active{NODE_TOGGLE, "Active", false, 0, {}, &g_abh.active, nullptr, nullptr}; 63static MenuNode g_abh_active{NODE_TOGGLE, "Active", false, 0, {}, &g_abh.active, nullptr, nullptr};
64static MenuNode g_esp_feat{NODE_FEATURE, "ESP", true, 1, {}, nullptr, nullptr, nullptr};
65static MenuNode g_esp_active{NODE_TOGGLE, "Active", false, 0, {}, &g_esp.active, nullptr, nullptr};
63 66
64static MenuNode *g_visible[16]; // flattened visible nodes for arrow navigation 67static MenuNode *g_visible[16]; // flattened visible nodes for arrow navigation
65static int g_visible_count = 0; 68static int g_visible_count = 0;
66static int g_selected = 0; 69static int g_selected = 0;
67bool g_menu_open = false; 70bool g_menu_open = false;
68 71
69// bind-select state 72static bool g_bind_mode = false;
70static bool g_bind_mode = false; // true = waiting for key press
71
72static void build_tree() { 73static void build_tree() {
73 g_bhop_feat.children[0] = &g_bhop_active; 74 g_bhop_feat.children[0] = &g_bhop_active;
74 g_abh_feat.children[0] = &g_abh_active; 75 g_abh_feat.children[0] = &g_abh_active;
76 g_esp_feat.children[0] = &g_esp_active;
75 g_root.children[0] = &g_bhop_feat; 77 g_root.children[0] = &g_bhop_feat;
76 g_root.children[1] = &g_abh_feat; 78 g_root.children[1] = &g_abh_feat;
77 g_root.child_count = 2; 79 g_root.children[2] = &g_esp_feat;
80 g_root.child_count = 3;
78} 81}
79 82
80static int g_depth[16]; // depth of each visible row (for indentation) 83static int g_depth[16]; // depth of each visible row (for indentation)
@@ -136,6 +139,7 @@ static void config_save() {
136 return; 139 return;
137 fprintf(f, "[bhop]\nactive=%d\nbind=%d\n", g_bhop.active, g_bhop.bind); 140 fprintf(f, "[bhop]\nactive=%d\nbind=%d\n", g_bhop.active, g_bhop.bind);
138 fprintf(f, "[abh]\nactive=%d\nbind=%d\n", g_abh.active, g_abh.bind); 141 fprintf(f, "[abh]\nactive=%d\nbind=%d\n", g_abh.active, g_abh.bind);
142 fprintf(f, "[esp]\nactive=%d\nbind=%d\n", g_esp.active, g_esp.bind);
139 fclose(f); 143 fclose(f);
140} 144}
141 145
@@ -152,6 +156,8 @@ static void config_load() {
152 cur = &g_bhop; 156 cur = &g_bhop;
153 else if (strstr(line, "[abh]")) 157 else if (strstr(line, "[abh]"))
154 cur = &g_abh; 158 cur = &g_abh;
159 else if (strstr(line, "[esp]"))
160 cur = &g_esp;
155 else 161 else
156 cur = nullptr; 162 cur = nullptr;
157 } else if (cur) { 163 } else if (cur) {
@@ -234,6 +240,7 @@ static void poll_mouse() {
234 return; 240 return;
235 int mx, my; 241 int mx, my;
236 unsigned mask = SDL_GetMouseState_real(&mx, &my); 242 unsigned mask = SDL_GetMouseState_real(&mx, &my);
243
237 for (int b = 0; b < 5; b++) { 244 for (int b = 0; b < 5; b++) {
238 bool down = (mask & (1u << b)) != 0; // SDL buttons 1..5 = bits 0..4 245 bool down = (mask & (1u << b)) != 0; // SDL buttons 1..5 = bits 0..4
239 int sc = MOUSE_BASE + b; 246 int sc = MOUSE_BASE + b;
@@ -269,8 +276,8 @@ static bool key_pressed(int sc) {
269// feature gate queried from hl2h.cpp do_move(): feature must be Active AND 276// feature gate queried from hl2h.cpp do_move(): feature must be Active AND
270// its bind key held (always-on when unbound). 277// its bind key held (always-on when unbound).
271bool feature_active(int feature) { 278bool feature_active(int feature) {
272 static FeatureState *feats[2] = {&g_bhop, &g_abh}; 279 static FeatureState *feats[3] = {&g_bhop, &g_abh, &g_esp};
273 if (feature < 0 || feature > 1) 280 if (feature < 0 || feature > 2)
274 return false; 281 return false;
275 FeatureState *f = feats[feature]; 282 FeatureState *f = feats[feature];
276 if (!f->active) 283 if (!f->active)
@@ -456,6 +463,15 @@ static void draw_text(int x, int y, const char *text) {
456 surf_draw_set_text_pos(x, y); 463 surf_draw_set_text_pos(x, y);
457 surf_draw_print_text(wtext, len); 464 surf_draw_print_text(wtext, len);
458} 465}
466void draw_text_col(int x, int y, const char *text, int r, int g, int b) {
467 wchar_t wtext[256];
468 mbstowcs(wtext, text, 255);
469 wtext[255] = 0;
470 surf_draw_set_text_font(g_font);
471 surf_draw_set_text_color(r, g, b, 255);
472 surf_draw_set_text_pos(x, y);
473 surf_draw_print_text(wtext, (int)wcslen(wtext));
474}
459 475
460// Draw overlay. MUST be called from inside the ISurface paint path 476// Draw overlay. MUST be called from inside the ISurface paint path
461// (see hkdDrawPrintText hook in hl2h.cpp): we wrap our draws in 477// (see hkdDrawPrintText hook in hl2h.cpp): we wrap our draws in
@@ -464,7 +480,8 @@ void outer_draw() {
464 menu_handle_input(); 480 menu_handle_input();
465 // HL2H_DRAW_TEST=1 draws a probe rect without needing the menu open 481 // HL2H_DRAW_TEST=1 draws a probe rect without needing the menu open
466 static bool draw_test = getenv("HL2H_DRAW_TEST") != nullptr; 482 static bool draw_test = getenv("HL2H_DRAW_TEST") != nullptr;
467 if (!g_surface || (!g_menu_open && !draw_test)) 483 bool esp_on = feature_active(FEAT_ESP);
484 if (!g_surface || (!g_menu_open && !draw_test && !esp_on))
468 return; 485 return;
469 if (!g_font) { 486 if (!g_font) {
470 g_font = surf_create_font(); 487 g_font = surf_create_font();
@@ -485,6 +502,8 @@ void outer_draw() {
485 if (!panel) 502 if (!panel)
486 return; 503 return;
487 surf_push_make_current(panel, false); 504 surf_push_make_current(panel, false);
505 if (esp_on)
506 esp_draw();
488 if (draw_test) { 507 if (draw_test) {
489 surf_draw_set_color(255, 0, 0, 255); 508 surf_draw_set_color(255, 0, 0, 255);
490 surf_draw_filled_rect(20, 20, 180, 60); 509 surf_draw_filled_rect(20, 20, 180, 60);