1 // Property of Alientrap/AK
2 // custom/joingame/joingame.qc
4 ////////////////////////////////////
5 // Item_Nex_HostCache_Entry
8 void() Item_Nex_HostCache_Entry_Update =
10 if( HostCache_ViewCount <= self.stepValue ) {
11 self.flag = self.flag | FLAG_HIDDEN;
13 } else if( self.flag & FLAG_HIDDEN )
14 self.flag = self.flag - FLAG_HIDDEN;
16 if( Menu_HasRunFlag( self, RUNFLAG_CLIPPED ) )
22 void() Item_Nex_HostCache_Entry_Draw =
28 void() Item_Nex_HostCache_Entry_Spawn =
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;
40 ////////////////////////////////////
41 // Item_Nex_HostCache_StringField
44 void() Item_Nex_HostCache_StringField_Update =
49 if( HostCache_ViewCount <= self._parent.stepValue )
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 ), "..." );
56 String_EntitySet( self, text, lString );
61 void() Item_Nex_HostCache_StringField_Spawn =
65 self._realValue = gethostcacheindexforkey( self.target );
66 self._update = Item_Nex_HostCache_StringField_Update;
69 ////////////////////////////////////
70 // Item_Nex_HostCache_ValueField
73 void() Item_Nex_HostCache_ValueField_Update =
75 if( HostCache_ViewCount <= self._parent.stepValue )
77 String_EntitySet( self, text, ftos( gethostcachenumber( self._realValue, self._parent.stepValue ) ) );
82 void() Item_Nex_HostCache_ValueField_Spawn =
86 self._realValue = gethostcacheindexforkey( self.target );
87 self._update = Item_Nex_HostCache_ValueField_Update;
90 //////////////////////////////////
91 // Item_Nex_HostCache_Players
94 void() Item_Nex_HostCache_Players_Update =
96 local string lHum, lNum, lMax;
99 if( HostCache_ViewCount <= self._parent.stepValue )
101 lHumans = gethostcachenumber( SLIST_FIELD_NUMHUMANS, self._parent.stepValue );
102 if (lHumans >= 0) lHum = ftos( lHumans ); else lHum = "?";
103 lNum = ftos( gethostcachenumber( SLIST_FIELD_NUMPLAYERS, self._parent.stepValue ) );
104 lMax = ftos( gethostcachenumber( SLIST_FIELD_MAXPLAYERS, self._parent.stepValue ) );
106 String_EntitySet( self, text, strcat( lHum, "/", lNum, "/", lMax ) );
111 void() Item_Nex_HostCache_Players_Spawn =
115 self._update = Item_Nex_HostCache_Players_Update;
118 //////////////////////////////////
119 // Item_Nex_HostCache_Ping
122 const vector HOSTCACHE_FAST_PING_COLOR = '0.0 1.0 0.0';
123 const vector HOSTCACHE_MEDIUM_PING_COLOR = '1.0 1.0 0.0';
124 const vector HOSTCACHE_SLOW_PING_COLOR = '1.0 0.0 0.0';
126 const float HOSTCACHE_FAST_PING = 90;
127 const float HOSTCACHE_SLOW_PING = 150;
129 void() Item_Nex_HostCache_Ping_Update =
133 Item_Nex_HostCache_ValueField_Update();
135 // AK 06 yes I know its not fast.. but its shorter..
136 ping = stof( self.text );
137 if( ping < HOSTCACHE_FAST_PING ) {
138 self.color = HOSTCACHE_FAST_PING_COLOR;
139 } else if( ping > HOSTCACHE_SLOW_PING ) {
140 self.color = HOSTCACHE_SLOW_PING_COLOR;
142 self.color = HOSTCACHE_MEDIUM_PING_COLOR;
146 void() Item_Nex_HostCache_Ping_Spawn =
148 Item_Nex_HostCache_ValueField_Spawn();
150 self._update = Item_Nex_HostCache_Ping_Update;