forked from minetest-mods/unified_inventory
Compare commits
2 Commits
aa04d4539f
...
match_copy
Author | SHA1 | Date | |
---|---|---|---|
88b3033477 | |||
19e14aa21e |
16
README.md
16
README.md
@ -71,9 +71,6 @@ From http://www.clker.com (Public Domain, CC-BY-4.0):
|
||||
* [`ui_pencil_icon.pnc`](http://www.clker.com/clipart-2256.html)
|
||||
* [`ui_waypoint_set_icon.png`](http://www.clker.com/clipart-larger-flag.html)
|
||||
|
||||
From https://www.svgrepo.com (CC-BY)
|
||||
* [`ui_teleport.png`](https://www.svgrepo.com/svg/321565/teleport)
|
||||
|
||||
Everaldo Coelho (YellowIcon) (LGPL v2.1+):
|
||||
|
||||
* [`ui_craftguide_icon.png` / `ui_craft_icon.png`](http://commons.wikimedia.org/wiki/File:Advancedsettings.png)
|
||||
@ -105,16 +102,3 @@ Other files from Wikimedia Commons:
|
||||
RealBadAngel: (CC-BY-4.0)
|
||||
|
||||
* Everything else.
|
||||
|
||||
|
||||
## Sounds
|
||||
|
||||
* [`bell.ogg`](https://freesound.org/people/bennstir/sounds/81072/) by bennstir, CC 4.0
|
||||
* [`electricity.ogg`](https://freesound.org/people/Halleck/sounds/19486/) by Halleck, CC 4.0 (cut)
|
||||
* [`pageflip1.ogg`](https://freesound.org/people/themfish/sounds/45823/) by themfish, CC 4.0 (cut, slowed down)
|
||||
* `pageflip2.ogg` (derived from `pageflip1.ogg`)
|
||||
* [`trash.ogg`](https://freesound.org/people/OwlStorm/sounds/151231/) by OwlStorm, CC 0 (speed up)
|
||||
* [`trash_all.ogg`](https://freesound.org/people/abel_K/sounds/68280/) by abel_K, Sampling Plus 1.0 (speed up)
|
||||
* [`ui_click.ogg`](https://freesound.org/people/lartti/sounds/527569/) by lartti, CC 0 (cut)
|
||||
* [`ui_morning.ogg`](https://freesound.org/people/InspectorJ/sounds/439472/) by InspectorJ, CC 4.0
|
||||
* [`ui_owl.ogg`](https://freesound.org/people/manda_g/sounds/54987/) by manda_g, Sampling Plus 1.0 (cut)
|
||||
|
65
bags.lua
65
bags.lua
@ -10,26 +10,25 @@ local F = minetest.formspec_escape
|
||||
local ui = unified_inventory
|
||||
|
||||
ui.register_page("bags", {
|
||||
get_formspec = function(player, perplayer_formspec)
|
||||
get_formspec = function(player)
|
||||
local player_name = player:get_player_name()
|
||||
local std_inv_x = perplayer_formspec.std_inv_x
|
||||
local formspec = {
|
||||
perplayer_formspec.standard_inv_bg,
|
||||
"label[", perplayer_formspec.form_header_x, ",",
|
||||
perplayer_formspec.form_header_y, ";", F(S("Bags")), "]",
|
||||
return { formspec = table.concat({
|
||||
ui.style_full.standard_inv_bg,
|
||||
ui.single_slot(0.925, 1.5),
|
||||
ui.single_slot(3.425, 1.5),
|
||||
ui.single_slot(5.925, 1.5),
|
||||
ui.single_slot(8.425, 1.5),
|
||||
"label["..ui.style_full.form_header_x..","..ui.style_full.form_header_y..";" .. F(S("Bags")) .. "]",
|
||||
"button[0.6125,2.75;1.875,0.75;bag1;" .. F(S("Bag @1", 1)) .. "]",
|
||||
"button[3.1125,2.75;1.875,0.75;bag2;" .. F(S("Bag @1", 2)) .. "]",
|
||||
"button[5.6125,2.75;1.875,0.75;bag3;" .. F(S("Bag @1", 3)) .. "]",
|
||||
"button[8.1125,2.75;1.875,0.75;bag4;" .. F(S("Bag @1", 4)) .. "]",
|
||||
"listcolors[#00000000;#00000000]",
|
||||
}
|
||||
|
||||
for i = 1, 4 do
|
||||
local x = std_inv_x + i * 2.5
|
||||
formspec[#formspec + 1] = ui.single_slot(x - 1.875, 1.5)
|
||||
formspec[#formspec + 1] = string.format("list[detached:%s_bags;bag%i;%.3f,1.65;1,1;]",
|
||||
F(player_name), i, x - 1.725)
|
||||
formspec[#formspec + 1] = string.format("button[%.4f,2.75;1.875,0.75;bag%i;%s]",
|
||||
x - 2.1875, i, F(S("Bag @1", i)))
|
||||
end
|
||||
|
||||
return { formspec = table.concat(formspec) }
|
||||
"list[detached:" .. F(player_name) .. "_bags;bag1;1.075,1.65;1,1;]",
|
||||
"list[detached:" .. F(player_name) .. "_bags;bag2;3.575,1.65;1,1;]",
|
||||
"list[detached:" .. F(player_name) .. "_bags;bag3;6.075,1.65;1,1;]",
|
||||
"list[detached:" .. F(player_name) .. "_bags;bag4;8.575,1.65;1,1;]"
|
||||
}) }
|
||||
end,
|
||||
})
|
||||
|
||||
@ -37,6 +36,7 @@ ui.register_button("bags", {
|
||||
type = "image",
|
||||
image = "ui_bags_icon.png",
|
||||
tooltip = S("Bags"),
|
||||
hide_lite=true
|
||||
})
|
||||
|
||||
local function get_player_bag_stack(player, i)
|
||||
@ -48,38 +48,23 @@ end
|
||||
|
||||
for bag_i = 1, 4 do
|
||||
ui.register_page("bag" .. bag_i, {
|
||||
get_formspec = function(player, perplayer_formspec)
|
||||
get_formspec = function(player)
|
||||
local stack = get_player_bag_stack(player, bag_i)
|
||||
local image = stack:get_definition().inventory_image
|
||||
local slots = stack:get_definition().groups.bagslots
|
||||
local std_inv_x = perplayer_formspec.std_inv_x
|
||||
local lite_mode = perplayer_formspec.is_lite_mode
|
||||
|
||||
local bag_inv_y, header_x, header_y = 1.5, 0.3, 0.65
|
||||
if lite_mode then
|
||||
bag_inv_y = 0.5
|
||||
header_x = perplayer_formspec.form_header_x
|
||||
header_y = perplayer_formspec.form_header_y
|
||||
end
|
||||
|
||||
local formspec = {
|
||||
perplayer_formspec.standard_inv_bg,
|
||||
ui.make_inv_img_grid(std_inv_x, bag_inv_y, 8, slots/8),
|
||||
"label[", header_x, ",", header_y, ";", F(S("Bag @1", bag_i)), "]",
|
||||
ui.style_full.standard_inv_bg,
|
||||
ui.make_inv_img_grid(0.3, 1.5, 8, slots/8),
|
||||
"image[9.2,0.4;1,1;" .. image .. "]",
|
||||
"label[0.3,0.65;" .. F(S("Bag @1", bag_i)) .. "]",
|
||||
"listcolors[#00000000;#00000000]",
|
||||
"listring[current_player;main]",
|
||||
string.format("list[current_player;bag%icontents;%f,%f;8,3;]",
|
||||
bag_i, std_inv_x + ui.list_img_offset, bag_inv_y + ui.list_img_offset),
|
||||
"listring[current_name;bag", bag_i, "contents]",
|
||||
bag_i, 0.3 + ui.list_img_offset, 1.5 + ui.list_img_offset),
|
||||
"listring[current_name;bag" .. bag_i .. "contents]",
|
||||
}
|
||||
|
||||
if lite_mode then
|
||||
return { formspec = table.concat(formspec) }
|
||||
end
|
||||
|
||||
local n = #formspec + 1
|
||||
formspec[n] = "image[" .. std_inv_x + 8.9 .. ",0.4;1,1;" .. image .. "]"
|
||||
n = n + 1
|
||||
|
||||
local player_name = player:get_player_name() -- For if statement.
|
||||
if ui.trash_enabled
|
||||
|
@ -57,47 +57,30 @@ end)
|
||||
local function apply_new_filter(player, search_text, new_dir)
|
||||
local player_name = player:get_player_name()
|
||||
|
||||
minetest.sound_play("ui_click", {to_player=player_name, gain = 0.1})
|
||||
minetest.sound_play("click", {to_player=player_name, gain = 0.1})
|
||||
ui.apply_filter(player, search_text, new_dir)
|
||||
ui.current_searchbox[player_name] = search_text
|
||||
ui.set_inventory_formspec(player, ui.current_page[player_name])
|
||||
end
|
||||
|
||||
-- Search box handling
|
||||
local function receive_fields_searchbox(player, formname, fields)
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
local player_name = player:get_player_name()
|
||||
|
||||
-- always take new search text, even if not searching on it yet
|
||||
if fields.searchbox and fields.searchbox ~= ui.current_searchbox[player_name] then
|
||||
ui.current_searchbox[player_name] = fields.searchbox
|
||||
end
|
||||
local ui_peruser,draw_lite_mode = unified_inventory.get_per_player_formspec(player_name)
|
||||
|
||||
if fields.searchbutton
|
||||
or fields.key_enter_field == "searchbox" then
|
||||
|
||||
if ui.current_searchbox[player_name] ~= ui.activefilter[player_name] then
|
||||
ui.apply_filter(player, ui.current_searchbox[player_name], "nochange")
|
||||
ui.set_inventory_formspec(player, ui.current_page[player_name])
|
||||
minetest.sound_play("paperflip2",
|
||||
{to_player=player_name, gain = 1.0})
|
||||
end
|
||||
elseif fields.searchresetbutton then
|
||||
if ui.activefilter[player_name] ~= "" then
|
||||
apply_new_filter(player, "", "nochange")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname ~= "" then
|
||||
return
|
||||
end
|
||||
|
||||
receive_fields_searchbox(player, formname, fields)
|
||||
-- always take new search text, even if not searching on it yet
|
||||
local dirty_search_filter = false
|
||||
|
||||
local player_name = player:get_player_name()
|
||||
if fields.searchbox
|
||||
and fields.searchbox ~= unified_inventory.current_searchbox[player_name] then
|
||||
unified_inventory.current_searchbox[player_name] = fields.searchbox
|
||||
dirty_search_filter = true
|
||||
end
|
||||
|
||||
local ui_peruser,draw_lite_mode = unified_inventory.get_per_player_formspec(player_name)
|
||||
|
||||
local clicked_category
|
||||
for name, value in pairs(fields) do
|
||||
@ -131,7 +114,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
for i, def in pairs(unified_inventory.buttons) do
|
||||
if fields[def.name] then
|
||||
def.action(player)
|
||||
minetest.sound_play("ui_click",
|
||||
minetest.sound_play("click",
|
||||
{to_player=player_name, gain = 0.1})
|
||||
return
|
||||
end
|
||||
@ -196,7 +179,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
end
|
||||
end
|
||||
if clicked_item then
|
||||
minetest.sound_play("ui_click",
|
||||
minetest.sound_play("click",
|
||||
{to_player=player_name, gain = 0.1})
|
||||
local page = unified_inventory.current_page[player_name]
|
||||
local player_creative = unified_inventory.is_creative(player_name)
|
||||
@ -218,11 +201,25 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
end
|
||||
end
|
||||
|
||||
if fields.searchbutton
|
||||
or fields.key_enter_field == "searchbox" then
|
||||
if dirty_search_filter then
|
||||
ui.apply_filter(player, ui.current_searchbox[player_name], "nochange")
|
||||
ui.set_inventory_formspec(player, ui.current_page[player_name])
|
||||
minetest.sound_play("paperflip2",
|
||||
{to_player=player_name, gain = 1.0})
|
||||
end
|
||||
elseif fields.searchresetbutton then
|
||||
if ui.activefilter[player_name] ~= "" then
|
||||
apply_new_filter(player, "", "nochange")
|
||||
end
|
||||
end
|
||||
|
||||
-- alternate buttons
|
||||
if not (fields.alternate or fields.alternate_prev) then
|
||||
return
|
||||
end
|
||||
minetest.sound_play("ui_click",
|
||||
minetest.sound_play("click",
|
||||
{to_player=player_name, gain = 0.1})
|
||||
local item_name = unified_inventory.current_item[player_name]
|
||||
if not item_name then
|
||||
|
2
init.lua
2
init.lua
@ -195,5 +195,3 @@ end
|
||||
dofile(modpath.."/item_names.lua")
|
||||
dofile(modpath.."/waypoints.lua")
|
||||
dofile(modpath.."/legacy.lua") -- mod compatibility
|
||||
|
||||
minetest.log("action", "[unified_inventory] loaded.")
|
||||
|
@ -274,11 +274,9 @@ local function formspec_add_item_browser(player, formspec, ui_peruser)
|
||||
end
|
||||
end
|
||||
end
|
||||
formspec[n] = "style[page_number;content_offset=0]"
|
||||
formspec[n + 1] = string.format("image_button[%f,%f;%f,0.4;;page_number;%s: %s;false;false;]",
|
||||
ui_peruser.page_buttons_x,
|
||||
ui_peruser.page_buttons_y + ui_peruser.btn_spc * 2 - 0.1,
|
||||
ui_peruser.btn_spc * (bn - 1) + ui_peruser.btn_size,
|
||||
formspec[n] = string.format("label[%f,%f;%s: %s]",
|
||||
ui_peruser.page_buttons_x + ui_peruser.btn_spc * (ui_peruser.is_lite_mode and 1 or 2),
|
||||
ui_peruser.page_buttons_y + 0.1 + ui_peruser.btn_spc * 2,
|
||||
F(S("Page")), S("@1 of @2",page2,pagemax))
|
||||
end
|
||||
|
||||
|
57
register.lua
57
register.lua
@ -41,6 +41,55 @@ ui.register_button("craftguide", {
|
||||
tooltip = S("Crafting Guide")
|
||||
})
|
||||
|
||||
ui.register_button("home_gui_set", {
|
||||
type = "image",
|
||||
image = "ui_sethome_icon.png",
|
||||
tooltip = S("Set home position"),
|
||||
hide_lite=true,
|
||||
action = function(player)
|
||||
local player_name = player:get_player_name()
|
||||
if minetest.check_player_privs(player_name, {home=true}) then
|
||||
ui.set_home(player, player:get_pos())
|
||||
local home = ui.home_pos[player_name]
|
||||
if home ~= nil then
|
||||
minetest.sound_play("dingdong",
|
||||
{to_player=player_name, gain = 1.0})
|
||||
minetest.chat_send_player(player_name,
|
||||
S("Home position set to: @1", minetest.pos_to_string(home)))
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(player_name,
|
||||
S("You don't have the \"home\" privilege!"))
|
||||
ui.set_inventory_formspec(player, ui.current_page[player_name])
|
||||
end
|
||||
end,
|
||||
condition = function(player)
|
||||
return minetest.check_player_privs(player:get_player_name(), {home=true})
|
||||
end,
|
||||
})
|
||||
|
||||
ui.register_button("home_gui_go", {
|
||||
type = "image",
|
||||
image = "ui_gohome_icon.png",
|
||||
tooltip = S("Go home"),
|
||||
hide_lite=true,
|
||||
action = function(player)
|
||||
local player_name = player:get_player_name()
|
||||
if minetest.check_player_privs(player_name, {home=true}) then
|
||||
if ui.go_home(player) then
|
||||
minetest.sound_play("teleport", {to_player = player_name})
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(player_name,
|
||||
S("You don't have the \"home\" privilege!"))
|
||||
ui.set_inventory_formspec(player, ui.current_page[player_name])
|
||||
end
|
||||
end,
|
||||
condition = function(player)
|
||||
return minetest.check_player_privs(player:get_player_name(), {home=true})
|
||||
end,
|
||||
})
|
||||
|
||||
ui.register_button("misc_set_day", {
|
||||
type = "image",
|
||||
image = "ui_sun_icon.png",
|
||||
@ -49,7 +98,7 @@ ui.register_button("misc_set_day", {
|
||||
action = function(player)
|
||||
local player_name = player:get_player_name()
|
||||
if minetest.check_player_privs(player_name, {settime=true}) then
|
||||
minetest.sound_play("ui_morning",
|
||||
minetest.sound_play("birds",
|
||||
{to_player=player_name, gain = 1.0})
|
||||
minetest.set_timeofday((6000 % 24000) / 24000)
|
||||
minetest.chat_send_player(player_name,
|
||||
@ -73,7 +122,7 @@ ui.register_button("misc_set_night", {
|
||||
action = function(player)
|
||||
local player_name = player:get_player_name()
|
||||
if minetest.check_player_privs(player_name, {settime=true}) then
|
||||
minetest.sound_play("ui_owl",
|
||||
minetest.sound_play("owl",
|
||||
{to_player=player_name, gain = 1.0})
|
||||
minetest.set_timeofday((21000 % 24000) / 24000)
|
||||
minetest.chat_send_player(player_name,
|
||||
@ -134,14 +183,14 @@ ui.register_page("craft", {
|
||||
local n=#formspec+1
|
||||
|
||||
if ui.trash_enabled or ui.is_creative(player_name) or minetest.get_player_privs(player_name).give then
|
||||
formspec[n] = string.format("label[%f,%f;%s]", craftx + 6.35, crafty + 2.3, F(S("Trash:")))
|
||||
formspec[n] = string.format("label[%f,%f;%s]", craftx + 6.45, crafty + 2.4, F(S("Trash:")))
|
||||
formspec[n+1] = ui.make_trash_slot(craftx + 6.25, crafty + 2.5)
|
||||
n=n + 2
|
||||
end
|
||||
|
||||
if ui.is_creative(player_name) then
|
||||
formspec[n] = ui.single_slot(craftx - 2.5, crafty + 2.5)
|
||||
formspec[n+1] = string.format("label[%f,%f;%s]", craftx - 2.4, crafty + 2.3, F(S("Refill:")))
|
||||
formspec[n+1] = string.format("label[%f,%f;%s]", craftx - 2.3, crafty + 2.4,F(S("Refill:")))
|
||||
formspec[n+2] = string.format("list[detached:%srefill;main;%f,%f;1,1;]",
|
||||
F(player_name), craftx - 2.5 + ui.list_img_offset, crafty + 2.5 + ui.list_img_offset)
|
||||
end
|
||||
|
BIN
sounds/birds.ogg
Normal file
BIN
sounds/birds.ogg
Normal file
Binary file not shown.
BIN
sounds/owl.ogg
Normal file
BIN
sounds/owl.ogg
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB |
@ -140,49 +140,36 @@ ui.register_page("waypoints", {
|
||||
|
||||
-- Main buttons:
|
||||
local btnlist = {
|
||||
-- 1. formspec name
|
||||
-- 2. button image
|
||||
-- 3. translation text
|
||||
{
|
||||
"toggle_waypoint",
|
||||
waypoint.active and "ui_on_icon.png" or "ui_off_icon.png",
|
||||
waypoint.active and S("Hide waypoint") or S("Show waypoint")
|
||||
},
|
||||
{
|
||||
"rename_waypoint",
|
||||
"ui_pencil_icon.png",
|
||||
S("Edit waypoint name")
|
||||
},
|
||||
{
|
||||
"set_waypoint",
|
||||
set_waypoint = {
|
||||
"ui_waypoint_set_icon.png",
|
||||
S("Set waypoint to current location")
|
||||
},
|
||||
{
|
||||
"toggle_display_pos",
|
||||
toggle_waypoint = {
|
||||
waypoint.active and "ui_on_icon.png" or "ui_off_icon.png",
|
||||
waypoint.active and S("Hide waypoint") or S("Show waypoint")
|
||||
},
|
||||
toggle_display_pos = {
|
||||
waypoint.display_pos and "ui_green_icon_background.png^ui_xyz_icon.png" or "ui_red_icon_background.png^ui_xyz_icon.png^(ui_no.png^[transformR90)",
|
||||
waypoint.display_pos and S("Hide coordinates") or S("Show coordinates")
|
||||
},
|
||||
{
|
||||
"toggle_color",
|
||||
toggle_color = {
|
||||
"ui_circular_arrows_icon.png",
|
||||
S("Change color of waypoint display")
|
||||
},
|
||||
rename_waypoint = {
|
||||
"ui_pencil_icon.png",
|
||||
S("Edit waypoint name")
|
||||
}
|
||||
}
|
||||
if minetest.get_player_privs(player_name).teleport then
|
||||
table.insert(btnlist, {
|
||||
"teleport_waypoint",
|
||||
"ui_teleport.png",
|
||||
S("Teleport to waypoint")
|
||||
})
|
||||
end
|
||||
|
||||
for i, def in pairs(btnlist) do
|
||||
local x = 4
|
||||
for name, def in pairs(btnlist) do
|
||||
formspec[n] = string.format("image_button[%f,%f;%f,%f;%s;%s%i;]",
|
||||
wp_buttons_rj + ui.style_full.btn_spc * (i - #btnlist), wp_bottom_row,
|
||||
wp_buttons_rj - ui.style_full.btn_spc * x, wp_bottom_row,
|
||||
ui.style_full.btn_size, ui.style_full.btn_size,
|
||||
def[2], def[1], sel)
|
||||
formspec[n+1] = "tooltip["..def[1]..sel..";"..F(def[3]).."]"
|
||||
def[1], name, sel)
|
||||
formspec[n+1] = "tooltip["..name..sel..";"..F(def[2]).."]"
|
||||
x = x - 1
|
||||
n = n + 2
|
||||
end
|
||||
|
||||
@ -326,13 +313,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
update_formspec = true
|
||||
end
|
||||
|
||||
if fields["teleport_waypoint" .. i] and waypoint.world_pos then
|
||||
if minetest.get_player_privs(player_name).teleport then
|
||||
minetest.sound_play("teleport", {to_player = player_name})
|
||||
player:set_pos(waypoint.world_pos)
|
||||
end
|
||||
end
|
||||
|
||||
if hit then
|
||||
-- Save first
|
||||
waypoints.data[i] = waypoint
|
||||
@ -343,7 +323,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
update_hud(player, waypoints, temp, i)
|
||||
end
|
||||
if update_formspec then
|
||||
minetest.sound_play("ui_click", {to_player=player_name, gain = 0.1})
|
||||
ui.set_inventory_formspec(player, "waypoints")
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user