hide paging if 1 page only

This commit is contained in:
Alexander Weber 2017-07-24 17:56:09 +02:00
parent e2e2927fe8
commit 7791ac7fdf
2 changed files with 43 additions and 39 deletions

View File

@ -54,6 +54,8 @@ local function get_formspec(player, context)
skin:get_preview()..";skins_set$"..i..";]".. skin:get_preview()..";skins_set$"..i..";]"..
"tooltip[skins_set$"..i..";"..minetest.formspec_escape(skin:get_meta_string("name")).."]" "tooltip[skins_set$"..i..";"..minetest.formspec_escape(skin:get_meta_string("name")).."]"
end end
if context.total_pages > 1 then
local page_prev = page - 1 local page_prev = page - 1
local page_next = page + 1 local page_next = page + 1
if page_prev < 1 then if page_prev < 1 then
@ -74,7 +76,7 @@ local function get_formspec(player, context)
.."button[0,8.3;1,.5;skins_page$"..page_prev..";<<]" .."button[0,8.3;1,.5;skins_page$"..page_prev..";<<]"
.."dropdown[1,8.16;6.5,.5;skins_selpg;"..page_list..";"..page.."]" .."dropdown[1,8.16;6.5,.5;skins_selpg;"..page_list..";"..page.."]"
.."button[7,8.3;1,.5;skins_page$"..page_next..";>>]" .."button[7,8.3;1,.5;skins_page$"..page_next..";>>]"
end
return formspec return formspec
end end

View File

@ -71,6 +71,7 @@ for page=1, total_pages do
skin:get_preview()..";skins_set$"..i..";]".. skin:get_preview()..";skins_set$"..i..";]"..
"tooltip[skins_set$"..i..";"..minetest.formspec_escape(skin:get_meta_string("name")).."]") "tooltip[skins_set$"..i..";"..minetest.formspec_escape(skin:get_meta_string("name")).."]")
end end
if total_pages > 1 then
local page_prev = page - 1 local page_prev = page - 1
local page_next = page + 1 local page_next = page + 1
if page_prev < 1 then if page_prev < 1 then
@ -91,6 +92,7 @@ for page=1, total_pages do
.."button[0,3.8;1,.5;skins_page$"..page_prev..";<<]" .."button[0,3.8;1,.5;skins_page$"..page_prev..";<<]"
.."dropdown[1,3.68;6.5,.5;skins_selpg;"..page_list..";"..page.."]" .."dropdown[1,3.68;6.5,.5;skins_selpg;"..page_list..";"..page.."]"
.."button[7,3.8;1,.5;skins_page$"..page_next..";>>]") .."button[7,3.8;1,.5;skins_page$"..page_next..";>>]")
end
unified_inventory.register_page("skins_page$"..(page), { unified_inventory.register_page("skins_page$"..(page), {
get_formspec = function(player) get_formspec = function(player)
return {formspec=formspec} return {formspec=formspec}