Quantcast

Feature: Alt mode: one click mission completion and mission sending

Alar of Daggerspine [01-16-16 - 23:08]
Feature: Alt mode: one click mission completion and mission sending

Clicking on auto pilot will automatically retrieve rewards from
completede missions, schedule new ones and logout
Filename
FollowerCache.lua
GarrisonCommander-Broker/ldb.lua
GarrisonCommander.lua
GarrisonCommander.toc
Init.lua
MissionCompletion.lua
MissionControl.lua
quick.lua
diff --git a/FollowerCache.lua b/FollowerCache.lua
index 9a2ff05..70b081a 100644
--- a/FollowerCache.lua
+++ b/FollowerCache.lua
@@ -255,4 +255,8 @@ function addon:GetAnyIterator(followerType,func)
 end
 function addon:GetFollowerType(followerID)
 	return followerTypes[followerID] or 0
+end
+function addon:GetFollowerID(followerName)
+	return self.names[followerName]
+
 end
\ No newline at end of file
diff --git a/GarrisonCommander-Broker/ldb.lua b/GarrisonCommander-Broker/ldb.lua
index 1e11369..cfb17a1 100644
--- a/GarrisonCommander-Broker/ldb.lua
+++ b/GarrisonCommander-Broker/ldb.lua
@@ -1,5 +1,6 @@
 local me, ns = ...
-if (not LibStub:GetLibrary("LibDataBroker-1.1",true)) then
+local LDB=LibStub:GetLibrary("LibDataBroker-1.1",true)
+if not LDB then
 	--@debug@
 	print("Missing libdatabroker")
 	--@end-debug@
@@ -442,14 +443,14 @@ function addon:ColorToString(r,g,b)
 	return format("%02X%02X%02X", 255*r, 255*g, 255*b)
 end

