Update hud.lua
This commit is contained in:
parent
5451e58ec6
commit
ed29b218a1
@ -5,8 +5,26 @@ local textoffsety = barheight / 2 - textheight / 2
|
|||||||
|
|
||||||
function createinfobar()
|
function createinfobar()
|
||||||
local infobar = LUI.UIElement.new({
|
local infobar = LUI.UIElement.new({
|
||||||
left = GameX.IsHardcoreMode() and 0 or 213,
|
left = 213,
|
||||||
top = GameX.IsHardcoreMode() and 0 or -6,
|
top = -6,
|
||||||
|
height = barheight,
|
||||||
|
width = 70,
|
||||||
|
leftAnchor = true,
|
||||||
|
topAnchor = true
|
||||||
|
})
|
||||||
|
|
||||||
|
infobar:registerAnimationState("minimap_on", {
|
||||||
|
left = 213,
|
||||||
|
top = -6,
|
||||||
|
height = barheight,
|
||||||
|
width = 70,
|
||||||
|
leftAnchor = true,
|
||||||
|
topAnchor = true
|
||||||
|
})
|
||||||
|
|
||||||
|
infobar:registerAnimationState("minimap_off", {
|
||||||
|
left = 0,
|
||||||
|
top = 0,
|
||||||
height = barheight,
|
height = barheight,
|
||||||
width = 70,
|
width = 70,
|
||||||
leftAnchor = true,
|
leftAnchor = true,
|
||||||
@ -24,6 +42,37 @@ function createinfobar()
|
|||||||
return infobar
|
return infobar
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function updateinfobarvisibility()
|
||||||
|
local root = Engine.GetLuiRoot()
|
||||||
|
local menus = root:AnyActiveMenusInStack()
|
||||||
|
local infobar = root.infobar
|
||||||
|
|
||||||
|
if (not infobar) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if (menus or Game.InKillCam()) then
|
||||||
|
infobar:animateToState("hud_off")
|
||||||
|
else
|
||||||
|
infobar:animateToState("hud_on")
|
||||||
|
end
|
||||||
|
|
||||||
|
local validstates = {
|
||||||
|
"hud_on",
|
||||||
|
"active",
|
||||||
|
"nosignal",
|
||||||
|
"scrambled"
|
||||||
|
}
|
||||||
|
|
||||||
|
infobar:animateToState("minimap_off")
|
||||||
|
for i = 1, #validstates do
|
||||||
|
if (validstates[i] == root.hud.minimap.current_state) then
|
||||||
|
infobar:animateToState("minimap_on")
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function populateinfobar(infobar)
|
function populateinfobar(infobar)
|
||||||
elementoffset = 0
|
elementoffset = 0
|
||||||
|
|
||||||
@ -48,6 +97,8 @@ function populateinfobar(infobar)
|
|||||||
interval = 100
|
interval = 100
|
||||||
}))
|
}))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
updateinfobarvisibility()
|
||||||
end
|
end
|
||||||
|
|
||||||
function infoelement(data)
|
function infoelement(data)
|
||||||
@ -120,20 +171,7 @@ end
|
|||||||
local updatehudvisibility = mphud.updateHudVisibility
|
local updatehudvisibility = mphud.updateHudVisibility
|
||||||
mphud.updateHudVisibility = function(a1, a2)
|
mphud.updateHudVisibility = function(a1, a2)
|
||||||
updatehudvisibility(a1, a2)
|
updatehudvisibility(a1, a2)
|
||||||
|
updateinfobarvisibility()
|
||||||
local root = Engine.GetLuiRoot()
|
|
||||||
local menus = root:AnyActiveMenusInStack()
|
|
||||||
local infobar = root.infobar
|
|
||||||
|
|
||||||
if (not infobar) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if (menus) then
|
|
||||||
infobar:animateToState("hud_off")
|
|
||||||
else
|
|
||||||
infobar:animateToState("hud_on")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
LUI.onmenuopen("mp_hud", function(hud)
|
LUI.onmenuopen("mp_hud", function(hud)
|
||||||
@ -144,6 +182,7 @@ LUI.onmenuopen("mp_hud", function(hud)
|
|||||||
local infobar = createinfobar()
|
local infobar = createinfobar()
|
||||||
local root = Engine.GetLuiRoot()
|
local root = Engine.GetLuiRoot()
|
||||||
root.infobar = infobar
|
root.infobar = infobar
|
||||||
|
root.hud = hud
|
||||||
populateinfobar(infobar)
|
populateinfobar(infobar)
|
||||||
|
|
||||||
root:registerEventHandler("update_hud_infobar_settings", function()
|
root:registerEventHandler("update_hud_infobar_settings", function()
|
||||||
@ -157,4 +196,3 @@ LUI.onmenuopen("mp_hud", function(hud)
|
|||||||
|
|
||||||
hud.static.scalable:addElement(infobar)
|
hud.static.scalable:addElement(infobar)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user