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 = {
|
local def = {
|
||||||
show = true,
|
show = true,
|
||||||
max_y = max_y,
|
max = {x = -330, y = max_y},
|
||||||
hud_msg = msg,
|
hud_msg = msg,
|
||||||
hud_img = img and fmt("%s^[resize:64x64", img) or nil,
|
hud_img = img and fmt("%s^[resize:64x64", img) or nil,
|
||||||
hud_timer = 0,
|
hud_timer = 0,
|
||||||
|
@ -339,7 +339,7 @@ function i3.hud_notif(name, msg, img)
|
||||||
local notif = data.hud.notifs[i]
|
local notif = data.hud.notifs[i]
|
||||||
if notif then
|
if notif then
|
||||||
notif.show = true
|
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
|
notif.hud_timer = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
25
src/hud.lua
25
src/hud.lua
|
@ -29,15 +29,16 @@ local function init_hud(player)
|
||||||
}
|
}
|
||||||
end
|
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 function show_hud(player, data, notif, idx, dt)
|
||||||
local hud_info_bg = player:hud_get(notif.elems.bg)
|
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))
|
if offset.y < notif.max.y then
|
||||||
progress = 1 - (progress ^ 4)
|
|
||||||
local speed = i3.settings.hud_speed * (100 * progress) * dt
|
|
||||||
|
|
||||||
if offset_y < notif.max_y then
|
|
||||||
notif.show = false
|
notif.show = false
|
||||||
notif.hud_timer = notif.hud_timer + dt
|
notif.hud_timer = notif.hud_timer + dt
|
||||||
end
|
end
|
||||||
|
@ -49,6 +50,8 @@ local function show_hud(player, data, notif, idx, dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
if notif.show then
|
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
|
for _, def in pairs(notif.elems) do
|
||||||
local hud_info = player:hud_get(def)
|
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
|
y = hud_info.offset.y - speed
|
||||||
})
|
})
|
||||||
end
|
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
|
for _, def in pairs(notif.elems) do
|
||||||
local hud_info = player:hud_get(def)
|
local hud_info = player:hud_get(def)
|
||||||
|
|
||||||
player:hud_change(def, "offset", {
|
player:hud_change(def, "offset", {
|
||||||
x = hud_info.offset.x,
|
x = hud_info.offset.x + speed,
|
||||||
y = hud_info.offset.y + speed
|
y = hud_info.offset.y
|
||||||
})
|
})
|
||||||
|
|
||||||
if offset_y > 0 then
|
if offset.x > 0 then
|
||||||
player:hud_remove(def)
|
player:hud_remove(def)
|
||||||
remove(data.hud.notifs, idx)
|
remove(data.hud.notifs, idx)
|
||||||
end
|
end
|
||||||
|
|
Ŝarĝante…
Reference in New Issue