Quantcast

Fix: No longer gives error when clicking on minimap report icon while in

Alar of Runetotem [07-28-19 - 11:36]
Fix: No longer gives error when clicking on minimap report icon while in
combat
Filename
GarrisonCommander-Broker/RelNotes.lua
GarrisonCommander-Broker/ldb.lua
GarrisonCommander.lua
RelNotes.lua
diff --git a/GarrisonCommander-Broker/RelNotes.lua b/GarrisonCommander-Broker/RelNotes.lua
index 5f6f68c..b309a1d 100644
--- a/GarrisonCommander-Broker/RelNotes.lua
+++ b/GarrisonCommander-Broker/RelNotes.lua
@@ -7,6 +7,9 @@ self:HF_Paragraph("Description")
 self:HF_Pre([[
 Data broker for Garrison stuff.
 ]])
+self:RelNotes(3,2,1,[[
+Fix: No longer gives error when clicking on minimap report icon while in combat
+]])
 self:RelNotes(3,1,1,[[
 Fix: Harvesting node should now be detected again
 ]])
diff --git a/GarrisonCommander-Broker/ldb.lua b/GarrisonCommander-Broker/ldb.lua
index 6677a74..54d639f 100644
--- a/GarrisonCommander-Broker/ldb.lua
+++ b/GarrisonCommander-Broker/ldb.lua
@@ -381,27 +381,32 @@ function addon:OnInitialized()
 	self:ScheduleTimer("DelayedInit",1)
 	-- Avoid double adding
 	if not IsAddOnLoaded("GarrisonCommander") then
-		GarrisonLandingPageMinimapButton:HookScript("OnEnter",function(this)
-				if this.description==MINIMAP_ORDER_HALL_LANDING_PAGE_TOOLTIP then
-					GameTooltip:AddLine(WARDROBE_NEXT_VISUAL_KEY .. " " .. MINIMAP_GARRISON_LANDING_PAGE_TOOLTIP)
-				end
-				GameTooltip:Show()
-		end
-		)
-		GarrisonLandingPageMinimapButton:RegisterForClicks("LEFTBUTTONUP","RIGHTBUTTONUP")
-		GarrisonLandingPageMinimapButton:SetScript("OnClick",
-			function (this,button)
-					if (_G.GarrisonLandingPage and GarrisonLandingPage:IsShown()) then
-						HideUIPanel(GarrisonLandingPage);
-					else
-						if button=="RightButton" then
-								ShowGarrisonLandingPage(2)
-						else
-								ShowGarrisonLandingPage(C_Garrison.GetLandingPageGarrisonType());
-						end
-					end
-			end
-		)
+    self:SecureHookScript(GarrisonLandingPageMinimapButton,"OnEnter",function(this)
+        if this.description==MINIMAP_ORDER_HALL_LANDING_PAGE_TOOLTIP or
+           this.description == GARRISON_TYPE_8_0_LANDING_PAGE_TOOLTIP then
+          GameTooltip:AddLine(WARDROBE_NEXT_VISUAL_KEY .. " " .. MINIMAP_GARRISON_LANDING_PAGE_TOOLTIP)
+          GameTooltip:AddLine(SHIFT_KEY_TEXT .." ".. WARDROBE_NEXT_VISUAL_KEY .. " " .. MINIMAP_ORDER_HALL_LANDING_PAGE_TOOLTIP)
+        end
+        GameTooltip:Show()
+    end
+    )
+    GarrisonLandingPageMinimapButton:RegisterForClicks("LEFTBUTTONUP","RIGHTBUTTONUP")
+    self:SecureHookScript(GarrisonLandingPageMinimapButton,"OnClick",
+      function (this,button)
+         local shown=GarrisonLandingPage:IsShown()
+         local actual=GarrisonLandingPage.garrTypeID
+         local requested=C_Garrison.GetLandingPageGarrisonType()
+         if button=="RightButton" and IsShiftKeyDown() then
+            requested=LE_GARRISON_TYPE_7_0
+         elseif button=="RightButton" then
+            requested=LE_GARRISON_TYPE_6_0
+         end
+         if InCombatLockdown() then return end
+         if shown and actual ~= requested then
+           ShowGarrisonLandingPage(requested);
+         end
+      end
+    )
 	end
 	self:loadHelp()
 end
