Quantcast

Logout can no longer be called by addons

Alar of Runetotem [08-17-18 - 11:21]
Logout can no longer be called by addons
Filename
MissionControl.lua
ShipControl.lua
quick.lua
diff --git a/MissionControl.lua b/MissionControl.lua
index c30d8c8..72a75df 100644
--- a/MissionControl.lua
+++ b/MissionControl.lua
@@ -264,7 +264,7 @@ end
 function module:OnClick_Run(this,button)
 	local GMC=GMF.MissionControlTab
 	this:Disable()
-	GMC.logoutButton:Disable()
+	--GMC.logoutButton:Disable()
 	do
 		local elapsed=0
 		local co=coroutine.wrap(self.RunMission)
@@ -276,7 +276,7 @@ function module:OnClick_Run(this,button)
 				local rc=co(self)
 				if (not rc) then
 					self:Unhook(GMC.runButton,'OnUpdate')
-					GMC.logoutButton:Enable()
+					--GMC.logoutButton:Enable()
 					if not ns.quick and addon:GetBoolean("AUTOLOGOUT") then
 						addon:LogoutPopout(5)
 					end
@@ -644,7 +644,7 @@ function module:RefreshConfig(event)
 	addon:RefreshConfig(event,settings,oldsettings,classlist,class2order,LE_FOLLOWER_TYPE_GARRISON_6_0)
 	if event ~="Init" then -- Initialization routine, we cant design yet
 		drawItemButtons()
-	end
+	end
 end
 function module:Removed()
 	if #settings.rewardList==0 and oldsettings and #oldsettings.rewardList>0 then
@@ -787,7 +787,8 @@ function module:BuildFlags()
 	addon:AddSlider("MINGOLD",50,1,1000,L["Minimum Gold Value"],L["Gold missions wich returns less than this amount are ignored"])
 	addon:AddToggle("GCSKIPEPIC",settings.skipEpic,L["Ignore epic for xp missions."],L["IF you have a Salvage Yard you probably dont want to have this one checked"])
 	addon:AddToggle("GCSKIPRARE",settings.skipRare,L["Ignore rare missions"],L["Rare missions will not be considered"])
-	addon:AddToggle("AUTOLOGOUT",false,L["Auto Logout"],L["Automatically logout after sending missions"])
+	--addon:AddToggle("AUTOLOGOUT",false,L["Auto Logout"],L["Automatically logout after sending missions"])
+	addon:SetBoolean("AUTOLOGOUT",false)
 end
 function module:BuildDuration()
 	-- Duration
@@ -852,7 +853,7 @@ function module:BuildMissionList()
 	ml.widget:Show()
 	GMC.startButton = CreateFrame('BUTTON',nil,  ml.widget.frame, 'GameMenuButtonTemplate')
 	GMC.startButton:SetText('Calculate')
-	GMC.startButton:SetWidth(148)
+	GMC.startButton:SetWidth(198)
 	GMC.startButton:SetPoint('TOPLEFT',10,25)
 	GMC.startButton:SetScript('OnClick', function(this,button) self:OnClick_Start(this,button) end)
 	GMC.startButton:SetScript('OnEnter', function() GameTooltip:SetOwner(GMC.startButton, 'ANCHOR_TOPRIGHT') GameTooltip:AddLine('Assign your followers to missions.') GameTooltip:Show() end)
@@ -866,20 +867,20 @@ function module:BuildMissionList()
 		GameTooltip:Show()
 	end)
 	GMC.runButton:SetScript('OnLeave', function() GameTooltip:Hide() end)
-	GMC.runButton:SetWidth(148)
+	GMC.runButton:SetWidth(198)
 	GMC.runButton:SetScript('OnClick',function(this,button) self:OnClick_Run(this,button) end)
 	GMC.runButton:Disable()
 	GMC.runButton:SetPoint('TOPRIGHT',-10,25)
-	GMC.logoutButton=CreateFrame('BUTTON', nil,ml.widget.frame, 'GameMenuButtonTemplate')
-	GMC.logoutButton:SetText(LOGOUT)
-	GMC.logoutButton:SetWidth(ns.bigscreen and 148 or 90)
-	GMC.logoutButton:SetScript("OnClick",function()
-		GMF:Hide()
-		module:Popup(LOGOUT)
-		module:ScheduleTimer(Logout,0.5)
-		end
-	)
-	GMC.logoutButton:SetPoint('TOP',0,25)
+--	GMC.logoutButton=CreateFrame('BUTTON', nil,ml.widget.frame, 'GameMenuButtonTemplate')
+--	GMC.logoutButton:SetText(LOGOUT)
+--	GMC.logoutButton:SetWidth(ns.bigscreen and 148 or 90)
+--	GMC.logoutButton:SetScript("OnClick",function()
+--		GMF:Hide()
+--		module:Popup(LOGOUT)
+--		module:ScheduleTimer(Logout,0.5)
+--		end
+--	)
+--	GMC.logoutButton:SetPoint('TOP',0,25)
 	return ml
 end

