From d2da0a22ae8a11100cb6c6d73489d0d450ff31ec Mon Sep 17 00:00:00 2001 From: Sumsebrum Date: Tue, 27 Jul 2021 16:32:37 +0200 Subject: [PATCH] Revert "fix entering arena in combat bug" This reverts commit 755a3e52b588307f70d734c4602c16a458eea211. --- Frame.lua | 20 ++++++++++++--- Gladdy.lua | 74 +++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 67 insertions(+), 27 deletions(-) diff --git a/Frame.lua b/Frame.lua index 3092ce9..e4a9fd0 100644 --- a/Frame.lua +++ b/Frame.lua @@ -110,7 +110,7 @@ function Gladdy:CreateFrame() self.anchor:Hide() end - self.frame:SetAlpha(0) + self.frame:Hide() end function Gladdy:UpdateFrame() @@ -279,7 +279,13 @@ end function Gladdy:HideFrame() if (self.frame) then - self.frame:SetAlpha(0) + if InCombatLockdown() then + self.startTest = nil + self.hideFrame = true + else + self.frame:Hide() + end + self.frame.testing = nil end end @@ -304,8 +310,14 @@ function Gladdy:ToggleFrame(i) self:Reset() self.curBracket = i self:UpdateFrame() - self:Test() - self.frame:SetAlpha(1) + if InCombatLockdown() then + Gladdy:Print("Gladdy frames show as soon as you leave combat") + self.showFrame = true + self.startTest = true + else + self:Test() + self.frame:Show() + end end end diff --git a/Gladdy.lua b/Gladdy.lua index 0978050..7689dee 100644 --- a/Gladdy.lua +++ b/Gladdy.lua @@ -250,16 +250,13 @@ end function Gladdy:OnEnable() self:RegisterEvent("UPDATE_BATTLEFIELD_STATUS") self:RegisterEvent("PLAYER_ENTERING_WORLD") - - self:CreateFrame() - for i = 1, 5 do - self:CreateButton(i) - end - self.curBracket = 5 - self:UpdateFrame() - self:Reset() + self:RegisterEvent("PLAYER_REGEN_ENABLED") if (IsAddOnLoaded("Clique")) then + for i = 1, 5 do + self:CreateButton(i) + end + ClickCastFrames = ClickCastFrames or {} ClickCastFrames[self.buttons.arena1.secure] = true ClickCastFrames[self.buttons.arena2.secure] = true @@ -301,22 +298,24 @@ end function Gladdy:Test() self.frame.testing = true - for i = 1, self.curBracket do - local unit = "arena" .. i - if (not self.buttons[unit]) then - self:CreateButton(i) - end - local button = self.buttons[unit] + if self.curBracket then + for i = 1, self.curBracket do + local unit = "arena" .. i + if (not self.buttons[unit]) then + self:CreateButton(i) + end + local button = self.buttons[unit] - for k, v in pairs(self.testData[unit]) do - button[k] = v - end + for k, v in pairs(self.testData[unit]) do + button[k] = v + end - for k, v in self:IterModules() do - self:Call(v, "Test", unit) - end + for k, v in self:IterModules() do + self:Call(v, "Test", unit) + end - button:SetAlpha(1) + button:SetAlpha(1) + end end end @@ -351,6 +350,23 @@ function Gladdy:UPDATE_BATTLEFIELD_STATUS(_, index) end end +function Gladdy:PLAYER_REGEN_ENABLED() + if self.showFrame then + self:UpdateFrame() + if self.startTest then + self:Test() + self.startTest = nil + end + self.frame:Show() + self.showFrame = nil + end + if self.hideFrame then + self:Reset() + self.frame:Hide() + self.hideFrame = nil + end +end + --------------------------- -- RESET FUNCTIONS (ARENA LEAVE) @@ -428,8 +444,20 @@ function Gladdy:JoinedArena() self.curBracket = 2 end - Gladdy:SendMessage("JOINED_ARENA") - self.frame:SetAlpha(1) + for i = 1, self.curBracket do + if (not self.buttons["arena" .. i]) then + self:CreateButton(i) + end + end + + self:SendMessage("JOINED_ARENA") + if InCombatLockdown() then + Gladdy:Print("Gladdy frames show as soon as you leave combat") + self.showFrame = true + else + self:UpdateFrame() + self.frame:Show() + end for i=1, self.curBracket do self.buttons["arena" .. i]:SetAlpha(1) end