unify formspec cration files

This commit is contained in:
Dirk Sohler 2021-04-02 08:57:00 +02:00
parent 7e0713a67a
commit b3b23e8860
No known key found for this signature in database
GPG Key ID: B9751241BD7D4E1A
4 changed files with 34 additions and 22 deletions

@ -7,7 +7,7 @@
-- Localise needed functions
local m = mtimer
local S = m.translator
local fe = minetest.formspec_escape
local esc = minetest.formspec_escape
-- Formspecs are loaded and shown by individual functions. The function name
@ -124,7 +124,7 @@ mtimer.dialog.ingame_time_format = function (player_name)
show_to = player_name,
formspec = {
'field_close_on_enter[format;false]',
'field[0,0;+contentWidth,0.5;format;;'..fe(time_data.format)..']',
'field[0,0;+contentWidth,0.5;format;;'..esc(time_data.format)..']',
'container[0,0.9]',
'label[2.8,0;'..S('Variable')..']',
'label[4.25,0;'..S('Current Value')..']',
@ -135,7 +135,7 @@ mtimer.dialog.ingame_time_format = function (player_name)
'label[0,1.7;'..S('Ingame Timestamp')..'] label[2.8,1.7;{its}] label[4.25,1.7;'..time_data.ingame_timestamp..']',
'box[0,2;+contentWidth,0.02;#ffffff]',
'label[0,2.25;'..S('Current Result')..']',
'label[2.8,2.25;'..fe(time_data.formatted)..']',
'label[2.8,2.25;'..esc(time_data.formatted)..']',
'container_end[]'
}
})
@ -178,7 +178,7 @@ mtimer.dialog.session_duration_format = function (player_name)
height = 3.8,
formspec = {
'field_close_on_enter[format;false]',
'field[0,0;+contentWidth,0.5;format;;'..fe(time_data.format)..']',
'field[0,0;+contentWidth,0.5;format;;'..esc(time_data.format)..']',
'container[0,0.9]',
'label[2.5,0;'..S('Variable')..']',
'label[4,0;'..S('Current Value')..']',
@ -189,7 +189,7 @@ mtimer.dialog.session_duration_format = function (player_name)
'label[0,1.7;'..S('Seconds')..'] label[2.5,1.7;{seconds}] label[4,1.7;'..time_data.seconds..']',
'box[0,2;+contentWidth,0.02;#ffffff]',
'label[0,2.25;'..S('Current Result')..']',
'label[2.5,2.25;'..fe(time_data.formatted)..']',
'label[2.5,2.25;'..esc(time_data.formatted)..']',
'container_end[]'
}
})
@ -222,7 +222,7 @@ end
mtimer.dialog.hud_element_offset = function (player_name)
local player = minetest.get_player_by_name(player_name)
local timer_data = fe(mtimer.get_timer_data(player_name).format)
local timer_data = esc(mtimer.get_timer_data(player_name).format)
local information = table.concat({
S('HUD element offset is used like a border/padding.'),
@ -269,17 +269,17 @@ mtimer.dialog.timer_format = function (player_name)
height = 6,
width = 8.5,
formspec = {
'textarea[0,0;6,2.5;format;;'..fe(timer_data.format)..']',
'textarea[0,0;6,2.5;format;;'..esc(timer_data.format)..']',
'container[0,2.9]',
'label[2.5,0;'..S('Variable')..']',
'label[4,0;'..S('Current Value')..']',
'box[0,0.25;+contentWidth,0.02;#ffffff]',
'label[0,0.5;'..S('Real-World Date')..'] label[2.5,0.5;{rd}] label[4,0.5;'..fe(timer_data.real_world_date)..']',
'label[0,0.9;'..S('In-Game Time')..'] label[2.5,0.9;{it}] label[4,0.9;'..fe(timer_data.ingame_time)..']',
'label[0,1.3;'..S('Session Start Time')..'] label[2.5,1.3;{st}] label[4,1.3;'..fe(timer_data.session_start_time)..']',
'label[0,1.7;'..S('Session Duration')..'] label[2.5,1.7;{sd}] label[4,1.7;'..fe(timer_data.session_duration)..']',
'label[0,2.1;'..S('Host Time')..'] label[2.5,2.1;{ht}] label[4,2.1;'..fe(timer_data.host_time)..']',
'label[0,2.5;'..S('Custom Timer')..'] label[2.5,2.5;{ct}] label[4,2.5;'..fe(S('As configured'))..']',
'label[0,0.5;'..S('Real-World Date')..'] label[2.5,0.5;{rd}] label[4,0.5;'..esc(timer_data.real_world_date)..']',
'label[0,0.9;'..S('In-Game Time')..'] label[2.5,0.9;{it}] label[4,0.9;'..esc(timer_data.ingame_time)..']',
'label[0,1.3;'..S('Session Start Time')..'] label[2.5,1.3;{st}] label[4,1.3;'..esc(timer_data.session_start_time)..']',
'label[0,1.7;'..S('Session Duration')..'] label[2.5,1.7;{sd}] label[4,1.7;'..esc(timer_data.session_duration)..']',
'label[0,2.1;'..S('Host Time')..'] label[2.5,2.1;{ht}] label[4,2.1;'..esc(timer_data.host_time)..']',
'label[0,2.5;'..S('Custom Timer')..'] label[2.5,2.5;{ct}] label[4,2.5;'..esc(S('As configured'))..']',
'container_end[]',
'container[6.25,0]',
'button[0,0;2,0.5;apply;'..S('Apply')..']',
@ -320,9 +320,9 @@ mtimer.dialog.custom_timer = function (player_name)
'field_close_on_enter[v_minutes;false]',
'field_close_on_enter[v_seconds;false]',
'container[0,0]',
' label[0,0.25;'..S('Running')..'] field[2.25,0;6.5,0.5;v_format_running;;'..fe(format_running)..']',
' label[0,0.85;'..S('Stopped')..'] field[2.25,0.6;6.5,0.5;v_format_stopped;;'..fe(format_stopped)..']',
' label[0,1.45;'..S('Finished')..'] field[2.25,1.2;6.5,0.5;v_format_finished;;'..fe(format_finished)..']',
' label[0,0.25;'..S('Running')..'] field[2.25,0;6.5,0.5;v_format_running;;'..esc(format_running)..']',
' label[0,0.85;'..S('Stopped')..'] field[2.25,0.6;6.5,0.5;v_format_stopped;;'..esc(format_stopped)..']',
' label[0,1.45;'..S('Finished')..'] field[2.25,1.2;6.5,0.5;v_format_finished;;'..esc(format_finished)..']',
' box[0,2;+contentWidth,0.04;#ffffff]',
'container_end[]',
'container[3.75,2.4]',

@ -1,3 +1,10 @@
-- # vim: nowrap
--
-- Set Vim to no-wrapping mode because of some lines not fitting within the 80
-- characters width limit due to overall readability of the code.
-- Localise needed functions
local m = mtimer
local S = m.translator
local esc = minetest.formspec_escape

@ -1,7 +1,13 @@
-- # vim: nowrap
--
-- Set Vim to no-wrapping mode because of some lines not fitting within the 80
-- characters width limit due to overall readability of the code.
-- Localise needed functions
local m = mtimer
local S = m.translator
local fe = minetest.formspec_escape
local esc = minetest.formspec_escape
-- Create buttons at the given position in the main menu formspec
@ -30,7 +36,7 @@ local button = function (column, row, id, label)
local bc_left = c_position + (c_spacing * (column - 1))
return mtimer.get_icon_button(id, {
label = fe(label),
label = esc(label),
width = b_width,
image_size = i_size,
container = {

@ -7,8 +7,7 @@
-- Localise needed functions
local m = mtimer
local S = m.translator
local build_frame = m.build_frame
local fe = minetest.formspec_escape
local esc = minetest.formspec_escape
-- Real Time Universal Formspec
@ -31,7 +30,7 @@ mtimer.dialog.real_time_universal = function (player_name, config)
height = 7.5,
formspec = {
'field_close_on_enter[format;false]',
'field[0,0;+contentWidth,0.5;format;;'..fe(time_data.format)..']',
'field[0,0;+contentWidth,0.5;format;;'..esc(time_data.format)..']',
'container[0,0.9]',
'label[2.8,0;'..S('Variable')..']',
'label[4.6,0;'..S('Current Value')..']',
@ -53,7 +52,7 @@ mtimer.dialog.real_time_universal = function (player_name, config)
'label[0,5.25;'..S('Timestamp')..'] label[2.8,5.25;{timestamp}] label[4.6,5.25;'..time_data.variables.timestamp..']',
'box[0,5.55;+contentWidth,0.02;#ffffff]',
'label[0,5.8;'..S('Current Result')..']',
'label[2.8,5.8;'..fe(time_data.formatted)..']',
'label[2.8,5.8;'..esc(time_data.formatted)..']',
'container_end[]'
}
})