2020-01-14 14:57:45 +01:00
|
|
|
local S = minetest.get_translator("skinsdb")
|
2017-02-09 23:06:25 +01:00
|
|
|
|
|
|
|
unified_inventory.register_page("skins", {
|
2021-03-10 01:12:29 +01:00
|
|
|
get_formspec = function(player, perplayer_formspec)
|
2017-06-15 15:10:59 +02:00
|
|
|
local skin = skins.get_player_skin(player)
|
2021-03-10 01:12:29 +01:00
|
|
|
local boffs = (type(perplayer_formspec) == "table") and 2 or 0.75
|
|
|
|
|
|
|
|
local formspec = perplayer_formspec.standard_inv_bg..
|
|
|
|
skins.get_skin_info_formspec(skin, perplayer_formspec)..
|
|
|
|
"button["..boffs..",3;6.5,.5;skins_page;"..S("Change").."]"
|
2017-02-09 23:06:25 +01:00
|
|
|
return {formspec=formspec}
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
unified_inventory.register_button("skins", {
|
|
|
|
type = "image",
|
|
|
|
image = "skins_button.png",
|
2020-01-16 17:19:49 +01:00
|
|
|
tooltip = S("Skins"),
|
2017-02-09 23:06:25 +01:00
|
|
|
})
|
|
|
|
|
2021-03-10 01:12:29 +01:00
|
|
|
local function get_formspec(player, perplayer_formspec)
|
2018-03-01 21:15:04 +01:00
|
|
|
local context = skins.get_formspec_context(player)
|
2021-03-10 01:12:29 +01:00
|
|
|
local formspec = perplayer_formspec.standard_inv_bg..
|
|
|
|
skins.get_skin_selection_formspec(player, context, perplayer_formspec)
|
2018-02-14 00:28:09 +01:00
|
|
|
return formspec
|
2017-06-15 17:18:51 +02:00
|
|
|
end
|
2017-06-15 15:10:59 +02:00
|
|
|
|
2018-02-14 00:28:09 +01:00
|
|
|
unified_inventory.register_page("skins_page", {
|
2021-03-10 01:12:29 +01:00
|
|
|
get_formspec = function(player, perplayer_formspec)
|
|
|
|
return {formspec=get_formspec(player, perplayer_formspec)}
|
2017-02-09 23:06:25 +01:00
|
|
|
end
|
2018-02-14 00:28:09 +01:00
|
|
|
})
|
2017-06-15 17:18:51 +02:00
|
|
|
|
2017-02-09 23:06:25 +01:00
|
|
|
-- click button handlers
|
|
|
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|
|
|
if fields.skins then
|
|
|
|
unified_inventory.set_inventory_formspec(player, "craft")
|
|
|
|
return
|
|
|
|
end
|
2018-02-14 00:28:09 +01:00
|
|
|
|
2018-02-14 01:39:05 +01:00
|
|
|
if formname ~= "" then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2018-03-01 21:15:04 +01:00
|
|
|
local context = skins.get_formspec_context(player)
|
2018-02-14 00:28:09 +01:00
|
|
|
local action = skins.on_skin_selection_receive_fields(player, context, fields)
|
|
|
|
if action == 'set' then
|
|
|
|
unified_inventory.set_inventory_formspec(player, "skins")
|
|
|
|
elseif action == 'page' then
|
|
|
|
unified_inventory.set_inventory_formspec(player, "skins_page")
|
|
|
|
end
|
2017-02-09 23:06:25 +01:00
|
|
|
end)
|