Version 1.1.7 (29-08-2020)

Ulrik Larsen [08-29-20 - 10:02]
Version 1.1.7 (29-08-2020)
- Updated APIVersion to 100032
- Categories are no longer filtered, it shows the same list as the ESO Collections view.
-- This is not the ideal solution, but there are no properties in common i can filter on (at this time at least).
-- SubCategories are made recursive, in case SubCategories to SubCategories ever becomes a thing.
- Categories are now collapsed by default.
-- Parent categories (shown without a COG icon) can be expanded/collapsed.
- Fixed issue with Tooltip for categories
Filename
CBs_Constants.lua
CBs_Helpers.lua
CBs_Settings_Data.lua
CBs_Settings_List.lua
Changelog
CollectionBars.lua
CollectionBars.txt
diff --git a/CBs_Constants.lua b/CBs_Constants.lua
index c044d0e..6d215f1 100644
--- a/CBs_Constants.lua
+++ b/CBs_Constants.lua
@@ -7,7 +7,7 @@ Filename: CBs_Constants.lua
 -------------------------------------------------------------------------------------------------
 CollectionBars = {
     WM = GetWindowManager(),
-    Addon = {Name = "CollectionBars", DisplayName = "Collection Bars", Abbreviation = "CBs", Version = 1.1, MinorVersion = 6, SettingsSlash = "/cb", Author = "Jarth"},
+    Addon = {Name = "CollectionBars", DisplayName = "Collection Bars", Abbreviation = "CBs", Version = 1.1, MinorVersion = 7, SettingsSlash = "/cb", Author = "Jarth"},
     AllButtons = {},
     Default = {
         UseAccountSettings = true,
@@ -67,7 +67,7 @@ CollectionBars = {
             [8] = {Name = "InStore", Instance = SCENE_MANAGER:GetScene("store"), Description = "%s at a store"}
         },
         HighestUnlocked = 0,
-        ShowChildren = {Appearance = true}
+        ShowChildren = {}
     },
     Categories = {},
     CategoriesOrdered = {},
@@ -110,48 +110,52 @@ function base:GenerateCategories()

     for _, categoryData in ZO_COLLECTIBLE_DATA_MANAGER:CategoryIterator({ZO_CollectibleCategoryData.HasShownCollectiblesInCollection}) do
         if categoryData ~= nil and categoryData:IsStandardCategory() then
-            local type = base.GetType(categoryData)
-            if type ~= nil and categoryData ~= nil and base:CategoryHasUnlockedValidAndUsableCollectible(categoryData) then
-                base.AddCategory(type, categoryData)
-            else
-                if categoryData:IsTopLevelCategory() and base:SubCategoryHasUsableCollectible(categoryData) then
-                    local parentIcons = {categoryData:GetKeyboardIcons()}
-                    base.AddCategory(nil, categoryData, parentIcons, true)
-                    for _, subcategoryData in categoryData:SubcategoryIterator({ZO_CollectibleCategoryData.HasShownCollectiblesInCollection}) do
-                        type = base.GetType(subcategoryData)
-                        if type ~= nil and subcategoryData ~= nil and subcategoryData:HasShownCollectiblesInCollection() then
-                            base.AddCategory(type, subcategoryData, parentIcons, false, categoryData:GetFormattedName())
-                        end
-                    end
-                end
-            end
+            local categoryType = base.GetCategoryTypeFromCollectible(categoryData)
+            local keyboardIcons = {categoryData:GetKeyboardIcons()}
+            local parentKey = categoryData:GetFormattedName()
+            local hasSubCategories = categoryData:GetNumSubcategories() > 0
+
+            base.AddCategory(categoryData, categoryType, keyboardIcons, hasSubCategories)
+            if hasSubCategories then base:AddSubCategories(categoryData, keyboardIcons, parentKey) end
         end
     end
 end

-function base.GetType(categoryData)
-    base:Debug("GetType", categoryData)
-    local type = nil
+function base:AddSubCategories(categoryData, parentKeyboardIcons, parentKey)
+    base:Debug("AddSubCategories", categoryData, parentKeyboardIcons, parentKey)
+    for _, subcategoryData in categoryData:SubcategoryIterator({ZO_CollectibleCategoryData.HasShownCollectiblesInCollection}) do
+        local categoryType = base.GetCategoryTypeFromCollectible(subcategoryData)
+        local hasSubCategories = subcategoryData:GetNumSubcategories() > 0
+        base.AddCategory(subcategoryData, categoryType, parentKeyboardIcons, hasSubCategories, parentKey)
+        if hasSubCategories then
+            local subcategoryParentKey = subcategoryData:GetFormattedName()
+            base:AddSubCategories(subcategoryData, parentKeyboardIcons, subcategoryParentKey)
+        end
+    end
+end
+
+function base.GetCategoryTypeFromCollectible(categoryData)
+    base:Debug("GetCategoryType", categoryData)
+    local categoryType = nil
     local collectibles = categoryData:GetCollectibleDataBySpecializedSort()
-    if collectibles ~= nil and collectibles[1] ~= nil then type = collectibles[1]:GetCategoryType() end
+    if base.HasAny(collectibles) then categoryType = collectibles[1]:GetCategoryType() end

-    return type
+    return categoryType
 end

-function base.AddCategory(type, categoryData, parentIcons, hasChildren, parentKey)
-    base:Debug("AddCategory", type, categoryData, parentIcons, hasChildren, parentKey)
+function base.AddCategory(categoryData, categoryType, keyboardIcons, hasChildren, parentKey)
+    base:Debug("AddCategory", categoryData, categoryType, keyboardIcons, hasChildren, parentKey)
     local categoryName = categoryData:GetFormattedName()
     local categoryId = categoryData:GetId()
-    local icon = parentIcons or {categoryData:GetKeyboardIcons()}
-    if icon ~= nil and icon[1] == ZO_NO_TEXTURE_FILE then icon = nil end
+    if keyboardIcons ~= nil and keyboardIcons[1] == ZO_NO_TEXTURE_FILE then keyboardIcons = nil end
     base.Categories[categoryId] = {
         Collection = {},
         CollectionOrdered = {},
         Buttons = {},
-        Type = type,
+        CategoryType = categoryType,
         Id = categoryId,
         CategoryData = categoryData,
-        Icon = icon,
+        Icon = keyboardIcons,
         HasChildren = hasChildren,
         ParentKey = parentKey,
         Unlocked = 0,
@@ -172,22 +176,3 @@ function base.AddCategory(type, categoryData, parentIcons, hasChildren, parentKe
         Label = {Show = true, EnableHideAll = true, Display = categoryName, Offset = {X = 0, Y = 0}, Height = 19, Width = 75, Font = "ZoFontGameSmall", Position = BOTTOMLEFT, PositionTarget = TOPLEFT}
     }
 end
-
-function base:CategoryHasUnlockedValidAndUsableCollectible(categoryData)
-    base:Debug("CategoryHasUnlockedValidAndUsableCollectible", categoryData)
-    if GetTotalCollectiblesByCategoryType(categoryData:GetId()) > 0 then
-        for _, collectibleData in ZO_CollectibleCategoryData.CollectibleIterator(categoryData, {ZO_CollectibleData.IsShownInCollection}) do
-            if collectibleData:IsUnlocked() and collectibleData:IsValidForPlayer() and collectibleData:IsUsable() then return true end
-        end
-    end
-    return false
-end
-
-function base:SubCategoryHasUsableCollectible(categoryData)
-    base:Debug("SubCategoryHasUsableCollectible", categoryData)
-    for _, subcategoryData in categoryData:SubcategoryIterator({ZO_CollectibleCategoryData.HasShownCollectiblesInCollection}) do
-        local type = base.GetType(subcategoryData)
-        if type ~= nil and subcategoryData ~= nil and base:CategoryHasUnlockedValidAndUsableCollectible(subcategoryData) then return true end
-    end
-    return false
-end
diff --git a/CBs_Helpers.lua b/CBs_Helpers.lua
index 1cee689..2f417e7 100644
--- a/CBs_Helpers.lua
+++ b/CBs_Helpers.lua
@@ -227,7 +227,7 @@ end

 function base:HasAny(array)
     base:Debug("HasAny", array)
-    for _ in pairs(array) do return true end
+    if array ~= nil then for _ in pairs(array) do return true end end
     return false
 end

diff --git a/CBs_Settings_Data.lua b/CBs_Settings_Data.lua
index b4421d0..2124521 100644
--- a/CBs_Settings_Data.lua
+++ b/CBs_Settings_Data.lua
@@ -220,15 +220,21 @@ function base.AppendMasterListTypeCategories(self, listType)
     self:AppendRow_Divider(listType, {})

     for _, category in ipairs(base.CategoriesOrdered or {}) do
+        local toolTipText = ""
+        if category.HasChildren then
+            toolTipText = string.format("Click to toggle subcategories for\n%s", category.Name)
+        else
+            toolTipText = string.format(
+                              "When ON the collection category:\n%s will enabled\n\nPress the 'cog' to display collectible in the tabs: 'Collectibles' and 'Category'\n and Right click wil also change the tab",
+                              category.Name)
+        end
         local data = {
             cId = category.Id,
             icon = category.Icon,
             name = string.format("Show %s", category.Name),
             hasChildren = category.HasChildren,
             parentKey = category.ParentKey,
-            tooltipText = string.format(
-                "When ON the collection category:\n%s will enabled\n\nPress the 'cog' to display collectible in the tabs: 'Collectibles' and 'Category'\n and Right click wil also change the tab",
-                category.Name),
+            tooltipText = toolTipText,
             funcGet = function() return category.Saved.Enabled end,
             disabledFunc = function() return category.Disabled end,
             funcSet = function(_, newValue)
diff --git a/CBs_Settings_List.lua b/CBs_Settings_List.lua
index 053fe9b..86dcf20 100644
--- a/CBs_Settings_List.lua
+++ b/CBs_Settings_List.lua
@@ -94,19 +94,24 @@ function CBs_Settings_List:AppendRow_Category_Title(listType, data)
 end

 function CBs_Settings_List:SetupRow_Category_Title(control, data)
-    base:Info("CBs_Settings_List:SetupRow_Category_Title", control, data)
+    base:Debug("CBs_Settings_List:SetupRow_Category_Title", control, data)
     control.data = data
     ZO_SortFilterList.SetupRow(self, control, control.data)
-    control:SetHandler("OnMouseUp", function()
-        local showChildren = base.Global.ShowChildren[data.name]
-        if (showChildren ~= nil) then
-            showChildren = not showChildren
+    local funcMouseEnter = nil
+    local funcMouseExit = nil
+    control:SetHidden(false)
+    control:SetAlpha(1)
+    if data.hasChildren then
+        control:SetHandler("OnMouseUp", function()
+            base.Global.ShowChildren[data.name] = not base.Global.ShowChildren[data.name]
             base.Global.Settings.List:RefreshFilters()
-        end
-    end)
+        end)
+        funcMouseEnter = function(_control) ZO_Tooltips_ShowTextTooltip(_control, BOTTOM, _control.data.tooltipText) end
+        funcMouseExit = function() ZO_Tooltips_HideTextTooltip() end
+    end

     self.SetNameText(control, control.data.name)
-    self.SetupIcon(control, control.data)
+    self.SetupIcon(control, control.data, funcMouseEnter, funcMouseExit)
     self.SetActiveOrInactive(control)
 end

@@ -312,7 +317,7 @@ function CBs_Settings_List.SetNameText(control, text, fontOverrides)
     end
 end

-function CBs_Settings_List.SetupIcon(control, data)
+function CBs_Settings_List.SetupIcon(control, data, funcMouseEnter, funcMouseExit)
     base:Debug("CBs_Settings_List.SetupIcon", control, data)
     if control.icon == nil then control.icon = GetControl(control, "Icon") end
     if control.icon ~= nil then
@@ -321,8 +326,14 @@ function CBs_Settings_List.SetupIcon(control, data)
         control.icon:SetTexture(data.icon and data.icon[1])

         if data.icon[1] ~= nil and data.icon[3] ~= nil then
-            control:SetHandler("OnMouseEnter", function() control.icon:SetTexture(data.icon[3]) end)
-            control:SetHandler("OnMouseExit", function() control.icon:SetTexture(data.icon[1]) end)
+            control:SetHandler("OnMouseEnter", function()
+                control.icon:SetTexture(data.icon[3])
+                if funcMouseEnter ~= nil then funcMouseEnter(control) end
+            end)
+            control:SetHandler("OnMouseExit", function()
+                control.icon:SetTexture(data.icon[1])
+                if funcMouseExit ~= nil then funcMouseExit(control) end
+            end)
         end
         return hasIcon
     end
@@ -379,14 +390,14 @@ function CBs_Settings_List:BuildMasterList()
 end

 function CBs_Settings_List:FilterScrollList()
-    base:Info("CBs_Settings_List:FilterScrollList")
+    base:Debug("CBs_Settings_List:FilterScrollList")
     local scrollData = ZO_ScrollList_GetDataList(self.list)
     ZO_ClearNumericallyIndexedTable(scrollData)
     for _, listElement in ipairs(self.masterList) do
         if self.masterListType == nil or self.masterListType == listElement.listType then
             if self.masterListType == "Categories" and listElement.parentKey ~= nil then
-                local showChildren = base.Global.ShowChildren[listElement.parentKey] or false
-                base:Info("FilterScrollList", base.Global.ShowChildren, listElement.parentKey, base.Global.ShowChildren[listElement.parentKey])
+                local showChildren = base.Global.ShowChildren[listElement.parentKey]
+                base:Debug("FilterScrollList", base.Global.ShowChildren, listElement.parentKey, base.Global.ShowChildren[listElement.parentKey])
                 if showChildren then scrollData[#scrollData + 1] = ZO_ScrollList_CreateDataEntry(listElement.dataTypeId, listElement) end
             else
                 scrollData[#scrollData + 1] = ZO_ScrollList_CreateDataEntry(listElement.dataTypeId, listElement)
diff --git a/Changelog b/Changelog
index 2690839..eab5508 100644
--- a/Changelog
+++ b/Changelog
@@ -1,6 +1,15 @@
 -------------------------------------------------------------------------------
  Collection bars
 -------------------------------------------------------------------------------
+Version 1.1.7 (29-08-2020)
+- Updated APIVersion to 100032
+- Categories are no longer filtered, it shows the same list as the ESO Collections view.
+-- This is not the ideal solution, but there are no properties in common i can filter on (at this time at least).
+-- SubCategories are made recursive, in case SubCategories to SubCategories ever becomes a thing.
+- Categories are now collapsed by default.
+-- Parent categories (shown without a COG icon) can be expanded/collapsed.
+- Fixed issue with Tooltip for categories
+
 Version 1.1.6 (05-07-2020)
 - Renamed saved setting: MenuShowDisabled to Menu.ShowDisabled
 - Fixed issue where it was not possible to collapse "Appearance" in categories
diff --git a/CollectionBars.lua b/CollectionBars.lua
index daa9afb..e192801 100644
--- a/CollectionBars.lua
+++ b/CollectionBars.lua
@@ -58,7 +58,7 @@ function base:CreateCategory(category)
     base:Debug("CreateCategory", category)
     category.Collection = {}
     category.CollectionOrdered = {}
-    category.Unlocked = GetTotalUnlockedCollectiblesByCategoryType(category.Type)
+    category.Unlocked = GetTotalUnlockedCollectiblesByCategoryType(category.CategoryType)

     if category.Unlocked > base.Global.HighestUnlocked then base.Global.HighestUnlocked = category.Unlocked end

diff --git a/CollectionBars.txt b/CollectionBars.txt
index f8a4b54..0caa7f4 100644
--- a/CollectionBars.txt
+++ b/CollectionBars.txt
@@ -4,10 +4,10 @@
 ; States and/or other countries. All rights reserved.
 ; You can read the full terms at https://account.elderscrollsonline.com/add-on-terms

-## APIVersion: 100031
+## APIVersion: 100032
 ## Title: Collection Bars
-## AddOnVersion: 10106
-## Version: 1.1.6
+## AddOnVersion: 10107
+## Version: 1.1.7
 ## Author: Jarth
 ## Description: Show collection bars and activate collections with key or button press. Shortcuts: Settings window: /cb OptionalDependsOn: LibDebugLogger (Logging can be enabled in settings)
 ##