main dropdown as scrollable list

AssemblerManiac [04-09-18 - 18:41]
main dropdown as scrollable list
Filename
IIfA/IIfA.lua
IIfA/IIfA.xml
IIfA/IIfABackpack.lua
IIfA/IIfADataCollection.lua
IIfA/IIfAEvents.lua
diff --git a/IIfA/IIfA.lua b/IIfA/IIfA.lua
index b3d23a0..88728c1 100644
--- a/IIfA/IIfA.lua
+++ b/IIfA/IIfA.lua
@@ -109,7 +109,7 @@ function IIfA_SlashCommands(cmd)

 	if (cmd == "run") then
 		d("[IIfA]:Running collector...")
-		IIfA:CollectAll()
+		IIfA:CollectAll(true)
 		return
 	end

@@ -280,6 +280,8 @@ function IIfA_onLoad(eventCode, addOnName)
 	IIfA.SearchHeight = IIFA_GUI_Search:GetHeight()

 	IIFA_GUI_ListHolder.rowHeight = 52	-- trying to find optimal size for this, set it in one spot for easier adjusting
+	IIFA_GUI_ListHolder:SetDrawLayer(0)	-- keep the scrollable dropdown ABOVE this one
+										-- (otherwise scrollable dropdown is shown like it's above the list, but the mouse events end up going through to the list)

 	IIfA.currentCharacterId = GetCurrentCharacterId()
 	IIfA.currentAccount = GetDisplayName()
@@ -467,7 +469,7 @@ function IIfA_onLoad(eventCode, addOnName)
 	IIfA.trackedBags[BAG_WORN] 		= not IIfA:IsCharacterEquipIgnored()
 	IIfA.trackedBags[BAG_BACKPACK] 	= not IIfA:IsCharacterInventoryIgnored()

-	IIfA:CollectAll()
+	IIfA:CollectAll(true)


 end
diff --git a/IIfA/IIfA.xml b/IIfA/IIfA.xml
index 82ecaaf..78e5c40 100644
--- a/IIfA/IIfA.xml
+++ b/IIfA/IIfA.xml
@@ -130,7 +130,8 @@
 						</Button>


-						<Control name="$(parent)_Dropdown" inherits="ZO_ComboBox" mouseEnabled="true" >
+<!-- 						<Control name="$(parent)_Dropdown" inherits="ZO_ComboBox" mouseEnabled="true"> -->
+						<Control name="$(parent)_Dropdown" inherits="ZO_ScrollableComboBox" mouseEnabled="true" tier="HIGH">
 							<Dimensions y="29" />
 							<Anchor point="TOPLEFT" relativeTo="$(parent)_BagButton" relativePoint="TOPRIGHT" offsetX="10" />
 							<Anchor point="BOTTOMRIGHT" relativeTo="$(parent)_BagButton" relativePoint="BOTTOMRIGHT" offsetX="250" offsetY="5" />
diff --git a/IIfA/IIfABackpack.lua b/IIfA/IIfABackpack.lua
index f1fa1e7..f64e755 100644
--- a/IIfA/IIfABackpack.lua
+++ b/IIfA/IIfABackpack.lua
@@ -740,8 +740,6 @@ function IIfA:SetupBackpack()
 				comboBox:SetSelectedItem(validChoices[i])
 			end
 		end
-
---		return IIFA_GUI_Header_Dropdown
 	end

 	local function createInventoryDropdownQuality()
@@ -831,9 +829,9 @@ function IIfA:FMC(control, WhoSeesIt)
 		[14] = ITEM_STYLE_CHAPTER_SWORDS,
 		}
 --]]
-
 -- following lookup turns a motif number "Crafting Motif 33: Thieves Guild Axes" into an achieve lookup
 -- |H1:achievement:1318:16383:1431113493|h|h
