From a30b84ba2e1991148b3b070facb1d0e5d791a5ef Mon Sep 17 00:00:00 2001 From: Peter Eliasson Date: Sun, 8 Feb 2015 15:17:44 +0100 Subject: [PATCH] Report window now hidden on esc. --- src/report.lua | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/report.lua b/src/report.lua index a3fe55f..08bf12a 100644 --- a/src/report.lua +++ b/src/report.lua @@ -54,7 +54,6 @@ local function getParseStringFromParse(rank, parse) end end - function report:SendData(channelId, whisperToName, dataTitle, filterString, parses, numParses) numParses = min(numParses, MAX_PARSES_TO_SEND); channelId = string.upper(channelId); @@ -98,12 +97,15 @@ function report:SendData(channelId, whisperToName, dataTitle, filterString, pars end end +function report:HideReportFrame() + if self.reportFrame then + self.reportFrame:Release(); + self.reportFrame = nil; + end +end function report:ShowReportFrame(guildId, zoneId, difficultyId, encounterId, roleId, parses, filters) - if self.currentFrame then - self.currentFrame:Release(); - self.currentFrame = nil; - end + self:HideReportFrame(); local channelId = self.lastChannelId or "SELF"; @@ -184,8 +186,7 @@ function report:ShowReportFrame(guildId, zoneId, difficultyId, encounterId, role local numParses = numToSendSlider:GetValue(); local whisperToName = whisperToNameEditBox:GetText(); self:SendData(channelId, whisperToName, dataTitle, filterString, parses, numParses); - report.currentFrame = nil; - frame:Release(); + self:HideReportFrame(); end); frame:AddChild(dataTitleLabel); @@ -197,6 +198,24 @@ function report:ShowReportFrame(guildId, zoneId, difficultyId, encounterId, role frame:AddChild(numToSendSlider); frame:AddChild(sendButton); - self.currentFrame = frame; + self.reportFrame = frame; frame:Show(); -end \ No newline at end of file +end + +function report:OnCloseSpecialWindows() + local found; + if self.reportFrame then + self:HideReportFrame() + found = 1 + end + return self.hooks["CloseSpecialWindows"]() or found; +end + +function report:OnEnable() + self:RawHook("CloseSpecialWindows", "OnCloseSpecialWindows", true); +end + +function report:OnDisable() + self:HideReportFrame(); + self:UnHook("CloseSpecialWindows"); +end -- 1.7.9.5