Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
pressedkeys.qc File Reference
#include "pressedkeys.qh"
#include <client/draw.qh>
Include dependency graph for pressedkeys.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void HUD_PressedKeys ()
void HUD_PressedKeys_Export (int fh)

Function Documentation

◆ HUD_PressedKeys()

void HUD_PressedKeys ( )

Definition at line 14 of file pressedkeys.qc.

15{
17 {
19 return;
21 return;
22 }
23
25 vector pos = panel_pos;
26 vector mySize = panel_size;
27
30 else
34 {
35 pos += '1 1 0' * panel_bg_padding;
36 mySize -= '2 2 0' * panel_bg_padding;
37 }
38
39 // force custom 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
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}
#define drawpic_aspect_skin(pos, pic, sz, color, theAlpha, drawflag)
Definition draw.qh:78
int spectatee_status
the -1 disables HUD panels before CSQC receives necessary data
Definition main.qh:197
const int KEY_JUMP
Definition constants.qh:39
const int KEY_ATCK2
Definition constants.qh:42
const int KEY_RIGHT
Definition constants.qh:38
const int KEY_BACKWARD
Definition constants.qh:36
const int KEY_FORWARD
Definition constants.qh:35
const int KEY_LEFT
Definition constants.qh:37
const int KEY_CROUCH
Definition constants.qh:40
const int KEY_ATCK
Definition constants.qh:41
const float DRAWFLAG_NORMAL
void HUD_Panel_LoadCvars()
Definition hud.qc:215
void HUD_Scale_Enable()
Definition hud.qc:91
void HUD_Scale_Disable()
Definition hud.qc:84
vector panel_size
Definition hud.qh:163
float panel_fg_alpha
Definition hud.qh:169
float panel_bg_padding
Definition hud.qh:174
#define HUD_Panel_DrawBg()
Definition hud.qh:55
vector panel_pos
Definition hud.qh:162
bool autocvar__hud_configure
Definition hud_config.qh:3
#define STAT(...)
Definition stats.qh:82
bool autocvar_hud_panel_pressedkeys_attack
Definition pressedkeys.qh:6
bool autocvar_hud_panel_pressedkeys_dynamichud
Definition pressedkeys.qh:7
int autocvar_hud_panel_pressedkeys
Definition pressedkeys.qh:4
float autocvar_hud_panel_pressedkeys_aspect
Definition pressedkeys.qh:5
vector
Definition self.qh:92
int pressedkeys
const vector eX
Definition vector.qh:44
#define vec2(...)
Definition vector.qh:90

References autocvar__hud_configure, autocvar_hud_panel_pressedkeys, autocvar_hud_panel_pressedkeys_aspect, autocvar_hud_panel_pressedkeys_attack, autocvar_hud_panel_pressedkeys_dynamichud, DRAWFLAG_NORMAL, drawpic_aspect_skin, eX, HUD_Panel_DrawBg, HUD_Panel_LoadCvars(), HUD_Scale_Disable(), HUD_Scale_Enable(), KEY_ATCK, KEY_ATCK2, KEY_BACKWARD, KEY_CROUCH, KEY_FORWARD, KEY_JUMP, KEY_LEFT, KEY_RIGHT, panel_bg_padding, panel_fg_alpha, panel_pos, panel_size, pressedkeys, spectatee_status, STAT, vec2, and vector.

◆ HUD_PressedKeys_Export()

void HUD_PressedKeys_Export ( int fh)

Definition at line 7 of file pressedkeys.qc.

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}
#define HUD_Write_Cvar(cvar)
Definition hud_config.qh:40

References HUD_Write_Cvar.