Use zzLibs 2021-03-21

This commit is contained in:
rilgamon 2021-03-21 17:12:55 +01:00
parent 03c4e24880
commit 29f50033c1
14 changed files with 465 additions and 348 deletions

View File

@ -1,31 +1,75 @@
local lib, oldminor = LibStub:NewLibrary("zzAddOn", 2) local lib = LibStub:NewLibrary("zzAddOn", 4)
if not lib then return end if not lib then return end
oldminor = oldminor or 0 local config = LibStub:GetLibrary("zzConfig")
lib['callbacks'] = lib['callbacks'] or LibStub:GetLibrary("CallbackHandler-1.0"):New(lib) lib['callbacks'] = lib['callbacks'] or LibStub:GetLibrary("CallbackHandler-1.0"):New(lib)
lib['addons'] = lib['addons'] or {} lib['addons'] = lib['addons'] or {}
lib['events'] = lib['events'] or CreateFrame("FRAME") lib['events'] = lib['events'] or CreateFrame("FRAME")
local mixins = {'RegisterEvent','UnregisterEvent','IsClassic', 'GetSpecs'} local mixins = {'NewAddOn', 'GetAddOn', 'AddChild', 'HasChild', 'IsChild', 'HasParent', 'GetParent', 'GetOptions', 'RegisterEvent','UnregisterEvent','IsClassic', 'GetSpecs', 'Fire'}
local events = lib['events'] local events = lib['events']
function lib:Fire(...)
lib['callbacks']:Fire(...)
end
function lib:GetAddOn(childName)
return lib['addons'][childName]
end
function lib:GetOptions()
return self['options']
end
function lib:GetParent()
return self['parent']
end
function lib:HasParent()
return self['parent'] and true or false
end
function lib:IsChild()
return self:HasParent()
end
function lib:HasChild()
return self['children'] and #self['children'] > 0
end
function lib:GetSpecs(childName) function lib:GetSpecs(childName)
if(self['specs']) then return lib['addons'][childName]['specs']
return self['specs'][childName] end
local function joinTables(tab1, tab2, prefix)
prefix = prefix or ''
for k, v in pairs(tab2) do
if(tab1[k] and type(v) == 'table') then
joinTables(tab1[k], v, format("%s ", prefix))
else
tab1[k] = v
end
end end
end end
function lib:RegisterEvent(event) function lib:AddChild(child)
local childName = child['specs']['name']
child['parent'] = self
self['children'] = self['children'] or {}
self['children'][#self['children'] + 1] = child
if(child['specs']['defaults']) then
joinTables(self['specs']['defaults'], child['specs']['defaults'])
end
end
function lib:RegisterEvent(event, globalfunc)
if(type(event) == 'table') then if(type(event) == 'table') then
for ev, func in pairs(event) do for k, v in pairs(event) do
-- print("[zza] Registertab CB", type(ev),ev) -- print("[zza] Registertab CB", type(ev),ev)
local ev = k
local func = v
if(type(v) == 'string') then
ev = v
func = globalfunc
end
if(type(ev) == 'string' and type(func) == 'function' and not self['events'][ev]) then if(type(ev) == 'string' and type(func) == 'function' and not self['events'][ev]) then
self['events'][ev] = func self['events'][ev] = func
end end
self:RegisterEvent(ev) self:RegisterEvent(ev, func)
end end
elseif(type(event) == 'string') then elseif(type(event) == 'string') then
-- print("[zza] Register CB", type(event),event) -- print("[zza] Register CB", type(event),event)
if(not lib['events']:IsEventRegistered(event)) then if(not lib['events']:IsEventRegistered(event)) then
lib['events']:RegisterEvent(event) lib['events']:RegisterEvent(event)
end end
lib['RegisterCallback'](self['events'], event) lib.RegisterCallback(self, event, globalfunc)
else else
print("ign reg", type(event), event) print("ign reg", type(event), event)
end end
@ -36,29 +80,32 @@ function lib:UnregisterEvent(event)
self:UnregisterEvent(ev) self:UnregisterEvent(ev)
end end
else else
lib['UnregisterCallback'](self['events'], event) lib['UnregisterCallback'](self, event)
end end
-- print('unreg', event)
end end
function lib:IsClassic() function lib:IsClassic()
return WOW_PROJECT_ID == WOW_PROJECT_CLASSIC return WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
end end
function lib:NewAddOn(specs, addonName, addonTable) function lib:NewAddOn(addonName, addonTable)
local specs = self['specs']
local childName = specs['name'] local childName = specs['name']
addonTable['parentName'] = addonName
addonTable['specs'] = addonTable['specs'] or {}
addonTable['specs'][childName] = specs
if(type(childName) == 'string') then if(type(childName) == 'string') then
lib['addons'][childName] = addonTable self.GetAddOnTable = function() return addonTable end
lib:Embed(addonTable) lib['addons'][childName] = self
if(addonTable['events']) then lib:Embed(self)
for ev, func in pairs(addonTable['events']) do if(childName ~= addonName) then
local parent = lib['addons'][addonName]
parent:AddChild(self)
end
if(self['events']) then
for ev, func in pairs(self['events']) do
if(type(func) == 'function') then if(type(func) == 'function') then
-- print("[zza] Register", ev) self:RegisterEvent(ev, func)
addonTable:RegisterEvent(ev)
end end
end end
end end
return lib['addons'][childName] return self
end end
end end
function lib:Embed(target) function lib:Embed(target)
@ -70,31 +117,69 @@ for target, _ in pairs(lib['addons']) do
lib:Embed(target) lib:Embed(target)
end end
lib['events']:RegisterEvent('ADDON_LOADED') lib['events']:RegisterEvent('ADDON_LOADED')
local function addLDB(...)
-- print('addLDB', ...)
return LibStub:GetLibrary("zzLDB"):AddLDB(...)
end
local function addConfig(addonName, child, specs)
local at = child:GetAddOnTable()
if(addonName == child['specs']['name']) then
-- print("init options", addonName)
config:InitConfig(child, addonName)
child['options']['args']['profile'] = LibStub("AceDBOptions-3.0"):GetOptionsTable(at['db'])
else
-- print('add child options', specs['name'], addonName)
config:AddConfig(child, addonName)
end
if(type(specs['cfgReset']) == 'function') then
specs['cfgReset'](child)
at['db'].RegisterCallback(specs, "OnProfileReset", 'cfgReset')
end
end
local function SetupSpecs(addonName, child)
local specs = child['specs']
if(specs and specs['sv'] and not child['db']) then
-- print('dbname',type(specs['sv']),type(specs['sv']) == 'boolean' and addonName or specs['sv'])
local dbname = format('%sDB', type(specs['sv']) == 'boolean' and addonName or specs['sv'])
local at = child:GetAddOnTable()
at['db'] = LibStub("AceDB-3.0"):New(dbname, type(specs['defaults']) == 'table' and specs['defaults'] or {}, 'Default')
-- print('setup parent ldb')
if(specs['ldb']) then
local ldbobj = addLDB(specs['name'], specs['ldb'], at['db'])
-- print(' result parent ldb', specs['name'])
end
if(specs['cfg']) then
-- print(' spec parent addcfg', addonName, specs['name'])
addConfig(addonName, child, specs)
end
if(child:HasChild()) then
for i = 1, #child['children'] do
local child = child['children'][i]
local childSpecs = child['specs']
-- print("Add child", childSpecs['name'])
if(childSpecs['ldb']) then
-- print(" Add ldb", childSpecs['name'])
local ldbobj = addLDB(childSpecs['name'], childSpecs['ldb'], at['db'])
end
if(childSpecs['cfg']) then
-- print(' spec child addcfg', addonName, childSpecs['name'])
addConfig(addonName, child, childSpecs)
end
end
end
end
end
lib['events']:SetScript("OnEvent", function(self, event, ...) lib['events']:SetScript("OnEvent", function(self, event, ...)
-- print("[zza]", self, event, ...) -- print("[zza]", self, event, ...)
local addonName = ... local addonName = ...
local addon = lib['addons'][addonName] local child = lib['addons'][addonName]
if(addon) then if(child) then
if(event == 'ADDON_LOADED') then if(event == 'ADDON_LOADED') then
local specs = addon:GetSpecs(addonName) SetupSpecs(addonName, child)
if(specs and specs['sv'] and not addon['db']) then
-- print('dbname',type(specs['sv']),type(specs['sv']) == 'boolean' and addonName or specs['sv'])
local dbname = format('%sDB', type(specs['sv']) == 'boolean' and addonName or specs['sv'])
addon['db'] = LibStub("AceDB-3.0"):New(dbname, type(specs['defaults']) == 'table' and specs['defaults'] or {}, 'Default')
if(specs['ldb']) then
local ldbobj = LibStub:GetLibrary("zzLDB"):AddLDB(specs['name'], specs['ldb'], addon['db'])
end
if(specs['cfg']) then
local config = LibStub:GetLibrary("zzConfig")
addon['options'] = config:InitConfig(addon, addonName)
addon['options']['args']['profile'] = LibStub("AceDBOptions-3.0"):GetOptionsTable(addon['db'])
if(type(specs['cfgReset']) == 'function') then
addon['db'].RegisterCallback(specs, "OnProfileReset", 'cfgReset')
end
end
end
end end
end end
-- print("[zza] Fire", event, ...) -- print("[zza] Fire", event, ...)
lib['callbacks']:Fire(event, ...) lib['callbacks']:Fire(event, self, event, ...)
end) end)

View File

@ -2,21 +2,23 @@ local lib = LibStub:NewLibrary("zzConfig", 3)
if not lib then return end if not lib then return end
local ldb = LibStub:GetLibrary("LibDataBroker-1.1") local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0") local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0")
local mixins = {'AddConfigMenu','AddConfigEntry','InitConfig', 'GetDefaultHandler'} local mixins = {'AddConfigMenu', 'AddConfigEntry', 'InitConfig', 'GetDefaultHandler'}
lib['configs'] = lib['configs'] or {} lib['configs'] = lib['configs'] or {}
local function getDB(objname) local function getDB(objname)
if(ldbicon) then if(ldbicon) then
ldbicon:Show(objname) ldbicon:Show(objname)
local iconbtn = ldbicon:GetMinimapButton(objname) local iconbtn = ldbicon:GetMinimapButton(objname)
local db = iconbtn['db'] if(iconbtn) then
if(db['hide']) then local db = iconbtn['db']
ldbicon:Hide(objname) if(db['hide']) then
ldbicon:Hide(objname)
end
return db
else
print("noicon", objname)
end end
return db
end end
end return {}
local function ldbiconUpdate(objname)
local db = getDB(objname)
end end
local function minimapGet(pref) local function minimapGet(pref)
local objname = pref[#pref - 2] local objname = pref[#pref - 2]
@ -27,7 +29,6 @@ local function minimapSet(pref,value)
local objname = pref[#pref - 2] local objname = pref[#pref - 2]
local db = getDB(objname) local db = getDB(objname)
db[pref[#pref]] = value db[pref[#pref]] = value
ldbiconUpdate(objname)
end end
local function notify(pref, value, oldvalue) local function notify(pref, value, oldvalue)
if(type(pref['handler'].PrefChanged) == 'function') then if(type(pref['handler'].PrefChanged) == 'function') then
@ -38,14 +39,16 @@ local function getPref(pref)
if(type(pref['handler']['GetPref']) == 'function') then if(type(pref['handler']['GetPref']) == 'function') then
return pref['handler']:GetPref(pref) return pref['handler']:GetPref(pref)
end end
return pref['handler']['db']['profile'][pref[#pref-1]] and pref['handler']['db']['profile'][pref[#pref-1]][pref[#pref]] or nil local db = pref['handler']['db'] or pref['handler']:GetAddOnTable()['db']['profile'][pref['appName']]
return db and db[pref[#pref]]
end end
local function setPref(pref,value) local function setPref(pref, value, ...)
if(type(pref['handler']['SetPref']) == 'function') then if(type(pref['handler']['SetPref']) == 'function') then
pref['handler']:SetPref(pref,value) pref['handler']:SetPref(pref, value, ...)
else else
local oldvalue = pref['handler']['db']['profile'][pref[#pref-1]][pref[#pref]] local db = pref['handler']['db'] or pref['handler']:GetAddonTable()['db']['profile'][pref[#pref-1]]
pref['handler']['db']['profile'][pref[#pref-1]][pref[#pref]] = value local oldvalue = db[pref[#pref]]
db[pref[#pref]] = value
if(value ~= oldvalue) then if(value ~= oldvalue) then
notify(pref, value, oldvalue) notify(pref, value, oldvalue)
end end
@ -134,6 +137,7 @@ function lib:AddConfigMenu(options, parentName, order, handler, more)
['name'] = parentName, ['name'] = parentName,
['type'] = 'group', ['type'] = 'group',
['handler'] = handler or self['handler'], ['handler'] = handler or self['handler'],
['childGroups'] =' tab',
['order'] = order or 1, ['order'] = order or 1,
['args'] = {} ['args'] = {}
} }
@ -145,22 +149,41 @@ function lib:AddConfigMenu(options, parentName, order, handler, more)
options['args'][parentName] = menu options['args'][parentName] = menu
return options['args'][parentName] return options['args'][parentName]
end end
function lib:InitConfig(addon, parentName, gp, sp) function lib:InitConfig(child, parentName, gp, sp)
addon['options'] = { local pp = child['specs']['name'] == parentName
['type']='group', child['options'] = {
['handler']=addon, ['name'] = parentName,
['get']=gp or getPref, ['type'] = 'group',
['set']=sp or setPref, ['handler'] = child,
['childGroups']='tab', ['childGroups'] = 'tab',
['args']={} ['get'] = gp or getPref,
['set'] = sp or setPref,
['args'] = {}
} }
local options = addon['options'] local options = child['options']
local par = self:AddConfigMenu(options, parentName) local par = self:AddConfigMenu(options, parentName)
self:AddLDBIconOptions(par, 'minimap') self:AddLDBIconOptions(par, 'minimap')
LibStub("AceConfig-3.0"):RegisterOptionsTable(parentName, options) LibStub("AceConfig-3.0"):RegisterOptionsTable(parentName, options)
LibStub("AceConfigDialog-3.0"):AddToBlizOptions(parentName, parentName, self['parentName']) LibStub("AceConfigDialog-3.0"):AddToBlizOptions(parentName, parentName, child['parentName'])
return options return options
end end
function lib:AddConfig(child, parentName, gp, sp)
local specs = child['specs']
child['options'] = {
['name'] = specs['name'],
['type'] = 'group',
['handler'] = child,
['childGroups']='tab',
['get']=gp or getPref,
['set']=sp or setPref,
['args'] = {}
}
local par = self:AddConfigMenu(child['options'], specs['name'])
self:AddLDBIconOptions(par, 'minimap')
LibStub("AceConfig-3.0"):RegisterOptionsTable(specs['name'], child['options'])
LibStub("AceConfigDialog-3.0"):AddToBlizOptions(specs['name'], specs['name'], parentName)
return child['options']
end
function lib:Embed(target) function lib:Embed(target)
for _,name in pairs(mixins) do for _,name in pairs(mixins) do
target[name] = lib[name] target[name] = lib[name]

View File

@ -141,10 +141,12 @@ end
]] ]]
function lib:IsTwink(name) function lib:IsTwink(name)
local at = self:GetAddOnTable()
local db = at['db']
local realm = GetRealmName() local realm = GetRealmName()
local _ local _
if(self['db']['sv']['profileKeys']) then if(db['sv']['profileKeys']) then
for k,v in pairs(self['db']['sv']['profileKeys']) do for k,v in pairs(db['sv']['profileKeys']) do
local n,m = strsplit(" - ",k,2) local n,m = strsplit(" - ",k,2)
_,m = strsplit(" ",m,2) _,m = strsplit(" ",m,2)
if(n) then if(n) then

View File

@ -1,9 +1,9 @@
local lib, oldminor = LibStub:NewLibrary("zzLDB", 3) local lib, oldminor = LibStub:NewLibrary("zzLDB", 4)
if not lib then return end if not lib then return end
local ldb = LibStub:GetLibrary("LibDataBroker-1.1") local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0") local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0")
oldminor = oldminor or 0 oldminor = oldminor or 0
local mixins = {'AddLDB', 'GetLDB'} local mixins = {'AddLDB', 'GetLDB', 'DefaultOnClick', 'DefaultOnText'}
local defaults = { local defaults = {
['hide'] = false, ['hide'] = false,
} }
@ -11,6 +11,32 @@ lib['ldbs'] = lib['ldbs'] or {}
local function proto_OnClick(self, button) local function proto_OnClick(self, button)
print("onclick required", self, button) print("onclick required", self, button)
end end
function lib:DefaultOnClick(dummy, button, addon, childName)
if(IsShiftKeyDown() and button == "LeftButton") then
local sb = addon['db']['global']['ldbicons']
sb[childName]['hide'] = not sb[childName]['hide']
if(ldbicon) then
if(sb[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(childName)
InterfaceOptionsFrame_OpenToCategory(childName) -- Twice because of a bug in InterfaceOptionsFrame_OpenToCategory
end
end
end
function lib:DefaultOnText(objname, message)
local ldbobj = lib:GetLDB(objname)
if(ldbobj['text'] ~= message) then
ldbobj['text'] = message
end
end
function lib:GetLDB(objname) function lib:GetLDB(objname)
return ldb:GetDataObjectByName(objname) return ldb:GetDataObjectByName(objname)
end end
@ -28,7 +54,10 @@ function lib:AddLDB(objname, obj, db)
db['global']['ldbicons'] = db['global']['ldbicons'] or {} db['global']['ldbicons'] = db['global']['ldbicons'] or {}
local sb = db['global']['ldbicons'] local sb = db['global']['ldbicons']
sb[objname] = sb[objname] or CopyTable(defaults) sb[objname] = sb[objname] or CopyTable(defaults)
local oldstatus = sb[objname]['hide']
sb[objname]['hide'] = false
ldbicon:Register(objname, ldbobj, sb[objname]) ldbicon:Register(objname, ldbobj, sb[objname])
sb[objname]['hide'] = oldstatus
end end
return ldbobj return ldbobj
end end

View File

@ -1,17 +1,8 @@
local addonName, addonTable = ... local addonName, addon = ...
addonTable['events'] = addonTable['events'] or {} local childName = addon['childName']
local child = addon[childName]
local db, mailSum, mailRec, player, dbb, dbr, dbf, L, faction, realm local db, mailSum, mailRec, player, dbb, dbr, dbf, L, faction, realm
local events = addonTable['events'] local events = child['events']
function addonTable:SetupBanker()
player = UnitName('player')
L = addonTable['storage']['L']
db = addonTable['storage']['db']
dbr = addonTable['storage']['dbr']
dbf = addonTable['storage']['dbf']
dbb = dbf['banker']
faction = addonTable['storage']['faction']
realm = addonTable['storage']['realm']
end
local mailframes = {} local mailframes = {}
local posFrame = CreateFrame("Frame") local posFrame = CreateFrame("Frame")
posFrame:SetSize(32,1) posFrame:SetSize(32,1)
@ -35,8 +26,8 @@ local lastframe = posFrame
local function GetFactionList() local function GetFactionList()
local n,m,_ local n,m,_
local l = {} local l = {}
if(addonTable['db']['sv']['profileKeys']) then if(addon['db']['sv']['profileKeys']) then
for k,v in pairs(addonTable['db']['sv']['profileKeys']) do for k,v in pairs(addon['db']['sv']['profileKeys']) do
n,_,m = strsplit(' ',k,3) n,_,m = strsplit(' ',k,3)
if(n) then if(n) then
if(m == realm) then if(m == realm) then
@ -71,7 +62,7 @@ local function getDeliver(name)
end end
local function Click(self,button) local function Click(self,button)
local sendSum = getDeliver(self['destName']) local sendSum = getDeliver(self['destName'])
if(addonTable:IsTwink(self['destName']) and self['destName']~=player) then if(child:IsTwink(self['destName']) and self['destName']~=player) then
if(sendSum>0) then if(sendSum>0) then
if(SetSendMailMoney(sendSum)) then if(SetSendMailMoney(sendSum)) then
posFrame:RegisterEvent('MAIL_SEND_SUCCESS') posFrame:RegisterEvent('MAIL_SEND_SUCCESS')
@ -83,7 +74,6 @@ local function Click(self,button)
end end
end end
end end
local function Mouse(self) local function Mouse(self)
local tip = GameTooltip local tip = GameTooltip
tip:SetOwner(self, "ANCHOR_BOTTOM") tip:SetOwner(self, "ANCHOR_BOTTOM")
@ -161,3 +151,16 @@ end
function events:MAIL_SHOW() function events:MAIL_SHOW()
buildMailFrames() buildMailFrames()
end end
local init = {
Setup = function(self)
player = UnitName('player')
L = child['storage']['L']
db = child['storage']['db']
dbr = child['storage']['dbr']
dbf = child['storage']['dbf']
dbb = dbf['banker']
faction = child['storage']['faction']
realm = child['storage']['realm']
end
}
addon.RegisterCallback(init, format("Init%s", childName), 'Setup')

View File

@ -1,29 +1,18 @@
local addonName, addonTable = ... local addonName, addon = ...
local childName = "zz_Money" local childName = addon['childName']
local child = addon[childName]
local db, dbr, dbp, L, lineIn, lineOut, session, faction, realm local db, dbr, dbp, L, lineIn, lineOut, session, faction, realm
local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0") local zzLDB = LibStub:GetLibrary("zzLDB")
function addonTable:SetupBroker()
L = addonTable['storage']['L']
db = addonTable['storage']['db']
dbr = addonTable['storage']['dbr']
dbp = addonTable['storage']['dbp']
session = addonTable['storage']['session']
faction = addonTable['storage']['faction']
realm = addonTable['storage']['realm']
local folder = addonName ~= childName and format("Interface\\AddOns\\%s\\%s", addonName, childName) or format("Interface\\AddOns\\%s", childName)
lineIn = format("|T%s:0|t %s", format("%s\\in.tga", folder), L['Einnahmen'])
lineOut = format("|T%s:0|t %s", format("%s\\out.tga", folder), L['Ausgaben'])
end
local function cdbCheck(n,realm) local function cdbCheck(n,realm)
db[realm] = db[realm] or {} db[realm] = db[realm] or {}
db[realm][n] = db[realm][n] or { currentGold = 0 } db[realm][n] = db[realm][n] or { currentGold = 0 }
end end
addonTable.cdbCheck = cdbCheck child.cdbCheck = cdbCheck
local function getSumToday(d) local function getSumToday(d)
if(faction=='Neutral') then return 0,0 end if(faction=='Neutral') then return 0,0 end
local sumIn,sumOut = 0,0 local sumIn,sumOut = 0,0
d = d or 0 d = d or 0
local day = addonTable:getDateString() + d local day = child:getDateString() + d
for a,b in pairs(dbr['activity'][faction][tostring(day)] or {}) do for a,b in pairs(dbr['activity'][faction][tostring(day)] or {}) do
if(b < 0) then if(b < 0) then
sumOut = sumOut + b sumOut = sumOut + b
@ -53,118 +42,117 @@ local function Helper_Tooltip3(realm)
end end
end end
end end
addonTable.Helper_Tooltip3 = Helper_Tooltip3 child.Helper_Tooltip3 = Helper_Tooltip3
local function OnClick(self, button) local function OnClick(self, button)
if(IsShiftKeyDown() and button == "LeftButton") then zzLDB:DefaultOnClick(self, button, addon, childName)
local sb = addonTable['db']['global']['ldbicons']
sb[childName]['hide'] = not sb[childName]['hide']
if(ldbicon) then
if(sb[childName]['hide']) then
ldbicon:Hide(childName)
else
ldbicon:Show(childName)
end
end
else
if(not InCombatLockdown()) then
if(InterfaceOptionsFrame:IsVisible()) then
InterfaceOptionsFrame:Hide()
else
InterfaceOptionsFrame_OpenToCategory(childName)
InterfaceOptionsFrame_OpenToCategory(childName) -- Twice because of a bug in InterfaceOptionsFrame_OpenToCategory
end
end
end
end end
local function OnTooltipShow(tip) local function OnTooltipShow(tip)
tip:AddLine(childName) tip:AddLine(childName)
if(faction == 'Neutral') then if(faction == 'Neutral') then
tip:AddLine(L['neutral']) tip:AddLine(L['neutral'])
return return
end end
local sessdiff = dbp['currentGold'] - session['start'] local sessdiff = dbp['currentGold'] - session['start']
local sdr,sdg,sdb = 1, 1, 1 local sdr,sdg,sdb = 1, 1, 1
if(sessdiff<0) then if(sessdiff<0) then
sdr,sdg,sdb = 1, 0, 0 sdr,sdg,sdb = 1, 0, 0
end end
tip:AddDoubleLine(L['Sitzung'], addonTable:displayMoney(abs(sessdiff), db['shortMoneyTip']),1,1,0,sdr,sdg,sdb) tip:AddDoubleLine(L['Sitzung'], child:displayMoney(abs(sessdiff), db['shortMoneyTip']),1,1,0,sdr,sdg,sdb)
tip:AddDoubleLine(lineIn, addonTable:displayMoney(session['income'], db['shortMoneyTip']),1,1,1,1,1,1) tip:AddDoubleLine(lineIn, child:displayMoney(session['income'], db['shortMoneyTip']),1,1,1,1,1,1)
tip:AddDoubleLine(lineOut, addonTable:displayMoney(abs(session['expense']), db['shortMoneyTip']),1,1,1,1,1,1) tip:AddDoubleLine(lineOut, child:displayMoney(abs(session['expense']), db['shortMoneyTip']),1,1,1,1,1,1)
tip:AddLine(' ')
local sumOut,sumIn = getSumToday()
sessdiff = sumOut+sumIn
if(sessdiff<0) then
sdr,sdg,sdb = 1, 0, 0
else
sdr,sdg,sdb = 1, 1, 1
end
tip:AddDoubleLine(L['Heute'], child:displayMoney(abs(sessdiff), db['shortMoneyTip']),1,1,0,sdr,sdg,sdb)
tip:AddDoubleLine(lineIn, child:displayMoney(sumIn, db['shortMoneyTip']),1,1,1,1,1,1)
tip:AddDoubleLine(lineOut, child:displayMoney(abs(sumOut), db['shortMoneyTip']),1,1,1,1,1,1)
tip:AddLine(' ')
local sumOut,sumIn = getSumToday(-1)
sessdiff = sumOut+sumIn
if(sessdiff<0) then
sdr,sdg,sdb = 1, 0, 0
else
sdr,sdg,sdb = 1, 1, 1
end
tip:AddDoubleLine(L['Gestern'], child:displayMoney(abs(sessdiff), db['shortMoneyTip']),1,1,0,sdr,sdg,sdb)
tip:AddDoubleLine(lineIn, child:displayMoney(sumIn, db['shortMoneyTip']),1,1,1,1,1,1)
tip:AddDoubleLine(lineOut, child:displayMoney(abs(sumOut), db['shortMoneyTip']),1,1,1,1,1,1)
tip:AddLine(' ')
local sumOut,sumIn = getSumWeek()
sessdiff = sumOut+sumIn
if(sessdiff<0) then
sdr,sdg,sdb = 1, 0, 0
else
sdr,sdg,sdb = 1, 1, 1
end
tip:AddDoubleLine(L['7-Tage'], child:displayMoney(abs(sessdiff), db['shortMoneyTip']),1,1,0,sdr,sdg,sdb)
tip:AddDoubleLine(lineIn, child:displayMoney(sumIn, db['shortMoneyTip']),1,1,1,1,1,1)
tip:AddDoubleLine(lineOut, child:displayMoney(abs(sumOut), db['shortMoneyTip']),1,1,1,1,1,1)
tip:AddLine(' ') tip:AddLine(' ')
local sumOut,sumIn = getSumToday() local sum = 0
sessdiff = sumOut+sumIn local ttlist = {}
if(sessdiff<0) then if(addon['db']['sv']['profileKeys']) then
sdr,sdg,sdb = 1, 0, 0 for k,v in pairs(addon['db']['sv']['profileKeys']) do
else local n,_,m = strsplit(' ',k,3)
sdr,sdg,sdb = 1, 1, 1 if(n) then
end local cr = Helper_Tooltip3(m)
tip:AddDoubleLine(L['Heute'], addonTable:displayMoney(abs(sessdiff), db['shortMoneyTip']),1,1,0,sdr,sdg,sdb) if(m == realm or cr) then
tip:AddDoubleLine(lineIn, addonTable:displayMoney(sumIn, db['shortMoneyTip']),1,1,1,1,1,1) cdbCheck(n, m)
tip:AddDoubleLine(lineOut, addonTable:displayMoney(abs(sumOut), db['shortMoneyTip']),1,1,1,1,1,1) if( faction == db[m][n]['faction']) then
tip:AddLine(' ')
local sumOut,sumIn = getSumToday(-1)
sessdiff = sumOut+sumIn
if(sessdiff<0) then
sdr,sdg,sdb = 1, 0, 0
else
sdr,sdg,sdb = 1, 1, 1
end
tip:AddDoubleLine(L['Gestern'], addonTable:displayMoney(abs(sessdiff), db['shortMoneyTip']),1,1,0,sdr,sdg,sdb)
tip:AddDoubleLine(lineIn, addonTable:displayMoney(sumIn, db['shortMoneyTip']),1,1,1,1,1,1)
tip:AddDoubleLine(lineOut, addonTable:displayMoney(abs(sumOut), db['shortMoneyTip']),1,1,1,1,1,1)
tip:AddLine(' ')
local sumOut,sumIn = getSumWeek()
sessdiff = sumOut+sumIn
if(sessdiff<0) then
sdr,sdg,sdb = 1, 0, 0
else
sdr,sdg,sdb = 1, 1, 1
end
tip:AddDoubleLine(L['7-Tage'], addonTable:displayMoney(abs(sessdiff), db['shortMoneyTip']),1,1,0,sdr,sdg,sdb)
tip:AddDoubleLine(lineIn, addonTable:displayMoney(sumIn, db['shortMoneyTip']),1,1,1,1,1,1)
tip:AddDoubleLine(lineOut, addonTable:displayMoney(abs(sumOut), db['shortMoneyTip']),1,1,1,1,1,1)
tip:AddLine(' ')
local sum = 0
local ttlist = {}
if(addonTable['db']['sv']['profileKeys']) then
for k,v in pairs(addonTable['db']['sv']['profileKeys']) do
local n,_,m = strsplit(' ',k,3)
if(n) then
local cr = Helper_Tooltip3(m)
if(m == realm or cr) then
cdbCheck(n, m)
if( faction == db[m][n]['faction']) then
-- sum = sum + db[m][n]['currentGold'] -- sum = sum + db[m][n]['currentGold']
ttlist[k] = db[m][n]['currentGold'] ttlist[k] = db[m][n]['currentGold']
end
elseif(db['accountMoney']) then
-- sum = sum + db[m][n]['currentGold']
end end
elseif(db['accountMoney']) then
-- sum = sum + db[m][n]['currentGold']
end end
end end
end end
for _,v in pairs(addonTable:sortArray(ttlist,db['sortDir'])) do
local n,_,m = strsplit(' ',v,3)
local cr = Helper_Tooltip3(m)
tip:AddDoubleLine(addonTable:classcolor(n,db[cr and m or realm][n]['class']),addonTable:displayMoney(db[cr and m or realm][n]['currentGold']+(db[cr and m or realm][n]['incoming'] or 0), db['shortMoneyTip']),0,1,0,1,1,1)
end
tip:AddLine(' ')
tip:AddDoubleLine(L['Gesamt'],addonTable:displayMoney(addonTable:GetGold(db['displaySelTT'] or 2), db['shortMoneyTip']),0,1,0,1,1,1)
end
function addonTable:GetBroker(objname)
return LibStub:GetLibrary("zzLDB"):GetLDB(objname)
end
function addonTable:OnText(objname, message)
local ldbobj = addonTable:GetBroker(objname)
if(ldbobj['text'] ~= message) then
ldbobj['text'] = message
end end
for _,v in pairs(child:sortArray(ttlist,db['sortDir'])) do
local n,_,m = strsplit(' ',v,3)
local cr = Helper_Tooltip3(m)
local rm = cr and m or realm
tip:AddDoubleLine(
child:classcolor(n,db[rm][n]['class']),
child:displayMoney(db[rm][n]['currentGold']+(db[rm][n]['incoming'] or 0), db['shortMoneyTip']),
0,1,0,
1,1,1
)
end
tip:AddLine(' ')
tip:AddDoubleLine(L['Gesamt'],child:displayMoney(child:GetGold(db['displaySelTT'] or 2), db['shortMoneyTip']),0,1,0,1,1,1)
end end
addonTable['ldb'] = { -- https://github.com/tekkub/libdatabroker-1-1/wiki/Data-Specifications child['ldb'] = { -- https://github.com/tekkub/libdatabroker-1-1/wiki/Data-Specifications
['type'] = 'data source', -- required: 'data source' or 'launcher' ['type'] = 'data source', -- required: 'data source' or 'launcher'
['text'] = childName, -- required/optional for launcher ['text'] = childName, -- required/optional for launcher
['icon'] = 'Interface\\Icons\\INV_Misc_Bag_10_Blue', -- optional/required for launcher ['icon'] = 'Interface\\Icons\\INV_Misc_Bag_10_Blue', -- optional/required for launcher
['OnClick'] = OnClick, -- optional/required for launcher ['OnClick'] = OnClick, -- optional/required for launcher
['OnTooltipShow'] = OnTooltipShow, -- optional ['OnTooltipShow'] = OnTooltipShow, -- optional
} }
function child:OnText(objname, message)
local ldbobj = zzLDB:GetLDB(objname)
if(ldbobj['text'] ~= message) then
ldbobj['text'] = message
end
end
local init = {
Setup = function(self, childName, event)
L = child['storage']['L']
db = child['storage']['db']
dbr = child['storage']['dbr']
dbp = child['storage']['dbp']
session = child['storage']['session']
faction = child['storage']['faction']
realm = child['storage']['realm']
local folder = addonName ~= childName and format("Interface\\AddOns\\%s\\%s", addonName, childName) or format("Interface\\AddOns\\%s", childName)
lineIn = format("|T%s:0|t %s", format("%s\\in.tga", folder), L['Einnahmen'])
lineOut = format("|T%s:0|t %s", format("%s\\out.tga", folder), L['Ausgaben'])
end
}
addon.RegisterCallback(init, format("Init%s", childName), 'Setup', childName)

107
core.lua
View File

@ -1,19 +1,19 @@
local addonName, addonTable = ... local addonName, addon = ...
local childName = "zz_Money" local childName = addon['childName']
local child = addon[childName]
local events = child['events']
local db, dbr, dbp, faction, realm local db, dbr, dbp, faction, realm
LibStub("zzHelper"):Embed(addonTable) LibStub("zzHelper"):Embed(child)
addonTable['events'] = addonTable['events'] or {}
local events = addonTable['events']
local session = { start = 0, income = 0, expense = 0 } local session = { start = 0, income = 0, expense = 0 }
local L = LibStub("AceLocale-3.0"):GetLocale(childName, true) local L = LibStub("AceLocale-3.0"):GetLocale(childName, true)
local function prepareDB() local function prepareDB(self)
local player = UnitName('player') local player = UnitName('player')
realm = GetNormalizedRealmName() realm = GetNormalizedRealmName()
if(not realm) then return end if(not realm) then return end
faction = UnitFactionGroup('player') faction = UnitFactionGroup('player')
local className, classFilename, classId = UnitClass('player') local className, classFilename, classId = UnitClass('player')
addonTable['db']['profile'][childName] = addonTable['db']['profile'][childName] or {} addon['db']['profile'][childName] = addon['db']['profile'][childName] or {}
db = addonTable['db']['profile'][childName] db = addon['db']['profile'][childName]
db[realm] = db[realm] or {} db[realm] = db[realm] or {}
db[faction] = db[faction] or {} db[faction] = db[faction] or {}
db[faction]['banker'] = db[faction]['banker'] or { db[faction]['banker'] = db[faction]['banker'] or {
@ -31,7 +31,7 @@ local function prepareDB()
dbp['currentGold'] = dbp['currentGold'] or 0 dbp['currentGold'] = dbp['currentGold'] or 0
dbp['class'] = classFilename dbp['class'] = classFilename
dbp['faction'] = faction dbp['faction'] = faction
addonTable['storage'] = { child['storage'] = {
['db'] = db, ['db'] = db,
['dbr'] = dbr, ['dbr'] = dbr,
['dbp'] = dbp, ['dbp'] = dbp,
@ -41,39 +41,22 @@ local function prepareDB()
['faction'] = faction, ['faction'] = faction,
['realm'] = realm, ['realm'] = realm,
} }
addonTable:SetupPrefs(childName) child['db'] = db
addonTable:SetupBroker() addon['callbacks']:Fire(format("Init%s", childName))
addonTable:SetupBanker() child['events']['PLAYER_MONEY']()
end end
function addonTable:getDateString() function child:getDateString()
return format("%s%s",tostring(date("%Y")),tostring(1000 + date("%j"))) return format("%s%s",tostring(date("%Y")),tostring(1000 + date("%j")))
end end
local specs = { function child:GetGold(val)
['name'] = childName,
['sv'] = true,
['cfg'] = true,
['cfgReset'] = prepareDB,
['ldb'] = addonTable['ldb'] ,
['defaults'] = {
['profile'] = {
[childName] = {
['disableBanker'] = true,
['displaySelTT'] = 2,
['displaySel'] = 2,
['connectedRealms'] = true
}
}
}
}
function addonTable:GetGold(val)
local val = val or 2 local val = val or 2
local sums = { dbp['currentGold'], 0, 0, 0 } local sums = { dbp['currentGold'], 0, 0, 0 }
if(addonTable['db']['sv']['profileKeys']) then if(addon['db']['sv']['profileKeys']) then
for k,v in pairs(addonTable['db']['sv']['profileKeys']) do for k,v in pairs(addon['db']['sv']['profileKeys']) do
local n,_,m = strsplit(' ',k,3) local n,_,m = strsplit(' ',k,3)
if(n) then if(n) then
local cr = addonTable.Helper_Tooltip3(m) local cr = child.Helper_Tooltip3(m)
addonTable.cdbCheck(n, m) child.cdbCheck(n, m)
local ch = db[m][n] local ch = db[m][n]
sums[3] = sums[3] + ch['currentGold'] -- global all sums[3] = sums[3] + ch['currentGold'] -- global all
if(faction == ch['faction']) then if(faction == ch['faction']) then
@ -87,29 +70,28 @@ function addonTable:GetGold(val)
end end
return sums[val] return sums[val]
end end
function addonTable:displayMoney(money, abr) function child:displayMoney(money, abr)
if(abr) then if(abr) then
if(db['shortMoney'] and money>10000)then if(db['shortMoney'] and money>10000)then
money = addonTable:round(money / 10000,0) * 10000 money = child:round(money / 10000,0) * 10000
end end
end end
return addonTable:MoneyString(money, color, abr and (db['abrevK'] and L['abrK'] or nil) or nil, abr and (db['abrevM'] and L['abrM'] or nil) or nil, db['noIcon'], db['noIconColor']) return child:MoneyString(money, color, abr and (db['abrevK'] and L['abrK'] or nil) or nil, abr and (db['abrevM'] and L['abrM'] or nil) or nil, db['noIcon'], db['noIconColor'])
end end
local pew_events = {} function events:PLAYER_MONEY(event)
function pew_events:PLAYER_MONEY(event)
local money = GetMoney() local money = GetMoney()
if(money == 0) then return end if(money == 0) then return end
if(session['start'] == 0) then if(session['start'] == 0) then
session['start'] = money session['start'] = money
end end
dbp['currentGold'] = dbp['currentGold'] or 0 dbp['currentGold'] = dbp['currentGold'] or 0
dbp['incoming'] = 0 dbp['incoming'] = nil
if(money ~= dbp['currentGold']) then if(money ~= dbp['currentGold']) then
local diff = money - dbp['currentGold'] local diff = money - dbp['currentGold']
local out = GetCoinTextureString(abs(diff)) local out = GetCoinTextureString(abs(diff))
local color = "ffffff" local color = "ffffff"
local stamp = time() local stamp = time()
local day = addonTable:getDateString() local day = child:getDateString()
local dba = dbr['activity'][faction] local dba = dbr['activity'][faction]
dba[day] = dba[day] or {} dba[day] = dba[day] or {}
local dbd = dba[day] local dbd = dba[day]
@ -124,21 +106,36 @@ function pew_events:PLAYER_MONEY(event)
end end
dbd[stamp] = diff dbd[stamp] = diff
if(db['showLog']) then if(db['showLog']) then
print(addonTable:colorize(out, color)) print(child:colorize(out, color))
end end
dbp['currentGold'] = money dbp['currentGold'] = money
end end
local sum = addonTable:GetGold(db['displaySel'] or 2) local sum = child:GetGold(db['displaySel'] or 2)
addonTable:OnText(childName, addonTable:displayMoney(sum, true)) child:OnText(childName, child:displayMoney(sum, true))
end end
function addonTable:PrefChanged(pref, value, oldvalue) child['specs'] = {
pew_events:PLAYER_MONEY() ['name'] = childName,
['sv'] = true,
['cfg'] = true,
['cfgReset'] = prepareDB,
['ldb'] = child['ldb'],
['defaults'] = {
['profile'] = {
[childName] = {
['disableBanker'] = true,
['displaySelTT'] = 2,
['displaySel'] = 2,
['connectedRealms'] = true
}
}
},
['events'] = events
}
function events:PLAYER_ENTERING_WORLD()
if(not realm) then
prepareDB()
else
child:UnregisterEvent('PLAYER_ENTERING_WORLD')
end
end end
function events:PLAYER_ENTERING_WORLD(event) child:NewAddOn(...)
prepareDB()
addonTable:UnregisterEvent('PLAYER_ENTERING_WORLD')
addonTable:RegisterEvent(pew_events)
pew_events:PLAYER_MONEY()
end
LibStub:GetLibrary("zzAddOn"):NewAddOn(specs, ...)

View File

@ -1,9 +1,9 @@
local addonname, addon = ... local addonName, addon = ...
local name = "zz_Money" local childName = addon['childName']
local L = LibStub("AceLocale-3.0"):NewLocale(name, "deDE", false) local L = LibStub("AceLocale-3.0"):NewLocale(childName, "deDE", false)
if L then if L then
L[name] = name L[childName] = childName
L[name..' Settings'] = name..' Einstellungen' L[childName..' Settings'] = childName..' Einstellungen'
L['Sitzung']='Sitzung' L['Sitzung']='Sitzung'
L['Einnahmen']='Einnahmen' L['Einnahmen']='Einnahmen'
L['Ausgaben']='Ausgaben' L['Ausgaben']='Ausgaben'

View File

@ -1,9 +1,9 @@
local addonname, addon = ... local addonname, addon = ...
local name = "zz_Money" local childName = addon['childName']
local L = LibStub("AceLocale-3.0"):NewLocale(name, "enUS", true) local L = LibStub("AceLocale-3.0"):NewLocale(childName, "enUS", true)
if L then if L then
L[name] = name L[childName] = childName
L[name..' Settings'] = name..' Settings' L[childName..' Settings'] = childName..' Settings'
L['Sitzung']='Session' L['Sitzung']='Session'
L['Einnahmen']='Income' L['Einnahmen']='Income'
L['Ausgaben']='Expenses' L['Ausgaben']='Expenses'

View File

@ -1,9 +1,9 @@
local addonname, addon = ... local addonname, addon = ...
local name = "zz_Money" local childName = addon['childName']
local L = LibStub("AceLocale-3.0"):NewLocale(name, "koKR", false) local L = LibStub("AceLocale-3.0"):NewLocale(childName, "koKR", false)
if L then if L then
L[name] = name L[childName] = childName
L[name..' Settings'] = name..' 설정' L[childName..' Settings'] = childName..' 설정'
L['Sitzung']='세션' L['Sitzung']='세션'
L['Einnahmen']='수입' L['Einnahmen']='수입'
L['Ausgaben']='지출' L['Ausgaben']='지출'

View File

@ -1,9 +1,9 @@
local addonname, addon = ... local addonname, addon = ...
local name = "zz_Money" local childName = addon['childName']
local L = LibStub("AceLocale-3.0"):NewLocale(name, "ruRU", false) local L = LibStub("AceLocale-3.0"):NewLocale(childName, "ruRU", false)
if L then if L then
L[name] = name L[childName] = childName
L[name..' Settings'] = name..' Настройки' L[childName..' Settings'] = childName..' Настройки'
L['Sitzung']='Сессия' L['Sitzung']='Сессия'
L['Einnahmen']='Доход' L['Einnahmen']='Доход'
L['Ausgaben']='Расход' L['Ausgaben']='Расход'

View File

@ -1,10 +1,11 @@
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd"> <Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<script file="locale_deDE.lua"/> <Script file="init.lua"/>
<script file="locale_koKR.lua"/> <Script file="locale_enUS.lua"/>
<script file="locale_enUS.lua"/> <Script file="locale_deDE.lua"/>
<script file="locale_ruRU.lua"/> <Script file="locale_koKR.lua"/>
<Script file="locale_ruRU.lua"/>
<Script file="banker.lua"/>
<Script file="prefs.lua"/> <Script file="prefs.lua"/>
<Script file="broker.lua"/> <Script file="broker.lua"/>
<Script file="banker.lua"/>
<Script file="core.lua"/> <Script file="core.lua"/>
</Ui> </Ui>

113
prefs.lua
View File

@ -1,24 +1,14 @@
local addonName, addonTable = ... local addonName, addon = ...
local childName = addon['childName']
local child = addon[childName]
local db, dbr, faction local db, dbr, faction
local childName = "zz_Money"
local L = LibStub("AceLocale-3.0"):GetLocale(childName, true)
addonTable['bankHandler'] = {
SetDB = function(self, db) self.db = db end,
GetPref = function(self, pref)
return self['db'][pref[#pref]]
end,
SetPref = function (self, pref, value)
self['db'][pref[#pref]] = value
addonTable['events']['MAIL_SHOW'](addonTable)
end,
}
local function buildSelect() local function buildSelect()
local sel = {} local sel = {}
local n,m,_ local n,m,_
if(addonTable['db']['sv']['profileKeys']) then if(addon['db']['sv']['profileKeys']) then
for k,v in pairs(addonTable['db']['sv']['profileKeys']) do for k,v in pairs(addon['db']['sv']['profileKeys']) do
n,_,m = strsplit(' ',k,3) n,_,m = strsplit(' ',k,3)
if(addonTable:IsTwink(n)) then if(child:IsTwink(n)) then
if(dbr[n] and faction == dbr[n]['faction']) then if(dbr[n] and faction == dbr[n]['faction']) then
sel[n] = n sel[n] = n
end end
@ -27,16 +17,11 @@ local function buildSelect()
end end
return sel return sel
end end
local buildDisplayValue = {
L['displayMoneyChar'], L['displayMoneyRealm'], L['displayMoneyGlobal'], L['displayMoneyGlobalFaction']
}
local function buildSelectAll() local function buildSelectAll()
local sel = {} local sel = {}
local n,m,_ local n,m,_
if(addonTable['db']['sv']['profileKeys']) then if(addon['db']['sv']['profileKeys']) then
for k,v in pairs(addonTable['db']['sv']['profileKeys']) do for k,v in pairs(addon['db']['sv']['profileKeys']) do
n,_,m = strsplit(' ',k,3) n,_,m = strsplit(' ',k,3)
sel[format("%s-%s",n,m)] = format("%s-%s",n,m) sel[format("%s-%s",n,m)] = format("%s-%s",n,m)
end end
@ -48,43 +33,53 @@ local function deleteChar()
local charName, charRealm = strsplit('-', db['deleteChar'],2) local charName, charRealm = strsplit('-', db['deleteChar'],2)
if(db[charRealm] and db[charRealm][charName]) then if(db[charRealm] and db[charRealm][charName]) then
db[charRealm][charName] = nil db[charRealm][charName] = nil
addonTable['db']['sv']['profileKeys'][format("%s - %s", charName, charRealm)] = nil addon['db']['sv']['profileKeys'][format("%s - %s", charName, charRealm)] = nil
end end
end end
db['deleteCharOk'] = nil db['deleteCharOk'] = nil
end end
function addonTable:SetupPrefs(childName)
local L = addonTable['storage']['L']
dbr = addonTable['storage']['dbr'] local init = {
db = addonTable['storage']['db'] Setup = function(self)
local dbf = addonTable['storage']['dbf'] local L = child['storage']['L']
local dbb = dbf['banker'] dbr = child['storage']['dbr']
faction = addonTable['storage']['faction'] db = child['storage']['db']
local config = LibStub:GetLibrary("zzConfig") local dbf = child['storage']['dbf']
local main = addonTable['options']['args'][childName] local dbb = dbf['banker']
config:AddConfigEntry(main, "displaySel", "select", L['Displayvalue'], L['DisplayvalueDesc'], 1, buildDisplayValue) faction = child['storage']['faction']
config:AddConfigEntry(main, "connectedRealms", "toggle", L['connectedRealms'], nil, 2) local config = LibStub:GetLibrary("zzConfig")
config:AddConfigEntry(main, "showLog", "toggle", L['showLog'], nil, 3) local options = child['options']
config:AddConfigEntry(main, "shortMoney", "toggle", L['shortMoney'], nil, 4) local main = options['args'][childName]
config:AddConfigEntry(main, "disableBanker", "toggle", L['nobanker'], nil, 5) local buildDisplayValue = {
config:AddConfigEntry(main, "abrevK", "toggle", L['abrevK'], nil, 6) L['displayMoneyChar'], L['displayMoneyRealm'], L['displayMoneyGlobal'], L['displayMoneyGlobalFaction']
config:AddConfigEntry(main, "abrevM", "toggle", L['abrevM'], nil, 7) }
local noicon = config:AddConfigEntry(main, "noIcon", "toggle", L['noIcon'], L['noIconDesk'], 6) config:AddConfigEntry(main, "displaySel", "select", L['Displayvalue'], L['DisplayvalueDesc'], 1, buildDisplayValue)
local noiconColor = config:AddConfigEntry(main, "noIconColor", "toggle", L['Color text'], L['Color text desc'], 7) config:AddConfigEntry(main, "connectedRealms", "toggle", L['connectedRealms'], nil, 2)
noiconColor['disabled'] = function(self) if(not db['noIcon']) then return true end end config:AddConfigEntry(main, "showLog", "toggle", L['showLog'], nil, 3)
local menu = config:AddConfigMenu(addonTable['options'], L['Bankier'], 2, config:GetDefaultHandler(addonTable['events']['MAIL_SHOW'], dbb), { disabled = function() return db['disableBanker'] config:AddConfigEntry(main, "shortMoney", "toggle", L['shortMoney'], nil, 4)
end}) config:AddConfigEntry(main, "disableBanker", "toggle", L['nobanker'], nil, 5)
config:AddConfigEntry(menu, "minLimit", "range", L['Minimum Limit'], L['Desc MinL'], 1, 10, 150000, 5, false) config:AddConfigEntry(main, "abrevK", "toggle", L['abrevK'], nil, 6)
config:AddConfigEntry(menu, "maxLimit", "range", L['Maximum Limit'], L['Desc MaxL'], 2, 10, 150000, 5, false) config:AddConfigEntry(main, "abrevM", "toggle", L['abrevM'], nil, 7)
config:AddConfigEntry(menu, "banker","select",L['Bankier'],nil,3,buildSelect) local noicon = config:AddConfigEntry(main, "noIcon", "toggle", L['noIcon'], L['noIconDesk'], 6)
local ttmenu = config:AddConfigEntry(main, "ttmenu", "group", L['ttmenu_title'], L['ttmenu_desc'], 9, config:GetDefaultHandler(addonTable['events']['PLAYER_MONEY'], db), true) local noiconColor = config:AddConfigEntry(main, "noIconColor", "toggle", L['Color text'], L['Color text desc'], 7)
config:AddConfigEntry(ttmenu, "displaySelTT", "select", L['Gesamt'], L['DisplayvalueDesc'], 1, buildDisplayValue) noiconColor['disabled'] = function(self) if(not db['noIcon']) then return true end end
config:AddConfigEntry(ttmenu, "sortDir", "toggle", L['sortDir'], nil, 2) local menu = config:AddConfigMenu(options, L['Bankier'], 2, config:GetDefaultHandler(child['events']['MAIL_SHOW'], dbb), { disabled = function() return db['disableBanker']
config:AddConfigEntry(ttmenu, "accountMoney", "toggle", L['accountMoney'], L['accountMoneyDesc'], 3) end})
local short = config:AddConfigEntry(ttmenu, "shortMoneyTip", "toggle", L['shortMoneyTip'], nil, 4) config:AddConfigEntry(menu, "minLimit", "range", L['Minimum Limit'], L['Desc MinL'], 1, 10, 150000, 5, false)
short['disabled'] = function(self) if(not db['abrevK'] and not db['abrevM']) then return true end end config:AddConfigEntry(menu, "maxLimit", "range", L['Maximum Limit'], L['Desc MaxL'], 2, 10, 150000, 5, false)
local delmenu = config:AddConfigEntry(main, "delmenu", "group", L['DeleteChar'], L['DeleteCharDesc'], 10, config:GetDefaultHandler(nil, db), true) config:AddConfigEntry(menu, "banker","select",L['Bankier'],nil,3,buildSelect)
config:AddConfigEntry(delmenu, "deleteChar", "select", L['DeleteChar'], L['DeleteCharDesc'], 1, buildSelectAll) local ttmenu = config:AddConfigEntry(main, "ttmenu", "group", L['ttmenu_title'], L['ttmenu_desc'], 9, config:GetDefaultHandler(child['events']['PLAYER_MONEY'], db), true)
config:AddConfigEntry(delmenu, "deleteCharOk", "toggle", L['DeleteCharOk'], nil , 2) config:AddConfigEntry(ttmenu, "displaySelTT", "select", L['Gesamt'], L['DisplayvalueDesc'], 1, buildDisplayValue)
config:AddConfigEntry(delmenu, "deleteCharExec", "execute", L['DeleteChar'], L['DeleteCharDesc'], 3, deleteChar) config:AddConfigEntry(ttmenu, "sortDir", "toggle", L['sortDir'], nil, 2)
end config:AddConfigEntry(ttmenu, "accountMoney", "toggle", L['accountMoney'], L['accountMoneyDesc'], 3)
local short = config:AddConfigEntry(ttmenu, "shortMoneyTip", "toggle", L['shortMoneyTip'], nil, 4)
short['disabled'] = function(self) if(not db['abrevK'] and not db['abrevM']) then return true end end
local delmenu = config:AddConfigEntry(main, "delmenu", "group", L['DeleteChar'], L['DeleteCharDesc'], 10, config:GetDefaultHandler(nil, db), true)
config:AddConfigEntry(delmenu, "deleteChar", "select", L['DeleteChar'], L['DeleteCharDesc'], 1, buildSelectAll)
config:AddConfigEntry(delmenu, "deleteCharOk", "toggle", L['DeleteCharOk'], nil , 2)
config:AddConfigEntry(delmenu, "deleteCharExec", "execute", L['DeleteChar'], L['DeleteCharDesc'], 3, deleteChar)
child.PrefChanged = child['events']['PLAYER_MONEY']
end
}
addon.RegisterCallback(init, format("Init%s", childName), 'Setup')

View File

@ -1,12 +1,6 @@
## Interface: 90005 ## Interface: 90005
## Title: Money ## Title: Money
## Notes: Broker Money display ## OptionalDeps: zzLib, Ace3, BrokerPack
## Notes-deDE: Broker zur Goldanzeige ## SavedVariables: zz_MoneyDB
## Author: Rilgamon Libs\embeds.xml
## X-WoWI-ID: 15621
## X-Curse-Project-ID: 39054
## X-Repository: https://git.grml.de/rilgamon/zz_Money.git
## OptionalDeps: zzLib, Ace3, BrokerPack
## SavedVariables: zz_MoneyDB
Libs\embeds.xml
pack.xml pack.xml