Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function private:LoadInventoryViewer(container)
- local playerList, guildList = {}, {}
- for name in pairs(TSMAPI.Player:GetCharacters()) do
- playerList[name] = name
- private.inventoryFilters.characters[name] = true
- end
- for name in pairs(TSMAPI.Player:GetGuilds()) do
- guildList[name] = name
- private.inventoryFilters.guilds[name] = true
- end
- private.inventoryFilters.group = nil
- local stCols = {
- {
- name = L["Item Name"],
- width = 0.35,
- },
- {
- name = L["Bags"],
- width = 0.08,
- align = "CENTER",
- },
- {
- name = L["Bank"],
- width = 0.08,
- align = "CENTER",
- },
- {
- name = L["Mail"],
- width = 0.08,
- align = "CENTER",
- },
- {
- name = L["GVault"],
- width = 0.08,
- align = "CENTER",
- },
- {
- name = L["AH"],
- width = 0.08,
- align = "CENTER",
- },
- {
- name = L["Total"],
- width = 0.08,
- align = "CENTER",
- },
- {
- name = L["Total Value"],
- width = 0.17,
- align = "RIGHT",
- }
- }
- local stHandlers = {
- OnEnter = function(_, data, self)
- GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
- TSMAPI.Util:SafeTooltipLink(data.itemString)
- GameTooltip:Show()
- end,
- OnLeave = function()
- GameTooltip:ClearLines()
- GameTooltip:Hide()
- end
- }
- local totalValue = 0
- local playerData, guildData = TSM.Inventory:GetAllData()
- for _, data in pairs(playerData) do
- for itemString, quantity in pairs(data.bag) do
- totalValue = totalValue + (TSMAPI:GetCustomPriceValue(TSM.db.profile.inventoryViewerPriceSource, itemString) or 0) * quantity
- end
- for itemString, quantity in pairs(data.bank) do
- totalValue = totalValue + (TSMAPI:GetCustomPriceValue(TSM.db.profile.inventoryViewerPriceSource, itemString) or 0) * quantity
- end
- for itemString, quantity in pairs(data.reagentBank) do
- totalValue = totalValue + (TSMAPI:GetCustomPriceValue(TSM.db.profile.inventoryViewerPriceSource, itemString) or 0) * quantity
- end
- for itemString, quantity in pairs(data.auction) do
- totalValue = totalValue + (TSMAPI:GetCustomPriceValue(TSM.db.profile.inventoryViewerPriceSource, itemString) or 0) * quantity
- end
- for itemString, quantity in pairs(data.mail) do
- totalValue = totalValue + (TSMAPI:GetCustomPriceValue(TSM.db.profile.inventoryViewerPriceSource, itemString) or 0) * quantity
- end
- end
- for _, data in pairs(guildData) do
- for itemString, quantity in pairs(data) do
- totalValue = totalValue + (TSMAPI:GetCustomPriceValue(TSM.db.profile.inventoryViewerPriceSource, itemString) or 0) * quantity
- end
- end
- local page = {
- {
- type = "SimpleGroup",
- layout = "TSMFillList",
- children = {
- {
- type = "SimpleGroup",
- layout = "Flow",
- children = {
- {
- type = "EditBox",
- label = L["Item Search"],
- relativeWidth = 0.2,
- onTextChanged = true,
- callback = function(_, _, value)
- private.inventoryFilters.name = value:trim()
- private:UpdateInventoryViewerST()
- end,
- },
- {
- type = "GroupBox",
- label = L["Group"],
- relativeWidth = 0.2,
- callback = function(_, _, value)
- private.inventoryFilters.group = value
- private:UpdateInventoryViewerST()
- end,
- },
- {
- type = "Dropdown",
- label = L["Characters"],
- relativeWidth = 0.2,
- list = playerList,
- value = private.inventoryFilters.characters,
- multiselect = true,
- callback = function(_, _, key, value)
- private.inventoryFilters.characters[key] = value
- private:UpdateInventoryViewerST()
- end,
- },
- {
- type = "Dropdown",
- label = L["Guilds"],
- relativeWidth = 0.2,
- list = guildList,
- value = private.inventoryFilters.guilds,
- multiselect = true,
- callback = function(_, _, key, value)
- private.inventoryFilters.guilds[key] = value
- private:UpdateInventoryViewerST()
- end,
- },
- {
- type = "EditBox",
- label = L["Value Price Source"],
- relativeWidth = 0.2,
- acceptCustom = true,
- settingInfo = {TSM.db.profile, "inventoryViewerPriceSource"},
- callback = function() container:Reload() end,
- },
- {
- type = "HeadingLine",
- },
- {
- type = "Label",
- relativeWidth = 1,
- text = format(L["The total value of all your items is %s!"], TSMAPI:MoneyToString(totalValue)),
- },
- },
- },
- {
- type = "HeadingLine",
- },
- {
- type = "ScrollingTable",
- tag = "TSM_INVENTORY_VIEWER",
- colInfo = stCols,
- handlers = stHandlers,
- defaultSort = 1,
- selectionDisabled = true,
- },
- },
- },
- }
- TSMAPI.GUI:BuildOptions(container, page)
- private:UpdateInventoryViewerST()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement