]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/dialog_teamselect.qc
Header police
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / dialog_teamselect.qc
1 #include "dialog_teamselect.qh"
2 #ifndef DIALOG_TEAMSELECT_H
3 #define DIALOG_TEAMSELECT_H
4 #include "rootdialog.qc"
5 CLASS(XonoticTeamSelectDialog, XonoticRootDialog)
6         METHOD(XonoticTeamSelectDialog, fill, void(entity));
7         METHOD(XonoticTeamSelectDialog, showNotify, void(entity));
8         ATTRIB(XonoticTeamSelectDialog, title, string, _("Team Selection"))
9         ATTRIB(XonoticTeamSelectDialog, color, vector, SKINCOLOR_DIALOG_TEAMSELECT)
10         ATTRIB(XonoticTeamSelectDialog, intendedWidth, float, 0.4)
11         ATTRIB(XonoticTeamSelectDialog, rows, float, 5)
12         ATTRIB(XonoticTeamSelectDialog, columns, float, 4)
13         ATTRIB(XonoticTeamSelectDialog, name, string, "TeamSelect")
14         ATTRIB(XonoticTeamSelectDialog, team1, entity, NULL)
15         ATTRIB(XonoticTeamSelectDialog, team2, entity, NULL)
16         ATTRIB(XonoticTeamSelectDialog, team3, entity, NULL)
17         ATTRIB(XonoticTeamSelectDialog, team4, entity, NULL)
18         ATTRIB(XonoticTeamSelectDialog, requiresConnection, float, true)
19 ENDCLASS(XonoticTeamSelectDialog)
20 #endif
21
22 #ifdef IMPLEMENTATION
23 entity makeTeamButton_T(string theName, vector theColor, string commandtheName, string theTooltip)
24 {
25         entity b;
26         b = makeXonoticBigCommandButton_T(theName, theColor, commandtheName, 1, theTooltip);
27         return b;
28 }
29 entity makeTeamButton(string theName, vector theColor, string commandtheName)
30 {
31         return makeTeamButton_T(theName, theColor, commandtheName, string_null);
32 }
33
34 void XonoticTeamSelectDialog_showNotify(entity me)
35 {
36         SUPER(XonoticTeamSelectDialog).showNotify(me);
37         float teams, nTeams;
38         teams = cvar("_teams_available");
39         nTeams = 0;
40         me.team1.disabled = !(teams & 1); nTeams += boolean(teams & 1);
41         me.team2.disabled = !(teams & 2); nTeams += boolean(teams & 2);
42         me.team3.disabled = !(teams & 4); nTeams += boolean(teams & 4);
43         me.team4.disabled = !(teams & 8); nTeams += boolean(teams & 8);
44 }
45
46 void XonoticTeamSelectDialog_fill(entity me)
47 {
48         entity e;
49         me.TR(me);
50                 me.TD(me, 2, 4, e = makeTeamButton_T(_("join 'best' team (auto-select)"), '0 0 0', "cmd selectteam auto; cmd join",
51                         _("Autoselect team (recommended)")));
52                         e.preferredFocusPriority = 1;
53         me.TR(me);
54         me.TR(me);
55                 me.TD(me, 2, 1, e = me.team1 = makeTeamButton(_("red"), '1 0.5 0.5', "cmd selectteam red; cmd join"));
56                 me.TD(me, 2, 1, e = me.team2 = makeTeamButton(_("blue"), '0.5 0.5 1', "cmd selectteam blue; cmd join"));
57                 me.TD(me, 2, 1, e = me.team3 = makeTeamButton(_("yellow"), '1 1 0.5', "cmd selectteam yellow; cmd join"));
58                 me.TD(me, 2, 1, e = me.team4 = makeTeamButton(_("pink"), '1 0.5 1', "cmd selectteam pink; cmd join"));
59         me.TR(me);
60         me.TR(me);
61                 me.TD(me, 1, 4, makeXonoticCommandButton(_("spectate"), '0 0 0', "cmd spectate", 1));
62 }
63 #endif
64
65 /* Click. The c-word is here so you can grep for it :-) */