@@ -2,8 +2,8 @@ local E, L, V, P, G = unpack(ElvUI)
22local UF = E :GetModule (' UnitFrames' )
33local ElvUF = E .oUF
44
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
77local type , pairs , min , random , strfind , next = type , pairs , min , random , strfind , next
88
99local UnitName = UnitName
@@ -35,13 +35,24 @@ local attributeBlacklist = {
3535 showSolo = true
3636}
3737
38- local colorTags = {
38+ local allowTags = {
39+ dead = true ,
40+ ghost = true ,
41+ status = true ,
42+ resting = true ,
43+ offline = true ,
3944 healthcolor = true ,
4045 powercolor = true ,
4146 classcolor = true ,
4247 namecolor = true
4348}
4449
50+ local statusChanceDefault = 10
51+ local statusChance = {
52+ UnitIsConnected = 15 , -- less likely
53+ UnitIsDeadOrGhost = 5 -- more likely
54+ }
55+
4556local PowerType = Enum .PowerType
4657local classPowers = {
4758 [0 ] = PowerType .Mana ,
@@ -76,10 +87,30 @@ local function envUnit(arg1)
7687 end
7788end
7889
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+
79106local function createConfigEnv ()
80107 if configEnv then return end
81108
82- configEnv = setmetatable ({
109+ UF .ConfigEnv = {
110+ Env = ElvUF .Tags .Env ,
111+ _VARS = ElvUF .Tags .Vars ,
112+ _COLORS = ElvUF .colors ,
113+ ColorGradient = ElvUF .ColorGradient ,
83114 UnitPower = function (arg1 , displayType )
84115 local unit , real = envUnit (arg1 )
85116 if real then
@@ -128,27 +159,29 @@ local function createConfigEnv()
128159
129160 local classToken = CLASS_SORT_ORDER [random (1 , NUM_CLASS_ORDER )]
130161 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 , {
137170 __index = function (obj , key )
138171 local envValue = ElvUF .Tags .Env [key ]
139172 if envValue ~= nil then
140173 return envValue
141174 end
142175
143- return obj [ key ]
176+ return rawget ( obj , key )
144177 end ,
145- __newindex = function (_ , key , value )
146- _G [ key ] = value
178+ __newindex = function (obj , key , value )
179+ rawset ( obj , key , value )
147180 end ,
148181 })
149182
150183 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
152185 overrideFuncs [tag ] = func
153186 end
154187 end
0 commit comments