From 15e4d33220bedb62beac635580fa4d222a7f5863 Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 26 Oct 2026 15:44:45 +0100 Subject: ESP: menu toggles for neutral/healthbar/healthnum/name --- src/menu.cpp | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) (limited to 'src/menu.cpp') diff --git a/src/menu.cpp b/src/menu.cpp index 302eab3..2caf0aa 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -37,7 +37,7 @@ struct MenuNode { const char *label; bool expanded; // for root/feature: whether children are visible int child_count; - MenuNode *children[4]; // max children per node + MenuNode *children[8]; // max children per node // leaf data bool *active_ptr; // NODE_TOGGLE: pointer to the active flag @@ -55,6 +55,11 @@ static FeatureState g_bhop{true, 0}; static FeatureState g_abh{true, 0}; static FeatureState g_esp{true, 0}; + +// 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}; + // 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}; @@ -63,8 +68,14 @@ static MenuNode g_abh_feat{NODE_FEATURE, "ABH", true, 1, {}, nullptr, nullptr, n 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_esp_opt_nodes[ESP_OPT_COUNT] = { + {NODE_TOGGLE, "Show neutral", false, 0, {}, &g_esp_opt[ESP_OPT_SHOW_NEUTRAL], nullptr, nullptr}, + {NODE_TOGGLE, "Show healthbar", false, 0, {}, &g_esp_opt[ESP_OPT_SHOW_HEALTHBAR], nullptr, nullptr}, + {NODE_TOGGLE, "Show healthnum", false, 0, {}, &g_esp_opt[ESP_OPT_SHOW_HEALTHNUM], nullptr, nullptr}, + {NODE_TOGGLE, "Show name", false, 0, {}, &g_esp_opt[ESP_OPT_SHOW_NAME], nullptr, nullptr}, +}; -static MenuNode *g_visible[16]; // flattened visible nodes for arrow navigation +static MenuNode *g_visible[32]; // flattened visible nodes for arrow navigation static int g_visible_count = 0; static int g_selected = 0; bool g_menu_open = false; @@ -74,16 +85,19 @@ 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; + for (int i = 0; i < ESP_OPT_COUNT; i++) + g_esp_feat.children[i + 1] = &g_esp_opt_nodes[i]; + g_esp_feat.child_count = ESP_OPT_COUNT + 1; g_root.children[0] = &g_bhop_feat; g_root.children[1] = &g_abh_feat; g_root.children[2] = &g_esp_feat; g_root.child_count = 3; } -static int g_depth[16]; // depth of each visible row (for indentation) +static int g_depth[32]; // depth of each visible row (for indentation) static void flatten(MenuNode *node, int depth) { - if (g_visible_count >= 16) + if (g_visible_count >= 32) return; node->type = (depth == 0) ? NODE_ROOT : (node->child_count > 0) ? NODE_FEATURE @@ -139,7 +153,11 @@ 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); + fprintf(f, "[esp]\nactive=%d\nbind=%d\nneutral=%d\nhealthbar=%d\n" + "healthnum=%d\nname=%d\n", + g_esp.active, g_esp.bind, g_esp_opt[ESP_OPT_SHOW_NEUTRAL], + g_esp_opt[ESP_OPT_SHOW_HEALTHBAR], + g_esp_opt[ESP_OPT_SHOW_HEALTHNUM], g_esp_opt[ESP_OPT_SHOW_NAME]); fclose(f); } @@ -149,6 +167,7 @@ static void config_load() { return; char line[256]; FeatureState *cur = nullptr; + bool in_esp = false; while (fgets(line, sizeof(line), f)) { line[strcspn(line, "\r\n")] = 0; if (line[0] == '[') { @@ -160,12 +179,23 @@ static void config_load() { cur = &g_esp; else cur = nullptr; + in_esp = (cur == &g_esp); } else if (cur) { char *eq = strchr(line, '='); if (!eq) continue; *eq = 0; const char *key = line, *val = eq + 1; + if (in_esp) { + if (strcmp(key, "neutral") == 0) + g_esp_opt[ESP_OPT_SHOW_NEUTRAL] = atoi(val) != 0; + else if (strcmp(key, "healthbar") == 0) + g_esp_opt[ESP_OPT_SHOW_HEALTHBAR] = atoi(val) != 0; + else if (strcmp(key, "healthnum") == 0) + g_esp_opt[ESP_OPT_SHOW_HEALTHNUM] = atoi(val) != 0; + else if (strcmp(key, "name") == 0) + g_esp_opt[ESP_OPT_SHOW_NAME] = atoi(val) != 0; + } if (strcmp(key, "active") == 0) cur->active = atoi(val) != 0; else if (strcmp(key, "bind") == 0) @@ -285,6 +315,10 @@ bool feature_active(int feature) { return f->bind == 0 || key_held(f->bind); } +bool esp_option(int opt) { + return opt >= 0 && opt < ESP_OPT_COUNT && g_esp_opt[opt]; +} + static void menu_handle_input() { poll_keyboard(); -- cgit v1.2.3