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
Ingame Time Format=Spielzeit-Format
Open Main Menu=Hauptmenü öffnen
Position=Ausrichtung
Real-World Time Format=Realzeit-Format
Host Time Format=Hostzeit-Format
Reset Everything=Alles zurücksetzen
@ -15,19 +14,29 @@ Session Start Time Format=Sitzungsstartzeit-Format
Timer Format=Timerformat
Timezone Offset=Zeitzonenunterschied
Custom Timer=Individueller Timer
Visibility=Sichtbarkeit
mTimer Configuration=mTimer-Konfiguration
# Visibility
# Dialog: Visibility
Visibility=Sichtbarkeit
Make invisible=Verbergen
Make visible=Anzeigen
The timer is currently @1.=Der Timer ist aktuell @1.
visible=sichtbar
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
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!
“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)
local player = minetest.get_player_by_name(player_name)
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', {
title = S('Visibility'),
show_to = player_name,
formspec = {
mtimer.get_icon_button('set_visible', { width = 4, 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.', timer_status)..']'
mtimer.get_icon_button('set_visible', {
width = 4,
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
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', {
title = S('Position'),
height = 5.35,
width = 8.25,
height = 7.2,
width = 10,
show_to = player_name,
formspec = {
'image_button[0,0;8,4.5 ;mtimer_positions_orientation.png;pos_xx;;;false]',
'image_button[0,0;2.67,1.5;mtimer_transparent.png;pos_tl;;;false]', -- TL
'image_button[2.67,0;2.67,1.5;mtimer_transparent.png;pos_tc;;;false]', -- TC
'image_button[5.34,0;2.67,1.5;mtimer_transparent.png;pos_tr;;;false]', -- TR
'image_button[0,1.5;2.67,1.5;mtimer_transparent.png;pos_ml;;;false]', -- ML
'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.')..']'
'image[0,0;'..i_width..','..i_height..';'..image..']',
b_define(1, 1, 'tl'), b_define(1, 2, 'tc'), b_define(1, 3, 'tr'),
b_define(2, 1, 'ml'), b_define(2, 2, 'mc'), b_define(2, 3, 'mr'),
b_define(3, 1, 'bl'), b_define(3, 2, 'bc'), b_define(3, 3, 'br'),
'label[0,6.5;'..howto..'\n'..p_info..']'
}
})
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
end
end
if not fields.quit then d.set_position(name) end
end