forked from rilgamon/zz_Money
Update Libs
This commit is contained in:
parent
f61c19a640
commit
e6ab43617c
|
@ -1,8 +1,8 @@
|
|||
local lib = LibStub:NewLibrary("zzConfig", 2)
|
||||
local lib = LibStub:NewLibrary("zzConfig", 3)
|
||||
if not lib then return end
|
||||
local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
|
||||
local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0")
|
||||
local mixins = {'AddConfigMenu','AddConfigEntry','InitConfig'}
|
||||
local mixins = {'AddConfigMenu','AddConfigEntry','InitConfig', 'GetDefaultHandler'}
|
||||
lib['configs'] = lib['configs'] or {}
|
||||
local function getDB(objname)
|
||||
if(ldbicon) then
|
||||
|
@ -20,7 +20,6 @@ local function ldbiconUpdate(objname)
|
|||
end
|
||||
local function minimapGet(pref)
|
||||
local objname = pref[#pref - 2]
|
||||
-- print('gp', objname, pref)
|
||||
local db = getDB(objname)
|
||||
return db[pref[#pref]]
|
||||
end
|
||||
|
@ -37,14 +36,9 @@ local function notify(pref, value, oldvalue)
|
|||
end
|
||||
local function getPref(pref)
|
||||
if(type(pref['handler']['GetPref']) == 'function') then
|
||||
-- print("use handler getpref", pref[#pref])
|
||||
return pref['handler']:GetPref(pref)
|
||||
end
|
||||
-- for i = 1, #pref do
|
||||
-- print(i, pref[i])
|
||||
-- end
|
||||
-- print("use default getpref", pref[#pref], pref['handler']['db']['profile'][pref[#pref]])
|
||||
return pref['handler']['db']['profile'][pref[#pref-1]][pref[#pref]]
|
||||
return pref['handler']['db']['profile'][pref[#pref-1]] and pref['handler']['db']['profile'][pref[#pref-1]][pref[#pref]] or nil
|
||||
end
|
||||
local function setPref(pref,value)
|
||||
if(type(pref['handler']['SetPref']) == 'function') then
|
||||
|
@ -57,6 +51,24 @@ local function setPref(pref,value)
|
|||
end
|
||||
end
|
||||
end
|
||||
local function GDH_GetPref(self, pref)
|
||||
return self['db'][pref[#pref]]
|
||||
end
|
||||
local function GDH_SetPref(self, pref, value)
|
||||
self['db'][pref[#pref]] = value
|
||||
if(type(self['func']) == 'function') then
|
||||
self['func'](self)
|
||||
end
|
||||
end
|
||||
function lib:GetDefaultHandler(func, db)
|
||||
return {
|
||||
['db'] = db,
|
||||
['func'] = func,
|
||||
SetDB = function(self, db) self.db = db end,
|
||||
GetPref = GDH_GetPref,
|
||||
SetPref = GDH_SetPref,
|
||||
}
|
||||
end
|
||||
function lib:AddLDBIconOptions(options, conf)
|
||||
options['args'][conf] = {
|
||||
['name']="Minimapicon",
|
||||
|
@ -103,20 +115,21 @@ function lib:AddConfigEntry(options, ...)
|
|||
elseif(input[2] == 'select') then
|
||||
menu['values'] = input[6]
|
||||
elseif(input[2] == 'group') then
|
||||
menu['inline'] = input[6]
|
||||
menu['inline'] = input[7]
|
||||
menu['handler'] = input[6]
|
||||
menu['args'] = {
|
||||
['description'] = {
|
||||
['name'] = input[4],
|
||||
['type'] = 'header',
|
||||
['order'] = 0
|
||||
}
|
||||
},
|
||||
}
|
||||
end
|
||||
options['args'][input[1]] = menu
|
||||
return menu
|
||||
end
|
||||
end
|
||||
function lib:AddConfigMenu(options, parentName, handler, order, more)
|
||||
function lib:AddConfigMenu(options, parentName, order, handler, more)
|
||||
local menu = {
|
||||
['name'] = parentName,
|
||||
['type'] = 'group',
|
||||
|
|
|
@ -14,12 +14,12 @@ end
|
|||
local iconbase = "\124TInterface\\MoneyFrame\\UI-%sIcon:%d:%d:1:0\124t"
|
||||
local iconSize = 14
|
||||
local moneyText = {
|
||||
gold = "G",
|
||||
silver = "S",
|
||||
copper = "C",
|
||||
goldColor = lib:colorize("G", "daa520"),
|
||||
silverColor = lib:colorize("S", "bfc1c2"),
|
||||
copperColor = lib:colorize("C", "b87333"),
|
||||
gold = " G",
|
||||
silver = " S",
|
||||
copper = " C",
|
||||
goldColor = lib:colorize(" G", "ffd700"),
|
||||
silverColor = lib:colorize(" S", "bfc1c2"),
|
||||
copperColor = lib:colorize(" C", "b87333"),
|
||||
}
|
||||
function lib:MoneyStringSetString(coin, str, col)
|
||||
if(moneyText[coin]) then
|
||||
|
@ -36,9 +36,9 @@ function lib:MoneyStringSetSize(size)
|
|||
end
|
||||
function lib:MoneyString(money, color, abrevK, abrevM, noicon, noiconcolor, size)
|
||||
local iconSize = size or iconSize
|
||||
local goldicon = noicon and (noiconcolor and moneyText['gold'] or moneyText['goldColor']) or format(iconbase, 'Gold', iconSize, iconSize)
|
||||
local silvericon = noicon and (noiconcolor and moneyText['silver'] or moneyText['silverColor']) or format(iconbase, 'Silver', iconSize, iconSize)
|
||||
local coppericon = noicon and (noiconcolor and moneyText['copper'] or moneyText['copperColor']) or format(iconbase, 'Copper', iconSize, iconSize)
|
||||
local goldicon = noicon and (noiconcolor and moneyText['goldColor'] or moneyText['gold']) or format(iconbase, 'Gold', iconSize, iconSize)
|
||||
local silvericon = noicon and (noiconcolor and moneyText['silverColor'] or moneyText['silver']) or format(iconbase, 'Silver', iconSize, iconSize)
|
||||
local coppericon = noicon and (noiconcolor and moneyText['copperColor'] or moneyText['copper']) or format(iconbase, 'Copper', iconSize, iconSize)
|
||||
|
||||
local moneystring = ''
|
||||
local g,s,c
|
||||
|
@ -69,10 +69,10 @@ function lib:MoneyString(money, color, abrevK, abrevM, noicon, noiconcolor, size
|
|||
moneystring = format("%s%s%s", color and lib:colorize(g, neg and "ff0000" or "44dd44") or g,abrev, goldicon)
|
||||
end
|
||||
if(s>0) then
|
||||
moneystring = format("%s%s%s",moneystring, color and lib:colorize(s, neg and "ff0000" or "44dd44") or s, silvericon)
|
||||
moneystring = format("%s %s%s",moneystring, color and lib:colorize(s, neg and "ff0000" or "44dd44") or s, silvericon)
|
||||
end
|
||||
if(c>0) then
|
||||
moneystring = format("%s%s%s",moneystring, color and lib:colorize(c, neg and "ff0000" or "44dd44") or c, coppericon)
|
||||
moneystring = format("%s %s%s",moneystring, color and lib:colorize(c, neg and "ff0000" or "44dd44") or c, coppericon)
|
||||
end
|
||||
else
|
||||
moneystring = format("%s%s",color and '0' or '0', coppericon)
|
||||
|
|
Loading…
Reference in New Issue