prepare implementation of custom timer

Addresses https://gitlab.com/4w/mtimer/-/issues/10
This commit is contained in:
Dirk Sohler 2021-02-10 21:21:24 +01:00
parent 6922ab9797
commit 5085711f6b
No known key found for this signature in database
GPG Key ID: B9751241BD7D4E1A
7 changed files with 30 additions and 1 deletions

@ -14,6 +14,7 @@ Session Duration Format=Sitzungsdauer-Format
Session Start Time Format=Sitzungsstartzeit-Format Session Start Time Format=Sitzungsstartzeit-Format
Timer Format=Timerformat Timer Format=Timerformat
Timezone Offset=Zeitzonenunterschied Timezone Offset=Zeitzonenunterschied
Custom Timer=Individueller Timer
Visibility=Sichtbarkeit Visibility=Sichtbarkeit
mTimer Configuration=mTimer-Konfiguration mTimer Configuration=mTimer-Konfiguration

@ -37,6 +37,7 @@ end
-- hs HUD size d.hud_element_size(name) -- hs HUD size d.hud_element_size(name)
-- os OffSet d.hud_element_offset(name) -- os OffSet d.hud_element_offset(name)
-- tf timer format d.timer_format(name) -- tf timer format d.timer_format(name)
-- ct custom timer d.custom_timer(name)
-- ------------------------------------------------------------------- -- -------------------------------------------------------------------
-- help Prints the help output showing the parameters -- help Prints the help output showing the parameters
-- --
@ -62,6 +63,7 @@ minetest.register_chatcommand('mtimer', {
if action == 'hs' then d.hud_element_size(name) end if action == 'hs' then d.hud_element_size(name) end
if action == 'os' then d.hud_element_offset(name) end if action == 'os' then d.hud_element_offset(name) end
if action == 'tf' then d.timer_format(name) end if action == 'tf' then d.timer_format(name) end
if action == 'ct' then d.custom_timer(name) end
if action == 'help' then if action == 'help' then
local message = { local message = {
@ -77,6 +79,7 @@ minetest.register_chatcommand('mtimer', {
command('hs')..S('HUD Element Size'), command('hs')..S('HUD Element Size'),
command('os')..S('HUD Element Offset'), command('os')..S('HUD Element Offset'),
command('tf')..S('Timer Format'), command('tf')..S('Timer Format'),
command('ct')..S('Custom Timer'),
command(' ')..S('Open Main Menu') command(' ')..S('Open Main Menu')
} }
cs(name, table.concat(message, '\n')) cs(name, table.concat(message, '\n'))

@ -51,6 +51,7 @@ mtimer.dialog.main_menu = function (player_name)
'label[0,0;'..S('Timer Configuration')..']', 'label[0,0;'..S('Timer Configuration')..']',
'button[0,0.25;3,0.5;timer_format;'..S('Timer Format')..']', 'button[0,0.25;3,0.5;timer_format;'..S('Timer Format')..']',
'button[0,1;3,0.5;timezone_offset;'..S('Timezone Offset')..']', 'button[0,1;3,0.5;timezone_offset;'..S('Timezone Offset')..']',
'button[0,1.75;3,0.5;custom_timer;'..S('Custom Timer')..']',
'container_end[]', 'container_end[]',
'container[0,4.125]', 'container[0,4.125]',
'box[0,0;+linewidth,0.04;#ffffff]', 'box[0,0;+linewidth,0.04;#ffffff]',
@ -324,3 +325,18 @@ mtimer.dialog.timer_format = function (player_name)
} }
}) })
end end
mtimer.dialog.custom_timer = function (player_name)
local timer_data = mtimer.get_timer_data(player_name)
mtimer.show_formspec('mtimer:custom_timer', {
title = S('Custom Timer'),
show_to = player_name,
height = 5.75,
width = 8.5,
formspec = {
'label[0,0;'..S('Custom Timer')..']',
}
})
end

@ -34,7 +34,8 @@ mtimer.get_timer_data = function (player_name)
['{it}'] = values.ingame_time, ['{it}'] = values.ingame_time,
['{st}'] = values.session_start_time, ['{st}'] = values.session_start_time,
['{sd}'] = values.session_duration, ['{sd}'] = values.session_duration,
['{ht}'] = values.host_time ['{ht}'] = values.host_time,
['{ct}'] = values.custom_timer
}) })
return values return values

@ -62,6 +62,7 @@ set('ingame_time_format', '{24h}:{min}')
set('real_time_format', '{24h}:{min} ({isodate})') set('real_time_format', '{24h}:{min} ({isodate})')
set('session_duration_format', '{hours}:{minutes}') set('session_duration_format', '{hours}:{minutes}')
set('session_start_time_format', '{isodate}T{isotime}') set('session_start_time_format', '{isodate}T{isotime}')
set('custom_timer_format', '{hours}:{minutes}:{seconds}')
-- Timer display format (the HUD elements content) -- Timer display format (the HUD elements content)
set('timer_format', table.concat({ set('timer_format', table.concat({

@ -29,6 +29,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields.hud_element_size then d.hud_element_size(name) end if fields.hud_element_size then d.hud_element_size(name) end
if fields.hud_element_offset then d.hud_element_offset(name) end if fields.hud_element_offset then d.hud_element_offset(name) end
if fields.timer_format then d.timer_format(name) end if fields.timer_format then d.timer_format(name) end
if fields.custom_timer then d.custom_timer(name) end
end end
@ -181,6 +182,12 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end end
-- TODO: Implement configure custom timer
if formname == 'mtimer:custom_timer' then
print(dump(fields))
end
-- Back to menu from all formspecs and conditionally update timer -- Back to menu from all formspecs and conditionally update timer
if fields.main_menu then d.main_menu(name) end if fields.main_menu then d.main_menu(name) end
if formname ~= 'mtimer:main_menu' then m.update_timer(name) end if formname ~= 'mtimer:main_menu' then m.update_timer(name) end

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB