2019-02-16 16:45:32 +01:00
|
|
|
local m = mtimer
|
|
|
|
local S = m.translator
|
|
|
|
|
|
|
|
|
2019-02-18 22:02:59 +01:00
|
|
|
local build_frame = function (width, height, title)
|
|
|
|
local formspec_frame = [[
|
|
|
|
size[+width,+height] label[0,-0.125;+title]
|
|
|
|
container[0,+position]
|
|
|
|
button_exit[+exitpos,0;+bwidth,1;exit;]]..S('Exit')..[[]
|
|
|
|
button[+mainpos,0;+bwidth,1;main_menu;]]..S('Main Menu')..[[]
|
|
|
|
button[+defaultpos,0;+bwidth,1;default;]]..S('Default')..[[]
|
|
|
|
container_end[]
|
|
|
|
]]
|
|
|
|
|
|
|
|
return formspec_frame:gsub('%+%a+', {
|
|
|
|
['+width'] = width,
|
|
|
|
['+height'] = height,
|
|
|
|
['+title'] = title,
|
|
|
|
['+position'] = height-0.6,
|
|
|
|
['+bwidth'] = width/3,
|
|
|
|
['+exitpos'] = 0,
|
|
|
|
['+mainpos'] = width/3,
|
|
|
|
['+defaultpos'] = (width/3)*2
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
|
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-17 01:31:10 +01:00
|
|
|
size[4,8.25]
|
|
|
|
label[0,-0.125;]]..S('mTimer Configuration')..[[]
|
|
|
|
|
|
|
|
button[0,0.5;4,1;set_visibility;]]..S('Set Visibility')..[[]
|
|
|
|
button[0,1.5;4,1;set_position;]]..S('Set Position')..[[]
|
|
|
|
button[0,2.5;4,1;set_color;]]..S('Set Color')..[[]
|
|
|
|
button[0,3.5;4,1;timezone_offset;]]..S('Timezone Offset')..[[]
|
|
|
|
button[0,4.5;4,1;ingame_time;]]..S('Ingame Time Representation')..[[]
|
|
|
|
button[0,5.5;4,1;real_time;]]..S('Real World Time Representation')..[[]
|
|
|
|
button[0,6.5;4,1;timer_text;]]..S('Set Timer Text')..[[]
|
|
|
|
button_exit[0,7.5;4,1;exit;]]..S('Exit')..[[]
|
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',
|
|
|
|
build_frame(6, 2.25, S('mTimer Visibility'))..[[
|
|
|
|
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',
|
|
|
|
build_frame(8, 6.125, S('mTimer 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'),
|
|
|
|
minetest.colorize('#729fcf', 'bb'),
|
|
|
|
'AA'
|
|
|
|
})
|
|
|
|
|
2019-02-18 22:02:59 +01:00
|
|
|
minetest.show_formspec(player_name, 'mtimer:set_color',
|
|
|
|
build_frame(6, 2.7, S('mTimer Color'))..[[
|
2019-02-17 03:10:41 +01:00
|
|
|
field_close_on_enter[color;false]
|
|
|
|
field[0.25,0.75;3,1;color;;]]..color..[[]
|
|
|
|
box[3,0.55;0.65,0.65;]]..color..[[]
|
|
|
|
label[-0.05,1.45;]]..S('Use `@1` format only!', hexcolor)..[[]
|
|
|
|
]])
|
|
|
|
end
|