OpenMoHAA 0.82.0
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{
36 HUD_LEFT = 0,
37 HUD_CENTER = 1,
38 HUD_RIGHT = 2,
39 HUD_TOP = 0,
40 HUD_BOTTOM = 2,
41 HUD_INVALID = 3
42} hudAlign_t;
43
44class Hud : public Listener
45{
46private:
47 unsigned int number; // auto-assigned number
48#ifdef GAME_DLL
49 char clientnum; // assigned client number
50#else
51 fontHeader_t *font;
52 qhandle_t shaderHandle;
53#endif
54 hudAlign_t alignX, alignY;
55 float x, y;
56 float width, height;
57 Vector color;
58 float alpha;
59 str fontName;
60 str shader;
61 str text;
62 bool virtualSize;
63 bool isDimensional;
64
65 bool fade_alpha;
66 bool fade_move;
67 bool fade_scale;
68 int fade_timer_flags;
69
70 bool fade_alpha_first;
71 int fade_move_x_first;
72 int fade_move_y_first;
73
74 float fade_alpha_current;
75 float fade_move_current;
76 float fade_scale_current;
77 float fade_time_current;
78
79 float fade_alpha_time;
80 float fade_move_time;
81 float fade_scale_time;
82 float fade_time;
83 float fade_out_time;
84
85 float fade_alpha_start;
86 float fade_move_x_start;
87 float fade_move_y_start;
88 float fade_scale_w_start;
89 float fade_scale_h_start;
90 float fade_time_alpha_start;
91
92 float fade_alpha_target;
93 float fade_move_x_target;
94 float fade_move_y_target;
95 float fade_scale_w_target;
96 float fade_scale_h_target;
97 float fade_time_target;
98
99 Vector org;
100 Vector lastOrg;
101 qboolean always_show;
102 qboolean depth;
103 int enttarget;
104
105#ifdef GAME_DLL
106 void SetBroadcast( int clientNumber = -1 ); // Broadcast to someone or everyone
107#endif
108
109private:
110#ifdef GAME_DLL
111 void WriteNumber();
112#endif
113
114public:
115 CLASS_PROTOTYPE( Hud );
116
117 void Archive( Archiver &arc ) override;
118
119 static Hud *Find( int index );
120 static Hud *FindOrCreate( int index );
121 static int GetFreeNumber( void );
122 static void ProcessThink( void );
123 static int Sort( const void *elem1, const void *elem2 );
124
125#ifdef CGAME_DLL
126 static void ArchiveFunction( Archiver &arc );
127#endif
128
129#ifdef GAME_DLL
130 Hud( int client = -1 );
131#else
132 Hud( int index = -1 );
133#endif
134 ~Hud( void );
135
136#ifdef CGAME_DLL
137 void Draw3D( void );
138#endif
139
140 void FadeThink( void );
141 void MoveThink( void );
142 void ScaleThink( void );
143 void TimerThink( void );
144
145 void Think( void );
146
147 void FadeOverTime( float time );
148 void MoveOverTime( float time );
149 void ScaleOverTime( float time, short width, short height );
150
151 void Refresh( int clientNumber = -1 );
152
153#ifdef GAME_DLL
154 int GetClient( void );
155#endif
156
157 void Set3D( Vector vector_or_offset, qboolean always_show, qboolean depth, int entnum = -1 );
158 void SetNon3D( void );
159 void SetAlignX( hudAlign_t align );
160 void SetAlignY( hudAlign_t align );
161 void SetAlpha( float alpha );
162 void SetClient( int clientnum, qboolean clears = false );
163 void SetColor( Vector color );
164 void SetFont( const char * font );
165 void SetRectX( short x );
166 void SetRectY( short y );
167 void SetRectHeight( short height );
168 void SetRectWidth( short height );
169 void SetShader( const char * shader, float width, float height );
170 void SetText( const char * text );
171 void SetTimer( float time, float fade_at_time = -1.0f );
172 void SetTimerUp( float time, float fade_at_time = -1.0f );
173 void SetVirtualSize( qboolean virtualSize );
174
175 // Events
176 void EventGetAlignX( Event * ev );
177 void EventGetAlignY( Event * ev );
178 void EventGetAlpha( Event * ev );
179 void EventGetColor( Event * ev );
180 void EventGetFont( Event * ev );
181 void EventGetHeight( Event *ev );
182 void EventGetRectX( Event * ev );
183 void EventGetRectY( Event * ev );
184 void EventGetTime( Event *ev );
185 void EventGetWidth( Event *ev );
186 void EventFadeDone( Event * ev );
187 void EventFadeOverTime( Event * ev );
188 void EventMoveDone( Event * ev );
189 void EventMoveOverTime( Event * ev );
190 void EventRefresh( Event * ev );
191 void EventScaleOverTime( Event * ev );
192 void EventSet3D( Event *ev );
193 void EventSetNon3D( Event *ev );
194 void EventSetAlignX( Event * ev );
195 void EventSetAlignY( Event * ev );
196 void EventSetAlpha( Event * ev );
197 void EventSetColor( Event * ev );
198 void EventSetFont( Event * ev );
199 void EventSetPlayer( Event * ev );
200 void EventSetRectX( Event * ev );
201 void EventSetRectY( Event * ev );
202 void EventSetShader( Event * ev );
203 void EventSetText( Event * ev );
204 void EventSetTimer( Event *ev );
205 void EventSetTimerUp( Event *ev );
206 void EventSetVirtualSize( Event * ev );
207};
208
209extern Container< Hud * > hudElements;
Definition archive.h:86
Definition container.h:85
Definition listener.h:246
Definition vector.h:61
Definition str.h:77