Merge pull request #16 from AssemblerManiac/master

manavortex [02-19-18 - 18:28]
Merge pull request #16 from AssemblerManiac/master

house name on tooltips, etc
Filename
IIfA/CharBagSpaceTooltip.lua
IIfA/IIfA.lua
IIfA/IIfA.txt
IIfA/IIfABackpack.lua
IIfA/IIfADataCollection.lua
IIfA/IIfAEvents.lua
diff --git a/IIfA/CharBagSpaceTooltip.lua b/IIfA/CharBagSpaceTooltip.lua
index 2de2388..757b142 100644
--- a/IIfA/CharBagSpaceTooltip.lua
+++ b/IIfA/CharBagSpaceTooltip.lua
@@ -98,10 +98,66 @@ function CharBagFrame:FillCharAndBank()
 	spaceUsed = spaceUsed + bankUsed + self.totSpaceUsed
 	spaceMax = spaceMax + bankMax + self.totSpaceMax

+	-- housing chests
+	local bInHouse, ctr, tempUsed
+	local cName
+	local iChestCount = 0
+	bInOwnedHouse = IsOwnerOfCurrentHouse()
+
+	for ctr = BAG_HOUSE_BANK_ONE,BAG_HOUSE_BANK_TEN do
+		tControl = self.houseChestControls[ctr]
+		if IsCollectibleUnlocked(GetCollectibleForHouseBankBag(ctr)) then
+			if bInOwnedHouse then
+				tempUsed = GetNumBagUsedSlots(ctr)
+				self.currAssets.houseChestSpace[ctr] = tempUsed
+				bFoundData = true
+			else
+				if self.currAssets.houseChestSpace[ctr] ~= nil then
+					tempUsed = self.currAssets.houseChestSpace[ctr]
+					bFoundData = true
+				else
+					tempUsed = nil
+				end
+			end
+			iChestCount = iChestCount + 1
+			if tempUsed ~= nil then
+				tControl:SetHeight(26)
+				self:SetQty(tControl, "spaceUsed", self:ComputeColorAndText(tempUsed, GetBagSize(ctr)))
+				self:SetQty(tControl, "spaceMax", GetBagSize(ctr))
+				cName = GetCollectibleNickname(GetCollectibleForHouseBankBag(ctr))
+				if cName == "" then
+					cName = GetCollectibleName(GetCollectibleForHouseBankBag(ctr))
+				end
+				tControl:GetNamedChild("charName"):SetText(cName)
+				spaceUsed = spaceUsed + tempUsed
+				spaceMax = spaceMax + GetBagSize(ctr)
+			end
+		else
+			tControl:SetHeight(0)
+			self.currAssets.houseChestSpace[ctr] = nil
+		end
+	end
+
+	local iFrameHeight
+	local iDivCount = 2
+
+	if iChestCount > 0 then
+		self.divider3:SetHeight(3)
+		if not bFoundData then
+			tControl = self.houseChestControls[BAG_HOUSE_BANK_ONE]
+			tControl:SetHeight(26)
+			tControl:GetNamedChild("charName"):SetText("Enter House once")
+		end
+		iDivCount = iDivCount + 1
+	end
+
+	iFrameHeight = ((GetNumCharacters() + 4 + iChestCount) * 26) + (iDivCount * 3)		-- numchars + numChests + 4 (title line + bank + total + dividers)
+
+	self.frame:SetHeight(iFrameHeight)
+
 	self:SetQty(self.totControl, "spaceUsed", spaceUsed)
 	self:SetQty(self.totControl, "spaceMax", spaceMax)

-
 end

 -- add iteration for house chests
@@ -128,10 +184,6 @@ end


 function CharBagFrame:Initialize(objectForAssets)
-	local function ComputeSpaceUsedText(spaceUsed, spaceMax)
-		-- returns color coded
-	end
-
 	self.frame = IIFA_CharBagFrame
 	local tControl
 	local prevControl = self.frame
@@ -217,13 +269,29 @@ function CharBagFrame:Initialize(objectForAssets)
     tControl:SetAlpha(1)
 	self.divider2 = tControl

