Improve formspecs for better mobile usability and consistency

This commit is contained in:
hlqkj 2021-04-02 19:47:48 +00:00 committed by Vanessa Dannenberg
parent a6e4f2dceb
commit 4add40705f
8 changed files with 96 additions and 49 deletions

View File

@ -14,17 +14,20 @@ local function set_filter_formspec(data, meta)
local formspec
if data.digiline then
formspec = "size[8,2.7]"..
"item_image[0,0;1,1;pipeworks:"..data.name.."]"..
"label[1,0;"..minetest.formspec_escape(itemname).."]"..
"field[0.3,1.5;8.0,1;channel;"..S("Channel")..";${channel}]"..
fs_helpers.cycling_button(meta, "button[0,2;4,1", "slotseq_mode",
formspec =
"size[8.5,3]"..
"item_image[0.2,0;1,1;pipeworks:"..data.name.."]"..
"label[1.2,0.2;"..minetest.formspec_escape(itemname).."]"..
"field[0.5,1.6;4.6,1;channel;"..S("Channel")..";${channel}]"..
"button[4.8,1.3;1.5,1;set_channel;"..S("Set").."]"..
fs_helpers.cycling_button(meta, "button[0.2,2.3;4.05,1", "slotseq_mode",
{S("Sequence slots by Priority"),
S("Sequence slots Randomly"),
S("Sequence slots by Rotation")})..
fs_helpers.cycling_button(meta, "button[4,2;4,1", "exmatch_mode",
fs_helpers.cycling_button(meta, "button[4.25,2.3;4.05,1", "exmatch_mode",
{S("Exact match - off"),
S("Exact match - on")})
S("Exact match - on")})..
"button_exit[6.3,1.3;2,1;close;"..S("Close").."]"
else
local exmatch_button = ""
if data.stackwise then
@ -425,10 +428,14 @@ for _, data in ipairs({
end
node.on_receive_fields = function(pos, formname, fields, sender)
if not pipeworks.may_configure(pos, sender) then return end
if (fields.quit and not fields.key_enter_field)
or not pipeworks.may_configure(pos, sender) then
return
end
fs_helpers.on_receive_fields(pos, fields)
if fields.channel then
if fields.channel and (fields.key_enter_field == "channel" or fields.set_channel) then
minetest.get_meta(pos):set_string("channel", fields.channel)
end

View File

@ -3,6 +3,10 @@
# License: CC-by-SA 4.0
# Author: Louis Royer <4259825-lroyer@users.noreply.gitlab.com>
## generic interaction
Set=Fixer
Close=Fermer
## digilines interfacing
Channel=Canal
@ -86,11 +90,12 @@ Sorting pneumatic tube=Tuyau pneumatique triant
## teleport tube
Receive=Reception
channels are public by default=Les canaux sont publics par défaut
use <player>:<channel> for fully private channels=Utilisez <joueur>:<canal> pour un canal entièrement privé
use <player>;<channel> for private receivers=Utilisez <joueur>;<canal> pour une réception privée
Channels are public by default=Les canaux sont publics par défaut
Use <player>:<channel> for fully private channels=Utilisez <joueur>:<canal> pour un canal entièrement privé
Use <player>;<channel> for private receivers=Utilisez <joueur>;<canal> pour une réception privée
Teleporting Pneumatic Tube Segment=Segment de tuyau pneumatique téléporteur
unconfigured Teleportation Tube=Tuyau téléporteur non-configuré
Teleporting Tube=Tuyau pneumatique téléporteur
Unconfigured Teleportation Tube=Tuyau téléporteur non-configuré
Sorry, channel '@1' is reserved for exclusive use by @2=Désolé, le canal '@1' est réservé exclusivement à lutilisateur @2.
Sorry, receiving from channel '@1' is reserved for @2=Désolé, la réception depuis le canal '@1' est réservée pour @2.
Teleportation Tube @1 on '@2'=Tuyau de téléportation @1 sur '@2'
@ -102,7 +107,9 @@ Trash Can=Poubelle
Pneumatic tube segment (legacy)=Segment de tuyau pneumatique (obsolète)
## vacuum tubes
Radius=Rayon
Vacuuming Pneumatic Tube Segment=Segment de tuyau pneumatique aspirant
Adjustable Vacuuming Tube=Tuyau pneumatique aspirant réglable
Adjustable Vacuuming Pneumatic Tube Segment=Segment de tuyau pneumatique aspirant réglable
Adjustable Vacuuming Pneumatic Tube Segment (@1m)=Segment de tuyau pneumatique aspirant réglable (@1 m)

View File

@ -2,6 +2,10 @@
# License: CC-by-SA 4.0
# Author: pevernow <3450354617@qq.com>
## generic interaction
Set=
Cancel=
## digilines interfacing
Channel=频道
@ -84,11 +88,12 @@ Sorting pneumatic tube=分类管道
## teleport tube
Receive=接收
channels are public by default=频道默认为公开
use <player>:<channel> for fully private channels=将<player>:<channel>用于完全私人的频道
use <player>;<channel> for private receivers=使用<player>;<channel>作为私人接收器
Channels are public by default=频道默认为公开
Use <player>:<channel> for fully private channels=将<player>:<channel>用于完全私人的频道
Use <player>;<channel> for private receivers=使用<player>;<channel>作为私人接收器
Teleporting Pneumatic Tube Segment=传送管道
unconfigured Teleportation Tube=未配置的传送管道
Teleporting Tube=
Unconfigured Teleportation Tube=未配置的传送管道
Sorry, channel '@1' is reserved for exclusive use by @2=抱歉,频道‘@1保留供@2专用
Sorry, receiving from channel '@1' is reserved for @2=抱歉,从频道'@1'接收的内容已保留给'@2'
Teleportation Tube @1 on '@2'=传送管'@1'在'@2'上
@ -100,7 +105,9 @@ Trash Can=垃圾箱
Pneumatic tube segment (legacy)=普通管道(旧式)
## vacuum tubes
Radius=
Vacuuming Pneumatic Tube Segment=拾取管道
Adjustable Vacuuming Tube=
Adjustable Vacuuming Pneumatic Tube Segment=高级拾取管道
Adjustable Vacuuming Pneumatic Tube Segment (@1m)=高级拾取管道(@1m)

View File

@ -3,6 +3,10 @@
# License: CC-by-SA 4.0
# Author:
## generic interaction
Set=
Cancel=
## digilines interfacing
Channel=
@ -86,11 +90,12 @@ Sorting pneumatic tube=
## teleport tube
Receive=
channels are public by default=
use <player>:<channel> for fully private channels=
use <player>;<channel> for private receivers=
Channels are public by default=
Use <player>:<channel> for fully private channels=
Use <player>;<channel> for private receivers=
Teleporting Pneumatic Tube Segment=
unconfigured Teleportation Tube=
Teleporting Tube=
Unconfigured Teleportation Tube=
Sorry, channel '@1' is reserved for exclusive use by @2=
Sorry, receiving from channel '@1' is reserved for @2=
Teleportation Tube @1 on '@2'=
@ -102,7 +107,9 @@ Trash Can=
Pneumatic tube segment (legacy)=
## vacuum tubes
Radius=
Vacuuming Pneumatic Tube Segment=
Adjustable Vacuuming Tube=
Adjustable Vacuuming Pneumatic Tube Segment=
Adjustable Vacuuming Pneumatic Tube Segment (@1m)=

View File

@ -31,7 +31,6 @@ end
function pipeworks.check_and_wear_hammer(player)
local itemstack = player:get_wielded_item()
local wieldname = itemstack:get_name()
local playername = player:get_player_name()
if allowed_hammers[wieldname] then
itemstack:add_wear(1000)
player:set_wielded_item(itemstack)

View File

@ -20,7 +20,6 @@ if pipeworks.enable_detector_tube then
node_def = {
tube = {can_go = function(pos, node, velocity, stack)
local meta = minetest.get_meta(pos)
local name = minetest.get_node(pos).name
local nitems = meta:get_int("nitems")+1
meta:set_int("nitems", nitems)
local saved_pos = vector.new(pos)
@ -46,8 +45,6 @@ if pipeworks.enable_detector_tube then
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_int("nitems", 1)
local name = minetest.get_node(pos).name
local saved_pos = vector.new(pos)
minetest.after(detector_tube_step, after_break, pos)
end,
},
@ -99,13 +96,20 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"size[8.6,2.2]"..
"field[0.6,0.6;8,1;channel;"..S("Channel")..";${channel}]"..
"image[0.3,1.3;1,1;pipeworks_digiline_detector_tube_inv.png]"..
"label[1.6,1.2;"..S("Digiline Detecting Tube").."]"
"size[8.5,2.2]"..
"image[0.2,0;1,1;pipeworks_digiline_detector_tube_inv.png]"..
"label[1.2,0.2;"..S("Digiline Detecting Tube").."]"..
"field[0.5,1.6;4.6,1;channel;"..S("Channel")..";${channel}]"..
"button[4.8,1.3;1.5,1;set_channel;"..S("Set").."]"..
"button_exit[6.3,1.3;2,1;close;"..S("Close").."]"
)
end,
on_receive_fields = function(pos, formname, fields, sender)
if (fields.quit and not fields.key_enter_field)
or (fields.key_enter_field ~= "channel" and not fields.set_channel)
or not pipeworks.may_configure(pos, sender) then
return
end
if fields.channel then
minetest.get_meta(pos):set_string("channel", fields.channel)
end

View File

@ -127,16 +127,22 @@ end
local function update_meta(meta, can_receive)
meta:set_int("can_receive", can_receive and 1 or 0)
local cr_state = can_receive and "on" or "off"
meta:set_string("formspec","size[8.6,2.2]"..
"field[0.6,0.6;7,1;channel;"..S("Channel")..";${channel}]"..
"label[7.3,0;"..S("Receive").."]"..
"image_button[7.3,0.3;1,0.6;pipeworks_button_" .. cr_state .. ".png;cr" .. (can_receive and 0 or 1) .. ";;;false;pipeworks_button_interm.png]"..
"image[0.3,1.3;1,1;pipeworks_teleport_tube_inv.png]"..
"label[1.6,1.2;"..S("channels are public by default").."]" ..
"label[1.6,1.5;"..S("use <player>:<channel> for fully private channels").."]" ..
"label[1.6,1.8;"..S("use <player>\\;<channel> for private receivers").."]" ..
default.gui_bg..
default.gui_bg_img)
local itext = S("Channels are public by default").."\n"..
S("Use <player>:<channel> for fully private channels").."\n"..
S("Use <player>\\;<channel> for private receivers")
meta:set_string("formspec",
"size[8.5,3.5]"..
"image[0.2,o;1,1;pipeworks_teleport_tube_inv.png]"..
"label[1.2,0.2;"..S("Teleporting Tube").."]"..
"field[0.5,1.6;4.6,1;channel;"..S("Channel")..";${channel}]"..
"button[4.8,1.3;1.5,1;set_channel;"..S("Set").."]"..
"label[7.0,0;"..S("Receive").."]"..
"image_button[7.0,0.5;1,0.6;pipeworks_button_" .. cr_state .. ".png;cr" .. (can_receive and 0 or 1) .. ";;;false;pipeworks_button_interm.png]"..
"button_exit[6.3,1.3;2,1;close;"..S("Close").."]"..
"label[0.2,2.3;"..itext.."]"..
default.gui_bg..
default.gui_bg_img)
end
pipeworks.register_tube("pipeworks:teleport_tube", {
@ -170,10 +176,11 @@ pipeworks.register_tube("pipeworks:teleport_tube", {
on_construct = function(pos)
local meta = minetest.get_meta(pos)
update_meta(meta, true)
meta:set_string("infotext", S("unconfigured Teleportation Tube"))
meta:set_string("infotext", S("Unconfigured Teleportation Tube"))
end,
on_receive_fields = function(pos,formname,fields,sender)
if not fields.channel -- ignore escaping or clientside manipulation of the form
or (fields.quit and not fields.key_enter_field)
or not pipeworks.may_configure(pos, sender) then
return
end
@ -207,7 +214,7 @@ pipeworks.register_tube("pipeworks:teleport_tube", {
-- was the channel changed?
local channel = meta:get_string("channel")
if new_channel ~= channel then
if new_channel ~= channel and (fields.key_enter_field == "channel" or fields.set_channel) then
channel = new_channel
meta:set_string("channel", channel)
dirty = true
@ -233,7 +240,7 @@ pipeworks.register_tube("pipeworks:teleport_tube", {
else
-- remove empty channel tubes, to not have to search through them
remove_tube(pos)
meta:set_string("infotext", S("unconfigured Teleportation Tube"))
meta:set_string("infotext", S("Unconfigured Teleportation Tube"))
end
end
end,

View File

@ -40,22 +40,31 @@ if pipeworks.enable_mese_sand_tube then
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_int("dist", 0)
meta:set_string("formspec", "size[2.1,0.8]"..
"image[0,0;1,1;pipeworks_mese_sand_tube_inv.png]"..
"field[1.3,0.4;1,1;dist;radius;${dist}]"..
default.gui_bg..
default.gui_bg_img)
meta:set_string("formspec",
"size[6.0,2.2]"..
"image[0.2,0;1,1;pipeworks_mese_sand_tube_inv.png]"..
"label[1.2,0.2;"..S("Adjustable Vacuuming Tube").."]"..
"field[0.5,1.6;2.1,1;dist;"..S("Radius")..";${dist}]"..
"button[2.3,1.3;1.5,1;set_dist;"..S("Set").."]"..
"button_exit[3.8,1.3;2,1;close;"..S("Close").."]"..
default.gui_bg..
default.gui_bg_img)
meta:set_string("infotext", S("Adjustable Vacuuming Pneumatic Tube Segment"))
end,
on_receive_fields = function(pos,formname,fields,sender)
if not pipeworks.may_configure(pos, sender) then return end
if (fields.quit and not fields.key_enter_field)
or (fields.key_enter_field ~= "dist" and not fields.set_dist)
or not pipeworks.may_configure(pos, sender) then
return
end
local meta = minetest.get_meta(pos)
local dist = tonumber(fields.dist)
if dist then
dist = math.max(0, dist)
dist = math.min(8, dist)
meta:set_int("dist", dist)
meta:set_string("infotext", (S("Adjustable Vacuuming Pneumatic Tube Segment (@1m)", dist)))
meta:set_string("infotext", S("Adjustable Vacuuming Pneumatic Tube Segment (@1m)", dist))
end
end,
},