2019-03-08 22:25:00 +01:00
|
|
|
|
-- # 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
|
2019-02-16 16:45:32 +01:00
|
|
|
|
local m = mtimer
|
|
|
|
|
local S = m.translator
|
2019-02-22 13:06:03 +01:00
|
|
|
|
local fe = minetest.formspec_escape
|
2019-02-18 22:02:59 +01:00
|
|
|
|
|
|
|
|
|
|
2019-02-22 20:33:42 +01:00
|
|
|
|
-- Formspecs are loaded and shown by individual functions. The function name
|
|
|
|
|
-- correlates with the formspec to show. All of the names are self-explanatory
|
|
|
|
|
-- and within the functions no logic is used.
|
|
|
|
|
--
|
2021-04-02 04:07:40 +02:00
|
|
|
|
-- The Main menu is a bit more complex and is generated seperately.
|
|
|
|
|
--
|
2019-03-08 22:25:00 +01:00
|
|
|
|
-- @see mtimer.show_formspec
|
2019-02-22 20:33:42 +01:00
|
|
|
|
-- @see mtimer.get_times
|
|
|
|
|
-- @see ./system/on_receive_fields.lua
|
|
|
|
|
-- @see ./system/chat_command.lua
|
2021-04-02 04:07:40 +02:00
|
|
|
|
-- @see ./system/formspec/main_menu.lua
|
2019-02-22 20:33:42 +01:00
|
|
|
|
-- @see https://dev.minetest.net/formspec
|
|
|
|
|
|
|
|
|
|
|
2019-03-06 18:22:50 +01:00
|
|
|
|
mtimer.dialog.set_visibility = function (player_name)
|
2019-03-08 22:25:00 +01:00
|
|
|
|
mtimer.show_formspec('mtimer:set_visibility', {
|
|
|
|
|
title = S('Visibility'),
|
|
|
|
|
show_to = player_name,
|
|
|
|
|
formspec = {
|
2019-10-16 01:00:11 +02:00
|
|
|
|
'button[0,0;3,0.5;visible;'..S('Visible')..']',
|
|
|
|
|
'button[3.25,0;3,0.5;invisible;'..S('Invisible')..']'
|
2019-03-08 22:25:00 +01:00
|
|
|
|
}
|
|
|
|
|
})
|
2019-02-16 16:45:32 +01:00
|
|
|
|
end
|
2019-02-17 01:31:10 +01:00
|
|
|
|
|
|
|
|
|
|
2019-03-06 18:22:50 +01:00
|
|
|
|
mtimer.dialog.set_position = function (player_name)
|
2019-03-08 22:25:00 +01:00
|
|
|
|
mtimer.show_formspec('mtimer:set_position', {
|
|
|
|
|
title = S('Position'),
|
2019-10-16 01:00:11 +02:00
|
|
|
|
height = 5.35,
|
|
|
|
|
width = 8.25,
|
2019-03-08 22:25:00 +01:00
|
|
|
|
show_to = player_name,
|
|
|
|
|
formspec = {
|
|
|
|
|
'image_button[0,0;8,4.5 ;mtimer_positions_orientation.png;pos_xx;;;false]',
|
|
|
|
|
'image_button[0,0;2.67,1.5;mtimer_transparent.png;pos_tl;;;false]', -- TL
|
|
|
|
|
'image_button[2.67,0;2.67,1.5;mtimer_transparent.png;pos_tc;;;false]', -- TC
|
|
|
|
|
'image_button[5.34,0;2.67,1.5;mtimer_transparent.png;pos_tr;;;false]', -- TR
|
|
|
|
|
'image_button[0,1.5;2.67,1.5;mtimer_transparent.png;pos_ml;;;false]', -- ML
|
|
|
|
|
'image_button[2.67,1.5;2.67,1.5;mtimer_transparent.png;pos_mc;;;false]', -- MC
|
|
|
|
|
'image_button[5.34,1.5;2.67,1.5;mtimer_transparent.png;pos_mr;;;false]', -- MR
|
|
|
|
|
'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[5.34,3;2.67,1.5;mtimer_transparent.png;pos_br;;;false]', -- BR
|
2019-10-16 01:00:11 +02:00
|
|
|
|
'label[0,4.75;'..S('Click the position you want to place the timer at.')..']'
|
2019-03-08 22:25:00 +01:00
|
|
|
|
}
|
|
|
|
|
})
|
2019-02-17 01:31:10 +01:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2019-03-06 18:22:50 +01:00
|
|
|
|
mtimer.dialog.set_color = function (player_name)
|
2019-02-17 03:10:41 +01:00
|
|
|
|
local player = minetest.get_player_by_name(player_name)
|
|
|
|
|
local color = player:get_meta():get_string(m.meta.color.key)
|
|
|
|
|
|
|
|
|
|
local hexcolor = table.concat({
|
|
|
|
|
'#',
|
|
|
|
|
minetest.colorize('#ce5c00', 'rr'),
|
|
|
|
|
minetest.colorize('#4e9a06', 'gg'),
|
2019-02-22 15:29:08 +01:00
|
|
|
|
minetest.colorize('#729fcf', 'bb')
|
2019-02-17 03:10:41 +01:00
|
|
|
|
})
|
|
|
|
|
|
2019-03-08 22:25:00 +01:00
|
|
|
|
mtimer.show_formspec('mtimer:set_color', {
|
|
|
|
|
title = S('Color'),
|
|
|
|
|
show_to = player_name,
|
|
|
|
|
formspec = {
|
|
|
|
|
'field_close_on_enter[color;false]',
|
2019-10-16 01:00:11 +02:00
|
|
|
|
'field[0,0;3,0.5;color;;'..color..']',
|
|
|
|
|
'box[3.25,0;0.5,0.5;'..color..'ff]',
|
|
|
|
|
'label[0.025,0.75;'..S('Use `@1` format only!', hexcolor)..']'
|
2019-03-08 22:25:00 +01:00
|
|
|
|
}
|
|
|
|
|
})
|
2019-02-17 03:10:41 +01:00
|
|
|
|
end
|
2019-02-19 13:40:19 +01:00
|
|
|
|
|
|
|
|
|
|
2019-03-06 18:22:50 +01:00
|
|
|
|
mtimer.dialog.timezone_offset = function (player_name)
|
2019-02-21 14:37:58 +01:00
|
|
|
|
local time_data = mtimer.get_times(player_name).real_time
|
2019-02-19 13:40:19 +01:00
|
|
|
|
|
2019-10-16 01:00:11 +02:00
|
|
|
|
local format = {
|
|
|
|
|
conversion = S('30 minutes @= 0.5, 60 minutes @= 1'),
|
|
|
|
|
arbitrarity = S('“Arbitrary” values are possible.')
|
|
|
|
|
}
|
2019-02-19 13:40:19 +01:00
|
|
|
|
|
2019-10-16 01:00:11 +02:00
|
|
|
|
local time_information = {
|
|
|
|
|
s = S('Server Time: @1', time_data.times.server_time),
|
|
|
|
|
l = S('Local Time: @1', time_data.times.local_time)
|
|
|
|
|
}
|
2019-02-19 13:40:19 +01:00
|
|
|
|
|
2019-03-08 22:25:00 +01:00
|
|
|
|
mtimer.show_formspec('mtimer:timezone_offset', {
|
|
|
|
|
title = S('Timezone Offset'),
|
|
|
|
|
show_to = player_name,
|
|
|
|
|
formspec = {
|
|
|
|
|
'field_close_on_enter[offset;false]',
|
2019-10-16 01:00:11 +02:00
|
|
|
|
'field[0,0;3,0.5;offset;;'..time_data.times.offset..']',
|
|
|
|
|
'container[3.25,0.1]',
|
|
|
|
|
'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[]'
|
2019-03-08 22:25:00 +01:00
|
|
|
|
}
|
|
|
|
|
})
|
2019-02-19 13:40:19 +01:00
|
|
|
|
end
|
2019-02-21 16:16:10 +01:00
|
|
|
|
|
|
|
|
|
|
2019-03-06 18:22:50 +01:00
|
|
|
|
mtimer.dialog.ingame_time_format = function (player_name)
|
2019-02-21 16:16:10 +01:00
|
|
|
|
local time_data = mtimer.get_times(player_name).ingame_time
|
|
|
|
|
|
2019-03-08 22:25:00 +01:00
|
|
|
|
mtimer.show_formspec('mtimer:ingame_time_format', {
|
|
|
|
|
title = S('Ingame Time Format'),
|
2019-10-16 01:00:11 +02:00
|
|
|
|
height = 3.8,
|
2019-03-08 22:25:00 +01:00
|
|
|
|
show_to = player_name,
|
|
|
|
|
formspec = {
|
|
|
|
|
'field_close_on_enter[format;false]',
|
2021-04-02 08:52:29 +02:00
|
|
|
|
'field[0,0;+contentWidth,0.5;format;;'..fe(time_data.format)..']',
|
2019-10-16 01:00:11 +02:00
|
|
|
|
'container[0,0.9]',
|
2019-03-08 22:25:00 +01:00
|
|
|
|
'label[2.8,0;'..S('Variable')..']',
|
2019-03-16 23:41:27 +01:00
|
|
|
|
'label[4.25,0;'..S('Current Value')..']',
|
2021-04-02 08:52:29 +02:00
|
|
|
|
'box[0,0.25;+contentWidth,0.02;#ffffff]',
|
2019-03-08 22:25:00 +01:00
|
|
|
|
'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,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..']',
|
2021-04-02 08:52:29 +02:00
|
|
|
|
'box[0,2;+contentWidth,0.02;#ffffff]',
|
2019-03-08 22:25:00 +01:00
|
|
|
|
'label[0,2.25;'..S('Current Result')..']',
|
|
|
|
|
'label[2.8,2.25;'..fe(time_data.formatted)..']',
|
|
|
|
|
'container_end[]'
|
|
|
|
|
}
|
|
|
|
|
})
|
2019-02-21 16:16:10 +01:00
|
|
|
|
end
|
2019-02-21 21:07:35 +01:00
|
|
|
|
|
|
|
|
|
|
2019-03-06 18:22:50 +01:00
|
|
|
|
mtimer.dialog.real_world_time_format = function (player_name)
|
|
|
|
|
mtimer.dialog.real_time_universal(player_name, {
|
2019-02-21 21:07:35 +01:00
|
|
|
|
time_type = 'real_time',
|
|
|
|
|
formspec_name = 'mtimer:real_world_time_format',
|
|
|
|
|
title = S('Real-World Time Format')
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2019-04-12 21:56:06 +02:00
|
|
|
|
mtimer.dialog.host_time_format = function (player_name)
|
|
|
|
|
mtimer.dialog.real_time_universal(player_name, {
|
|
|
|
|
time_type = 'host_time',
|
|
|
|
|
formspec_name = 'mtimer:host_time_format',
|
|
|
|
|
title = S('Host Time Format')
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2019-03-06 18:22:50 +01:00
|
|
|
|
mtimer.dialog.session_start_time_format = function (player_name)
|
|
|
|
|
mtimer.dialog.real_time_universal(player_name, {
|
2019-02-21 21:07:35 +01:00
|
|
|
|
time_type = 'session_start_time',
|
|
|
|
|
formspec_name = 'mtimer:session_start_time_format',
|
|
|
|
|
title = S('Session Start Time Format')
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2019-03-06 18:22:50 +01:00
|
|
|
|
mtimer.dialog.session_duration_format = function (player_name)
|
2019-02-21 21:07:35 +01:00
|
|
|
|
local time_data = mtimer.get_times(player_name).session_duration
|
|
|
|
|
|
2019-03-08 22:25:00 +01:00
|
|
|
|
mtimer.show_formspec('mtimer:session_duration_format', {
|
|
|
|
|
title = S('Session Duration Format'),
|
|
|
|
|
show_to = player_name,
|
2019-10-16 01:00:11 +02:00
|
|
|
|
height = 3.8,
|
2019-03-08 22:25:00 +01:00
|
|
|
|
formspec = {
|
|
|
|
|
'field_close_on_enter[format;false]',
|
2021-04-02 08:52:29 +02:00
|
|
|
|
'field[0,0;+contentWidth,0.5;format;;'..fe(time_data.format)..']',
|
2019-10-16 01:00:11 +02:00
|
|
|
|
'container[0,0.9]',
|
2019-03-08 22:25:00 +01:00
|
|
|
|
'label[2.5,0;'..S('Variable')..']',
|
2019-03-16 23:41:27 +01:00
|
|
|
|
'label[4,0;'..S('Current Value')..']',
|
2021-04-02 08:52:29 +02:00
|
|
|
|
'box[0,0.25;+contentWidth,0.02;#ffffff]',
|
2019-03-08 22:25:00 +01:00
|
|
|
|
'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,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..']',
|
2021-04-02 08:52:29 +02:00
|
|
|
|
'box[0,2;+contentWidth,0.02;#ffffff]',
|
2019-03-08 22:25:00 +01:00
|
|
|
|
'label[0,2.25;'..S('Current Result')..']',
|
|
|
|
|
'label[2.5,2.25;'..fe(time_data.formatted)..']',
|
|
|
|
|
'container_end[]'
|
|
|
|
|
}
|
|
|
|
|
})
|
2019-02-21 21:07:35 +01:00
|
|
|
|
end
|
2019-02-22 14:08:44 +01:00
|
|
|
|
|
|
|
|
|
|
2020-08-07 05:15:47 +02:00
|
|
|
|
mtimer.dialog.hud_element_size = function (player_name)
|
|
|
|
|
local player = minetest.get_player_by_name(player_name)
|
|
|
|
|
local size = player:get_meta():get_string(m.meta.hud_element_size.key)
|
|
|
|
|
|
2020-08-07 05:28:52 +02:00
|
|
|
|
local information = table.concat({
|
|
|
|
|
S('If set to 1 the HUD element is unscaled.'),
|
|
|
|
|
S('All values larger than 1 scale the element up.'),
|
|
|
|
|
S('Clicking the +/- button changes the size by 1.')
|
|
|
|
|
}, '\n')
|
|
|
|
|
|
2020-08-07 05:15:47 +02:00
|
|
|
|
mtimer.show_formspec('mtimer:hud_element_size', {
|
|
|
|
|
title = S('HUD Element Size'),
|
|
|
|
|
show_to = player_name,
|
|
|
|
|
formspec = {
|
|
|
|
|
'field_close_on_enter[hud_element_size;false]',
|
|
|
|
|
'button[0,0;0.5,0.5;substract;'..S('-')..']',
|
|
|
|
|
'field[0.75,0;0.75,0.5;hud_element_size;;'..size..']',
|
|
|
|
|
'button[1.75,0;0.5,0.5;add;'..S('+')..']',
|
2020-08-07 05:28:52 +02:00
|
|
|
|
'label[0.025,1;'..information..']',
|
2020-08-07 05:15:47 +02:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
|
2020-08-11 21:30:16 +02:00
|
|
|
|
|
2020-08-11 21:02:26 +02:00
|
|
|
|
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 information = table.concat({
|
|
|
|
|
S('HUD element offset is used like a border/padding.'),
|
|
|
|
|
S('Timer format can’t be set here. Go to the timer format dialog for that.')
|
|
|
|
|
}, '\n')
|
|
|
|
|
|
|
|
|
|
-- Get current offset values or 0 for use in formspec
|
|
|
|
|
local key = m.meta.hud_element_offset.key
|
|
|
|
|
local offset = minetest.deserialize(player:get_meta():get_string(key))
|
|
|
|
|
offset.x = offset.x and offset.x or 0
|
|
|
|
|
offset.y = offset.y and offset.y or 0
|
|
|
|
|
|
|
|
|
|
mtimer.show_formspec('mtimer:hud_element_offset', {
|
|
|
|
|
title = S('HUD Element Offset'),
|
|
|
|
|
show_to = player_name,
|
|
|
|
|
height = 4.75,
|
|
|
|
|
formspec = {
|
|
|
|
|
'field_close_on_enter[x_offset;false]',
|
|
|
|
|
'field_close_on_enter[y_offset;false]',
|
|
|
|
|
'box[0,0;5,2.25;#ffffff33]',
|
|
|
|
|
'textarea[0,0;5,2.25;;;'..timer_data..']',
|
|
|
|
|
'container[0,2.5]',
|
2020-08-11 21:30:16 +02:00
|
|
|
|
' button[0,0;0.5,0.5;x_substract_1;'..S('-')..']',
|
2020-08-11 21:02:26 +02:00
|
|
|
|
' field[0.75,0;0.75,0.5;x_offset;;'..offset.x..']',
|
2020-08-11 21:30:16 +02:00
|
|
|
|
' button[1.75,0;0.5,0.5;x_add_1;'..S('+')..']',
|
2020-08-11 21:02:26 +02:00
|
|
|
|
'container_end[]',
|
|
|
|
|
'container[5.25,0]',
|
2020-08-11 21:30:16 +02:00
|
|
|
|
' button[0,0;0.5,0.5;y_add_1;'..S('+')..']',
|
2020-08-11 21:02:26 +02:00
|
|
|
|
' field[0,0.75;0.75,0.5;y_offset;;'..offset.y..']',
|
2020-08-11 21:30:16 +02:00
|
|
|
|
' button[0,1.5;0.5,0.5;y_substract_1;'..S('-')..']',
|
2020-08-11 21:02:26 +02:00
|
|
|
|
'container_end[]',
|
|
|
|
|
'label[0.025,3.5;'..information..']',
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
|
2020-08-07 05:15:47 +02:00
|
|
|
|
|
2019-03-06 18:22:50 +01:00
|
|
|
|
mtimer.dialog.timer_format = function (player_name)
|
2019-02-22 14:08:44 +01:00
|
|
|
|
local timer_data = mtimer.get_timer_data(player_name)
|
|
|
|
|
|
2019-03-08 22:25:00 +01:00
|
|
|
|
mtimer.show_formspec('mtimer:timer_format', {
|
|
|
|
|
title = S('Timer Format'),
|
|
|
|
|
show_to = player_name,
|
2021-02-12 20:23:40 +01:00
|
|
|
|
height = 6,
|
2019-10-16 01:00:11 +02:00
|
|
|
|
width = 8.5,
|
2019-03-08 22:25:00 +01:00
|
|
|
|
formspec = {
|
2019-10-16 01:00:11 +02:00
|
|
|
|
'textarea[0,0;6,2.5;format;;'..fe(timer_data.format)..']',
|
|
|
|
|
'container[0,2.9]',
|
2019-03-08 22:25:00 +01:00
|
|
|
|
'label[2.5,0;'..S('Variable')..']',
|
2019-03-16 23:41:27 +01:00
|
|
|
|
'label[4,0;'..S('Current Value')..']',
|
2021-04-02 08:52:29 +02:00
|
|
|
|
'box[0,0.25;+contentWidth,0.02;#ffffff]',
|
2019-03-08 22:25:00 +01:00
|
|
|
|
'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)..']',
|
2019-04-12 21:56:06 +02:00
|
|
|
|
'label[0,2.1;'..S('Host Time')..'] label[2.5,2.1;{ht}] label[4,2.1;'..fe(timer_data.host_time)..']',
|
2021-02-12 20:23:40 +01:00
|
|
|
|
'label[0,2.5;'..S('Custom Timer')..'] label[2.5,2.5;{ct}] label[4,2.5;'..fe(S('As configured'))..']',
|
2019-03-08 22:25:00 +01:00
|
|
|
|
'container_end[]',
|
2019-10-16 01:00:11 +02:00
|
|
|
|
'container[6.25,0]',
|
|
|
|
|
'button[0,0;2,0.5;apply;'..S('Apply')..']',
|
2019-03-08 22:25:00 +01:00
|
|
|
|
'container_end[]'
|
|
|
|
|
}
|
|
|
|
|
})
|
2019-02-22 14:08:44 +01:00
|
|
|
|
end
|
2021-02-10 21:21:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mtimer.dialog.custom_timer = function (player_name)
|
2021-02-11 21:49:26 +01:00
|
|
|
|
local player_meta = minetest.get_player_by_name(player_name):get_meta()
|
|
|
|
|
local ctv = minetest.deserialize(player_meta:get_string(m.meta.custom_timer_settings.key))
|
|
|
|
|
|
2021-02-12 12:02:23 +01:00
|
|
|
|
local days = ctv.values.days or 0
|
|
|
|
|
local hours = ctv.values.hours or 0
|
|
|
|
|
local minutes = ctv.values.minutes or 0
|
|
|
|
|
local seconds = ctv.values.seconds or 0
|
2021-02-11 21:49:26 +01:00
|
|
|
|
|
|
|
|
|
local a_countdown = ctv.timer_mode == 'countdown' and 'x' or ''
|
|
|
|
|
local a_timer = ctv.timer_mode == 'timer' and 'x' or ''
|
|
|
|
|
local a_continuous = ctv.timer_mode == 'continuous' and 'x' or ''
|
2021-02-10 21:21:24 +01:00
|
|
|
|
|
2021-02-12 20:23:40 +01:00
|
|
|
|
local format_running = ctv.format.running or ''
|
|
|
|
|
local format_stopped = ctv.format.stopped or ''
|
|
|
|
|
local format_finished = ctv.format.finished or ''
|
|
|
|
|
|
2021-02-10 21:21:24 +01:00
|
|
|
|
mtimer.show_formspec('mtimer:custom_timer', {
|
|
|
|
|
title = S('Custom Timer'),
|
|
|
|
|
show_to = player_name,
|
2021-02-12 12:02:23 +01:00
|
|
|
|
height = 5.3,
|
2021-02-11 21:49:26 +01:00
|
|
|
|
width = 9,
|
2021-02-10 21:21:24 +01:00
|
|
|
|
formspec = {
|
2021-02-12 12:02:23 +01:00
|
|
|
|
'field_close_on_enter[v_format_running;false]',
|
|
|
|
|
'field_close_on_enter[v_format_stopped;false]',
|
|
|
|
|
'field_close_on_enter[v_format_finished;false]',
|
|
|
|
|
'field_close_on_enter[v_days;false]',
|
|
|
|
|
'field_close_on_enter[v_hours;false]',
|
|
|
|
|
'field_close_on_enter[v_minutes;false]',
|
|
|
|
|
'field_close_on_enter[v_seconds;false]',
|
2021-02-11 21:49:26 +01:00
|
|
|
|
'container[0,0]',
|
2021-02-12 20:23:40 +01:00
|
|
|
|
' 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)..']',
|
2021-04-02 08:52:29 +02:00
|
|
|
|
' box[0,2;+contentWidth,0.04;#ffffff]',
|
2021-02-11 21:49:26 +01:00
|
|
|
|
'container_end[]',
|
2021-02-12 12:02:23 +01:00
|
|
|
|
'container[3.75,2.4]',
|
2021-02-11 21:49:26 +01:00
|
|
|
|
' label[0,0;'..S('Information')..']',
|
|
|
|
|
' label[1.75,0;'..S('Variable')..']',
|
2021-02-12 12:02:23 +01:00
|
|
|
|
' label[3.25,0;'..S('Used Value')..']',
|
2021-02-11 21:49:26 +01:00
|
|
|
|
' box[0,0.25;5,0.02;#ffffff]',
|
|
|
|
|
' label[0,0.5;'..S('Days')..'] label[1.75,0.5;{days}] label[3.25,0.5;'..days..']',
|
|
|
|
|
' label[0,0.9;'..S('Hours')..'] label[1.75,0.9;{hours}] label[3.25,0.9;'..hours..']',
|
|
|
|
|
' label[0,1.3;'..S('Minutes')..'] label[1.75,1.3;{minutes}] label[3.25,1.3;'..minutes..']',
|
|
|
|
|
' label[0,1.7;'..S('Seconds')..'] label[1.75,1.7;{seconds}] label[3.25,1.7;'..seconds..']',
|
|
|
|
|
'container_end[]',
|
2021-02-12 12:02:23 +01:00
|
|
|
|
'container[0,2.3]',
|
2021-02-11 21:49:26 +01:00
|
|
|
|
' container[0,0]',
|
2021-02-12 12:02:23 +01:00
|
|
|
|
' button[0,0;0.75,0.25;c_days_p;+]',
|
|
|
|
|
' field[0,0.25;0.755,0.5;v_days;;'..days..']',
|
|
|
|
|
' button[0,0.75;0.75,0.25;c_days_m;-]',
|
2021-02-11 21:49:26 +01:00
|
|
|
|
' container_end[]',
|
|
|
|
|
' container[0.9,0]',
|
2021-02-12 12:02:23 +01:00
|
|
|
|
' button[0,0;0.75,0.25;c_hours_p;+]',
|
|
|
|
|
' field[0,0.25;0.755,0.5;v_hours;;'..hours..']',
|
|
|
|
|
' button[0,0.75;0.75,0.25;c_hours_m;-]',
|
2021-02-11 21:49:26 +01:00
|
|
|
|
' container_end[]',
|
|
|
|
|
' container[1.8,0]',
|
2021-02-12 12:02:23 +01:00
|
|
|
|
' button[0,0;0.75,0.25;c_minutes_p;+]',
|
|
|
|
|
' field[0,0.25;0.755,0.5;v_minutes;;'..minutes..']',
|
|
|
|
|
' button[0,0.75;0.75,0.25;c_minutes_m;-]',
|
2021-02-11 21:49:26 +01:00
|
|
|
|
' container_end[]',
|
|
|
|
|
' container[2.7,0]',
|
2021-02-12 12:02:23 +01:00
|
|
|
|
' button[0,0;0.75,0.25;c_seconds_p;+]',
|
|
|
|
|
' field[0,0.25;0.755,0.5;v_seconds;;'..seconds..']',
|
|
|
|
|
' button[0,0.75;0.75,0.25;c_seconds_m;-]',
|
2021-02-11 21:49:26 +01:00
|
|
|
|
' container_end[]',
|
|
|
|
|
'container_end[]',
|
2021-02-12 12:02:23 +01:00
|
|
|
|
'container[0,3.6]',
|
|
|
|
|
' button[0,0;0.25,0.25;mode_countdown;'..a_countdown..'] label[0.35,0.125;'..S('Countdown')..']',
|
|
|
|
|
' button[0,0.4;0.25,0.25;mode_timer;'..a_timer..'] label[0.35,0.525;'..S('Timer Mode')..']',
|
|
|
|
|
' button[0,0.8;0.25,0.25;mode_continuous;'..a_continuous..'] label[0.35,0.925;'..S('Continuous Run')..']',
|
2021-02-11 21:49:26 +01:00
|
|
|
|
'container_end[]',
|
2021-02-10 21:21:24 +01:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
end
|