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