Quantcast

Doesnt get stuck if Mission Control is already open

Alar of Daggerspine [01-21-16 - 22:22]
Doesnt get stuck if Mission Control is already open
Filename
quick.lua
diff --git a/quick.lua b/quick.lua
index f91f9dc..a6c8223 100644
--- a/quick.lua
+++ b/quick.lua
@@ -14,23 +14,29 @@ function qm:RunQuick()
 --@end-debug@
 	while not qm.Mission do
 		if GarrisonCommanderQuickMissionComplete:IsVisible() then
+--@debug@
 			print("Quickcompletion")
+--@end-debug@
 			GarrisonCommanderQuickMissionComplete:Click()
 			return -- Waits to be rescheeduled by mission completion
 		end
 		if not GMF.MissionControlTab:IsVisible() then
+--@debug@
 			print("MissionControl")
+--@end-debug@
 			GMF.tabMC:Click()
 			break
 		end
 		if (GMF.MissionControlTab.runButton:IsEnabled()) then
+--@debug@
 			print("Run Missions")
+--@end-debug@
 			GMF.MissionControlTab.runButton:Click()
 		end
 		break -- Never loop or we get stuck
 	end
 	watchdog=watchdog+1
-	if watchdog > 100 then
+	if watchdog > 10 then
 		ns.quick=false
 	end
 	if ns.quick then
@@ -42,10 +48,23 @@ function addon:RunQuick(force)
 --@debug@
 print("Runquick called")
 --@end-debug@
+	if GMF.tabMC:GetChecked() then
+		self:OpenMissionControlTab()
+		self:ScheduleTimer("RunQuick",0.2)
+		return
+	end
 	if not IsShiftKeyDown()  and not force then
-		self:Popup(L["Are you sure to start Garrison Commander Auto Pilot?\n(Keep shift pressed while clicking to avoid this question)"],10,function() return addon:RunQuick(true) end,function() end)
+		self:Popup(L["Are you sure to start Garrison Commander Auto Pilot?\n(Keep shift pressed while clicking to avoid this question)"],10,
+			function()
+				StaticPopup_Hide("LIBINIT_POPUP")
+				return addon:RunQuick(true)
+			end,
+			function()
+				StaticPopup_Hide("LIBINIT_POPUP")
+			end)
 	else
 		ns.quick=true
-		return qm:RunQuick()
+		qm.watchdog=0
+		return addon.ScheduleTimer(qm,"RunQuick",0.2)
 	end
 end
\ No newline at end of file