I'm not sure if it exactly what you want, but here is my book filter:
Source code:
BookFilters.txt
Code:
## Title: |cEFEBBEBook Filters|r
## Version: 0.1
## Author: |cEFEBBEGarkin|r
## APIVersion: 100010
BookFilters.lua
BookFilters.lua
Lua Code:
local ADDON_NAME = "BookFilters"
local BOOK_DATA_TYPE = 1
local LIBRARY
local savedVars
local filterData = {
"Show All",
"Show Known",
"Show Unknown",
}
local function OnFilterChanged(comboBox, entryText, entry)
local container = comboBox:GetContainer()
container.filterType = entry.filterType
savedVars.filterType = entry.filterType
LIBRARY.list:FilterScrollList()
if LIBRARY.navigationTree.selectedNode then
LIBRARY.navigationTree.selectedNode:OnSelected()
end
end
local function InitializeFilters(filterControl, filterChangedCallback)
local comboBox = ZO_ComboBox_ObjectFromContainer(filterControl)
comboBox:SetSortsItems(false)
comboBox:SetFont("ZoFontWinT1")
comboBox:SetSpacing(4)
for i, text in ipairs(filterData) do
local entry = comboBox:CreateItemEntry(text, filterChangedCallback)
entry.filterType = i
comboBox:AddItem(entry)
end
comboBox:SelectFirstItem()
filterControl.filterType = savedVars.filterType or 1
end
local function FilterScrollList(self)
local categoryIndex = self.owner:GetSelectedCategoryIndex()
local collectionIndex = self.owner:GetSelectedCollectionIndex()
local totalBooks = select(4, GetLoreCollectionInfo(categoryIndex, collectionIndex))
local scrollData = ZO_ScrollList_GetDataList(self.list)
ZO_ScrollList_Clear(self.list)
for bookIndex = 1, totalBooks do
local shouldAdd
if self.filter.filterType == 1 then
shouldAdd = true
else
local _, _, known = GetLoreBookInfo(categoryIndex, collectionIndex, bookIndex)
if self.filter.filterType == 2 then
shouldAdd = known
elseif self.filter.filterType == 3 then
shouldAdd = not known
end
end
if shouldAdd then
scrollData[#scrollData + 1] = ZO_ScrollList_CreateDataEntry(BOOK_DATA_TYPE, { categoryIndex = categoryIndex, collectionIndex = collectionIndex, bookIndex = bookIndex })
end
end
end
local function OnAddonLoaded(evt, name)
if (name == ADDON_NAME) then
EVENT_MANAGER:UnregisterForEvent(name, evt)
savedVars = ZO_SavedVars:New("ZO_Ingame_SavedVariables", 1, "BookFilters", { filterType = 1 })
LIBRARY = ZO_LoreLibrary.owner
LIBRARY.list.filter = CreateControlFromVirtual("$(parent)Filter", ZO_LoreLibrary, "ZO_ComboBox")
LIBRARY.list.filter:SetDimensions(222, 32)
LIBRARY.list.filter:SetAnchor(TOPRIGHT, ZO_LoreLibrary, TOPRIGHT, -20, 15)
InitializeFilters(LIBRARY.list.filter, OnFilterChanged)
LIBRARY.list.FilterScrollList = FilterScrollList
end
end
EVENT_MANAGER:RegisterForEvent(ADDON_NAME, EVENT_ADD_ON_LOADED, OnAddonLoaded)
If you want downloadable version, it is BookFilters-0.1.zip in my Dropbox folder.