2019-02-16 16:45:32 +01:00
|
|
|
local m = mtimer
|
|
|
|
local S = m.translator
|
2019-02-21 21:07:35 +01:00
|
|
|
local build_frame = m.build_frame
|
2019-02-22 13:06:03 +01:00
|
|
|
local fe = minetest.formspec_escape
|
2019-02-18 22:02:59 +01:00
|
|
|
|
|
|
|
|
2019-02-16 17:33:16 +01:00
|
|
|
mtimer.show_formspec.main_menu = function (player_name)
|
2019-02-16 16:45:32 +01:00
|
|
|
minetest.show_formspec(player_name, 'mtimer:main_menu', [[
|
2019-02-22 18:49:00 +01:00
|
|
|
size[9.5,6]
|
|
|
|
|
|
|
|
container[0,0]
|
|
|
|
label[0,0;]]..S('Visuals')..[[]
|
|
|
|
button[0,0.5;3,1;set_visibility;]]..S('Visibility')..[[]
|
|
|
|
button[0,1.5;3,1;set_position;]]..S('Position')..[[]
|
|
|
|
button[0,2.5;3,1;set_color;]]..S('Color')..[[]
|
|
|
|
container_end[]
|
|
|
|
|
|
|
|
container[3.25,0]
|
|
|
|
label[0,0;]]..S('Time Representation')..[[]
|
|
|
|
button[0,0.5;3,1;ingame_time_format;]]..S('Ingame Time Format')..[[]
|
|
|
|
button[0,1.5;3,1;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,3.5;3,1;session_duration_format;]]..S('Session Duration Format')..[[]
|
|
|
|
container_end[]
|
|
|
|
|
|
|
|
container[6.5,]
|
|
|
|
label[0,0;]]..S('Timer Configuration')..[[]
|
|
|
|
button[0,0.5;3,1;timer_format;]]..S('Timer Format')..[[]
|
|
|
|
button[0,1.5;3,1;timezone_offset;]]..S('Timezone Offset')..[[]
|
|
|
|
container_end[]
|
|
|
|
|
|
|
|
container[0,5.25]
|
|
|
|
box[0,0;9.25,0.02;#ffffff]
|
|
|
|
button[3.49,0.125;3,1;reset_everything;]]..S('Reset Everything')..[[]
|
|
|
|
button_exit[6.49,0.125;3,1;exit;]]..S('Exit')..[[]
|
|
|
|
container_end[]
|
2019-02-16 16:45:32 +01:00
|
|
|
]])
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
mtimer.show_formspec.set_visibility = function (player_name)
|
2019-02-18 22:02:59 +01:00
|
|
|
minetest.show_formspec(player_name, 'mtimer:set_visibility',
|
2019-02-21 21:07:35 +01:00
|
|
|
build_frame(6, 2.25, S('Visibility'))..[[
|
2019-02-18 22:02:59 +01:00
|
|
|
button[0,0.5;3,1;visible;]]..S('Visible')..[[]
|
|
|
|
button[3,0.5;3,1;invisible;]]..S('Invisible')..[[]
|
2019-02-16 16:45:32 +01:00
|
|
|
]])
|
|
|
|
end
|
2019-02-17 01:31:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
mtimer.show_formspec.set_position = function (player_name)
|
2019-02-18 22:02:59 +01:00
|
|
|
minetest.show_formspec(player_name, 'mtimer:set_position',
|
2019-02-21 21:07:35 +01:00
|
|
|
build_frame(8, 6.2, S('Position'))..[[
|
2019-02-17 01:31:10 +01:00
|
|
|
|
|
|
|
image_button[0,0.5;8,4.5 ;mtimer_positions_orientation.png;pos_xx;;;false]
|
|
|
|
|
|
|
|
image_button[0,0.5;2.67,1.5;mtimer_transparent.png;pos_tl;;;false]
|
|
|
|
image_button[2.67,0.5;2.67,1.5;mtimer_transparent.png;pos_tc;;;false]
|
|
|
|
image_button[5.34,0.5;2.67,1.5;mtimer_transparent.png;pos_tr;;;false]
|
|
|
|
|
|
|
|
image_button[0,2;2.67,1.5;mtimer_transparent.png;pos_ml;;;false]
|
|
|
|
image_button[2.67,2;2.67,1.5;mtimer_transparent.png;pos_mc;;;false]
|
|
|
|
image_button[5.34,2;2.67,1.5;mtimer_transparent.png;pos_mr;;;false]
|
|
|
|
|
|
|
|
image_button[0,3.5;2.67,1.5;mtimer_transparent.png;pos_bl;;;false]
|
|
|
|
image_button[2.67,3.5;2.67,1.5;mtimer_transparent.png;pos_bc;;;false]
|
|
|
|
image_button[5.34,3.5;2.67,1.5;mtimer_transparent.png;pos_br;;;false]
|
|
|
|
|
|
|
|
label[0,5;]]..S('Click the position you want to place the timer at.')..[[]
|
|
|
|
]])
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2019-02-17 03:10:41 +01:00
|
|
|
mtimer.show_formspec.set_color = function (player_name)
|
|
|
|
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-02-18 22:02:59 +01:00
|
|
|
minetest.show_formspec(player_name, 'mtimer:set_color',
|
2019-02-21 21:07:35 +01:00
|
|
|
build_frame(6, 2.7, S('Color'))..[[
|
2019-02-17 03:10:41 +01:00
|
|
|
field_close_on_enter[color;false]
|
|
|
|
field[0.25,0.75;3,1;color;;]]..color..[[]
|
2019-02-22 15:29:08 +01:00
|
|
|
box[3,0.55;0.65,0.65;]]..color..[[ff]
|
2019-02-17 03:10:41 +01:00
|
|
|
label[-0.05,1.45;]]..S('Use `@1` format only!', hexcolor)..[[]
|
|
|
|
]])
|
|
|
|
end
|
2019-02-19 13:40:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
mtimer.show_formspec.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
|
|
|
|
|
|
|
local format_information = table.concat({
|
|
|
|
S('30 minutes @= 0.5, 60 minutes @= 1'),
|
|
|
|
S('“Arbitrary” values are possible.')
|
|
|
|
}, '\n')
|
|
|
|
|
|
|
|
local time_information = table.concat({
|
2019-02-21 21:07:35 +01:00
|
|
|
S('Server Time: @1', time_data.times.server_time),
|
|
|
|
S('Local Time: @1', time_data.times.local_time)
|
2019-02-19 13:40:19 +01:00
|
|
|
}, '\n')
|
|
|
|
|
|
|
|
minetest.show_formspec(player_name, 'mtimer:timezone_offset',
|
2019-02-21 21:07:35 +01:00
|
|
|
build_frame(7, 3.125, S('Timezone Offset'))..[[
|
2019-02-19 13:40:19 +01:00
|
|
|
field_close_on_enter[offset;false]
|
2019-02-21 21:07:35 +01:00
|
|
|
field[0.25,0.75;3,1;offset;;]]..time_data.times.offset..[[]
|
2019-02-19 13:40:19 +01:00
|
|
|
label[3,0.425;]]..format_information..[[]
|
|
|
|
label[0,1.45;]]..time_information..[[]
|
|
|
|
]])
|
|
|
|
end
|
2019-02-21 16:16:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
mtimer.show_formspec.ingame_time_format = function (player_name)
|
|
|
|
local time_data = mtimer.get_times(player_name).ingame_time
|
|
|
|
|
|
|
|
minetest.show_formspec(player_name, 'mtimer:ingame_time_format',
|
2019-02-21 21:07:35 +01:00
|
|
|
build_frame(7, 4.9, S('Ingame Time Format'))..[[
|
2019-02-21 16:16:10 +01:00
|
|
|
field_close_on_enter[format;false]
|
2019-02-22 13:06:03 +01:00
|
|
|
field[0.25,0.75;7,1;format;;]]..fe(time_data.format)..[[]
|
2019-02-21 16:16:10 +01:00
|
|
|
container[0,1.425]
|
|
|
|
|
2019-02-21 16:25:07 +01:00
|
|
|
label[2.8,0;]]..S('Variable')..[[]
|
2019-02-21 16:16:10 +01:00
|
|
|
label[4.25,0;]]..S('Current value')..[[]
|
|
|
|
|
|
|
|
box[0,0.45;6.75,0.02;#ffffff]
|
|
|
|
|
|
|
|
label[0,0.5;]]..S('Hours (24h)')..[[]
|
2019-02-21 16:25:07 +01:00
|
|
|
label[2.8,0.5;{24h}]
|
2019-02-21 16:16:10 +01:00
|
|
|
label[4.25,0.5;]]..time_data.hours_24..[[]
|
|
|
|
|
|
|
|
label[0,0.9;]]..S('Hours (12h)')..[[]
|
2019-02-21 16:25:07 +01:00
|
|
|
label[2.8,0.9;{12h}]
|
2019-02-21 16:16:10 +01:00
|
|
|
label[4.25,0.9;]]..time_data.hours_12..[[]
|
|
|
|
|
|
|
|
label[0,1.3;]]..S('Minutes')..[[]
|
2019-02-21 16:25:07 +01:00
|
|
|
label[2.8,1.3;{min}]
|
2019-02-21 16:16:10 +01:00
|
|
|
label[4.25,1.3;]]..time_data.minutes..[[]
|
|
|
|
|
|
|
|
label[0,1.7;]]..S('Ingame Timestamp')..[[]
|
2019-02-21 16:25:07 +01:00
|
|
|
label[2.8,1.7;{its}]
|
2019-02-21 16:16:10 +01:00
|
|
|
label[4.25,1.7;]]..time_data.ingame_timestamp..[[]
|
|
|
|
|
|
|
|
box[0,2.2;6.75,0.02;#ffffff]
|
|
|
|
|
|
|
|
label[0,2.25;]]..S('Current Result')..[[]
|
2019-02-22 13:06:03 +01:00
|
|
|
label[2.8,2.25;]]..fe(time_data.formatted)..[[]
|
2019-02-21 16:16:10 +01:00
|
|
|
container_end[]
|
|
|
|
]])
|
|
|
|
end
|
2019-02-21 21:07:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
mtimer.show_formspec.real_world_time_format = function (player_name)
|
|
|
|
mtimer.show_formspec.real_time_universal(player_name, {
|
|
|
|
time_type = 'real_time',
|
|
|
|
formspec_name = 'mtimer:real_world_time_format',
|
|
|
|
title = S('Real-World Time Format')
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
mtimer.show_formspec.session_start_time_format = function (player_name)
|
|
|
|
mtimer.show_formspec.real_time_universal(player_name, {
|
|
|
|
time_type = 'session_start_time',
|
|
|
|
formspec_name = 'mtimer:session_start_time_format',
|
|
|
|
title = S('Session Start Time Format')
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
mtimer.show_formspec.session_duration_format = function (player_name)
|
|
|
|
local time_data = mtimer.get_times(player_name).session_duration
|
|
|
|
|
|
|
|
minetest.show_formspec(player_name, 'mtimer:session_duration_format',
|
|
|
|
build_frame(7, 5, S('Session Duration Format'))..[[
|
|
|
|
field_close_on_enter[format;false]
|
2019-02-22 13:06:03 +01:00
|
|
|
field[0.25,0.75;7,1;format;;]]..fe(time_data.format)..[[]
|
2019-02-21 21:07:35 +01:00
|
|
|
|
|
|
|
container[0,1.425]
|
|
|
|
|
|
|
|
label[2.5,0;]]..S('Variable')..[[]
|
|
|
|
label[4,0;]]..S('Current value')..[[]
|
|
|
|
|
|
|
|
box[0,0.45;6.75,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.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..[[]
|
|
|
|
|
|
|
|
box[0,2.2;6.75,0.02;#ffffff]
|
|
|
|
|
|
|
|
label[0,2.25;]]..S('Current Result')..[[]
|
2019-02-22 13:06:03 +01:00
|
|
|
label[2.5,2.25;]]..fe(time_data.formatted)..[[]
|
2019-02-21 21:07:35 +01:00
|
|
|
|
|
|
|
container_end[]
|
|
|
|
]])
|
|
|
|
end
|
2019-02-22 14:08:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
mtimer.show_formspec.timer_format = function (player_name)
|
|
|
|
local timer_data = mtimer.get_timer_data(player_name)
|
|
|
|
minetest.show_formspec(player_name, 'mtimer:timer_format',
|
|
|
|
build_frame(9, 5.8, S('Timer Format'))..[[
|
|
|
|
textarea[0.25,0.5;6,2.5;format;;]]..fe(timer_data.format)..[[]
|
|
|
|
|
|
|
|
container[0,2.785]
|
|
|
|
|
|
|
|
label[2.5,0;]]..S('Variable')..[[]
|
|
|
|
label[4,0;]]..S('Current value')..[[]
|
|
|
|
|
|
|
|
box[0,0.45;8.75,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)..[[]
|
|
|
|
|
|
|
|
container_end[]
|
|
|
|
|
|
|
|
container[6,0.45]
|
|
|
|
button[0,0;3,1;apply;]]..S('Apply')..[[]
|
|
|
|
container_end[]
|
|
|
|
|
|
|
|
]])
|
|
|
|
end
|