use new style for position dialog

addresses https://gitlab.com/4w/mtimer/-/issues/16
This commit is contained in:
Dirk Sohler 2021-04-04 17:15:32 +02:00
parent f7d6025557
commit 75365e2f1c
No known key found for this signature in database
GPG Key ID: B9751241BD7D4E1A
3 changed files with 61 additions and 21 deletions

@ -4,7 +4,6 @@
Color=Farbe Color=Farbe
Ingame Time Format=Spielzeit-Format Ingame Time Format=Spielzeit-Format
Open Main Menu=Hauptmenü öffnen Open Main Menu=Hauptmenü öffnen
Position=Ausrichtung
Real-World Time Format=Realzeit-Format Real-World Time Format=Realzeit-Format
Host Time Format=Hostzeit-Format Host Time Format=Hostzeit-Format
Reset Everything=Alles zurücksetzen Reset Everything=Alles zurücksetzen
@ -15,19 +14,29 @@ Session Start Time Format=Sitzungsstartzeit-Format
Timer Format=Timerformat Timer Format=Timerformat
Timezone Offset=Zeitzonenunterschied Timezone Offset=Zeitzonenunterschied
Custom Timer=Individueller Timer Custom Timer=Individueller Timer
Visibility=Sichtbarkeit
mTimer Configuration=mTimer-Konfiguration mTimer Configuration=mTimer-Konfiguration
# Visibility # Dialog: Visibility
Visibility=Sichtbarkeit
Make invisible=Verbergen Make invisible=Verbergen
Make visible=Anzeigen Make visible=Anzeigen
The timer is currently @1.=Der Timer ist aktuell @1. The timer is currently @1.=Der Timer ist aktuell @1.
visible=sichtbar visible=sichtbar
invisible=verborgen invisible=verborgen
# Dialog: Position
Position=Ausrichtung
Click the position you want to place the timer at.=Auf die Stelle klicken, an der der Timer angezeigt werden soll.
Current position: @1=Aktuelle Position: @1
top=Oben
middle=mittig
bottom=Unten
left=links
center=zentriert
right=rechts
# Information & Warnings # Information & Warnings
30 minutes @= 0.5, 60 minutes @= 1=30 Minuten @= 0.5, 60 Minuten @= 1 30 minutes @= 0.5, 60 minutes @= 1=30 Minuten @= 0.5, 60 Minuten @= 1
Click the position you want to place the timer at.=Auf die Stelle klicken, an der der Timer angezeigt werden soll.
Use `@1` format only!=Ausschließlich `@1`-Format benutzen! Use `@1` format only!=Ausschließlich `@1`-Format benutzen!
“Arbitrary” values are possible.=Es sind „beliebige“ Werte möglich. “Arbitrary” values are possible.=Es sind „beliebige“ Werte möglich.

@ -27,38 +27,68 @@ local esc = minetest.formspec_escape
mtimer.dialog.set_visibility = function (player_name) mtimer.dialog.set_visibility = function (player_name)
local player = minetest.get_player_by_name(player_name) local player = minetest.get_player_by_name(player_name)
local visible = player:get_meta():get_string(m.meta.visible.key) local visible = player:get_meta():get_string(m.meta.visible.key)
local timer_status = visible == 'true' and S('visible') or S('invisible') local status = visible == 'true' and S('visible') or S('invisible')
mtimer.show_formspec('mtimer:set_visibility', { mtimer.show_formspec('mtimer:set_visibility', {
title = S('Visibility'), title = S('Visibility'),
show_to = player_name, show_to = player_name,
formspec = { formspec = {
mtimer.get_icon_button('set_visible', { width = 4, label = S('Make visible') }), mtimer.get_icon_button('set_visible', {
mtimer.get_icon_button('set_invisible', { width = 4, label = S('Make invisible'), container = { left = 4.25 } }), width = 4,
'label[0,1.25;'..S('The timer is currently @1.', timer_status)..']' label = S('Make visible')
}),
mtimer.get_icon_button('set_invisible', {
width = 4,
label = S('Make invisible'),
container = { left = 4.25 }
}),
'label[0,1.25;'..S('The timer is currently @1.', status)..']'
} }
}) })
end end
mtimer.dialog.set_position = function (player_name) mtimer.dialog.set_position = function (player_name)
local player = minetest.get_player_by_name(player_name)
local howto = S('Click the position you want to place the timer at.')
-- Get current position name
local p_value = player:get_meta():get_string(m.meta.position.key)
local p_names = {
['t'] = S('top'), ['m'] = S('middle'), ['b'] = S('bottom'),
['l'] = S('left'), ['c'] = S('center'), ['r'] = S('right')
}
local p_name = p_names[p_value:sub(1,1)]..' '..p_names[p_value:sub(2,2)]
local p_info = S('Current position: @1', p_name)
-- Set up image
local image = 'mtimer_positions_orientation.png'
local i_width = 10
local i_height = 6
-- Return the parsed button
local b_define = function(t, l, p)
return ('image_button[+l,+t;+w,+h;+i;pos_+p;d;;false]'):gsub('%+%w', {
['+l'] = (l - 1) * (i_width / 3),
['+t'] = (t - 1) * (i_height / 3),
['+w'] = i_width / 3,
['+h'] = i_height / 3,
['+i'] = 'mtimer_transparent.png',
['+p'] = p,
})
end
mtimer.show_formspec('mtimer:set_position', { mtimer.show_formspec('mtimer:set_position', {
title = S('Position'), title = S('Position'),
height = 5.35, height = 7.2,
width = 8.25, width = 10,
show_to = player_name, show_to = player_name,
formspec = { formspec = {
'image_button[0,0;8,4.5 ;mtimer_positions_orientation.png;pos_xx;;;false]', 'image[0,0;'..i_width..','..i_height..';'..image..']',
'image_button[0,0;2.67,1.5;mtimer_transparent.png;pos_tl;;;false]', -- TL b_define(1, 1, 'tl'), b_define(1, 2, 'tc'), b_define(1, 3, 'tr'),
'image_button[2.67,0;2.67,1.5;mtimer_transparent.png;pos_tc;;;false]', -- TC b_define(2, 1, 'ml'), b_define(2, 2, 'mc'), b_define(2, 3, 'mr'),
'image_button[5.34,0;2.67,1.5;mtimer_transparent.png;pos_tr;;;false]', -- TR b_define(3, 1, 'bl'), b_define(3, 2, 'bc'), b_define(3, 3, 'br'),
'image_button[0,1.5;2.67,1.5;mtimer_transparent.png;pos_ml;;;false]', -- ML 'label[0,6.5;'..howto..'\n'..p_info..']'
'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
'label[0,4.75;'..S('Click the position you want to place the timer at.')..']'
} }
}) })
end end

@ -53,6 +53,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if new_pos ~= 'xx' then meta:set_string(attr.key, new_pos) end if new_pos ~= 'xx' then meta:set_string(attr.key, new_pos) end
end end
end end
if not fields.quit then d.set_position(name) end
end end