Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
pressedkeys.qc
Go to the documentation of this file.
1
#include "
pressedkeys.qh
"
2
3
#include <
client/draw.qh
>
4
5
// Pressed keys (#11)
6
7
void
HUD_PressedKeys_Export
(
int
fh)
8
{
9
// allow saving cvars that aesthetically change the panel into hud skin files
10
HUD_Write_Cvar
(
"hud_panel_pressedkeys_aspect"
);
11
HUD_Write_Cvar
(
"hud_panel_pressedkeys_attack"
);
12
}
13
14
void
HUD_PressedKeys
()
15
{
16
if
(!
autocvar__hud_configure
)
17
{
18
if
(!
autocvar_hud_panel_pressedkeys
||
spectatee_status
< 0)
19
return
;
20
if
(
spectatee_status
<= 0 &&
autocvar_hud_panel_pressedkeys
< 2)
21
return
;
22
}
23
24
HUD_Panel_LoadCvars
();
25
vector
pos =
panel_pos
;
26
vector
mySize =
panel_size
;
27
28
if
(
autocvar_hud_panel_pressedkeys_dynamichud
)
29
HUD_Scale_Enable
();
30
else
31
HUD_Scale_Disable
();
32
HUD_Panel_DrawBg
();
33
if
(
panel_bg_padding
)
34
{
35
pos +=
'1 1 0'
*
panel_bg_padding
;
36
mySize -=
'2 2 0'
*
panel_bg_padding
;
37
}
38
39
// force custom aspect
40
float
aspect =
autocvar_hud_panel_pressedkeys_aspect
;
41
if
(aspect)
42
{
43
vector
newSize =
'0 0 0'
;
44
if
(mySize.x / mySize.y > aspect)
45
{
46
newSize.x = aspect * mySize.y;
47
newSize.y = mySize.y;
48
49
pos.x += (mySize.x - newSize.x) * 0.5;
50
}
51
else
52
{
53
newSize.y = 1 / aspect * mySize.x;
54
newSize.x = mySize.x;
55
56
pos.y += (mySize.y - newSize.y) * 0.5;
57
}
58
mySize = newSize;
59
}
60
61
vector
keysize =
vec2
(mySize.x / (14/4), mySize.y / (3 - !
autocvar_hud_panel_pressedkeys_attack
));
62
int
pressedkeys
=
STAT
(PRESSED_KEYS);
63
64
if
(
autocvar_hud_panel_pressedkeys_attack
)
65
{
66
drawpic_aspect_skin
(pos +
eX
* (3/4 * keysize.x), ((
pressedkeys
&
KEY_ATCK
) ?
"key_atck_inv"
:
"key_atck"
), keysize,
'1 1 1'
,
panel_fg_alpha
,
DRAWFLAG_NORMAL
);
67
drawpic_aspect_skin
(pos +
eX
* (7/4 * keysize.x), ((
pressedkeys
&
KEY_ATCK2
) ?
"key_atck2_inv"
:
"key_atck2"
), keysize,
'1 1 1'
,
panel_fg_alpha
,
DRAWFLAG_NORMAL
);
68
pos.y += keysize.y;
69
}
70
71
drawpic_aspect_skin
(pos, ((
pressedkeys
&
KEY_CROUCH
) ?
"key_crouch_inv"
:
"key_crouch"
), keysize,
'1 1 1'
,
panel_fg_alpha
,
DRAWFLAG_NORMAL
);
72
drawpic_aspect_skin
(pos +
eX
* (5/4 * keysize.x), ((
pressedkeys
&
KEY_FORWARD
) ?
"key_forward_inv"
:
"key_forward"
), keysize,
'1 1 1'
,
panel_fg_alpha
,
DRAWFLAG_NORMAL
);
73
drawpic_aspect_skin
(pos +
eX
* (10/4 * keysize.x), ((
pressedkeys
&
KEY_JUMP
) ?
"key_jump_inv"
:
"key_jump"
), keysize,
'1 1 1'
,
panel_fg_alpha
,
DRAWFLAG_NORMAL
);
74
pos.y += keysize.y;
75
drawpic_aspect_skin
(pos +
eX
* (1/4 * keysize.x), ((
pressedkeys
&
KEY_LEFT
) ?
"key_left_inv"
:
"key_left"
), keysize,
'1 1 1'
,
panel_fg_alpha
,
DRAWFLAG_NORMAL
);
76
drawpic_aspect_skin
(pos +
eX
* (5/4 * keysize.x), ((
pressedkeys
&
KEY_BACKWARD
) ?
"key_backward_inv"
:
"key_backward"
), keysize,
'1 1 1'
,
panel_fg_alpha
,
DRAWFLAG_NORMAL
);
77
drawpic_aspect_skin
(pos +
eX
* (9/4 * keysize.x), ((
pressedkeys
&
KEY_RIGHT
) ?
"key_right_inv"
:
"key_right"
), keysize,
'1 1 1'
,
panel_fg_alpha
,
DRAWFLAG_NORMAL
);
78
}
draw.qh
drawpic_aspect_skin
#define drawpic_aspect_skin(pos, pic, sz, color, theAlpha, drawflag)
Definition
draw.qh:78
spectatee_status
int spectatee_status
the -1 disables HUD panels before CSQC receives necessary data
Definition
main.qh:197
KEY_JUMP
const int KEY_JUMP
Definition
constants.qh:39
KEY_ATCK2
const int KEY_ATCK2
Definition
constants.qh:42
KEY_RIGHT
const int KEY_RIGHT
Definition
constants.qh:38
KEY_BACKWARD
const int KEY_BACKWARD
Definition
constants.qh:36
KEY_FORWARD
const int KEY_FORWARD
Definition
constants.qh:35
KEY_LEFT
const int KEY_LEFT
Definition
constants.qh:37
KEY_CROUCH
const int KEY_CROUCH
Definition
constants.qh:40
KEY_ATCK
const int KEY_ATCK
Definition
constants.qh:41
DRAWFLAG_NORMAL
const float DRAWFLAG_NORMAL
Definition
csprogsdefs.qc:321
HUD_Panel_LoadCvars
void HUD_Panel_LoadCvars()
Definition
hud.qc:215
HUD_Scale_Enable
void HUD_Scale_Enable()
Definition
hud.qc:91
HUD_Scale_Disable
void HUD_Scale_Disable()
Definition
hud.qc:84
panel_size
vector panel_size
Definition
hud.qh:163
panel_fg_alpha
float panel_fg_alpha
Definition
hud.qh:169
panel_bg_padding
float panel_bg_padding
Definition
hud.qh:174
HUD_Panel_DrawBg
#define HUD_Panel_DrawBg()
Definition
hud.qh:55
panel_pos
vector panel_pos
Definition
hud.qh:162
HUD_Write_Cvar
#define HUD_Write_Cvar(cvar)
Definition
hud_config.qh:40
autocvar__hud_configure
bool autocvar__hud_configure
Definition
hud_config.qh:3
STAT
#define STAT(...)
Definition
stats.qh:82
HUD_PressedKeys_Export
void HUD_PressedKeys_Export(int fh)
Definition
pressedkeys.qc:7
HUD_PressedKeys
void HUD_PressedKeys()
Definition
pressedkeys.qc:14
pressedkeys.qh
autocvar_hud_panel_pressedkeys_attack
bool autocvar_hud_panel_pressedkeys_attack
Definition
pressedkeys.qh:6
autocvar_hud_panel_pressedkeys_dynamichud
bool autocvar_hud_panel_pressedkeys_dynamichud
Definition
pressedkeys.qh:7
autocvar_hud_panel_pressedkeys
int autocvar_hud_panel_pressedkeys
Definition
pressedkeys.qh:4
autocvar_hud_panel_pressedkeys_aspect
float autocvar_hud_panel_pressedkeys_aspect
Definition
pressedkeys.qh:5
vector
vector
Definition
self.qh:92
pressedkeys
int pressedkeys
Definition
sv_dodging.qc:113
eX
const vector eX
Definition
vector.qh:44
vec2
#define vec2(...)
Definition
vector.qh:90
client
hud
panel
pressedkeys.qc
Generated on
for Xonotic QuakeC by
1.14.0