mirror of
https://github.com/minetest-mods/skinsdb.git
synced 2024-12-23 07:50:18 +01:00
changes needed for character_creator support
This commit is contained in:
parent
920061c0f1
commit
57b815f91f
9
api.lua
9
api.lua
@ -26,12 +26,5 @@ end
|
|||||||
-- update visuals
|
-- update visuals
|
||||||
skins.update_player_skin = function(player)
|
skins.update_player_skin = function(player)
|
||||||
local skin = skins.get_player_skin(player)
|
local skin = skins.get_player_skin(player)
|
||||||
player:set_properties({
|
skin:set_skin(player)
|
||||||
textures = {skin:get_texture()},
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Update skin on join
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
|
||||||
skins.update_player_skin(player)
|
|
||||||
end)
|
|
||||||
|
7
init.lua
7
init.lua
@ -26,10 +26,15 @@ end
|
|||||||
if minetest.global_exists("armor") then
|
if minetest.global_exists("armor") then
|
||||||
armor.get_player_skin = function(self, name)
|
armor.get_player_skin = function(self, name)
|
||||||
local skin = skins.get_player_skin(minetest.get_player_by_name(name))
|
local skin = skins.get_player_skin(minetest.get_player_by_name(name))
|
||||||
return skin:get_meta("_key") --3d_armor adds a ".png" but it should be compatible in most cases
|
return skin:get_texture()
|
||||||
end
|
end
|
||||||
armor.get_preview = function(self, name)
|
armor.get_preview = function(self, name)
|
||||||
local skin = skins.get_player_skin(minetest.get_player_by_name(name))
|
local skin = skins.get_player_skin(minetest.get_player_by_name(name))
|
||||||
return skin:get_preview()
|
return skin:get_preview()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Update skin on join
|
||||||
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
skins.update_player_skin(player)
|
||||||
|
end)
|
||||||
|
@ -9,15 +9,16 @@ end
|
|||||||
local function get_formspec(player, context)
|
local function get_formspec(player, context)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local skin = skins.get_player_skin(player)
|
local skin = skins.get_player_skin(player)
|
||||||
|
local texture = skin:get_texture()
|
||||||
-- overview page
|
|
||||||
local formspec = "image[0,.75;1,2;"..skin:get_preview().."]"
|
|
||||||
.."label[6,.5;"..S("Raw texture")..":]"
|
|
||||||
.."image[6,1;2,1;"..skin:get_texture().."]"
|
|
||||||
|
|
||||||
local m_name = skin:get_meta_string("name")
|
local m_name = skin:get_meta_string("name")
|
||||||
local m_author = skin:get_meta_string("author")
|
local m_author = skin:get_meta_string("author")
|
||||||
local m_license = skin:get_meta_string("license")
|
local m_license = skin:get_meta_string("license")
|
||||||
|
-- overview page
|
||||||
|
local formspec = "image[0,.75;1,2;"..skin:get_preview().."]"
|
||||||
|
if texture then
|
||||||
|
formspec = formspec.."label[6,.5;"..S("Raw texture")..":]"
|
||||||
|
.."image[6,1;2,1;"..skin:get_texture().."]"
|
||||||
|
end
|
||||||
if m_name ~= "" then
|
if m_name ~= "" then
|
||||||
formspec = formspec.."label[2,.5;"..S("Name")..": "..minetest.formspec_escape(m_name).."]"
|
formspec = formspec.."label[2,.5;"..S("Name")..": "..minetest.formspec_escape(m_name).."]"
|
||||||
end
|
end
|
||||||
@ -62,10 +63,10 @@ local function get_formspec(player, context)
|
|||||||
page_next = 1
|
page_next = 1
|
||||||
end
|
end
|
||||||
local page_list = ""
|
local page_list = ""
|
||||||
dropdown_values = {}
|
context.dropdown_values = {}
|
||||||
for pg=1, context.total_pages do
|
for pg=1, context.total_pages do
|
||||||
local pagename = S("Page").." "..pg.."/"..context.total_pages
|
local pagename = S("Page").." "..pg.."/"..context.total_pages
|
||||||
dropdown_values[pagename] = pg
|
context.dropdown_values[pagename] = pg
|
||||||
if pg > 1 then page_list = page_list.."," end
|
if pg > 1 then page_list = page_list.."," end
|
||||||
page_list = page_list..pagename
|
page_list = page_list..pagename
|
||||||
end
|
end
|
||||||
@ -106,7 +107,7 @@ sfinv.register_page("skins:overview", {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if fields.skins_selpg then
|
if fields.skins_selpg then
|
||||||
context.skins_page = tonumber(dropdown_values[fields.skins_selpg])
|
context.skins_page = tonumber(context.dropdown_values[fields.skins_selpg])
|
||||||
sfinv.set_player_inventory_formspec(player)
|
sfinv.set_player_inventory_formspec(player)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -54,3 +54,15 @@ end
|
|||||||
function skin_class:get_preview()
|
function skin_class:get_preview()
|
||||||
return self._preview or "player.png"
|
return self._preview or "player.png"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function skin_class:set_skin(player)
|
||||||
|
player:set_properties({
|
||||||
|
visual_size = {
|
||||||
|
x = 1,
|
||||||
|
y = 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
player:set_properties({
|
||||||
|
textures = {self:get_texture()},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
27
skinlist.lua
27
skinlist.lua
@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
local skins_dir_list = minetest.get_dir_list(skins.modpath.."/textures")
|
local skins_dir_list = minetest.get_dir_list(skins.modpath.."/textures")
|
||||||
local unsorted_skinslist = {}
|
|
||||||
local sorted_skinslist
|
|
||||||
for _, fn in pairs(skins_dir_list) do
|
for _, fn in pairs(skins_dir_list) do
|
||||||
local nameparts = string.gsub(fn, "[.]", "_"):split("_")
|
local nameparts = string.gsub(fn, "[.]", "_"):split("_")
|
||||||
|
|
||||||
@ -43,28 +42,20 @@ for _, fn in pairs(skins_dir_list) do
|
|||||||
else
|
else
|
||||||
skin_obj:set_meta("name", name)
|
skin_obj:set_meta("name", name)
|
||||||
end
|
end
|
||||||
table.insert(unsorted_skinslist, skin_obj)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- get skinlist. If assignment given ("mod:wardrobe" or "player:bell07") select skins matches the assignment. select_unassigned selects the skins without any assignment too
|
-- get skinlist. If assignment given ("mod:wardrobe" or "player:bell07") select skins matches the assignment. select_unassigned selects the skins without any assignment too
|
||||||
function skins.get_skinlist(assignment, select_unassigned)
|
function skins.get_skinlist(assignment, select_unassigned)
|
||||||
-- sort on demand
|
local skinslist = {}
|
||||||
if not sorted_skinslist then
|
for _, skin in pairs(skins.meta) do
|
||||||
table.sort(unsorted_skinslist, function(a,b) return a:get_meta("_sort_id") < b:get_meta("_sort_id") end)
|
if not assignment or
|
||||||
sorted_skinslist = unsorted_skinslist
|
assignment == skin:get_meta("assignment") or
|
||||||
end
|
(select_unassigned and skin:get_meta("assignment") == nil) then
|
||||||
if not assignment then
|
table.insert(skinslist, skin)
|
||||||
return sorted_skinslist
|
|
||||||
else
|
|
||||||
local ret = {}
|
|
||||||
for _, skin in ipairs(sorted_skinslist) do
|
|
||||||
if assignment == skin:get_meta("assignment") or
|
|
||||||
(select_unassigned and skin:get_meta("assignment") == nil) then
|
|
||||||
table.insert(ret, skin)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return ret
|
|
||||||
end
|
end
|
||||||
|
table.sort(skinslist, function(a,b) return a:get_meta("_sort_id") < b:get_meta("_sort_id") end)
|
||||||
|
return skinslist
|
||||||
end
|
end
|
||||||
|
@ -12,15 +12,15 @@ unified_inventory.register_page("skins", {
|
|||||||
get_formspec = function(player)
|
get_formspec = function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local skin = skins.get_player_skin(player)
|
local skin = skins.get_player_skin(player)
|
||||||
local formspec = ("background[0.06,0.99;7.92,7.52;ui_misc_form.png]"
|
local texture = skin:get_texture()
|
||||||
.."image[0,.75;1,2;"..skin:get_preview().."]"
|
|
||||||
.."label[6,.5;"..S("Raw texture")..":]"
|
|
||||||
.."image[6,1;2,1;"..skin:get_texture().."]")
|
|
||||||
|
|
||||||
|
|
||||||
local m_name = skin:get_meta_string("name")
|
local m_name = skin:get_meta_string("name")
|
||||||
local m_author = skin:get_meta_string("author")
|
local m_author = skin:get_meta_string("author")
|
||||||
local m_license = skin:get_meta_string("license")
|
local m_license = skin:get_meta_string("license")
|
||||||
|
local formspec = "background[0.06,0.99;7.92,7.52;ui_misc_form.png]".."image[0,.75;1,2;"..skin:get_preview().."]"
|
||||||
|
if texture then
|
||||||
|
formspec=formspec.."label[6,.5;"..S("Raw texture")..":]"
|
||||||
|
.."image[6,1;2,1;"..texture.."]"
|
||||||
|
end
|
||||||
if m_name ~= "" then
|
if m_name ~= "" then
|
||||||
formspec = formspec.."label[2,.5;"..S("Name")..": "..minetest.formspec_escape(m_name).."]"
|
formspec = formspec.."label[2,.5;"..S("Name")..": "..minetest.formspec_escape(m_name).."]"
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user