OpenMoHAA 0.82.1
Loading...
Searching...
No Matches
hud.h
1/*
2===========================================================================
3Copyright (C) 2024 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23// hud.h: New HUD handler for MoHAA
24//
25
26#pragma once
27
28#include "listener.h"
29#include "container.h"
30
31#define TIMER_ACTIVE (1 << 0)
32#define TIMER_UP (1 << 1)
33
34typedef enum hudAlign_s {
35 HUD_LEFT = 0,
36 HUD_CENTER = 1,
37 HUD_RIGHT = 2,
38 HUD_TOP = 0,
39 HUD_BOTTOM = 2,
40 HUD_INVALID = 3
41} hudAlign_t;
42
43class Hud : public Listener
44{
45private:
46 unsigned int number; // auto-assigned number
47#ifdef GAME_DLL
48 char clientnum; // assigned client number
49#else
50 fontHeader_t *font;
51 qhandle_t shaderHandle;
52#endif
53 hudAlign_t alignX, alignY;
54 float x, y;
55 float width, height;
56 Vector color;
57 float alpha;
58 str fontName;
59 str shader;
60 str text;
61 bool virtualSize;
62 bool isDimensional;
63
64 bool fade_alpha;
65 bool fade_move;
66 bool fade_scale;
67 int fade_timer_flags;
68
69 bool fade_alpha_first;
70 int fade_move_x_first;
71 int fade_move_y_first;
72
73 float fade_alpha_current;
74 float fade_move_current;
75 float fade_scale_current;
76 float fade_time_current;
77
78 float fade_alpha_time;
79 float fade_move_time;
80 float fade_scale_time;
81 float fade_time;
82 float fade_out_time;
83
84 float fade_alpha_start;
85 float fade_move_x_start;
86 float fade_move_y_start;
87 float fade_scale_w_start;
88 float fade_scale_h_start;
89 float fade_time_alpha_start;
90
91 float fade_alpha_target;
92 float fade_move_x_target;
93 float fade_move_y_target;
94 float fade_scale_w_target;
95 float fade_scale_h_target;
96 float fade_time_target;
97
98 Vector org;
99 Vector lastOrg;
100 qboolean always_show;
101 qboolean depth;
102 int enttarget;
103
104#ifdef GAME_DLL
105 void SetBroadcast(int clientNumber = -1); // Broadcast to someone or everyone
106#endif
107
108private:
109#ifdef GAME_DLL
110 void WriteNumber();
111#endif
112
113public:
114 CLASS_PROTOTYPE(Hud);
115
116 void Archive(Archiver& arc) override;
117
118 static Hud *Find(int index);
119 static Hud *FindOrCreate(int index);
120 static int GetFreeNumber(void);
121 static void ProcessThink(void);
122 static int Sort(const void *elem1, const void *elem2);
123
124#ifdef CGAME_DLL
125 static void ArchiveFunction(Archiver& arc);
126#endif
127
128#ifdef GAME_DLL
129 Hud(int client = -1);
130#else
131 Hud(int index = -1);
132#endif
133 ~Hud(void);
134
135#ifdef CGAME_DLL
136 void Draw3D(void);
137#endif
138
139 void FadeThink(void);
140 void MoveThink(void);
141 void ScaleThink(void);
142 void TimerThink(void);
143
144 void Think(void);
145
146 void FadeOverTime(float time);
147 void MoveOverTime(float time);
148 void ScaleOverTime(float time, short width, short height);
149
150 void Refresh(int clientNumber = -1);
151
152#ifdef GAME_DLL
153 int GetClient(void);
154#endif
155
156 void Set3D(Vector vector_or_offset, qboolean always_show, qboolean depth, int entnum = -1);
157 void SetNon3D(void);
158 void SetAlignX(hudAlign_t align);
159 void SetAlignY(hudAlign_t align);
160 void SetAlpha(float alpha);
161 void SetClient(int clientnum, qboolean clears = false);
162 void SetColor(Vector color);
163 void SetFont(const char *font);
164 void SetRectX(short x);
165 void SetRectY(short y);
166 void SetRectHeight(short height);
167 void SetRectWidth(short height);
168 void SetShader(const char *shader, float width, float height);
169 void SetText(const char *text);
170 void SetTimer(float time, float fade_at_time = -1.0f);
171 void SetTimerUp(float time, float fade_at_time = -1.0f);
172 void SetVirtualSize(qboolean virtualSize);
173
174 // Events
175 void EventGetAlignX(Event *ev);
176 void EventGetAlignY(Event *ev);
177 void EventGetAlpha(Event *ev);
178 void EventGetColor(Event *ev);
179 void EventGetFont(Event *ev);
180 void EventGetHeight(Event *ev);
181 void EventGetRectX(Event *ev);
182 void EventGetRectY(Event *ev);
183 void EventGetTime(Event *ev);
184 void EventGetWidth(Event *ev);
185 void EventFadeDone(Event *ev);
186 void EventFadeOverTime(Event *ev);
187 void EventMoveDone(Event *ev);
188 void EventMoveOverTime(Event *ev);
189 void EventRefresh(Event *ev);
190 void EventScaleOverTime(Event *ev);
191 void EventSet3D(Event *ev);
192 void EventSetNon3D(Event *ev);
193 void EventSetAlignX(Event *ev);
194 void EventSetAlignY(Event *ev);
195 void EventSetAlpha(Event *ev);
196 void EventSetColor(Event *ev);
197 void EventSetFont(Event *ev);
198 void EventSetPlayer(Event *ev);
199 void EventSetRectX(Event *ev);
200 void EventSetRectY(Event *ev);
201 void EventSetShader(Event *ev);
202 void EventSetText(Event *ev);
203 void EventSetTimer(Event *ev);
204 void EventSetTimerUp(Event *ev);
205 void EventSetVirtualSize(Event *ev);
206};
207
208extern Container<Hud *> hudElements;
Definition archive.h:86
Definition container.h:85
Definition listener.h:246
Definition vector.h:61
Definition str.h:77