Quantcast

Report window now hidden on esc.

Peter Eliasson [02-08-15 - 14:17]
Report window now hidden on esc.
Filename
src/report.lua
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