Skip to content

Commit bac78d3

Browse files
committed
Merge branch 'main' into ptr
2 parents 88789d9 + 12c75a0 commit bac78d3

File tree

6 files changed

+85
-42
lines changed

6 files changed

+85
-42
lines changed

ElvUI/Core/Defaults/Global.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ G.datatexts = {
9797
Parry = { decimalLength = 1 },
9898
Block = { decimalLength = 1 },
9999
['Mana Regen'] = { Label = '', NoLabel = false, decimalLength = 1 },
100-
HealPower = { Label = '', NoLabel = false }
100+
HealPower = { Label = '', NoLabel = false },
101+
['Spell Hit'] = { Label = '', NoLabel = false, decimalLength = 0 }
101102
},
102103
newPanelInfo = {
103104
growth = 'HORIZONTAL',

ElvUI/Core/General/Tags.lua

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,8 @@ local UnitGUID = UnitGUID
4444
local UnitHealthMax = UnitHealthMax
4545
local UnitIsAFK = UnitIsAFK
4646
local UnitIsBattlePetCompanion = UnitIsBattlePetCompanion
47-
local UnitIsConnected = UnitIsConnected
48-
local UnitIsDead = UnitIsDead
49-
local UnitIsDeadOrGhost = UnitIsDeadOrGhost
5047
local UnitIsDND = UnitIsDND
5148
local UnitIsFeignDeath = UnitIsFeignDeath
52-
local UnitIsGhost = UnitIsGhost
5349
local UnitIsPlayer = UnitIsPlayer
5450
local UnitIsPVP = UnitIsPVP
5551
local UnitIsPVPFreeForAll = UnitIsPVPFreeForAll
@@ -79,7 +75,7 @@ local SPEC_MONK_BREWMASTER = SPEC_MONK_BREWMASTER
7975
local PVP = PVP
8076

8177
-- GLOBALS: Hex, _TAGS, _COLORS -- added by oUF
82-
-- GLOBALS: UnitPower, UnitHealth, UnitName, UnitClass -- override during testing groups
78+
-- GLOBALS: UnitPower, UnitHealth, UnitName, UnitClass, UnitIsDead, UnitIsGhost, UnitIsDeadOrGhost, UnitIsConnected -- override during testing groups
8379
-- GLOBALS: GetTitleNPC, Abbrev, GetClassPower, GetQuestData, UnitEffectiveLevel, NameHealthColor -- custom ones we made
8480

8581
local RefreshNewTags -- will turn true at EOF

ElvUI/Core/Modules/DataTexts/SpellHit.lua

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,24 @@ local GetCombatRatingBonus = GetCombatRatingBonus
88
local STAT_CATEGORY_ENHANCEMENTS = STAT_CATEGORY_ENHANCEMENTS
99
local CR_HIT_SPELL = CR_HIT_SPELL
1010

11-
local displayString = ''
11+
local displayString, db = ''
1212

1313
local function OnEvent(self)
14-
self.text:SetFormattedText(displayString, E.Classic and GetSpellHitModifier() or GetCombatRatingBonus(CR_HIT_SPELL) or 0)
14+
local spellHit = E.Classic and GetSpellHitModifier() or GetCombatRatingBonus(CR_HIT_SPELL) or 0
15+
16+
if db.NoLabel then
17+
self.text:SetFormattedText(displayString, spellHit)
18+
else
19+
self.text:SetFormattedText(displayString, db.Label ~= '' and db.Label or L["Spell Hit"]..': ', spellHit)
20+
end
1521
end
1622

17-
local function ApplySettings(_, hex)
18-
displayString = strjoin('', L["Spell Hit"], ': ', hex, '%.2f%%|r')
23+
local function ApplySettings(self, hex)
24+
if not db then
25+
db = E.global.datatexts.settings[self.name]
26+
end
27+
28+
displayString = strjoin('', db.NoLabel and '' or '%s', hex, '%.'..db.decimalLength..'f%%|r')
1929
end
2030

2131
DT:RegisterDatatext('Spell Hit', STAT_CATEGORY_ENHANCEMENTS, { 'UNIT_STATS', 'UNIT_AURA' }, OnEvent, nil, nil, nil, nil, L["Spell Hit"], nil, ApplySettings)

ElvUI/Core/Modules/Nameplates/StyleFilter.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,8 +998,8 @@ function NP:StyleFilterConditionCheck(frame, filter, trigger)
998998
end
999999

10001000
-- My Role
1001-
if trigger.role and (trigger.role.tank or trigger.role.healer or trigger.role.damager) then
1002-
if trigger.role[NP.TriggerConditions.roles[E.myrole]] then passed = true else return end
1001+
if trigger.myRole and (trigger.myRole.tank or trigger.myRole.healer or trigger.myRole.damager) then
1002+
if trigger.myRole[NP.TriggerConditions.roles[E.myrole]] then passed = true else return end
10031003
end
10041004

10051005
-- Unit Type

ElvUI/Core/Modules/UnitFrames/ConfigEnviroment.lua

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ local E, L, V, P, G = unpack(ElvUI)
22
local UF = E:GetModule('UnitFrames')
33
local 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
77
local type, pairs, min, random, strfind, next = type, pairs, min, random, strfind, next
88

99
local 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+
4556
local PowerType = Enum.PowerType
4657
local classPowers = {
4758
[0] = PowerType.Mana,
@@ -76,10 +87,30 @@ local function envUnit(arg1)
7687
end
7788
end
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+
79106
local 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

ElvUI/Core/Modules/UnitFrames/Elements/Health.lua

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ local E, L, V, P, G = unpack(ElvUI)
22
local UF = E:GetModule('UnitFrames')
33
local ElvUF = E.oUF
44

5+
local _G = _G
56
local random = random
67
local strmatch = strmatch
8+
79
local CreateFrame = CreateFrame
10+
local UnitInPartyIsAI = UnitInPartyIsAI
11+
local UnitIsCharmed = UnitIsCharmed
12+
local UnitIsEnemy = UnitIsEnemy
13+
local UnitIsFriend = UnitIsFriend
14+
local UnitIsPlayer = UnitIsPlayer
815
local UnitIsTapDenied = UnitIsTapDenied
916
local UnitReaction = UnitReaction
10-
local UnitIsPlayer = UnitIsPlayer
1117
local UnitClass = UnitClass
12-
local UnitIsConnected = UnitIsConnected
13-
local UnitIsDeadOrGhost = UnitIsDeadOrGhost
14-
local UnitIsCharmed = UnitIsCharmed
15-
local UnitIsFriend = UnitIsFriend
16-
local UnitIsEnemy = UnitIsEnemy
17-
local UnitInPartyIsAI = UnitInPartyIsAI
1818

1919
local BACKDROP_MULT = 0.35
2020

@@ -252,19 +252,25 @@ local HOSTILE_REACTION = 2
252252
function UF:PostUpdateHealthColor(unit, r, g, b)
253253
local parent = self:GetParent()
254254
local colors = E.db.unitframe.colors
255+
local env = (parent.isForced and UF.ConfigEnv) or _G
255256

256257
local isTapped = UnitIsTapDenied(unit)
257-
local isDeadOrGhost = UnitIsDeadOrGhost(unit)
258+
local isDeadOrGhost = env.UnitIsDeadOrGhost(unit)
258259
local healthBreak = not isTapped and colors.healthBreak
259260

260261
local color -- main bar
261262
if not b then
262263
r, g, b = colors.health.r, colors.health.g, colors.health.b
263264
end
264265

266+
-- Recheck offline status when forced
267+
if parent.isForced and self.colorDisconnected and not env.UnitIsConnected(unit) then
268+
color = parent.colors.disconnected
269+
end
270+
265271
-- Charmed player should have hostile color
266272
if unit and (strmatch(unit, 'raid%d+') or strmatch(unit, 'party%d+')) then
267-
if not isDeadOrGhost and UnitIsConnected(unit) and UnitIsCharmed(unit) and UnitIsEnemy('player', unit) then
273+
if not isDeadOrGhost and env.UnitIsConnected(unit) and UnitIsCharmed(unit) and UnitIsEnemy('player', unit) then
268274
color = parent.colors.reaction[HOSTILE_REACTION]
269275
end
270276
end
@@ -339,14 +345,11 @@ end
339345
function UF:PostUpdateHealth(_, cur)
340346
local parent = self:GetParent()
341347
if parent.isForced then
342-
cur = random(1, 100)
343-
local max = 100
344-
345-
self.cur = cur
346-
self.max = max
348+
self.cur = random(1, 100)
349+
self.max = 100
347350

348-
self:SetMinMaxValues(0, max)
349-
self:SetValue(cur)
351+
self:SetMinMaxValues(0, self.max)
352+
self:SetValue(self.cur)
350353
elseif parent.ResurrectIndicator then
351354
parent.ResurrectIndicator:SetAlpha(cur == 0 and 1 or 0)
352355
end

0 commit comments

Comments
 (0)