Added personal and realm bank implementations (#27)
* added personal and realm bank implementations * fix gathering from personal and realm banks * faster gathering from personal and realm banks * Fix Profession Multiselect on Gathering window * cleaner GetAscensionBankType function * craft queue update
This commit is contained in:
@@ -5,3 +5,5 @@
|
||||
.lua/*
|
||||
.vscode
|
||||
.idea
|
||||
deploy.bat
|
||||
claude.md
|
||||
@@ -14,9 +14,19 @@ local AceGUI = LibStub("AceGUI-3.0") -- load the AceGUI libraries
|
||||
local lib = TSMAPI
|
||||
|
||||
local bankType
|
||||
local ascensionBankType
|
||||
local fullMoves, splitMoves, bagState = {}, {}, {}
|
||||
local callbackMsg = {}
|
||||
|
||||
local function GetAscensionBankType()
|
||||
if GuildBankFrame and GuildBankFrame.IsPersonalBank then
|
||||
return "personal"
|
||||
elseif GuildBankFrame and GuildBankFrame.IsRealmBank then
|
||||
return "realm"
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- this is a set of wrapper functions so that I can switch
|
||||
-- between guildbank and bank function easily (taken from warehousing)
|
||||
|
||||
@@ -42,6 +52,7 @@ function TSM:OnEnable()
|
||||
|
||||
TSM:RegisterEvent("GUILDBANKFRAME_OPENED", function(event)
|
||||
bankType = "guildbank"
|
||||
ascensionBankType = GetAscensionBankType() -- Ascension WoW: detect personal/realm bank
|
||||
end)
|
||||
|
||||
TSM:RegisterEvent("BANKFRAME_OPENED", function(event)
|
||||
@@ -50,6 +61,7 @@ function TSM:OnEnable()
|
||||
|
||||
TSM:RegisterEvent("GUILDBANKFRAME_CLOSED", function(event, addon)
|
||||
bankType = nil
|
||||
ascensionBankType = nil -- Ascension WoW: reset
|
||||
TSM:UnregisterEvent("GUILDBANKBAGSLOTS_CHANGED")
|
||||
end)
|
||||
|
||||
@@ -402,13 +414,23 @@ function TSM.generateMoves(includeSoulbound)
|
||||
|
||||
if next(fullMoves) ~= nil then
|
||||
if bankType == "guildbank" then
|
||||
TSMAPI:CreateTimeDelay("moveItem", 0.05, TSM.moveItem, 0.35)
|
||||
-- Ascension WoW: Personal/Realm banks don't need slow delays like real guild banks
|
||||
if ascensionBankType then
|
||||
TSMAPI:CreateTimeDelay("moveItem", 0.05, TSM.moveItem, 0.05)
|
||||
else
|
||||
TSMAPI:CreateTimeDelay("moveItem", 0.05, TSM.moveItem, 0.35)
|
||||
end
|
||||
else
|
||||
TSMAPI:CreateTimeDelay("moveItem", 0.05, TSM.moveItem, 0.05)
|
||||
end
|
||||
elseif next(splitMoves) ~= nil then
|
||||
if bankType == "guildbank" then
|
||||
TSMAPI:CreateTimeDelay("moveSplitItem", 0.05, TSM.moveSplitItem, 0.75)
|
||||
-- Ascension WoW: Personal/Realm banks don't need slow delays like real guild banks
|
||||
if ascensionBankType then
|
||||
TSMAPI:CreateTimeDelay("moveSplitItem", 0.05, TSM.moveSplitItem, 0.1)
|
||||
else
|
||||
TSMAPI:CreateTimeDelay("moveSplitItem", 0.05, TSM.moveSplitItem, 0.75)
|
||||
end
|
||||
else
|
||||
TSMAPI:CreateTimeDelay("moveSplitItem", 0.05, TSM.moveSplitItem, 0.4)
|
||||
end
|
||||
|
||||
@@ -21,6 +21,7 @@ L["<< Hide Queue"] = true
|
||||
L["<None>"] = true
|
||||
L["AH"] = true
|
||||
L["All"] = true
|
||||
L["Are you sure you want to clear the entire queue?"] = true
|
||||
L["Are you sure you want to reset all material prices to the default value?"] = true
|
||||
L["Ask Later"] = true
|
||||
L["Auction House"] = true
|
||||
@@ -168,6 +169,9 @@ L["Total"] = true
|
||||
L["Vendor"] = true
|
||||
L["Visit Bank"] = true
|
||||
L["Visit Guild Bank"] = true
|
||||
L["Visit Personal Bank"] = true
|
||||
L["Visit Realm Bank"] = true
|
||||
L["Realm Bank"] = true
|
||||
L["Visit Vendor"] = true
|
||||
L["Warning: The min restock quantity must be lower than the max restock quantity."] = true
|
||||
L["When you click on the \"Restock Queue\" button enough of each craft will be queued so that you have this maximum number on hand. For example, if you have 2 of item X on hand and you set this to 4, 2 more will be added to the craft queue."] = true
|
||||
|
||||
@@ -539,9 +539,13 @@ function GUI:CreateQueueFrame(parent)
|
||||
end
|
||||
|
||||
end
|
||||
-- Position tooltip next to the row, on left or right depending on screen position
|
||||
GameTooltip:SetOwner(self, "ANCHOR_NONE")
|
||||
-- GameTooltip:SetPoint("LEFT", self, "RIGHT")
|
||||
GameTooltip:SetPoint("LEFT", self, "LEFT")
|
||||
if self:GetRight() >= (GetScreenWidth() / 2) then
|
||||
GameTooltip:SetPoint("TOPRIGHT", self, "TOPLEFT", -5, 0)
|
||||
else
|
||||
GameTooltip:SetPoint("TOPLEFT", self, "TOPRIGHT", 5, 0)
|
||||
end
|
||||
GameTooltip:AddLine(TSM.db.realm.crafts[data.spellID].name .. " (x" .. data.numQueued .. ")")
|
||||
|
||||
local cost = TSM.Cost:GetCraftPrices(data.spellID)
|
||||
@@ -621,6 +625,8 @@ function GUI:CreateQueueFrame(parent)
|
||||
name = color .. inventory .. "/" .. need .. "|r " .. name
|
||||
GameTooltip:AddLine(name, 1, 1, 1)
|
||||
end
|
||||
GameTooltip:AddLine(" ")
|
||||
GameTooltip:AddLine("|cff00ff00Ctrl+Click|r to remove from queue", 0.7, 0.7, 0.7)
|
||||
GameTooltip:Show()
|
||||
end
|
||||
|
||||
@@ -644,6 +650,13 @@ function GUI:CreateQueueFrame(parent)
|
||||
TSM.db.realm.queueStatus.collapsed[data.profession] = not TSM.db.realm.queueStatus.collapsed[data.profession]
|
||||
end
|
||||
GUI:UpdateQueue()
|
||||
elseif data.spellID and IsControlKeyDown() then
|
||||
-- Ctrl+Left-Click: Remove item from queue
|
||||
local craft = TSM.db.realm.crafts[data.spellID]
|
||||
if craft then
|
||||
craft.queued = 0
|
||||
GUI:UpdateQueue()
|
||||
end
|
||||
elseif data.index then
|
||||
GUI:CastTradeSkill(data.index, min(data.canCraft, data.numQueued), data.velName)
|
||||
end
|
||||
@@ -739,20 +752,31 @@ function GUI:CreateQueueFrame(parent)
|
||||
btn:SetHeight(20)
|
||||
btn:SetText(L["Clear Queue"])
|
||||
btn:SetScript("OnClick", function()
|
||||
TSM.Queue:ClearQueue()
|
||||
GUI:UpdateQueue()
|
||||
if GUI.frame.gather:IsVisible() then
|
||||
GUI.frame.gather:Hide()
|
||||
end
|
||||
private.gather = {}
|
||||
GUI:UpdateGatherSelectionWindow()
|
||||
if GUI.gatheringFrame:IsShown() then
|
||||
GUI.gatheringFrame:Hide()
|
||||
TSM.db.realm.gathering.crafter = nil
|
||||
TSM.db.realm.gathering.neededMats = {}
|
||||
TSM.db.realm.gathering.gatheredMats = false
|
||||
TSM.db.realm.sourceStatus.collapsed = {}
|
||||
end
|
||||
StaticPopupDialogs["TSM_CRAFTING_CLEAR_QUEUE"] = StaticPopupDialogs["TSM_CRAFTING_CLEAR_QUEUE"] or {
|
||||
text = L["Are you sure you want to clear the entire queue?"],
|
||||
button1 = YES,
|
||||
button2 = CANCEL,
|
||||
timeout = 0,
|
||||
hideOnEscape = true,
|
||||
OnAccept = function()
|
||||
TSM.Queue:ClearQueue()
|
||||
GUI:UpdateQueue()
|
||||
if GUI.frame.gather:IsVisible() then
|
||||
GUI.frame.gather:Hide()
|
||||
end
|
||||
private.gather = {}
|
||||
GUI:UpdateGatherSelectionWindow()
|
||||
if GUI.gatheringFrame:IsShown() then
|
||||
GUI.gatheringFrame:Hide()
|
||||
TSM.db.realm.gathering.crafter = nil
|
||||
TSM.db.realm.gathering.neededMats = {}
|
||||
TSM.db.realm.gathering.gatheredMats = false
|
||||
TSM.db.realm.sourceStatus.collapsed = {}
|
||||
end
|
||||
end,
|
||||
preferredIndex = 3,
|
||||
}
|
||||
TSMAPI:ShowStaticPopupDialog("TSM_CRAFTING_CLEAR_QUEUE")
|
||||
end)
|
||||
frame.clearBtn = btn
|
||||
|
||||
@@ -2041,7 +2065,12 @@ function GUI:CreateGatheringSelectionFrame(parent)
|
||||
dropdown:SetMultiselect(true)
|
||||
dropdown:SetCallback("OnValueChanged", function(_, _, profession, value)
|
||||
private.gather.professions[profession] = value or nil
|
||||
GUI:UpdateGatherSelectionWindow()
|
||||
-- Only update the button state, don't rebuild the dropdown list
|
||||
if next(private.gather.professions) then
|
||||
frame.gatherButton:Enable()
|
||||
else
|
||||
frame.gatherButton:Disable()
|
||||
end
|
||||
end)
|
||||
frame.professionDropdown = dropdown
|
||||
|
||||
@@ -2622,8 +2651,19 @@ function GUI:GatheringEventHandler(event)
|
||||
if not GUI.gatheringFrame or not GUI.gatheringFrame:IsShown() then return end
|
||||
|
||||
if event == "GUILDBANKFRAME_OPENED" then
|
||||
private.currentSource = UnitName("player")
|
||||
private.currentTask = L["Visit Guild Bank"]
|
||||
-- Ascension WoW: Detect bank type based on first tab name
|
||||
local numTabs = GetNumGuildBankTabs()
|
||||
local firstTabName = numTabs > 0 and GetGuildBankTabInfo(1) or nil
|
||||
if firstTabName == "Personal Bank" then
|
||||
private.currentSource = UnitName("player")
|
||||
private.currentTask = L["Visit Personal Bank"]
|
||||
elseif firstTabName == "Realm Bank" then
|
||||
private.currentSource = L["Realm Bank"]
|
||||
private.currentTask = L["Visit Realm Bank"]
|
||||
else
|
||||
private.currentSource = UnitName("player")
|
||||
private.currentTask = L["Visit Guild Bank"]
|
||||
end
|
||||
elseif event == "GUILDBANKFRAME_CLOSED" then
|
||||
private.currentSource = nil
|
||||
private.currentTask = nil
|
||||
|
||||
@@ -34,7 +34,7 @@ function Gather:gatherItems(source, task)
|
||||
|
||||
if source == L["Vendor"] then
|
||||
Gather:BuyFromMerchant(items)
|
||||
elseif source == UnitName("player") and (task == L["Visit Bank"] or task == L["Visit Guild Bank"]) then
|
||||
elseif (source == UnitName("player") or source == L["Realm Bank"]) and (task == L["Visit Bank"] or task == L["Visit Guild Bank"] or task == L["Visit Personal Bank"] or task == L["Visit Realm Bank"]) then
|
||||
Gather:GatherBank(items)
|
||||
elseif source == UnitName("player") and task == L["Mail Items"] then
|
||||
Gather:MailItems(items)
|
||||
|
||||
@@ -75,6 +75,24 @@
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Ascension WoW: add personal bank counts for all non-ignored characters
|
||||
for _, player in pairs(TSMAPI:ModuleAPI("ItemTracker", "playerlist") or {}) do
|
||||
if player == UnitName("player") or not TSM.db.global.ignoreCharacters[player] then
|
||||
local personalBank = TSMAPI:ModuleAPI("ItemTracker", "personalbank", player) or {}
|
||||
for itemString, quantity in pairs(personalBank) do
|
||||
otherTotal[itemString] = (otherTotal[itemString] or 0) + quantity
|
||||
total[itemString] = (total[itemString] or 0) + quantity
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Ascension WoW: add realm bank counts
|
||||
local realmBank = TSMAPI:ModuleAPI("ItemTracker", "realmbank") or {}
|
||||
for itemString, quantity in pairs(realmBank) do
|
||||
otherTotal[itemString] = (otherTotal[itemString] or 0) + quantity
|
||||
total[itemString] = (total[itemString] or 0) + quantity
|
||||
end
|
||||
|
||||
return bagTotal, auctionTotal, otherTotal, total
|
||||
end
|
||||
|
||||
@@ -104,6 +122,18 @@
|
||||
end
|
||||
end
|
||||
|
||||
-- Ascension WoW: add personal bank counts for all non-ignored characters
|
||||
for _, player in pairs(TSMAPI:ModuleAPI("ItemTracker", "playerlist") or {}) do
|
||||
if player == UnitName("player") or not TSM.db.global.ignoreCharacters[player] then
|
||||
local personalBank = TSMAPI:ModuleAPI("ItemTracker", "personalbank", player) or {}
|
||||
count = count + (personalBank[itemString] or 0)
|
||||
end
|
||||
end
|
||||
|
||||
-- Ascension WoW: add realm bank count
|
||||
local realmBank = TSMAPI:ModuleAPI("ItemTracker", "realmbank") or {}
|
||||
count = count + (realmBank[itemString] or 0)
|
||||
|
||||
if TSMAPI.SOULBOUND_MATS[itemString] then
|
||||
count = count + GetItemCount(itemString, true)
|
||||
end
|
||||
@@ -119,13 +149,15 @@
|
||||
local crafterBags = TSMAPI:ModuleAPI("ItemTracker", "playerbags", crafter) or {}
|
||||
local crafterMail = TSMAPI:ModuleAPI("ItemTracker", "playermail", crafter) or {}
|
||||
local crafterBank = TSMAPI:ModuleAPI("ItemTracker", "playerbank", crafter) or {}
|
||||
-- Ascension WoW: crafter's personal bank
|
||||
local crafterPersonalBank = TSMAPI:ModuleAPI("ItemTracker", "personalbank", crafter) or {}
|
||||
|
||||
-- add vendor items
|
||||
local task = {}
|
||||
local items = {}
|
||||
for itemString, quantity in pairs(neededMats) do
|
||||
if TSMAPI:GetVendorCost(itemString) then
|
||||
local vendorNeed = quantity - ((crafterBags[itemString] or 0) + (crafterMail[itemString] or 0) + (crafterBank[itemString] or 0))
|
||||
local vendorNeed = quantity - ((crafterBags[itemString] or 0) + (crafterMail[itemString] or 0) + (crafterBank[itemString] or 0) + (crafterPersonalBank[itemString] or 0))
|
||||
if vendorNeed > 0 then
|
||||
items[itemString] = vendorNeed
|
||||
end
|
||||
@@ -152,15 +184,20 @@
|
||||
if TSMAPI.SOULBOUND_MATS[itemString] then
|
||||
soulboundBagCount = GetItemCount(itemString)
|
||||
end
|
||||
local need = max(quantity - (crafterBags[itemString] or soulboundBagCount or 0), 0)
|
||||
local inBags = crafterBags[itemString] or soulboundBagCount or 0
|
||||
local need = max(quantity - inBags, 0)
|
||||
if need > 0 then
|
||||
shortItems[itemString] = need
|
||||
end
|
||||
end
|
||||
if not next(shortItems) then return end
|
||||
if not next(shortItems) then
|
||||
return sources -- Return sources instead of nil so vendor items are not lost
|
||||
end
|
||||
|
||||
-- add bags/bank/mail "tasks" for needed items of all non-ignored characters (always include crafter)
|
||||
for _, player in pairs(TSMAPI:ModuleAPI("ItemTracker", "playerlist") or {}) do
|
||||
local playerList = TSMAPI:ModuleAPI("ItemTracker", "playerlist") or {}
|
||||
|
||||
for _, player in pairs(playerList) do
|
||||
if player == crafter or not TSM.db.global.ignoreCharacters[player] then
|
||||
local task = {}
|
||||
local bags = TSMAPI:ModuleAPI("ItemTracker", "playerbags", player) or {}
|
||||
@@ -171,10 +208,13 @@
|
||||
gbank = TSMAPI:ModuleAPI("ItemTracker", "guildbank", guild) or {}
|
||||
end
|
||||
local mail = TSMAPI:ModuleAPI("ItemTracker", "playermail", player) or {}
|
||||
-- Ascension WoW: personal bank for this player
|
||||
local personalBank = TSMAPI:ModuleAPI("ItemTracker", "personalbank", player) or {}
|
||||
local bankItems = {}
|
||||
local gbankItems = {}
|
||||
local mailItems = {}
|
||||
local bagItems = {}
|
||||
local personalBankItems = {}
|
||||
|
||||
for itemString in pairs(neededMats) do
|
||||
local soulboundBagCount, soulboundBankCount
|
||||
@@ -192,6 +232,12 @@
|
||||
gbankItems[itemString] = gbank[itemString]
|
||||
end
|
||||
end
|
||||
-- Ascension WoW: check personal bank
|
||||
if personalBank[itemString] and shortItems[itemString] then
|
||||
if shortItems[itemString] - (crafterMail[itemString] or 0) - (player ~= crafter and bags[itemString] or 0) > 0 then
|
||||
personalBankItems[itemString] = personalBank[itemString]
|
||||
end
|
||||
end
|
||||
if mail[itemString] and shortItems[itemString] then
|
||||
mailItems[itemString] = mail[itemString]
|
||||
end
|
||||
@@ -216,6 +262,10 @@
|
||||
if next(gbankItems) then
|
||||
tinsert(task, { taskType = L["Visit Guild Bank"], items = gbankItems })
|
||||
end
|
||||
-- Ascension WoW: personal bank task
|
||||
if next(personalBankItems) then
|
||||
tinsert(task, { taskType = L["Visit Personal Bank"], items = personalBankItems })
|
||||
end
|
||||
if next(mailItems) then
|
||||
tinsert(task, { taskType = L["Collect Mail"], items = mailItems })
|
||||
end
|
||||
@@ -228,6 +278,22 @@
|
||||
end
|
||||
end
|
||||
|
||||
-- Ascension WoW: add realm bank as a separate source
|
||||
local realmBank = TSMAPI:ModuleAPI("ItemTracker", "realmbank") or {}
|
||||
local realmBankTask = {}
|
||||
local realmBankItems = {}
|
||||
for itemString in pairs(neededMats) do
|
||||
if realmBank[itemString] and shortItems[itemString] then
|
||||
if shortItems[itemString] - (crafterMail[itemString] or 0) > 0 then
|
||||
realmBankItems[itemString] = realmBank[itemString]
|
||||
end
|
||||
end
|
||||
end
|
||||
if next(realmBankItems) then
|
||||
tinsert(realmBankTask, { taskType = L["Visit Realm Bank"], items = realmBankItems })
|
||||
tinsert(sources, { sourceName = L["Realm Bank"], isCrafter = false, isVendor = false, isAH = false, tasks = realmBankTask, isCurrent = true })
|
||||
end
|
||||
|
||||
-- add auction house tasks
|
||||
local auctionTask = {}
|
||||
local auctionItems = {}
|
||||
@@ -318,16 +384,26 @@
|
||||
|
||||
|
||||
sort(sources, function(a, b)
|
||||
if a.isCurrent then return true end
|
||||
if b.isCurrent then return false end
|
||||
if a.isAH then return false end
|
||||
if b.isAH then return true end
|
||||
if a.isVendor then return false end
|
||||
if b.isVendor then return true end
|
||||
if a.isCrafter then return false end
|
||||
if b.isCrafter then return true end
|
||||
-- isCurrent sources come first
|
||||
if a.isCurrent ~= b.isCurrent then
|
||||
return a.isCurrent
|
||||
end
|
||||
-- AH sources come last
|
||||
if a.isAH ~= b.isAH then
|
||||
return b.isAH
|
||||
end
|
||||
-- Vendor sources come near last (before AH)
|
||||
if a.isVendor ~= b.isVendor then
|
||||
return b.isVendor
|
||||
end
|
||||
-- Crafter sources come after other players
|
||||
if a.isCrafter ~= b.isCrafter then
|
||||
return b.isCrafter
|
||||
end
|
||||
-- Alphabetical by name
|
||||
return a.sourceName < b.sourceName
|
||||
end)
|
||||
|
||||
return sources
|
||||
end
|
||||
|
||||
|
||||
@@ -14,9 +14,13 @@ local L = LibStub("AceLocale-3.0"):NewLocale("TradeSkillMaster_ItemTracker", "en
|
||||
if not L then return end
|
||||
|
||||
L["%s (%s bags, %s bank, %s AH, %s mail)"] = true
|
||||
L["%s (%s bags, %s bank, %s AH, %s mail, %s personal)"] = true
|
||||
L["%s in guild bank"] = true
|
||||
L["%s in realm bank"] = true
|
||||
L["%s item(s) total"] = true
|
||||
L["(%s player, %s alts, %s guild banks, %s AH)"] = true
|
||||
L["(%s player, %s alts, %s guild, %s AH, %s personal, %s realm)"] = true
|
||||
L["Realm Bank"] = true
|
||||
L["AH"] = true
|
||||
L["Bags"] = true
|
||||
L["Bank"] = true
|
||||
|
||||
@@ -78,12 +78,32 @@ function Data:ThrottleEvent(event)
|
||||
throttleFrames[event]:Show()
|
||||
end
|
||||
|
||||
local BANK_TYPE_PERSONAL = "personal"
|
||||
local BANK_TYPE_REALM = "realm"
|
||||
local BANK_TYPE_GUILD = "guild"
|
||||
|
||||
local function GetCurrentBankType()
|
||||
if GuildBankFrame and GuildBankFrame.IsPersonalBank then
|
||||
return BANK_TYPE_PERSONAL
|
||||
elseif GuildBankFrame and GuildBankFrame.IsRealmBank then
|
||||
return BANK_TYPE_REALM
|
||||
else
|
||||
return BANK_TYPE_GUILD
|
||||
end
|
||||
end
|
||||
|
||||
-- Store the current bank type when opened (persists until next open)
|
||||
local currentOpenBankType = nil
|
||||
|
||||
function Data:EventHandler(event, fire)
|
||||
if isScanning then return end
|
||||
if fire ~= "FIRE" then
|
||||
Data:ThrottleEvent(event)
|
||||
else
|
||||
if event == "GUILDBANKFRAME_OPENED" then
|
||||
-- Detect and store the bank type
|
||||
currentOpenBankType = GetCurrentBankType()
|
||||
|
||||
-- Query all tabs of the gbank to ensure all tabs will be scanned.
|
||||
local initialTab = GetCurrentGuildBankTab()
|
||||
for tab = 1, GetNumGuildBankTabs() do
|
||||
@@ -93,7 +113,14 @@ function Data:EventHandler(event, fire)
|
||||
end
|
||||
QueryGuildBankTab(initialTab)
|
||||
elseif event == "GUILDBANKBAGSLOTS_CHANGED" then
|
||||
Data:GetGuildBankData()
|
||||
-- Route to the appropriate handler based on bank type
|
||||
if currentOpenBankType == BANK_TYPE_PERSONAL then
|
||||
Data:GetPersonalBankData()
|
||||
elseif currentOpenBankType == BANK_TYPE_REALM then
|
||||
Data:GetRealmBankData()
|
||||
else
|
||||
Data:GetGuildBankData()
|
||||
end
|
||||
elseif event == "AUCTION_OWNED_LIST_UPDATE" then
|
||||
Data:ScanPlayerAuctions()
|
||||
end
|
||||
@@ -128,7 +155,32 @@ function Data:GetBankData(state)
|
||||
TSM.Sync:BroadcastUpdateRequest()
|
||||
end
|
||||
|
||||
-- scan the guild bank
|
||||
-- Helper function to scan all guild bank slots and return items table
|
||||
local function ScanGuildBankSlots()
|
||||
local items = {}
|
||||
local numTabs = GetNumGuildBankTabs()
|
||||
for tab = 1, numTabs do
|
||||
local name, icon, isViewable, canDeposit, numWithdrawals = GetGuildBankTabInfo(tab)
|
||||
-- Ascension WoW: For Personal/Realm banks, always scan (numWithdrawals check may not apply)
|
||||
local canAccess = (numWithdrawals and numWithdrawals > 0) or IsGuildLeader(UnitName("player")) or (name == "Personal Bank") or (name == "Realm Bank")
|
||||
if canAccess then
|
||||
for slot = 1, MAX_GUILDBANK_SLOTS_PER_TAB or 98 do
|
||||
local itemString = TSMAPI:GetItemString(GetGuildBankItemLink(tab, slot))
|
||||
local baseItemString = TSMAPI:GetBaseItemString(GetGuildBankItemLink(tab, slot))
|
||||
if itemString then
|
||||
local quantity = select(2, GetGuildBankItemInfo(tab, slot))
|
||||
items[itemString] = (items[itemString] or 0) + quantity
|
||||
if itemString ~= baseItemString then
|
||||
items[baseItemString] = (items[baseItemString] or 0) + quantity
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return items
|
||||
end
|
||||
|
||||
-- scan the guild bank (real guild bank only)
|
||||
function Data:GetGuildBankData()
|
||||
if not TSM.CURRENT_GUILD then
|
||||
Data:StoreCurrentGuildInfo(true)
|
||||
@@ -136,27 +188,53 @@ function Data:GetGuildBankData()
|
||||
end
|
||||
wipe(TSM.guilds[TSM.CURRENT_GUILD].items)
|
||||
|
||||
for tab = 1, GetNumGuildBankTabs() do
|
||||
if select(5, GetGuildBankTabInfo(tab)) > 0 or IsGuildLeader(UnitName("player")) then
|
||||
for slot = 1, MAX_GUILDBANK_SLOTS_PER_TAB or 98 do
|
||||
local itemString = TSMAPI:GetItemString(GetGuildBankItemLink(tab, slot))
|
||||
local baseItemString = TSMAPI:GetBaseItemString(GetGuildBankItemLink(tab, slot))
|
||||
if itemString then
|
||||
local quantity = select(2, GetGuildBankItemInfo(tab, slot))
|
||||
TSM.guilds[TSM.CURRENT_GUILD].items[itemString] = (TSM.guilds[TSM.CURRENT_GUILD].items[itemString] or 0) + quantity
|
||||
if itemString ~= baseItemString then
|
||||
TSM.guilds[TSM.CURRENT_GUILD].items[baseItemString] = (TSM.guilds[TSM.CURRENT_GUILD].items[baseItemString] or 0) + quantity
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local items = ScanGuildBankSlots()
|
||||
for itemString, quantity in pairs(items) do
|
||||
TSM.guilds[TSM.CURRENT_GUILD].items[itemString] = quantity
|
||||
end
|
||||
|
||||
if GuildBankFrame and GuildBankFrame:IsVisible() then
|
||||
TSM.guilds[TSM.CURRENT_GUILD].lastUpdate = time()
|
||||
end
|
||||
TSM.Sync:BroadcastUpdateRequest()
|
||||
end
|
||||
|
||||
-- Ascension WoW: scan the personal bank (per character)
|
||||
function Data:GetPersonalBankData()
|
||||
-- Initialize personal bank for current player if needed
|
||||
if not TSM.personalBanks[TSM.CURRENT_PLAYER] then
|
||||
TSM.personalBanks[TSM.CURRENT_PLAYER] = { items = {}, lastUpdate = 0 }
|
||||
end
|
||||
wipe(TSM.personalBanks[TSM.CURRENT_PLAYER].items)
|
||||
|
||||
local items = ScanGuildBankSlots()
|
||||
for itemString, quantity in pairs(items) do
|
||||
TSM.personalBanks[TSM.CURRENT_PLAYER].items[itemString] = quantity
|
||||
end
|
||||
|
||||
TSM.personalBanks[TSM.CURRENT_PLAYER].lastUpdate = time()
|
||||
TSM.Sync:BroadcastUpdateRequest()
|
||||
end
|
||||
|
||||
-- Ascension WoW: scan the realm bank (shared across realm)
|
||||
function Data:GetRealmBankData()
|
||||
-- Initialize realm bank if needed
|
||||
if not TSM.realmBank.items then
|
||||
TSM.realmBank.items = {}
|
||||
end
|
||||
wipe(TSM.realmBank.items)
|
||||
|
||||
local items = ScanGuildBankSlots()
|
||||
for itemString, quantity in pairs(items) do
|
||||
TSM.realmBank.items[itemString] = quantity
|
||||
end
|
||||
|
||||
if GuildBankFrame and GuildBankFrame:IsVisible() then
|
||||
TSM.realmBank.lastUpdate = time()
|
||||
end
|
||||
TSM.Sync:BroadcastUpdateRequest()
|
||||
end
|
||||
|
||||
function Data:ScanPlayerAuctions()
|
||||
wipe(TSM.characters[TSM.CURRENT_PLAYER].auctions)
|
||||
TSM.characters[TSM.CURRENT_PLAYER].auctions.time = time()
|
||||
|
||||
@@ -23,6 +23,10 @@ local savedDBDefaults = {
|
||||
characters = {},
|
||||
guilds = {},
|
||||
ignoreGuilds = {},
|
||||
-- Ascension WoW: Personal banks (per character, stored by character name)
|
||||
personalBanks = {},
|
||||
-- Ascension WoW: Realm bank (shared across all characters on realm)
|
||||
realmBank = { items = {}, lastUpdate = 0 },
|
||||
},
|
||||
|
||||
-- data that is stored per user profile
|
||||
@@ -47,6 +51,11 @@ local guildDefaults = {
|
||||
items = {},
|
||||
lastUpdate = 0,
|
||||
}
|
||||
-- Ascension WoW: Personal bank defaults (same structure as guild)
|
||||
local personalBankDefaults = {
|
||||
items = {},
|
||||
lastUpdate = 0,
|
||||
}
|
||||
|
||||
-- Called once the player has loaded into the game
|
||||
-- Anything that needs to be done in order to initialize the addon should go here
|
||||
@@ -61,6 +70,9 @@ function TSM:OnInitialize()
|
||||
|
||||
TSM.characters = TSM.db.realm.characters
|
||||
TSM.guilds = TSM.db.realm.guilds
|
||||
-- Ascension WoW: Personal banks and realm bank
|
||||
TSM.personalBanks = TSM.db.realm.personalBanks
|
||||
TSM.realmBank = TSM.db.realm.realmBank
|
||||
|
||||
-- handle connected realms for characters
|
||||
local connectedRealms = TSMAPI.GetConnectedRealms and TSMAPI:GetConnectedRealms() or {}
|
||||
@@ -117,6 +129,11 @@ function TSM:OnInitialize()
|
||||
for _, guildData in pairs(TSM.guilds) do
|
||||
ClearItemIDs(guildData.items)
|
||||
end
|
||||
-- Ascension WoW: Clean up personal banks and realm bank
|
||||
for _, personalBankData in pairs(TSM.personalBanks) do
|
||||
ClearItemIDs(personalBankData.items)
|
||||
end
|
||||
ClearItemIDs(TSM.realmBank.items)
|
||||
|
||||
TSM.Data:Initialize()
|
||||
TSM:UpdatePlayerLookup()
|
||||
@@ -151,6 +168,11 @@ function TSM:RegisterModule()
|
||||
{ key = "guildtotal", callback = "GetGuildTotal" },
|
||||
{ key = "playerguildtotal", callback = "GetPlayerGuildTotal" },
|
||||
{ key = "playerguild", callback = "GetPlayerGuild" },
|
||||
-- Ascension WoW: Personal banks and realm bank APIs
|
||||
{ key = "personalbank", callback = "GetPersonalBank" },
|
||||
{ key = "realmbank", callback = "GetRealmBank" },
|
||||
{ key = "personalbankstotal", callback = "GetPersonalBanksTotal" },
|
||||
{ key = "realmbanktotal", callback = "GetRealmBankTotal" },
|
||||
}
|
||||
--TSM.sync = { callback = "Sync:Callback" }
|
||||
TSM.tooltipOptions = { callback = "Config:LoadTooltipOptions" }
|
||||
@@ -169,9 +191,18 @@ function TSM:GetTooltip(itemString)
|
||||
local player, alts = TSM:GetPlayerTotal(itemString)
|
||||
local guild = TSM:GetGuildTotal(itemString)
|
||||
local auctions = TSM:GetAuctionsTotal(itemString)
|
||||
grandTotal = grandTotal + player + alts + guild + auctions
|
||||
-- Ascension WoW: Add personal banks and realm bank
|
||||
local personalBanks = TSM:GetPersonalBanksTotal(itemString)
|
||||
local realmBank = TSM:GetRealmBankTotal(itemString)
|
||||
grandTotal = grandTotal + player + alts + guild + auctions + personalBanks + realmBank
|
||||
if grandTotal > 0 then
|
||||
tinsert(text, { left = " " .. "ItemTracker:", right = format(L["(%s player, %s alts, %s guild banks, %s AH)"], "|cffffffff" .. player .. "|r", "|cffffffff" .. alts .. "|r", "|cffffffff" .. guild .. "|r", "|cffffffff" .. auctions .. "|r") })
|
||||
tinsert(text, { left = " " .. "ItemTracker:", right = format(L["(%s player, %s alts, %s guild, %s AH, %s personal, %s realm)"],
|
||||
"|cffffffff" .. player .. "|r",
|
||||
"|cffffffff" .. alts .. "|r",
|
||||
"|cffffffff" .. guild .. "|r",
|
||||
"|cffffffff" .. auctions .. "|r",
|
||||
"|cffffffff" .. personalBanks .. "|r",
|
||||
"|cffffffff" .. realmBank .. "|r") })
|
||||
end
|
||||
elseif TSM.db.global.tooltip == "full" then
|
||||
for name, data in pairs(TSM.characters) do
|
||||
@@ -179,17 +210,26 @@ function TSM:GetTooltip(itemString)
|
||||
local bank = data.bank[itemString] or 0
|
||||
local auctions = data.auctions[itemString] or 0
|
||||
local mail = data.mail[itemString] or 0
|
||||
local total = bags + bank + auctions + mail
|
||||
-- Ascension WoW: Add personal bank for this character
|
||||
local personalBank = TSM.personalBanks[name] and TSM.personalBanks[name].items[itemString] or 0
|
||||
local total = bags + bank + auctions + mail + personalBank
|
||||
grandTotal = grandTotal + total
|
||||
|
||||
local bagText = "|cffffffff" .. bags .. "|r"
|
||||
local bankText = "|cffffffff" .. bank .. "|r"
|
||||
local auctionText = "|cffffffff" .. auctions .. "|r"
|
||||
local mailText = "|cffffffff" .. mail .. "|r"
|
||||
local personalBankText = "|cffffffff" .. personalBank .. "|r"
|
||||
local totalText = "|cffffffff" .. total .. "|r"
|
||||
|
||||
if total > 0 then
|
||||
tinsert(text, { left = format(" %s:", name), right = format(L["%s (%s bags, %s bank, %s AH, %s mail)"], "|cffffffff" .. totalText, "|cffffffff" .. bagText, "|cffffffff" .. bankText, "|cffffffff" .. auctionText, "|cffffffff" .. mailText) })
|
||||
tinsert(text, { left = format(" %s:", name), right = format(L["%s (%s bags, %s bank, %s AH, %s mail, %s personal)"],
|
||||
"|cffffffff" .. totalText,
|
||||
"|cffffffff" .. bagText,
|
||||
"|cffffffff" .. bankText,
|
||||
"|cffffffff" .. auctionText,
|
||||
"|cffffffff" .. mailText,
|
||||
"|cffffffff" .. personalBankText) })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -205,6 +245,14 @@ function TSM:GetTooltip(itemString)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Ascension WoW: Show realm bank
|
||||
local realmBank = TSM:GetRealmBankTotal(itemString)
|
||||
if realmBank > 0 then
|
||||
grandTotal = grandTotal + realmBank
|
||||
local realmBankText = "|cffffffff" .. realmBank .. "|r"
|
||||
tinsert(text, { left = " " .. L["Realm Bank"] .. ":", right = format(L["%s in realm bank"], realmBankText) })
|
||||
end
|
||||
end
|
||||
|
||||
if #text > 0 then
|
||||
@@ -344,3 +392,30 @@ function TSM:GetPlayerGuild(player)
|
||||
if not player or not TSM.characters[player] then return end
|
||||
return TSM.characters[player].guild
|
||||
end
|
||||
|
||||
-- Ascension WoW: Get personal bank data for a player
|
||||
function TSM:GetPersonalBank(player)
|
||||
player = player or TSM.CURRENT_PLAYER
|
||||
player = TSM.playerLookup[player] or player
|
||||
if not player or not TSM.personalBanks[player] then return end
|
||||
return TSM.personalBanks[player].items
|
||||
end
|
||||
|
||||
-- Ascension WoW: Get realm bank data
|
||||
function TSM:GetRealmBank()
|
||||
return TSM.realmBank.items
|
||||
end
|
||||
|
||||
-- Ascension WoW: Get total items across all personal banks
|
||||
function TSM:GetPersonalBanksTotal(itemString)
|
||||
local total = 0
|
||||
for _, data in pairs(TSM.personalBanks) do
|
||||
total = total + (data.items[itemString] or 0)
|
||||
end
|
||||
return total
|
||||
end
|
||||
|
||||
-- Ascension WoW: Get realm bank total for an item
|
||||
function TSM:GetRealmBankTotal(itemString)
|
||||
return TSM.realmBank.items[itemString] or 0
|
||||
end
|
||||
Reference in New Issue
Block a user