diff --git a/ShipControl.lua b/ShipControl.lua
index cd1d834..80e6f5c 100644
--- a/ShipControl.lua
+++ b/ShipControl.lua
@@ -90,7 +90,7 @@ end
 -- Builds a mission list based on user preferences
 -- @param #module self self
 -- @param #table workList table to be filled with mission list
---
+--
 function module:CreateMissionList(workList)
 	local ar=settings.allowedRewards
 	wipe(priority)
@@ -113,7 +113,7 @@ function module:CreateMissionList(workList)
 			if missionID==OILRIG and settings.rig then
 				self:AcceptMission(missionID,class,10,name,choosenby)
 				break
-			end
+			end
 			if class=='blockade' then
 				self:AcceptMission(missionID,class,10,name,choosenby)
 				break
@@ -179,7 +179,7 @@ function module:RunMission(missionID,start)
 	if (start) then
 		G.StartMission(missionID)
 		PlaySound(SOUNDKIT.UI_GARRISON_COMMAND_TABLE_MISSION_START)
-
+
 		addon:RefreshFollowerStatus()
 		return
 	end
@@ -288,7 +288,7 @@ do
 							party.perc=0
 							party.full=nil
 							self:MCMatchMaker(missionID,party,false,100)
-						end
+						end
 					end
 					--@debug@
 					print(missionID,"  Accepted",party.perc,minimumChance)
@@ -317,7 +317,7 @@ end
 function module:OnClick_Run(this,button)
 	local GMC=GSF.MissionControlTab
 	this:Disable()
-	GMC.logoutButton:Disable()
+	--GMC.logoutButton:Disable()
 	do
 		local elapsed=0
 		local co=coroutine.wrap(self.RunMission)
@@ -329,7 +329,7 @@ function module:OnClick_Run(this,button)
 				local rc=co(self)
 				if (not rc) then
 					self:Unhook(GMC.runButton,'OnUpdate')
-					GMC.logoutButton:Enable()
+					--GMC.logoutButton:Enable()
 					if not ns.quick and addon:GetBoolean("SAUTOLOGOUT") then
 						addon:LogoutPopup(5)
 					end
@@ -686,7 +686,7 @@ local function clone(from,to)
 end
 function module:RefreshConfig(event)
 	settings=addon.db.profile.shipControl
-	classlist=settings.rewardList
+	classlist=settings.rewardList
 	addon:RefreshConfig(event,settings,nil,classlist,class2order,LE_FOLLOWER_TYPE_SHIPYARD_6_2)
 	if event ~="Init" then -- Initialization routine, we cant design yet
 		drawItemButtons()
@@ -796,7 +796,7 @@ function module:BuildFlags()
 	addon:AddToggle("SAUTOLOGOUT",false,L["Auto Logout"],L["Automatically logout after sending missions"])
 	addon:Trigger('SGCMINLEVEL')
 	addon:Trigger('SGCSKIPEPIC')
-
+
 end
 function module:BuildDuration()
 	-- Duration
@@ -861,7 +861,7 @@ function module:BuildMissionList()
 	ml.widget:Show()
 	GMC.startButton = CreateFrame('BUTTON',nil,  ml.widget.frame, 'GameMenuButtonTemplate')
 	GMC.startButton:SetText('Calculate')
-	GMC.startButton:SetWidth(148)
+	GMC.startButton:SetWidth(200)
 	GMC.startButton:SetPoint('TOPLEFT',10,25)
 	GMC.startButton:SetScript('OnClick', function(this,button) self:OnClick_Start(this,button) end)
 	GMC.startButton:SetScript('OnEnter', function() GameTooltip:SetOwner(GMC.startButton, 'ANCHOR_TOPRIGHT') GameTooltip:AddLine('Assign your followers to missions.') GameTooltip:Show() end)
@@ -875,20 +875,20 @@ function module:BuildMissionList()
 		GameTooltip:Show()
 	end)
 	GMC.runButton:SetScript('OnLeave', function() GameTooltip:Hide() end)
-	GMC.runButton:SetWidth(148)
+	GMC.runButton:SetWidth(200)
 	GMC.runButton:SetScript('OnClick',function(this,button) self:OnClick_Run(this,button) end)
 	GMC.runButton:Disable()
 	GMC.runButton:SetPoint('TOPRIGHT',-10,25)
