Revision 51

This commit is contained in:
Robin 2021-01-13 15:32:33 +01:00
commit fef448d5fd
14 changed files with 1518 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "Common"]
path = Common
url = https://git.grml.de/rilgamon/Common.git

1
Common Submodule

@ -0,0 +1 @@
Subproject commit 762c59c6c6abc6ecaa71f3e36bb2c6dd16b8e0ed

129
bags.lua Normal file
View File

@ -0,0 +1,129 @@
local name, addon = ...
local modulname = 'bags'
local events = {}
local modul = {
['name'] = modulname
}
function addon:scanBag(bag)
local slot = 1
local itemlist = {}
local empty = true
while(slot<=GetContainerNumSlots(bag)) do
local item = Item:CreateFromBagAndSlot(bag, slot)
if(item) then
local texture, itemCount, locked, quality, readable, lootable, itemLink, isFiltered = GetContainerItemInfo(bag, slot)
local itemLink = item:GetItemLink()
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
addon:getName(id)
end
end
end
slot = slot + 1
end
return empty and nil or itemlist
end
local function scanAllBags(delayed)
if(not addon:funcSync(scanAllBags,delayed)) then return end
local playerID = addon.getPID()
if(playerID) then
for bag=0,4 do
modul['db'][playerID][bag] = addon:scanBag(bag) -- loop all bought bags
end
for k,v in pairs(modul['db'][playerID]) do
if(k<0 or k>4) then
modul['db'][playerID][k] = nil -- prevent bogus bags
end
end
end
end
local function bagLoop(id,res)
local dName = modulname.."Count"
for k,v in pairs(modul['db']) do
local units = addon:getUnits()
if(units[k]) then
local playerID = addon.getPID()
if(playerID and units[k]['faction']==units[playerID]['faction']) then
local unitname = units[k]['name']
for bag,list in pairs(v) do
for a,b in pairs(list) do
if(a == id) then
res[unitname] = res[unitname] or {
[dName] = 0
}
res[unitname][dName] = res[unitname][dName] or 0
res[unitname][dName] = res[unitname][dName] + b['count']
end
end
end
end
end
end
return res
end
function modul.Search(id,res)
local playerID = addon.getPID()
if(playerID) then
modul['db'][playerID] = modul['db'][playerID] or {}
end
return playerID and bagLoop(id,res) or res
end
function modul.Output(input,sum,b)
local desc = modulname..'Count'
if(b[desc] and b[desc]>0) then
input[#input+1] = format("Bags %s",b[desc])
sum = sum + b[desc]
end
return input,sum
end
function events:BAG_UPDATE(event,bag)
local playerID = addon.getPID()
if(playerID) then
modul['db'][playerID][bag] = addon:scanBag(bag)
end
end
function events:ITEM_UNLOCKED(event,...)
scanAllBags(nil)
end
function events:BAG_UPDATE_DELAYED(event,...)
scanAllBags(nil)
end
local function OnEvent(self,event,...)
local playerID = addon.getPID()
if(playerID and type(events[event])=='function') then
modul['db'] = addon:GetNamespace(modul.name)
modul['db'][playerID] = modul['db'][playerID] or {}
events[event](self, event, ...)
end
end
function modul:Delete(id, typ)
self['db'] = addon:GetNamespace(modul.name)
if(typ == self['typ'] and id and id>0) then
self['db'][id] = nil
end
end
function modul:Enable()
self['status'] = true
local list = {}
for event,func in pairs(events) do
list[#list+1] = event
end
self['frame'] = addon:RegisterFunc(list,"OnEvent",OnEvent)
end
function modul:Disable()
self['status'] = false
for event,func in pairs(events) do
self['frame']:UnregisterEvent(event)
end
end
addon['inits'][#addon['inits']+1] = function()
modul['db'],modul['status'] = addon:RegisterModul(modul, modulname)
if(modul.status) then
modul:Enable()
end
end

197
bank.lua Normal file
View File

@ -0,0 +1,197 @@
local name, addon = ...
local modulname = 'bank'
local events = {}
local modul = {
['name'] = modulname
}
local BankIsOpen = false
function modul.Guess(id)
local dbcount = modul.Get(id)
local count = GetItemCount(id,true)
local playerID = addon.getPID()
local tt = false
if(playerID and dbcount > count) then
local dif = dbcount - count
modul['db'][playerID] = modul['db'][playerID] or {}
for bag=5,GetNumBankSlots()+4 do
if(modul['db'][playerID][bag] and modul['db'][playerID][bag][id] and modul['db'][playerID][bag][id]['count']>0) then
while(dif>0 and modul['db'][playerID][bag][id]['count']>0) do
tt = true
dif = dif - 1
modul['db'][playerID][bag][id]['count'] = modul['db'][playerID][bag][id]['count'] - 1
if(modul['db'][playerID][bag][id]['count'] == 0) then
modul['db'][playerID][bag][id] = nil
end
end
end
end
end
if(tt) then
addon:updateTT()
end
end
local function guess(bag)
if(bag) then
for id, v in pairs(bag) do
local _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, isCraftingReagent = GetItemInfo(id)
if(isCraftingReagent) then
modul.Guess(id)
end
end
end
end
local function scanAllBankBags(delayed)
if(not addon:funcSync(scanAllBankBags,delayed)) then return end
local playerID = addon.getPID()
if(playerID) then
modul['db'][playerID] = modul['db'][playerID] or {}
for bag=5,GetNumBankSlots()+4 do
if(BankIsOpen) then
modul['db'][playerID][bag] = addon:scanBag(bag) -- loop all bought bankbags
else
guess(modul['db'][playerID][bag])
end
end
if(BankIsOpen) then
modul['db'][playerID][-1] = addon:scanBag(-1) -- Main bankbag
else
guess(modul['db'][playerID][-1])
end
modul['db'][playerID][-3] = addon:scanBag(-3) -- Main reagentbag
for k,v in pairs(modul['db'][playerID]) do
if(not(k==-1) and not(k==-3) and not(k>4 and k<=GetNumBankSlots()+4)) then
modul['db'][playerID][k] = nil -- prevent bogus bankbags
end
end
addon:updateTT()
end
end
local function bagLoop(id,res)
local cName = modulname.."Count"
local dName = cName
for k,v in pairs(modul['db']) do
local units = addon:getUnits()
if(units[k]) then
local playerID = addon.getPID()
if(playerID and units[k]['faction']==units[playerID]['faction']) then
local unitname = units[k]['name']
for bag,list in pairs(v) do
if(bag == -3) then
dName = 'reagentCount'
else
dName = cName
end
for a,b in pairs(list) do
if(a == id) then
res[unitname] = res[unitname] or {
[dName] = 0
}
res[unitname][dName] = res[unitname][dName] or 0
res[unitname][dName] = res[unitname][dName] + b['count']
end
end
end
end
end
end
return res
end
function modul.Get(id)
local cName = modulname.."Count"
local dName = cName
local res = 0
local playerID = addon.getPID()
for k,v in pairs(modul['db']) do
if(playerID and k==playerID) then
for bag,list in pairs(v) do
for a,b in pairs(list) do
if(a == id) then
res = res + b['count']
end
end
end
end
end
return res
end
function modul.Search(id,res)
local playerID = addon.getPID()
if(playerID) then
modul['db'][playerID] = modul['db'][playerID] or {}
end
return playerID and bagLoop(id,res) or res
end
function modul.Output(input,sum,b)
local desc = modulname..'Count'
if(b[desc] and b[desc]>0) then
input[#input+1] = format("Bank %s",b[desc])
sum = sum + b[desc]
end
desc = 'reagentCount'
if(b[desc] and b[desc]>0) then
input[#input+1] = format("Reagents %s",b[desc])
sum = sum + b[desc]
end
return input,sum
end
function events:BANKFRAME_OPENED(event,...)
BankIsOpen = true
scanAllBankBags(nil)
end
function events:BANKFRAME_CLOSED(event,...)
BankIsOpen = false
end
function events:PLAYERBANKBAGSLOTS_CHANGED(event,...)
scanAllBankBags(nil)
end
function events:PLAYERBANKSLOTS_CHANGED(event,...)
scanAllBankBags(nil)
end
function events:PLAYERREAGENTBANKSLOTS_CHANGED(event,...)
scanAllBankBags(nil)
end
function events:ITEM_UNLOCKED(event,...)
scanAllBankBags(nil)
end
local function OnEvent(self,event,...)
local playerID = addon.getPID()
if(playerID and type(events[event])=='function') then
modul['db'] = addon:GetNamespace(modul.name)
modul['db'][playerID] = modul['db'][playerID] or {}
events[event](self, event, ...)
end
end
function modul:Delete(id, typ)
self['db'] = addon:GetNamespace(modul.name)
if(typ == self['typ'] and id and id>0) then
self['db'][id] = nil
end
end
local skipClassic = {
['PLAYERREAGENTBANKSLOTS_CHANGED'] = true
}
function modul:Enable()
self.status = true
local list = {}
for event,func in pairs(events) do
if(not addon:IsClassic() or (addon:IsClassic() and not skipClassic[event])) then
list[#list+1] = event
end
end
self.frame = addon:RegisterFunc(list,"OnEvent",OnEvent)
end
function modul:Disable()
self.status = false
for event,func in pairs(events) do
if(not addon:IsClassic() or (addon:IsClassic() and not skipClassic[event])) then
self.frame:UnregisterEvent(event)
end
end
end
addon['inits'][#addon['inits']+1] = function()
modul.db,modul.status = addon:RegisterModul(modul, modulname)
if(modul.status) then
modul:Enable()
end
end

105
char.lua Normal file
View File

@ -0,0 +1,105 @@
local name, addon = ...
local modulname = 'char'
local events = {}
local modul = {
['name'] = modulname
}
local function scanChar()
local itemlist = {}
local empty = true
for i=1,19 do
local id = GetInventoryItemID("player", i)
if(id) then
empty = false
itemlist[id] = itemlist[id] or {}
itemlist[id]['count'] = (itemlist[id]['count'] or 0) + 1
addon:getName(id)
end
end
return empty and nil or itemlist
end
local function bagLoop(id,res)
local dName = modulname.."Count"
for k,v in pairs(modul['db']) do
local units = addon:getUnits()
if(units[k]) then
local playerID = addon.getPID()
if(playerID and units[k]['faction']==units[playerID]['faction']) then
local unitname = units[k]['name']
for bag,list in pairs(v) do
for a,b in pairs(list) do
if(a == id) then
res[unitname] = res[unitname] or {
[dName] = 0
}
res[unitname][dName] = (res[unitname][dName] or 0) + b['count']
end
end
end
end
end
end
return res
end
function modul.Search(id,res)
local playerID = addon.getPID()
if(playerID) then
modul['db'][playerID] = modul['db'][playerID] or {}
end
return playerID and bagLoop(id,res) or res
end
function modul.Output(input,sum,b)
local desc = modulname..'Count'
if(b[desc] and b[desc]>0) then
input[#input+1] = format("Equip %s",b[desc])
sum = sum + b[desc]
end
return input,sum
end
function events:UNIT_INVENTORY_CHANGED(event,...)
local playerID = addon.getPID()
if(playerID) then
modul['db'][playerID][0] = scanChar(nil)
end
end
function events:ITEM_UNLOCKED(event,...)
local playerID = addon.getPID()
if(playerID) then
modul['db'][playerID][0] = scanChar(nil)
end
end
local function OnEvent(self,event,...)
local playerID = addon.getPID()
if(playerID and type(events[event])=='function') then
modul['db'] = addon:GetNamespace(modul.name)
modul['db'][playerID] = modul['db'][playerID] or {}
events[event](self, event, ...)
end
end
function modul:Delete(id, typ)
self['db'] = addon:GetNamespace(modul.name)
if(typ == self['typ'] and id and id>0) then
self['db'][id] = nil
end
end
function modul:Enable()
self.status = true
local list = {}
for event,func in pairs(events) do
list[#list+1] = event
end
self.frame = addon:RegisterFunc(list,"OnEvent",OnEvent)
OnEvent(self.frame,"UNIT_INVENTORY_CHANGED")
end
function modul:Disable()
self.status = false
for event,func in pairs(events) do
self.frame:UnregisterEvent(event)
end
end
addon['inits'][#addon['inits']+1] = function()
modul.db,modul.status = addon:RegisterModul(modul, modulname)
if(modul.status) then
modul:Enable()
end
end

147
currency.lua Normal file
View File

@ -0,0 +1,147 @@
local name, addon = ...
local modulname = 'currency'
local events = {}
local modul = {
['name'] = modulname
}
local GetCurrencyListLink = GetCurrencyListLink
local GetCurrencyListSize = GetCurrencyListSize
local GetCurrencyListInfo = GetCurrencyListInfo
if(C_CurrencyInfo) then
if(C_CurrencyInfo.GetCurrencyListLink) then
GetCurrencyListLink = C_CurrencyInfo.GetCurrencyListLink
end
if(C_CurrencyInfo.GetCurrencyListSize) then
GetCurrencyListSize = C_CurrencyInfo.GetCurrencyListSize
end
if(C_CurrencyInfo.GetCurrencyListInfo) then
GetCurrencyListInfo = C_CurrencyInfo.GetCurrencyListInfo
end
end
local function getCurrencyItem(index)
local currencyLink = GetCurrencyListLink(index)
if(currencyLink) then
return tonumber(currencyLink:match("currency:(%d+)")) or nil
end
end
local function curLoop(res,id)
local unitname = nil
for k,v in pairs(modul['db']) do
local units = addon:getUnits()
if(units and units[k]) then
unitname = units[k]['name']
for a,b in pairs(v) do
if(a == id and b['count']>0) then
if(b['max']>0) then
res[unitname] = addon:colorize(format("%s/%s",b['count'],b['max']),b['count']==b['max'] and "ff0000" or "ffffff")
else
res[unitname] = addon:colorize(format("%s",b['count']),"ffffff")
end
end
end
end
end
return res
end
addon['curLoop'] = curLoop
local function SetCurrencyByID(tooltip,itemID)
if(itemID) then
local res = curLoop({},itemID)
if(type(res) == 'table') then
tooltip:AddLine(" ")
for curName, b in pairs(res) do
if(addon:GetPref(modul.name .. "Tooltip")) then
tooltip:AddLine(format("%s %s: %s",addon:getIcon(itemID),curName,b))
end
end
end
tooltip:Show()
end
return tooltip,itemID
end
local function SetCurrencyToken(tooltip,index)
SetCurrencyByID(tooltip,getCurrencyItem(index))
end
local function GameTooltip_SetHyperlink(tooltip, link)
SetCurrencyByID(tooltip,tonumber(link:match("currency:(%d+)")))
end
function events:CURRENCY_DISPLAY_UPDATE(event)
local playerID = addon.getPID()
if(playerID) then
modul['db'][playerID] = modul['db'][playerID] or {}
for index=1,GetCurrencyListSize() do
local curInfo
if(C_CurrencyInfo and C_CurrencyInfo.GetCurrencyListInfo) then
curInfo = GetCurrencyListInfo(index)
else
local curName, isHeader, isExpanded, isUnused, isWatched, count, icon, maximum, hasWeeklyLimit, currentWeeklyAmount = GetCurrencyListInfo(index)
curInfo = {
['isHeader'] = isHeader,
['quantity'] = count,
['iconFileID'] = icon,
['maxQuantity'] = maximum
}
end
local itemID = getCurrencyItem(index)
if((not curInfo['isHeader']) and itemID) then
modul['db'][playerID][tonumber(itemID)] = {
['count'] = curInfo['quantity'],
['max'] = curInfo['maxQuantity'],
}
addon:setIcon(itemID, curInfo['iconFileID'])
end
end
end
end
local function OnEvent(self,event,...)
local playerID = addon.getPID()
if(playerID and type(events[event])=='function') then
modul['db'] = addon:GetNamespace(modul.name)
modul['db'][playerID] = modul['db'][playerID] or {}
events[event](self, event, ...)
end
end
function modul:Delete(id, typ)
self['db'] = addon:GetNamespace(modul.name)
if(typ == self['typ'] and id and id>0) then
self['db'][id] = nil
end
end
local skipClassic = {
['CURRENCY_DISPLAY_UPDATE'] = true
}
function modul:Enable()
if(not addon:IsClassic()) then
self.status = true
local list = {}
for event,func in pairs(events) do
if(not addon:IsClassic() or (addon:IsClassic() and not skipClassic[event])) then
list[#list+1] = event
end
end
self.frame = addon:RegisterFunc(list,"OnEvent",OnEvent)
OnEvent(self.frame, "CURRENCY_DISPLAY_UPDATE")
hooksecurefunc(GameTooltip, "SetCurrencyByID", SetCurrencyByID)
hooksecurefunc(GameTooltip, "SetCurrencyToken", SetCurrencyToken)
hooksecurefunc(GameTooltip,"SetHyperlink", GameTooltip_SetHyperlink)
else
self.status = false
end
end
function modul:Disable()
self.status = false
for event,func in pairs(events) do
if(not addon:IsClassic() or (addon:IsClassic() and not skipClassic[event])) then
self.frame:UnregisterEvent(event)
end
end
end
addon['inits'][#addon['inits']+1] = function()
modul.db,modul.status = addon:RegisterModul(modul, modulname)
if(modul.status) then
modul:Enable()
end
end

172
guildbank.lua Normal file
View File

@ -0,0 +1,172 @@
local name, addon = ...
local modulname = 'guildbank'
local events = {}
local modul = {
['name'] = modulname,
['typ'] = 'guild'
}
local GuildBankIsOpen = false
local failCount = 0
local lgbc
local function gbagLoop(id)
local res = {}
local dName = modulname.."Count"
for k,v in pairs(modul['db']) do
local guilds = addon:getGuilds()
if(guilds[k]) then
local guildID = addon.getGID()
if(guildID and guilds[k]['faction']==guilds[guildID]['faction'] or not guildID) then
local guildname = guilds[k]['name']
for bag,list in pairs(v) do
for a,b in pairs(list) do
if(a == id) then
res[guildname] = res[guildname] or {
[dName] = 0
}
res[guildname][dName] = res[guildname][dName] or 0
res[guildname][dName] = res[guildname][dName] + b['count']
end
end
end
end
end
end
return res
end
function modul.Search2(id,res,mode)
local guildID = addon.getGID()
if(guildID) then
modul['db'][guildID] = modul['db'][guildID] or {}
end
res = res or {}
for guildname, b in pairs(gbagLoop(id)) do
if(mode) then
res[#res+1] = format(" %s: %s",addon:colorize(guildname,"00ffff"),addon:colorize(b[modulname..'Count'],"ffffff"))
else
res[#res+1] = format("%s %s: %s",addon:getIcon(id),guildname,addon:colorize(b[modulname..'Count'],"ffffff"))
end
end
return res
end
local function scanGuildBank(tab)
if(not tab) then return end
local itemlist = {}
for slot = 1,98 do
local texturePath, itemCount, locked, isFiltered = GetGuildBankItemInfo(tab,slot)
if(itemCount>0) then
local itemLink = GetGuildBankItemLink(tab,slot)
if(itemLink) then
local id = addon:getItemId(itemLink)
if(id) then
itemlist[id] = itemlist[id] or {}
itemlist[id]['count'] = itemlist[id]['count'] or 0
itemlist[id]['count'] = itemlist[id]['count'] + itemCount
addon:getName(id)
end
end
end
end
local count = 0
for k,v in pairs(itemlist) do
count = count + 1
end
if(count==0 and failCount<3) then
C_Timer.After(.2, function(tab) scanGuildBank(tab) end)
failCount = failCount + 1
return
end
failCount = 0
return count==0 and nil or itemlist
end
function events:GUILDBANKBAGSLOTS_CHANGED(event,...)
if(not addon.checkGID() or not GuildBankIsOpen) then return end
local tab = GetCurrentGuildBankTab()
if(tab>0) then
local guildID = addon.getGID()
if(guildID) then
local list = scanGuildBank(tab)
if(list) then
modul['db'][guildID][tab] = list
end
end
end
end
function events:GUILDBANKFRAME_CLOSED(event,...)
GuildBankIsOpen = false
end
function events:GUILDBANKFRAME_OPENED(event,...)
GuildBankIsOpen = true
end
local function OnEvent(self,event,...)
local guildID = addon.getGID()
if(guildID and type(events[event])=='function') then
modul['db'] = addon:GetNamespace(modul.name)
modul['db'][guildID] = modul['db'][guildID] or {}
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
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
self['db'][id] = nil
end
end
function modul:Enable()
if(not addon:IsClassic()) then
self.status = true
local list = {}
for event,func in pairs(events) do
list[#list+1] = event
end
lgbc = LibStub("LibGuildBankComm-1.0",true)
if(lgbc) then
lgbc.RegisterCallback(self,"GuildBankComm_PageUpdate", "OnPageSync")
end
self.frame = addon:RegisterFunc(list,"OnEvent",OnEvent)
else
self.status = false
end
end
function modul:Disable()
self.status = false
if(not addon:IsClassic()) then
for event,func in pairs(events) do
self.frame:UnregisterEvent(event)
end
if(lgbc) then
lgbc.UnregisterCallback(self, "GuildBankComm_PageUpdate")
end
end
end
addon['inits'][#addon['inits']+1] = function()
modul.db,modul.status = addon:RegisterModul(modul, modulname)
if(modul.status) then
modul:Enable()
end
end

6
license.txt Normal file
View File

@ -0,0 +1,6 @@
The following license excludes the libraries (Libs) included. See the libraries directory or website.
This AddOn is public domain. That means you can change it, rename it or paint it yellow.
My name (Rilgamon) is valid only for WoWInterface.com and curse.com.
If you use/offer this addon on another website please remove my name.
If you want to give me credit you can replace it with a link to my profile on WoWInterface.com.

42
locale_deDE.lua Normal file
View File

@ -0,0 +1,42 @@
local name, addon = ...
local L = LibStub("AceLocale-3.0"):NewLocale(name, "deDE", false)
if L then
L[name] = name
L[name..' Settings'] = format("%s Einstellungen",name)
L['tooltip_main_string'] = "%s %s: %s [ %s ]"
L['tooltip_id_string'] = "Id: %i"
L['cmd_main_string'] = " %s: %s [ %s ]"
L['cmd_header_string'] = "%s %s"
L['pref_modul_toggle'] = function(namespace) return format("Ein/Aus %s",namespace) end
L['pref_tooltip_toggle'] = function(namespace) return format("Ein/Aus Tooltip %s",namespace) end
L['pref_modul_header'] = "Module ein-/ausschalten"
L['pref_modul_desc'] = "Abgeschaltete Module updaten die gespeicherten Daten nicht mehr!"
L['pref_tooltip_header'] = "Tooltip ein-/ausschalten"
L['pref_tooltip_desc'] = "Abgeschaltete Module werden nicht im Tooltip angezeigt!"
L['pref_itemid_header'] = "ItemID anzeigen"
L['pref_itemid_desc'] = "Zeige ItemID in Tooltips"
L['pref_maint_char_header'] = "Characterauswahl"
L['pref_maint_char_desc'] = "W\195\164hle einen Character aus"
L['pref_maint_char_del_header'] = "L\195\182schen"
L['pref_maint_char_del_desc'] = "L\195\182sche den ausgew\195\164hlten Character"
L['pref_maint_guild_header'] = "Gildenauswahl"
L['pref_maint_guild_desc'] = "W\195\164hle eine Gilde aus"
L['pref_maint_guild_del_header'] = "L\195\182schen"
L['pref_maint_guild_del_desc'] = "L\195\182sche die ausgew\195\164hlte Gilde"
L['pref_maint_names_del_header'] = "L\195\182sche Namensspeicher"
L['pref_maint_names_del_desc'] = "L\195\182sche die gespeicherten Itemnamen. Sie werden f\195\188r die Suche ben\195\182tigt."
L['pref_maint_icons_del_header'] = "L\195\182sche Iconspeicher"
L['pref_maint_icons_del_desc'] = "L\195\182sche die gespeicherten Icons. Sie werden f\195\188r die Suche/Tooltip ben\195\182tigt."
L['pref_donthookCraftFrame_header'] = "Deaktiviere Verzaubertooltip"
L['pref_donthookCraftFrame_desc'] = "Falls der Tooltip im Verzauberfenster Probleme macht bitte mit dieser Einstellung deaktivieren. Braucht einen UI Reload um wirksam zu werden."
L['pref_crafttip_header'] = "Einstellungen zum Enchanting Tooltip"
L['pref_crafttip_desc'] = "Ersetzt den Standardtooltip f\195\188r den Verzaubererberuf zz_itemsdb."
L['pref_crafttipscale_header'] = "Skalierung"
L['pref_crafttipscale_desc'] = "Setzt die Skalierung f\195\188r den Tooltip. Voreinstellung ist 0.9."
end
-- ö \195\182 ß \195\159
-- ü \195\188 ä \195\164
-- Ä \195\132
-- ö \195\182
-- Ü \195\156

36
locale_enUS.lua Normal file
View File

@ -0,0 +1,36 @@
local name, addon = ...
local L = LibStub("AceLocale-3.0"):NewLocale(name, "enUS", true)
if L then
L[name] = name
L[name..' Settings'] = format("%s Settings",name)
L['tooltip_main_string'] = "%s %s: %s [ %s ]"
L['tooltip_id_string'] = "Id: %i"
L['cmd_main_string'] = " %s: %s [ %s ]"
L['cmd_header_string'] = "%s %s"
L['pref_modul_toggle'] = function(namespace) return format("Enable/Disable %s",namespace) end
L['pref_tooltip_toggle'] = function(namespace) return format("Enable/Disable Tooltip %s",namespace) end
L['pref_modul_header'] = "Enable/Disable Moduls"
L['pref_modul_desc'] = "Disabled moduls will not update stored data anymore!"
L['pref_tooltip_header'] = "Enable/Disable Tooltip"
L['pref_tooltip_desc'] = "Disabled moduls are not added to tooltip!"
L['pref_itemid_header'] = "Show ItemID"
L['pref_itemid_desc'] = "Show ItemID in tooltips"
L['pref_maint_char_header'] = "Select character to modify"
L['pref_maint_char_desc'] = "Select character to modify"
L['pref_maint_char_del_header'] = "Delete"
L['pref_maint_char_del_desc'] = "Delete selected Char"
L['pref_maint_guild_header'] = "Select guild to modify"
L['pref_maint_guild_desc'] = "Select guild to modify"
L['pref_maint_guild_del_header'] = "Delete"
L['pref_maint_guild_del_desc'] = "Delete selected Guild"
L['pref_maint_names_del_header'] = "Clear Namecache"
L['pref_maint_names_del_desc'] = "Deletes cached itemnames. They are required for itemsearch."
L['pref_maint_icons_del_header'] = "Clear Iconcache"
L['pref_maint_icons_del_desc'] = "Deletes cached icons. They are used for itemsearch/tooltip."
L['pref_donthookCraftFrame_header'] = "Disable Enchanting Tooltip"
L['pref_donthookCraftFrame_desc'] = "When your crafting tooltip for enchanting profession causes trouble please disable the workaround with this setting.Needs a reload of the UI."
L['pref_crafttip_header'] = "Setting for Enchanting tooltip"
L['pref_crafttip_desc'] = "Replaces the standard tooltip so it works with zz_itemsdb."
L['pref_crafttipscale_header'] = "Scale"
L['pref_crafttipscale_desc'] = "Set the scale of the tooltip to your needs. Defaults to 0.9."
end

11
pack.xml Normal file
View File

@ -0,0 +1,11 @@
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<script file="locale_deDE.lua"/>
<script file="locale_enUS.lua"/>
<Script file="zz_itemsdb.lua"/>
<Script file="bags.lua"/>
<Script file="bank.lua"/>
<Script file="guildbank.lua"/>
<Script file="void.lua"/>
<Script file="char.lua"/>
<Script file="currency.lua"/>
</Ui>

135
void.lua Normal file
View File

@ -0,0 +1,135 @@
local name, addon = ...
local modulname = 'void'
local events = {}
local modul = {
['name'] = modulname
}
local voidOpen
local failCount = 0
local function scanVoid()
if(not voidOpen) then return end
local playerID = addon.getPID()
if(playerID) then
local itemlist = {}
local empty = true
for tab=1,2 do
for slot=1,80 do
local id, icon = GetVoidItemInfo(tab, slot)
if(id) then
id = tonumber(id)
empty = false
itemlist[id] = itemlist[id] or {}
itemlist[id]['count'] = (itemlist[id]['count'] or 0) + 1
addon:getName(id)
addon:setIcon(id, icon)
end
end
end
local count = 0
for k,v in pairs(itemlist) do
count = count + 1
end
if(count==0 and failCount<3) then
C_Timer.After(.2, scanVoid)
failCount = failCount + 1
return
end
failCount = 0
modul['db'][playerID][0] = itemlist
end
end
local function bagLoop(id,res)
local dName = modulname.."Count"
for k,v in pairs(modul['db']) do
local units = addon:getUnits()
if(units[k]) then
local playerID = addon.getPID()
if(playerID and units[k]['faction']==units[playerID]['faction']) then
local unitname = units[k]['name']
for bag,list in pairs(v) do
for a,b in pairs(list) do
if(a == id) then
res[unitname] = res[unitname] or {
[dName] = 0
}
res[unitname][dName] = (res[unitname][dName] or 0) + b['count']
end
end
end
end
end
end
return res
end
function modul.Search(id,res)
local playerID = addon.getPID()
if(playerID) then
modul['db'][playerID] = modul['db'][playerID] or {}
end
return playerID and bagLoop(id,res) or res
end
function modul.Output(input,sum,b)
local desc = modulname..'Count'
if(b[desc] and b[desc]>0) then
input[#input+1] = format("Void %s",b[desc])
sum = sum + b[desc]
end
return input,sum
end
function events:VOID_STORAGE_CLOSE(event,...)
voidOpen = false
end
function events:VOID_STORAGE_OPEN(event,...)
voidOpen = true
scanVoid()
end
function events:VOID_STORAGE_CONTENTS_UPDATE(event,...)
scanVoid()
end
function events:VOID_STORAGE_DEPOSIT_UPDATE(event,...)
scanVoid()
end
function events:ITEM_UNLOCKED(event,...)
scanVoid()
end
function events:VOID_TRANSFER_DONE(event,...)
scanVoid()
end
local function OnEvent(self,event,...)
local playerID = addon.getPID()
if(playerID and type(events[event])=='function') then
modul['db'] = addon:GetNamespace(modul.name)
modul['db'][playerID] = modul['db'][playerID] or {}
events[event](self, event, ...)
end
end
function modul:Delete(id, typ)
self['db'] = addon:GetNamespace(modul.name)
if(typ == self['typ'] and id and id>0) then
self['db'][id] = nil
end
end
function modul:Enable()
if(not addon:IsClassic()) then
self.status = true
local list = {}
for event,func in pairs(events) do
list[#list+1] = event
end
self.frame = addon:RegisterFunc(list,"OnEvent",OnEvent)
else
self.status = false
end
end
function modul:Disable()
self.status = false
for event,func in pairs(events) do
self.frame:UnregisterEvent(event)
end
end
addon['inits'][#addon['inits']+1] = function()
modul.db,modul.status = addon:RegisterModul(modul, modulname)
if(modul.status) then
modul:Enable()
end
end

525
zz_itemsdb.lua Normal file
View File

@ -0,0 +1,525 @@
local name, addon = ...
local playerID,guildID,db,options
local NUM_BAG_SLOTS = NUM_BAG_SLOTS
local GetContainerNumSlots = GetContainerNumSlots
local GetContainerItemLink = GetContainerItemLink
local GetContainerItemInfo = GetContainerItemInfo
local strsplit,format = strsplit,format
local sync = {}
local moduls = {}
local defaults = {
['bagsToggle'] = true,
['bankToggle'] = true,
['charToggle'] = true,
['bagsTooltip'] = true,
['bankTooltip'] = true,
['charTooltip'] = true,
['showID'] = true,
['icons'] = {},
['names'] = {},
['currencies'] = {},
['bags'] = {},
['bank'] = {},
['guildbank'] = {},
['units'] = {},
['guilds'] = {},
['CraftTipScale'] = 0.9
}
local L = LibStub("AceLocale-3.0"):GetLocale(name, true)
local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0")
local function OnClick(self, button)
if(IsShiftKeyDown() and button == "LeftButton") then
addon['db']['global']['ldbicons'][childName]['hide'] = not addon['db']['global']['ldbicons'][childName]['hide']
if(ldbicon) then
if(addon['db']['global']['ldbicons'][childName]['hide']) then
ldbicon:Hide(childName)
else
ldbicon:Show(childName)
end
end
else
if(InterfaceOptionsFrame:IsVisible() and not InCombatLockdown()) then
InterfaceOptionsFrame:Hide()
else
InterfaceOptionsFrame_OpenToCategory(name)
InterfaceOptionsFrame_OpenToCategory(name) -- Twice because of a bug in InterfaceOptionsFrame_OpenToCategory
end
end
end
function addon:getPID()
if(playerID) then
return playerID
end
local pname, pserver = UnitFullName("player")
if(not pserver) then
return
end
local player = format("%s - %s",pname,pserver)
playerID = 0
local units = addon:GetNamespace('units')
for k,v in pairs(units) do
if(v['name']==player) then
playerID = k
return playerID
end
if(k>=playerID) then
playerID = k
end
end
playerID = playerID + 1
units[playerID]= {
['name'] = player,
['faction'] = UnitFactionGroup('player')
}
return playerID
end
local function getChars()
local chars = {}
for k,v in pairs(db['units']) do
chars[k] = v['name']
end
return chars
end
local function deleteChar()
local cid = db['selectCID']
if(cid and cid>0) then
for k, modul in pairs(moduls) do
modul:Delete(cid)
end
db['units'][cid] = nil
if(cid == playerID) then
playerID = nil
end
end
end
local function getGuilds()
local guilds = {}
for k,v in pairs(db['guilds']) do
guilds[k] = v['name']
end
return guilds
end
local function deleteGuild()
local gid = db['selectGID']
if(gid and gid>0) then
for k, modul in pairs(moduls) do
modul:Delete(gid, 'guild')
end
db['guilds'][gid] = nil
if(gid == guildID) then
guildID = nil
end
end
end
function addon:getGID()
local pname, pserver = UnitFullName("player")
if(not pserver) then
return
end
local guildName, guildRankName, guildRankIndex, guildRealm = GetGuildInfo("player")
guildID = 0
if(not guildName) then return end
local guild = format("%s - %s",guildName,guildRealm and guildRealm or pserver)
local guilds = addon:GetNamespace('guilds')
for k,v in pairs(guilds) do
if(v['name']==guild) then
guildID = k
return guildID
end
if(k>=guildID) then
guildID = k
end
end
guildID = guildID + 1
guilds[guildID]= {
['name'] = guild,
['faction'] = UnitFactionGroup('player')
}
return guildID
end
function addon:checkGID()
if(not guildID) then
guildID = addon:getGID()
end
if(guildID and guildID>0) then
addon:GetNamespace('guildbank')
return true
end
end
function addon:getGuilds()
return db['guilds']
end
local function setName(id,itemname)
if(id and itemname) then
local names = addon:GetNamespace('names')
names[tonumber(id)] = itemname
end
end
local function getId(itemName)
for k,v in pairs(addon:GetNamespace('names')) do
if(v==itemName) then
return k
end
end
end
function addon:getName(id)
local names = addon:GetNamespace('names')
if(not names[tonumber(id)]) then
setName(id,C_Item.GetItemNameByID(id))
end
return db['names'][id]
end
local function deleteNames()
db['names'] = {}
end
function addon:setIcon(id,icon)
if(id and icon) then
local icons = addon:GetNamespace('icons')
icons[tonumber(id)] = "|T"..icon..":0|t"
end
end
function addon:getIcon(id)
id = tonumber(id)
if(id and not db['icons'][id]) then
local itemName = C_Item.GetItemNameByID(id)
local icon = C_Item.GetItemIconByID(id)
setName(id,itemName)
addon:setIcon(id,icon)
end
return db['icons'][id] or ''
end
local function deleteIcons()
db['icons'] = {}
end
function addon:getUnits()
return addon:GetNamespace('units')
end
local function search(id)
local res = {}
for k,modul in pairs(moduls) do
if(type(modul.Search)=='function') then
res = modul.Search(id,res)
end
end
return res
end
function addon:GetModul(modName)
for k,modul in pairs(moduls) do
if(modul.name==modName) then
return modul
end
end
end
local function output(b)
local input, sum = {}, 0
for k,modul in pairs(moduls) do
if(type(modul.Output)=='function') then
if(db[modul.name .. 'Tooltip']) then
input,sum = modul.Output(input,sum,b)
end
end
end
return input,sum
end
local function specialoutput(tooltip, id)
for k,modul in pairs(moduls) do
if(type(modul.Search2)=='function' and db[modul.name .. 'Tooltip']) then
local res = modul.Search2(id)
if(res) then
for k,v in pairs(res) do
tooltip:AddLine(v)
end
end
end
end
end
local function checkID(itemID)
if(C_TradeSkillUI and TradeSkillFrame ~= nil and TradeSkillFrame:IsVisible()) then
local tab = GetMouseFocus()
local par2 = tab:GetParent()
local par = par2:GetParent()
local tooltip = par2.tooltipFrame
for i = 1, C_TradeSkillUI.GetRecipeNumReagents(par.selectedRecipeID) do
if(tab.reagentIndex and i==tab.reagentIndex) then
local recipeItemLink = C_TradeSkillUI.GetRecipeReagentItemLink(par.selectedRecipeID, i)
itemID = addon:getItemId(recipeItemLink)
break
end
end
return tonumber(itemID),tooltip
end
end
local curHooks,curTT,curID = {}
local function hookIt(self)
self.zzTT = nil
end
function addon:setTT(id,tooltip)
if(not tooltip.zzTT and not curHooks[tooltip]) then
curHooks[tooltip] = true
tooltip:HookScript("OnHide", hookIt)
end
tooltip.zzTT = true
curTT = tooltip
curID = id
end
function addon:getTT()
return curID,curTT
end
local tmp = 0
local function GameTooltip_OnTooltipSetItem(tooltip)
local _, link = tooltip:GetItem()
if(not link) then
return
end
local id = addon:getItemId(link)
if(not id) then
local tip
id,tip = checkID(id)
if(id and tip) then
tooltip = tip
end
end
if(id)then
addon:setTT(id,tooltip)
tooltip:AddLine()
for name,b in pairs(search(id)) do
local dname, drealm = strsplit(" - ",name)
local input,sum = output(b)
if(sum>0) then
tooltip:AddLine(format(L['tooltip_main_string'],addon:getIcon(id),dname,sum,addon:colorize(table.concat(input,', '),"ffffff")))
end
input = nil
end
specialoutput(tooltip, id)
if(db['showID']) then
tooltip:AddLine(format(L['tooltip_id_string'],id))
end
end
tooltip:Show()
end
function addon:updateTT()
local id,tip = addon:getTT()
if(tip and tip.zzTT) then
if(id) then
tip:SetItemByID(id)
end
end
end
GameTooltip:HookScript("OnTooltipSetItem", GameTooltip_OnTooltipSetItem)
local craftTip = CreateFrame( "GameTooltip", name.."CraftReagentTip", nil, "GameTooltipTemplate")
local function CraftReagent_OnLeave(self,...)
craftTip:Hide()
end
local function CraftReagent_OnEnter(self,...)
if(self.hasItem==1) then
local itemName = self['Name']:GetText()
if(itemName) then
local id = getId(itemName)
craftTip:Hide()
craftTip:ClearLines()
craftTip:SetOwner(self, "ANCHOR_TOPLEFT")
if(id) then
craftTip:SetItemByID(id)
GameTooltip_OnTooltipSetItem(craftTip)
else
craftTip:SetCraftItem(GetCraftSelectionIndex(), self:GetID())
end
craftTip:Show()
CursorUpdate()
end
end
end
function addon:funcSync(func,delayed)
local st = GetTime()
if(delayed and sync[func]['times'][delayed]) then
sync[func]['times'][delayed] = nil
end
sync[func] = sync[func] or {
['last'] = 0,
['times'] = {}
}
if(not (st == sync[func]['last'])) then
sync[func]['last'] = st
return true
else
if(not sync[func]['times'][st]) then
sync[func]['times'][st] = true
C_Timer.After(.1, function() func(st) end)
end
return
end
end
local events = {}
local ignItems = {}
local hookedCraft = {}
function events:CRAFT_SHOW(...)
for i = 1, MAX_CRAFT_REAGENTS,1 do
if(not hookedCraft["CraftReagent"..i]) then
_G["CraftReagent"..i]:SetScript("OnEnter", CraftReagent_OnEnter)
_G["CraftReagent"..i]:SetScript("OnLeave", CraftReagent_OnLeave)
hookedCraft["CraftReagent"..i] = true
end
end
end
function events:GET_ITEM_INFO_RECEIVED(event, id)
if(id and id>0) then
if(ignItems[id]) then return end
local itemName = C_Item.GetItemNameByID(id)
if(itemName) then
setName(id,itemName)
else
ignItems[id] = true
end
end
end
events.ITEM_DATA_LOAD_RESULT = events.GET_ITEM_INFO_RECEIVED
function events:TRADE_SKILL_LIST_UPDATE(event)
addon:updateTT()
end
local function OnEvent(self, event, ...)
if(type(events[event])=='function') then
events[event](self,event,...)
end
end
local function specialoutput2(id,res)
for k,modul in pairs(moduls) do
if(type(modul.Search2)=='function') then
res = modul.Search2(id,res,true)
end
end
return res
end
SlashCmdList[string.upper(name)] = function(msg)
local um = string.upper(msg)
for id, itemname in pairs(db['names']) do
local un = string.upper(itemname)
if(string.find(un,um)) then
local item = Item:CreateFromItemID(id)
local itemlink = item:GetItemLink()
local dout = {}
if(id)then
for name,b in pairs(search(id)) do
local dname, drealm = strsplit(" - ",name)
local input,sum = output(b)
dout[#dout+1] = (format(L['cmd_main_string'],dname,sum,addon:colorize(table.concat(input,', '),"ffffff")))
input = nil
end
dout = specialoutput2(id,dout)
end
if(#dout>0) then
addon:Print(format(L['cmd_header_string'],addon:getIcon(id),itemlink and itemlink or itemname))
for k,v in pairs(dout) do
addon:Print(v)
end
end
end
end
end
_G["SLASH_"..string.upper(name).."1"] = "/find"
function addon:GetNamespace(namespace)
if(namespace) then
db[namespace] = db[namespace] or {}
return db[namespace]
end
end
local skipClassic = {
['void'] = true,
['guildbank'] = true,
['currency'] = true
}
function addon:RegisterModul(modul, namespace)
moduls[#moduls+1] = modul
if(not skipClassic[namespace] or not addon:IsClassic()) then
self:AddConfigEntry(name,"toggle",namespace.."Toggle",namespace,L['pref_modul_toggle'](namespace),1,nil,nil,nil,nil,self['options']['args'][name]['args']["ModulGroup"])
self:AddConfigEntry(name,"toggle",namespace.."Tooltip",namespace,L['pref_tooltip_toggle'](namespace),1,nil,nil,nil,nil,self['options']['args'][name]['args']["ModulTooltip"])
end
return self:GetNamespace(namespace), db[namespace.."Toggle"]
end
function addon:GetPref(prefName)
return db[prefName]
end
local function getPref(pref)
return db[pref[#pref]]
end
local function setPref(pref,value)
db[pref[#pref]] = value
if(pref[#pref] == 'CraftTipScale') then
craftTip:SetScale(value)
else
for k, modul in pairs(moduls) do
if(modul.name .. 'Toggle' == pref[#pref]) then
if(value) then
if(type(modul.Enable)=='function') then
modul:Enable()
end
else
if(type(modul.Disable)=='function') then
modul:Disable()
end
end
elseif(type(modul.setPref)=='function' and string.sub(pref[#pref],0,string.len(modul.name)) == modul.name) then
modul.setPref(pref[#pref], value)
end
end
end
end
local function init(self, ...)
options = addon:InitConfig(name, true, {
['type'] = "launcher",
['OnClick'] = OnClick,
['icon'] ="Interface\\Icons\\INV_Misc_Bag_10_Blue",
}, getPref, setPref)
db = addon['db']['profile'][name]
local list = {}
local skipRetail = {
['CRAFT_SHOW'] = true
}
for event,func in pairs(events) do
if((addon:IsClassic() and not db['donthookCraftFrame']) or (not addon:IsClassic() and not skipRetail[event])) then
list[#list+1] = event
end
end
addon:RegisterFunc(list,"OnEvent", OnEvent)
addon:AddConfigEntry(name,"group","ModulGroup",L['pref_modul_header'],L['pref_modul_desc'],1,true)
addon:AddConfigEntry(name,"group","ModulTooltip",L['pref_tooltip_header'],L['pref_tooltip_desc'],1,true)
addon:AddConfigEntry(name,"toggle","showID",L['pref_itemid_header'],L['pref_itemid_desc'],1)
if(addon:IsClassic()) then
if(not addon:GetPref("CraftTipScale")) then
setPref({"CraftTipScale"},0.9)
end
craftTip:SetScale(addon:GetPref("CraftTipScale"))
addon:AddConfigEntry(name,"group","CraftTip",L['pref_crafttip_header'],L['pref_crafttip_desc'],3,true)
addon:AddConfigEntry(name,"toggle","donthookCraftFrame",L['pref_donthookCraftFrame_header'],L['pref_donthookCraftFrame_desc'],1,nil,nil,nil,nil,options['args'][name]['args']["CraftTip"])
addon:AddConfigEntry(name, "range","CraftTipScale",L['pref_crafttipscale_header'],L['pref_crafttipscale_desc'],2,0.01,1,.01,false,options['args'][name]['args']["CraftTip"])
end
addon.dbmenu = addon:AddConfigMenu({
['name'] = 'Database',
['childGroups'] = 'tab',
['order'] = 20,
['menuGet'] = getPref,
['menuSet'] = setPref
})
addon.menuchar = addon:AddConfigMenu({
['name'] = 'Character',
['order'] = 10,
['menuGet'] = getPref,
['menuSet'] = setPref
},addon.dbmenu)
addon:AddConfigEntry(name,"select","selectCID",L['pref_maint_char_header'],L['pref_maint_char_desc'],1,getChars,nil,nil,nil,addon.menuchar)
addon:AddConfigEntry(name,"execute","deleteCID",L['pref_maint_char_del_header'],L['pref_maint_char_del_desc'],2,deleteChar,nil,nil,nil,addon.menuchar)
addon.menuguild = addon:AddConfigMenu({
['name'] = 'Guild',
['order'] = 20,
['menuGet'] = getPref,
['menuSet'] = setPref
},addon.dbmenu)
addon:AddConfigEntry(name,"select","selectGID",L['pref_maint_guild_header'],L['pref_maint_guild_desc'],1,getGuilds,nil,nil,nil,addon.menuguild)
addon:AddConfigEntry(name,"execute","deleteGID",L['pref_maint_guild_del_header'],L['pref_maint_guild_del_desc'],2,deleteGuild,nil,nil,nil,addon.menuguild)
addon:AddConfigEntry(name,"execute","deleteNames",L['pref_maint_names_del_header'],L['pref_maint_names_del_desc'],2,deleteNames,nil,nil,nil,addon.dbmenu)
addon:AddConfigEntry(name,"execute","deleteIcons",L['pref_maint_icons_del_header'],L['pref_maint_icons_del_desc'],2,deleteIcons,nil,nil,nil,addon.dbmenu)
end
addon:startup(name, name, init, true, defaults)

9
zz_itemsdb.toc Normal file
View File

@ -0,0 +1,9 @@
## Interface: 90002
## X-Curse-Project-ID: 290291
## X-WoWI-ID: 24579
## X-Repository: https://svn.grml.de/zz_itemsdb
## X-TOC-Classic: 11302
## SavedVariables: zz_itemsdbDB
## OptionalDeps: Ace3,zzLibCommon,LibGuildBankComm-1.0
Common\common.xml
pack.xml