-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLCcfg.lua
More file actions
98 lines (94 loc) · 2.89 KB
/
LCcfg.lua
File metadata and controls
98 lines (94 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
LCcfgStore = type(LCcfgStore)=='table' and LCcfgStore or {};
local defaultDisabledWatches = {
slow = true,
falling = true
}
local defaultCfgs = {
instanceChat = 'INSTANCE_CHAT',
oomBreakpoint = 15,
raidChat = 'RAID',
minDebuffTime = 3
}
local getDebuffTimeKey = function(dbType)
local key = 'minDebuffTime';
if (dbType == nil or dbType == '') then
return key;
end
return key..'_'..LCU.str(dbType);
end
LCcfg = {
get = function(name,ifNil,allowBlankString)
if(type(allowBlankString)~='boolean') then allowBlankString = true; end
local role = LCcfg.getPlayerSpecRole();
local ret = (type(LCcfgStore[role])=='table') and LCcfgStore[role][name] or nil;
if(ret==nil) then ret = defaultCfgs[name]; end
if(ret==nil or (type(ret)=='string' and allowBlankString==false and LCU.trim(ret)=='')) then return ifNil;
else return ret; end
end
,checkPlayerSpec = function()
if(LCU.player.spec==nil or LCU.player.spec.name==nil or LCU.player.spec.role==nil) then LCU.player.updateSpec(); end
end
,getPlayerSpecName = function()
LCcfg.checkPlayerSpec();
return (LCU.player.spec and LCU.player.spec.name) and LCU.player.spec.name or 'unknown';
end
,getPlayerSpecRole = function()
LCcfg.checkPlayerSpec();
return (LCU.player.spec and LCU.player.spec.role) and LCU.player.spec.role or 'unknown';
end
,set = function(name,val)
local role = LCcfg.getPlayerSpecRole();
if(role ~= 'unknown') then
if(LCcfgStore[role]==nil) then LCcfgStore[role] = {}; end
LCcfgStore[role][name] = val;
end
end
,setDefault = function(name,val)
if(LCcfg.get(name)==nil) then LCcfg.set(name,val); end
end
,getDisabledWatches = function()
local disabledWatches = LCcfg.get('disabledWatches');
if(disabledWatches == nil) then
disabledWatches = LCU.cloneTable(defaultDisabledWatches);
LCcfg.set('disabledWatches', disabledWatches);
end
return disabledWatches;
end
,disableWatch = function(dbType,val)
LCcfg.getDisabledWatches()[dbType] = LCU.tern(val == true, true, nil);
end
,setMinDebuffTime = function(value, dbType)
if (dbType == nil or dbType == '') then
if (type(value)~='number') then
value = defaultCfgs.minDebuffTime;
end
LCcfg.set(getDebuffTimeKey(), value);
end
if (string.lower(LCU.str(value)) == 'global') then
value = nil;
end
dbType = LCU.str(dbType);
LCcfg.set(getDebuffTimeKey(dbType), value);
end
,getMinDebuffTime = function(dbType, globalFallback)
local globalCfg = LCcfg.get(getDebuffTimeKey(), 3);
if (dbType == nil or dbType == '') then
return globalCfg;
end
dbType = LCU.str(dbType);
local typeCfg = LCcfg.get(getDebuffTimeKey(dbType), nil);
if (typeCfg ~= nil or globalFallback == false) then
return typeCfg;
elseif (globalFallback ~= false) then
return globalCfg;
end
end
,watching = function(dbType)
return LCcfg.getDisabledWatches()[dbType] ~= true;
end
,setDefaults = function()
end
,init = function()
LCcfg.setDefaults();
end
}