]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.c
Merge branch 'master' into mirceakitsune/multijump
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / dialog_multiplayer_join_serverinfo.c
1 #ifdef INTERFACE
2 CLASS(XonoticServerInfoDialog) EXTENDS(XonoticDialog)
3         METHOD(XonoticServerInfoDialog, fill, void(entity))
4         METHOD(XonoticServerInfoDialog, loadServerInfo, void(entity, float))
5         ATTRIB(XonoticServerInfoDialog, title, string, "Server Information")
6         ATTRIB(XonoticServerInfoDialog, color, vector, SKINCOLOR_DIALOG_SERVERINFO)
7         ATTRIB(XonoticServerInfoDialog, intendedWidth, float, 0.68)
8         ATTRIB(XonoticServerInfoDialog, rows, float, 11)
9         ATTRIB(XonoticServerInfoDialog, columns, float, 12)
10
11         ATTRIB(XonoticServerInfoDialog, currentServerName, string, string_null)
12         ATTRIB(XonoticServerInfoDialog, currentServerCName, string, string_null)
13         ATTRIB(XonoticServerInfoDialog, currentServerType, string, string_null)
14         ATTRIB(XonoticServerInfoDialog, currentServerMap, string, string_null)
15         ATTRIB(XonoticServerInfoDialog, currentServerPlayers, string, string_null)
16         ATTRIB(XonoticServerInfoDialog, currentServerNumPlayers, string, string_null)
17         ATTRIB(XonoticServerInfoDialog, currentServerNumBots, string, string_null)
18         ATTRIB(XonoticServerInfoDialog, currentServerMod, string, string_null)
19         ATTRIB(XonoticServerInfoDialog, currentServerVersion, string, string_null)
20         ATTRIB(XonoticServerInfoDialog, currentServerPing, string, string_null)
21
22         ATTRIB(XonoticServerInfoDialog, nameLabel, entity, NULL)
23         ATTRIB(XonoticServerInfoDialog, cnameLabel, entity, NULL)
24         ATTRIB(XonoticServerInfoDialog, typeLabel, entity, NULL)
25         ATTRIB(XonoticServerInfoDialog, mapLabel, entity, NULL)
26         ATTRIB(XonoticServerInfoDialog, rawPlayerList, entity, NULL)
27         ATTRIB(XonoticServerInfoDialog, numPlayersLabel, entity, NULL)
28         ATTRIB(XonoticServerInfoDialog, numBotsLabel, entity, NULL)
29         ATTRIB(XonoticServerInfoDialog, modLabel, entity, NULL)
30         ATTRIB(XonoticServerInfoDialog, versionLabel, entity, NULL)
31         ATTRIB(XonoticServerInfoDialog, pingLabel, entity, NULL)
32 ENDCLASS(XonoticServerInfoDialog)
33
34 float SLIST_FIELD_NAME;
35 float SLIST_FIELD_CNAME;
36 float SLIST_FIELD_QCSTATUS;
37 float SLIST_FIELD_MAP;
38 float SLIST_FIELD_PLAYERS;
39 float SLIST_FIELD_NUMHUMANS;
40 float SLIST_FIELD_MAXPLAYERS;
41 float SLIST_FIELD_NUMBOTS;
42 float SLIST_FIELD_MOD;
43 float SLIST_FIELD_PING;
44 void Join_Click(entity btn, entity me);
45 #endif
46
47 #ifdef IMPLEMENTATION
48 void XonoticServerInfoDialog_loadServerInfo(entity me, float i)
49 {
50         float m;
51         string s, typestr, versionstr, numh, maxp;
52
53         SLIST_FIELD_NAME = gethostcacheindexforkey("name");
54         me.currentServerName = strzone(gethostcachestring(SLIST_FIELD_NAME, i));
55         me.nameLabel.setText(me.nameLabel, me.currentServerName);
56
57         SLIST_FIELD_CNAME = gethostcacheindexforkey("cname");
58         me.currentServerCName = strzone(gethostcachestring(SLIST_FIELD_CNAME, i));
59         me.cnameLabel.setText(me.cnameLabel, me.currentServerCName);
60
61         SLIST_FIELD_QCSTATUS = gethostcacheindexforkey("qcstatus");
62         s = gethostcachestring(SLIST_FIELD_QCSTATUS, i);
63         m = tokenizebyseparator(s, ":");
64         if(m > 1)
65         {
66                 typestr = argv (0);
67                 versionstr = argv(1);
68         }
69         else
70         {
71                 typestr = "N/A";
72                 versionstr = "N/A";
73         }
74         me.currentServerType = strzone(typestr);
75         me.typeLabel.setText(me.typeLabel, me.currentServerType);
76
77
78         SLIST_FIELD_MAP = gethostcacheindexforkey("map");
79         me.currentServerMap = strzone(gethostcachestring(SLIST_FIELD_MAP, i));
80         me.mapLabel.setText(me.mapLabel, me.currentServerMap);
81
82         SLIST_FIELD_PLAYERS = gethostcacheindexforkey("players");
83         me.currentServerPlayers = strzone(gethostcachestring(SLIST_FIELD_PLAYERS, i));
84         me.rawPlayerList.setPlayerList(me.rawPlayerList, me.currentServerPlayers);
85
86         SLIST_FIELD_NUMHUMANS = gethostcacheindexforkey("numhumans");
87         numh = ftos(gethostcachenumber(SLIST_FIELD_NUMHUMANS, i));
88         SLIST_FIELD_MAXPLAYERS = gethostcacheindexforkey("maxplayers");
89         maxp = ftos(gethostcachenumber(SLIST_FIELD_MAXPLAYERS, i));
90         me.currentServerNumPlayers = strzone(strcat(numh,"/",maxp));
91         me.numPlayersLabel.setText(me.numPlayersLabel, me.currentServerNumPlayers);
92
93         SLIST_FIELD_NUMBOTS = gethostcacheindexforkey("numbots");
94         s = ftos(gethostcachenumber(SLIST_FIELD_NUMBOTS, i));
95         me.currentServerNumBots = strzone(s);
96         me.numBotsLabel.setText(me.numBotsLabel, me.currentServerNumBots);
97
98         SLIST_FIELD_MOD = gethostcacheindexforkey("mod");
99         me.currentServerMod = strzone(gethostcachestring(SLIST_FIELD_MOD, i));
100         me.modLabel.setText(me.modLabel, me.currentServerMod);
101
102         me.currentServerVersion = strzone(versionstr);
103         me.versionLabel.setText(me.versionLabel, me.currentServerVersion);
104
105         SLIST_FIELD_PING = gethostcacheindexforkey("ping");
106         s = ftos(gethostcachenumber(SLIST_FIELD_PING, i));
107         me.currentServerPing = strzone(s);
108         me.pingLabel.setText(me.pingLabel, me.currentServerPing);
109 }
110
111 void XonoticServerInfoDialog_fill(entity me)
112 {
113         entity e;
114         me.TR(me);
115                 me.TD(me, 1, me.columns, e = makeXonoticTextLabel(0.5, ""));
116                         e.colorL = SKINCOLOR_SERVERINFO_NAME;
117                         e.allowCut = 1;
118                         me.nameLabel = e;
119         me.TR(me);
120                 me.TD(me, 1, me.columns, e = makeXonoticTextLabel(0.5, ""));
121                         e.colorL = SKINCOLOR_SERVERINFO_IP;
122                         e.allowCut = 1;
123                         me.cnameLabel = e;
124
125         me.TR(me);
126                 me.TD(me, 1, 5.5, e = makeXonoticTextLabel(0, "Players:"));
127         me.TR(me);
128                 me.TD(me, me.rows - 4, 6, e = makeXonoticPlayerList());
129                         me.rawPlayerList = e;
130
131         me.gotoRC(me, 1, 6.25); me.setFirstColumn(me, me.currentColumn);
132
133         me.TR(me);
134                 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "Type:"));
135                 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
136                         e.allowCut = 1;
137                         me.typeLabel = e;
138         me.TR(me);
139                 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "Map:"));
140                 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
141                         e.allowCut = 1;
142                         me.mapLabel = e;
143         me.TR(me);
144                 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "Players:"));
145                 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
146                         e.allowCut = 1;
147                         me.numPlayersLabel = e;
148         me.TR(me);
149                 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "Bots:"));
150                 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
151                         e.allowCut = 1;
152                         me.numBotsLabel = e;
153         me.TR(me);
154                 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "Mod:"));
155                 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
156                         e.allowCut = 1;
157                         me.modLabel = e;
158         me.TR(me);
159                 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "Version:"));
160                 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
161                         e.allowCut = 1;
162                         me.versionLabel = e;
163         me.TR(me);
164                 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "Ping:"));
165                 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
166                         e.allowCut = 1;
167                         me.pingLabel = e;
168
169         me.gotoRC(me, me.rows - 1, 0);
170
171                 me.TD(me, 1, me.columns - 6, e = makeXonoticButton("Close", '0 0 0'));
172                         e.onClick = Dialog_Close;
173                         e.onClickEntity = me;
174                 me.TD(me, 1, me.columns - 6, e = makeXonoticButton("Join!", '0 0 0'));
175                         e.onClick = Join_Click;
176                         e.onClickEntity = me;
177 }
178
179 void Join_Click(entity btn, entity me)
180 {
181         localcmd("connect ", me.currentServerCName, "\n");
182 }
183
184 #endif