You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
2.6 KiB
101 lines
2.6 KiB
local addonName, addon = ...
|
|
local childName = addon['childName']
|
|
local child = addon[childName]
|
|
local events = child['events']
|
|
local L = LibStub("AceLocale-3.0"):GetLocale(childName, true)
|
|
local db
|
|
local NUM_BAG_SLOTS = NUM_BAG_SLOTS
|
|
local bagTypes = {
|
|
[0] = L['Unspecified'],
|
|
[1] = L['Quiver'],
|
|
[2] = L['Ammo Pouch'],
|
|
[4] = L['Soul Bag'],
|
|
[8] = L['Leatherworking Bag'],--4
|
|
[16] = L['Inscription Bag'],--5
|
|
[32] = L['Herb Bag'],--6
|
|
[64] = L['Enchanting Bag'],--7
|
|
[128] = L['Engineering Bag'],--8
|
|
[256] = L['Keyring'],--9?
|
|
[512] = L['Gem Bag'], --10
|
|
[1024] = L['Mining Bag'], --11
|
|
[2048] = L['Unknown'], --12
|
|
[4096] = L['Vanity Pets'], --13
|
|
[32768] = L['Fishing Supplies'], --16
|
|
[65536] = L['Cooking Supplies'], --17
|
|
[524288] = L['Toys'], --20
|
|
[1048576] = L['Archaeology'], --21
|
|
[2097152] = L['Alchemy'], --22
|
|
[4194304] = L['Blacksmithing'], --23
|
|
[8388608] = L['First Aid'], --24
|
|
[16777216] = L['Jewelcrafting'], --25
|
|
[33554432] = L['Skinning'], --26
|
|
[67108864] = L['Tailoring'], --27
|
|
}
|
|
child['L'] = L
|
|
child['bagStatus'] = {
|
|
['bagTypes'] = bagTypes,
|
|
['full'] = {},
|
|
['free'] = {}
|
|
}
|
|
local function OnDataUpdate()
|
|
local bagID = 0
|
|
local n,m = 0,0
|
|
local free = child['bagStatus']['free']
|
|
local full = child['bagStatus']['full']
|
|
wipe(free)
|
|
wipe(full)
|
|
while(bagID<=NUM_BAG_SLOTS) do
|
|
local b = C_Container.GetContainerNumSlots(bagID)
|
|
local c = C_Container.GetContainerNumFreeSlots(bagID)
|
|
local bagType = GetItemFamily(C_Container.GetBagName(bagID))
|
|
if(not bagType or bagType==0) then
|
|
bagType = 0
|
|
full[0] = full[0] or 0
|
|
free[0] = free[0] or 0
|
|
free[0] = free[0] + c
|
|
full[0] = full[0] + b
|
|
else
|
|
full[bagType] = full[bagType] or 0
|
|
free[bagType] = free[bagType] or 0
|
|
free[bagType] = free[bagType] + c
|
|
full[bagType] = full[bagType] + b
|
|
end
|
|
if(db['bagTypes'][bagTypes[bagType]]==true) then
|
|
n = n + c
|
|
m = m + b
|
|
end
|
|
bagID = bagID + 1
|
|
end
|
|
if(not db['showFree']) then
|
|
n = m - n
|
|
end
|
|
child:OnText(childName, format("%d/%d",n,m))
|
|
end
|
|
local function prepareDB()
|
|
db = addon['db']['profile'][childName]
|
|
db['bagTypes'] = db['bagTypes'] or {
|
|
[L['Unspecified']] = true
|
|
}
|
|
child['db'] = db
|
|
addon['callbacks']:Fire(format("Init%s", childName))
|
|
OnDataUpdate()
|
|
end
|
|
child['update'] = OnDataUpdate
|
|
child['specs'] = {
|
|
['name'] = childName,
|
|
['sv'] = true,
|
|
['cfg'] = true,
|
|
['cfgReset'] = prepareDB,
|
|
['ldb'] = child['ldb'],
|
|
['defaults'] = {
|
|
['profile'] = {
|
|
[childName] = {
|
|
['bagTypes'] = {
|
|
[L['Unspecified']] = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
events.BAG_UPDATE_DELAYED = OnDataUpdate
|
|
child:NewAddOn(...) |