+	self.houseChestControls = {}
+	self.currAssets.houseChestSpace = self.currAssets.houseChestSpace or {}
+	local ctr
+	prevControl = self.divider2
+	for ctr = BAG_HOUSE_BANK_ONE,BAG_HOUSE_BANK_TEN do
+		tControl = CreateControlFromVirtual("IIFA_GUI_Bag_Row_House_Bank" .. ctr, self.frame, "IIFA_CharBagRow")
+		tControl:SetAnchor(TOPLEFT, prevControl, BOTTOMLEFT, 0, 0)
+		tControl:SetHeight(0)
+		self.houseChestControls[ctr] = tControl
+		prevControl = tControl
+	end
+
+	tControl = CreateControlFromVirtual("IIFA_GUI_Bag_Row_Divider3", self.frame, "ZO_Options_Divider")
+	tControl:SetDimensions(288, 0)
+    tControl:SetAnchor(TOPLEFT, prevControl, BOTTOMLEFT, 0, 0)
+    tControl:SetAlpha(1)
+	self.divider3 = tControl
+
 	tControl = CreateControlFromVirtual("IIFA_GUI_Bag_Row_Tots", self.frame, "IIFA_CharBagRow")
 	tControl:GetNamedChild("charName"):SetText("Totals")
-	tControl:SetAnchor(TOPLEFT, self.divider2, BOTTOMLEFT, 0, 0)
+	tControl:SetAnchor(TOPLEFT, self.divider3, BOTTOMLEFT, 0, 0)
 	self.totControl = tControl

-	self.frame:SetHeight((GetNumCharacters() + 4) * 26)	-- numchars + 4 represents # chars + bank + total + title and col titles
-
 	self:FillCharAndBank()

 	self.isInitialized = true
diff --git a/IIfA/IIfA.lua b/IIfA/IIfA.lua
index 5f7e317..3646cf9 100644
--- a/IIfA/IIfA.lua
+++ b/IIfA/IIfA.lua
@@ -21,7 +21,7 @@ if IIfA == nil then IIfA = {} end
 --local IIfA = IIfA

 IIfA.name 				= "Inventory Insight"
-IIfA.version 			= "3.04"
+IIfA.version 			= "3.05"
 IIfA.author 			= "AssemblerManiac & manavortex"
 IIfA.defaultAlertSound 	= nil
 IIfA.colorHandler 		= nil
@@ -62,9 +62,12 @@ IIfA.dropdownBankNames = {
 	"Bank and Current Character",
 	"Bank and other characters",
 	"Bank Only",
-	"Craft Bag"
+	"Craft Bag",
+	"Housing Storage",
+	"All Houses",
 }
-if GetAPIVersion() >= 100022 then
+
+if IIfA.trackedBags[BAG_SUBSCRIBER_BANK] == nil then
 	IIfA.trackedBags[BAG_SUBSCRIBER_BANK] 	= true
 	IIfA.trackedBags[BAG_HOUSE_BANK_TWO] 	= true
 	IIfA.trackedBags[BAG_HOUSE_BANK_THREE]	= true
diff --git a/IIfA/IIfA.txt b/IIfA/IIfA.txt
index bf7c443..086b19f 100644
--- a/IIfA/IIfA.txt
+++ b/IIfA/IIfA.txt
@@ -1,6 +1,6 @@
 ## Title: Inventory Insight
 ## Author: manavortex, AssemblerManiac
-## Version: 3.04a
+## Version: 3.05
 ## APIVersion: 100022
 ## SavedVariables: IIfA_Settings IIfA_Data
 ## OptionalDependsOn: libFilters pChat
@@ -48,7 +48,7 @@ IIfA_xml_adapter.lua

 ; DISCLOSURE:
 ; This Add-on is not created by, affiliated with or sponsored by ZeniMax
-; Media Inc. or its affiliates. The Elder Scrolls and related logos are
+; Media Inc. or its affiliates. The Elder Scrolls® and related logos are
 ; registered trademarks or trademarks of ZeniMax Media Inc. in the United
 ; States and/or other countries. All rights reserved.
 ; You can read the full terms at https://account.elderscrollsonline.com/add-on-terms
diff --git a/IIfA/IIfABackpack.lua b/IIfA/IIfABackpack.lua
index 71dc948..bb6c4d3 100644
--- a/IIfA/IIfABackpack.lua
+++ b/IIfA/IIfABackpack.lua
@@ -323,7 +323,7 @@ end

 --sort datalines
 local function IIfA_FilterCompareUp(a, b)
-
+
 	local sort1 = (IIfA.bSortQuality and a.quality) or a.name
 	local sort2 = (IIfA.bSortQuality and b.quality) or b.name
 	return (sort1 or "") < (sort2 or "")
@@ -655,9 +655,11 @@ function IIfA:QueryAccountInventory(itemLink)
 						newLocation = {}
 						newLocation.name = locationName

-						if location.bagID >= BAG_HOUSE_BANK_ONE and location.bagID <= BAG_HOUSE_BANK_TEN then	-- location is a housing chest
+						if location.bagID >= BAG_HOUSE_BANK_ONE and location.bagID <= BAG_HOUSE_BANK_TEN then -- location is a housing chest
 							newLocation.name = GetCollectibleNickname(locationName)
 							if newLocation.name == "" then newLocation.name = GetCollectibleName(locationName) end
