master #1
|
@ -227,5 +227,27 @@ minetest.register_tool("mcl_armor:elytra", {
|
||||||
on_place = mcl_armor.equip_on_use,
|
on_place = mcl_armor.equip_on_use,
|
||||||
on_secondary_use = mcl_armor.equip_on_use,
|
on_secondary_use = mcl_armor.equip_on_use,
|
||||||
_mcl_armor_element = "torso",
|
_mcl_armor_element = "torso",
|
||||||
_mcl_armor_texture = "mcl_armor_elytra.png"
|
_mcl_armor_texture = function(obj, itemstack)
|
||||||
|
if obj:is_player() then
|
||||||
|
local cape = mcl_skins.player_skins[obj].cape
|
||||||
|
if cape ~= "blank.png" then
|
||||||
|
return cape:gsub("_body", "_elytra")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return "mcl_armor_elytra.png"
|
||||||
|
end,
|
||||||
|
_on_equip = function(obj, itemstack)
|
||||||
|
if not obj:is_player() then return end
|
||||||
|
local cape = mcl_skins.player_skins[obj].cape
|
||||||
|
if cape ~= "blank.png" then
|
||||||
|
local skinval = mcl_player.player_get_skin(obj)
|
||||||
|
skinval = skinval:gsub("%^" .. cape, "")
|
||||||
|
mcl_player.player_set_skin(obj, skinval)
|
||||||
|
-- this doesn't mess with the data mcl_skins has, so when mcl_skins reloads (which happens when the elytra is unequipped), the normal cape returns
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
_on_unequip = function(obj, itemstack)
|
||||||
|
if not obj:is_player() then return end
|
||||||
|
mcl_skins.update_player_skin(obj)
|
||||||
|
end
|
||||||
})
|
})
|
||||||
|
|
|
@ -129,6 +129,11 @@ function mcl_player.player_set_skin(player, texture)
|
||||||
update_player_textures(player)
|
update_player_textures(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mcl_player.player_get_skin(player)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
return player_textures[name][1]
|
||||||
|
end
|
||||||
|
|
||||||
function mcl_player.player_set_armor(player, texture)
|
function mcl_player.player_set_armor(player, texture)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
player_textures[name][2] = texture
|
player_textures[name][2] = texture
|
||||||
|
|
|
@ -5,8 +5,8 @@ local EDIT_SKIN_KEY = -1 -- The key used for edit skin in the mcl_skins.simple_s
|
||||||
mcl_skins = {
|
mcl_skins = {
|
||||||
simple_skins = {},
|
simple_skins = {},
|
||||||
texture_to_simple_skin = {},
|
texture_to_simple_skin = {},
|
||||||
item_names = {"base", "footwear", "eye", "mouth", "bottom", "top", "hair", "headwear"},
|
item_names = {"base", "footwear", "eye", "mouth", "bottom", "top", "hair", "headwear", "cape"},
|
||||||
tab_names = {"skin", "template", "base", "headwear", "hair", "eye", "mouth", "top", "arm", "bottom", "footwear"},
|
tab_names = {"skin", "template", "base", "headwear", "hair", "eye", "mouth", "top", "arm", "bottom", "footwear", "cape"},
|
||||||
tab_descriptions = {
|
tab_descriptions = {
|
||||||
template = S("Templates"),
|
template = S("Templates"),
|
||||||
arm = S("Arm size"),
|
arm = S("Arm size"),
|
||||||
|
@ -19,11 +19,13 @@ mcl_skins = {
|
||||||
hair = S("Hairs"),
|
hair = S("Hairs"),
|
||||||
headwear = S("Headwears"),
|
headwear = S("Headwears"),
|
||||||
skin = S("Skins"),
|
skin = S("Skins"),
|
||||||
|
cape = S("Capes")
|
||||||
},
|
},
|
||||||
|
cape = {},
|
||||||
template1 = {}, -- Stores edit skin values for template1
|
template1 = {}, -- Stores edit skin values for template1
|
||||||
template2 = {}, -- Stores edit skin values for template2
|
template2 = {}, -- Stores edit skin values for template2
|
||||||
base = {}, -- List of base textures
|
base = {}, -- List of base textures
|
||||||
|
|
||||||
-- Base color is separate to keep the number of junk nodes registered in check
|
-- Base color is separate to keep the number of junk nodes registered in check
|
||||||
base_color = {0xffeeb592, 0xffb47a57, 0xff8d471d},
|
base_color = {0xffeeb592, 0xffb47a57, 0xff8d471d},
|
||||||
color = {
|
color = {
|
||||||
|
@ -59,15 +61,29 @@ mcl_skins = {
|
||||||
|
|
||||||
function mcl_skins.register_item(item)
|
function mcl_skins.register_item(item)
|
||||||
assert(mcl_skins[item.type], "Skin item type " .. item.type .. " does not exist.")
|
assert(mcl_skins[item.type], "Skin item type " .. item.type .. " does not exist.")
|
||||||
|
|
||||||
|
if item.type == "cape" then
|
||||||
|
local func = item.selector_func
|
||||||
|
|
||||||
|
if type(func) == "string" then
|
||||||
|
func = loadstring(func)()
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(mcl_skins.cape, {name=item.name, selector_func=func, mask=item.mask})
|
||||||
|
mcl_skins.masks[item.name] = item.mask
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local texture = item.texture or "blank.png"
|
local texture = item.texture or "blank.png"
|
||||||
|
|
||||||
if item.template1 then
|
if item.template1 then
|
||||||
mcl_skins.template1[item.type] = texture
|
mcl_skins.template1[item.type] = texture
|
||||||
end
|
end
|
||||||
|
|
||||||
if item.template2 then
|
if item.template2 then
|
||||||
mcl_skins.template2[item.type] = texture
|
mcl_skins.template2[item.type] = texture
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(mcl_skins[item.type], texture)
|
table.insert(mcl_skins[item.type], texture)
|
||||||
mcl_skins.masks[texture] = item.mask
|
mcl_skins.masks[texture] = item.mask
|
||||||
mcl_skins.preview_rotations[texture] = item.preview_rotation
|
mcl_skins.preview_rotations[texture] = item.preview_rotation
|
||||||
|
@ -143,11 +159,19 @@ function mcl_skins.update_player_skin(player)
|
||||||
if not player then
|
if not player then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local skin = mcl_skins.player_skins[player]
|
|
||||||
|
|
||||||
mcl_player.player_set_skin(player, mcl_skins.compile_skin(skin))
|
local skin = mcl_skins.player_skins[player]
|
||||||
|
local skinval = mcl_skins.compile_skin(skin)
|
||||||
|
|
||||||
|
if player:get_inventory():get_stack("armor", 3):get_name() == "mcl_armor:elytra" then
|
||||||
|
skinval = skinval:gsub("%^" .. skin.cape, "")
|
||||||
|
-- don't render the "normal" cape on players while wearing the elytra.
|
||||||
|
-- this is NOT used when the player puts an elytra on, see register.lua in mcl_armor for that.
|
||||||
|
-- this is used when a player joins or changes something regarding their skin.
|
||||||
|
end
|
||||||
|
|
||||||
|
mcl_player.player_set_skin(player, skinval)
|
||||||
|
|
||||||
local slim_arms
|
local slim_arms
|
||||||
if skin.simple_skins_id then
|
if skin.simple_skins_id then
|
||||||
slim_arms = mcl_skins.texture_to_simple_skin[skin.simple_skins_id].slim_arms
|
slim_arms = mcl_skins.texture_to_simple_skin[skin.simple_skins_id].slim_arms
|
||||||
|
@ -200,9 +224,17 @@ minetest.register_on_leaveplayer(function(player)
|
||||||
mcl_skins.player_formspecs[player] = nil
|
mcl_skins.player_formspecs[player] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function calculate_page_count(tab)
|
local function calculate_page_count(tab, player)
|
||||||
if tab == "skin" then
|
if tab == "skin" then
|
||||||
return math.ceil((#mcl_skins.simple_skins + 2) / 8)
|
return math.ceil((#mcl_skins.simple_skins + 2) / 8)
|
||||||
|
elseif tab == "cape" then
|
||||||
|
local player_capes = 0
|
||||||
|
for _, cape in pairs(mcl_skins.cape) do
|
||||||
|
if type(cape.selector_func) == "nil" or cape.selector_func(player) then
|
||||||
|
player_capes = player_capes + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return math.ceil((player_capes + 1) / 5) -- add one so the player can select no cape as well
|
||||||
elseif mcl_skins[tab] then
|
elseif mcl_skins[tab] then
|
||||||
return math.ceil(#mcl_skins[tab] / 16)
|
return math.ceil(#mcl_skins[tab] / 16)
|
||||||
end
|
end
|
||||||
|
@ -213,29 +245,29 @@ function mcl_skins.show_formspec(player, active_tab, page_num)
|
||||||
local formspec_data = mcl_skins.player_formspecs[player]
|
local formspec_data = mcl_skins.player_formspecs[player]
|
||||||
local skin = mcl_skins.player_skins[player]
|
local skin = mcl_skins.player_skins[player]
|
||||||
formspec_data.active_tab = active_tab
|
formspec_data.active_tab = active_tab
|
||||||
|
|
||||||
local page_count = calculate_page_count(active_tab)
|
local page_count = calculate_page_count(active_tab, player)
|
||||||
if page_num < 1 then page_num = 1 end
|
if page_num < 1 then page_num = 1 end
|
||||||
if page_num > page_count then page_num = page_count end
|
if page_num > page_count then page_num = page_count end
|
||||||
formspec_data.page_num = page_num
|
formspec_data.page_num = page_num
|
||||||
|
|
||||||
local formspec = "formspec_version[3]size[14.2,11]"
|
local formspec = "formspec_version[3]size[14.2,11]"
|
||||||
|
|
||||||
for i, tab in pairs(mcl_skins.tab_names) do
|
for i, tab in pairs(mcl_skins.tab_names) do
|
||||||
if tab == active_tab then
|
if tab == active_tab then
|
||||||
formspec = formspec ..
|
formspec = formspec ..
|
||||||
"style[" .. tab .. ";bgcolor=green]"
|
"style[" .. tab .. ";bgcolor=green]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local y = 0.3 + (i - 1) * 0.8
|
local y = 0.3 + (i - 1) * 0.8
|
||||||
formspec = formspec ..
|
formspec = formspec ..
|
||||||
"style[" .. tab .. ";content_offset=16,0]" ..
|
"style[" .. tab .. ";content_offset=16,0]" ..
|
||||||
"button[0.3," .. y .. ";4,0.8;" .. tab .. ";" .. mcl_skins.tab_descriptions[tab] .. "]" ..
|
"button[0.3," .. y .. ";4,0.8;" .. tab .. ";" .. mcl_skins.tab_descriptions[tab] .. "]" ..
|
||||||
"image[0.4," .. y + 0.1 .. ";0.6,0.6;mcl_skins_icons.png^[verticalframe:11:" .. i - 1 .. "]"
|
"image[0.4," .. y + 0.1 .. ";0.6,0.6;mcl_skins_icons.png^[verticalframe:12:" .. i - 1 .. "]"
|
||||||
|
|
||||||
if skin.simple_skins_id then break end
|
if skin.simple_skins_id then break end
|
||||||
end
|
end
|
||||||
|
|
||||||
local slim_arms
|
local slim_arms
|
||||||
if skin.simple_skins_id then
|
if skin.simple_skins_id then
|
||||||
slim_arms = mcl_skins.texture_to_simple_skin[skin.simple_skins_id].slim_arms
|
slim_arms = mcl_skins.texture_to_simple_skin[skin.simple_skins_id].slim_arms
|
||||||
|
@ -249,6 +281,9 @@ function mcl_skins.show_formspec(player, active_tab, page_num)
|
||||||
mcl_skins.compile_skin(skin) ..
|
mcl_skins.compile_skin(skin) ..
|
||||||
",blank.png,blank.png;0,180;false;true;0,0]"
|
",blank.png,blank.png;0,180;false;true;0,0]"
|
||||||
|
|
||||||
|
|
||||||
|
local cape_tab = active_tab == "cape"
|
||||||
|
|
||||||
if active_tab == "skin" then
|
if active_tab == "skin" then
|
||||||
local page_start = (page_num - 1) * 8 - 1
|
local page_start = (page_num - 1) * 8 - 1
|
||||||
local page_end = math.min(page_start + 8 - 1, #mcl_skins.simple_skins)
|
local page_end = math.min(page_start + 8 - 1, #mcl_skins.simple_skins)
|
||||||
|
@ -264,21 +299,21 @@ function mcl_skins.show_formspec(player, active_tab, page_num)
|
||||||
}
|
}
|
||||||
simple_skins_id = simple_skins_id or
|
simple_skins_id = simple_skins_id or
|
||||||
mcl_skins.simple_skins[EDIT_SKIN_KEY].texture
|
mcl_skins.simple_skins[EDIT_SKIN_KEY].texture
|
||||||
|
|
||||||
for i = page_start, page_end do
|
for i = page_start, page_end do
|
||||||
local skin = mcl_skins.simple_skins[i]
|
local skin = mcl_skins.simple_skins[i]
|
||||||
local j = i - page_start - 1
|
local j = i - page_start - 1
|
||||||
local mesh = skin.slim_arms and "mcl_armor_character_female.b3d" or
|
local mesh = skin.slim_arms and "mcl_armor_character_female.b3d" or
|
||||||
"mcl_armor_character.b3d"
|
"mcl_armor_character.b3d"
|
||||||
|
|
||||||
local x = 4.5 + (j + 1) % 4 * 1.6
|
local x = 4.5 + (j + 1) % 4 * 1.6
|
||||||
local y = 0.3 + math.floor((j + 1) / 4) * 3.1
|
local y = 0.3 + math.floor((j + 1) / 4) * 3.1
|
||||||
|
|
||||||
formspec = formspec ..
|
formspec = formspec ..
|
||||||
"model[" .. x .. "," .. y .. ";1.5,3;player_mesh;" .. mesh .. ";" ..
|
"model[" .. x .. "," .. y .. ";1.5,3;player_mesh;" .. mesh .. ";" ..
|
||||||
skin.texture ..
|
skin.texture ..
|
||||||
",blank.png,blank.png;0,180;false;true;0,0]"
|
",blank.png,blank.png;0,180;false;true;0,0]"
|
||||||
|
|
||||||
if simple_skins_id == skin.texture then
|
if simple_skins_id == skin.texture then
|
||||||
formspec = formspec ..
|
formspec = formspec ..
|
||||||
"style[" .. i ..
|
"style[" .. i ..
|
||||||
|
@ -288,7 +323,7 @@ function mcl_skins.show_formspec(player, active_tab, page_num)
|
||||||
formspec = formspec ..
|
formspec = formspec ..
|
||||||
"button[" .. x .. "," .. y .. ";1.5,3;" .. i .. ";]"
|
"button[" .. x .. "," .. y .. ";1.5,3;" .. i .. ";]"
|
||||||
end
|
end
|
||||||
|
|
||||||
if page_start == EDIT_SKIN_KEY then
|
if page_start == EDIT_SKIN_KEY then
|
||||||
formspec = formspec .. "image[4.85,1;0.8,0.8;mcl_skins_button.png]"
|
formspec = formspec .. "image[4.85,1;0.8,0.8;mcl_skins_button.png]"
|
||||||
end
|
end
|
||||||
|
@ -303,16 +338,46 @@ function mcl_skins.show_formspec(player, active_tab, page_num)
|
||||||
"model[7.5,2;2,3;player_mesh;mcl_armor_character_female.b3d;" ..
|
"model[7.5,2;2,3;player_mesh;mcl_armor_character_female.b3d;" ..
|
||||||
mcl_skins.compile_skin(mcl_skins.template2) ..
|
mcl_skins.compile_skin(mcl_skins.template2) ..
|
||||||
",blank.png,blank.png;0,180;false;true;0,0]" ..
|
",blank.png,blank.png;0,180;false;true;0,0]" ..
|
||||||
|
|
||||||
"button[7.5,5.2;2,0.8;template2;" .. S("Select") .. "]"
|
"button[7.5,5.2;2,0.8;template2;" .. S("Select") .. "]"
|
||||||
|
|
||||||
|
elseif cape_tab then
|
||||||
|
local possize = {{"6,2;1,2", "5.5,4.2;2,0.8"}, {"9,2;1,2","8.5,4.2;2,0.8"}, {"6,7;1,2","5.5,9.2;2,0.8"}, {"9,7;1,2","8.5,9.2;2,0.8"},{"12,7;1,2","11.5,9.2;2,0.8"}}
|
||||||
|
local player_capes = {} -- contains all capes the player is allowed to wear
|
||||||
|
for _, cape in pairs (mcl_skins.cape) do
|
||||||
|
if type(cape.selector_func) == "nil" or cape.selector_func(player) then
|
||||||
|
table.insert(player_capes, cape)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local slot_offset = 0
|
||||||
|
|
||||||
|
if page_num == 1 then
|
||||||
|
formspec = formspec ..
|
||||||
|
"label[6,3;" .. S("(None)") .. "]"..
|
||||||
|
"button[5.5,4.2;2,0.8;nocape;" .. S("Select") .. "]"
|
||||||
|
slot_offset = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local array_start = page_num * 5 - 4
|
||||||
|
local index_offset = page_num == 1 and 1 or 2
|
||||||
|
|
||||||
|
for slot = 1 + slot_offset, page_num ~= page_count and 5 or (#player_capes % 5 == 0 and 1 or #player_capes % 5) + slot_offset do
|
||||||
|
local cape = player_capes[array_start + slot - slot_offset - index_offset]
|
||||||
|
local pos = possize[slot]
|
||||||
|
|
||||||
|
formspec = formspec ..
|
||||||
|
"image[" .. possize[slot][1] .. ";" .. cape.name ..".png]"..
|
||||||
|
"button[" .. possize[slot][2] .. ";" .. cape.name ..";" .. S("Select") .. "]"
|
||||||
|
end
|
||||||
|
|
||||||
elseif mcl_skins[active_tab] then
|
elseif mcl_skins[active_tab] then
|
||||||
formspec = formspec ..
|
formspec = formspec ..
|
||||||
"style_type[button;bgcolor=#00000000]"
|
"style_type[button;bgcolor=#00000000]"
|
||||||
local textures = mcl_skins[active_tab]
|
local textures = mcl_skins[active_tab]
|
||||||
local page_start = (page_num - 1) * 16 + 1
|
local page_start = (page_num - 1) * 16 + 1
|
||||||
local page_end = math.min(page_start + 16 - 1, #textures)
|
local page_end = math.min(page_start + 16 - 1, #textures)
|
||||||
|
|
||||||
for j = page_start, page_end do
|
for j = page_start, page_end do
|
||||||
local i = j - page_start + 1
|
local i = j - page_start + 1
|
||||||
local texture = textures[j]
|
local texture = textures[j]
|
||||||
|
@ -323,21 +388,21 @@ function mcl_skins.show_formspec(player, active_tab, page_num)
|
||||||
preview = preview .. "^(" .. mask .. "^[colorize:" .. color .. ":alpha)"
|
preview = preview .. "^(" .. mask .. "^[colorize:" .. color .. ":alpha)"
|
||||||
end
|
end
|
||||||
preview = preview .. "^" .. texture
|
preview = preview .. "^" .. texture
|
||||||
|
|
||||||
local mesh = "mcl_skins_head.obj"
|
local mesh = "mcl_skins_head.obj"
|
||||||
if active_tab == "top" then
|
if active_tab == "top" then
|
||||||
mesh = "mcl_skins_top.obj"
|
mesh = "mcl_skins_top.obj"
|
||||||
elseif active_tab == "bottom" or active_tab == "footwear" then
|
elseif active_tab == "bottom" or active_tab == "footwear" then
|
||||||
mesh = "mcl_skins_bottom.obj"
|
mesh = "mcl_skins_bottom.obj"
|
||||||
end
|
end
|
||||||
|
|
||||||
local rot_x = -10
|
local rot_x = -10
|
||||||
local rot_y = 20
|
local rot_y = 20
|
||||||
if mcl_skins.preview_rotations[texture] then
|
if mcl_skins.preview_rotations[texture] then
|
||||||
rot_x = mcl_skins.preview_rotations[texture].x
|
rot_x = mcl_skins.preview_rotations[texture].x
|
||||||
rot_y = mcl_skins.preview_rotations[texture].y
|
rot_y = mcl_skins.preview_rotations[texture].y
|
||||||
end
|
end
|
||||||
|
|
||||||
i = i - 1
|
i = i - 1
|
||||||
local x = 4.5 + i % 4 * 1.6
|
local x = 4.5 + i % 4 * 1.6
|
||||||
local y = 0.3 + math.floor(i / 4) * 1.6
|
local y = 0.3 + math.floor(i / 4) * 1.6
|
||||||
|
@ -346,7 +411,7 @@ function mcl_skins.show_formspec(player, active_tab, page_num)
|
||||||
";1.5,1.5;" .. mesh .. ";" .. mesh .. ";" ..
|
";1.5,1.5;" .. mesh .. ";" .. mesh .. ";" ..
|
||||||
preview ..
|
preview ..
|
||||||
";" .. rot_x .. "," .. rot_y .. ";false;false;0,0]"
|
";" .. rot_x .. "," .. rot_y .. ";false;false;0,0]"
|
||||||
|
|
||||||
if skin[active_tab] == texture then
|
if skin[active_tab] == texture then
|
||||||
formspec = formspec ..
|
formspec = formspec ..
|
||||||
"style[" .. texture ..
|
"style[" .. texture ..
|
||||||
|
@ -365,11 +430,11 @@ function mcl_skins.show_formspec(player, active_tab, page_num)
|
||||||
"button[" .. x .. ",0.3;1,1;arm;]"
|
"button[" .. x .. ",0.3;1,1;arm;]"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if skin[active_tab .. "_color"] then
|
if skin[active_tab .. "_color"] then
|
||||||
local colors = mcl_skins.color
|
local colors = mcl_skins.color
|
||||||
if active_tab == "base" then colors = mcl_skins.base_color end
|
if active_tab == "base" then colors = mcl_skins.base_color end
|
||||||
|
|
||||||
local tab_color = active_tab .. "_color"
|
local tab_color = active_tab .. "_color"
|
||||||
local selected_color = skin[tab_color]
|
local selected_color = skin[tab_color]
|
||||||
for i, colorspec in pairs(colors) do
|
for i, colorspec in pairs(colors) do
|
||||||
|
@ -381,7 +446,7 @@ function mcl_skins.show_formspec(player, active_tab, page_num)
|
||||||
"image_button[" .. x .. "," .. y ..
|
"image_button[" .. x .. "," .. y ..
|
||||||
";0.8,0.8;blank.png^[noalpha^[colorize:" ..
|
";0.8,0.8;blank.png^[noalpha^[colorize:" ..
|
||||||
color .. ":alpha;" .. colorspec .. ";]"
|
color .. ":alpha;" .. colorspec .. ";]"
|
||||||
|
|
||||||
if selected_color == colorspec then
|
if selected_color == colorspec then
|
||||||
formspec = formspec ..
|
formspec = formspec ..
|
||||||
"style[" .. color ..
|
"style[" .. color ..
|
||||||
|
@ -389,9 +454,9 @@ function mcl_skins.show_formspec(player, active_tab, page_num)
|
||||||
"bgimg_pressed=mcl_skins_select_overlay.png]" ..
|
"bgimg_pressed=mcl_skins_select_overlay.png]" ..
|
||||||
"button[" .. x .. "," .. y .. ";0.8,0.8;" .. color .. ";]"
|
"button[" .. x .. "," .. y .. ";0.8,0.8;" .. color .. ";]"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if not (active_tab == "base") then
|
if not (active_tab == "base") then
|
||||||
-- Bitwise Operations !?!?!
|
-- Bitwise Operations !?!?!
|
||||||
local red = math.floor(selected_color / 0x10000) - 0xff00
|
local red = math.floor(selected_color / 0x10000) - 0xff00
|
||||||
|
@ -400,39 +465,54 @@ function mcl_skins.show_formspec(player, active_tab, page_num)
|
||||||
formspec = formspec ..
|
formspec = formspec ..
|
||||||
"container[10.2,8]" ..
|
"container[10.2,8]" ..
|
||||||
"scrollbaroptions[min=0;max=255;smallstep=20]" ..
|
"scrollbaroptions[min=0;max=255;smallstep=20]" ..
|
||||||
|
|
||||||
"box[0.4,0;2.49,0.38;red]" ..
|
"box[0.4,0;2.49,0.38;red]" ..
|
||||||
"label[0.2,0.2;-]" ..
|
"label[0.2,0.2;-]" ..
|
||||||
"scrollbar[0.4,0;2.5,0.4;horizontal;red;" .. red .."]" ..
|
"scrollbar[0.4,0;2.5,0.4;horizontal;red;" .. red .."]" ..
|
||||||
"label[2.9,0.2;+]" ..
|
"label[2.9,0.2;+]" ..
|
||||||
|
|
||||||
"box[0.4,0.6;2.49,0.38;green]" ..
|
"box[0.4,0.6;2.49,0.38;green]" ..
|
||||||
"label[0.2,0.8;-]" ..
|
"label[0.2,0.8;-]" ..
|
||||||
"scrollbar[0.4,0.6;2.5,0.4;horizontal;green;" .. green .."]" ..
|
"scrollbar[0.4,0.6;2.5,0.4;horizontal;green;" .. green .."]" ..
|
||||||
"label[2.9,0.8;+]" ..
|
"label[2.9,0.8;+]" ..
|
||||||
|
|
||||||
"box[0.4,1.2;2.49,0.38;blue]" ..
|
"box[0.4,1.2;2.49,0.38;blue]" ..
|
||||||
"label[0.2,1.4;-]" ..
|
"label[0.2,1.4;-]" ..
|
||||||
"scrollbar[0.4,1.2;2.5,0.4;horizontal;blue;" .. blue .. "]" ..
|
"scrollbar[0.4,1.2;2.5,0.4;horizontal;blue;" .. blue .. "]" ..
|
||||||
"label[2.9,1.4;+]" ..
|
"label[2.9,1.4;+]" ..
|
||||||
|
|
||||||
"container_end[]"
|
"container_end[]"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if page_num > 1 then
|
if page_num > 1 then
|
||||||
formspec = formspec ..
|
if cape_tab then
|
||||||
"image_button[4.5,6.7;1,1;mcl_skins_arrow.png^[transformFX;previous_page;]"
|
formspec = formspec ..
|
||||||
|
"image_button[4.5,0.7;1,1;mcl_skins_arrow.png^[transformFX;previous_page;]"
|
||||||
|
else
|
||||||
|
formspec = formspec ..
|
||||||
|
"image_button[4.5,6.7;1,1;mcl_skins_arrow.png^[transformFX;previous_page;]"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if page_num < page_count then
|
if page_num < page_count then
|
||||||
formspec = formspec ..
|
if cape_tab then
|
||||||
"image_button[9.8,6.7;1,1;mcl_skins_arrow.png;next_page;]"
|
formspec = formspec ..
|
||||||
|
"image_button[9.8,0.7;1,1;mcl_skins_arrow.png;next_page;]"
|
||||||
|
else
|
||||||
|
formspec = formspec ..
|
||||||
|
"image_button[9.8,6.7;1,1;mcl_skins_arrow.png;next_page;]"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if page_count > 1 then
|
if page_count > 1 then
|
||||||
formspec = formspec ..
|
if cape_tab then
|
||||||
"label[7.3,7.2;" .. page_num .. " / " .. page_count .. "]"
|
formspec = formspec ..
|
||||||
|
"label[7.3,1.2;" .. page_num .. " / " .. page_count .. "]"
|
||||||
|
else
|
||||||
|
formspec = formspec ..
|
||||||
|
"label[7.3,7.2;" .. page_num .. " / " .. page_count .. "]"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
|
@ -456,7 +536,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
formspec_data.form_send_job:cancel()
|
formspec_data.form_send_job:cancel()
|
||||||
formspec_data.form_send_job = nil
|
formspec_data.form_send_job = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields.quit then
|
if fields.quit then
|
||||||
mcl_skins.save(player)
|
mcl_skins.save(player)
|
||||||
return true
|
return true
|
||||||
|
@ -472,18 +552,35 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
mcl_skins.update_player_skin(player)
|
mcl_skins.update_player_skin(player)
|
||||||
mcl_skins.show_formspec(player, active_tab, page_num)
|
mcl_skins.show_formspec(player, active_tab, page_num)
|
||||||
return true
|
return true
|
||||||
|
elseif fields.nocape then
|
||||||
|
mcl_skins.player_skins[player].cape = "blank.png"
|
||||||
|
mcl_skins.update_player_skin(player)
|
||||||
|
mcl_armor.update(player) --update elytra cape
|
||||||
|
mcl_skins.show_formspec(player, active_tab, page_num)
|
||||||
|
return true
|
||||||
|
elseif active_tab == "cape" then
|
||||||
|
for cape_index = ((page_num - 1) * 5) + 1, math.min(#mcl_skins.cape, page_num * 5) do
|
||||||
|
local cape = mcl_skins.cape[cape_index]
|
||||||
|
if fields[cape.name] then
|
||||||
|
mcl_skins.player_skins[player].cape = cape.mask -- the actual overlay image
|
||||||
|
mcl_skins.update_player_skin(player)
|
||||||
|
mcl_armor.update(player) --update elytra cape
|
||||||
|
mcl_skins.show_formspec(player, active_tab, page_num)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for i, tab in pairs(mcl_skins.tab_names) do
|
for i, tab in pairs(mcl_skins.tab_names) do
|
||||||
if fields[tab] then
|
if fields[tab] then
|
||||||
mcl_skins.show_formspec(player, tab, 1)
|
mcl_skins.show_formspec(player, tab, 1)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local skin = mcl_skins.player_skins[player]
|
local skin = mcl_skins.player_skins[player]
|
||||||
if not skin then return true end
|
if not skin then return true end
|
||||||
|
|
||||||
if fields.next_page then
|
if fields.next_page then
|
||||||
page_num = page_num + 1
|
page_num = page_num + 1
|
||||||
mcl_skins.show_formspec(player, active_tab, page_num)
|
mcl_skins.show_formspec(player, active_tab, page_num)
|
||||||
|
@ -493,7 +590,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
mcl_skins.show_formspec(player, active_tab, page_num)
|
mcl_skins.show_formspec(player, active_tab, page_num)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if active_tab == "arm" then
|
if active_tab == "arm" then
|
||||||
if fields.thick_arms then
|
if fields.thick_arms then
|
||||||
skin.slim_arms = false
|
skin.slim_arms = false
|
||||||
|
@ -504,7 +601,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
mcl_skins.show_formspec(player, active_tab, page_num)
|
mcl_skins.show_formspec(player, active_tab, page_num)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if
|
if
|
||||||
skin[active_tab .. "_color"] and (
|
skin[active_tab .. "_color"] and (
|
||||||
fields.red and fields.red:find("^CHG") or
|
fields.red and fields.red:find("^CHG") or
|
||||||
|
@ -518,7 +615,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
red = tonumber(red) or 0
|
red = tonumber(red) or 0
|
||||||
green = tonumber(green) or 0
|
green = tonumber(green) or 0
|
||||||
blue = tonumber(blue) or 0
|
blue = tonumber(blue) or 0
|
||||||
|
|
||||||
local color = 0xff000000 + red * 0x10000 + green * 0x100 + blue
|
local color = 0xff000000 + red * 0x10000 + green * 0x100 + blue
|
||||||
if color >= 0 and color <= 0xffffffff then
|
if color >= 0 and color <= 0xffffffff then
|
||||||
-- We delay resedning the form because otherwise it will break dragging scrollbars
|
-- We delay resedning the form because otherwise it will break dragging scrollbars
|
||||||
|
@ -533,7 +630,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local field
|
local field
|
||||||
for f, value in pairs(fields) do
|
for f, value in pairs(fields) do
|
||||||
if value == "" then
|
if value == "" then
|
||||||
|
@ -541,7 +638,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if field and active_tab == "skin" then
|
if field and active_tab == "skin" then
|
||||||
local index = tonumber(field)
|
local index = tonumber(field)
|
||||||
index = index and math.floor(index) or 0
|
index = index and math.floor(index) or 0
|
||||||
|
@ -556,7 +653,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- See if field is a texture
|
-- See if field is a texture
|
||||||
if
|
if
|
||||||
field and mcl_skins[active_tab] and
|
field and mcl_skins[active_tab] and
|
||||||
|
@ -567,7 +664,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
mcl_skins.show_formspec(player, active_tab, page_num)
|
mcl_skins.show_formspec(player, active_tab, page_num)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- See if field is a color
|
-- See if field is a color
|
||||||
local number = tonumber(field)
|
local number = tonumber(field)
|
||||||
if number and skin[active_tab .. "_color"] then
|
if number and skin[active_tab .. "_color"] then
|
||||||
|
@ -591,7 +688,7 @@ local function init()
|
||||||
local json, error = minetest.parse_json(data)
|
local json, error = minetest.parse_json(data)
|
||||||
assert(json, error)
|
assert(json, error)
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
for _, item in pairs(json) do
|
for _, item in pairs(json) do
|
||||||
mcl_skins.register_item(item)
|
mcl_skins.register_item(item)
|
||||||
end
|
end
|
||||||
|
@ -600,12 +697,14 @@ local function init()
|
||||||
mcl_skins.template1.top_color = 0xff993535
|
mcl_skins.template1.top_color = 0xff993535
|
||||||
mcl_skins.template1.bottom_color = 0xff644939
|
mcl_skins.template1.bottom_color = 0xff644939
|
||||||
mcl_skins.template1.slim_arms = false
|
mcl_skins.template1.slim_arms = false
|
||||||
|
mcl_skins.template1.cape = "blank.png"
|
||||||
|
|
||||||
mcl_skins.template2.base_color = mcl_skins.base_color[1]
|
mcl_skins.template2.base_color = mcl_skins.base_color[1]
|
||||||
mcl_skins.template2.hair_color = 0xff715d57
|
mcl_skins.template2.hair_color = 0xff715d57
|
||||||
mcl_skins.template2.top_color = 0xff346840
|
mcl_skins.template2.top_color = 0xff346840
|
||||||
mcl_skins.template2.bottom_color = 0xff383532
|
mcl_skins.template2.bottom_color = 0xff383532
|
||||||
mcl_skins.template2.slim_arms = true
|
mcl_skins.template2.slim_arms = true
|
||||||
|
mcl_skins.template2.cape = "blank.png"
|
||||||
|
|
||||||
mcl_skins.register_simple_skin({
|
mcl_skins.register_simple_skin({
|
||||||
index = 0,
|
index = 0,
|
||||||
|
@ -619,3 +718,9 @@ local function init()
|
||||||
end
|
end
|
||||||
|
|
||||||
init()
|
init()
|
||||||
|
|
||||||
|
if not minetest.settings:get_bool("mcl_keepInventory", false) then
|
||||||
|
minetest.register_on_respawnplayer(function(player)
|
||||||
|
mcl_skins.update_player_skin(player) -- ensures players have their cape again after dying with an elytra
|
||||||
|
end)
|
||||||
|
end
|
|
@ -263,5 +263,29 @@
|
||||||
"mask": "mcl_skins_base_1_mask.png",
|
"mask": "mcl_skins_base_1_mask.png",
|
||||||
"template1": true,
|
"template1": true,
|
||||||
"template2": true
|
"template2": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "cape",
|
||||||
|
"name": "mtcape",
|
||||||
|
"mask": "mtcape_body.png",
|
||||||
|
"selector_func" : null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "cape",
|
||||||
|
"name": "slimecape",
|
||||||
|
"mask": "slimecape_body.png",
|
||||||
|
"selector_func" : null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "cape",
|
||||||
|
"name": "ghastcape",
|
||||||
|
"mask": "ghastcape_body.png",
|
||||||
|
"selector_func" : null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "cape",
|
||||||
|
"name": "mclcape",
|
||||||
|
"mask": "mclcape_body.png",
|
||||||
|
"selector_func" : null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -10,5 +10,6 @@ Bottoms=
|
||||||
Tops=
|
Tops=
|
||||||
Hairs=
|
Hairs=
|
||||||
Headwears=
|
Headwears=
|
||||||
Open skin configuration screen.=
|
Open skin configuration screen.=
|
||||||
Select=
|
Select=
|
||||||
|
Capes=
|
||||||
|
|
After Width: | Height: | Size: 6.7 KiB |
After Width: | Height: | Size: 8.5 KiB |
After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 420 B After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 725 B |
After Width: | Height: | Size: 803 B |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 7.7 KiB |
After Width: | Height: | Size: 780 B |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 8.0 KiB |
After Width: | Height: | Size: 821 B |
After Width: | Height: | Size: 5.8 KiB |