Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
gametypelist.qc
Go to the documentation of this file.
1#include "gametypelist.qh"
2
5#include <common/mapinfo.qh>
6
8{
10 me.configureXonoticGametypeList(me);
11 return me;
12}
14{
15 me.configureXonoticListBox(me);
16 me.nItems = GameType_GetCount();
17
18 if(SKINBOOL_GAMETYPELIST_ICON_BLUR)
19 {
20 for(int i = 0; i < GameType_GetTotalCount(); ++i)
22 }
23
24 me.loadCvars(me);
25}
27{
28 SUPER(XonoticGametypeList).setSelected(me, i);
29 me.saveCvars(me);
30}
32{
34 int cnt = GameType_GetCount();
35 float i;
36 for(i = 0; i < cnt; ++i)
37 if(t == GameType_GetID(i))
38 break;
39 if(i >= cnt)
40 {
41 for(i = 0; i < cnt; ++i)
42 if(t == MAPINFO_TYPE_DEATHMATCH)
43 break;
44 if(i >= cnt)
45 i = 0;
46 }
47 me.setSelected(me, i);
48 // do we need this: me.parent.gameTypeChangeNotify(me.parent); // to make sure
49}
51{
52 Gametype t = GameType_GetID(me.selectedItem);
53 if (t == MapInfo_CurrentGametype()) {
54 return;
55 }
57 entity owner = me.parent;
58 if (owner) { // not set immediately
59 owner.gameTypeChangeNotify(owner);
60 }
61}
63{
64 if(me.nItems != GameType_GetCount())
65 {
66 me.nItems = GameType_GetCount();
67 me.setSelected(me, 0);
68 }
69 SUPER(XonoticGametypeList).draw(me);
70}
71void XonoticGametypeList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
72{
73 string s1, s2;
74
75 if(isSelected)
76 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
77 else if(isFocused)
78 {
79 me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
80 draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
81 }
82
83 draw_Picture(me.columnIconOrigin * eX, GameType_GetIcon(i), me.columnIconSize * eX + eY, '1 1 1', SKINALPHA_LISTBOX_SELECTED);
85
87 s2 = _("teamplay");
88 else
89 s2 = _("free for all");
90
91 vector save_fontscale = draw_fontscale;
92 float f = draw_CondensedFontFactor(strcat(s1, " ", s2), false, me.realFontSize, 1);
93 draw_fontscale.x *= f;
94 vector fs = me.realFontSize;
95 fs.x *= f;
96 draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s1, fs, '1 1 1', SKINALPHA_TEXT, 0);
97 draw_Text(me.realUpperMargin * eY + (me.columnNameOrigin + 1.0 * (me.columnNameSize - draw_TextWidth(s2, 0, fs))) * eX, s2, fs, SKINCOLOR_TEXT, SKINALPHA_TEXT, 0);
98 draw_fontscale = save_fontscale;
99}
100void XonoticGametypeList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
101{
102 me.itemAbsSize = '0 0 0';
103 SUPER(XonoticGametypeList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
104
105 me.itemAbsSize.y = absSize.y * me.itemHeight;
106 me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
107 me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
108 me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
109 me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
110 me.columnIconOrigin = 0;
111 me.columnIconSize = me.itemAbsSize.y / me.itemAbsSize.x;
112 me.columnNameOrigin = me.columnIconOrigin + me.columnIconSize + (0.5 * me.realFontSize.x);
113 me.columnNameSize = 1 - me.columnIconSize - (1.5 * me.realFontSize.x);
114}
115float XonoticGametypeList_keyDown(entity me, float scan, float ascii, float shift)
116{
117 if(scan == K_ENTER || scan == K_KP_ENTER)
118 {
120 me.parent.gameTypeSelectNotify(me.parent);
121 return 1;
122 }
123
124 return SUPER(XonoticGametypeList).keyDown(me, scan, ascii, shift);
125}
131{
132 if(me.focusedItem >= 0)
134 else
135 clearTooltip(me);
136}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float cnt
Definition powerups.qc:24
entity owner
Definition main.qh:87
float PRECACHE_PIC_MIPMAP
void XonoticGametypeList_configureXonoticGametypeList(entity me)
void XonoticGametypeList_clickListBoxItem(entity me, float i, vector where)
void XonoticGametypeList_setSelected(entity me, float i)
entity makeXonoticGametypeList()
void XonoticGametypeList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
void XonoticGametypeList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
void XonoticGametypeList_saveCvars(entity me)
float XonoticGametypeList_keyDown(entity me, float scan, float ascii, float shift)
void XonoticGametypeList_loadCvars(entity me)
void XonoticGametypeList_focusedItemChangeNotify(entity me)
void XonoticGametypeList_draw(entity me)
float K_ENTER
Definition keycodes.qc:8
float K_KP_ENTER
Definition keycodes.qc:74
string MapInfo_Type_Description(Gametype t)
Definition mapinfo.qc:650
Gametype MapInfo_CurrentGametype()
Definition mapinfo.qc:1482
void MapInfo_SwitchGameType(Gametype t)
Definition mapinfo.qc:1509
float _MapInfo_GetTeamPlayBool(Gametype t)
Definition mapinfo.qc:538
string draw_PreloadPictureWithFlags(string pic, float f)
Definition draw.qc:66
void draw_Picture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha)
Definition draw.qc:72
float draw_CondensedFontFactor(string theText, float ICanHasKallerz, vector SizeThxBye, float maxWidth)
Definition draw.qc:317
void draw_Text(vector theOrigin, string theText, vector theSize, vector theColor, float theAlpha, float ICanHasKallerz)
Definition draw.qc:282
float draw_TextWidth(string theText, float ICanHasKallerz, vector SizeThxBye)
Definition draw.qc:304
void draw_Fill(vector theOrigin, vector theSize, vector theColor, float theAlpha)
Definition draw.qc:97
#define draw_fontscale
Definition draw.qh:5
Gametype GameType_GetID(int cnt)
Definition util.qc:664
int GameType_GetCount()
Definition util.qc:674
int GameType_GetTotalCount()
Definition util.qc:687
string GameType_GetName(int cnt)
Definition util.qc:697
string GameType_GetIcon(int cnt)
Definition util.qc:703
float getFadedAlpha(float currentAlpha, float startAlpha, float targetAlpha)
Definition util.qc:816
void clearTooltip(entity e)
Definition util.qc:277
void setZonedTooltip(entity e, string theTooltip, string theCvar)
Definition util.qc:257
void m_play_click_sound(string soundfile)
Definition menu.qc:1111
const string MENU_SOUND_SELECT
Definition menu.qh:54
const string MENU_SOUND_EXECUTE
Definition menu.qh:51
string string_null
Definition nil.qh:9
spree_inf s1 s2 s3loc s2 s1
Definition all.inc:281
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 s2 f1points s1 s2
Definition all.inc:471
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
#define NEW(cname,...)
Definition oo.qh:117
#define SUPER(cname)
Definition oo.qh:231
vector
Definition self.qh:92
const vector eY
Definition vector.qh:45
const vector eX
Definition vector.qh:44