More HUD improvements
This commit is contained in:
parent
c64f28a90b
commit
83623effbf
|
@ -341,7 +341,7 @@ function i3.hud_notif(name, msg, img)
|
||||||
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.5 * (nb_notifs - i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -826,6 +826,7 @@ local _ = {
|
||||||
|
|
||||||
-- Math
|
-- Math
|
||||||
round = round,
|
round = round,
|
||||||
|
abs = math.abs,
|
||||||
min = math.min,
|
min = math.min,
|
||||||
max = math.max,
|
max = math.max,
|
||||||
ceil = math.ceil,
|
ceil = math.ceil,
|
||||||
|
|
12
src/hud.lua
12
src/hud.lua
|
@ -1,4 +1,4 @@
|
||||||
IMPORT("ceil", "remove", "str_to_pos")
|
IMPORT("abs", "max", "ceil", "remove", "str_to_pos")
|
||||||
IMPORT("get_connected_players", "add_hud_waypoint")
|
IMPORT("get_connected_players", "add_hud_waypoint")
|
||||||
|
|
||||||
local function init_hud(player)
|
local function init_hud(player)
|
||||||
|
@ -29,8 +29,8 @@ local function init_hud(player)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_progress(offset, max)
|
local function get_progress(offset, max_val)
|
||||||
local progress = offset * (1 / (max - 5))
|
local progress = offset * (1 / (max_val - 5))
|
||||||
return 1 - (progress ^ 4)
|
return 1 - (progress ^ 4)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ local function show_hud(player, data, notif, idx, dt)
|
||||||
|
|
||||||
if offset.y < notif.max.y then
|
if offset.y < notif.max.y then
|
||||||
notif.show = false
|
notif.show = false
|
||||||
notif.hud_timer = notif.hud_timer + dt
|
notif.hud_timer += dt
|
||||||
end
|
end
|
||||||
|
|
||||||
player:hud_change(notif.elems.text, "text", notif.hud_msg)
|
player:hud_change(notif.elems.text, "text", notif.hud_msg)
|
||||||
|
@ -57,7 +57,7 @@ local function show_hud(player, data, notif, idx, dt)
|
||||||
|
|
||||||
player:hud_change(def, "offset", {
|
player:hud_change(def, "offset", {
|
||||||
x = hud_info.offset.x,
|
x = hud_info.offset.x,
|
||||||
y = hud_info.offset.y - speed
|
y = hud_info.offset.y - (speed * max(1, (#data.hud.notifs - idx + 1) / 1.4))
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
elseif notif.show == false and notif.hud_timer >= i3.settings.hud_timer_max then
|
elseif notif.show == false and notif.hud_timer >= i3.settings.hud_timer_max then
|
||||||
|
@ -71,7 +71,7 @@ local function show_hud(player, data, notif, idx, dt)
|
||||||
y = hud_info.offset.y
|
y = hud_info.offset.y
|
||||||
})
|
})
|
||||||
|
|
||||||
if offset.x > 0 then
|
if hud_info.offset.x > abs(notif.max.x) 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