]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/menu/custom/joingame.qc
I did not want to do that. Sorry, disk space. Some admin better get rid of that mess.
[divverent/nexuiz.git] / data / qcsrc / menu / custom / joingame.qc
1 // Property of Alientrap/AK
2 // custom/joingame/joingame.qc
3
4 ////////////////////////////////////
5 // Item_Nex_HostCache_Entry
6 //////
7
8 void() Item_Nex_HostCache_Entry_Update =
9 {
10         if( HostCache_ViewCount <= self.stepValue ) {
11                 self.flag = self.flag | FLAG_HIDDEN;
12                 return;
13         } else if( self.flag & FLAG_HIDDEN )
14                 self.flag = self.flag - FLAG_HIDDEN;
15
16         if( Menu_HasRunFlag( self, RUNFLAG_CLIPPED ) )
17                 return;
18
19         Item_Button_Update();
20 };
21
22 void() Item_Nex_HostCache_Entry_Draw =
23 {
24         Item_Window_Draw();
25         Item_Button_Draw();
26 };
27
28 void() Item_Nex_HostCache_Entry_Spawn =
29 {
30         Item_Window_Spawn();
31         Item_Button_Spawn();
32
33         self.flag = self.flag | FLAG_HIDDEN; // we dont want to get this bloody hostcachestring warning
34         if( self.flag & FLAG_NOSELECT )
35                 self.flag = self.flag - FLAG_NOSELECT;
36         self._draw = Item_Nex_HostCache_Entry_Draw;
37         self._update = Item_Nex_HostCache_Entry_Update;
38 };
39
40 ////////////////////////////////////
41 // Item_Nex_HostCache_StringField
42 ////////
43
44 void() Item_Nex_HostCache_StringField_Update =
45 {
46         local float lMaxLen;
47         local string lString;
48
49         if( HostCache_ViewCount <= self._parent.stepValue )
50                 return;
51         lMaxLen = floor( self.size_x / self.fontSize_x );
52         lString = gethostcachestring( self._realValue, self._parent.stepValue );
53         if( lMaxLen < strlen( lString ) ) {
54                 lString = strcat( substring( lString, 0, lMaxLen - 3 ), "..." );
55         }
56         String_EntitySet( self, text, lString );
57
58         Item_Label_Update();
59 };
60
61 void() Item_Nex_HostCache_StringField_Spawn =
62 {
63         Item_Label_Spawn();
64
65         self._realValue = gethostcacheindexforkey( self.target );
66         self._update = Item_Nex_HostCache_StringField_Update;
67 };
68
69 ////////////////////////////////////
70 // Item_Nex_HostCache_ValueField
71 ////////
72
73 void() Item_Nex_HostCache_ValueField_Update =
74 {
75         if( HostCache_ViewCount <= self._parent.stepValue )
76                 return;
77         String_EntitySet( self, text, ftos( gethostcachenumber( self._realValue, self._parent.stepValue ) ) );
78
79         Item_Label_Update();
80 };
81
82 void() Item_Nex_HostCache_ValueField_Spawn =
83 {
84         Item_Label_Spawn();
85
86         self._realValue = gethostcacheindexforkey( self.target );
87         self._update = Item_Nex_HostCache_ValueField_Update;
88 };
89
90 //////////////////////////////////
91 // Item_Nex_HostCache_Players
92 ///////
93
94 void() Item_Nex_HostCache_Players_Update =
95 {
96         local string lHum, lNum, lMax;
97         local float lHumans, lBots;
98
99         if( HostCache_ViewCount <= self._parent.stepValue )
100                 return;
101         lHumans = gethostcachenumber( SLIST_FIELD_NUMHUMANS, self._parent.stepValue );
102         lBots = gethostcachenumber( SLIST_FIELD_NUMBOTS, self._parent.stepValue );
103         if (lBots >= 0) lHum = ftos( lHumans ); else lHum = "?";
104         lNum = ftos( gethostcachenumber( SLIST_FIELD_NUMPLAYERS, self._parent.stepValue ) );
105         lMax = ftos( gethostcachenumber( SLIST_FIELD_MAXPLAYERS, self._parent.stepValue ) );
106
107         String_EntitySet( self, text, strcat( lHum, "/", lNum, "/", lMax ) );
108
109         Item_Label_Update();
110 };
111
112 void() Item_Nex_HostCache_Players_Spawn =
113 {
114         Item_Label_Spawn();
115
116         self._update = Item_Nex_HostCache_Players_Update;
117 };
118
119 //////////////////////////////////
120 // Item_Nex_HostCache_Ping
121 ///////
122
123 const vector HOSTCACHE_FAST_PING_COLOR = '0.0 1.0 0.0';
124 const vector HOSTCACHE_MEDIUM_PING_COLOR = '1.0 1.0 0.0';
125 const vector HOSTCACHE_SLOW_PING_COLOR = '1.0 0.0 0.0';
126
127 const float HOSTCACHE_FAST_PING = 90;
128 const float HOSTCACHE_SLOW_PING = 150;
129
130 void() Item_Nex_HostCache_Ping_Update =
131 {
132         local float ping;
133
134         Item_Nex_HostCache_ValueField_Update();
135
136         // AK 06 yes I know its not fast.. but its shorter..
137         ping = stof( self.text );
138         if( ping < HOSTCACHE_FAST_PING ) {
139                 self.color = HOSTCACHE_FAST_PING_COLOR;
140         } else if( ping > HOSTCACHE_SLOW_PING ) {
141                 self.color = HOSTCACHE_SLOW_PING_COLOR;
142         } else {
143                 self.color = HOSTCACHE_MEDIUM_PING_COLOR;
144         }
145 }
146
147 void() Item_Nex_HostCache_Ping_Spawn =
148 {
149         Item_Nex_HostCache_ValueField_Spawn();
150
151         self._update = Item_Nex_HostCache_Ping_Update;
152 };
153