summaryrefslogtreecommitdiffstats
path: root/src/gui.cpp
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-10-27 20:15:51 +0100
committersalmonik <salmonik@tuta.io>2026-10-27 20:15:51 +0100
commitba500fef7fbf94725f18541b0e23a45591379dba (patch)
treef1eec8ad34e532fb7bcb9172083c78d96bcdca4f /src/gui.cpp
parentOverlay: keep GUI and toasts drawing if the ESP font fails (diff)
downloadhl2h-ba500fef7fbf94725f18541b0e23a45591379dba.tar.gz
hl2h-ba500fef7fbf94725f18541b0e23a45591379dba.zip
Fix tooltip truncation; add Stucklaunch assist
Tooltips: text_in() shifted the x position to fit the full string before truncating, which drew the tooltip text outside its box. Truncate to the available width first, then clamp inside the clip. Stucklaunch (Movement): - opt-in feature (Active off by default) with its own bind; - holds jump, alternates +use every 2 ticks to regrab a physics prop, optionally +attack while the gravity gun is active, and air-strafes; - engagement uses m_hGroundEntity (client netvar) latched for ~0.5 s so the prop stays active while airborne; falls back to running whenever active if the netvar is unavailable, with a startup warning to bind it; - does not spawn or place props; the player supplies the prop and initial speed. Config gets [stucklaunch] active/bind/use_spam/gravspam/autostrafe; Reset restores those defaults. CONTEXT documents the assist and its limits.
Diffstat (limited to 'src/gui.cpp')
-rw-r--r--src/gui.cpp47
1 files changed, 37 insertions, 10 deletions
diff --git a/src/gui.cpp b/src/gui.cpp
index 0d5b458..dc0e4eb 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -293,6 +293,19 @@ static void build_cards() {
293 add_card(0, &g_abh, "ABH", "Accelerate on the jump tick by facing away " 293 add_card(0, &g_abh, "ABH", "Accelerate on the jump tick by facing away "
294 "from the velocity.", true); 294 "from the velocity.", true);
295 295
296 int sl = add_card(0, &g_stucklaunch, "Stucklaunch",
297 "Hop on a physics prop while spamming grab to build "
298 "speed in a small space.",
299 true);
300 add_toggle(sl, "Use spam",
301 "Rapidly press +use to keep regrabbing the prop.",
302 &g_stucklaunch_use_spam);
303 add_toggle(sl, "Gravity gun spam",
304 "Rapidly press +attack while holding the gravity gun.",
305 &g_stucklaunch_gravspam);
306 add_toggle(sl, "Auto-strafe", "Air-strafe each hop.",
307 &g_stucklaunch_autostrafe);
308
296 int jb = add_card(0, &g_jumpbug, "Jumpbug", 309 int jb = add_card(0, &g_jumpbug, "Jumpbug",
297 "Duck+jump when landing would hurt.", true); 310 "Duck+jump when landing would hurt.", true);
298 add_toggle(jb, "Assist timing", 311 add_toggle(jb, "Assist timing",
@@ -523,26 +536,40 @@ static void text_in(const Rect &clip, int x, int y, const char *s,
523 return; 536 return;
524 if (x >= clip.x + clip.w) 537 if (x >= clip.x + clip.w)
525 return; 538 return;
526 if (x + text_w(s, tall) > clip.x + clip.w) 539
527 x = clip.x + clip.w - text_w(s, tall); 540 // Available space from x to the clip edge, optionally capped by max_w.
528 if (max_w > 0 && text_w(s, tall) > max_w) { 541 // Truncate first, then clamp: shifting before truncating used to draw the
529 char buf[256]; 542 // text outside the tooltip/button box.
543 int avail = clip.x + clip.w - x;
544 if (max_w > 0 && max_w < avail)
545 avail = max_w;
546 if (avail <= 0)
547 return;
548
549 char buf[256];
550 const char *draw = s;
551 int w = text_w(s, tall);
552 if (w > avail) {
530 snprintf(buf, sizeof(buf), "%s", s); 553 snprintf(buf, sizeof(buf), "%s", s);
531 int n = (int)strlen(buf); 554 int n = (int)strlen(buf);
532 while (n > 3 && text_w(buf, tall) > max_w) 555 int dots = text_w("...", tall);
556 while (n > 0 && text_w(buf, tall) + dots > avail)
533 buf[--n] = 0; 557 buf[--n] = 0;
534 if (n > 3 && n < (int)sizeof(buf) - 3) { 558 if (n > 0 && n + 3 < (int)sizeof(buf)) {
535 buf[n++] = '.'; 559 buf[n++] = '.';
536 buf[n++] = '.'; 560 buf[n++] = '.';
537 buf[n++] = '.'; 561 buf[n++] = '.';
538 buf[n] = 0; 562 buf[n] = 0;
539 } 563 }
540 s_text_color(c.r, c.g, c.b, c.a); 564 draw = buf;
541 draw_text_raw(x, y, buf, font, tall); 565 w = text_w(draw, tall);
542 return;
543 } 566 }
567 if (x + w > clip.x + clip.w)
568 x = clip.x + clip.w - w;
569 if (x < clip.x)
570 x = clip.x;
544 s_text_color(c.r, c.g, c.b, c.a); 571 s_text_color(c.r, c.g, c.b, c.a);
545 draw_text_raw(x, y, s, font, tall); 572 draw_text_raw(x, y, draw, font, tall);
546} 573}
547 574
548static Rect clip_rect(const Rect &r, const Rect &clip) { 575static Rect clip_rect(const Rect &r, const Rect &clip) {