update formspecs to version 2

This commit is contained in:
Dirk Sohler 2019-10-16 01:00:11 +02:00
parent 76115d9e13
commit fb51c1eebe
No known key found for this signature in database
GPG Key ID: B9751241BD7D4E1A
3 changed files with 80 additions and 77 deletions

@ -25,35 +25,35 @@ local fe = minetest.formspec_escape
mtimer.dialog.main_menu = function (player_name) mtimer.dialog.main_menu = function (player_name)
mtimer.show_formspec('mtimer:main_menu', { mtimer.show_formspec('mtimer:main_menu', {
title = S('mTimer'), title = S('mTimer'),
width = 9.5, width = 9.75,
height = 7.125, height = 6,
prefix = '', prefix = '',
add_buttons = false, add_buttons = false,
show_to = player_name, show_to = player_name,
formspec = { formspec = {
'container[0,0]', 'container[0,0]',
'label[0,0;'..S('Visuals')..']', 'label[0,0;'..S('Visuals')..']',
'button[0,0.5;3,1;set_visibility;'..S('Visibility')..']', 'button[0,0.25;3,0.5;set_visibility;'..S('Visibility')..']',
'button[0,1.5;3,1;set_position;'..S('Position')..']', 'button[0,1;3,0.5;set_position;'..S('Position')..']',
'button[0,2.5;3,1;set_color;'..S('Color')..']', 'button[0,1.75;3,0.5;set_color;'..S('Color')..']',
'container_end[]', 'container_end[]',
'container[3.25,0]', 'container[3.25,0]',
'label[0,0;'..S('Time Representation')..']', 'label[0,0;'..S('Time Representation')..']',
'button[0,0.5;3,1;ingame_time_format;'..S('Ingame Time Format')..']', 'button[0,0.25;3,0.5;ingame_time_format;'..S('Ingame Time Format')..']',
'button[0,1.5;3,1;real_world_time_format;'..S('Real-World Time Format')..']', 'button[0,1;3,0.5;real_world_time_format;'..S('Real-World Time Format')..']',
'button[0,2.5;3,1;session_start_time_format;'..S('Session Start Time Format')..']', 'button[0,1.75;3,0.5;session_start_time_format;'..S('Session Start Time Format')..']',
'button[0,3.5;3,1;session_duration_format;'..S('Session Duration Format')..']', 'button[0,2.5;3,0.5;session_duration_format;'..S('Session Duration Format')..']',
'button[0,4.5;3,1;host_time_format;'..S('Host Time Format')..']', 'button[0,3.25;3,0.5;host_time_format;'..S('Host Time Format')..']',
'container_end[]', 'container_end[]',
'container[6.5,0]', 'container[6.5,0]',
'label[0,0;'..S('Timer Configuration')..']', 'label[0,0;'..S('Timer Configuration')..']',
'button[0,0.5;3,1;timer_format;'..S('Timer Format')..']', 'button[0,0.25;3,0.5;timer_format;'..S('Timer Format')..']',
'button[0,1.5;3,1;timezone_offset;'..S('Timezone Offset')..']', 'button[0,1;3,0.5;timezone_offset;'..S('Timezone Offset')..']',
'container_end[]', 'container_end[]',
'container[0,5.55]', 'container[0,4.125]',
'box[0,0;+linewidth,0.04;#ffffff]', 'box[0,0;+linewidth,0.04;#ffffff]',
'button[4.5,0.225;2.5,1;reset_everything;'..S('Reset Everything')..']', 'button[4.3,0.225;2.5,0.5;reset_everything;'..S('Reset Everything')..']',
'button_exit[7,0.225;2.5,1;exit;'..S('Exit')..']', 'button_exit[7,0.225;2.5,0.5;exit;'..S('Exit')..']',
'container_end[]' 'container_end[]'
} }
}) })
@ -65,8 +65,8 @@ mtimer.dialog.set_visibility = function (player_name)
title = S('Visibility'), title = S('Visibility'),
show_to = player_name, show_to = player_name,
formspec = { formspec = {
'button[0,0;3,1;visible;'..S('Visible')..']', 'button[0,0;3,0.5;visible;'..S('Visible')..']',
'button[3,0;3,1;invisible;'..S('Invisible')..']' 'button[3.25,0;3,0.5;invisible;'..S('Invisible')..']'
} }
}) })
end end
@ -75,8 +75,8 @@ end
mtimer.dialog.set_position = function (player_name) mtimer.dialog.set_position = function (player_name)
mtimer.show_formspec('mtimer:set_position', { mtimer.show_formspec('mtimer:set_position', {
title = S('Position'), title = S('Position'),
height = 5, height = 5.35,
content_offset = 0.1, width = 8.25,
show_to = player_name, show_to = player_name,
formspec = { formspec = {
'image_button[0,0;8,4.5 ;mtimer_positions_orientation.png;pos_xx;;;false]', 'image_button[0,0;8,4.5 ;mtimer_positions_orientation.png;pos_xx;;;false]',
@ -89,7 +89,7 @@ mtimer.dialog.set_position = function (player_name)
'image_button[0,3;2.67,1.5;mtimer_transparent.png;pos_bl;;;false]', -- BL 'image_button[0,3;2.67,1.5;mtimer_transparent.png;pos_bl;;;false]', -- BL
'image_button[2.67,3;2.67,1.5;mtimer_transparent.png;pos_bc;;;false]', -- BC 'image_button[2.67,3;2.67,1.5;mtimer_transparent.png;pos_bc;;;false]', -- BC
'image_button[5.34,3;2.67,1.5;mtimer_transparent.png;pos_br;;;false]', -- BR 'image_button[5.34,3;2.67,1.5;mtimer_transparent.png;pos_br;;;false]', -- BR
'label[0,4.5;'..S('Click the position you want to place the timer at.')..']' 'label[0,4.75;'..S('Click the position you want to place the timer at.')..']'
} }
}) })
end end
@ -109,12 +109,11 @@ mtimer.dialog.set_color = function (player_name)
mtimer.show_formspec('mtimer:set_color', { mtimer.show_formspec('mtimer:set_color', {
title = S('Color'), title = S('Color'),
show_to = player_name, show_to = player_name,
content_offset = 0.275,
formspec = { formspec = {
'field_close_on_enter[color;false]', 'field_close_on_enter[color;false]',
'field[0.3,0;3,1;color;;'..color..']', 'field[0,0;3,0.5;color;;'..color..']',
'box[3,-0.2;0.65,0.65;'..color..'ff]', 'box[3.25,0;0.5,0.5;'..color..'ff]',
'label[0.025,0.60;'..S('Use `@1` format only!', hexcolor)..']' 'label[0.025,0.75;'..S('Use `@1` format only!', hexcolor)..']'
} }
}) })
end end
@ -123,25 +122,30 @@ end
mtimer.dialog.timezone_offset = function (player_name) mtimer.dialog.timezone_offset = function (player_name)
local time_data = mtimer.get_times(player_name).real_time local time_data = mtimer.get_times(player_name).real_time
local format_information = table.concat({ local format = {
S('30 minutes @= 0.5, 60 minutes @= 1'), conversion = S('30 minutes @= 0.5, 60 minutes @= 1'),
S('“Arbitrary” values are possible.') arbitrarity = S('“Arbitrary” values are possible.')
}, '\n') }
local time_information = table.concat({ local time_information = {
S('Server Time: @1', time_data.times.server_time), s = S('Server Time: @1', time_data.times.server_time),
S('Local Time: @1', time_data.times.local_time) l = S('Local Time: @1', time_data.times.local_time)
}, '\n') }
mtimer.show_formspec('mtimer:timezone_offset', { mtimer.show_formspec('mtimer:timezone_offset', {
title = S('Timezone Offset'), title = S('Timezone Offset'),
show_to = player_name, show_to = player_name,
content_offset = 0.275,
formspec = { formspec = {
'field_close_on_enter[offset;false]', 'field_close_on_enter[offset;false]',
'field[0.3,0;3,1;offset;;'..time_data.times.offset..']', 'field[0,0;3,0.5;offset;;'..time_data.times.offset..']',
'label[3,-0.3;'..format_information..']', 'container[3.25,0.1]',
'label[0,0.55;'..time_information..']' 'label[0,0;'..format.conversion..']',
'label[0,0.3;'..format.arbitrarity..']',
'container_end[]',
'container[0,0.9]',
'label[0,0;'..time_information.s..']',
'label[0,0.3;'..time_information.l..']',
'container_end[]'
} }
}) })
end end
@ -152,21 +156,20 @@ mtimer.dialog.ingame_time_format = function (player_name)
mtimer.show_formspec('mtimer:ingame_time_format', { mtimer.show_formspec('mtimer:ingame_time_format', {
title = S('Ingame Time Format'), title = S('Ingame Time Format'),
height = 3.5, height = 3.8,
show_to = player_name, show_to = player_name,
content_offset = 0.275,
formspec = { formspec = {
'field_close_on_enter[format;false]', 'field_close_on_enter[format;false]',
'field[0.3,0;+width,1;format;;'..fe(time_data.format)..']', 'field[0,0;+linewidth,0.5;format;;'..fe(time_data.format)..']',
'container[0,0.65]', 'container[0,0.9]',
'label[2.8,0;'..S('Variable')..']', 'label[2.8,0;'..S('Variable')..']',
'label[4.25,0;'..S('Current Value')..']', 'label[4.25,0;'..S('Current Value')..']',
'box[0,0.45;+linewidth,0.02;#ffffff]', 'box[0,0.25;+linewidth,0.02;#ffffff]',
'label[0,0.5;'..S('Hours (24h)')..'] label[2.8,0.5;{24h}] label[4.25,0.5;'..time_data.hours_24..']', 'label[0,0.5;'..S('Hours (24h)')..'] label[2.8,0.5;{24h}] label[4.25,0.5;'..time_data.hours_24..']',
'label[0,0.9;'..S('Hours (12h)')..'] label[2.8,0.9;{12h}] label[4.25,0.9;'..time_data.hours_12..']', 'label[0,0.9;'..S('Hours (12h)')..'] label[2.8,0.9;{12h}] label[4.25,0.9;'..time_data.hours_12..']',
'label[0,1.3;'..S('Minutes')..'] label[2.8,1.3;{min}] label[4.25,1.3;'..time_data.minutes..']', 'label[0,1.3;'..S('Minutes')..'] label[2.8,1.3;{min}] label[4.25,1.3;'..time_data.minutes..']',
'label[0,1.7;'..S('Ingame Timestamp')..'] label[2.8,1.7;{its}] label[4.25,1.7;'..time_data.ingame_timestamp..']', '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.2;+linewidth,0.02;#ffffff]', 'box[0,2;+linewidth,0.02;#ffffff]',
'label[0,2.25;'..S('Current Result')..']', 'label[0,2.25;'..S('Current Result')..']',
'label[2.8,2.25;'..fe(time_data.formatted)..']', 'label[2.8,2.25;'..fe(time_data.formatted)..']',
'container_end[]' 'container_end[]'
@ -208,20 +211,19 @@ mtimer.dialog.session_duration_format = function (player_name)
mtimer.show_formspec('mtimer:session_duration_format', { mtimer.show_formspec('mtimer:session_duration_format', {
title = S('Session Duration Format'), title = S('Session Duration Format'),
show_to = player_name, show_to = player_name,
height = 3.425, height = 3.8,
content_offset = 0.275,
formspec = { formspec = {
'field_close_on_enter[format;false]', 'field_close_on_enter[format;false]',
'field[0.3,0;+width,1;format;;'..fe(time_data.format)..']', 'field[0,0;+linewidth,0.5;format;;'..fe(time_data.format)..']',
'container[0,0.65]', 'container[0,0.9]',
'label[2.5,0;'..S('Variable')..']', 'label[2.5,0;'..S('Variable')..']',
'label[4,0;'..S('Current Value')..']', 'label[4,0;'..S('Current Value')..']',
'box[0,0.45;+linewidth,0.02;#ffffff]', 'box[0,0.25;+linewidth,0.02;#ffffff]',
'label[0,0.5;'..S('Days')..'] label[2.5,0.5;{days}] label[4,0.5;'..time_data.days..']', 'label[0,0.5;'..S('Days')..'] label[2.5,0.5;{days}] label[4,0.5;'..time_data.days..']',
'label[0,0.9;'..S('Hours')..'] label[2.5,0.9;{hours}] label[4,0.9;'..time_data.hours..']', 'label[0,0.9;'..S('Hours')..'] label[2.5,0.9;{hours}] label[4,0.9;'..time_data.hours..']',
'label[0,1.3;'..S('Minutes')..'] label[2.5,1.3;{minutes}] label[4,1.3;'..time_data.minutes..']', 'label[0,1.3;'..S('Minutes')..'] label[2.5,1.3;{minutes}] label[4,1.3;'..time_data.minutes..']',
'label[0,1.7;'..S('Seconds')..'] label[2.5,1.7;{seconds}] label[4,1.7;'..time_data.seconds..']', 'label[0,1.7;'..S('Seconds')..'] label[2.5,1.7;{seconds}] label[4,1.7;'..time_data.seconds..']',
'box[0,2.2;+linewidth,0.02;#ffffff]', 'box[0,2;+linewidth,0.02;#ffffff]',
'label[0,2.25;'..S('Current Result')..']', 'label[0,2.25;'..S('Current Result')..']',
'label[2.5,2.25;'..fe(time_data.formatted)..']', 'label[2.5,2.25;'..fe(time_data.formatted)..']',
'container_end[]' 'container_end[]'
@ -236,21 +238,22 @@ mtimer.dialog.timer_format = function (player_name)
mtimer.show_formspec('mtimer:timer_format', { mtimer.show_formspec('mtimer:timer_format', {
title = S('Timer Format'), title = S('Timer Format'),
show_to = player_name, show_to = player_name,
height = 4.75, height = 5.75,
width = 8.5,
formspec = { formspec = {
'textarea[0.3,0;6,2.5;format;;'..fe(timer_data.format)..']', 'textarea[0,0;6,2.5;format;;'..fe(timer_data.format)..']',
'container[0,2.18]', 'container[0,2.9]',
'label[2.5,0;'..S('Variable')..']', 'label[2.5,0;'..S('Variable')..']',
'label[4,0;'..S('Current Value')..']', 'label[4,0;'..S('Current Value')..']',
'box[0,0.45;+linewidth,0.02;#ffffff]', 'box[0,0.25;+linewidth,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.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,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.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,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.1;'..S('Host Time')..'] label[2.5,2.1;{ht}] label[4,2.1;'..fe(timer_data.host_time)..']',
'container_end[]', 'container_end[]',
'container[6,0]', 'container[6.25,0]',
'button[0,-0.05;2,1;apply;'..S('Apply')..']', 'button[0,0;2,0.5;apply;'..S('Apply')..']',
'container_end[]' 'container_end[]'
} }
}) })

@ -80,33 +80,34 @@ mtimer.show_formspec = function (name, def)
local buttons = not add_buttons and '' or table.concat({ local buttons = not add_buttons and '' or table.concat({
'container[0,+buttons]', 'container[0,+buttons]',
'box[0,0;+linewidth,0.04;#ffffff]', 'box[0.25,0;+linewidth,0.04;#ffffff]',
'button[+defbutton,0.2;2,1;default;'..S('Default')..']', 'button[+defbutton,0.2;2,0.5;default;'..S('Default')..']',
'button[+mainbutton,0.2;2,1;main_menu;'..S('Main Menu')..']', 'button[+mainbutton,0.2;2,0.5;main_menu;'..S('Main Menu')..']',
'button_exit[+exitbutton,0.2;2,1;exit;'..S('Exit')..']', 'button_exit[+exitbutton,0.2;2,0.5;exit;'..S('Exit')..']',
'container_end[]' 'container_end[]'
}, ' ') }, ' ')
local formspec = table.concat({ local formspec = table.concat({
'formspec_version[2]',
'size[+width,+height]', 'size[+width,+height]',
'label[0,-0.1;+title]', 'label[0.25,0.35;+title]',
'box[0,0.5;+linewidth,0.04;#ffffff]', 'box[0.25,0.6;+linewidth,0.04;#ffffff]',
'container[0,+content]', 'container[0.25,+content]',
table.concat(def.formspec, ' '), table.concat(def.formspec, ' '),
'container_end[]', 'container_end[]',
buttons buttons
}, ' ') }, ' ')
formspec = formspec:gsub('%+%a+', { formspec = formspec:gsub('%+%a+', {
['+width'] = width, ['+width'] = width+0.25,
['+height'] = height, ['+height'] = height,
['+linewidth'] = width-0.215, ['+linewidth'] = width-0.25,
['+title'] = minetest.formspec_escape(prefix..def.title), ['+title'] = minetest.formspec_escape(prefix..def.title),
['+content'] = 0.7 + content_offset, ['+content'] = 0.9 + content_offset,
['+buttons'] = height-0.8, ['+buttons'] = height-1,
['+defbutton'] = 0, ['+defbutton'] = 0.25,
['+mainbutton'] = width-4, ['+mainbutton'] = width-4.4+0.25,
['+exitbutton'] = width-2, ['+exitbutton'] = width-2.25+0.25,
}) })

@ -28,31 +28,30 @@ mtimer.dialog.real_time_universal = function (player_name, config)
mtimer.show_formspec(config.formspec_name, { mtimer.show_formspec(config.formspec_name, {
title = config.title, title = config.title,
show_to = player_name, show_to = player_name,
height = 7, height = 7.5,
content_offset = 0.275,
formspec = { formspec = {
'field_close_on_enter[format;false]', 'field_close_on_enter[format;false]',
'field[0.3,0;+width,1;format;;'..fe(time_data.format)..']', 'field[0,0;+linewidth,0.5;format;;'..fe(time_data.format)..']',
'container[0,0.65]', 'container[0,0.9]',
'label[2.8,0;'..S('Variable')..']', 'label[2.8,0;'..S('Variable')..']',
'label[4.6,0;'..S('Current Value')..']', 'label[4.6,0;'..S('Current Value')..']',
'box[0,0.45;+linewidth,0.02;#ffffff]', 'box[0,0.25;+linewidth,0.02;#ffffff]',
'label[0,0.5;'..S('Hours (24h)')..'] label[2.8,0.5;{24h}] label[4.6,0.5;'..time_data.variables.hours_24..']', 'label[0,0.5;'..S('Hours (24h)')..'] label[2.8,0.5;{24h}] label[4.6,0.5;'..time_data.variables.hours_24..']',
'label[0,0.9;'..S('Hours (12h)')..'] label[2.8,0.9;{12h}] label[4.6,0.9;'..time_data.variables.hours_12..']', 'label[0,0.9;'..S('Hours (12h)')..'] label[2.8,0.9;{12h}] label[4.6,0.9;'..time_data.variables.hours_12..']',
'label[0,1.3;'..S('Minutes')..'] label[2.8,1.3;{min}] label[4.6,1.3;'..time_data.variables.minutes..']', 'label[0,1.3;'..S('Minutes')..'] label[2.8,1.3;{min}] label[4.6,1.3;'..time_data.variables.minutes..']',
'label[0,1.7;'..S('Seconds')..'] label[2.8,1.7;{sec}] label[4.6,1.7;'..time_data.variables.seconds..']', 'label[0,1.7;'..S('Seconds')..'] label[2.8,1.7;{sec}] label[4.6,1.7;'..time_data.variables.seconds..']',
'box[0,2.18;+linewidth,0.02;#ffffff]', 'box[0,1.98;+linewidth,0.02;#ffffff]',
'label[0,2.2;'..S('Day Name')..'] label[2.8,2.2;{dname}] label[4.6,2.2;'..time_data.variables.dayname..']', 'label[0,2.2;'..S('Day Name')..'] label[2.8,2.2;{dname}] label[4.6,2.2;'..time_data.variables.dayname..']',
'label[0,2.6;'..S('Month Name')..'] label[2.8,2.6;{mname}] label[4.6,2.6;'..time_data.variables.monthname..']', 'label[0,2.6;'..S('Month Name')..'] label[2.8,2.6;{mname}] label[4.6,2.6;'..time_data.variables.monthname..']',
'box[0,3.05;+linewidth,0.02;#ffffff]', 'box[0,2.85;+linewidth,0.02;#ffffff]',
'label[0,3.1;'..S('Year')..'] label[2.8,3.1;{year}] label[4.6,3.1;'..time_data.variables.year..']', 'label[0,3.1;'..S('Year')..'] label[2.8,3.1;{year}] label[4.6,3.1;'..time_data.variables.year..']',
'label[0,3.5;'..S('Month')..'] label[2.8,3.5;{month}] label[4.6,3.5;'..time_data.variables.month..']', 'label[0,3.5;'..S('Month')..'] label[2.8,3.5;{month}] label[4.6,3.5;'..time_data.variables.month..']',
'label[0,3.9;'..S('Day')..'] label[2.8,3.9;{day}] label[4.6,3.9;'..time_data.variables.day..']', 'label[0,3.9;'..S('Day')..'] label[2.8,3.9;{day}] label[4.6,3.9;'..time_data.variables.day..']',
'box[0,4.4;+linewidth,0.02;#ffffff]', 'box[0,4.2;+linewidth,0.02;#ffffff]',
'label[0,4.45;'..S('ISO 8601 Date')..'] label[2.8,4.45;{isodate}] label[4.6,4.45;'..time_data.variables.iso8601_date..']', 'label[0,4.45;'..S('ISO 8601 Date')..'] label[2.8,4.45;{isodate}] label[4.6,4.45;'..time_data.variables.iso8601_date..']',
'label[0,4.85;'..S('ISO 8601 Time')..'] label[2.8,4.85;{isotime}] label[4.6,4.85;'..time_data.variables.iso8601_time..']', 'label[0,4.85;'..S('ISO 8601 Time')..'] label[2.8,4.85;{isotime}] label[4.6,4.85;'..time_data.variables.iso8601_time..']',
'label[0,5.25;'..S('Timestamp')..'] label[2.8,5.25;{timestamp}] label[4.6,5.25;'..time_data.variables.timestamp..']', 'label[0,5.25;'..S('Timestamp')..'] label[2.8,5.25;{timestamp}] label[4.6,5.25;'..time_data.variables.timestamp..']',
'box[0,5.75;+linewidth,0.02;#ffffff]', 'box[0,5.55;+linewidth,0.02;#ffffff]',
'label[0,5.8;'..S('Current Result')..']', 'label[0,5.8;'..S('Current Result')..']',
'label[2.8,5.8;'..fe(time_data.formatted)..']', 'label[2.8,5.8;'..fe(time_data.formatted)..']',
'container_end[]' 'container_end[]'