-	GMC.logoutButton=CreateFrame('BUTTON', nil,ml.widget.frame, 'GameMenuButtonTemplate')
-	GMC.logoutButton:SetText(LOGOUT)
-	GMC.logoutButton:SetWidth(ns.bigscreen and 148 or 90)
-	GMC.logoutButton:SetScript("OnClick",function()
-		GSF:Hide()
-		module:Popup(LOGOUT)
-		module:ScheduleTimer(Logout,0.5)
-		end
-	)
-	GMC.logoutButton:SetPoint('TOP',0,25)
+	--GMC.logoutButton=CreateFrame('BUTTON', nil,ml.widget.frame, 'GameMenuButtonTemplate')
+	--GMC.logoutButton:SetText(LOGOUT)
+	--GMC.logoutButton:SetWidth(ns.bigscreen and 148 or 90)
+	--GMC.logoutButton:SetScript("OnClick",function()
+	--	GSF:Hide()
+	--	module:Popup(LOGOUT)
+	--	module:ScheduleTimer(Logout,0.5)
+	--	end
+	--)
+	--GMC.logoutButton:SetPoint('TOP',0,25)
 	return ml
 end

diff --git a/quick.lua b/quick.lua
index 3f5c51c..8dbc2aa 100644
--- a/quick.lua
+++ b/quick.lua
@@ -78,12 +78,12 @@ function addon:LogoutTimer(dialog,elapsed)
 	if dialog.which ~="LIBINIT_POPUP" then return end
 	local text = _G[dialog:GetName().."Text"];
 	local timeleft = ceil(dialog.timeleft);
-	local which=dialog.which
+	local which=dialog.which
 	if ( timeleft < 60 ) then
 		text:SetFormattedText(StaticPopupDialogs[which].text, timeleft, SECONDS);
 	else
 		text:SetFormattedText(StaticPopupDialogs[which].text, ceil(timeleft / 60), MINUTES);
-	end
+	end
 end
 function addon:LogoutPopup(timeout)
 	local msg=''
@@ -93,7 +93,7 @@ function addon:LogoutPopup(timeout)
 		for i=0,NUM_BAG_SLOTS do
 			freeSlots=freeSlots+(GetContainerNumFreeSlots(i) or 0)
 		end
-		for _,id in ipairs(ns.allSalvages) do
+		for _,id in ipairs(ns.allSalvages) do
 			salvage=salvage+(GetItemCount(id) or 0)
 		end
 		if salvage > 5 then
@@ -103,53 +103,36 @@ function addon:LogoutPopup(timeout)
 				msg=msg .. format(L[" and only %d free slots in your bags"],freeSlots)
 			end
 			msg=C(msg,'green').."\n"
+    	local popup=addon:Popup(msg,timeout or 10,
+    		function(dialog,data,data2)
+          StaticPopup_Hide("LIBINIT_POPUP")
+    		end
+    	)
 		end
 	end
-	if not autologout then
-		msg=msg .. LOGOUT
-	else
-		msg=msg .. CAMP_TIMER
-	end
-	local popup=addon:Popup(msg,timeout or 10,
-		function(dialog,data,data2)
-			addon:Unhook(dialog,"OnUpdate")
-			Logout()
-		end,
-		function(dialog,data,timeout)
-			addon:Unhook(dialog,"OnUpdate")
-			if timeout=="timeout" and autologout then Logout() end
-			autologout=false
-			missionDone=false
-			shipyardDone=false
-			StaticPopup_Hide("LIBINIT_POPUP")
-		end
-	)
-	if autologout then
-		self:SecureHookScript(popup, "OnUpdate", "LogoutTimer")
-	end
 end
 function qm:RunQuick()
 	local completeButton=GMF:IsVisible() and GarrisonCommanderQuickMissionComplete or GCQuickShipMissionCompletionButton
 	local main=GMF:IsVisible() and GMF or GSF
-	if not ns.quick then
+	if not ns.quick then
 		HideUIPanel(main)
 		if not G.HasShipyard() then
 			shipyardDone=true
 		end
 		if missionDone and shipyardDone then
 			addon:LogoutPopup(5)
-		else
+		else
 			autologout=false
 		end
-		return
+		return
 	end
 	while not qm.Mission do
-		if completeButton:IsVisible() then
+		if completeButton and completeButton:IsVisible() then
 			completeButton:Click()
 			return -- Waits to be rescheduled by mission completion
 		end
 		if not main.MissionControlTab:IsVisible() then
-			main.tabMC:Click()
+			if main.tabMC then main.tabMC:Click() end
 			break
 		end
 		if (main.MissionControlTab.runButton:IsEnabled()) then
@@ -176,19 +159,7 @@ function addon:RunQuick(force)
 		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)"].."\n" ..
-				C(format(L["Keep pressed %s while opening table to automate processing"],CTRL_KEY),"green"),10,
-			function()
-				StaticPopup_Hide("LIBINIT_POPUP")
-				return addon:RunQuick(true)
-			end,
-			function()
-				StaticPopup_Hide("LIBINIT_POPUP")
-			end)
-	else
-		ns.quick=true
-		qm.watchdog=0
-		return addon.ScheduleTimer(qm,"RunQuick",0.2)
-	end
+	ns.quick=true
+	qm.watchdog=0
+	return addon.ScheduleTimer(qm,"RunQuick",0.2)
 end
\ No newline at end of file