Improve notification look

This commit is contained in:
Jean-Patrick Guerrero 2023-04-01 18:13:21 +02:00
parent 21affdeeba
commit 6953a11279
3 changed files with 28 additions and 27 deletions

View File

@ -33,7 +33,7 @@ i3 = {
wielditem_fade_after = 3, wielditem_fade_after = 3,
save_interval = 600, -- Player data save interval (in seconds) save_interval = 600, -- Player data save interval (in seconds)
hud_speed = 1, hud_speed = 3,
hud_timer_max = 3, hud_timer_max = 3,
damage_enabled = core.settings:get_bool"enable_damage", damage_enabled = core.settings:get_bool"enable_damage",

View File

@ -16,17 +16,17 @@ local function init_hud(player)
bg = player:hud_add { bg = player:hud_add {
hud_elem_type = "image", hud_elem_type = "image",
position = {x = 1, y = 1}, position = {x = 1, y = 1},
offset = {x = -320, y = 0}, offset = {x = -330, y = 0},
alignment = {x = 1, y = 1}, alignment = {x = 1, y = 1},
scale = {x = 300, y = 105}, scale = {x = 0.6, y = 0.6},
text = "i3_bg.png", text = "i3_bg_notif.png",
z_index = 0xDEAD, z_index = 0xDEAD,
}, },
img = player:hud_add { img = player:hud_add {
hud_elem_type = "image", hud_elem_type = "image",
position = {x = 1, y = 1}, position = {x = 1, y = 1},
offset = {x = -310, y = 20}, offset = {x = -320, y = 20},
alignment = {x = 1, y = 1}, alignment = {x = 1, y = 1},
scale = {x = 1, y = 1}, scale = {x = 1, y = 1},
text = "", text = "",
@ -36,7 +36,7 @@ local function init_hud(player)
text = player:hud_add { text = player:hud_add {
hud_elem_type = "text", hud_elem_type = "text",
position = {x = 1, y = 1}, position = {x = 1, y = 1},
offset = {x = -235, y = 40}, offset = {x = -245, y = 40},
alignment = {x = 1, y = 1}, alignment = {x = 1, y = 1},
number = 0xffffff, number = 0xffffff,
text = "", text = "",
@ -57,13 +57,16 @@ local function init_hud(player)
} }
end end
local function show_hud(player, data) local function show_hud(player, data, dt)
local hud_info_bg = player:hud_get(data.hud.bg) local hud_info_bg = player:hud_get(data.hud.bg)
local dt = 0.016
local offset_y = hud_info_bg.offset.y local offset_y = hud_info_bg.offset.y
local speed = 5 * i3.settings.hud_speed
if offset_y < -100 then local max_y = -120
local progress = offset_y * (1 / (max_y - 5))
progress = 1 - (progress ^ 4)
local speed = i3.settings.hud_speed * (100 * progress) * dt
if offset_y < max_y then
data.show_hud = false data.show_hud = false
data.hud_timer = (data.hud_timer or 0) + dt data.hud_timer = (data.hud_timer or 0) + dt
end end
@ -85,8 +88,7 @@ local function show_hud(player, data)
}) })
end end
end end
elseif data.show_hud == false then elseif data.show_hud == false and data.hud_timer >= i3.settings.hud_timer_max then
if data.hud_timer >= i3.settings.hud_timer_max then
for name, def in pairs(data.hud) do for name, def in pairs(data.hud) do
if name ~= "wielditem" then if name ~= "wielditem" then
local hud_info = player:hud_get(def) local hud_info = player:hud_get(def)
@ -106,7 +108,6 @@ local function show_hud(player, data)
end end
end end
end end
end
core.register_globalstep(function(dt) core.register_globalstep(function(dt)
local players = get_connected_players() local players = get_connected_players()
@ -119,7 +120,7 @@ core.register_globalstep(function(dt)
if not data then return end if not data then return end
if data.show_hud ~= nil then if data.show_hud ~= nil then
show_hud(player, data) show_hud(player, data, dt)
end end
local has_text = player:hud_get(data.hud.wielditem).text ~= "" local has_text = player:hud_get(data.hud.wielditem).text ~= ""

BIN
textures/i3_bg_notif.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB