aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorkilbith <kilbith@users.noreply.github.com>2017-02-03 14:53:43 +0100
committerZeno- <kde.psych@gmail.com>2017-02-03 23:53:43 +1000
commit03b34cb3dd0647b3e378f00cdc7203e580c9dcc8 (patch)
tree20e3a025c31befce23ceea280fa81fe791974aab /builtin
parent3b9ae409c7d7e9445099b86c85392dba4771e08a (diff)
downloadminetest-03b34cb3dd0647b3e378f00cdc7203e580c9dcc8.tar.gz
minetest-03b34cb3dd0647b3e378f00cdc7203e580c9dcc8.tar.bz2
minetest-03b34cb3dd0647b3e378f00cdc7203e580c9dcc8.zip
Serverlist: Add ping indicators (#5164)
Diffstat (limited to 'builtin')
-rw-r--r--builtin/mainmenu/common.lua21
-rw-r--r--builtin/mainmenu/tab_multiplayer.lua1
-rw-r--r--builtin/mainmenu/tab_simple_main.lua1
3 files changed, 22 insertions, 1 deletions
diff --git a/builtin/mainmenu/common.lua b/builtin/mainmenu/common.lua
index 5e3df0864..17d910e8b 100644
--- a/builtin/mainmenu/common.lua
+++ b/builtin/mainmenu/common.lua
@@ -54,7 +54,11 @@ end
function image_column(tooltip, flagname)
return "image,tooltip=" .. core.formspec_escape(tooltip) .. "," ..
"0=" .. core.formspec_escape(defaulttexturedir .. "blank.png") .. "," ..
- "1=" .. core.formspec_escape(defaulttexturedir .. "server_flags_" .. flagname .. ".png")
+ "1=" .. core.formspec_escape(defaulttexturedir .. "server_flags_" .. flagname .. ".png") .. "," ..
+ "2=" .. core.formspec_escape(defaulttexturedir .. "server_ping_4.png") .. "," ..
+ "3=" .. core.formspec_escape(defaulttexturedir .. "server_ping_3.png") .. "," ..
+ "4=" .. core.formspec_escape(defaulttexturedir .. "server_ping_2.png") .. "," ..
+ "5=" .. core.formspec_escape(defaulttexturedir .. "server_ping_1.png")
end
--------------------------------------------------------------------------------
@@ -97,6 +101,21 @@ function render_serverlist_row(spec, is_favorite)
details = "0,"
end
+ if spec.ping then
+ local ping = spec.ping * 1000
+ if ping <= 50 then
+ details = details .. "2,"
+ elseif ping <= 100 then
+ details = details .. "3,"
+ elseif ping <= 250 then
+ details = details .. "4,"
+ else
+ details = details .. "5,"
+ end
+ else
+ details = details .. "0,"
+ end
+
if spec.clients and spec.clients_max then
local clients_color = ''
local clients_percent = 100 * spec.clients / spec.clients_max
diff --git a/builtin/mainmenu/tab_multiplayer.lua b/builtin/mainmenu/tab_multiplayer.lua
index f8edeaddd..033ba38d8 100644
--- a/builtin/mainmenu/tab_multiplayer.lua
+++ b/builtin/mainmenu/tab_multiplayer.lua
@@ -69,6 +69,7 @@ local function get_formspec(tabview, name, tabdata)
--favourites
retval = retval .. "tablecolumns[" ..
image_column(fgettext("Favorite"), "favorite") .. ";" ..
+ image_column(fgettext("Ping"), "") .. ",padding=0.25;" ..
"color,span=3;" ..
"text,align=right;" .. -- clients
"text,align=center,padding=0.25;" .. -- "/"
diff --git a/builtin/mainmenu/tab_simple_main.lua b/builtin/mainmenu/tab_simple_main.lua
index a773a4912..23820aab7 100644
--- a/builtin/mainmenu/tab_simple_main.lua
+++ b/builtin/mainmenu/tab_simple_main.lua
@@ -43,6 +43,7 @@ local function get_formspec(tabview, name, tabdata)
retval = retval .. "tablecolumns[" ..
image_column(fgettext("Favorite"), "favorite") .. ";" ..
+ image_column(fgettext("Ping"), "") .. ",padding=0.25;" ..
"color,span=3;" ..
"text,align=right;" .. -- clients
"text,align=center,padding=0.25;" .. -- "/"