Quantcast

Alert if you still have salvage when auto logging out (so you can cancel

Alar of Runetotem [02-17-17 - 10:46]
Alert if you still have salvage when auto logging out (so you can cancel
it)
Filename
RelNotes.lua
quick.lua
diff --git a/RelNotes.lua b/RelNotes.lua
index 18029c8..ac90f39 100644
--- a/RelNotes.lua
+++ b/RelNotes.lua
@@ -25,6 +25,7 @@ typing /gac silent in chat will eliminate every chat message from GarrisonComman
 self:RelNotes(2,17,0,[[
 Feature: Fast mode: if you keep the CTRL key pressed while opening the mission table, GC automagically completes pending mission and schedule new ones
 Feature: Fast mode works for both Garrison and Shipyard mission
+Feature: On auto logout informs you if you have items to salvage
 Feature: No longer includes OrderHallCommander: be sure you added it to Curse Client or manually update it
 Fix: Lua error when trying to close header in Order Hall if OrderHallCommander was not installed
 ]])
diff --git a/quick.lua b/quick.lua
index e7ba230..daefcbe 100644
--- a/quick.lua
+++ b/quick.lua
@@ -7,6 +7,8 @@ local GSF=GSF
 local qm=addon:NewSubModule("Quick") --#qm
 local missionDone
 local shipyardDone
+local format=format
+local ipairs=ipairs
 local NavalDomination={
 	Alliance=39068,
 	Horde=39246
@@ -37,7 +39,27 @@ function addon:LogoutTimer(dialog,elapsed)
 	end
 end
 function addon:LogoutPopup(timeout)
-	local popup=addon:Popup(CAMP_TIMER,timeout or 10,
+	local msg=''
+	if addon:HasSalvageYard() then
+		local salvage=0
+		local freeSlots=0
+		for i=0,NUM_BAG_SLOTS do
+			freeSlots=freeSlots+(GetContainerNumFreeSlots(i) or 0)
+		end
+		for _,id in ipairs(ns.allSalvages) do
+			salvage=salvage+(GetItemCount(id) or 0)
+		end
+		if salvage > 5 then
+			timeout=timeout+5
+			msg=format(L["You have %d items to salvage"],salvage)
+			if freeSlots < 5 then
+				msg=msg .. format(L[" and only %d free slots in your bags"],freeSlots)
+			end
+			msg=C(msg,'green').."\n"
+		end
+
+	end
+	local popup=addon:Popup(msg .. CAMP_TIMER,timeout or 10,
 		function(dialog,data,data2)
 			addon:Unhook(dialog,"OnUpdate")
 			Logout()
@@ -61,14 +83,14 @@ function qm:RunQuick()
 			shipyardDone=true
 		end
 		if missionDone and shipyardDone then
-			addon:LogoutPopup(10)
+			addon:LogoutPopup(5)
 		end
 		return
 	end
 	while not qm.Mission do
 		if completeButton:IsVisible() then
 			completeButton:Click()
-			return -- Waits to be rescheeduled by mission completion
+			return -- Waits to be rescheduled by mission completion
 		end
 		if not main.MissionControlTab:IsVisible() then
 			main.tabMC:Click()