modified unified_inventory to place buttons in 2 rows when +12

modified unified_inventory to hide buttons if player does not have the necessary privileges
modified other mods to adjust with unified_inventory
This commit is contained in:
crabman77 2015-06-30 16:15:58 +02:00
parent 04e5e49904
commit a2b7be291f
9 changed files with 45 additions and 21 deletions

View File

@ -105,6 +105,8 @@ elseif minetest.get_modpath("unified_inventory") then
unified_inventory.register_button("armor", {
type = "image",
image = "inventory_plus_armor.png",
tooltip = "Armor inventory",
show_with = false, --Modif MFF (Crabman 30/06/2015)
})
unified_inventory.register_page("armor", {
get_formspec = function(player)

View File

@ -77,6 +77,8 @@ if unified_inventory then --unified inventory installed
unified_inventory.register_button("worldedit_gui", {
type = "image",
image = "inventory_plus_worldedit_gui.png",
tooltip = "Worldedit GUI",
show_with = "worldedit", --Modiff MFF (Crabman 30/06/2015)
})
minetest.register_on_player_receive_fields(function(player, formname, fields)

View File

@ -216,6 +216,8 @@ end
unified_inventory.register_button("runes", {
type = "image",
image = "runes_heal_major.png",
tooltip = "Rune inventory",
show_with = false, --Modif MFF (Crabman 30/06/2015)
})
unified_inventory.register_page("runes", {
get_formspec = function(player)

View File

@ -173,6 +173,7 @@ if (minetest.get_modpath("unified_inventory")) then
type = "image",
image = "soundset_menu_icon.png",
tooltip = "sounds menu ",
show_with = false, --Modif MFF (Crabman 30/06/2015)
action = function(player)
local name = player:get_player_name()
if not name then return end

View File

@ -84,6 +84,8 @@ unified_inventory.register_page("u_skins", {
unified_inventory.register_button("u_skins", {
type = "image",
image = "u_skins_button.png",
tooltip = "Skin inventory",
show_with = false, -- modif MFF (Crabman 30/06/2015)
})
-- Create all of the skin-picker pages.
@ -163,4 +165,4 @@ minetest.register_on_joinplayer(function(player)
end)
u_skins.generate_pages()
u_skins.load_players()
u_skins.load_players()

View File

@ -32,7 +32,8 @@ unified_inventory.register_page("bags", {
unified_inventory.register_button("bags", {
type = "image",
image = "ui_bags_icon.png",
tooltip = S("Bags")
tooltip = S("Bags"),
show_with = false, --Modif MFF (Crabman 30/06/2015)
})
for i = 1, 4 do

View File

@ -48,28 +48,34 @@ function unified_inventory.get_formspec(player, page)
return "" -- Invalid page name
end
local privs = minetest.get_player_privs(player_name) --Modif MFF (Crabman 30/06/2015) DEBUT,12 buttons max by row and not show if player has not privs requiered
local button_row = 0
local button_col = 0
local i = 1
-- Main buttons
for i, def in pairs(unified_inventory.buttons) do
if unified_inventory.lite_mode and i > 4 then
button_row = 1
button_col = 1
for _, def in pairs(unified_inventory.buttons) do
if (def.show_with == nil or def.show_with == false) or (privs[def.show_with] and privs[def.show_with] == true) then
if unified_inventory.lite_mode and i > 4 then
button_row = 1
button_col = 1
elseif not unified_inventory.lite_mode and i > 12 then
button_row = 1
i = 1
end
local tooltip = def.tooltip or ""
if def.type == "image" then
formspec = formspec.."image_button["
..( unified_inventory.main_button_x + 0.65 * (i - 1) - button_col * 0.65 * 4)
..","..(unified_inventory.main_button_y + button_row * 0.7)..";0.8,0.8;"
..minetest.formspec_escape(def.image)..";"
..minetest.formspec_escape(def.name)..";]"
.."tooltip["..minetest.formspec_escape(def.name)
..";"..tooltip.."]"
end
i = i + 1
end
local tooltip = def.tooltip or ""
if def.type == "image" then
formspec = formspec.."image_button["
..( unified_inventory.main_button_x + 0.65 * (i - 1) - button_col * 0.65 * 4)
..","..(unified_inventory.main_button_y + button_row * 0.7)..";0.8,0.8;"
..minetest.formspec_escape(def.image)..";"
..minetest.formspec_escape(def.name)..";]"
.."tooltip["..minetest.formspec_escape(def.name)
..";"..tooltip.."]"
end
end
end --Modif MFF (Crabman 30/06/2015) FIN
if fsdata.draw_inventory ~= false then
-- Player inventory

View File

@ -33,13 +33,15 @@ trash:set_size("main", 1)
unified_inventory.register_button("craft", {
type = "image",
image = "ui_craft_icon.png",
tooltip = S("Crafting Grid")
tooltip = S("Crafting Grid"),
show_with = false, --Modif MFF (Crabman 30/06/2015)
})
unified_inventory.register_button("craftguide", {
type = "image",
image = "ui_craftguide_icon.png",
tooltip = S("Crafting Guide")
tooltip = S("Crafting Guide"),
show_with = false, --Modif MFF (Crabman 30/06/2015)
})
if not unified_inventory.lite_mode then
@ -47,6 +49,7 @@ if not unified_inventory.lite_mode then
type = "image",
image = "ui_sethome_icon.png",
tooltip = S("Set home position"),
show_with = "interact", --Modif MFF (Crabman 30/06/2015)
action = function(player)
if home.sethome(player:get_player_name()) == true then --modif MFF
minetest.sound_play("dingdong",
@ -59,6 +62,7 @@ if not unified_inventory.lite_mode then
type = "image",
image = "ui_gohome_icon.png",
tooltip = S("Go home"),
show_with = "interact", --Modif MFF (Crabman 30/06/2015)
action = function(player)
if home.tohome(player:get_player_name()) == true then --modif MFF
minetest.sound_play("teleport",
@ -71,6 +75,7 @@ if not unified_inventory.lite_mode then
type = "image",
image = "ui_sun_icon.png",
tooltip = S("Set time to day"),
show_with = "settime", --Modif MFF (Crabman 30/06/2015)
action = function(player)
local player_name = player:get_player_name()
if minetest.check_player_privs(player_name, {settime=true}) then
@ -90,6 +95,7 @@ if not unified_inventory.lite_mode then
type = "image",
image = "ui_moon_icon.png",
tooltip = S("Set time to night"),
show_with = "settime", --Modif MFF (Crabman 30/06/2015)
action = function(player)
local player_name = player:get_player_name()
if minetest.check_player_privs(player_name, {settime=true}) then
@ -110,6 +116,7 @@ unified_inventory.register_button("clear_inv", {
type = "image",
image = "ui_trash_icon.png",
tooltip = S("Clear inventory"),
show_with = "creative", --Modif MFF (Crabman 30/06/2015)
action = function(player)
local player_name = player:get_player_name()
if not unified_inventory.is_creative(player_name) then

View File

@ -112,6 +112,7 @@ unified_inventory.register_button("waypoints", {
type = "image",
image = "ui_waypoints_icon.png",
tooltip = S("Waypoints"),
show_with = false, --Modif MFF (Crabman 30/06/2015)
})
local function update_hud(player, waypoints, temp, i)