+-- the index is the # from the motif text, NOT any internal value
 	local motifAchieves =
 		{
 		[15] = 1144,	-- Dwemer
@@ -878,6 +876,7 @@ function IIfA:FMC(control, WhoSeesIt)
 		[55] = 2097,	-- Dreadhorn
 		[56] = 2044,	-- Apostle
 		[57] = 2045,	-- Ebonshadow
+		[60] = 2120,	-- Worm Cult
 		}

 --		local i, a
diff --git a/IIfA/IIfADataCollection.lua b/IIfA/IIfADataCollection.lua
index 5a5aafc..4058739 100644
--- a/IIfA/IIfADataCollection.lua
+++ b/IIfA/IIfADataCollection.lua
@@ -26,6 +26,7 @@ local function grabBagContent(bagId, override)

 	local bagItems = GetBagSize(bagId)
 	p("grabBagContent(<<1>>, <<2>>", bagId, override)
+	local slotId
 	for slotId=0, bagItems, 1 do
 		local dbItem, itemKey = IIfA:EvalBagItem(bagId, slotId, false, nil, nil, nil, nil, override)
 	end
@@ -575,62 +576,72 @@ function IIfA:ValidateItemCounts(bagID, slotId, dbItem, itemKey, itemLinkOverrid
 		end
 	end
 end
- --]]
-
-function IIfA:CollectAll(bagId, tracked)		-- the args aren't used, but by making them args to function, they're avail to the task
-	local bagItems = nil
-	local itemLink, dbItem = nil
-	local itemKey
-	local location = IIfA.EMPTY_STRING
-	local BagList = IIfA:GetTrackedBags() -- 20.1. mana: Iterating over a list now
+--]]

-	for bagId, tracked in pairs(BagList) do		-- do NOT use ipairs, it's non-linear list (holes in the # sequence)
-		if bagId <= BAG_MAX_VALUE and bagId ~= BAG_SUBSCRIBER_BANK then -- ignore subscriber bank, it's handled along with the regular bank
-			-- call with libAsync to avoid lag
-			task:Call(function()
-				bagItems = GetBagSize(bagId)
-				if bagId == BAG_WORN then
-					IIfA:ClearLocationData(IIfA.currentCharacterId, BAG_WORN)
-				elseif bagId == BAG_BANK then	-- do NOT add BAG_SUBSCRIBER_BANK here, it'll wipe whatever already got put into the bank on first hit
-					IIfA:ClearLocationData(GetString(IIFA_BAG_BANK))
-				elseif bagId == BAG_BACKPACK then
-					IIfA:ClearLocationData(IIfA.currentCharacterId, BAG_BACKPACK)
-				elseif bagId == BAG_VIRTUAL then
-					IIfA:ClearLocationData(GetString(IIFA_BAG_CRAFTBAG))
-				elseif bagId >= BAG_HOUSE_BANK_ONE and bagId <= BAG_HOUSE_BANK_TEN then
-					if IsOwnerOfCurrentHouse() then
-						IIfA:ClearLocationData(GetCollectibleForHouseBankBag(bagId))
-					else
-						tracked = false		-- prevent reading the house bag if we're not in our own home
+local function CollectBag(bagId, tracked)
+	if bagId <= BAG_MAX_VALUE and bagId ~= BAG_SUBSCRIBER_BANK then -- ignore subscriber bank, it's handled along with the regular bank
+		local bagItems
+		bagItems = GetBagSize(bagId)
+		if bagId == BAG_WORN then
+			IIfA:ClearLocationData(IIfA.currentCharacterId, BAG_WORN)
+		elseif bagId == BAG_BANK then	-- do NOT add BAG_SUBSCRIBER_BANK here, it'll wipe whatever already got put into the bank on first hit
+			IIfA:ClearLocationData(GetString(IIFA_BAG_BANK))
+		elseif bagId == BAG_BACKPACK then
+			IIfA:ClearLocationData(IIfA.currentCharacterId, BAG_BACKPACK)
+		elseif bagId == BAG_VIRTUAL then
+			IIfA:ClearLocationData(GetString(IIFA_BAG_CRAFTBAG))
+		elseif bagId >= BAG_HOUSE_BANK_ONE and bagId <= BAG_HOUSE_BANK_TEN then
+			if IsOwnerOfCurrentHouse() then
+				IIfA:ClearLocationData(GetCollectibleForHouseBankBag(bagId))
+			else
+				tracked = false		-- prevent reading the house bag if we're not in our own home
+			end
+		end
+		if tracked then
+			if bagId ~= BAG_VIRTUAL then
+				if bagId ~= BAG_SUBSCRIBER_BANK then
+					grabBagContent(bagId)
+					if bagId == BAG_BANK then
+						grabBagContent(BAG_SUBSCRIBER_BANK)
 					end
 				end
-				if tracked then
-					if bagId ~= BAG_VIRTUAL then
-						if bagId ~= BAG_SUBSCRIBER_BANK then
-							grabBagContent(bagId)
-							if bagId == BAG_BANK then
-								grabBagContent(BAG_SUBSCRIBER_BANK)
-							end
-						end
-					else -- it's bag virtual
-						local slotId = GetNextVirtualBagSlotId(nil)
-						while slotId ~= nil do
-							IIfA:EvalBagItem(bagId, slotId)
-							slotId = GetNextVirtualBagSlotId(slotId)
-						end
-					end
+			else -- it's bag virtual
+				local slotId = GetNextVirtualBagSlotId(nil)
+				while slotId ~= nil do
+					IIfA:EvalBagItem(bagId, slotId)
+					slotId = GetNextVirtualBagSlotId(slotId)
 				end
+			end
+		end
+	end
+end
+
+function IIfA:CollectAll(b_useAsync)
+	local BagList = IIfA:GetTrackedBags() -- 20.1. mana: Iterating over a list now

-			end)
+	local bagId, tracked
+	for bagId, tracked in pairs(BagList) do		-- do NOT use ipairs, it's non-linear list (holes in the # sequence)
+		if b_useAsync then
+			task:Call(function() CollectBag(bagId, tracked) end)
+		else
+			CollectBag(bagId, tracked)
 		end
 	end

