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{
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}
72void 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);
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}
101void 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}
116float 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}
132{
133 if(me.focusedItem >= 0)
135 else
136 clearTooltip(me);
137}
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:651
Gametype MapInfo_CurrentGametype()
Definition mapinfo.qc:1490
void MapInfo_SwitchGameType(Gametype t)
Definition mapinfo.qc:1518
float _MapInfo_GetTeamPlayBool(Gametype t)
Definition mapinfo.qc:539
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:316
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:1106
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:469
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