2019-02-21 21:07:35 +01:00
|
|
|
local m = mtimer
|
|
|
|
local S = m.translator
|
2021-04-02 08:57:00 +02:00
|
|
|
local esc = minetest.formspec_escape
|
2021-05-15 17:06:41 +02:00
|
|
|
local line = mtimer.get_table_line
|
2021-05-08 22:48:14 +02:00
|
|
|
|
|
|
|
|
2019-02-22 20:33:42 +01:00
|
|
|
-- Real Time Universal Formspec
|
|
|
|
--
|
|
|
|
-- This formspec can be used to show formatting options for all real-world time
|
|
|
|
-- values that can be formatted within mTimer. Since all the real-world times
|
|
|
|
-- are defined identically this formspec exists so it has to be defined only
|
|
|
|
-- once and can be re-used as needed.
|
|
|
|
--
|
|
|
|
-- @param player_name The name of the player to show the formspec to
|
|
|
|
-- @config time_type A time type that is provided by the `get_times` function
|
|
|
|
-- @return void
|
|
|
|
-- @see mtimer.get_times
|
2019-03-06 18:22:50 +01:00
|
|
|
mtimer.dialog.real_time_universal = function (player_name, config)
|
2019-02-21 21:07:35 +01:00
|
|
|
local time_data = mtimer.get_times(player_name)[config.time_type]
|
2021-05-08 22:48:14 +02:00
|
|
|
local vars = time_data.variables
|
2019-02-21 21:07:35 +01:00
|
|
|
|
2019-03-08 22:25:00 +01:00
|
|
|
mtimer.show_formspec(config.formspec_name, {
|
|
|
|
title = config.title,
|
|
|
|
show_to = player_name,
|
2021-05-08 22:48:14 +02:00
|
|
|
height = 8.75,
|
2019-03-08 22:25:00 +01:00
|
|
|
formspec = {
|
|
|
|
'field_close_on_enter[format;false]',
|
2021-04-02 08:57:00 +02:00
|
|
|
'field[0,0;+contentWidth,0.5;format;;'..esc(time_data.format)..']',
|
2021-05-08 22:48:14 +02:00
|
|
|
'container[0,1.5]',
|
|
|
|
line(0, '', S('Variable'), S('Current Value')),
|
|
|
|
line(1, '-'),
|
|
|
|
line(2, S('Hours (24h)'), '{24h}', vars.hours_24),
|
|
|
|
line(3, S('Hours (12h)'), '{12h}', vars.hours_12),
|
|
|
|
line(4, S('Minutes'), '{min}', vars.minutes),
|
|
|
|
line(5, S('Seconds'), '{sec}', vars.seconds),
|
|
|
|
line(6, '-'),
|
|
|
|
line(7, S('Day Name'), '{dname}', vars.dayname),
|
|
|
|
line(8, S('Month Name'), '{mname}', vars.monthname),
|
|
|
|
line(9, '-'),
|
|
|
|
line(10, S('Year'), '{year}', vars.year),
|
|
|
|
line(11, S('Month'), '{month}', vars.month),
|
|
|
|
line(12, S('Day'), '{day}', vars.day),
|
|
|
|
line(13, '-'),
|
|
|
|
line(14, S('ISO 8601 Date'), '{isodate}', vars.iso8601_date),
|
|
|
|
line(15, S('ISO 8601 Time'), '{isotime}', vars.iso8601_time),
|
|
|
|
line(16, S('Timestamp'), '{timestamp}', vars.timestamp),
|
|
|
|
line(17, '-'),
|
|
|
|
line(18, S('Current Result'), esc(time_data.formatted), ''),
|
2019-03-08 22:25:00 +01:00
|
|
|
'container_end[]'
|
|
|
|
}
|
|
|
|
})
|
2019-02-21 21:07:35 +01:00
|
|
|
end
|