-	-- 6-3-17 AM - need to clear unowned items when deleting char/guildbank too
-	IIfA:ClearUnowned()

-	zo_callLater(function()
-		IIfA:MakeBSI()
-	end, 1000)
+	-- when b_useAsync is true, this isn't being called from the player unloaded event, so we need to re-make bag/slot index
+	if b_useAsync then
+		-- 6-3-17 AM - need to clear unowned items when deleting char/guildbank too
+		-- 4-4-18 AM - need to call AFTER collectbag is called
+		task:Call(function() IIfA:ClearUnowned() end)
+		zo_callLater(function()
+			IIfA:MakeBSI()
+		end, 1000)
+	else
+		-- 6-3-17 AM - need to clear unowned items when deleting char/guildbank too
+		-- 4-4-18 AM - call immediately after collectbag calls above
+		IIfA:ClearUnowned()
+	end
 end


diff --git a/IIfA/IIfAEvents.lua b/IIfA/IIfAEvents.lua
index 2062e3b..1fc8531 100644
--- a/IIfA/IIfAEvents.lua
+++ b/IIfA/IIfAEvents.lua
@@ -6,7 +6,7 @@ local em 	= EVENT_MANAGER
 -- 2015-3-7 AssemblerManiac - added code to collect inventory data at char disconnect
 local function IIfA_EventOnPlayerUnloaded()
 	-- update the stored inventory every time character logs out, will assure it's always right when viewing from other chars
-	IIfA:CollectAll()
+	IIfA:CollectAll(false)		-- don't call async lib

 	IIfA.CharCurrencyFrame:UpdateAssets()
 	IIfA.CharBagFrame:UpdateAssets()