Merge pull request #19 from AssemblerManiac/master

manavortex [02-23-18 - 07:54]
Merge pull request #19 from AssemblerManiac/master

version bump, refresh list after changes
Filename
IIfA/CharBagSpaceTooltip.lua
IIfA/IIfA.lua
IIfA/IIfA.txt
IIfA/IIfAEvents.lua
IIfA/IIfASceneFuncs.lua
diff --git a/IIfA/CharBagSpaceTooltip.lua b/IIfA/CharBagSpaceTooltip.lua
index 6773267..dbc30a5 100644
--- a/IIfA/CharBagSpaceTooltip.lua
+++ b/IIfA/CharBagSpaceTooltip.lua
@@ -99,13 +99,13 @@ function CharBagFrame:FillCharAndBank()
 	spaceMax = spaceMax + bankMax + self.totSpaceMax

 	-- housing chests
-	local bInHouse, ctr, tempUsed, bFoundData
+	local bInHouse, ctr, tempUsed, bFoundData, tControl
 	local cName
 	local iChestCount = 0
 	local bInOwnedHouse = IsOwnerOfCurrentHouse()

-	for ctr = BAG_HOUSE_BANK_ONE,BAG_HOUSE_BANK_TEN do
-		local tControl = self.houseChestControls[ctr]
+	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)
@@ -138,7 +138,7 @@ function CharBagFrame:FillCharAndBank()
 		end
 	end

-	local iFrameHeight, tControl
+	local iFrameHeight
 	local iDivCount = 2

 	if iChestCount > 0 then
diff --git a/IIfA/IIfA.lua b/IIfA/IIfA.lua
index ac05e64..065fbd2 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.06"
+IIfA.version 			= "3.07"
 IIfA.author 			= "AssemblerManiac & manavortex"
 IIfA.defaultAlertSound 	= nil
 IIfA.colorHandler 		= nil
@@ -281,51 +281,28 @@ function IIfA_onLoad(eventCode, addOnName)

 	IIfA:RebuildHouseMenuDropdowns()

-	local function setIfNil(value, defaultValue)
-		if nil ~= value then return end
-		value = defaultValue
-	end
-	local function setNil(value)
-		if nil ~= value then value = nil end
-	end
-
 	--  nuke non-global positioning settings
 	local ObjSettings = IIfA:GetSettings()
-	local function nukePositioning()
-		if ObjSettings.in2InventoryFrameSceneSettings ~= nil then
-			ObjSettings.in2InventoryFrameSceneSettings = nil
-		end
-		if ObjSettings.in2InventoryFrameScenes ~= nil then
-			ObjSettings.in2InventoryFrameScenes = nil
-		end
-		if ObjSettings.valDocked ~= nil then
-			ObjSettings.valDocked = nil
-			ObjSettings.valLocked = nil
-			ObjSettings.valMinimized = nil
-			ObjSettings.valLastX = nil
-			ObjSettings.valLastY = nil
-			ObjSettings.valHeight = nil
-			ObjSettings.valWidth = nil
-			ObjSettings.valWideX = nil
-		end
+	if ObjSettings.in2InventoryFrameSceneSettings ~= nil then
+		ObjSettings.in2InventoryFrameSceneSettings = nil
 	end
-	nukePositioning()
-
-	local function considerWorldData()
-		-- keep EU and US items apart
-		local worldName = GetWorldName():gsub(" Megaserver", "")
-		IIfA.data[worldName] = IIfA.data[worldName] or {}
-		if IIfA.data[worldName].DBv3 == nil then
-			 IIfA.data[worldName].DBv3 = IIfA.data.DBv3
-		end
-		IIfA.data.DBv3 = nil
-		IIfA.database = IIfA.data[worldName].DBv3
+	if ObjSettings.in2InventoryFrameScenes ~= nil then
+		ObjSettings.in2InventoryFrameScenes = nil
+	end
+	if ObjSettings.valDocked ~= nil then
+		ObjSettings.valDocked = nil
+		ObjSettings.valLocked = nil
+		ObjSettings.valMinimized = nil
+		ObjSettings.valLastX = nil
+		ObjSettings.valLastY = nil
+		ObjSettings.valHeight = nil
+		ObjSettings.valWidth = nil
+		ObjSettings.valWideX = nil
 	end

-
-
-	setNil(IIfA.settings.in2ToggleGuildBankDataCollection ~= nil)
-
+	if IIfA.settings.in2ToggleGuildBankDataCollection ~= nil then
+		IIfA.settings.in2ToggleGuildBankDataCollection = nil
+	end
 	if IIfA.data.in2ToggleGuildBankDataCollection ~= nil then
 		IIfA.data.bCollectGuildBankData = IIfA.data.in2ToggleGuildBankDataCollection
 		IIfA.data.in2ToggleGuildBankDataCollection = nil
@@ -360,8 +337,13 @@ function IIfA_onLoad(eventCode, addOnName)
 		end
 	end

-	setIfNil(IIfA.data.showStyleInfo, true)
-	setIfNil(ObjSettings.showStyleInfo, IIfA.data.showStyleInfo)
+	if IIfA.data.showStyleInfo == nil then
+		IIfA.data.showStyleInfo = true
+	end
+	if ObjSettings.showStyleInfo == nil then
+		ObjSettings.showStyleInfo = IIfA.data.showStyleInfo
+	end
+

 	-- 2-9-17 AM - convert saved data names into proper language for this session
     local lang = GetCVar("language.2")
@@ -432,9 +414,16 @@ function IIfA_onLoad(eventCode, addOnName)
 	IIfA:CreateTooltips()	-- setup the tooltip frames

 	-- manavortex, Feb. 22 2018: drop dbv2 support
