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