Its not the same. I just use a toggle frame vs show/hide on event. I fixed it and should have a working copy below. Try it out. It is your entire layout. I just checked to make sure it worked correctly multiple times with test panels. It should work to do the following - show intended panels (ie Minimap_location and Minimap_tracking) unless you are in combat then those 2 panels will hide.
lua Code:
lpanels:CreateLayout("Minimap", {
-- Bordure minimap int
{ name = "Minimap_border",
parent = "Minimap", anchor_to = "TOP",
height = "100%", width = "100%" , bg_alpha = 0,
border = "SOLID", border_color = "0 0 0",
border_alpha = 0.5, level = 99, inset = -2.5
},
-- barre supérieur carte
{ name = "Minimap_location",
anchor_frame = "Minimap", anchor_to = "TOPLEFT",
height = 11, width = "100%",
bg_alpha = 0.3, level = 99,
OnLoad=function(self)
self:RegisterEvent'PLAYER_REGEN_ENABLED'
self:RegisterEvent'PLAYER_REGEN_DISABLED'
self:Show()
end,
OnEvent=function(self) ToggleFrame(self) end
},
{ name = "Minimap_location_border",
parent = "Minimap_location", anchor_to = "BOTTOM",
width = "100%", height = 1, y_off = -1,
bg_alpha = 0.5,
},
-- Barre inférieur carte
{ name = "Minimap_tracking",
anchor_frame = "Minimap",
height = 18, width = "100%",
bg_alpha = 0.3, level = 99,
OnLoad=function(self)
self:RegisterEvent'PLAYER_REGEN_ENABLED'
self:RegisterEvent'PLAYER_REGEN_DISABLED'
self:Show()
end,
OnEvent=function(self) ToggleFrame(self) end
},
{ name = "Minimap_tracking_border",
parent = "Minimap_tracking", anchor_to = "TOP",
width = "100%", height = 1, y_off = 1,
bg_alpha = 0.5,
},
-- barre inférieur extérieur carte
{ name = "Minimap_stat",
parent = "Minimap_tracking", anchor_to = "BOTTOM",
border = "SOLID", border_color = "0 0 0",
border_alpha = 0.5, level = 0, inset = 1,
height = 15, width = 140, y_off = -17.5,
bg_alpha = 0.3, level = 99,
}
})
lpanels:CreateLayout("Afker", {
{ name = "AFK", anchor_to = "TOP", y_off = -350,
bg_alpha = 0.5, width = 200, height = 50,
border = "SOLID", border_color = "1 0.3 0.3",
text = {
-- "YOU ARE AFK!"
{ string = "Tu es AFK !", anchor_to = "TOP", y_off = -10,
shadow=1, font = "Fonts\\FRIZQT__.TTF", size=14,
},
-- "0:00" TIMER
{ string=function()
if afk_timer then
local secs = mod(time() - afk_timer, 60)
local mins = floor((time() - afk_timer) / 60)
return format("%s:%02.f", mins, secs)
end
end, update=0.1,
shadow=1, font = "Fonts\\FRIZQT__.TTF", size=16,
anchor_to = "CENTER", y_off = -7, color = "1 0.3 0.3"
}
},
OnLoad = function(self)
self:RegisterEvent("PLAYER_FLAGS_CHANGED")
self:Hide()
end,
OnEvent = function(self)
if UnitIsAFK("player") and not afk_timer then
self.text2:SetText("0:00")
afk_timer = time()
self:Show()
elseif not UnitIsAFK("player") then
self:Hide()
afk_timer = nil
end
end,
OnClick = function(self, b)
self:Hide()
if b == "LeftButton" then SendChatMessage("", "AFK") end
end,
OnEnter = function(self) self.bg:SetTexture(.1,.1,.1,.5) end,
OnLeave = function(self) self.bg:SetTexture(0,0,0,.5) end
}
})
lpanels:ApplyLayout(nil, "Minimap", "Afker")