+						elseif location.bagID == locationName then	-- location is a house
+							newLocation.name = GetCollectibleName(locationName)
 						end

 						newLocation.itemsFound = location.itemCount
diff --git a/IIfA/IIfADataCollection.lua b/IIfA/IIfADataCollection.lua
index 7c51403..4ce346a 100644
--- a/IIfA/IIfADataCollection.lua
+++ b/IIfA/IIfADataCollection.lua
@@ -72,8 +72,9 @@ function IIfA:CollectGuildBank()
 		IIfA.data.guildBanks[curGuild].bCollectData = true		-- default to true just so it's here and ok
 	end

-	-- call with libAsync to avoid lags
+	-- call with libAsync to avoid lag
 	task:Call(function()
+		IIfA:DebugOut("Collect guild bank - <<1>>", curGuild)
 		local guildData = IIfA.data.guildBanks[curGuild]
 		guildData.items = #ZO_GuildBankBackpack.data
 		guildData.lastCollected = GetDate() .. "@" .. GetFormattedTime();
@@ -115,15 +116,22 @@ function IIfA:ScanCurrentCharacter()
 	end)
 end

+--[[
+Developer note: In TryScanHouseBank, the call to IIfA:ClearLocationData will fail because collectibleId is zero
+bagId on the other hand DOES work, possibly because it's in use by the for loop
+]]--
+
 local function tryScanHouseBank()
 	if not IsOwnerOfCurrentHouse() then return end
+
 	local bagId, collectibleId
 	for bagId = BAG_HOUSE_BANK_ONE, BAG_HOUSE_BANK_TEN do
-		collectibleId = GetCollectibleForHouseBankBag(bagId) -- this MUST stay here, or collectibleId is 0
+		collectibleId = GetCollectibleForHouseBankBag(bagId)
 		if IsCollectibleUnlocked(collectibleId) then
 			IIfA:DebugOut(zo_strformat("tryScanHouseBank(<<1>>)", collectibleId))
-			-- call with libAsync to avoid lags
+			-- call with libAsync to avoid lag
 			task:Call(function()
+				local collectibleId = GetCollectibleForHouseBankBag(bagId)		-- required code - MUST stay here, or collectibleId is 0
 				IIfA:ClearLocationData(collectibleId)
 			end):Then(function()
 				grabBagContent(bagId, true)
@@ -133,7 +141,7 @@ local function tryScanHouseBank()
 end

 function IIfA:ScanBank()
-	-- call with libAsync to avoid lags
+	-- call with libAsync to avoid lag
 	task:Call(function()
 		IIfA:ClearLocationData(GetString(IIFA_BAG_BANK))
 	end):Then(function()
@@ -239,7 +247,7 @@ end

 function IIfA:GuildBankAddRemove(eventID, slotId)
 	IIfA:DebugOut("Guild Bank Add or Remove...")
-	-- call with libAsync to avoid lags
+	-- call with libAsync to avoid lag
 	task:Call(function()
 		IIfA:UpdateGuildBankData()
 		IIfA:CleanEmptyGuildBug()
@@ -247,7 +255,7 @@ function IIfA:GuildBankAddRemove(eventID, slotId)
 	--IIfA:CollectGuildBank()
 		local dbItem, itemKey
 		if eventID == EVENT_GUILD_BANK_ITEM_ADDED then
-	--		d("GB Add")
+			IIfA:DebugOut("GB Add - Slot <<1>>", slotId)
 			dbItem, itemKey = IIfA:EvalBagItem(BAG_GUILDBANK, slotId, true, 0)
 			IIfA:ValidateItemCounts(BAG_GUILDBANK, slotId, dbItem, itemKey)
 		else
diff --git a/IIfA/IIfAEvents.lua b/IIfA/IIfAEvents.lua
index c131822..fa541a8 100644
--- a/IIfA/IIfAEvents.lua
+++ b/IIfA/IIfAEvents.lua
@@ -47,7 +47,7 @@ local function IIfA_InventorySlotUpdate(...)
 end

 local function IIfA_ScanHouse(eventCode, oldMode, newMode)
-	d(newMode)
+	IIfA:DebugOut("IIfA_ScanHouse(<<1>>, <<2>>, <<3>>)", eventCode, oldMode, newMode)
 	if newMode == "showing" or newMode == "shown" then return end
 	-- are we listening?
 	if not IIfA:GetCollectingHouseData() then return end