diff options
Diffstat (limited to '')
| -rw-r--r-- | src/overlay.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/overlay.h b/src/overlay.h new file mode 100644 index 0000000..6cf86c9 --- /dev/null +++ b/src/overlay.h | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | #ifndef HL2H_OVERLAY_H | ||
| 2 | #define HL2H_OVERLAY_H | ||
| 3 | |||
| 4 | #include <cstdint> | ||
| 5 | |||
| 6 | // VGUI_Surface030 vtable slots, confirmed against the shipped | ||
| 7 | // vguimatsurface.so. This header is the only place that knows them; every | ||
| 8 | // consumer goes through the functions below. | ||
| 9 | enum SurfaceSlot { | ||
| 10 | SURF_GetEmbeddedPanel = 6, | ||
| 11 | SURF_PushMakeCurrent = 8, | ||
| 12 | SURF_PopMakeCurrent = 9, | ||
| 13 | SURF_DrawSetColor = 10, | ||
| 14 | SURF_DrawFilledRect = 12, | ||
| 15 | SURF_DrawOutlinedRect = 14, | ||
| 16 | SURF_DrawLine = 15, | ||
| 17 | SURF_DrawSetTextFont = 17, | ||
| 18 | SURF_DrawSetTextColor = 18, | ||
| 19 | SURF_DrawSetTextPos = 20, | ||
| 20 | SURF_DrawPrintText = 22, | ||
| 21 | SURF_GetScreenSize = 38, | ||
| 22 | SURF_CreateFont = 66, | ||
| 23 | SURF_AddGlyphSetToFont = 67, | ||
| 24 | SURF_GetTextSize = 75 | ||
| 25 | }; | ||
| 26 | |||
| 27 | using HFont = unsigned long; | ||
| 28 | |||
| 29 | struct ISurface; | ||
| 30 | |||
| 31 | // Set once by install_menu(); every wrapper below is a no-op while it is null. | ||
| 32 | extern ISurface *g_surface; | ||
| 33 | |||
| 34 | void overlay_color(int r, int g, int b, int a); | ||
| 35 | void overlay_fill(int x0, int y0, int x1, int y1); | ||
| 36 | void overlay_outline_rect(int x0, int y0, int x1, int y1); | ||
| 37 | void overlay_line(int x0, int y0, int x1, int y1); | ||
| 38 | void overlay_text_font(HFont f); | ||
| 39 | void overlay_text_color(int r, int g, int b, int a); | ||
| 40 | void overlay_text_pos(int x, int y); | ||
| 41 | void overlay_print_text(const wchar_t *text, int count, int draw_type = 0); | ||
| 42 | HFont overlay_create_font(); | ||
| 43 | bool overlay_add_glyph_set(HFont f, const char *name, int tall, int weight, | ||
| 44 | int blur, int scanlines, int flags, int range_min, | ||
| 45 | int range_max); | ||
| 46 | void overlay_screen_size(int &w, int &h); | ||
| 47 | void overlay_text_size(HFont f, const wchar_t *text, int &w, int &h); | ||
| 48 | int overlay_embedded_panel(); | ||
| 49 | void overlay_push_make_current(int panel, bool use_insets); | ||
| 50 | void overlay_pop_make_current(int panel); | ||
| 51 | |||
| 52 | // Per-frame draw budget. The engine calls PaintTraverseEx for every panel, and | ||
| 53 | // DrawPrintText for every text draw, so the overlay must be collapsed to one | ||
| 54 | // draw per frame. A timer cannot do that: panels spaced a few ms apart in the | ||
| 55 | // same frame would draw twice and double the alpha of translucent elements. | ||
| 56 | // overlay_frame_mark() is called from FRAME_RENDER_START, which is the real | ||
| 57 | // frame boundary; if that stops arriving (menu/pause) a 10 ms fallback keeps | ||
| 58 | // the GUI repainting. | ||
| 59 | void overlay_frame_mark(); | ||
| 60 | bool overlay_should_draw(); | ||
| 61 | |||
| 62 | #endif | ||
