From 6953a11279c7a18f045679ab4de0481319d18943 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Sat, 1 Apr 2023 18:13:21 +0200 Subject: [PATCH] Improve notification look --- init.lua | 2 +- src/hud.lua | 53 ++++++++++++++++++++------------------- textures/i3_bg_notif.png | Bin 0 -> 5636 bytes 3 files changed, 28 insertions(+), 27 deletions(-) create mode 100644 textures/i3_bg_notif.png diff --git a/init.lua b/init.lua index 9829f2d..328327c 100644 --- a/init.lua +++ b/init.lua @@ -33,7 +33,7 @@ i3 = { wielditem_fade_after = 3, save_interval = 600, -- Player data save interval (in seconds) - hud_speed = 1, + hud_speed = 3, hud_timer_max = 3, damage_enabled = core.settings:get_bool"enable_damage", diff --git a/src/hud.lua b/src/hud.lua index 5bb0951..e5f0b5a 100644 --- a/src/hud.lua +++ b/src/hud.lua @@ -16,17 +16,17 @@ local function init_hud(player) bg = player:hud_add { hud_elem_type = "image", position = {x = 1, y = 1}, - offset = {x = -320, y = 0}, + offset = {x = -330, y = 0}, alignment = {x = 1, y = 1}, - scale = {x = 300, y = 105}, - text = "i3_bg.png", + scale = {x = 0.6, y = 0.6}, + text = "i3_bg_notif.png", z_index = 0xDEAD, }, img = player:hud_add { hud_elem_type = "image", position = {x = 1, y = 1}, - offset = {x = -310, y = 20}, + offset = {x = -320, y = 20}, alignment = {x = 1, y = 1}, scale = {x = 1, y = 1}, text = "", @@ -36,7 +36,7 @@ local function init_hud(player) text = player:hud_add { hud_elem_type = "text", position = {x = 1, y = 1}, - offset = {x = -235, y = 40}, + offset = {x = -245, y = 40}, alignment = {x = 1, y = 1}, number = 0xffffff, text = "", @@ -57,13 +57,16 @@ local function init_hud(player) } 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 dt = 0.016 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.hud_timer = (data.hud_timer or 0) + dt end @@ -85,25 +88,23 @@ local function show_hud(player, data) }) end end - elseif data.show_hud == false then - if data.hud_timer >= i3.settings.hud_timer_max then - for name, def in pairs(data.hud) do - if name ~= "wielditem" then - local hud_info = player:hud_get(def) + elseif data.show_hud == false and data.hud_timer >= i3.settings.hud_timer_max then + for name, def in pairs(data.hud) do + if name ~= "wielditem" then + local hud_info = player:hud_get(def) - player:hud_change(def, "offset", { - x = hud_info.offset.x, - y = hud_info.offset.y + speed - }) - end + player:hud_change(def, "offset", { + x = hud_info.offset.x, + y = hud_info.offset.y + speed + }) end + end - if offset_y > 0 then - data.show_hud = nil - data.hud_timer = nil - data.hud_msg = nil - data.hud_img = nil - end + if offset_y > 0 then + data.show_hud = nil + data.hud_timer = nil + data.hud_msg = nil + data.hud_img = nil end end end @@ -119,7 +120,7 @@ core.register_globalstep(function(dt) if not data then return end if data.show_hud ~= nil then - show_hud(player, data) + show_hud(player, data, dt) end local has_text = player:hud_get(data.hud.wielditem).text ~= "" diff --git a/textures/i3_bg_notif.png b/textures/i3_bg_notif.png new file mode 100644 index 0000000000000000000000000000000000000000..a9e3b3da260db0be6aee0279f6e28ca0fe1db520 GIT binary patch literal 5636 zcmeHLYg7~07M}2shay_F)rt^e6$K}mJRy;Qyo8hn0cj9K%49MLqvSynAfN(TW3`AN zUbxtz#R^)XD2k|P5mA)l>xz$BK`DxD1uVg93tFw*lYj!NU90u3+h12$z?pr%{q4QK zv(H{kHim`-+S$Hs3qg>bAjm%)g3Q1YYOo#yes}KJmIw?zX%S1b;b;n3rB+Ib1e~l* zRpDe@M@S(^*YZ<=PeI3=aqIhwKF`T~XI(=gQrQ2)7|pXM`t92HU9kk>QgoP&Lx za!Ve4mm&I9@2gk4E{|PWF|G8_m7`eu6W7&8{&8O6q*r#jq`v(c zyBzH13oG+uiRSsy`38sDE3T``zYfmpuF7y*RASis;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