From f27615d77ecaf3aa0fbfa9560b528ea775080ed9 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 7 Apr 2020 13:03:10 +0200 Subject: [PATCH] Add z_index to HUD elements --- mods/ENTITIES/mobs_mc/1_items_default.lua | 1 + mods/HUD/awards/api.lua | 10 +++++++--- mods/HUD/hudbars/init.lua | 5 +++++ mods/HUD/show_wielded_item/init.lua | 1 + mods/ITEMS/mcl_jukebox/init.lua | 1 + 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/1_items_default.lua b/mods/ENTITIES/mobs_mc/1_items_default.lua index 0929936430..e370934c9e 100644 --- a/mods/ENTITIES/mobs_mc/1_items_default.lua +++ b/mods/ENTITIES/mobs_mc/1_items_default.lua @@ -578,6 +578,7 @@ if c("totem") then position = { x=0.5, y=1 }, scale = { x=17, y=17 }, offset = { x=0, y=-178 }, + z_index = 10, }) minetest.after(3, function(name) local player = minetest.get_player_by_name(name) diff --git a/mods/HUD/awards/api.lua b/mods/HUD/awards/api.lua index 0722041748..f86cf0f234 100644 --- a/mods/HUD/awards/api.lua +++ b/mods/HUD/awards/api.lua @@ -297,7 +297,8 @@ function awards.unlock(name, award) text = background, position = {x = 0.5, y = 0}, offset = {x = 0, y = 138}, - alignment = {x = 0, y = -1} + alignment = {x = 0, y = -1}, + z_index = 11, }) local hud_announce if awdef.secret == true then @@ -313,7 +314,8 @@ function awards.unlock(name, award) text = hud_announce, position = {x = 0.5, y = 0}, offset = {x = 0, y = 40}, - alignment = {x = 0, y = -1} + alignment = {x = 0, y = -1}, + z_index = 12, }) local three = player:hud_add({ hud_elem_type = "text", @@ -323,7 +325,8 @@ function awards.unlock(name, award) text = title, position = {x = 0.5, y = 0}, offset = {x = 30, y = 100}, - alignment = {x = 0, y = -1} + alignment = {x = 0, y = -1}, + z_index = 12, }) --[[ We use a statbar instead of image here because statbar allows us to scale the image properly. Note that number is 2, thus leading to a single full image. @@ -339,6 +342,7 @@ function awards.unlock(name, award) offset = {x = -110, y = 62}, alignment = {x = 0, y = 0}, direction = 0, + z_index = 12, }) minetest.after(3, function(name) local player = minetest.get_player_by_name(name) diff --git a/mods/HUD/hudbars/init.lua b/mods/HUD/hudbars/init.lua index 0f91960224..9c7708bdd6 100644 --- a/mods/HUD/hudbars/init.lua +++ b/mods/HUD/hudbars/init.lua @@ -200,6 +200,7 @@ function hb.register_hudbar(identifier, text_color, label, textures, default_sta text = "hudbars_bar_background.png", alignment = {x=1,y=1}, offset = { x = offset.x - 1, y = offset.y - 1 }, + z_index = 0, }) if textures.icon ~= nil then ids.icon = player:hud_add({ @@ -209,6 +210,7 @@ function hb.register_hudbar(identifier, text_color, label, textures, default_sta text = textures.icon, alignment = {x=-1,y=1}, offset = { x = offset.x - 3, y = offset.y }, + z_index = 1, }) end elseif hb.settings.bar_type == "statbar_modern" then @@ -222,6 +224,7 @@ function hb.register_hudbar(identifier, text_color, label, textures, default_sta offset = { x = offset.x, y = offset.y }, direction = 0, size = {x=24, y=24}, + z_index = 0, }) end end @@ -248,6 +251,7 @@ function hb.register_hudbar(identifier, text_color, label, textures, default_sta offset = offset, direction = 0, size = bar_size, + z_index = 1, }) if hb.settings.bar_type == "progress_bar" then ids.text = player:hud_add({ @@ -258,6 +262,7 @@ function hb.register_hudbar(identifier, text_color, label, textures, default_sta number = text_color, direction = 0, offset = { x = offset.x + 2, y = offset.y - 1}, + z_index = 2, }) end -- Do not forget to update hb.get_hudbar_state if you add new fields to the state table diff --git a/mods/HUD/show_wielded_item/init.lua b/mods/HUD/show_wielded_item/init.lua index addd92e0ec..04cef8450c 100644 --- a/mods/HUD/show_wielded_item/init.lua +++ b/mods/HUD/show_wielded_item/init.lua @@ -42,6 +42,7 @@ local function set_hud(player) alignment = {x=0, y=0}, number = 0xFFFFFF , text = "", + z_index = 10, }) end diff --git a/mods/ITEMS/mcl_jukebox/init.lua b/mods/ITEMS/mcl_jukebox/init.lua index 1329864f16..0328c70727 100644 --- a/mods/ITEMS/mcl_jukebox/init.lua +++ b/mods/ITEMS/mcl_jukebox/init.lua @@ -70,6 +70,7 @@ local function now_playing(player, track_id) size = { x=100, y=100}, number = 0x55FFFF, text = text, + z_index = 10, }) active_huds[playername] = id end