commit
This commit is contained in:
parent
7872894d6f
commit
e200aa9859
|
@ -1,8 +1,8 @@
|
||||||
local lib = LibStub:NewLibrary("zzConfig", 2)
|
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'}
|
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
|
||||||
|
@ -38,7 +38,7 @@ 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]][pref[#pref]]
|
return pref['handler']['db']['profile'][pref[#pref-1]] and pref['handler']['db']['profile'][pref[#pref-1]][pref[#pref]] or nil
|
||||||
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
|
||||||
|
@ -51,6 +51,24 @@ local function setPref(pref,value)
|
||||||
end
|
end
|
||||||
end
|
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)
|
function lib:AddLDBIconOptions(options, conf)
|
||||||
options['args'][conf] = {
|
options['args'][conf] = {
|
||||||
['name']="Minimapicon",
|
['name']="Minimapicon",
|
||||||
|
@ -97,20 +115,21 @@ function lib:AddConfigEntry(options, ...)
|
||||||
elseif(input[2] == 'select') then
|
elseif(input[2] == 'select') then
|
||||||
menu['values'] = input[6]
|
menu['values'] = input[6]
|
||||||
elseif(input[2] == 'group') then
|
elseif(input[2] == 'group') then
|
||||||
menu['inline'] = input[6]
|
menu['inline'] = input[7]
|
||||||
|
menu['handler'] = input[6]
|
||||||
menu['args'] = {
|
menu['args'] = {
|
||||||
['description'] = {
|
['description'] = {
|
||||||
['name'] = input[4],
|
['name'] = input[4],
|
||||||
['type'] = 'header',
|
['type'] = 'header',
|
||||||
['order'] = 0
|
['order'] = 0
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
options['args'][input[1]] = menu
|
options['args'][input[1]] = menu
|
||||||
return menu
|
return menu
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function lib:AddConfigMenu(options, parentName, handler, order, more)
|
function lib:AddConfigMenu(options, parentName, order, handler, more)
|
||||||
local menu = {
|
local menu = {
|
||||||
['name'] = parentName,
|
['name'] = parentName,
|
||||||
['type'] = 'group',
|
['type'] = 'group',
|
||||||
|
|
|
@ -14,12 +14,12 @@ end
|
||||||
local iconbase = "\124TInterface\\MoneyFrame\\UI-%sIcon:%d:%d:1:0\124t"
|
local iconbase = "\124TInterface\\MoneyFrame\\UI-%sIcon:%d:%d:1:0\124t"
|
||||||
local iconSize = 14
|
local iconSize = 14
|
||||||
local moneyText = {
|
local moneyText = {
|
||||||
gold = "G",
|
gold = " G",
|
||||||
silver = "S",
|
silver = " S",
|
||||||
copper = "C",
|
copper = " C",
|
||||||
goldColor = lib:colorize("G", "daa520"),
|
goldColor = lib:colorize(" G", "ffd700"),
|
||||||
silverColor = lib:colorize("S", "bfc1c2"),
|
silverColor = lib:colorize(" S", "bfc1c2"),
|
||||||
copperColor = lib:colorize("C", "b87333"),
|
copperColor = lib:colorize(" C", "b87333"),
|
||||||
}
|
}
|
||||||
function lib:MoneyStringSetString(coin, str, col)
|
function lib:MoneyStringSetString(coin, str, col)
|
||||||
if(moneyText[coin]) then
|
if(moneyText[coin]) then
|
||||||
|
@ -36,9 +36,9 @@ function lib:MoneyStringSetSize(size)
|
||||||
end
|
end
|
||||||
function lib:MoneyString(money, color, abrevK, abrevM, noicon, noiconcolor, size)
|
function lib:MoneyString(money, color, abrevK, abrevM, noicon, noiconcolor, size)
|
||||||
local iconSize = size or iconSize
|
local iconSize = size or iconSize
|
||||||
local goldicon = noicon and (noiconcolor and moneyText['gold'] or moneyText['goldColor']) or format(iconbase, 'Gold', 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['silver'] or moneyText['silverColor']) or format(iconbase, 'Silver', 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['copper'] or moneyText['copperColor']) or format(iconbase, 'Copper', iconSize, iconSize)
|
local coppericon = noicon and (noiconcolor and moneyText['copperColor'] or moneyText['copper']) or format(iconbase, 'Copper', iconSize, iconSize)
|
||||||
|
|
||||||
local moneystring = ''
|
local moneystring = ''
|
||||||
local g,s,c
|
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)
|
moneystring = format("%s%s%s", color and lib:colorize(g, neg and "ff0000" or "44dd44") or g,abrev, goldicon)
|
||||||
end
|
end
|
||||||
if(s>0) then
|
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
|
end
|
||||||
if(c>0) then
|
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
|
end
|
||||||
else
|
else
|
||||||
moneystring = format("%s%s",color and '0' or '0', coppericon)
|
moneystring = format("%s%s",color and '0' or '0', coppericon)
|
||||||
|
|
Loading…
Reference in New Issue