mirror of
https://gitlab.com/4w/mtimer.git
synced 2024-11-28 10:13:50 +01:00
fully implement hud element offset
This commit is contained in:
parent
93771fbbaf
commit
a7e89e6c2e
@ -257,8 +257,7 @@ mtimer.dialog.hud_element_size = function (player_name)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO Remove debug information when done
|
|
||||||
-- Debug offsets: y=20 x=50
|
|
||||||
mtimer.dialog.hud_element_offset = function (player_name)
|
mtimer.dialog.hud_element_offset = function (player_name)
|
||||||
local player = minetest.get_player_by_name(player_name)
|
local player = minetest.get_player_by_name(player_name)
|
||||||
local timer_data = fe(mtimer.get_timer_data(player_name).format)
|
local timer_data = fe(mtimer.get_timer_data(player_name).format)
|
||||||
@ -284,17 +283,16 @@ mtimer.dialog.hud_element_offset = function (player_name)
|
|||||||
'box[0,0;5,2.25;#ffffff33]',
|
'box[0,0;5,2.25;#ffffff33]',
|
||||||
'textarea[0,0;5,2.25;;;'..timer_data..']',
|
'textarea[0,0;5,2.25;;;'..timer_data..']',
|
||||||
'container[0,2.5]',
|
'container[0,2.5]',
|
||||||
' button[0,0;0.5,0.5;x_substract;'..S('-')..']',
|
' button[0,0;0.5,0.5;x_substract_1;'..S('-')..']',
|
||||||
' field[0.75,0;0.75,0.5;x_offset;;'..offset.x..']',
|
' field[0.75,0;0.75,0.5;x_offset;;'..offset.x..']',
|
||||||
' button[1.75,0;0.5,0.5;x_add;'..S('+')..']',
|
' button[1.75,0;0.5,0.5;x_add_1;'..S('+')..']',
|
||||||
'container_end[]',
|
'container_end[]',
|
||||||
'container[5.25,0]',
|
'container[5.25,0]',
|
||||||
' button[0,0;0.5,0.5;y_add;'..S('+')..']',
|
' button[0,0;0.5,0.5;y_add_1;'..S('+')..']',
|
||||||
' field[0,0.75;0.75,0.5;y_offset;;'..offset.y..']',
|
' field[0,0.75;0.75,0.5;y_offset;;'..offset.y..']',
|
||||||
' button[0,1.5;0.5,0.5;y_substract;'..S('-')..']',
|
' button[0,1.5;0.5,0.5;y_substract_1;'..S('-')..']',
|
||||||
'container_end[]',
|
'container_end[]',
|
||||||
'label[0.025,3.5;'..information..']',
|
'label[0.025,3.5;'..information..']',
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -151,8 +151,19 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
-- Set offset (used as border/padding) of the timer HUD element
|
-- Set offset (used as border/padding) of the timer HUD element
|
||||||
if formname == 'mtimer:hud_element_offset' then
|
if formname == 'mtimer:hud_element_offset' then
|
||||||
local attr = m.meta.hud_element_offset
|
local attr = m.meta.hud_element_offset
|
||||||
|
local default = minetest.deserialize(attr.default)
|
||||||
|
local x_offset = tonumber(fields.x_offset) or default.x
|
||||||
|
local y_offset = tonumber(fields.y_offset) or default.y
|
||||||
|
|
||||||
-- TODO Implement Logic for sanitizig and setting the offset
|
if fields.x_add_1 then x_offset = x_offset + 1 end
|
||||||
|
if fields.y_add_1 then y_offset = y_offset + 1 end
|
||||||
|
if fields.x_substract_1 then x_offset = x_offset - 1 end
|
||||||
|
if fields.y_substract_1 then y_offset = y_offset - 1 end
|
||||||
|
|
||||||
|
meta:set_string(attr.key, minetest.serialize({
|
||||||
|
x = x_offset,
|
||||||
|
y = y_offset
|
||||||
|
}))
|
||||||
|
|
||||||
if fields.default then meta:set_string(attr.key, attr.default) end
|
if fields.default then meta:set_string(attr.key, attr.default) end
|
||||||
if not fields.quit then d.hud_element_offset(name) end
|
if not fields.quit then d.hud_element_offset(name) end
|
||||||
|
Loading…
Reference in New Issue
Block a user