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 local formspec
if data.digiline then if data.digiline then
formspec = "size[8,2.7]".. formspec =
"item_image[0,0;1,1;pipeworks:"..data.name.."]".. "size[8.5,3]"..
"label[1,0;"..minetest.formspec_escape(itemname).."]".. "item_image[0.2,0;1,1;pipeworks:"..data.name.."]"..
"field[0.3,1.5;8.0,1;channel;"..S("Channel")..";${channel}]".. "label[1.2,0.2;"..minetest.formspec_escape(itemname).."]"..
fs_helpers.cycling_button(meta, "button[0,2;4,1", "slotseq_mode", "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 by Priority"),
S("Sequence slots Randomly"), S("Sequence slots Randomly"),
S("Sequence slots by Rotation")}).. 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 - off"),
S("Exact match - on")}) S("Exact match - on")})..
"button_exit[6.3,1.3;2,1;close;"..S("Close").."]"
else else
local exmatch_button = "" local exmatch_button = ""
if data.stackwise then if data.stackwise then
@ -425,10 +428,14 @@ for _, data in ipairs({
end end
node.on_receive_fields = function(pos, formname, fields, sender) 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) 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) minetest.get_meta(pos):set_string("channel", fields.channel)
end end

View File

@ -3,6 +3,10 @@
# License: CC-by-SA 4.0 # License: CC-by-SA 4.0
# Author: Louis Royer <4259825-lroyer@users.noreply.gitlab.com> # Author: Louis Royer <4259825-lroyer@users.noreply.gitlab.com>
## generic interaction
Set=Fixer
Close=Fermer
## digilines interfacing ## digilines interfacing
Channel=Canal Channel=Canal
@ -86,11 +90,12 @@ Sorting pneumatic tube=Tuyau pneumatique triant
## teleport tube ## teleport tube
Receive=Reception Receive=Reception
channels are public by default=Les canaux sont publics par défaut 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 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 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 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, 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. 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' 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) Pneumatic tube segment (legacy)=Segment de tuyau pneumatique (obsolète)
## vacuum tubes ## vacuum tubes
Radius=Rayon
Vacuuming Pneumatic Tube Segment=Segment de tuyau pneumatique aspirant 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=Segment de tuyau pneumatique aspirant réglable
Adjustable Vacuuming Pneumatic Tube Segment (@1m)=Segment de tuyau pneumatique aspirant réglable (@1 m) 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 # License: CC-by-SA 4.0
# Author: pevernow <3450354617@qq.com> # Author: pevernow <3450354617@qq.com>
## generic interaction
Set=
Cancel=
## digilines interfacing ## digilines interfacing
Channel=频道 Channel=频道
@ -84,11 +88,12 @@ Sorting pneumatic tube=分类管道
## teleport tube ## teleport tube
Receive=接收 Receive=接收
channels are public by default=频道默认为公开 Channels are public by default=频道默认为公开
use <player>:<channel> for fully private channels=将<player>:<channel>用于完全私人的频道 Use <player>:<channel> for fully private channels=将<player>:<channel>用于完全私人的频道
use <player>;<channel> for private receivers=使用<player>;<channel>作为私人接收器 Use <player>;<channel> for private receivers=使用<player>;<channel>作为私人接收器
Teleporting Pneumatic Tube Segment=传送管道 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, channel '@1' is reserved for exclusive use by @2=抱歉,频道‘@1保留供@2专用
Sorry, receiving from channel '@1' is reserved for @2=抱歉,从频道'@1'接收的内容已保留给'@2' Sorry, receiving from channel '@1' is reserved for @2=抱歉,从频道'@1'接收的内容已保留给'@2'
Teleportation Tube @1 on '@2'=传送管'@1'在'@2'上 Teleportation Tube @1 on '@2'=传送管'@1'在'@2'上
@ -100,7 +105,9 @@ Trash Can=垃圾箱
Pneumatic tube segment (legacy)=普通管道(旧式) Pneumatic tube segment (legacy)=普通管道(旧式)
## vacuum tubes ## vacuum tubes
Radius=
Vacuuming Pneumatic Tube Segment=拾取管道 Vacuuming Pneumatic Tube Segment=拾取管道
Adjustable Vacuuming Tube=
Adjustable Vacuuming Pneumatic Tube Segment=高级拾取管道 Adjustable Vacuuming Pneumatic Tube Segment=高级拾取管道
Adjustable Vacuuming Pneumatic Tube Segment (@1m)=高级拾取管道(@1m) Adjustable Vacuuming Pneumatic Tube Segment (@1m)=高级拾取管道(@1m)

View File

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

View File

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

View File

@ -20,7 +20,6 @@ if pipeworks.enable_detector_tube then
node_def = { node_def = {
tube = {can_go = function(pos, node, velocity, stack) tube = {can_go = function(pos, node, velocity, stack)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local name = minetest.get_node(pos).name
local nitems = meta:get_int("nitems")+1 local nitems = meta:get_int("nitems")+1
meta:set_int("nitems", nitems) meta:set_int("nitems", nitems)
local saved_pos = vector.new(pos) local saved_pos = vector.new(pos)
@ -46,8 +45,6 @@ if pipeworks.enable_detector_tube then
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_int("nitems", 1) 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) minetest.after(detector_tube_step, after_break, pos)
end, end,
}, },
@ -99,13 +96,20 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", meta:set_string("formspec",
"size[8.6,2.2]".. "size[8.5,2.2]"..
"field[0.6,0.6;8,1;channel;"..S("Channel")..";${channel}]".. "image[0.2,0;1,1;pipeworks_digiline_detector_tube_inv.png]"..
"image[0.3,1.3;1,1;pipeworks_digiline_detector_tube_inv.png]".. "label[1.2,0.2;"..S("Digiline Detecting Tube").."]"..
"label[1.6,1.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, end,
on_receive_fields = function(pos, formname, fields, sender) 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 if fields.channel then
minetest.get_meta(pos):set_string("channel", fields.channel) minetest.get_meta(pos):set_string("channel", fields.channel)
end end

View File

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

View File

@ -40,22 +40,31 @@ if pipeworks.enable_mese_sand_tube then
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_int("dist", 0) meta:set_int("dist", 0)
meta:set_string("formspec", "size[2.1,0.8]".. meta:set_string("formspec",
"image[0,0;1,1;pipeworks_mese_sand_tube_inv.png]".. "size[6.0,2.2]"..
"field[1.3,0.4;1,1;dist;radius;${dist}]".. "image[0.2,0;1,1;pipeworks_mese_sand_tube_inv.png]"..
default.gui_bg.. "label[1.2,0.2;"..S("Adjustable Vacuuming Tube").."]"..
default.gui_bg_img) "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")) meta:set_string("infotext", S("Adjustable Vacuuming Pneumatic Tube Segment"))
end, end,
on_receive_fields = function(pos,formname,fields,sender) 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 meta = minetest.get_meta(pos)
local dist = tonumber(fields.dist) local dist = tonumber(fields.dist)
if dist then if dist then
dist = math.max(0, dist) dist = math.max(0, dist)
dist = math.min(8, dist) dist = math.min(8, dist)
meta:set_int("dist", 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
end, end,
}, },