Add realm bank support (#5)
* Update db.lua Add support for realm bank. Treat realm as a separate character * Update localization.lua * Update tooltips.lua
This commit is contained in:
+49
-2
@@ -13,6 +13,7 @@ end)
|
||||
BagnonDB:RegisterEvent('ADDON_LOADED')
|
||||
|
||||
ASC_PERSONAL_BANK_OFFSET = 1000;
|
||||
ASC_REALM_BANK_OFFSET = 2000;
|
||||
|
||||
--constants
|
||||
local L = BAGNON_FOREVER_LOCALS
|
||||
@@ -115,6 +116,12 @@ function BagnonDB:LoadSettings()
|
||||
self.rdb[currentPlayer] = {}
|
||||
end
|
||||
self.pdb = self.rdb[currentPlayer]
|
||||
|
||||
|
||||
if not self.rdb[currentRealm] then
|
||||
self.rdb[currentRealm] = {}
|
||||
end
|
||||
self.realmdb = self.rdb[currentRealm]
|
||||
end
|
||||
|
||||
function BagnonDB:UpdateSettings()
|
||||
@@ -201,6 +208,16 @@ function BagnonDB:GUILDBANKFRAME_OPENED()
|
||||
self:UpdateBag(i + ASC_PERSONAL_BANK_OFFSET)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if (self.IsRealmBank) then
|
||||
for i = 1, 6 do
|
||||
local avail = GetGuildBankTabInfo(i)
|
||||
if type(avail) == "string" then
|
||||
self:UpdateBag(i + ASC_REALM_BANK_OFFSET)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -217,6 +234,16 @@ function BagnonDB:GUILDBANKBAGSLOTS_CHANGED()
|
||||
self:UpdateBag(i + ASC_PERSONAL_BANK_OFFSET)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if (self.IsRealmBank) then
|
||||
for i = 1, 6 do
|
||||
local avail = GetGuildBankTabInfo(i)
|
||||
if type(avail) == "string" then
|
||||
self:UpdateBag(i + ASC_REALM_BANK_OFFSET)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -428,7 +455,23 @@ end
|
||||
function BagnonDB:SaveItem(bag, slot)
|
||||
|
||||
|
||||
if (bag > ASC_PERSONAL_BANK_OFFSET) then
|
||||
if (bag > ASC_REALM_BANK_OFFSET) then
|
||||
local texture, count = GetGuildBankItemInfo(bag - ASC_REALM_BANK_OFFSET, slot)
|
||||
|
||||
local index = ToIndex(bag, slot)
|
||||
|
||||
if texture then
|
||||
local link = ToShortLink(GetGuildBankItemLink(bag - ASC_REALM_BANK_OFFSET, slot))
|
||||
count = count > 1 and count or nil
|
||||
if(link and count) then
|
||||
self.realmdb[index] = format('%s,%d', link, count)
|
||||
else
|
||||
self.realmdb[index] = link
|
||||
end
|
||||
else
|
||||
self.realmdb[index] = nil
|
||||
end
|
||||
elseif (bag > ASC_PERSONAL_BANK_OFFSET) then
|
||||
local texture, count = GetGuildBankItemInfo(bag - ASC_PERSONAL_BANK_OFFSET, slot)
|
||||
|
||||
local index = ToIndex(bag, slot)
|
||||
@@ -469,7 +512,11 @@ end
|
||||
function BagnonDB:SaveBag(bag)
|
||||
local data = self.pdb
|
||||
|
||||
if (bag >= ASC_PERSONAL_BANK_OFFSET) then
|
||||
if (bag >= ASC_REALM_BANK_OFFSET) then
|
||||
local size = GetBagSize(bag)
|
||||
local index = ToBagIndex(bag)
|
||||
self.realmdb[index] = size
|
||||
elseif (bag >= ASC_PERSONAL_BANK_OFFSET) then
|
||||
local size = GetBagSize(bag)
|
||||
local index = ToBagIndex(bag)
|
||||
self.pdb[index] = size
|
||||
|
||||
@@ -7,3 +7,4 @@ BAGNON_NUM_BAGS = 'Bags: %d'
|
||||
BAGNON_NUM_BANK = 'Bank: %d'
|
||||
BAGNON_EQUIPPED = 'Equipped'
|
||||
BAGNON_NUM_PBANK = 'PBank: %d'
|
||||
BAGNON_NUM_RBANK = 'RBank: %d'
|
||||
|
||||
@@ -8,7 +8,7 @@ local itemInfo = {}
|
||||
local SILVER = '|cffc7c7cf%s|r'
|
||||
local TEAL = '|cff00ff9a%s|r'
|
||||
|
||||
local function CountsToInfoString(invCount, bankCount, equipCount, pbankCount)
|
||||
local function CountsToInfoString(invCount, bankCount, equipCount, pbankCount, rbankCount)
|
||||
local info
|
||||
local total = invCount + bankCount + equipCount + pbankCount
|
||||
|
||||
@@ -34,6 +34,15 @@ local function CountsToInfoString(invCount, bankCount, equipCount, pbankCount)
|
||||
end
|
||||
end
|
||||
|
||||
if rbankCount > 0 then
|
||||
local count = BAGNON_NUM_RBANK:format(rbankCount)
|
||||
if info then
|
||||
info = strjoin(', ', info, count)
|
||||
else
|
||||
info = count
|
||||
end
|
||||
end
|
||||
|
||||
if equipCount > 0 then
|
||||
if info then
|
||||
info = strjoin(', ', info, BAGNON_EQUIPPED)
|
||||
@@ -52,11 +61,14 @@ local function CountsToInfoString(invCount, bankCount, equipCount, pbankCount)
|
||||
end
|
||||
end
|
||||
|
||||
local currentRealm = GetRealmName() --what currentRealm we're on
|
||||
|
||||
--make up the self populating table
|
||||
do
|
||||
for player in BagnonDB:GetPlayers() do
|
||||
if player ~= currentPlayer then
|
||||
if player ~= currentPlayer and player ~= currentRealm then
|
||||
itemInfo[player] = setmetatable({}, {__index = function(self, link)
|
||||
|
||||
local invCount = BagnonDB:GetItemCount(link, KEYRING_CONTAINER, player)
|
||||
for bag = 0, NUM_BAG_SLOTS do
|
||||
invCount = invCount + BagnonDB:GetItemCount(link, bag, player)
|
||||
@@ -72,9 +84,14 @@ do
|
||||
personalBankCount = personalBankCount + BagnonDB:GetItemCount(link, i + ASC_PERSONAL_BANK_OFFSET, player)
|
||||
end
|
||||
|
||||
local realmBankCount = 0
|
||||
for i = 1, 6 do
|
||||
realmBankCount = realmBankCount + BagnonDB:GetItemCount(link, i + ASC_REALM_BANK_OFFSET, player)
|
||||
end
|
||||
|
||||
local equipCount = BagnonDB:GetItemCount(link, 'e', player)
|
||||
|
||||
self[link] = CountsToInfoString(invCount or 0, bankCount or 0, equipCount or 0, personalBankCount or 0) or ''
|
||||
self[link] = CountsToInfoString(invCount or 0, bankCount or 0, equipCount or 0, personalBankCount or 0, realmBankCount or 0) or ''
|
||||
return self[link]
|
||||
end})
|
||||
end
|
||||
@@ -84,7 +101,16 @@ end
|
||||
local function AddOwners(frame, link)
|
||||
for player in BagnonDB:GetPlayers() do
|
||||
local infoString
|
||||
if player == currentPlayer then
|
||||
|
||||
|
||||
if player == currentRealm then
|
||||
local realmBankCount = 0
|
||||
for i = 1, 6 do
|
||||
realmBankCount = realmBankCount + BagnonDB:GetItemCount(link, i + ASC_REALM_BANK_OFFSET, player)
|
||||
end
|
||||
|
||||
infoString = CountsToInfoString(0,0,0,0, realmBankCount or 0)
|
||||
elseif player == currentPlayer then
|
||||
local invCount = BagnonDB:GetItemCount(link, KEYRING_CONTAINER, player)
|
||||
for bag = 0, NUM_BAG_SLOTS do
|
||||
invCount = invCount + BagnonDB:GetItemCount(link, bag, player)
|
||||
@@ -102,7 +128,7 @@ local function AddOwners(frame, link)
|
||||
|
||||
local equipCount = BagnonDB:GetItemCount(link, 'e', player)
|
||||
|
||||
infoString = CountsToInfoString(invCount or 0, bankCount or 0, equipCount or 0, personalBankCount or 0)
|
||||
infoString = CountsToInfoString(invCount or 0, bankCount or 0, equipCount or 0, personalBankCount or 0, 0)
|
||||
else
|
||||
infoString = itemInfo[player][link]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user