/trunk
} |
local GuildBankIsOpen = false |
local failCount = 0 |
local lgbc |
local function gbagLoop(id) |
local res = {} |
local dName = modulname.."Count" |
end |
local function scanGuildBank(tab) |
local itemlist = {} |
local empty = true |
for slot = 1,14*7 do |
for slot = 1,98 do |
local texturePath, itemCount, locked, isFiltered = GetGuildBankItemInfo(tab,slot) |
if(itemCount>0) then |
emtpy = false |
local itemLink = GetGuildBankItemLink(tab,slot) |
if(itemLink) then |
local id = addon:getItemId(itemLink) |
if(id) then |
empty = false |
itemlist[id] = itemlist[id] or {} |
itemlist[id]['count'] = itemlist[id]['count'] or 0 |
itemlist[id]['count'] = itemlist[id]['count'] + itemCount |
return |
end |
failCount = 0 |
return empty and nil or itemlist |
return count==0 and nil or itemlist |
end |
function events:GUILDBANKBAGSLOTS_CHANGED(event,...) |
if(not addon.checkGID() or not GuildBankIsOpen) then return end |
events[event](self, event, ...) |
end |
end |
local function lgbc_scan(page) |
local guildID = addon.getGID() |
if(guildID and page) then |
local itemlist = {} |
for slot, link, stack in lgbc:IteratePage(page) do |
local id = addon:getItemId(link) |
if(id) then |
empty = false |
itemlist[id] = itemlist[id] or {} |
itemlist[id]['count'] = itemlist[id]['count'] or 0 |
itemlist[id]['count'] = itemlist[id]['count'] + stack |
addon:getName(id) |
end |
end |
modul['db'][guildID][page] = itemlist |
end |
end |
local function lgbc_scanAll() |
for page = 1, lgbc:GetNumBankTabs() do |
lgbc_scan(page) |
end |
end |
function modul:OnPageSync(event, sender, page, guildName) |
print(event, sender, page, guildName) |
local guildID = addon.getGID() |
lgbc_scan(page) |
end |
function modul:Delete(id, typ) |
self['db'] = addon:GetNamespace(modul.name) |
if(typ == self['typ'] and id and id>0) then |
for event,func in pairs(events) do |
list[#list+1] = event |
end |
lgbc = LibStub("LibGuildBankComm-1.0") |
if(lgbc) then |
print("reg cb") |
lgbc.RegisterCallback(self,"GuildBankComm_PageUpdate", "OnPageSync") |
end |
self.frame = addon:RegisterFunc(list,"OnEvent",OnEvent) |
end |
function modul:Disable() |
for event,func in pairs(events) do |
self.frame:UnregisterEvent(event) |
end |
if(lgbc) then |
lgbc.UnregisterCallback(self, "GuildBankComm_PageUpdate") |
end |
end |
addon['inits'][#addon['inits']+1] = function() |
modul.db,modul.status = addon:RegisterModul(modul, modulname) |