File: hud.h

package info (click to toggle)
openmohaa 0.82.1%2Bdfsg-1
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 34,192 kB
  • sloc: cpp: 315,720; ansic: 275,789; sh: 312; xml: 246; asm: 141; makefile: 7
file content (208 lines) | stat: -rw-r--r-- 5,580 bytes parent folder | download
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
/*
===========================================================================
Copyright (C) 2024 the OpenMoHAA team

This file is part of OpenMoHAA source code.

OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/

// hud.h: New HUD handler for MoHAA
//

#pragma once

#include "listener.h"
#include "container.h"

#define TIMER_ACTIVE (1 << 0)
#define TIMER_UP     (1 << 1)

typedef enum hudAlign_s {
    HUD_LEFT    = 0,
    HUD_CENTER  = 1,
    HUD_RIGHT   = 2,
    HUD_TOP     = 0,
    HUD_BOTTOM  = 2,
    HUD_INVALID = 3
} hudAlign_t;

class Hud : public Listener
{
private:
    unsigned int number; // auto-assigned number
#ifdef GAME_DLL
    char clientnum; // assigned client number
#else
    fontHeader_t *font;
    qhandle_t     shaderHandle;
#endif
    hudAlign_t alignX, alignY;
    float      x, y;
    float      width, height;
    Vector     color;
    float      alpha;
    str        fontName;
    str        shader;
    str        text;
    bool       virtualSize;
    bool       isDimensional;

    bool fade_alpha;
    bool fade_move;
    bool fade_scale;
    int  fade_timer_flags;

    bool fade_alpha_first;
    int  fade_move_x_first;
    int  fade_move_y_first;

    float fade_alpha_current;
    float fade_move_current;
    float fade_scale_current;
    float fade_time_current;

    float fade_alpha_time;
    float fade_move_time;
    float fade_scale_time;
    float fade_time;
    float fade_out_time;

    float fade_alpha_start;
    float fade_move_x_start;
    float fade_move_y_start;
    float fade_scale_w_start;
    float fade_scale_h_start;
    float fade_time_alpha_start;

    float fade_alpha_target;
    float fade_move_x_target;
    float fade_move_y_target;
    float fade_scale_w_target;
    float fade_scale_h_target;
    float fade_time_target;

    Vector   org;
    Vector   lastOrg;
    qboolean always_show;
    qboolean depth;
    int      enttarget;

#ifdef GAME_DLL
    void SetBroadcast(int clientNumber = -1); // Broadcast to someone or everyone
#endif

private:
#ifdef GAME_DLL
    void WriteNumber();
#endif

public:
    CLASS_PROTOTYPE(Hud);

    void Archive(Archiver& arc) override;

    static Hud *Find(int index);
    static Hud *FindOrCreate(int index);
    static int  GetFreeNumber(void);
    static void ProcessThink(void);
    static int  Sort(const void *elem1, const void *elem2);

#ifdef CGAME_DLL
    static void ArchiveFunction(Archiver& arc);
#endif

#ifdef GAME_DLL
    Hud(int client = -1);
#else
    Hud(int index = -1);
#endif
    ~Hud(void);

#ifdef CGAME_DLL
    void Draw3D(void);
#endif

    void FadeThink(void);
    void MoveThink(void);
    void ScaleThink(void);
    void TimerThink(void);

    void Think(void);

    void FadeOverTime(float time);
    void MoveOverTime(float time);
    void ScaleOverTime(float time, short width, short height);

    void Refresh(int clientNumber = -1);

#ifdef GAME_DLL
    int GetClient(void);
#endif

    void Set3D(Vector vector_or_offset, qboolean always_show, qboolean depth, int entnum = -1);
    void SetNon3D(void);
    void SetAlignX(hudAlign_t align);
    void SetAlignY(hudAlign_t align);
    void SetAlpha(float alpha);
    void SetClient(int clientnum, qboolean clears = false);
    void SetColor(Vector color);
    void SetFont(const char *font);
    void SetRectX(short x);
    void SetRectY(short y);
    void SetRectHeight(short height);
    void SetRectWidth(short height);
    void SetShader(const char *shader, float width, float height);
    void SetText(const char *text);
    void SetTimer(float time, float fade_at_time = -1.0f);
    void SetTimerUp(float time, float fade_at_time = -1.0f);
    void SetVirtualSize(qboolean virtualSize);

    // Events
    void EventGetAlignX(Event *ev);
    void EventGetAlignY(Event *ev);
    void EventGetAlpha(Event *ev);
    void EventGetColor(Event *ev);
    void EventGetFont(Event *ev);
    void EventGetHeight(Event *ev);
    void EventGetRectX(Event *ev);
    void EventGetRectY(Event *ev);
    void EventGetTime(Event *ev);
    void EventGetWidth(Event *ev);
    void EventFadeDone(Event *ev);
    void EventFadeOverTime(Event *ev);
    void EventMoveDone(Event *ev);
    void EventMoveOverTime(Event *ev);
    void EventRefresh(Event *ev);
    void EventScaleOverTime(Event *ev);
    void EventSet3D(Event *ev);
    void EventSetNon3D(Event *ev);
    void EventSetAlignX(Event *ev);
    void EventSetAlignY(Event *ev);
    void EventSetAlpha(Event *ev);
    void EventSetColor(Event *ev);
    void EventSetFont(Event *ev);
    void EventSetPlayer(Event *ev);
    void EventSetRectX(Event *ev);
    void EventSetRectY(Event *ev);
    void EventSetShader(Event *ev);
    void EventSetText(Event *ev);
    void EventSetTimer(Event *ev);
    void EventSetTimerUp(Event *ev);
    void EventSetVirtualSize(Event *ev);
};

extern Container<Hud *> hudElements;