summaryrefslogtreecommitdiffstats
path: root/src/menu.cpp
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-04 12:52:03 +0100
committersalmonik <salmonik@tuta.io>2026-11-04 12:52:03 +0100
commit669d6c37306ca728e64836b61e9e466020129f48 (patch)
tree0061e6c9a289ff4912dbf44d2bc82b6d2244740a /src/menu.cpp
parentProps: forward DrawModel's modelOrigin argument (diff)
downloadhl2h-669d6c37306ca728e64836b61e9e466020129f48.tar.gz
hl2h-669d6c37306ca728e64836b61e9e466020129f48.zip
ESP: render damage tags as small left-side labels
Draw ARM/VULN/IMM on the left edge of the box with a 10px font and a black 1px shadow, instead of full-size text above the name. The small font is a second HFont created next to the 16px body font. CONTEXT: document the DrawModel argument fix and the tag styling.
Diffstat (limited to '')
-rw-r--r--src/menu.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/menu.cpp b/src/menu.cpp
index eb1075a..00aa189 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -683,6 +683,7 @@ using HFont = unsigned long;
683 683
684ISurface *g_surface = nullptr; 684ISurface *g_surface = nullptr;
685static HFont g_font = 0; 685static HFont g_font = 0;
686static HFont g_font_small = 0;
686 687
687// VGUI_Surface030 vtable slots (confirmed via binary disassembly of vguimatsurface.so): 688// VGUI_Surface030 vtable slots (confirmed via binary disassembly of vguimatsurface.so):
688// 8 = PushMakeCurrent(VPANEL, bool useInsets) — reads args at 0xc/0x10(%ebp) 689// 8 = PushMakeCurrent(VPANEL, bool useInsets) — reads args at 0xc/0x10(%ebp)
@@ -778,6 +779,16 @@ void draw_text_col(int x, int y, const char *text, int r, int g, int b) {
778 surf_draw_print_text(wtext, (int)wcslen(wtext)); 779 surf_draw_print_text(wtext, (int)wcslen(wtext));
779} 780}
780 781
782void draw_text_small_col(int x, int y, const char *text, int r, int g, int b) {
783 wchar_t wtext[256];
784 mbstowcs(wtext, text, 255);
785 wtext[255] = 0;
786 surf_draw_set_text_font(g_font_small ? g_font_small : g_font);
787 surf_draw_set_text_color(r, g, b, 255);
788 surf_draw_set_text_pos(x, y);
789 surf_draw_print_text(wtext, (int)wcslen(wtext));
790}
791
781// --------------------------------------------------------------------------- 792// ---------------------------------------------------------------------------
782// mat_fullbright 793// mat_fullbright
783// --------------------------------------------------------------------------- 794// ---------------------------------------------------------------------------
@@ -849,6 +860,7 @@ void outer_draw() {
849 } 860 }
850 if (font_reset && g_font) { 861 if (font_reset && g_font) {
851 g_font = 0; 862 g_font = 0;
863 g_font_small = 0;
852 logd("font: reset (local entity change)"); 864 logd("font: reset (local entity change)");
853 } 865 }
854 866
@@ -858,6 +870,7 @@ void outer_draw() {
858 "Liberation Sans", "DejaVu Sans", "Noto Sans", "Tahoma", 870 "Liberation Sans", "DejaVu Sans", "Noto Sans", "Tahoma",
859 "Verdana", "Arial", nullptr}; 871 "Verdana", "Arial", nullptr};
860 bool font_ok = false; 872 bool font_ok = false;
873 const char *chosen = nullptr;
861 for (int fi = 0; families[fi] && !font_ok; fi++) { 874 for (int fi = 0; families[fi] && !font_ok; fi++) {
862 g_font = surf_create_font(); 875 g_font = surf_create_font();
863 if (!g_font) 876 if (!g_font)
@@ -866,10 +879,18 @@ void outer_draw() {
866 0x20, 0xFF)) { 879 0x20, 0xFF)) {
867 logd("outer_draw: font family %s", families[fi]); 880 logd("outer_draw: font family %s", families[fi]);
868 font_ok = true; 881 font_ok = true;
882 chosen = families[fi];
869 } else { 883 } else {
870 g_font = 0; 884 g_font = 0;
871 } 885 }
872 } 886 }
887 if (font_ok && chosen && !g_font_small) {
888 g_font_small = surf_create_font();
889 if (g_font_small &&
890 !surf_set_font_glyph_set(g_font_small, chosen, 10, 400, 0, 0, 0x400,
891 0x20, 0xFF))
892 g_font_small = 0;
893 }
873 if (!font_ok) { 894 if (!font_ok) {
874 logf("outer_draw: no usable font"); 895 logf("outer_draw: no usable font");
875 toastf(TOAST_ERROR, "No usable overlay font"); 896 toastf(TOAST_ERROR, "No usable overlay font");