- Fix hireling correspondance messed up display. Librarian will simply ignore this category

Orionik [07-31-24 - 13:54]
- Fix hireling correspondance messed up display. Librarian will simply ignore this category
- Fix left over from renaming of API 101038 about "loreReaderInteraction" which became "loreReaderDefault"
- Hide book that are not known when using the "Show Hidden Book" option because a book ("Jubilee Cake Voucher") got lost making the count of known book different between Librarian and Lore Library
- Add optional dependency on LoreBooks addon because some categories could not be retrieved during initialization without it (probably because LoreBooks mess a bit with the GetLoreCollectionInfo function)
Filename
CHANGELOG
ESOUIModifications.lua
Librarian.lua
Librarian.txt
LibrarianUI.lua
diff --git a/CHANGELOG b/CHANGELOG
index 347b893..6504c1b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,12 @@
 -------------------------------------------------------------------------------
 Librarian v3.0 2022-07-25
 -------------------------------------------------------------------------------
+3.13 2024-07-31
+- Fix hireling correspondance messed up display. Librarian will simply ignore this category
+- Fix left over from renaming of API 101038 about "loreReaderInteraction" which became "loreReaderDefault"
+- Hide book that are not known when using the "Show Hidden Book" option because a book ("Jubilee Cake Voucher") got lost making the count of known book different between Librarian and Lore Library
+- Add optional dependency on LoreBooks addon because some categories could not be retrieved during initialization without it (probably because LoreBooks mess a bit with the GetLoreCollectionInfo function)
+
 3.12 2024-06-03
 - Updated API for Gold Road (101042)

diff --git a/ESOUIModifications.lua b/ESOUIModifications.lua
index f8880c5..3d95af2 100644
--- a/ESOUIModifications.lua
+++ b/ESOUIModifications.lua
@@ -66,10 +66,10 @@ function Librarian:AddLoreReaderUnreadToggle()
     -- This list of scene should be the same as the list in esoui/ingame/lorereader/lorereader.lua in its Initialize function
     LORE_READER_INVENTORY_SCENE:RegisterCallback("StateChange", OnSceneStateChange)
     LORE_READER_LORE_LIBRARY_SCENE:RegisterCallback("StateChange", OnSceneStateChange)
-    LORE_READER_INTERACTION_SCENE:RegisterCallback("StateChange", OnSceneStateChange)
+    LORE_READER_DEFAULT_SCENE:RegisterCallback("StateChange", OnSceneStateChange)
     GAMEPAD_LORE_READER_INVENTORY_SCENE:RegisterCallback("StateChange", OnSceneStateChange)
     GAMEPAD_LORE_READER_LORE_LIBRARY_SCENE:RegisterCallback("StateChange", OnSceneStateChange)
-    GAMEPAD_LORE_READER_INTERACTION_SCENE:RegisterCallback("StateChange", OnSceneStateChange)
+    GAMEPAD_LORE_READER_DEFAULT_SCENE:RegisterCallback("StateChange", OnSceneStateChange)

     self.loreReaderUnreadIndicator = WINDOW_MANAGER:CreateControl("LibrarianLoreReaderUnreadIndicator", ZO_LoreReaderBookContainer, CT_TEXTURE)
     self.loreReaderUnreadIndicator:SetAnchor(TOPLEFT, ZO_LoreReaderBookContainerFirstPage, TOPLEFT, -32, 3)
@@ -167,7 +167,7 @@ function Librarian:AddLoreLibraryIcons()
         keybind = "UI_SHORTCUT_SECONDARY",
         visible = function()
             local selectedRow = LORE_LIBRARY.list:GetMouseOverRow()
-            return selectedRow and selectedRow.known
+            return selectedRow and selectedRow.known and selectedRow.hirelingType == nil
         end,
         callback = function()
             local selectedRow = LORE_LIBRARY.list:GetMouseOverRow()
@@ -196,7 +196,7 @@ function Librarian:AddLoreLibraryIcons()

         local shouldHideIcon = true
         local statusIcon = control:GetNamedChild("StatusIcon")
