diff --git a/formspecs.lua b/formspecs.lua index 89e60f7..39d4a17 100644 --- a/formspecs.lua +++ b/formspecs.lua @@ -16,11 +16,14 @@ function skins.get_skin_info_formspec(skin) local m_name = skin:get_meta_string("name") local m_author = skin:get_meta_string("author") local m_license = skin:get_meta_string("license") + local m_format = skin:get_meta("format") -- overview page - local formspec = "image[0,.75;1,2;"..skin:get_preview().."]" + local raw_size = m_format == "1.8" and "2,2" or "2,1" + + local formspec = "image[0.8,.6;1,2;"..minetest.formspec_escape(skin:get_preview()).."]" if texture then formspec = formspec.."label[6,.5;"..S("Raw texture")..":]" - .."image[6,1;2,1;"..skin:get_texture().."]" + .."image[6,1;"..raw_size..";"..texture.."]" end if m_name ~= "" then formspec = formspec.."label[2,.5;"..S("Name")..": "..minetest.formspec_escape(m_name).."]" @@ -63,7 +66,7 @@ function skins.get_skin_selection_formspec(player, context, y_delta) y = y_delta end formspec = formspec.."image_button["..x..","..y..";1,2;".. - skin:get_preview()..";skins_set$"..i..";]".. + minetest.formspec_escape(skin:get_preview())..";skins_set$"..i..";]".. "tooltip[skins_set$"..i..";"..minetest.formspec_escape(skin:get_meta_string("name")).."]" end diff --git a/init.lua b/init.lua index a771df4..33345ed 100644 --- a/init.lua +++ b/init.lua @@ -82,3 +82,13 @@ player_api.register_model("skinsdb_3d_armor_character_5.b3d", { sit = {x=81, y=160}, }, }) + +-- Register default character.png if not part of this mod +local default_skin_obj = skins.get(skins.default) +if not default_skin_obj then + default_skin_obj = skins.new(skins.default) + default_skin_obj:set_texture("character.png") + default_skin_obj:set_meta("format", '1.0') + default_skin_obj:set_meta("_sort_id", 0) + default_skin_obj:set_meta("name", "Sam") +end diff --git a/meta/character.txt b/meta/character.txt deleted file mode 100644 index b4599e6..0000000 --- a/meta/character.txt +++ /dev/null @@ -1,3 +0,0 @@ -Sam 0 -Jordach -CC BY-SA 3.0 diff --git a/skin_meta_api.lua b/skin_meta_api.lua index 06929e8..375905b 100644 --- a/skin_meta_api.lua +++ b/skin_meta_api.lua @@ -56,7 +56,58 @@ function skin_class:set_preview(value) end function skin_class:get_preview() - return self._preview or "player.png" + if self._preview then + return self._preview + end + + local player_skin = "("..self:get_texture()..")" + local skin = "" + + -- Consistent on both sizes: + --Chest + skin = skin .. "([combine:16x32:-16,-12=" .. player_skin .. "^[mask:skindb_mask_chest.png)^" + --Head + skin = skin .. "([combine:16x32:-4,-8=" .. player_skin .. "^[mask:skindb_mask_head.png)^" + --Hat + skin = skin .. "([combine:16x32:-36,-8=" .. player_skin .. "^[mask:skindb_mask_head.png)^" + --Right Arm + skin = skin .. "([combine:16x32:-44,-12=" .. player_skin .. "^[mask:skindb_mask_rarm.png)^" + --Right Leg + skin = skin .. "([combine:16x32:0,0=" .. player_skin .. "^[mask:skindb_mask_rleg.png)^" + + -- 64x skins have non-mirrored arms and legs + local left_arm + local left_leg + + if self:get_meta("format") == "1.8" then + left_arm = "([combine:16x32:-24,-44=" .. player_skin .. "^[mask:(skindb_mask_rarm.png^[transformFX))^" + left_leg = "([combine:16x32:-12,-32=" .. player_skin .. "^[mask:(skindb_mask_rleg.png^[transformFX))^" + else + left_arm = "([combine:16x32:-44,-12=" .. player_skin .. "^[mask:skindb_mask_rarm.png^[transformFX)^" + left_leg = "([combine:16x32:0,0=" .. player_skin .. "^[mask:skindb_mask_rleg.png^[transformFX)^" + end + + -- Left Arm + skin = skin .. left_arm + --Left Leg + skin = skin .. left_leg + + -- Add overlays for 64x skins. these wont appear if skin is 32x because it will be cropped out + --Chest Overlay + skin = skin .. "([combine:16x32:-16,-28=" .. player_skin .. "^[mask:skindb_mask_chest.png)^" + --Right Arm Overlay + skin = skin .. "([combine:16x32:-44,-28=" .. player_skin .. "^[mask:skindb_mask_rarm.png)^" + --Right Leg Overlay + skin = skin .. "([combine:16x32:0,-16=" .. player_skin .. "^[mask:skindb_mask_rleg.png)^" + --Left Arm Overlay + skin = skin .. "([combine:16x32:-40,-44=" .. player_skin .. "^[mask:(skindb_mask_rarm.png^[transformFX))^" + --Left Leg Overlay + skin = skin .. "([combine:16x32:4,-32=" .. player_skin .. "^[mask:(skindb_mask_rleg.png^[transformFX))" + + -- Full Preview + skin = "(((" .. skin .. ")^[resize:64x128)^[mask:skindb_transform.png)" + + return skin end function skin_class:apply_skin_to_player(player) @@ -133,6 +184,6 @@ end function skin_class:is_applicable_for_player(playername) local assigned_player = self:get_meta("playername") - return assigned_player == nil or assigned_player == true or + return minetest.check_player_privs(playername, {server=true}) or assigned_player == nil or assigned_player == true or (assigned_player:lower() == playername:lower()) end diff --git a/skinlist.lua b/skinlist.lua index f8055a2..293ffb6 100644 --- a/skinlist.lua +++ b/skinlist.lua @@ -1,9 +1,12 @@ - local skins_dir_list = minetest.get_dir_list(skins.modpath.."/textures") for _, fn in pairs(skins_dir_list) do local name, sort_id, assignment, is_preview, playername - local nameparts = string.gsub(fn, "[.]", "_"):split("_") + local nameparts = { + fn:match("^%w+"), + fn:gsub("^%w+_", ""):gsub("%.%w+$", ""), + fn:match("%w+$"), + } -- check allowed prefix and file extension if (nameparts[1] == 'player' or nameparts[1] == 'character') and diff --git a/textures/character.png b/textures/character.png deleted file mode 100644 index fe0154d..0000000 Binary files a/textures/character.png and /dev/null differ diff --git a/textures/character_preview.png b/textures/character_preview.png deleted file mode 100644 index d4ba26f..0000000 Binary files a/textures/character_preview.png and /dev/null differ diff --git a/textures/inventory_plus_skins.png b/textures/inventory_plus_skins.png deleted file mode 100644 index 781b42f..0000000 Binary files a/textures/inventory_plus_skins.png and /dev/null differ diff --git a/textures/readme.txt b/textures/readme.txt index 93776ed..9d0b450 100644 --- a/textures/readme.txt +++ b/textures/readme.txt @@ -7,6 +7,7 @@ One or multiple private skins for player "nick": player_[nick].png or player_[nick]_[number-or-name].png -Preview files for public and private skins: +Preview files for public and private skins. +Optional, overrides the generated preview character_*_preview.png or player_*_*_preview.png diff --git a/textures/skindb_mask_chest.png b/textures/skindb_mask_chest.png new file mode 100644 index 0000000..b0456da Binary files /dev/null and b/textures/skindb_mask_chest.png differ diff --git a/textures/skindb_mask_head.png b/textures/skindb_mask_head.png new file mode 100644 index 0000000..5058673 Binary files /dev/null and b/textures/skindb_mask_head.png differ diff --git a/textures/skindb_mask_rarm.png b/textures/skindb_mask_rarm.png new file mode 100644 index 0000000..dfe1813 Binary files /dev/null and b/textures/skindb_mask_rarm.png differ diff --git a/textures/skindb_mask_rleg.png b/textures/skindb_mask_rleg.png new file mode 100644 index 0000000..d06c3d8 Binary files /dev/null and b/textures/skindb_mask_rleg.png differ diff --git a/textures/skindb_transform.png b/textures/skindb_transform.png new file mode 100644 index 0000000..a36bf54 Binary files /dev/null and b/textures/skindb_transform.png differ diff --git a/textures/skins_button.png b/textures/skins_button.png index 7f6e19e..f4c006c 100644 Binary files a/textures/skins_button.png and b/textures/skins_button.png differ diff --git a/textures/ui_misc_form.png b/textures/ui_misc_form.png index 81da804..2a7edb9 100644 Binary files a/textures/ui_misc_form.png and b/textures/ui_misc_form.png differ diff --git a/unified_inventory_page.lua b/unified_inventory_page.lua index ede819a..572d253 100644 --- a/unified_inventory_page.lua +++ b/unified_inventory_page.lua @@ -12,6 +12,7 @@ unified_inventory.register_page("skins", { unified_inventory.register_button("skins", { type = "image", image = "skins_button.png", + tooltip = "Skins", }) local function get_formspec(player)