@@ -2,8 +2,8 @@ local E, L, V, P, G = unpack(ElvUI)
2
2
local UF = E :GetModule (' UnitFrames' )
3
3
local ElvUF = E .oUF
4
4
5
- local _G = _G
6
- local setmetatable , getfenv , setfenv = setmetatable , getfenv , setfenv
5
+ local _G , getfenv , setfenv = _G , getfenv , setfenv
6
+ local setmetatable , rawget , rawset = setmetatable , rawget , rawset
7
7
local type , pairs , min , random , strfind , next = type , pairs , min , random , strfind , next
8
8
9
9
local UnitName = UnitName
@@ -35,13 +35,24 @@ local attributeBlacklist = {
35
35
showSolo = true
36
36
}
37
37
38
- local colorTags = {
38
+ local allowTags = {
39
+ dead = true ,
40
+ ghost = true ,
41
+ status = true ,
42
+ resting = true ,
43
+ offline = true ,
39
44
healthcolor = true ,
40
45
powercolor = true ,
41
46
classcolor = true ,
42
47
namecolor = true
43
48
}
44
49
50
+ local statusChanceDefault = 10
51
+ local statusChance = {
52
+ UnitIsConnected = 15 , -- less likely
53
+ UnitIsDeadOrGhost = 5 -- more likely
54
+ }
55
+
45
56
local PowerType = Enum .PowerType
46
57
local classPowers = {
47
58
[0 ] = PowerType .Mana ,
@@ -76,10 +87,30 @@ local function envUnit(arg1)
76
87
end
77
88
end
78
89
90
+ local function generateStatusFunc (tag )
91
+ return function (arg1 )
92
+ local unit , real = envUnit (arg1 )
93
+ if real then
94
+ return _G [tag ](unit )
95
+ end
96
+
97
+ local chance = random (1 , statusChance [tag ] or statusChanceDefault )
98
+ if tag == ' UnitIsConnected' then
99
+ return chance ~= 1
100
+ else
101
+ return chance == 1
102
+ end
103
+ end
104
+ end
105
+
79
106
local function createConfigEnv ()
80
107
if configEnv then return end
81
108
82
- configEnv = setmetatable ({
109
+ UF .ConfigEnv = {
110
+ Env = ElvUF .Tags .Env ,
111
+ _VARS = ElvUF .Tags .Vars ,
112
+ _COLORS = ElvUF .colors ,
113
+ ColorGradient = ElvUF .ColorGradient ,
83
114
UnitPower = function (arg1 , displayType )
84
115
local unit , real = envUnit (arg1 )
85
116
if real then
@@ -128,27 +159,29 @@ local function createConfigEnv()
128
159
129
160
local classToken = CLASS_SORT_ORDER [random (1 , NUM_CLASS_ORDER )]
130
161
return LOCALIZED_CLASS_NAMES_MALE [classToken ], classToken
131
- end ,
132
- Env = ElvUF .Tags .Env ,
133
- _VARS = ElvUF .Tags .Vars ,
134
- _COLORS = ElvUF .colors ,
135
- ColorGradient = ElvUF .ColorGradient ,
136
- }, {
162
+ end
163
+ }
164
+
165
+ for _ , name in next , { ' IsResting' , ' UnitIsDead' , ' UnitIsGhost' , ' UnitIsDeadOrGhost' , ' UnitIsConnected' } do
166
+ UF .ConfigEnv [name ] = generateStatusFunc (name )
167
+ end
168
+
169
+ configEnv = setmetatable (UF .ConfigEnv , {
137
170
__index = function (obj , key )
138
171
local envValue = ElvUF .Tags .Env [key ]
139
172
if envValue ~= nil then
140
173
return envValue
141
174
end
142
175
143
- return obj [ key ]
176
+ return rawget ( obj , key )
144
177
end ,
145
- __newindex = function (_ , key , value )
146
- _G [ key ] = value
178
+ __newindex = function (obj , key , value )
179
+ rawset ( obj , key , value )
147
180
end ,
148
181
})
149
182
150
183
for tag , func in next , ElvUF .Tags .Methods do
151
- if colorTags [tag ] or UF .overrideTags [tag ] or (strfind (tag , ' ^name:' ) or strfind (tag , ' ^health:' ) or strfind (tag , ' ^power:' )) then
184
+ if allowTags [tag ] or UF .overrideTags [tag ] or (strfind (tag , ' ^name:' ) or strfind (tag , ' ^health:' ) or strfind (tag , ' ^power:' )) then
152
185
overrideFuncs [tag ] = func
153
186
end
154
187
end
0 commit comments