-        if data.numKnownBooks > 0 then
+        if data.numKnownBooks > 0 and data.categoryIndex ~= nil and data.collectionIndex ~= nil then
             if self.unreadPerCollections[data.categoryIndex] and
                 self.unreadPerCollections[data.categoryIndex][data.collectionIndex] and
                 self.unreadPerCollections[data.categoryIndex][data.collectionIndex] > 0 then
@@ -207,14 +207,21 @@ function Librarian:AddLoreLibraryIcons()
                 statusIcon:SetTexture("esoui/art/miscellaneous/check.dds")
             end
         end
+
         statusIcon:SetHidden(shouldHideIcon)
+
+        -- Fix about some collection being grayed out
+        -- This happens because the empty hireling type can get disabled if empty. And because control can be reused elsewhere when the list is rebuilt, then some random collection can appear disabled
+        if data.hirelingType == nil then
+            control:SetEnabled(true)
+        end
     end

     navigationEntryTemplateInfo.setupFunction = TreeEntrySetup
     navigationEntryTemplateInfo.template = "Librarian_LoreLibraryNavigationEntry"
     navigationEntryTemplateInfo.objectPool.templateName = "Librarian_LoreLibraryNavigationEntry"

-    -- Fix of ESO because a label header is equal to all of its entries with the current code (API 101033)
+    -- Fix of ESO because a label header is equal to all of its entries with the current code (API 101033, still present at API 101042)
     LORE_LIBRARY.navigationTree.templateInfo["ZO_LabelHeader"].equalityFunction = navigationEntryTemplateInfo.equalityFunction
 end

diff --git a/Librarian.lua b/Librarian.lua
index da96481..f7c4120 100644
--- a/Librarian.lua
+++ b/Librarian.lua
@@ -104,7 +104,7 @@ function Librarian:Initialize(...)

     local function OnShowAllBooksClicked(checkButton, isChecked)
         self.settings.showAllBooks = isChecked
-        self:RefreshFilters()
+        self:RefreshData()
     end

     local function GetShowAllBooks()
diff --git a/Librarian.txt b/Librarian.txt
index fc9ff01..ac9ff11 100644
--- a/Librarian.txt
+++ b/Librarian.txt
@@ -1,9 +1,10 @@
 ## Title: Librarian
 ## Author: Orionik, |c4EFFF6Calia1120|r, Flamage
-## Version: 3.12
+## Version: 3.13
 ## APIVersion: 101042
 ## SavedVariables: Librarian_SavedVariables Librarian_SavedVariables_Backup
 ## DependsOn: LibAddonMenu-2.0 LibrarianDeprecation
+## OptionalDependsOn: LoreBooks

 ; Load language strings
 /lang/en.lua
diff --git a/LibrarianUI.lua b/LibrarianUI.lua
index 3f9aefb..7403858 100644
--- a/LibrarianUI.lua
+++ b/LibrarianUI.lua
@@ -89,10 +89,18 @@ end
 function Librarian:BuildMasterList()
     local function ShouldDisplayBook(book)
         if not self.settings.showHiddenBook then
-            local category, collection = self:GetLoreBookIndicesFromBookId(book.bookId)
+            local category, collection, bookIndex = self:GetLoreBookIndicesFromBookId(book.bookId)
             if category and collection then
                 if self:IsLoreCollectionHidden(category, collection) then
                     return false
+                elseif not self.settings.showAllBooks then
+                    -- I don't know how, but I ended up with some book in Librarian which are not considered as known by the game (Jubilee Cake Voucher)
+                    -- Maybe because it is an event book and is added/removed at each event ?
+                    -- Anyway, if it isn't known, then we should hide it when showHiddenBook is on to have a consistent count between Librarian and LoreLibrary
+                    _, known = self:GetBookInfo(category, collection, bookIndex)
+                    if not known then
+                        return false
+                    end
                 end
             else
                 return false