More improvements to notification look
This commit is contained in:
parent
1684388851
commit
ad08ca56b8
|
@ -324,7 +324,7 @@ function i3.hud_notif(name, msg, img)
|
|||
|
||||
local def = {
|
||||
show = true,
|
||||
max_y = max_y,
|
||||
max = {x = -330, y = max_y},
|
||||
hud_msg = msg,
|
||||
hud_img = img and fmt("%s^[resize:64x64", img) or nil,
|
||||
hud_timer = 0,
|
||||
|
@ -339,7 +339,7 @@ function i3.hud_notif(name, msg, img)
|
|||
local notif = data.hud.notifs[i]
|
||||
if notif then
|
||||
notif.show = true
|
||||
notif.max_y = ((nb_notifs - i) + 1) * max_y
|
||||
notif.max.y = ((nb_notifs - i) + 1) * max_y
|
||||
notif.hud_timer = 0
|
||||
end
|
||||
end
|
||||
|
|
25
src/hud.lua
25
src/hud.lua
|
@ -29,15 +29,16 @@ local function init_hud(player)
|
|||
}
|
||||
end
|
||||
|
||||
local function get_progress(offset, max)
|
||||
local progress = offset * (1 / (max - 5))
|
||||
return 1 - (progress ^ 4)
|
||||
end
|
||||
|
||||
local function show_hud(player, data, notif, idx, dt)
|
||||
local hud_info_bg = player:hud_get(notif.elems.bg)
|
||||
local offset_y = hud_info_bg.offset.y
|
||||
local offset = hud_info_bg.offset
|
||||
|
||||
local progress = offset_y * (1 / (notif.max_y - 5))
|
||||
progress = 1 - (progress ^ 4)
|
||||
local speed = i3.settings.hud_speed * (100 * progress) * dt
|
||||
|
||||
if offset_y < notif.max_y then
|
||||
if offset.y < notif.max.y then
|
||||
notif.show = false
|
||||
notif.hud_timer = notif.hud_timer + dt
|
||||
end
|
||||
|
@ -49,6 +50,8 @@ local function show_hud(player, data, notif, idx, dt)
|
|||
end
|
||||
|
||||
if notif.show then
|
||||
local speed = i3.settings.hud_speed * (100 * get_progress(offset.y, notif.max.y)) * dt
|
||||
|
||||
for _, def in pairs(notif.elems) do
|
||||
local hud_info = player:hud_get(def)
|
||||
|
||||
|
@ -57,16 +60,18 @@ local function show_hud(player, data, notif, idx, dt)
|
|||
y = hud_info.offset.y - speed
|
||||
})
|
||||
end
|
||||
elseif notif.show == false and notif.hud_timer >= (i3.settings.hud_timer_max + (idx * 0.25)) then
|
||||
elseif notif.show == false and notif.hud_timer >= i3.settings.hud_timer_max then
|
||||
local speed = (i3.settings.hud_speed * 2.6) * (100 * get_progress(offset.x, notif.max.x)) * dt
|
||||
|
||||
for _, def in pairs(notif.elems) do
|
||||
local hud_info = player:hud_get(def)
|
||||
|
||||
player:hud_change(def, "offset", {
|
||||
x = hud_info.offset.x,
|
||||
y = hud_info.offset.y + speed
|
||||
x = hud_info.offset.x + speed,
|
||||
y = hud_info.offset.y
|
||||
})
|
||||
|
||||
if offset_y > 0 then
|
||||
if offset.x > 0 then
|
||||
player:hud_remove(def)
|
||||
remove(data.hud.notifs, idx)
|
||||
end
|
||||
|
|
Ŝarĝante…
Reference in New Issue