summaryrefslogtreecommitdiffstats
path: root/src/menu.cpp
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-10-27 18:02:10 +0100
committersalmonik <salmonik@tuta.io>2026-10-27 18:02:10 +0100
commit0e9f3422e37d0b2d1344efec5ceb07c2246bfcd7 (patch)
treea8aa0b5a4718f0e7d407a31135823523a77744b0 /src/menu.cpp
parentSpeedgraph: lower the graph (diff)
downloadhl2h-0e9f3422e37d0b2d1344efec5ceb07c2246bfcd7.tar.gz
hl2h-0e9f3422e37d0b2d1344efec5ceb07c2246bfcd7.zip
GUI: add F2 preview shell with dummy controls
First vertical slice for the custom ISurface GUI: - window/sidebar/content shell with Movement, Combat, Visuals, Weapons and System categories; - cards with dummy Active/Bind, collapsible settings, toggles, sliders, buttons, bind capture, scrolling and tooltips; - native OS cursor by releasing SDL relative mode; reasserted while open; - F2 toggles the preview; Insert still opens the old text tree; - while the GUI is open, do_move freezes movement/buttons/impulses/view and skips combat features; ESP and the speed graph keep drawing. Dummy controls do not touch the real config yet. The text menu is removed after feature parity in the next pass.
Diffstat (limited to 'src/menu.cpp')
-rw-r--r--src/menu.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/menu.cpp b/src/menu.cpp
index 9dffc9e..56fe6fa 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -625,9 +625,15 @@ int silentaim_fov() { return g_silent_fov; }
625 625
626bool aimbot_fov_circle() { return g_aim_fov_circle; } 626bool aimbot_fov_circle() { return g_aim_fov_circle; }
627 627
628void menu_force_close() {
629 g_menu_open = false;
630 g_bind_mode = false;
631 g_insert_latch = false;
632 g_menu_draw_logged = false;
633}
634
628static void menu_handle_input() { 635static void menu_handle_input() {
629 poll_keyboard(); 636 poll_keyboard();
630
631 // SDL state can be sampled several times per rendered frame (both ISurface 637 // SDL state can be sampled several times per rendered frame (both ISurface
632 // hooks call outer_draw). Use a physical-key latch instead of the one-poll 638 // hooks call outer_draw). Use a physical-key latch instead of the one-poll
633 // edge so one press cannot open and close the menu in the same frame. 639 // edge so one press cannot open and close the menu in the same frame.
@@ -838,11 +844,13 @@ void draw_text_col(int x, int y, const char *text, int r, int g, int b) {
838// (see hkdDrawPrintText hook in hl2h.cpp): we wrap our draws in 844// (see hkdDrawPrintText hook in hl2h.cpp): we wrap our draws in
839// PushMakeCurrent/PopMakeCurrent so they are submitted with a clean clip. 845// PushMakeCurrent/PopMakeCurrent so they are submitted with a clean clip.
840void outer_draw() { 846void outer_draw() {
841 menu_handle_input(); 847 gui_handle_input();
848 if (!gui_is_open())
849 menu_handle_input();
842 // HL2H_DRAW_TEST=1 draws a probe rect without needing the menu open 850 // HL2H_DRAW_TEST=1 draws a probe rect without needing the menu open
843 static bool draw_test = getenv("HL2H_DRAW_TEST") != nullptr; 851 static bool draw_test = getenv("HL2H_DRAW_TEST") != nullptr;
844 bool esp_on = feature_active(FEAT_ESP); 852 bool esp_on = feature_active(FEAT_ESP);
845 if (!g_surface || (!g_menu_open && !draw_test && !esp_on)) 853 if (!g_surface || (!g_menu_open && !gui_is_open() && !draw_test && !esp_on))
846 return; 854 return;
847 855
848 // Level/menu -> game transitions can invalidate the VGUI font handle. 856 // Level/menu -> game transitions can invalidate the VGUI font handle.
@@ -896,6 +904,11 @@ void outer_draw() {
896 surf_draw_set_color(255, 255, 255, 255); 904 surf_draw_set_color(255, 255, 255, 255);
897 draw_text(28, 36, "HL2H DRAW TEST"); 905 draw_text(28, 36, "HL2H DRAW TEST");
898 } 906 }
907 if (gui_is_open()) {
908 gui_draw();
909 surf_pop_make_current(panel);
910 return;
911 }
899 if (!g_menu_open) { 912 if (!g_menu_open) {
900 surf_pop_make_current(panel); 913 surf_pop_make_current(panel);
901 return; 914 return;