Test skinsdb tab

This commit is contained in:
Daretmavi 2021-07-06 11:50:32 +02:00
parent f98abbaddf
commit 7b7ee41346
2 changed files with 55 additions and 0 deletions

51
i3_mods_tabs.lua Normal file
View File

@ -0,0 +1,51 @@
local modpath = core.get_modpath "i3"
local maxn, sort, concat, copy, insert, remove, indexof =
table.maxn, table.sort, table.concat, table.copy,
table.insert, table.remove, table.indexof
local sprintf, find, gmatch, match, sub, split, upper, lower =
string.format, string.find, string.gmatch, string.match,
string.sub, string.split, string.upper, string.lower
local PNG, styles, fs_elements = loadfile(modpath .. "/etc/styles.lua")()
local ESC = core.formspec_escape
local S = core.get_translator "i3"
local ES = function(...)
return ESC(S(...))
end
local function fmt(elem, ...)
if not fs_elements[elem] then
return sprintf(elem, ...)
end
return sprintf(fs_elements[elem], ...)
end
i3.new_tab {
name = "Skins",
description = "Skins",
image = "i3_skin.png",
formspec = function(player, data, fs)
--fs("label[3,1;Test 1]")
local name = player:get_player_name()
local _skins = skins.get_skinlist_for_player(name)
local sks = {}
local yextra = 1
for _, skin in ipairs(_skins) do
sks[#sks + 1] = skin.name
end
sks = concat(sks, ","):gsub(";", "")
fs("label", 1, yextra + 0.85, fmt("%s:", ES"Select a skin"))
fs(fmt("dropdown[1,%f;4,0.6;skins;%s;%u;true]", yextra + 1.1, sks, data.skin_id or 1))
--core.log("skin: ", dump(skins.get_player_skin(player).name))
end,
}

View File

@ -3428,3 +3428,7 @@ end
--dofile(modpath .. "/tests/test_tabs.lua")
--dofile(modpath .. "/tests/test_custom_recipes.lua")
if __skinsdb then
dofile(modpath .. "/i3_mods_tabs.lua")
end