forked from hitmen047/Source-PlusPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathISurfaceV30.h
375 lines (299 loc) · 13 KB
/
ISurfaceV30.h
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
// the agreement/contract under which the contents have been supplied.
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef ISURFACE_V30_H
#define ISURFACE_V30_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui/VGUI.h>
#include <vgui/IHTML.h> // CreateHTML, PaintHTML
#include "interface.h"
#include "IVguiMatInfo.h"
#include "appframework/IAppSystem.h"
#include "bitmap/ImageFormat.h"
#include "Vector2D.h" // must be before the namespace line
#ifdef CreateFont
#undef CreateFont
#endif
#ifdef PlaySound
#undef PlaySound
#endif
class Color;
namespace vgui
{
class Image;
class Point;
// handles
typedef unsigned long HCursor;
typedef unsigned long HTexture;
typedef unsigned long HFont;
}
namespace SurfaceV30
{
//SRC only defines
struct Vertex_t
{
Vertex_t() {}
Vertex_t( const Vector2D &pos, const Vector2D &coord = Vector2D( 0, 0 ) )
{
m_Position = pos;
m_TexCoord = coord;
}
void Init( const Vector2D &pos, const Vector2D &coord = Vector2D( 0, 0 ) )
{
m_Position = pos;
m_TexCoord = coord;
}
Vector2D m_Position;
Vector2D m_TexCoord;
};
enum FontDrawType_t
{
// Use the "additive" value from the scheme file
FONT_DRAW_DEFAULT = 0,
// Overrides
FONT_DRAW_NONADDITIVE,
FONT_DRAW_ADDITIVE,
FONT_DRAW_TYPE_COUNT = 2,
};
// Refactor these two
struct CharRenderInfo
{
// In:
FontDrawType_t drawType;
wchar_t ch;
// Out
bool valid;
// In/Out (true by default)
bool shouldclip;
// Text pos
int x, y;
// Top left and bottom right
Vertex_t verts[ 2 ];
int textureId;
int abcA;
int abcB;
int abcC;
int fontTall;
vgui::HFont currentFont;
};
struct IntRect
{
int x0;
int y0;
int x1;
int y1;
};
//-----------------------------------------------------------------------------
// Purpose: Wraps contextless windows system functions
//-----------------------------------------------------------------------------
class ISurface : public IAppSystem
{
public:
// call to Shutdown surface; surface can no longer be used after this is called
virtual void Shutdown() = 0;
// frame
virtual void RunFrame() = 0;
// hierarchy root
virtual vgui::VPANEL GetEmbeddedPanel() = 0;
virtual void SetEmbeddedPanel( vgui::VPANEL pPanel ) = 0;
// drawing context
virtual void PushMakeCurrent(vgui::VPANEL panel, bool useInsets) = 0;
virtual void PopMakeCurrent(vgui::VPANEL panel) = 0;
// rendering functions
virtual void DrawSetColor(int r, int g, int b, int a) = 0;
virtual void DrawSetColor(Color col) = 0;
virtual void DrawFilledRect(int x0, int y0, int x1, int y1) = 0;
virtual void DrawFilledRectArray( IntRect *pRects, int numRects ) = 0;
virtual void DrawOutlinedRect(int x0, int y0, int x1, int y1) = 0;
virtual void DrawLine(int x0, int y0, int x1, int y1) = 0;
virtual void DrawPolyLine(int *px, int *py, int numPoints) = 0;
virtual void DrawSetTextFont(vgui::HFont font) = 0;
virtual void DrawSetTextColor(int r, int g, int b, int a) = 0;
virtual void DrawSetTextColor(Color col) = 0;
virtual void DrawSetTextPos(int x, int y) = 0;
virtual void DrawGetTextPos(int& x,int& y) = 0;
virtual void DrawPrintText(const wchar_t *text, int textLen, FontDrawType_t drawType = FONT_DRAW_DEFAULT ) = 0;
virtual void DrawUnicodeChar(wchar_t wch, FontDrawType_t drawType = FONT_DRAW_DEFAULT ) = 0;
virtual void DrawFlushText() = 0; // flushes any buffered text (for rendering optimizations)
virtual vgui::IHTML *CreateHTMLWindow(vgui::IHTMLEvents *events,vgui::VPANEL context)=0;
virtual void PaintHTMLWindow(vgui::IHTML *htmlwin) =0;
virtual void DeleteHTMLWindow(vgui::IHTML *htmlwin)=0;
virtual int DrawGetTextureId( char const *filename ) = 0;
virtual bool DrawGetTextureFile(int id, char *filename, int maxlen ) = 0;
virtual void DrawSetTextureFile(int id, const char *filename, int hardwareFilter, bool forceReload) = 0;
virtual void DrawSetTextureRGBA(int id, const unsigned char *rgba, int wide, int tall, int hardwareFilter, bool forceReload)=0;
virtual void DrawSetTexture(int id) = 0;
virtual void DrawGetTextureSize(int id, int &wide, int &tall) = 0;
virtual void DrawTexturedRect(int x0, int y0, int x1, int y1) = 0;
virtual bool IsTextureIDValid(int id) = 0;
virtual int CreateNewTextureID( bool procedural = false ) = 0;
#ifdef _XBOX
virtual void DestroyTextureID( int id ) = 0;
virtual bool IsCachedForRendering( int id, bool bSyncWait ) = 0;
virtual void CopyFrontBufferToBackBuffer() = 0;
virtual void UncacheUnusedMaterials() = 0;
#endif
virtual void GetScreenSize(int &wide, int &tall) = 0;
virtual void SetAsTopMost(vgui::VPANEL panel, bool state) = 0;
virtual void BringToFront(vgui::VPANEL panel) = 0;
virtual void SetForegroundWindow (vgui::VPANEL panel) = 0;
virtual void SetPanelVisible(vgui::VPANEL panel, bool state) = 0;
virtual void SetMinimized(vgui::VPANEL panel, bool state) = 0;
virtual bool IsMinimized(vgui::VPANEL panel) = 0;
virtual void FlashWindow(vgui::VPANEL panel, bool state) = 0;
virtual void SetTitle(vgui::VPANEL panel, const wchar_t *title) = 0;
virtual void SetAsToolBar(vgui::VPANEL panel, bool state) = 0; // removes the window's task bar entry (for context menu's, etc.)
// windows stuff
virtual void CreatePopup(vgui::VPANEL panel, bool minimised, bool showTaskbarIcon = true, bool disabled = false, bool mouseInput = true , bool kbInput = true) = 0;
virtual void SwapBuffers(vgui::VPANEL panel) = 0;
virtual void Invalidate(vgui::VPANEL panel) = 0;
virtual void SetCursor(vgui::HCursor cursor) = 0;
virtual bool IsCursorVisible() = 0;
virtual void ApplyChanges() = 0;
virtual bool IsWithin(int x, int y) = 0;
virtual bool HasFocus() = 0;
// returns true if the surface supports minimize & maximize capabilities
enum SurfaceFeature_e
{
ANTIALIASED_FONTS = 1,
DROPSHADOW_FONTS = 2,
ESCAPE_KEY = 3,
OPENING_NEW_HTML_WINDOWS = 4,
FRAME_MINIMIZE_MAXIMIZE = 5,
OUTLINE_FONTS = 6,
DIRECT_HWND_RENDER = 7,
};
virtual bool SupportsFeature(SurfaceFeature_e feature) = 0;
// restricts what gets drawn to one panel and it's children
// currently only works in the game
virtual void RestrictPaintToSinglePanel(vgui::VPANEL panel) = 0;
// these two functions obselete, use IInput::SetAppModalSurface() instead
virtual void SetModalPanel(vgui::VPANEL ) = 0;
virtual vgui::VPANEL GetModalPanel() = 0;
virtual void UnlockCursor() = 0;
virtual void LockCursor() = 0;
virtual void SetTranslateExtendedKeys(bool state) = 0;
virtual vgui::VPANEL GetTopmostPopup() = 0;
// engine-only focus handling (replacing WM_FOCUS windows handling)
virtual void SetTopLevelFocus(vgui::VPANEL panel) = 0;
// fonts
// creates an empty handle to a vgui font. windows fonts can be add to this via SetFontGlyphSet().
virtual vgui::HFont CreateFont() = 0;
// adds to the font
enum EFontFlags
{
FONTFLAG_NONE,
FONTFLAG_ITALIC = 0x001,
FONTFLAG_UNDERLINE = 0x002,
FONTFLAG_STRIKEOUT = 0x004,
FONTFLAG_SYMBOL = 0x008,
FONTFLAG_ANTIALIAS = 0x010,
FONTFLAG_GAUSSIANBLUR = 0x020,
FONTFLAG_ROTARY = 0x040,
FONTFLAG_DROPSHADOW = 0x080,
FONTFLAG_ADDITIVE = 0x100,
FONTFLAG_OUTLINE = 0x200,
FONTFLAG_CUSTOM = 0x400, // custom generated font - never fall back to asian compatibility mode
FONTFLAG_BITMAP = 0x800, // compiled bitmap font - no fallbacks
};
virtual bool SetFontGlyphSet(vgui::HFont font, const char *windowsFontName, int tall, int weight, int blur, int scanlines, int flags) = 0;
// adds a custom font file (only supports true type font files (.ttf) for now)
virtual bool AddCustomFontFile(const char *fontName, const char *fontFileName) = 0;
// returns the details about the font
virtual int GetFontTall(vgui::HFont font) = 0;
virtual int GetFontAscent(vgui::HFont font, wchar_t wch) = 0;
virtual bool IsFontAdditive(vgui::HFont font) = 0;
virtual void GetCharABCwide(vgui::HFont font, int ch, int &a, int &b, int &c) = 0;
virtual int GetCharacterWidth(vgui::HFont font, int ch) = 0;
virtual void GetTextSize(vgui::HFont font, const wchar_t *text, int &wide, int &tall) = 0;
// notify icons?!?
virtual vgui::VPANEL GetNotifyPanel() = 0;
virtual void SetNotifyIcon(vgui::VPANEL context, vgui::HTexture icon, vgui::VPANEL panelToReceiveMessages, const char *text) = 0;
// plays a sound
virtual void PlaySound(const char *fileName) = 0;
//!! these functions should not be accessed directly, but only through other vgui items
//!! need to move these to seperate interface
virtual int GetPopupCount() = 0;
virtual vgui::VPANEL GetPopup(int index) = 0;
virtual bool ShouldPaintChildPanel(vgui::VPANEL childPanel) = 0;
virtual bool RecreateContext(vgui::VPANEL panel) = 0;
virtual void AddPanel(vgui::VPANEL panel) = 0;
virtual void ReleasePanel(vgui::VPANEL panel) = 0;
virtual void MovePopupToFront(vgui::VPANEL panel) = 0;
virtual void MovePopupToBack(vgui::VPANEL panel) = 0;
virtual void SolveTraverse(vgui::VPANEL panel, bool forceApplySchemeSettings = false) = 0;
virtual void PaintTraverse(vgui::VPANEL panel) = 0;
virtual void EnableMouseCapture(vgui::VPANEL panel, bool state) = 0;
// returns the size of the workspace
virtual void GetWorkspaceBounds(int &x, int &y, int &wide, int &tall) = 0;
// gets the absolute coordinates of the screen (in windows space)
virtual void GetAbsoluteWindowBounds(int &x, int &y, int &wide, int &tall) = 0;
// gets the base resolution used in proportional mode
virtual void GetProportionalBase( int &width, int &height ) = 0;
virtual void CalculateMouseVisible() = 0;
virtual bool NeedKBInput() = 0;
virtual bool HasCursorPosFunctions() = 0;
virtual void SurfaceGetCursorPos(int &x, int &y) = 0;
virtual void SurfaceSetCursorPos(int x, int y) = 0;
// SRC only functions!!!
virtual void DrawTexturedLine( const Vertex_t &a, const Vertex_t &b ) = 0;
virtual void DrawOutlinedCircle(int x, int y, int radius, int segments) = 0;
virtual void DrawTexturedPolyLine( const Vertex_t *p,int n ) = 0; // (Note: this connects the first and last points).
virtual void DrawTexturedSubRect( int x0, int y0, int x1, int y1, float texs0, float text0, float texs1, float text1 ) = 0;
virtual void DrawTexturedPolygon(int n, Vertex_t *pVertices) = 0;
virtual const wchar_t *GetTitle(vgui::VPANEL panel) = 0;
virtual bool IsCursorLocked( void ) const = 0;
virtual void SetWorkspaceInsets( int left, int top, int right, int bottom ) = 0;
// Lower level char drawing code, call DrawGet then pass in info to DrawRender
virtual bool DrawGetUnicodeCharRenderInfo( wchar_t ch, CharRenderInfo& info ) = 0;
virtual void DrawRenderCharFromInfo( const CharRenderInfo& info ) = 0;
// global alpha setting functions
// affect all subsequent draw calls - shouldn't normally be used directly, only in Panel::PaintTraverse()
virtual void DrawSetAlphaMultiplier( float alpha /* [0..1] */ ) = 0;
virtual float DrawGetAlphaMultiplier() = 0;
// web browser
virtual void SetAllowHTMLJavaScript( bool state ) = 0;
// video mode changing
virtual void OnScreenSizeChanged( int nOldWidth, int nOldHeight ) = 0;
#if !defined( _XBOX )
virtual vgui::HCursor CreateCursorFromFile( char const *curOrAniFile, char const *pPathID = 0 ) = 0;
#endif
// create IVguiMatInfo object ( IMaterial wrapper in VguiMatSurface, NULL in CWin32Surface )
virtual IVguiMatInfo *DrawGetTextureMatInfoFactory( int id ) = 0;
virtual void PaintTraverseEx(vgui::VPANEL panel, bool paintPopups = false ) = 0;
virtual float GetZPos() const = 0;
// From the Xbox
virtual void SetPanelForInput( vgui::VPANEL vpanel ) = 0;
virtual void DrawFilledRectFade( int x0, int y0, int x1, int y1, unsigned int alpha0, unsigned int alpha1, bool bHorizontal ) = 0;
virtual void DrawSetTextureRGBAEx(int id, const unsigned char *rgba, int wide, int tall, ImageFormat imageFormat ) = 0;
virtual void DrawSetTextScale(float sx, float sy) = 0;
virtual bool SetBitmapFontGlyphSet(vgui::HFont font, const char *windowsFontName, float scalex, float scaley, int flags) = 0;
// adds a bitmap font file
virtual bool AddBitmapFontFile(const char *fontFileName) = 0;
// sets a symbol for the bitmap font
virtual void SetBitmapFontName( const char *pName, const char *pFontFilename ) = 0;
// gets the bitmap font filename
virtual const char *GetBitmapFontName( const char *pName ) = 0;
virtual vgui::IImage *GetIconImageForFullPath( char const *pFullPath ) = 0;
virtual void DrawUnicodeString( const wchar_t *pwString, FontDrawType_t drawType = FONT_DRAW_DEFAULT ) = 0;
};
} // end namespace
//-----------------------------------------------------------------------------
// FIXME: This works around using scoped interfaces w/ EXPOSE_SINGLE_INTERFACE
//-----------------------------------------------------------------------------
class ISurfaceV30 : public SurfaceV30::ISurface
{
public:
};
#define VGUI_SURFACE_INTERFACE_VERSION_30 "VGUI_Surface030"
#endif // ISURFACE_V30_H