-dataobj=LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("GC-Missions", {
+dataobj=LDB:NewDataObject("GC-Missions", {
 	type = "data source",
 	label = "GC "  .. GARRISON_NUM_COMPLETED_MISSIONS,
 	text=QUEUED_STATUS_WAITING,
 	category = "Interface",
 	icon = "Interface\\ICONS\\ACHIEVEMENT_GUILDPERK_WORKINGOVERTIME"
 })
-farmobj=LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("GC-Farms", {
+farmobj=LDB:NewDataObject("GC-Farms", {
 	type = "data source",
 	label = "GC " .. "Harvesting",
 	text=QUEUED_STATUS_WAITING,
@@ -457,14 +458,14 @@ farmobj=LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("GC-Farms", {
 	icon = "Interface\\Icons\\Inv_ore_gold_nugget"
 	--icon = "Interface\\Icons\\Trade_Engineering"
 })
-workobj=LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("GC-WorkOrders", {
+workobj=LDB:NewDataObject("GC-WorkOrders", {
 	type = "data source",
 	label = "GC " ..CAPACITANCE_WORK_ORDERS,
 	text=QUEUED_STATUS_WAITING,
 	category = "Interface",
 	icon = "Interface\\Icons\\Trade_Engineering"
 })
-cacheobj=LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("GC-Cache", {
+cacheobj=LDB:NewDataObject("GC-Cache", {
 	type = "data source",
 	label = "GC " .. GARRISON_CACHE,
 	text=QUEUED_STATUS_WAITING,
diff --git a/GarrisonCommander.lua b/GarrisonCommander.lua
index f7bec74..4157c51 100644
--- a/GarrisonCommander.lua
+++ b/GarrisonCommander.lua
@@ -444,6 +444,7 @@ print("Initialize")
 	end
 	self:AddLabel("Buildings Panel")
 	self:AddToggle("HF",false,L["Hide followers"],L["Do not show follower icon on plots"])
+
 --@debug@
 	self:AddLabel("Developers options")
 	self:AddToggle("DBG",false, "Enable Debug")
@@ -1505,7 +1506,7 @@ print("Setup")
 	GCF=self:CreateHeader(self,"PIN")
 	local tabMC=CreateFrame("CheckButton",nil,GMF,"SpellBookSkillLineTabTemplate")
 	GMF.tabMC=tabMC
-	tabMC.tooltip="Open Garrison Commander Mission Control"
+	tabMC.tooltip=L["Open Garrison Commander Mission Control"]
 	tabMC:SetNormalTexture("Interface\\ICONS\\ACHIEVEMENT_GUILDPERK_WORKINGOVERTIME.blp")
 	self:MarkAsNew(tabMC,'MissionControl','New in 2.2.0! Try automatic mission management!')
 	tabMC:Show()
@@ -1513,24 +1514,32 @@ print("Setup")
 	GMF.FollowerStatusInfo:SetPoint("TOPRIGHT",-30,-5)
 	local tabCF=CreateFrame("Button",nil,GMF,"SpellBookSkillLineTabTemplate")
 	GMF.tabCF=tabCF
-	tabCF.tooltip="Open Garrison Commander Configuration Screen"
+	tabCF.tooltip=L["Open Garrison Commander Configuration Screen"]
 	tabCF:SetNormalTexture("Interface\\ICONS\\Trade_Engineering.blp")
 	tabCF:SetPushedTexture("Interface\\ICONS\\Trade_Engineering.blp")
 	tabCF:Show()
 	local tabHP=CreateFrame("Button",nil,GMF,"SpellBookSkillLineTabTemplate")
 	GMF.tabHP=tabHP
-	tabHP.tooltip="Open Garrison Commander Help"
+	tabHP.tooltip=L["Open Garrison Commander Help"]
 	tabHP:SetNormalTexture("Interface\\ICONS\\INV_Misc_QuestionMark.blp")
 	tabHP:SetPushedTexture("Interface\\ICONS\\INV_Misc_QuestionMark.blp")
 	tabHP:Show()
+	local tabQ=CreateFrame("Button",nil,GMF,"SpellBookSkillLineTabTemplate")
+	GMF.tabQ=tabQ
+	tabQ.tooltip=L["Automatically process completed missions and schedules new ones"]
+	tabQ:SetNormalTexture("Interface\\ICONS\\Ability_Rogue_Sprint.blp")
+	tabQ:SetPushedTexture("Interface\\ICONS\\Ability_Rogue_Sprint.blp")
+	tabQ:Show()
 	tabMC:SetScript("OnClick",function(this,...) addon:OpenMissionControlTab() end)
 	tabCF:SetScript("OnClick",function(this,...) GMF:Hide() addon:Gui() end)
 	tabHP:SetScript("OnClick",function(this,button) addon:ShowHelpWindow(this,button) end)
+	tabQ:SetScript("OnClick",function(this,button) addon:RunQuick() end)
 	tabHP:SetPoint('TOPLEFT',GCF,'TOPRIGHT',0,-10)
 	tabCF:SetPoint('TOPLEFT',GCF,'TOPRIGHT',0,-60)
 	tabMC:SetPoint('TOPLEFT',GCF,'TOPRIGHT',0,-110)
+	tabQ:SetPoint('TOPLEFT',GCF,'TOPRIGHT',0,-160)
 	local ref=GMFMissions.CompleteDialog.BorderFrame.ViewButton
-	local bt = CreateFrame('BUTTON',nil, ref, 'UIPanelButtonTemplate')
+	local bt = CreateFrame('BUTTON','GarrisonCommanderQuickMissionComplete', ref, 'UIPanelButtonTemplate')
 	bt:SetWidth(300)
 	bt:SetText(L["Garrison Comander Quick Mission Completion"])
 	bt:SetPoint("CENTER",0,-50)
@@ -1583,7 +1592,7 @@ function addon:AddMenu()
 		self:RenderFollowerPageMissionList(nil,GMF.FollowerTab.followerID)
 	elseif GMF.MissionControlTab:IsVisible() then
 		self.currentmenu=GMF.MissionControlTab
-		menu,size=self:CreateOptionsLayer('BIGSCREEN','GCMINLEVEL','GCMINUPGRADE','GCSKIPRARE','GCSKIPEPIC','USEFUL')
+		menu,size=self:CreateOptionsLayer('BIGSCREEN','GCMINLEVEL','GCMINUPGRADE','GCSKIPRARE','GCSKIPEPIC','USEFUL','AUTOLOGOUT')
 	else
 		self.currentmenu=nil
 		menu,size=self:CreateOptionsLayer('BIGSCREEN')
diff --git a/GarrisonCommander.toc b/GarrisonCommander.toc
index 7743cdf..c049888 100644
--- a/GarrisonCommander.toc
+++ b/GarrisonCommander.toc
@@ -46,6 +46,7 @@ MatchMaker.lua
 FollowerRecruiting.lua
 BuildingPage.lua
 ShipYard.lua
+quick.lua
 RelNotes.lua
 #@do-not-package@
 Debug.lua
diff --git a/Init.lua b/Init.lua
index 245e0bf..9bb7b2d 100644
--- a/Init.lua
+++ b/Init.lua
@@ -31,6 +31,7 @@ ns.L=ns.addon:GetLocale()
 ns.G=C_Garrison
 ns.GMF=_G.GarrisonMissionFrame
 ns.blacklist=false
+ns.prioritylist=false
 if not ns.GMF then
 --@debug@
 	print("GarrisonCommander is being loaded before Blizzard_GarrisonUI is available")
diff --git a/MissionCompletion.lua b/MissionCompletion.lua
index 7edcecc..f498237 100644
--- a/MissionCompletion.lua
+++ b/MissionCompletion.lua
@@ -151,7 +151,7 @@ function module:MissionComplete(this,button,skiprescheck)
 			end
 		end
 		if stop and not skiprescheck then
-			self:Popup(message.."\n" ..L["If you continue, you will loose them"],0,
+			self:Popup(message.."\n" ..format(L["If you %s, you will loose them\nClick on %s to abort"],ACCEPT,CANCEL),0,
 				function()
 					module:MissionComplete(this,button,true)
 				end,
@@ -159,6 +159,7 @@ function module:MissionComplete(this,button,skiprescheck)
 					this:SetEnabled(true)
 					missionsFrame.CompleteDialog.BorderFrame.ViewButton:SetEnabled(true)
 					panel:Hide()
+					ns.quick=false

 				end
 			)
@@ -344,7 +345,15 @@ function module:MissionsPrintResults(success)
 	if not followers then
 		report:AddRow(L["No follower gained xp"])
 	end
+	if ns.quick then
+		self:ScheduleTimer("CloseReport",1)
+		local qm=addon:GetModule("Quick")
+		addon.ScheduleTimer(qm,"RunQuick",1.1)
+	end
 end
 function addon:MissionComplete(...)
 	return module:MissionComplete(...)
 end
+function addon:CloseMissionComplete()
+	return module:CloseReport()
+end
diff --git a/MissionControl.lua b/MissionControl.lua
index 369ca19..f5b78f8 100644
--- a/MissionControl.lua
+++ b/MissionControl.lua
@@ -267,6 +267,10 @@ function module:GMC_OnClick_Run(this,button)
 				if (not rc) then
 					self:Unhook(GMC.runButton,'OnUpdate')
 					GMC.logoutButton:Enable()
+					if addon:GetBoolean("AUTOLOGOUT") or ns.quick then
+						ns.quick=false
+						addon:ScheduleTimer(Logout,0.5)
+					end
 				end
 			end
 		end
@@ -713,6 +717,7 @@ function module:GMCBuildFlags()
 		addon:AddSlider("GCMINUPGRADE",settings.minUpgrade,600,675,L["Follower set minimum upgrade"],L['Minimum requested upgrade for followers set (Enhancements are always included)'],15)
 		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"])
 	else
 		-- Duration
 		local frame= CreateFrame('FRAME', nil, GMC) -- Flags frame
@@ -847,5 +852,6 @@ function module:GMCBuildMissionList()
 	GMC.logoutButton:SetScript("OnClick",function() GMF:Hide() Logout() end )
 	GMC.logoutButton:SetPoint('TOP',0,25)
 	return ml
-
 end
+
+
diff --git a/quick.lua b/quick.lua
new file mode 100644
index 0000000..f91f9dc
--- /dev/null
+++ b/quick.lua
@@ -0,0 +1,51 @@
+local me, ns = ...
+ns.Configure()
+local addon=addon --#addon
+local _G=_G
+local qm=addon:NewSubModule("Quick") --#qm
+function qm:OnInitialized()
+	ns.step="none"
+end
+local watchdog=0
+function qm:RunQuick()
+	if not ns.quick then return end
+--@debug@
+	print("qm.RunQuick",watchdog)
+--@end-debug@
+	while not qm.Mission do
+		if GarrisonCommanderQuickMissionComplete:IsVisible() then
+			print("Quickcompletion")
+			GarrisonCommanderQuickMissionComplete:Click()
+			return -- Waits to be rescheeduled by mission completion
+		end
+		if not GMF.MissionControlTab:IsVisible() then
+			print("MissionControl")
+			GMF.tabMC:Click()
+			break
+		end
+		if (GMF.MissionControlTab.runButton:IsEnabled()) then
+			print("Run Missions")
+			GMF.MissionControlTab.runButton:Click()
+		end
+		break -- Never loop or we get stuck
+	end
+	watchdog=watchdog+1
+	if watchdog > 100 then
+		ns.quick=false
+	end
+	if ns.quick then
+		return addon.ScheduleTimer(qm,"RunQuick",1)
+	end
+
+end
+function addon:RunQuick(force)
+--@debug@
+print("Runquick called")
+--@end-debug@
+	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)
+	else
+		ns.quick=true
+		return qm:RunQuick()
+	end
+end
\ No newline at end of file