-	if nil ~= IIfA.data.DBv2 then IIfA.data.DBv2 = nil end
+	if nil ~= IIfA.data.DBv2 then IIfA.data.DBv2 = nil end

-	considerWorldData()
+	-- keep EU and US items apart
+	local worldName = GetWorldName():gsub(" Megaserver", "")
+	IIfA.data[worldName] = IIfA.data[worldName] or {}
+	if IIfA.data[worldName].DBv3 == nil then
+		 IIfA.data[worldName].DBv3 = IIfA.data.DBv3
+	end
+	IIfA.data.DBv3 = nil
+	IIfA.database = IIfA.data[worldName].DBv3

 	IIfA:ActionLayerInventoryUpdate()

@@ -445,8 +434,8 @@ function IIfA_onLoad(eventCode, addOnName)
 	IIfA:RegisterForEvents()
 	IIfA:RegisterForSceneChanges() -- register for callbacks on scene statechanges using user preferences or defaults

-	IIfA.ignoredCharEquipment 		= IIfA.ignoredCharEquipment or {}
-	IIfA.ignoredCharInventories 	= IIfA.ignoredCharInventories or {}
+	IIfA.ignoredCharEquipment = IIfA.ignoredCharEquipment or {}
+	IIfA.ignoredCharInventories = IIfA.ignoredCharInventories or {}

 	IIfA.trackedBags[BAG_WORN] 		= not IIfA:IsCharacterEquipIgnored()
 	IIfA.trackedBags[BAG_BACKPACK] 	= not IIfA:IsCharacterInventoryIgnored()
diff --git a/IIfA/IIfA.txt b/IIfA/IIfA.txt
index a92363c..6ad01c7 100644
--- a/IIfA/IIfA.txt
+++ b/IIfA/IIfA.txt
@@ -1,6 +1,6 @@
 ## Title: Inventory Insight
 ## Author: manavortex, AssemblerManiac
-## Version: 3.06
+## Version: 3.07
 ## APIVersion: 100022
 ## SavedVariables: IIfA_Settings IIfA_Data
 ## OptionalDependsOn: libFilters pChat
diff --git a/IIfA/IIfAEvents.lua b/IIfA/IIfAEvents.lua
index fa541a8..a800520 100644
--- a/IIfA/IIfAEvents.lua
+++ b/IIfA/IIfAEvents.lua
@@ -39,6 +39,22 @@ function IIfA:InventorySlotUpdate(eventCode, bagId, slotId, isNewItem, itemSound
 	-- (bagId, slotNum, fromXfer, itemCount, itemLink, itemName, locationID)
 	local dbItem, itemKey = self:EvalBagItem(bagId, slotId, not isNewItem, qty, itemLink)

+	-- once a bunch of items comes in, this will be created for each, but only the last one stays alive
+	-- so once all the items are finished coming in, it'll only need to update the shown list one time
+	local callbackName = "IIfA_RefreshInventoryScroll"
+    local function Update()
+        EVENT_MANAGER:UnregisterForUpdate(callbackName)
+		if IIFA_GUI:IsControlHidden() then
+			return
+		else
+			IIfA:RefreshInventoryScroll()
+		end
+    end
+
+    --cancel previously scheduled update if any
+    EVENT_MANAGER:UnregisterForUpdate(callbackName)
+    --register a new one
+    EVENT_MANAGER:RegisterForUpdate(callbackName, 250, Update)
 end


diff --git a/IIfA/IIfASceneFuncs.lua b/IIfA/IIfASceneFuncs.lua
index b9220bb..3fcec53 100644
--- a/IIfA/IIfASceneFuncs.lua
+++ b/IIfA/IIfASceneFuncs.lua
@@ -40,9 +40,9 @@ function IIfA:RegisterForSceneChanges()
 end

 function IIfA:GetSceneSettings(sceneName)
-
+
 	sceneName = sceneName or IIfA:GetCurrentSceneName()
-
+

 	local settings = IIfA:GetSettings().frameSettings

@@ -65,17 +65,15 @@ end


 function IIfA:ProcessSceneChange(sceneName, oldState, newState)
-
-
 	-- IIfA:DebugOut(zo_strformat("ProcessSceneChange <<1>>: <<2>> -> <<3>>", sceneName, oldState, newState))
 	if (tostring(newState) == "shown") then
 		sceneName = IIfA:GetCurrentSceneName()
 		local settings = IIfA:GetSceneSettings(sceneName)
 		self:RePositionFrame(settings)
-
+
 	elseif (tostring(newState) == "hidden") then
 		IIFA_GUI:SetHidden(true)
-	end
+	end
 end


@@ -85,8 +83,8 @@ function IIfA:SaveFrameInfo(calledFrom)
 	local sceneName = IIfA:GetCurrentSceneName()
 	local settings = IIfA:GetSceneSettings(sceneName)

-    settings.hidden    	=  IIFA_GUI:IsControlHidden()
-
+    settings.hidden = IIFA_GUI:IsControlHidden()
+
 	if (not settings.docked and (calledFrom == "onMoveStop" or calledFrom == "onResizeStop")) then
     	settings.lastX	= IIFA_GUI:GetLeft()
     	settings.lastY	= IIFA_GUI:GetTop()
@@ -107,7 +105,7 @@ function IIfA:ToggleInventoryFrame()
 		IIfA:GuiResizeScroll()
     	IIfA:RefreshInventoryScroll()
 	end
-	if not IIfA.data.dontFocusSearch then
+	if not IIfA.data.dontFocusSearch then
 		IIFA_GUI_SearchBox:TakeFocus()
 	end
 	IIfA:SaveFrameInfo("ToggleInventoryFrame")