From a2b7be291f2017e33bc0423b1e544e6f7cf1a9c1 Mon Sep 17 00:00:00 2001 From: crabman77 Date: Tue, 30 Jun 2015 16:15:58 +0200 Subject: [PATCH] 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 --- mods/3d_armor/3d_armor/armor.lua | 2 ++ mods/WorldEdit/worldedit_gui/init.lua | 2 ++ mods/runes/api.lua | 2 ++ mods/soundset/init.lua | 1 + mods/u_skins/u_skins/init.lua | 4 ++- mods/unified_inventory/bags.lua | 3 +- mods/unified_inventory/internal.lua | 40 +++++++++++++++------------ mods/unified_inventory/register.lua | 11 ++++++-- mods/unified_inventory/waypoints.lua | 1 + 9 files changed, 45 insertions(+), 21 deletions(-) diff --git a/mods/3d_armor/3d_armor/armor.lua b/mods/3d_armor/3d_armor/armor.lua index d7bad099..0fd98094 100755 --- a/mods/3d_armor/3d_armor/armor.lua +++ b/mods/3d_armor/3d_armor/armor.lua @@ -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) diff --git a/mods/WorldEdit/worldedit_gui/init.lua b/mods/WorldEdit/worldedit_gui/init.lua index afd8c2c2..e545ae72 100755 --- a/mods/WorldEdit/worldedit_gui/init.lua +++ b/mods/WorldEdit/worldedit_gui/init.lua @@ -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) diff --git a/mods/runes/api.lua b/mods/runes/api.lua index 77bef76c..c9e13a9f 100755 --- a/mods/runes/api.lua +++ b/mods/runes/api.lua @@ -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) diff --git a/mods/soundset/init.lua b/mods/soundset/init.lua index 652bd968..4e210f28 100755 --- a/mods/soundset/init.lua +++ b/mods/soundset/init.lua @@ -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 diff --git a/mods/u_skins/u_skins/init.lua b/mods/u_skins/u_skins/init.lua index 773bb529..95260a0d 100755 --- a/mods/u_skins/u_skins/init.lua +++ b/mods/u_skins/u_skins/init.lua @@ -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() \ No newline at end of file +u_skins.load_players() diff --git a/mods/unified_inventory/bags.lua b/mods/unified_inventory/bags.lua index adc66b43..904ed642 100755 --- a/mods/unified_inventory/bags.lua +++ b/mods/unified_inventory/bags.lua @@ -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 diff --git a/mods/unified_inventory/internal.lua b/mods/unified_inventory/internal.lua index 124d3643..3c4b5561 100755 --- a/mods/unified_inventory/internal.lua +++ b/mods/unified_inventory/internal.lua @@ -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 diff --git a/mods/unified_inventory/register.lua b/mods/unified_inventory/register.lua index 539e0f7a..5d4277b4 100755 --- a/mods/unified_inventory/register.lua +++ b/mods/unified_inventory/register.lua @@ -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 diff --git a/mods/unified_inventory/waypoints.lua b/mods/unified_inventory/waypoints.lua index 94f9f11d..d87bb9a2 100755 --- a/mods/unified_inventory/waypoints.lua +++ b/mods/unified_inventory/waypoints.lua @@ -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)