LeoAltholicInventoryList = ZO_SortFilterList:Subclass() function LeoAltholicInventoryList:New(control) ZO_SortFilterList.InitializeSortFilterList(self, control) local sorterKeys = { ["name"] = {}, ["bag"] = { tiebreaker = "name" }, ["gold"] = { tiebreaker = "name" }, ["soulgems"] = { tiebreaker = "name" }, ["ap"] = { tiebreaker = "name" }, ["telvar"] = { tiebreaker = "name" }, ["writvouchers"] = { tiebreaker = "name" }, } self.masterList = {} self.currentSortKey = "name" self.currentSortOrder = ZO_SORT_ORDER_UP ZO_ScrollList_AddDataType(self.list, 1, "LeoAltholicInventoryListTemplate", 32, function(control, data) self:SetupEntry(control, data) end) self.sortFunction = function(listEntry1, listEntry2) return ZO_TableOrderingFunction(listEntry1.data, listEntry2.data, self.currentSortKey, sorterKeys, self.currentSortOrder) end return self end local function formatNumber(amount) if amount == nil then return nil; end if type(amount) == "string" then amount = tonumber( amount ) end if type(amount) ~= "number" then return amount; end if amount < 1000 then return amount; end return FormatIntegerWithDigitGrouping( amount, GetString( SI_DIGIT_GROUP_SEPARATOR ) ) end function LeoAltholicInventoryList:SetupEntry(control, data) control.data = data control.name = GetControl(control, "Name") control.name:SetText(data.name) local color = '|c21A121' if data.inventory.free <= 25 then color = '|c596cfd' end if data.inventory.free <= 10 then color = '|cCB110E' end control.bag = GetControl(control, "Bag") control.bag:SetText(color .. data.inventory.used .. "|r / " .. data.inventory.size) control.soulgems = GetControl(control, "SoulGems") control.soulgems:SetText("|c21A121" .. data.inventory.soulGemFilled .. '|r / ' .. data.inventory.soulGemEmpty) control.gold = GetControl(control, "Gold") control.gold:SetText(formatNumber(data.inventory.gold)) control.ap = GetControl(control, "AP") control.ap:SetText(formatNumber(data.inventory.ap)) control.telvar = GetControl(control, "TelVar") control.telvar:SetText(formatNumber(data.inventory.telvar)) control.writVouchers = GetControl(control, "Writ") control.writVouchers:SetText(formatNumber(data.inventory.writVoucher)) control.listButton = GetControl(control, "ListButton") control.listButton:SetHandler('OnClicked', function() LeoAltholic.ShowInventoryUI(data.name, BAG_BACKPACK) end) ZO_SortFilterList.SetupRow(self, control, data) end function LeoAltholicStatsList:ColorRow(control, data, mouseIsOver) local color = ZO_SECOND_CONTRAST_TEXT local r, g, b = GetInterfaceColor(INTERFACE_COLOR_TYPE_ITEM_QUALITY_COLORS, ITEM_QUALITY_MAGIC) for i = 1, control:GetNumChildren() do local child = control:GetChild(i) if data.name == LeoAltholic.CharName then child:SetColor(r, g, b) else child:SetColor(color:UnpackRGBA()) end end end function LeoAltholicInventoryList:ColorRow(control, data, mouseIsOver) local color = ZO_SECOND_CONTRAST_TEXT local r, g, b = GetInterfaceColor(INTERFACE_COLOR_TYPE_ITEM_QUALITY_COLORS, ITEM_QUALITY_MAGIC) for i = 1, control:GetNumChildren() do local child = control:GetChild(i) if child:GetType() == CT_LABEL and string.find(child:GetName(), 'Name$') then if data.name == LeoAltholic.CharName then child:SetColor(r, g, b) else child:SetColor(color:UnpackRGBA()) end end if not child.nonRecolorable and child.number ~= nil then if child.number == child.max then child:SetColor(0, 1, 0, 1) elseif child.number > child.max * 0.8 then child:SetColor(1, 1, 0, 1) elseif child.number > child.max * 0.1 then child:SetColor(color:UnpackRGBA()) else child:SetColor(1, 0, 0, 1) end end end end function LeoAltholicInventoryList:BuildMasterList() self.masterList = {} local list = LeoAltholic.ExportCharacters(true) for k, v in ipairs(list) do local data = { name = v.bio.name, inventory = v.inventory } data.queueIndex = k table.insert(self.masterList, data) end end function LeoAltholicInventoryList:SortScrollList() local scrollData = ZO_ScrollList_GetDataList(self.list) table.sort(scrollData, self.sortFunction) end function LeoAltholicInventoryList:FilterScrollList() local scrollData = ZO_ScrollList_GetDataList(self.list) ZO_ClearNumericallyIndexedTable(scrollData) for i = 1, #self.masterList do local data = self.masterList[i] table.insert(scrollData, ZO_ScrollList_CreateDataEntry(1, data)) end end