15#include "engine_string.h"
16#include "engine_vector.h"
23 HUD_ELEMENT_RECTANGLE,
32 HUD_FONT_SMALL_HEADER,
40class HUDLineElementClass;
41class HUDRectangleElementClass;
42class HUDOutlineElementClass;
43class HUDTextElementClass;
48 HUDSurfaceClass(
int client,
int srf_id);
49 virtual ~HUDSurfaceClass();
51 int Get_Surface_ID()
const {
return id; }
52 int Get_Client_ID()
const {
return clientId; }
53 bool Is_Dirty()
const {
return isDirty; }
54 void Set_Dirty(
bool dirty) { isDirty = dirty; }
55 const RectClass& Get_Boundary_Area()
const {
return boundary; }
56 float Get_Aspect_Ratio()
const {
return boundary.Height() > WWMATH_EPSILON ? boundary.Width() / boundary.Height() : 0; }
57 const StringClass& Get_Surface_Texture()
const {
return surfaceTexture; }
58 void Set_Surface_Texture(
const char* texture) { surfaceTexture = texture; Set_Dirty(
true); }
60 virtual void Add_Element(HUDElementClass* element);
61 virtual HUDElementClass* Create_Element(HUDElementType type);
62 virtual HUDElementClass* Find_Element(
int id);
63 virtual int Get_Element_Count();
64 virtual HUDElementClass* Get_Element_Index(
int index);
65 virtual void Remove_Element(
int id);
66 virtual void Remove_Element(HUDElementClass* element);
67 virtual void Clear_Elements();
73 StringClass surfaceTexture;
74 DynamicVectorClass<HUDElementClass*> elements;
81 HUDElementClass(
int elem_id);
82 virtual ~HUDElementClass();
84 virtual HUDElementType Get_Element_Type()
const = 0;
85 virtual HUDLineElementClass* As_HUDLineElementClass() {
return NULL; }
86 virtual HUDRectangleElementClass* As_HUDRectangleElementClass() {
return NULL; }
87 virtual HUDOutlineElementClass* As_HUDOutlineElementClass() {
return NULL; }
88 virtual HUDTextElementClass* As_HUDTextElementClass() {
return NULL; }
90 int Get_Element_ID()
const {
return elementId; }
91 bool Is_Dirty()
const {
return isDirty; }
92 void Set_Dirty(
bool dirty) { isDirty = dirty; }
93 bool Is_Rendered()
const {
return isRendered; }
94 void Set_Rendered(
bool rendered) { isRendered = rendered; Set_Dirty(
true); }
95 const RectClass& Get_UV_Range()
const {
return uvRange; }
96 void Set_UV_Range(
const RectClass& newRange) { uvRange = newRange; Set_Dirty(
true); }
105class HUDLineElementClass :
public HUDElementClass {
107 HUDLineElementClass(
int elem_id);
109 virtual HUDElementType Get_Element_Type()
const {
return HUD_ELEMENT_LINE; }
110 virtual HUDLineElementClass* As_HUDLineElementClass() {
return this; }
112 const Vector2& Get_P0()
const {
return p0; }
113 void Set_P0(
const Vector2& newP0) { p0 = newP0; Set_Dirty(
true); }
114 const Vector2& Get_P1()
const {
return p1; }
115 void Set_P1(
const Vector2& newP1) { p1 = newP1; Set_Dirty(
true); }
116 float Get_Length()
const {
return Vector2::Distance(p1, p0); }
117 float Get_Thickness()
const {
return thickness; }
118 void Set_Thickness(
float newThickness) { thickness = newThickness; Set_Dirty(
true); }
119 const Vector4& Get_Color()
const {
return color; }
120 void Set_Color(
const Vector4& newColor) { color = newColor; Set_Dirty(
true); }
121 void Set_Color(
int a,
int r,
int g,
int b) { color = Vector4(a / 255.f, r / 255.f, g / 255.f, b / 255.f); Set_Dirty(
true); }
130class HUDRectangleElementClass :
public HUDElementClass {
132 HUDRectangleElementClass(
int elem_id);
134 virtual HUDElementType Get_Element_Type()
const {
return HUD_ELEMENT_RECTANGLE; }
135 virtual HUDRectangleElementClass* As_HUDRectangleElementClass() {
return this; }
137 const RectClass& Get_Rect()
const {
return rect; }
138 void Set_Rect(
const RectClass& newRect) { rect = newRect; Set_Dirty(
true); }
139 float Get_Area()
const {
const Vector2& a = rect.getSize();
return a.X * a.Y; }
140 float Get_Diagonal_Length()
const {
return rect.Extent().Length() * 2; }
141 const Vector4& Get_Color()
const {
return color; }
142 void Set_Color(
const Vector4& newColor) { color = newColor; Set_Dirty(
true); }
143 void Set_Color(
int a,
int r,
int g,
int b) { color = Vector4(a / 255.f, r / 255.f, g / 255.f, b / 255.f); Set_Dirty(
true); }
150class HUDOutlineElementClass :
public HUDElementClass {
152 HUDOutlineElementClass(
int elem_id);
154 virtual HUDElementType Get_Element_Type()
const {
return HUD_ELEMENT_OUTLINE; }
155 virtual HUDOutlineElementClass* As_HUDOutlineElementClass() {
return this; }
157 const RectClass& Get_Rect()
const {
return rect; }
158 void Set_Rect(
const RectClass& newRect) { rect = newRect; Set_Dirty(
true); }
159 float Get_Area()
const {
const Vector2& a = rect.getSize();
return a.X * a.Y; }
160 float Get_Diagonal_Length()
const {
return rect.Extent().Length() * 2; }
161 float Get_Thickness()
const {
return thickness; }
162 void Set_Thickness(
float newThickness) { thickness = newThickness; Set_Dirty(
true); }
163 const Vector4& Get_Color()
const {
return color; }
164 void Set_Color(
const Vector4& newColor) { color = newColor; Set_Dirty(
true); }
165 void Set_Color(
int a,
int r,
int g,
int b) { color = Vector4(a / 255.f, r / 255.f, g / 255.f, b / 255.f); Set_Dirty(
true); }
173class HUDTextElementClass :
public HUDElementClass {
175 HUDTextElementClass(
int elem_id);
177 virtual HUDElementType Get_Element_Type()
const {
return HUD_ELEMENT_TEXT; }
178 virtual HUDTextElementClass* As_HUDTextElementClass() {
return this; }
180 const WideStringClass& Get_Text()
const {
return text; }
181 void Set_Text(
const wchar_t* newText) { text = newText; Set_Dirty(
true); }
182 HUDFontType Get_Font()
const {
return font; }
183 void Set_Font(HUDFontType newFont) { font = newFont; Set_Dirty(
true); }
184 const RectClass& Get_Clipping_Area()
const {
return clipArea; }
185 void Set_Clipping_Area(
const RectClass& newArea) { clipArea = newArea; Set_Dirty(
true); }
186 float Get_Clipping_Area_Size()
const {
const Vector2& a = clipArea.getSize();
return a.X * a.Y; }
187 float Get_Clipping_Area_Diagonal_Length()
const {
return clipArea.Extent().Length() * 2; }
188 const Vector4& Get_Color()
const {
return color; }
189 void Set_Color(
const Vector4& newColor) { color = newColor; Set_Dirty(
true); }
190 void Set_Color(
int a,
int r,
int g,
int b) { color = Vector4(a / 255.f, r / 255.f, g / 255.f, b / 255.f); Set_Dirty(
true); }
193 WideStringClass text;