Add screenshots and a README to display them.

This commit is contained in:
Signal 2026-02-15 19:20:34 -05:00
parent ce6cb893bf
commit 48ffa74bfd
12 changed files with 229 additions and 168 deletions

View file

@ -127,6 +127,17 @@ local function refresh_server_list(state)
nil,
function(result)
local list = table.copy(state.favorite_servers)
local num_servers = #result
local i = 0
while i < num_servers do
i = i + 1
-- Drop incompatible servers. You can't join them,
-- so showing them is rather pointless.
if (result[i].proto_max or version.proto_min) < version.proto_min then
table.remove(result, i)
num_servers = num_servers - 1
end
end
table.insert_all(list, result)
state.servers = list
if state.search ~= "" then
@ -280,109 +291,99 @@ return function(state)
imfs.scope("servers")
local height = size.y * 0.8
local i = 0
local idx = state.scroll_pos()
while true do
-- We must use a while loop here because we skip incompatible servers,
-- and we have no way of knowing how many there will be until we iterate.
if i > math.ceil(height / 0.5) then break end
for idx = state.scroll_pos(), state.scroll_pos() + height / 0.5 do
local x = list[idx]
-- End early if we've run out of list.
if not x then break end
-- Skip incompatible servers. You can't join them,
-- so showing them is rather pointless.
if (x.proto_max or version.proto_min) >= version.proto_min then
local ping_lvl = 0
local lag = (x.lag or 0) * 1000 + (x.ping or 0) * 250
if lag <= 125 then
ping_lvl = 4
elseif lag <= 175 then
ping_lvl = 3
elseif lag <= 250 then
ping_lvl = 2
elseif lag <= 400 then
ping_lvl = 1
local ping_lvl = 0
local lag = (x.lag or 0) * 1000 + (x.ping or 0) * 250
if lag <= 125 then
ping_lvl = 4
elseif lag <= 175 then
ping_lvl = 3
elseif lag <= 250 then
ping_lvl = 2
elseif lag <= 400 then
ping_lvl = 1
end
local name = x.name and x.name:trim() or ""
if name == "" then
name = core.colorize(theme.styles.text_color_muted, x.address..":"..x.port)
end
imfs.button(0, i * 0.5, "100%", 0.5)
:style({
border = false,
bgimg = "[fill:1x1:0,0:#fff",
bgimg_middle = 0,
bgcolor = i % 2 == 1 and theme.styles.container.bg_color or theme.styles.container.bg_color_alt,
})
:style("hovered", {
border = false,
bgimg = "[fill:1x1:0,0:#fff",
bgimg_middle = 0,
})
:style("pressed", {
border = false,
bgimg = "[fill:1x1:0,0:#fff",
bgimg_middle = 0,
})
:onclick(function()
state.detail(x)
end)
imfs.row(0.1, i * 0.5, "100% - 0.65", 0.5)
if x.favorite then
imfs.image(0, 0, 0.5, 0.5, theme.icon("menu_servers_favorite"))
:tooltip("Favorite server", enable_tooltips)
end
local name = x.name and x.name:trim() or ""
if name == "" then
name = core.colorize("#888", x.address..":"..x.port)
end
-- We use an arealabel to ensure that the name will be clipped
-- if it is inordinately long, rather than overflowing onto
-- other thigs.
imfs.arealabel(0, 0.125, "1x", 0.375, name)
imfs.button(0, i * 0.5, "100%", 0.5)
:style({
border = false,
bgimg = "[fill:1x1:0,0:#fff",
bgimg_middle = 0,
bgcolor = i % 2 == 1 and theme.styles.container.bg_color or theme.styles.container.bg_color_alt,
})
:style("hovered", {
border = false,
bgimg = "[fill:1x1:0,0:#fff",
bgimg_middle = 0,
})
:style("pressed", {
border = false,
bgimg = "[fill:1x1:0,0:#fff",
bgimg_middle = 0,
})
:onclick(function()
state.detail(x)
end)
imfs.row(0.1, i * 0.5, "100% - 0.65", 0.5)
if x.favorite then
imfs.image(0, 0, 0.5, 0.5, theme.icon("menu_servers_favorite"))
:tooltip("Favorite server", enable_tooltips)
end
if x.pvp == false then
imfs.image(0, 0, 0.5, 0.5, theme.icon("menu_servers_peaceful"))
:tooltip("Peaceful", enable_tooltips)
end
local name = x.name and x.name:trim() or ""
if name == "" then
name = core.colorize("#888", x.address..":"..x.port)
end
-- We use an arealabel to ensure that the name will be clipped
-- if it is inordinately long, rather than overflowing onto
-- other thigs.
imfs.arealabel(0, 0.125, "1x", 0.375, name)
if x.pvp == false then
imfs.image(0, 0, 0.5, 0.5, theme.icon("menu_servers_peaceful"))
:tooltip("Peaceful", enable_tooltips)
end
if x.creative then
imfs.image(0, 0, 0.5, 0.5, theme.icon("menu_servers_creative"))
:tooltip("Creative", enable_tooltips)
end
if x.clients then
local clients = x.clients..(
x.clients_max and "/"..x.clients_max or ""
)
local color = "#aaa"
if x.clients > 0 and x.clients_max then
local percent = x.clients /x.clients_max
if percent < 0.75 then
color = "#638b67"
elseif percent < 1 then
color = "#a69174"
else
color = "#9d5b5b"
end
if x.creative then
imfs.image(0, 0, 0.5, 0.5, theme.icon("menu_servers_creative"))
:tooltip("Creative", enable_tooltips)
end
if x.clients then
local clients = x.clients..(
x.clients_max and "/"..x.clients_max or ""
)
local color = "#aaa"
if x.clients > 0 and x.clients_max then
local percent = x.clients /x.clients_max
if percent < 0.75 then
color = "#638b67"
elseif percent < 1 then
color = "#a69174"
else
color = "#9d5b5b"
end
imfs.hypertext(0, 0, 1, 0.5, "<global valign=middle halign=center color="..color..">"..core.hypertext_escape(clients))
end
if x.ping or x.lag then
imfs.image(0, 0, 0.5, 0.5, theme.icon("menu_servers_icon_ping_"..ping_lvl))
:tooltip("Ping: "..math.floor(lag), enable_tooltips)
end
imfs.hypertext(0, 0, 1, 0.5, "<global valign=middle halign=center color="..color..">"..core.hypertext_escape(clients))
end
imfs.row_end()
i = i + 1
end
idx = idx + 1
if x.ping or x.lag then
imfs.image(0, 0, 0.5, 0.5, theme.icon("menu_servers_icon_ping_"..ping_lvl))
:tooltip("Ping: "..math.floor(lag), enable_tooltips)
end
imfs.row_end()
i = i + 1
end
imfs.scope_end()
@ -467,7 +468,7 @@ return function(state)
end
if joining == true then
imfs.hypertext(0, 0, "100%", 0.75, "<global valign=middle halign=center color=#aaa>Connecting to server...")
imfs.hypertext(0, 0, "100%", 0.75, "<global valign=middle halign=center color=#aaa>Joining server...")
imfs.group(0, 0, "100%", 1.05)
imfs.image(0, 0.3, "100%", "100% - 0.3", theme.get_background_image("field"))
imfs.label(0.2, 0.125, "Address")
@ -489,7 +490,7 @@ return function(state)
end)
imfs.group_end()
else
imfs.hypertext(0, 0, "100%", 0.75, "<global valign=middle halign=center color=#aaa>Connecting to <b>"..core.hypertext_escape(joining.name or joining.address..":"..joining.port).."</b>...")
imfs.hypertext(0, 0, "100%", 0.75, "<global valign=middle halign=center color=#aaa>Joining <b>"..core.hypertext_escape(joining.name or joining.address..":"..joining.port).."</b>...")
end
theme.field(0, 0, "100%", 0.75, "Username", state.username)