diff --git a/GarrisonCommander.lua b/GarrisonCommander.lua
index c6970d4..f56d039 100644
--- a/GarrisonCommander.lua
+++ b/GarrisonCommander.lua
@@ -461,28 +461,33 @@ function addon:OnInitialized()
 	self:AddOpenCmd("show","showdata","Prints a mission score")
 --@end-debug@
 	self:Trigger("MSORT")
-	if (not IsAddOnLoaded("GarrisonCommander-Broker")) then
-		GarrisonLandingPageMinimapButton:HookScript("OnEnter",function(this)
-				if this.description==MINIMAP_ORDER_HALL_LANDING_PAGE_TOOLTIP then
-					GameTooltip:AddLine(WARDROBE_NEXT_VISUAL_KEY .. " " .. MINIMAP_GARRISON_LANDING_PAGE_TOOLTIP)
-				end
-				GameTooltip:Show()
-		end
-		)
-		GarrisonLandingPageMinimapButton:RegisterForClicks("LEFTBUTTONUP","RIGHTBUTTONUP")
-		GarrisonLandingPageMinimapButton:SetScript("OnClick",
-			function (this,button)
-					if (_G.GarrisonLandingPage and GarrisonLandingPage:IsShown()) then
-						HideUIPanel(GarrisonLandingPage);
-					else
-						if button=="RightButton" then
-								ShowGarrisonLandingPage(2)
-						else
-								ShowGarrisonLandingPage(C_Garrison.GetLandingPageGarrisonType());
-						end
-					end
-			end
-		)
+	if not IsAddOnLoaded("GarrisonCommander-Broker") then
+    self:SecureHookScript(GarrisonLandingPageMinimapButton,"OnEnter",function(this)
+        if this.description==MINIMAP_ORDER_HALL_LANDING_PAGE_TOOLTIP or
+           this.description == GARRISON_TYPE_8_0_LANDING_PAGE_TOOLTIP then
+          GameTooltip:AddLine(WARDROBE_NEXT_VISUAL_KEY .. " " .. MINIMAP_GARRISON_LANDING_PAGE_TOOLTIP)
+          GameTooltip:AddLine(SHIFT_KEY_TEXT .." ".. WARDROBE_NEXT_VISUAL_KEY .. " " .. MINIMAP_ORDER_HALL_LANDING_PAGE_TOOLTIP)
+        end
+        GameTooltip:Show()
+    end
+    )
+    GarrisonLandingPageMinimapButton:RegisterForClicks("LEFTBUTTONUP","RIGHTBUTTONUP")
+    self:SecureHookScript(GarrisonLandingPageMinimapButton,"OnClick",
+      function (this,button)
+         local shown=GarrisonLandingPage:IsShown()
+         local actual=GarrisonLandingPage.garrTypeID
+         local requested=C_Garrison.GetLandingPageGarrisonType()
+         if button=="RightButton" and IsShiftKeyDown() then
+            requested=LE_GARRISON_TYPE_7_0
+         elseif button=="RightButton" then
+            requested=LE_GARRISON_TYPE_6_0
+         end
+         if InCombatLockdown() then return end
+         if shown and actual ~= requested then
+           ShowGarrisonLandingPage(requested);
+         end
+      end
+    )
 	end
 --@debug@
 --	assert(self:GetAgeColor(1/0))
diff --git a/RelNotes.lua b/RelNotes.lua
index 355a12d..d70b3aa 100644
--- a/RelNotes.lua
+++ b/RelNotes.lua
@@ -22,6 +22,9 @@ self:Wiki([[
 == Silent mode ==
 typing /gac silent in chat will eliminate every chat message from GarrisonCommander
 ]])
+self:RelNotes(3,2,1,[[
+Fix: No longer gives error when clicking on minimap report icon while in combat
+]])
 self:RelNotes(3,2,0,[[
 Fix: Checked Russian Localization
 ]])