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