From 8af245ae414cb548a2188030ed8a52b31986252f Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 14 Sep 2026 16:47:32 +0200 Subject: Default map d1_town_01 (intro-less, enemies spawned) --- src/menu.cpp | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'src/menu.cpp') 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 { }; static FeatureState g_bhop{true, 0}; -static FeatureState g_abh{true, 0}; +static FeatureState g_abh{true, 0}; +static FeatureState g_esp{true, 0}; // tree static MenuNode g_root{NODE_ROOT, "HL2hake", true, 0, {}, nullptr, nullptr, nullptr}; static MenuNode g_bhop_feat{NODE_FEATURE, "Bunnyhop", true, 1, {}, nullptr, nullptr, nullptr}; static MenuNode g_bhop_active{NODE_TOGGLE, "Active", false, 0, {}, &g_bhop.active, nullptr, nullptr}; static MenuNode g_abh_feat{NODE_FEATURE, "ABH", true, 1, {}, nullptr, nullptr, nullptr}; static MenuNode g_abh_active{NODE_TOGGLE, "Active", false, 0, {}, &g_abh.active, nullptr, nullptr}; +static MenuNode g_esp_feat{NODE_FEATURE, "ESP", true, 1, {}, nullptr, nullptr, nullptr}; +static MenuNode g_esp_active{NODE_TOGGLE, "Active", false, 0, {}, &g_esp.active, nullptr, nullptr}; static MenuNode *g_visible[16]; // flattened visible nodes for arrow navigation static int g_visible_count = 0; static int g_selected = 0; bool g_menu_open = false; -// bind-select state -static bool g_bind_mode = false; // true = waiting for key press - +static bool g_bind_mode = false; static void build_tree() { g_bhop_feat.children[0] = &g_bhop_active; g_abh_feat.children[0] = &g_abh_active; + g_esp_feat.children[0] = &g_esp_active; g_root.children[0] = &g_bhop_feat; g_root.children[1] = &g_abh_feat; - g_root.child_count = 2; + g_root.children[2] = &g_esp_feat; + g_root.child_count = 3; } static int g_depth[16]; // depth of each visible row (for indentation) @@ -136,6 +139,7 @@ static void config_save() { return; fprintf(f, "[bhop]\nactive=%d\nbind=%d\n", g_bhop.active, g_bhop.bind); fprintf(f, "[abh]\nactive=%d\nbind=%d\n", g_abh.active, g_abh.bind); + fprintf(f, "[esp]\nactive=%d\nbind=%d\n", g_esp.active, g_esp.bind); fclose(f); } @@ -152,6 +156,8 @@ static void config_load() { cur = &g_bhop; else if (strstr(line, "[abh]")) cur = &g_abh; + else if (strstr(line, "[esp]")) + cur = &g_esp; else cur = nullptr; } else if (cur) { @@ -234,6 +240,7 @@ static void poll_mouse() { return; int mx, my; unsigned mask = SDL_GetMouseState_real(&mx, &my); + for (int b = 0; b < 5; b++) { bool down = (mask & (1u << b)) != 0; // SDL buttons 1..5 = bits 0..4 int sc = MOUSE_BASE + b; @@ -269,8 +276,8 @@ static bool key_pressed(int sc) { // feature gate queried from hl2h.cpp do_move(): feature must be Active AND // its bind key held (always-on when unbound). bool feature_active(int feature) { - static FeatureState *feats[2] = {&g_bhop, &g_abh}; - if (feature < 0 || feature > 1) + static FeatureState *feats[3] = {&g_bhop, &g_abh, &g_esp}; + if (feature < 0 || feature > 2) return false; FeatureState *f = feats[feature]; if (!f->active) @@ -456,6 +463,15 @@ static void draw_text(int x, int y, const char *text) { surf_draw_set_text_pos(x, y); surf_draw_print_text(wtext, len); } +void draw_text_col(int x, int y, const char *text, int r, int g, int b) { + wchar_t wtext[256]; + mbstowcs(wtext, text, 255); + wtext[255] = 0; + surf_draw_set_text_font(g_font); + surf_draw_set_text_color(r, g, b, 255); + surf_draw_set_text_pos(x, y); + surf_draw_print_text(wtext, (int)wcslen(wtext)); +} // Draw overlay. MUST be called from inside the ISurface paint path // (see hkdDrawPrintText hook in hl2h.cpp): we wrap our draws in @@ -464,7 +480,8 @@ void outer_draw() { menu_handle_input(); // HL2H_DRAW_TEST=1 draws a probe rect without needing the menu open static bool draw_test = getenv("HL2H_DRAW_TEST") != nullptr; - if (!g_surface || (!g_menu_open && !draw_test)) + bool esp_on = feature_active(FEAT_ESP); + if (!g_surface || (!g_menu_open && !draw_test && !esp_on)) return; if (!g_font) { g_font = surf_create_font(); @@ -485,6 +502,8 @@ void outer_draw() { if (!panel) return; surf_push_make_current(panel, false); + if (esp_on) + esp_draw(); if (draw_test) { surf_draw_set_color(255, 0, 0, 255); surf_draw_filled_rect(20, 20, 180, 60); -- cgit v1.2.3