diff options
Diffstat (limited to '')
| -rw-r--r-- | src/menu.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/menu.cpp b/src/menu.cpp index 4f76529..8df67fe 100644 --- a/src/menu.cpp +++ b/src/menu.cpp | |||
| @@ -143,8 +143,10 @@ static MenuNode *g_visible[48]; // flattened visible nodes for arrow navigation | |||
| 143 | static int g_visible_count = 0; | 143 | static int g_visible_count = 0; |
| 144 | static int g_selected = 0; | 144 | static int g_selected = 0; |
| 145 | bool g_menu_open = false; | 145 | bool g_menu_open = false; |
| 146 | static bool g_menu_draw_logged = false; | ||
| 146 | 147 | ||
| 147 | static bool g_bind_mode = false; | 148 | static bool g_bind_mode = false; |
| 149 | static bool g_insert_latch = false; | ||
| 148 | static void build_tree() { | 150 | static void build_tree() { |
| 149 | g_bhop_feat.children[0] = &g_bhop_active; | 151 | g_bhop_feat.children[0] = &g_bhop_active; |
| 150 | g_bhop_feat.children[1] = &g_bhop_autostrafe_node; | 152 | g_bhop_feat.children[1] = &g_bhop_autostrafe_node; |
| @@ -598,12 +600,24 @@ bool aimbot_fov_circle() { return g_aim_fov_circle; } | |||
| 598 | static void menu_handle_input() { | 600 | static void menu_handle_input() { |
| 599 | poll_keyboard(); | 601 | poll_keyboard(); |
| 600 | 602 | ||
| 603 | // SDL state can be sampled several times per rendered frame (both ISurface | ||
| 604 | // hooks call outer_draw). Use a physical-key latch instead of the one-poll | ||
| 605 | // edge so one press cannot open and close the menu in the same frame. | ||
| 606 | bool insert_down = key_held(SCAN_INSERT); | ||
| 607 | bool insert_edge = insert_down && !g_insert_latch; | ||
| 608 | if (insert_down) | ||
| 609 | g_insert_latch = true; | ||
| 610 | else | ||
| 611 | g_insert_latch = false; | ||
| 612 | |||
| 601 | if (!g_menu_open) { | 613 | if (!g_menu_open) { |
| 602 | if (key_pressed(SCAN_INSERT)) { | 614 | if (insert_edge) { |
| 603 | std::logf("insert pressed"); | ||
| 604 | g_menu_open = true; | 615 | g_menu_open = true; |
| 605 | g_bind_mode = false; | 616 | g_bind_mode = false; |
| 617 | if (!g_root.expanded) | ||
| 618 | g_root.expanded = true; | ||
| 606 | rebuild_visible(); | 619 | rebuild_visible(); |
| 620 | logf("menu: open rows=%d", g_visible_count); | ||
| 607 | } | 621 | } |
| 608 | return; | 622 | return; |
| 609 | } | 623 | } |
| @@ -646,8 +660,10 @@ static void menu_handle_input() { | |||
| 646 | } | 660 | } |
| 647 | 661 | ||
| 648 | // normal navigation | 662 | // normal navigation |
| 649 | if (key_pressed(SCAN_INSERT) || key_pressed(SCAN_ESCAPE)) { | 663 | if (insert_edge || key_pressed(SCAN_ESCAPE)) { |
| 650 | g_menu_open = false; | 664 | g_menu_open = false; |
| 665 | g_menu_draw_logged = false; | ||
| 666 | logf("menu: closed"); | ||
| 651 | return; | 667 | return; |
| 652 | } | 668 | } |
| 653 | if (key_pressed(SCAN_UP) && g_selected > 0) { | 669 | if (key_pressed(SCAN_UP) && g_selected > 0) { |
| @@ -856,6 +872,10 @@ void outer_draw() { | |||
| 856 | surf_pop_make_current(panel); | 872 | surf_pop_make_current(panel); |
| 857 | return; | 873 | return; |
| 858 | } | 874 | } |
| 875 | if (!g_menu_draw_logged) { | ||
| 876 | g_menu_draw_logged = true; | ||
| 877 | logf("menu: drawing rows=%d selected=%d", g_visible_count, g_selected); | ||
| 878 | } | ||
| 859 | for (int i = 0; i < g_visible_count; i++) { | 879 | for (int i = 0; i < g_visible_count; i++) { |
| 860 | MenuNode *n = g_visible[i]; | 880 | MenuNode *n = g_visible[i]; |
| 861 | char line[96]; | 881 | char line[96]; |
