]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/dialog_teamselect.c
auto-super.pl run
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / dialog_teamselect.c
1 #ifdef INTERFACE
2 CLASS(XonoticTeamSelectDialog) EXTENDS(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 ENDCLASS(XonoticTeamSelectDialog)
16 #endif
17
18 #ifdef IMPLEMENTATION
19 entity makeTeamButton(string theName, vector theColor, string commandtheName)
20 {
21         entity b;
22         b = makeXonoticBigCommandButton(theName, theColor, commandtheName, 1);
23         return b;
24 }
25
26 void XonoticTeamSelectDialog_showNotify(entity me)
27 {
28         float teams, nTeams;
29         teams = cvar("_teams_available");
30         nTeams = 0;
31         me.team1.disabled = !(teams & 1); nTeams += !!(teams & 1);
32         me.team2.disabled = !(teams & 2); nTeams += !!(teams & 2);
33         me.team3.disabled = !(teams & 4); nTeams += !!(teams & 4);
34         me.team4.disabled = !(teams & 8); nTeams += !!(teams & 8);
35 }
36
37 void XonoticTeamSelectDialog_fill(entity me)
38 {
39         entity e;
40         me.TR(me);
41                 me.TD(me, 2, 4, e = makeTeamButton("join 'best' team (auto-select)", '0 0 0', "cmd selectteam auto; cmd join"));
42                         e.preferredFocusPriority = 1;
43         me.TR(me);
44         me.TR(me);
45                 me.TD(me, 2, 1, me.team1 = makeTeamButton("red", '1 0.5 0.5', "cmd selectteam red; cmd join"));
46                 me.TD(me, 2, 1, me.team2 = makeTeamButton("blue", '0.5 0.5 1', "cmd selectteam blue; cmd join"));
47                 me.TD(me, 2, 1, me.team3 = makeTeamButton("yellow", '1 1 0.5', "cmd selectteam yellow; cmd join"));
48                 me.TD(me, 2, 1, me.team4 = makeTeamButton("pink", '1 0.5 1', "cmd selectteam pink; cmd join"));
49         me.TR(me);
50         me.TR(me);
51                 me.TD(me, 1, 4, makeXonoticCommandButton("spectate", '0 0 0', "cmd spectate", 1));
52 }
53 #endif
54
55 /* Click. The c-word is here so you can grep for it :-) */