diff --git a/init.lua b/init.lua index a18eb03..2984f3b 100644 --- a/init.lua +++ b/init.lua @@ -7,6 +7,7 @@ mtimer = { show_formspec = {}, meta = { visible = { key = 'mtimer:visible', default = 'true' }, + position = { key = 'mtimer:position', default = 'bl' }, } } diff --git a/locale/mtimer.de.tr b/locale/mtimer.de.tr index 619a818..c1d6c17 100644 --- a/locale/mtimer.de.tr +++ b/locale/mtimer.de.tr @@ -1,7 +1,8 @@ # textdomain: mtimer # Configuration Selection Menu and chat command help -Toggle Visibility=Sichtbarkeit umschalten +mTimer Configuration=mTimer-Konfiguration +Set Visibility=Sichtbarkeit einstellen Set Position=Position setzen Set Color=Farbe einstellen Timezone Offset=Zeitzonenunterschied @@ -15,6 +16,10 @@ mTimer Visibility=mTimer-Sichtbarkeit Visible=Sichtbar Invisible=Unsichtbar +# Positioning +mTimer Position=mTimer-Position +Click the position you want to place the timer at.=Auf die Stelle klicken, an der der Timer angezeigt werden soll. + # Generic Formspec Strings Default=Standard Exit=Verlassen diff --git a/system/formspec_creation.lua b/system/formspec_creation.lua index 9ed7cc1..ced8937 100644 --- a/system/formspec_creation.lua +++ b/system/formspec_creation.lua @@ -4,15 +4,17 @@ local S = m.translator mtimer.show_formspec.main_menu = function (player_name) minetest.show_formspec(player_name, 'mtimer:main_menu', [[ - size[4,7.75] - button[0,0;4,1;set_visibility;]]..S('Set Visibility')..[[] - button[0,1;4,1;set_position;]]..S('Set Position')..[[] - button[0,2;4,1;set_color;]]..S('Set Color')..[[] - button[0,3;4,1;timezone_offset;]]..S('Timezone Offset')..[[] - button[0,4;4,1;ingame_time;]]..S('Ingame Time Representation')..[[] - button[0,5;4,1;real_time;]]..S('Real World Time Representation')..[[] - button[0,6;4,1;timer_text;]]..S('Set Timer Text')..[[] - button_exit[0,7;4,1;exit;]]..S('Exit')..[[] + 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')..[[] ]]) end @@ -21,6 +23,7 @@ mtimer.show_formspec.set_visibility = function (player_name) minetest.show_formspec(player_name, 'mtimer:set_visibility', [[ size[6,2.25] label[0,-0.125;]]..S('mTimer Visibility')..[[] + button[0,0.5;2,1;visible;]]..S('Visible')..[[] button[2,0.5;2,1;invisible;]]..S('Invisible')..[[] button[4,0.5;2,1;default;]]..S('Default')..[[] @@ -28,3 +31,35 @@ mtimer.show_formspec.set_visibility = function (player_name) button[3,1.5;3,1;back;]]..S('Main Menu')..[[] ]]) end + + +mtimer.show_formspec.set_position = function (player_name) + minetest.show_formspec(player_name, 'mtimer:set_position', [[ + size[8,6.125] + label[0,-0.125;]]..S('mTimer Position')..[[] + + 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.')..[[] + + button_exit[0,5.5;2,1;exit;]]..S('Exit')..[[] + button[2,5.5;2,1;back;]]..S('Main Menu')..[[] + button[4,5.5;2,1;default;]]..S('Default')..[[] + + ]]) +end + + + diff --git a/system/on_receive_fields.lua b/system/on_receive_fields.lua index 617e8c5..e61e620 100644 --- a/system/on_receive_fields.lua +++ b/system/on_receive_fields.lua @@ -9,6 +9,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) -- Select what formspec to show basing on main menu button if formname == 'mtimer:main_menu' then if fields.set_visibility then f.set_visibility(name) end + if fields.set_position then f.set_position(name) end end @@ -21,6 +22,20 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end + -- Set timer position + if formname == 'mtimer:set_position' then + local attr = m.meta.position + for p,_ in pairs(fields) do + if p == 'default' then + meta:set_string(attr.key, attr.default) + elseif p:gsub('_.*', '') == 'pos' then + local new_pos = p:gsub('pos_', '') + if new_pos ~= 'xx' then meta:set_string(attr.key, new_pos) end + end + end + end + + -- Back to menu from all formspecs if fields.back then f.main_menu(name) end diff --git a/textures/mtimer_positions_orientation.png b/textures/mtimer_positions_orientation.png new file mode 100644 index 0000000..f0475d6 Binary files /dev/null and b/textures/mtimer_positions_orientation.png differ diff --git a/textures/mtimer_transparent.png b/textures/mtimer_transparent.png new file mode 100644 index 0000000..4d7beb8 Binary files /dev/null and b/textures/mtimer_transparent.png differ