Xonotic
gametypelist.qc
Go to the documentation of this file.
1 #include "gametypelist.qh"
2 
5 #include <common/mapinfo.qh>
6 
8 {
9  entity me;
11  me.configureXonoticGametypeList(me);
12  return me;
13 }
15 {
16  me.configureXonoticListBox(me);
17  me.nItems = GameType_GetCount();
18 
19  if(SKINBOOL_GAMETYPELIST_ICON_BLUR)
20  {
21  for(int i = 0; i < GameType_GetTotalCount(); ++i)
23  }
24 
25  me.loadCvars(me);
26 }
28 {
29  SUPER(XonoticGametypeList).setSelected(me, i);
30  me.saveCvars(me);
31 }
33 {
35  int cnt = GameType_GetCount();
36  float i;
37  for(i = 0; i < cnt; ++i)
38  if(t == GameType_GetID(i))
39  break;
40  if(i >= cnt)
41  {
42  for(i = 0; i < cnt; ++i)
43  if(t == MAPINFO_TYPE_DEATHMATCH)
44  break;
45  if(i >= cnt)
46  i = 0;
47  }
48  me.setSelected(me, i);
49  // do we need this: me.parent.gameTypeChangeNotify(me.parent); // to make sure
50 }
52 {
53  Gametype t = GameType_GetID(me.selectedItem);
54  if (t == MapInfo_CurrentGametype()) {
55  return;
56  }
58  entity owner = me.parent;
59  if (owner) { // not set immediately
60  owner.gameTypeChangeNotify(owner);
61  }
62 }
64 {
65  if(me.nItems != GameType_GetCount())
66  {
67  me.nItems = GameType_GetCount();
68  me.setSelected(me, 0);
69  }
70  SUPER(XonoticGametypeList).draw(me);
71 }
72 void XonoticGametypeList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
73 {
74  string s1, s2;
75 
76  if(isSelected)
77  draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
78  else if(isFocused)
79  {
80  me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
81  draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
82  }
83 
84  draw_Picture(me.columnIconOrigin * eX, GameType_GetIcon(i), me.columnIconSize * eX + eY, '1 1 1', SKINALPHA_LISTBOX_SELECTED);
85  s1 = GameType_GetName(i);
86 
88  s2 = _("teamplay");
89  else
90  s2 = _("free for all");
91 
92  vector save_fontscale = draw_fontscale;
93  float f = draw_CondensedFontFactor(strcat(s1, " ", s2), false, me.realFontSize, 1);
94  draw_fontscale.x *= f;
95  vector fs = me.realFontSize;
96  fs.x *= f;
97  draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s1, fs, '1 1 1', SKINALPHA_TEXT, 0);
98  draw_Text(me.realUpperMargin * eY + (me.columnNameOrigin + 1.0 * (me.columnNameSize - draw_TextWidth(s2, 0, fs))) * eX, s2, fs, SKINCOLOR_TEXT, SKINALPHA_TEXT, 0);
99  draw_fontscale = save_fontscale;
100 }
101 void XonoticGametypeList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
102 {
103  me.itemAbsSize = '0 0 0';
104  SUPER(XonoticGametypeList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
105 
106  me.itemAbsSize.y = absSize.y * me.itemHeight;
107  me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
108  me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
109  me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
110  me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
111  me.columnIconOrigin = 0;
112  me.columnIconSize = me.itemAbsSize.y / me.itemAbsSize.x;
113  me.columnNameOrigin = me.columnIconOrigin + me.columnIconSize + (0.5 * me.realFontSize.x);
114  me.columnNameSize = 1 - me.columnIconSize - (1.5 * me.realFontSize.x);
115 }
116 float XonoticGametypeList_keyDown(entity me, float scan, float ascii, float shift)
117 {
118  if(scan == K_ENTER || scan == K_KP_ENTER)
119  {
121  me.parent.gameTypeSelectNotify(me.parent);
122  return 1;
123  }
124 
125  return SUPER(XonoticGametypeList).keyDown(me, scan, ascii, shift);
126 }
128 {
130 }
132 {
133  if(me.focusedItem >= 0)
135  else
136  clearTooltip(me);
137 }
float XonoticGametypeList_keyDown(entity me, float scan, float ascii, float shift)
void XonoticGametypeList_saveCvars(entity me)
Definition: gametypelist.qc:51
string string_null
Definition: nil.qh:9
void XonoticGametypeList_draw(entity me)
Definition: gametypelist.qc:63
spree_inf s1 s2 s3loc s2 s1
Definition: all.inc:265
const vector eY
Definition: vector.qh:45
#define NEW(cname,...)
Definition: oo.qh:105
spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2 f1 f1points s1 s2
Definition: all.inc:438
float _MapInfo_GetTeamPlayBool(Gametype t)
Definition: mapinfo.qc:507
entity() spawn
void XonoticGametypeList_focusedItemChangeNotify(entity me)
void XonoticGametypeList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
Definition: gametypelist.qc:72
entity owner
Definition: main.qh:73
float K_KP_ENTER
Definition: keycodes.qc:74
void XonoticGametypeList_clickListBoxItem(entity me, float i, vector where)
float PRECACHE_PIC_MIPMAP
#define SUPER(cname)
Definition: oo.qh:219
Gametype MapInfo_CurrentGametype()
Definition: mapinfo.qc:1150
float cnt
Definition: powerups.qc:24
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"))
entity makeXonoticGametypeList()
Definition: gametypelist.qc:7
vector(float skel, float bonenum) _skel_get_boneabs_hidden
void XonoticGametypeList_setSelected(entity me, float i)
Definition: gametypelist.qc:27
string MapInfo_Type_Description(Gametype t)
Definition: mapinfo.qc:611
const vector eX
Definition: vector.qh:44
float K_ENTER
Definition: keycodes.qc:8
void XonoticGametypeList_configureXonoticGametypeList(entity me)
Definition: gametypelist.qc:14
void MapInfo_SwitchGameType(Gametype t)
Definition: mapinfo.qc:1178
void XonoticGametypeList_loadCvars(entity me)
Definition: gametypelist.qc:32
void XonoticGametypeList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)