Merge pull request #40 from AssemblerManiac/master

manavortex [04-10-18 - 06:45]
Merge pull request #40 from AssemblerManiac/master

scrollable main list
Filename
IIfA/IIfA.lua
IIfA/IIfA.txt
IIfA/IIfA.xml
IIfA/IIfABackpack.lua
IIfA/IIfADataCollection.lua
IIfA/IIfAEvents.lua
IIfA/IIfATooltip.lua
diff --git a/IIfA/IIfA.lua b/IIfA/IIfA.lua
index 0e36ea9..0c71482 100644
--- a/IIfA/IIfA.lua
+++ b/IIfA/IIfA.lua
@@ -15,7 +15,7 @@ if IIfA == nil then IIfA = {} end
 --local IIfA = IIfA

 IIfA.name 				= "Inventory Insight"
-IIfA.version 			= "3.15"
+IIfA.version 			= "3.16"
 IIfA.author 			= "AssemblerManiac & manavortex"
 IIfA.defaultAlertSound 	= nil
 IIfA.colorHandler 		= nil
@@ -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.txt b/IIfA/IIfA.txt
index e7fd8dc..c52f5ed 100644
--- a/IIfA/IIfA.txt
+++ b/IIfA/IIfA.txt
@@ -1,6 +1,6 @@
 ## Title: Inventory Insight
 ## Author: manavortex, AssemblerManiac
-## Version: 3.15
+## Version: 3.16
 ## APIVersion: 100022
 ## SavedVariables: IIfA_Settings IIfA_Data
 ## OptionalDependsOn: libFilters pChat
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 09334d4..e57c259 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
@@ -577,62 +578,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()
diff --git a/IIfA/IIfATooltip.lua b/IIfA/IIfATooltip.lua
index 19bfe37..07c2c54 100644
--- a/IIfA/IIfATooltip.lua
+++ b/IIfA/IIfATooltip.lua
@@ -97,7 +97,7 @@ IIfA.racialTextures = {
 	[33] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(33)), styleTexture = getTex("akaviri")},  			-- Akaviri
 	[34] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(34)), styleTexture = getTex("imperial")}, 			-- Imperial
 	[35] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(35)), styleTexture = getTex("akaviri")}, 			-- Yokudan
-	[36] 	= { styleName = "Universal", styleTexture = getTex("imperial")}, 											-- "Universal" what the hell
+	[36] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(36)), styleTexture = getTex("imperial")}, 			-- "Universal" what the hell
 	[37] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(37)), styleTexture = getTex("reach")}, 				-- Reach Winter
 	[38] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(38)), styleTexture = getTex("tsaesci")}, 			-- Tsaesci
 	[39] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(39)), styleTexture = getTex("minotaur")}, 			-- Minotaur
@@ -111,7 +111,7 @@ IIfA.racialTextures = {
 	[47] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(47)), styleTexture = getTex("outlaw")}, 				-- Outlaw
 	[48] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(48)), styleTexture = getTex("redoran")}, 			-- Redoran
 	[49] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(49)), styleTexture = getTex("hlaalu")}, 				-- Hlaalu
-	[50] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(50)), styleTexture = getTex("ordinator")}, 			-- Ordinator **
+	[50] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(50)), styleTexture = getTex("ordinator")}, 			-- Militant Ordinator
 	[51] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(51)), styleTexture = getTex("telvanni")}, 			-- Telvanni
 	[52] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(52)), styleTexture = getTex("buoyantarmiger")}, 		-- Buoyant Armiger
 	[53] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(53)), styleTexture = getTex("frostcaster")}, 		-- Frostcaster
@@ -121,26 +121,26 @@ IIfA.racialTextures = {
 	[57] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(57)), styleTexture = getTex("lizard")}, 				-- Mazzatun
 	[58] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(58)), styleTexture = getTex("harlequin")}, 			-- Grim Harlequin
 	[59] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(59)), styleTexture = getTex("hollowjack")}, 			-- Hollowjack
-	[60] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(60)), styleTexture = getTex("clockwork")}, 			-- Clockwork
+	[60] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(60)), styleTexture = getTex("clockwork")}, 			-- Refabricated (Clockwork)
 	[61] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(61)), styleTexture = getTex("bloodforge")}, 			-- Bloodforge
-	[62] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(62)), styleTexture = getTex("dreadhorn")}, 			-- Dreadhorn / Falkreath
-	[63] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(63)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 					-- Unused
-	[64] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(64)), styleTexture = getTex(IIfA.EMPTY_STRING)},					-- Unused
+	[62] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(62)), styleTexture = getTex("dreadhorn")}, 			-- Dreadhorn
+	[63] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(63)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 		-- Unused
+	[64] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(64)), styleTexture = getTex(IIfA.EMPTY_STRING)},			-- Unused
 	[65] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(65)), styleTexture = getTex("apostle")},				-- Apostle
 	[66] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(66)), styleTexture = getTex("ebonshadow")},			-- Ebonshadow
-	[67] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(67)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 					-- Unused
-	[68] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(68)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 					-- Unused
-	[69] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(69)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 					-- Unused
-	[70] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(70)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 					-- Unused
-	[71] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(71)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 					-- Unused
-	[72] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(72)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 					-- Unused
-	[73] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(73)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 					-- Unused
-	[74] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(74)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 					-- Unused
-	[75] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(75)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 					-- Unused
-	[76] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(76)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 					-- Unused
-	[77] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(77)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 					-- Unused
-	[78] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(78)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 					-- Unused
-	[79] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(79)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 					-- Unused
+	[67] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(67)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 	-- Undaunted
+	[68] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(68)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 		-- Unused
+	[69] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(69)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 	-- Fang Lair
+	[70] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(70)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 	-- Dragon Priest
+	[71] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(71)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 		-- Unused
+	[72] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(72)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 		-- Unused
+	[73] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(73)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 		-- Unused
+	[74] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(74)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 		-- Unused
+	[75] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(75)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 		-- Unused
+	[76] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(76)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 		-- Unused
+	[77] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(77)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 		-- Unused
+	[78] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(78)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 		-- Unused
+	[79] 	= { styleName = zo_strformat("<<1>>", GetItemStyleName(79)), styleTexture = getTex(IIfA.EMPTY_STRING)}, 		-- Unused
 }

 -- check on icons Hlaalu, Redoran and Morag Tong not loading properly