Xonotic
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 
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 
15 {
17  {
19  if(spectatee_status <= 0 && autocvar_hud_panel_pressedkeys < 2) return;
20  }
21 
23  vector pos, mySize;
24  pos = panel_pos;
25  mySize = panel_size;
26 
29  else
33  {
34  pos += '1 1 0' * panel_bg_padding;
35  mySize -= '2 2 0' * panel_bg_padding;
36  }
37 
38  // force custom aspect
40  if(aspect)
41  {
42  vector newSize = '0 0 0';
43  if(mySize.x/mySize.y > aspect)
44  {
45  newSize.x = aspect * mySize.y;
46  newSize.y = mySize.y;
47 
48  pos.x = pos.x + (mySize.x - newSize.x) / 2;
49  }
50  else
51  {
52  newSize.y = 1/aspect * mySize.x;
53  newSize.x = mySize.x;
54 
55  pos.y = pos.y + (mySize.y - newSize.y) / 2;
56  }
57  mySize = newSize;
58  }
59 
60  vector keysize = vec2(mySize.x / (14/4), mySize.y / (3 - !autocvar_hud_panel_pressedkeys_attack));
61  int pressedkeys = STAT(PRESSED_KEYS);
62 
64  {
65  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);
66  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);
67  pos.y += keysize.y;
68  }
69 
70  drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv" : "key_crouch"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
71  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);
72  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);
73  pos.y += keysize.y;
74  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);
75  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);
76  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);
77 }
float panel_fg_alpha
Definition: hud.qh:166
void HUD_PressedKeys()
Definition: pressedkeys.qc:14
bool autocvar__hud_configure
Definition: hud_config.qh:3
vector panel_size
Definition: hud.qh:160
void HUD_Scale_Disable()
Definition: hud.qc:83
bool autocvar_hud_panel_pressedkeys_dynamichud
Definition: pressedkeys.qh:7
#define HUD_Panel_DrawBg()
Definition: hud.qh:54
void HUD_Scale_Enable()
Definition: hud.qc:90
#define drawpic_aspect_skin(pos, pic, sz, color, theAlpha, drawflag)
Definition: draw.qh:78
void HUD_PressedKeys_Export(int fh)
Definition: pressedkeys.qc:7
const float DRAWFLAG_NORMAL
Definition: csprogsdefs.qc:317
vector panel_pos
Definition: hud.qh:159
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float spectatee_status
Definition: main.qh:166
int autocvar_hud_panel_pressedkeys
Definition: pressedkeys.qh:4
const vector eX
Definition: vector.qh:44
int pressedkeys
Definition: client.qh:76
bool autocvar_hud_panel_pressedkeys_attack
Definition: pressedkeys.qh:6
#define vec2(...)
Definition: vector.qh:90
#define HUD_Write_Cvar(cvar)
Definition: hud_config.qh:38
float autocvar_hud_panel_pressedkeys_aspect
Definition: pressedkeys.qh:5
void HUD_Panel_LoadCvars()
Definition: hud.qc:216
float panel_bg_padding
Definition: hud.qh:171