From 2a84fff8b20522da5182bd89155c917d6e7036a1 Mon Sep 17 00:00:00 2001 From: black Date: Wed, 13 Dec 2006 00:10:48 +0000 Subject: [PATCH] Commit a new item (Nex_HostCache_Ping) that colors serverlist pings depending on the latency. git-svn-id: svn://svn.icculus.org/nexuiz/trunk@2044 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/menu/joingame.menu | 2 +- data/qcsrc/menu/custom/joingame.qc | 36 ++++++++++++++++++++++++++++++ data/qcsrc/menu/custom/joingame.qh | 4 ++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/data/menu/joingame.menu b/data/menu/joingame.menu index ee9551fdc..2e3a15f09 100644 --- a/data/menu/joingame.menu +++ b/data/menu/joingame.menu @@ -151,7 +151,7 @@ Item Window JoinGame size '824 15' action Nex_Action_EntryConnect - DeriveTemplate Nex_HostCache_ValueField Ping + DeriveTemplate Nex_HostCache_Ping Ping { pos '0 0' size [SList_Ping] diff --git a/data/qcsrc/menu/custom/joingame.qc b/data/qcsrc/menu/custom/joingame.qc index 5cec662b9..10f0f4f39 100644 --- a/data/qcsrc/menu/custom/joingame.qc +++ b/data/qcsrc/menu/custom/joingame.qc @@ -111,3 +111,39 @@ void() Item_Nex_HostCache_Players_Spawn = self._update = Item_Nex_HostCache_Players_Update; }; + +////////////////////////////////// +// Item_Nex_HostCache_Ping +/////// + +const vector HOSTCACHE_FAST_PING_COLOR = '1.0 1.0 0.0'; +const vector HOSTCACHE_MEDIUM_PING_COLOR = '0.0 1.0 0.0'; +const vector HOSTCACHE_SLOW_PING_COLOR = '1.0 0.0 0.0'; + +const float HOSTCACHE_FAST_PING = 90; +const float HOSTCACHE_SLOW_PING = 150; + +void() Item_Nex_HostCache_Ping_Update = +{ + local float ping; + + Item_Nex_HostCache_ValueField_Update(); + + // AK 06 yes I know its not fast.. but its shorter.. + ping = stof( self.text ); + if( ping < HOSTCACHE_FAST_PING ) { + self.color = HOSTCACHE_FAST_PING_COLOR; + } else if( ping > HOSTCACHE_SLOW_PING ) { + self.color = HOSTCACHE_SLOW_PING_COLOR; + } else { + self.color = HOSTCACHE_MEDIUM_PING_COLOR; + } +} + +void() Item_Nex_HostCache_Ping_Spawn = +{ + Item_Nex_HostCache_ValueField_Spawn(); + + self._update = Item_Nex_HostCache_Ping_Update; +}; + diff --git a/data/qcsrc/menu/custom/joingame.qh b/data/qcsrc/menu/custom/joingame.qh index ba0f3b9a0..c56e8dc81 100644 --- a/data/qcsrc/menu/custom/joingame.qh +++ b/data/qcsrc/menu/custom/joingame.qh @@ -29,3 +29,7 @@ void() Item_Nex_HostCache_ValueField_Spawn; void() Item_Nex_HostCache_Players_Update; void() Item_Nex_HostCache_Players_Spawn; +// Item_Nex_HostCache_Ping Item_Nex_HostCache_ValueField +void() Item_Nex_HostCache_Ping_Update; +void() Item_Nex_HostCache_Ping_Spawn; + -- 2.39.2