View Single Post
01-16-12, 07:27 PM   #348
Unkn
Premium Member
 
Unkn's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 258
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:
  1. lpanels:CreateLayout("Minimap", {
  2.         -- Bordure minimap int
  3.         {       name = "Minimap_border",
  4.                 parent = "Minimap", anchor_to = "TOP",
  5.                 height = "100%", width = "100%" , bg_alpha = 0,
  6.                 border = "SOLID", border_color = "0 0 0",
  7.                 border_alpha = 0.5, level = 99, inset = -2.5
  8.         },
  9.         -- barre supérieur carte
  10.         {       name = "Minimap_location",
  11.                 anchor_frame = "Minimap", anchor_to = "TOPLEFT",
  12.                 height = 11, width = "100%",
  13.                 bg_alpha = 0.3, level = 99,
  14.     OnLoad=function(self)
  15.         self:RegisterEvent'PLAYER_REGEN_ENABLED'
  16.         self:RegisterEvent'PLAYER_REGEN_DISABLED'
  17.         self:Show()
  18.     end,
  19.     OnEvent=function(self) ToggleFrame(self) end
  20.         },    
  21.         {       name = "Minimap_location_border",
  22.                 parent = "Minimap_location", anchor_to = "BOTTOM",
  23.                 width = "100%", height = 1, y_off = -1,
  24.                 bg_alpha = 0.5,
  25.         },
  26.        
  27.         -- Barre inférieur carte
  28.         {       name = "Minimap_tracking",
  29.                 anchor_frame = "Minimap",
  30.                 height = 18, width = "100%",
  31.                 bg_alpha = 0.3, level = 99,
  32.     OnLoad=function(self)
  33.         self:RegisterEvent'PLAYER_REGEN_ENABLED'
  34.         self:RegisterEvent'PLAYER_REGEN_DISABLED'
  35.         self:Show()
  36.     end,
  37.     OnEvent=function(self) ToggleFrame(self) end
  38.                
  39.         },
  40.         {       name = "Minimap_tracking_border",
  41.                 parent = "Minimap_tracking", anchor_to = "TOP",
  42.                 width = "100%", height = 1, y_off = 1,
  43.                 bg_alpha = 0.5,
  44.         },
  45.  
  46.         -- barre inférieur extérieur carte
  47.         {       name = "Minimap_stat",
  48.                 parent = "Minimap_tracking", anchor_to = "BOTTOM",
  49.                 border = "SOLID", border_color = "0 0 0",
  50.                 border_alpha = 0.5, level = 0, inset = 1,
  51.                 height = 15, width = 140, y_off = -17.5,
  52.                 bg_alpha = 0.3, level = 99,
  53.                
  54.         }
  55. })
  56.  
  57. lpanels:CreateLayout("Afker", {
  58.     {    name = "AFK", anchor_to = "TOP", y_off = -350,
  59.         bg_alpha = 0.5, width = 200, height = 50,
  60.         border = "SOLID", border_color = "1 0.3 0.3",
  61.         text = {
  62.         -- "YOU ARE AFK!"
  63.             {    string = "Tu es AFK !", anchor_to = "TOP", y_off = -10,
  64.                 shadow=1, font = "Fonts\\FRIZQT__.TTF", size=14,
  65.             },
  66.             -- "0:00" TIMER
  67.             {    string=function()
  68.                     if afk_timer then
  69.                         local secs = mod(time() - afk_timer, 60)
  70.                         local mins = floor((time() - afk_timer) / 60)
  71.                         return format("%s:%02.f", mins, secs)
  72.                     end
  73.                 end, update=0.1,
  74.                 shadow=1, font = "Fonts\\FRIZQT__.TTF", size=16,
  75.                 anchor_to = "CENTER", y_off = -7, color = "1 0.3 0.3"
  76.             }
  77.         },
  78.         OnLoad = function(self)
  79.             self:RegisterEvent("PLAYER_FLAGS_CHANGED")
  80.             self:Hide()
  81.         end,
  82.         OnEvent = function(self)
  83.             if UnitIsAFK("player") and not afk_timer then
  84.                 self.text2:SetText("0:00")
  85.                 afk_timer = time()
  86.                 self:Show()
  87.             elseif not UnitIsAFK("player") then
  88.                 self:Hide()
  89.                 afk_timer = nil
  90.             end
  91.         end,
  92.         OnClick = function(self, b)
  93.             self:Hide()
  94.             if b == "LeftButton" then SendChatMessage("", "AFK") end
  95.         end,
  96.         OnEnter = function(self) self.bg:SetTexture(.1,.1,.1,.5) end,
  97.         OnLeave = function(self) self.bg:SetTexture(0,0,0,.5) end
  98.     }
  99. })
  100.  
  101. lpanels:ApplyLayout(nil, "Minimap", "Afker")
__________________
"I'm very feminine. And I'll beat the crap out of ANYONE who disagrees!"

Last edited by Unkn : 01-16-12 at 07:29 PM. Reason: typo...
  Reply With Quote