mirror of
https://github.com/moparisthebest/minetest
synced 2024-12-21 23:28:48 -05:00
Serverlist: Add ping indicators (#5164)
This commit is contained in:
parent
3b9ae409c7
commit
03b34cb3dd
@ -54,7 +54,11 @@ end
|
|||||||
function image_column(tooltip, flagname)
|
function image_column(tooltip, flagname)
|
||||||
return "image,tooltip=" .. core.formspec_escape(tooltip) .. "," ..
|
return "image,tooltip=" .. core.formspec_escape(tooltip) .. "," ..
|
||||||
"0=" .. core.formspec_escape(defaulttexturedir .. "blank.png") .. "," ..
|
"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
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
@ -97,6 +101,21 @@ function render_serverlist_row(spec, is_favorite)
|
|||||||
details = "0,"
|
details = "0,"
|
||||||
end
|
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
|
if spec.clients and spec.clients_max then
|
||||||
local clients_color = ''
|
local clients_color = ''
|
||||||
local clients_percent = 100 * spec.clients / spec.clients_max
|
local clients_percent = 100 * spec.clients / spec.clients_max
|
||||||
|
@ -69,6 +69,7 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
--favourites
|
--favourites
|
||||||
retval = retval .. "tablecolumns[" ..
|
retval = retval .. "tablecolumns[" ..
|
||||||
image_column(fgettext("Favorite"), "favorite") .. ";" ..
|
image_column(fgettext("Favorite"), "favorite") .. ";" ..
|
||||||
|
image_column(fgettext("Ping"), "") .. ",padding=0.25;" ..
|
||||||
"color,span=3;" ..
|
"color,span=3;" ..
|
||||||
"text,align=right;" .. -- clients
|
"text,align=right;" .. -- clients
|
||||||
"text,align=center,padding=0.25;" .. -- "/"
|
"text,align=center,padding=0.25;" .. -- "/"
|
||||||
|
@ -43,6 +43,7 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
|
|
||||||
retval = retval .. "tablecolumns[" ..
|
retval = retval .. "tablecolumns[" ..
|
||||||
image_column(fgettext("Favorite"), "favorite") .. ";" ..
|
image_column(fgettext("Favorite"), "favorite") .. ";" ..
|
||||||
|
image_column(fgettext("Ping"), "") .. ",padding=0.25;" ..
|
||||||
"color,span=3;" ..
|
"color,span=3;" ..
|
||||||
"text,align=right;" .. -- clients
|
"text,align=right;" .. -- clients
|
||||||
"text,align=center,padding=0.25;" .. -- "/"
|
"text,align=center,padding=0.25;" .. -- "/"
|
||||||
|
@ -577,6 +577,13 @@ int ModApiMainMenu::l_get_favorites(lua_State *L)
|
|||||||
lua_settable(L, top_lvl2);
|
lua_settable(L, top_lvl2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (servers[i].isMember("ping")) {
|
||||||
|
float ping = servers[i]["ping"].asFloat();
|
||||||
|
lua_pushstring(L, "ping");
|
||||||
|
lua_pushnumber(L, ping);
|
||||||
|
lua_settable(L, top_lvl2);
|
||||||
|
}
|
||||||
|
|
||||||
lua_settable(L, top);
|
lua_settable(L, top);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
BIN
textures/base/pack/server_ping_1.png
Normal file
BIN
textures/base/pack/server_ping_1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 251 B |
BIN
textures/base/pack/server_ping_2.png
Normal file
BIN
textures/base/pack/server_ping_2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 244 B |
BIN
textures/base/pack/server_ping_3.png
Normal file
BIN
textures/base/pack/server_ping_3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 245 B |
BIN
textures/base/pack/server_ping_4.png
Normal file
BIN
textures/base/pack/server_ping_4.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 213 B |
Loading…
Reference in New Issue
Block a user