Xonotic
weaponslist.qc File Reference
#include "weaponslist.qh"
#include <common/weapons/_all.qh>
+ Include dependency graph for weaponslist.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

entity makeXonoticWeaponsList ()
 
void WeaponsList_MoveDown_Click (entity box, entity me)
 
void WeaponsList_MoveUp_Click (entity box, entity me)
 
void XonoticWeaponsList_configureXonoticWeaponsList (entity me)
 
void XonoticWeaponsList_draw (entity me)
 
void XonoticWeaponsList_drawListBoxItem (entity me, int i, vector absSize, bool isSelected, bool isFocused)
 
float XonoticWeaponsList_keyDown (entity me, float scan, float ascii, float shift)
 
float XonoticWeaponsList_mouseDrag (entity me, vector pos)
 
void XonoticWeaponsList_resizeNotify (entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
 
string XonoticWeaponsList_toString (entity me)
 

Variables

bool disabled
 

Function Documentation

◆ makeXonoticWeaponsList()

entity makeXonoticWeaponsList ( )

Definition at line 7 of file weaponslist.qc.

References entity(), and NEW.

8 {
9  entity me;
10  me = NEW(XonoticWeaponsList);
11  me.configureXonoticWeaponsList(me);
12  return me;
13 }
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
+ Here is the call graph for this function:

◆ WeaponsList_MoveDown_Click()

void WeaponsList_MoveDown_Click ( entity  box,
entity  me 
)

Definition at line 37 of file weaponslist.qc.

References cvar_set(), cvar_string(), and swapInPriorityList().

Referenced by XonoticWeaponsList_keyDown().

38 {
39  if(me.selectedItem < me.nItems - 1)
40  {
41  cvar_set("cl_weaponpriority", swapInPriorityList(cvar_string("cl_weaponpriority"), me.selectedItem, me.selectedItem + 1));
42  me.setSelected(me, me.selectedItem + 1);
43  }
44 }
string swapInPriorityList(string order, float i, float j)
Definition: util.qc:540
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WeaponsList_MoveUp_Click()

void WeaponsList_MoveUp_Click ( entity  box,
entity  me 
)

Definition at line 29 of file weaponslist.qc.

References cvar_set(), cvar_string(), and swapInPriorityList().

Referenced by XonoticWeaponsList_keyDown().

30 {
31  if(me.selectedItem > 0)
32  {
33  cvar_set("cl_weaponpriority", swapInPriorityList(cvar_string("cl_weaponpriority"), me.selectedItem - 1, me.selectedItem));
34  me.setSelected(me, me.selectedItem - 1);
35  }
36 }
string swapInPriorityList(string order, float i, float j)
Definition: util.qc:540
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ XonoticWeaponsList_configureXonoticWeaponsList()

void XonoticWeaponsList_configureXonoticWeaponsList ( entity  me)

Definition at line 14 of file weaponslist.qc.

15 {
16  me.configureXonoticListBox(me);
17 }

◆ XonoticWeaponsList_draw()

void XonoticWeaponsList_draw ( entity  me)

Definition at line 18 of file weaponslist.qc.

References cvar_set(), cvar_string(), SUPER, tokenize_console, W_FixWeaponOrder(), W_NameWeaponOrder(), and W_NumberWeaponOrder().

19 {
20  // read in cvar?
21  string s, t;
22  s = W_NumberWeaponOrder(cvar_string("cl_weaponpriority"));
23  t = W_FixWeaponOrder(s, 1);
24  if(t != s)
25  cvar_set("cl_weaponpriority", W_NameWeaponOrder(t));
26  me.nItems = tokenize_console(t);
27  SUPER(XonoticWeaponsList).draw(me);
28 }
string W_FixWeaponOrder(string order, float complete)
Definition: all.qc:95
#define SUPER(cname)
Definition: oo.qh:219
string W_NumberWeaponOrder(string order)
Definition: all.qc:136
#define tokenize_console
Definition: dpextensions.qh:24
string W_NameWeaponOrder(string order)
Definition: all.qc:125
+ Here is the call graph for this function:

◆ XonoticWeaponsList_drawListBoxItem()

void XonoticWeaponsList_drawListBoxItem ( entity  me,
int  i,
vector  absSize,
bool  isSelected,
bool  isFocused 
)

Definition at line 84 of file weaponslist.qc.

References argv(), draw_CondensedFontFactor(), draw_Fill(), draw_fontscale, draw_Text(), entity(), eY, getFadedAlpha(), REGISTRY_GET, stof(), strcat(), vector(), and WEP_FLAG_MUTATORBLOCKED.

85 {
86  entity e;
87  if(isSelected)
88  draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
89  else if(isFocused)
90  {
91  me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
92  draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
93  }
94  e = REGISTRY_GET(Weapons, stof(argv(i)));
95  string msg = e.m_name;
96  if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED)
97  msg = strcat(msg, "*");
98 
99  vector save_fontscale = draw_fontscale;
100  float f = draw_CondensedFontFactor(msg, false, me.realFontSize, 1);
101  draw_fontscale.x *= f;
102  vector fs = me.realFontSize;
103  fs.x *= f;
104  draw_Text(me.realUpperMargin * eY, msg, fs, SKINCOLOR_TEXT, SKINALPHA_TEXT, 0);
105  draw_fontscale = save_fontscale;
106 }
const vector eY
Definition: vector.qh:45
entity() spawn
#define REGISTRY_GET(id, i)
Definition: registry.qh:43
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const int WEP_FLAG_MUTATORBLOCKED
Definition: weapon.qh:203
+ Here is the call graph for this function:

◆ XonoticWeaponsList_keyDown()

float XonoticWeaponsList_keyDown ( entity  me,
float  scan,
float  ascii,
float  shift 
)

Definition at line 108 of file weaponslist.qc.

References NULL, SUPER, WeaponsList_MoveDown_Click(), and WeaponsList_MoveUp_Click().

109 {
110  if(ascii == 43) // +
111  {
113  return 1;
114  }
115  else if(ascii == 45) // -
116  {
118  return 1;
119  }
120  else if(SUPER(XonoticWeaponsList).keyDown(me, scan, ascii, shift))
121  return 1;
122  return 0;
123 }
void WeaponsList_MoveDown_Click(entity box, entity me)
Definition: weaponslist.qc:37
#define SUPER(cname)
Definition: oo.qh:219
#define NULL
Definition: post.qh:17
void WeaponsList_MoveUp_Click(entity box, entity me)
Definition: weaponslist.qc:29
+ Here is the call graph for this function:

◆ XonoticWeaponsList_mouseDrag()

float XonoticWeaponsList_mouseDrag ( entity  me,
vector  pos 
)

Definition at line 53 of file weaponslist.qc.

References cvar_set(), cvar_string(), SUPER, and swapInPriorityList().

54 {
55  int i = me.selectedItem;
56  float f = SUPER(XonoticWeaponsList).mouseDrag(me, pos);
57 
58  if(me.pressed != 1) // don't change priority if the person is just scrolling
59  {
60  if(me.selectedItem != i)
61  {
62  if(me.applyButton)
63  me.applyButton.disabled = false;
64  cvar_set("cl_weaponpriority", swapInPriorityList(cvar_string("cl_weaponpriority"), me.selectedItem, i));
65  }
66  }
67 
68  return f;
69 }
#define SUPER(cname)
Definition: oo.qh:219
string swapInPriorityList(string order, float i, float j)
Definition: util.qc:540
+ Here is the call graph for this function:

◆ XonoticWeaponsList_resizeNotify()

void XonoticWeaponsList_resizeNotify ( entity  me,
vector  relOrigin,
vector  relSize,
vector  absOrigin,
vector  absSize 
)

Definition at line 45 of file weaponslist.qc.

References SUPER.

46 {
47  SUPER(XonoticWeaponsList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
48 
49  me.realFontSize_y = me.fontSize / (absSize.y * me.itemHeight);
50  me.realFontSize_x = me.fontSize / (absSize.x * (1 - me.controlWidth));
51  me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
52 }
#define SUPER(cname)
Definition: oo.qh:219

◆ XonoticWeaponsList_toString()

string XonoticWeaponsList_toString ( entity  me)

Definition at line 70 of file weaponslist.qc.

References argv(), cvar_string(), entity(), REGISTRY_GET, stof(), strcat(), strlen(), substring(), tokenize_console, and W_NumberWeaponOrder().

71 {
72  float n, i;
73  string s;
74  entity e;
75  n = tokenize_console(W_NumberWeaponOrder(cvar_string("cl_weaponpriority")));
76  s = "";
77  for(i = 0; i < n; ++i)
78  {
79  e = REGISTRY_GET(Weapons, stof(argv(i)));
80  s = strcat(s, e.m_name, ", ");
81  }
82  return substring(s, 0, strlen(s) - 2);
83 }
entity() spawn
#define REGISTRY_GET(id, i)
Definition: registry.qh:43
string W_NumberWeaponOrder(string order)
Definition: all.qc:136
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define tokenize_console
Definition: dpextensions.qh:24
+ Here is the call graph for this function:

Variable Documentation

◆ disabled

bool disabled

Definition at line 5 of file weaponslist.qc.