Compare commits

..
Author SHA1 Message Date
omicron 289a555cee Fix font and status bars to use new API arguments 2026-10-28 18:24:52 +01:00
omicron eaebe470b9 Add multiple spell ids support to AuraTrigger
Before AuraTrigger only supported a single spell id but now multiple
spells can activate the same trigger.

Related changes:
- Change the glue between AuraList and AuraTrigger to match this new functionality.
- Update the default frame config
2026-06-26 01:25:10 +02:00
omicron 8be0732930 Replace Trigger:SetState by Trigger:SetStateAndData
Update the use of the old API in most triggers except AuraTrigger. This
means the code isn't in a working state at this commit.
2026-06-25 21:58:04 +02:00
omicron 86e5ed78b0 Change the sort algorithm to use UnitExist instead of frame:IsShown
When UNIT_PET fires, pet units will exist but the UnitWatch will not yet
have shown the frame.
2026-06-24 00:37:15 +02:00
omicron 77ae4ddad3 Make UnitGroup trigger sort on UNIT_PET 2026-06-20 00:24:18 +02:00
omicron 5ac84782d2 Add raid pets to the hardcoded configuration 2026-06-20 00:21:25 +02:00
omicron 24a72cb02f Fixed typos and logic error in UnitFrame:Disable
This function is currently unused so these changes are not tested. The
Disable function now always hides the UnitFrame and calls
UnregisterUnitWatch with the correct parameters.
2026-03-18 02:41:39 +01:00
omicron 851fb5740b Fix type in AuraList:UpdateAura
Due to a typo AuraTrigger:UpdateAura always received nil as its first
(before) parameter. This parameter is currently unused so it did not
trigger an error.
2026-03-18 01:29:43 +01:00
omicron b9d16f5ba2 update config for TBC shaman play 2026-03-18 01:27:07 +01:00
omicron 90d71a54cf temporary enhancement hack: show debuffs in a suboptimal way
In new dungeons you don't really know what debuffs you want to see so
it's hard to configure them. To deal with this I added a quick but
suboptimal feature to show up to 5 debuffs automatically on the unit
frames. It's not great, but it's not terrible either. A hardcoded list
of debuffs to ignore is added too.
2026-03-07 13:21:12 +01:00
omicron abeac379f3 Enhance IconIndicator with tooltips, fix stacks/applications mixup 2026-03-07 13:17:25 +01:00
9 changed files with 345 additions and 115 deletions

No files matched your search

+84 -41
View File
@@ -21,6 +21,7 @@ local colors = {
white = { 1.0, 1.0, 1.0 },
orange = { 1.0, 0.5, 0 },
violet = { 1.0, 0, 1.0 },
yellow = { 1.0, 1.0, 0 },
magic = { 0.4, 0.4, 1.0 },
disease = { 0.4, 0.2, 0.0 },
poison = { 0.0, 0.7, 0.7 },
@@ -30,6 +31,19 @@ local colors = {
light_blue = { 0.7, 0.7, 1 },
}
---@param list number[]
---@return table<number, true>
local function set(list)
local s = {}
for _, v in ipairs(list) do
s[v] = true
end
return s
end
local AURAS_PRIEST_RENEW = set({ 139, 6074, 6075, 6076, 6077, 6078, 10927, 10928, 10929, 25315, 25221, 25222 })
local AURAS_PRIEST_PWS = set({ 17, 592, 600, 3747, 6065, 6066, 10898, 10899, 10900, 10901, 25217, 25218 })
local function RangeConfig()
local _, class = UnitClass("player")
if class == "SHAMAN" then
@@ -40,7 +54,7 @@ local function RangeConfig()
}
elseif class == "PRIEST" then
return {
friendly = "Flash Heal",
friendly = "Heal",
enemy = "Smite",
fade = 0.2,
}
@@ -61,25 +75,41 @@ local function MouseConfig()
button = "mouse2",
mods = {},
kind = "macro",
data = "/use [@UNIT,dead,help]Ancestral Vision; [@UNIT,help]Chain Heal",
data = "/use [@UNIT,dead,help]Ancestral Spirit; [@UNIT,help]Chain Heal",
},
{
button = "mouse3",
mods = {},
kind = "macro",
data = "/use [@UNIT,dead,help]Ancestral Spirit; [@UNIT,help]Purify Spirit",
data = "/use [@UNIT,help]Cure Poison",
},
{
button = "wheel-up",
mods = {},
kind = "macro",
data = "/use [@UNIT,help]Healing Surge",
data = "/use [@UNIT,help]Lesser Healing Wave",
},
{
button = "wheel-down",
mods = {},
kind = "macro",
data = "/use [@UNIT,help]Healing Wave",
},
{ button = "wheel-down", mods = {}, kind = "macro", data = "/use [@UNIT,help]Riptide" },
-- alt
{ button = "wheel-up", mods = { alt = true }, kind = "spell", data = "Healing Wave" },
{ button = "wheel-down", mods = { alt = true }, kind = "spell", data = "Earth Shield" },
{
button = "wheel-up",
mods = { alt = true },
kind = "macro",
data = "/use [@UNIT,help,nodead]Nature's Swiftness\n/use [@UNIT,help]Healing Wave",
},
{
button = "mouse3",
mods = { alt = true },
kind = "macro",
data = "/use [@UNIT,help]Cure Disease",
},
-- Shift
{ button = "mouse2", mods = { shift = true }, kind = "togglemenu" },
@@ -89,6 +119,12 @@ local function MouseConfig()
kind = "macro",
data = "/cast [@UNIT,help]Water Walking;\n/stopspelltarget",
},
{
button = "wheel-down",
mods = { shift = true },
kind = "macro",
data = "/use [@UNIT,help]Healing Wave(rank 1)",
},
}
elseif class == "PRIEST" then
return {
@@ -111,15 +147,15 @@ local function MouseConfig()
button = "wheel-up",
mods = {},
kind = "macro",
data = "/use [@UNIT,help]Flash Heal",
data = "/use [@UNIT,help]Lesser Heal",
},
{ button = "wheel-down", mods = {}, kind = "macro", data = "/use [@UNIT,help]Renew" },
{ button = "wheel-down", mods = {}, kind = "macro", data = "/use [@UNIT,help]Heal" },
-- alt
{ button = "mouse1", mods = { alt = true }, kind = "spell", data = "Power Word: Life" },
{ button = "mouse2", mods = { alt = true }, kind = "spell", data = "Pain Suppression" },
{ button = "mouse3", mods = { alt = true }, kind = "spell", data = "Power Infusion" },
{ button = "wheel-up", mods = { alt = true }, kind = "spell", data = "Rapture" },
{ button = "wheel-up", mods = { alt = true }, kind = "spell", data = "Renew" },
{ button = "wheel-down", mods = { alt = true }, kind = "spell", data = "Power Word: Shield" },
-- Shift
@@ -259,7 +295,7 @@ local function TriggerClassConfig()
return {
{
kind = "AuraTrigger",
spellId = 383648,
spellIds = set({ 32594 }),
own = true, -- Second Earth Shield on yourself
indicator = {
kind = "SquareIndicator",
@@ -273,29 +309,30 @@ local function TriggerClassConfig()
},
{
kind = "AuraTrigger",
spellId = 974,
own = true, -- Second Earth Shield on yourself
spellIds = set({ 29203 }),
own = true, -- Healing Way
indicator = {
kind = "SquareIndicator",
size = 17,
point = "TOPLEFT",
x = 3,
x = 20,
y = -3,
color = colors.white,
color = colors.yellow,
showStacks = true,
},
},
{
kind = "AuraTrigger",
spellId = 61295,
own = true, -- Riptide
spellIds = set({ 16237 }),
own = true, -- Ancestral Fortitude
indicator = {
kind = "IconIndicator",
kind = "SquareIndicator",
size = 17,
point = "BOTTOMLEFT",
x = 3,
y = 3,
fadeTime = 10.0,
point = "TOPLEFT",
x = 40,
y = -3,
color = colors.orange,
showStacks = false,
},
},
{
@@ -314,7 +351,7 @@ local function TriggerClassConfig()
return {
{
kind = "AuraTrigger",
spellId = 17,
spellIds = AURAS_PRIEST_PWS,
own = true, -- Power Word: Shield
indicator = {
kind = "SquareIndicator",
@@ -328,7 +365,7 @@ local function TriggerClassConfig()
},
{
kind = "AuraTrigger",
spellId = 33206,
spellIds = set({ 33206 }),
own = true, -- Pain Suppression
indicator = {
kind = "SquareIndicator",
@@ -343,7 +380,7 @@ local function TriggerClassConfig()
},
{
kind = "AuraTrigger",
spellId = 41635,
spellIds = set({ 41635 }),
own = true, -- Prayer of Mending
indicator = {
kind = "SquareIndicator",
@@ -357,7 +394,7 @@ local function TriggerClassConfig()
},
{
kind = "AuraTrigger",
spellId = 139,
spellIds = AURAS_PRIEST_RENEW,
own = true, -- Renew
indicator = {
kind = "SquareIndicator",
@@ -371,7 +408,7 @@ local function TriggerClassConfig()
},
{
kind = "AuraTrigger",
spellId = 194384,
spellIds = set({ 194384 }),
own = true, -- Atonement
indicator = {
kind = "SquareIndicator",
@@ -386,7 +423,7 @@ local function TriggerClassConfig()
},
{
kind = "AuraTrigger",
spellId = 10060,
spellIds = set({ 10060 }),
own = true, -- Power Infusion
indicator = {
kind = "SquareIndicator",
@@ -414,7 +451,7 @@ local function TriggerClassConfig()
return {
{
kind = "AuraTrigger",
spellId = 287280, -- Glimmer of Light
spellIds = set({ 287280 }), -- Glimmer of Light
own = true,
indicator = {
kind = "SquareIndicator",
@@ -429,7 +466,7 @@ local function TriggerClassConfig()
},
{
kind = "AuraTrigger",
spellId = 25771, -- Forbearance
spellIds = set({ 25771 }), -- Forbearance
indicator = {
kind = "SquareIndicator",
size = 17,
@@ -443,7 +480,7 @@ local function TriggerClassConfig()
},
{
kind = "AuraTrigger",
spellId = 53563, -- Beacon of Light
spellIds = set({ 53563 }), -- Beacon of Light
own = true,
indicator = {
kind = "SquareIndicator",
@@ -456,7 +493,7 @@ local function TriggerClassConfig()
},
{
kind = "AuraTrigger",
spellId = 156910, -- Beacon of Faith
spellIds = set({ 156910 }), -- Beacon of Faith
own = true,
indicator = {
kind = "SquareIndicator",
@@ -469,7 +506,7 @@ local function TriggerClassConfig()
},
{
kind = "AuraTrigger",
spellId = 200025, -- Beacon of Virtue
spellIds = set({ 200025 }), -- Beacon of Virtue
own = true,
indicator = {
kind = "SquareIndicator",
@@ -482,7 +519,7 @@ local function TriggerClassConfig()
},
{
kind = "AuraTrigger",
spellId = 1044, -- Blessing of Freedom
spellIds = set({ 1044 }), -- Blessing of Freedom
own = true,
indicator = {
kind = "SquareIndicator",
@@ -496,7 +533,7 @@ local function TriggerClassConfig()
},
{
kind = "AuraTrigger",
spellId = 1111, -- Blessing of Spellwarding
spellIds = set({ 1111 }), -- Blessing of Spellwarding
own = true,
indicator = {
kind = "SquareIndicator",
@@ -510,7 +547,7 @@ local function TriggerClassConfig()
},
{
kind = "AuraTrigger",
spellId = 1022, -- Blessing of Protection
spellIds = set({ 1022 }), -- Blessing of Protection
own = true,
indicator = {
kind = "SquareIndicator",
@@ -524,7 +561,7 @@ local function TriggerClassConfig()
},
{
kind = "AuraTrigger",
spellId = 6940, -- Blessing of Saccrifice
spellIds = set({ 6940 }), -- Blessing of Saccrifice
own = true,
indicator = {
kind = "SquareIndicator",
@@ -572,7 +609,7 @@ local function MakeDebuffTrigger(slot, spellid, color, stacks)
end
return {
kind = "AuraTrigger",
spellId = spellid,
spellIds = set({ spellid }),
indicator = {
kind = "SquareIndicator",
size = 15,
@@ -652,7 +689,7 @@ local function TriggerConfig()
-- Some more debuffs in the bottom row
table.insert(triggers, {
kind = "AuraTrigger",
spellId = 240443, -- Bursting
spellIds = set({ 240443 }), -- Bursting
indicator = {
kind = "SquareIndicator",
size = 17,
@@ -700,6 +737,8 @@ function CreateRaidFrames(left, top, config)
local num = i * 5 + j + 1
local frame = UnitFrame:new("raid" .. num, config)
group:AddUnitFrame(frame)
local raidpet = UnitFrame:new("raidpet" .. num, config)
group:AddUnitFrame(raidpet)
end
end
end
@@ -710,9 +749,13 @@ function CreatePartyFrames(left, top, config)
local group = UnitGroup:new(left, top, width, height)
local player = UnitFrame:new("player", config)
group:AddUnitFrame(player)
local pet = UnitFrame:new("pet", config)
group:AddUnitFrame(pet)
for i = 1, 4 do
local frame = UnitFrame:new("party" .. i, config)
group:AddUnitFrame(frame)
local partypet = UnitFrame:new("partypet" .. i, config)
group:AddUnitFrame(partypet)
end
group:Sort()
end
@@ -742,10 +785,10 @@ function CreateFrames()
triggers = TriggerConfig(),
}
CreatePartyFrames(-0.05, -290.05, config)
CreatePartyFrames(-0.05, -240.05, config)
config.hideInRaid = false
CreateRaidFrames(-0.05, -290.05, config)
CreateTargetFrames(110 * 3 + 50 - 0.05, -245.05, config)
CreateRaidFrames(-0.05, -240.05, config)
CreateTargetFrames(110 * 3 + 50 - 0.05, -240.05, config)
HideBlizzardFrames()
end
+25 -9
View File
@@ -16,6 +16,8 @@
-- Omicron Frames. If not, see <https://www.gnu.org/licenses/>.
local omi = select(2, ...)
local types = omi.GetModule("types")
local AuraTrigger = types.AuraTrigger
local StatusTrigger = types.StatusTrigger
--- AuraList keeps track of all the auras attached to a unitframe
---@class AuraList: Object
@@ -180,21 +182,35 @@ function AuraList:Init(unitframe)
self.triggersByStatus = {}
end
---@param trigger AuraTrigger | StatusTrigger
function AuraList:AddTrigger(trigger)
---@param trigger StatusTrigger
function AuraList:AddStatusTrigger(trigger)
table.insert(self.triggers, trigger)
local spellId = trigger.spellId
local status = trigger.status
if spellId then
if self.triggersByStatus[status] == nil then
self.triggersByStatus[status] = {}
end
table.insert(self.triggersByStatus[status], trigger)
end
---@param trigger AuraTrigger
function AuraList:AddAuraTrigger(trigger)
table.insert(self.triggers, trigger)
for spellId in pairs(trigger.spellIds) do
if self.triggersBySpell[spellId] == nil then
self.triggersBySpell[spellId] = {}
end
table.insert(self.triggersBySpell[spellId], trigger)
end
end
---@param trigger AuraTrigger | StatusTrigger
function AuraList:AddTrigger(trigger)
if trigger:IsInstanceOf(AuraTrigger) then
self:AddAuraTrigger(trigger)
elseif trigger:IsInstanceOf(StatusTrigger) then
self:AddStatusTrigger(trigger)
else
if self.triggersByStatus[status] == nil then
self.triggersByStatus[status] = {}
end
table.insert(self.triggersByStatus[status], trigger)
error("AddTrigger: trigger is neither an AuraTrigger nor a StatusTrigger")
end
end
@@ -269,7 +285,7 @@ end
---@param aura UnitAuraInfo
function AuraList:UpdateAura(aura)
for _, trigger in ipairs(self.triggersBySpell[aura.spellId] or {}) do
trigger:UpdateAura(self.auras[aura.auraInstanceId], aura)
trigger:UpdateAura(self.auras[aura.auraInstanceID], aura)
end
self.auras[aura.auraInstanceID] = aura
end
+52 -10
View File
@@ -46,7 +46,8 @@ end
---@param showStacks boolean
---@param doFade nil|number
---@param doFlash nil|number
function IconIndicator:Init(unitframe, size, point, x, y, showStacks, fadeTime, flashTime)
---@param showTooltip nil|boolean
function IconIndicator:Init(unitframe, size, point, x, y, showStacks, fadeTime, flashTime, showTooltip)
self.unitframe = unitframe
self.frameParent = unitframe.overlays
self.size = size
@@ -57,13 +58,21 @@ function IconIndicator:Init(unitframe, size, point, x, y, showStacks, fadeTime,
self.showStacks = showStacks
self.fadeTime = fadeTime
self.flashTime = flashTime
self.showTooltip = showTooltip or false
self.instanceId = 0
self.spellId = 0
end
--- Show the square indicator
---@param data table
function IconIndicator:Show(data)
local frame, stacks = self:GetFrame()
local numStacks = data.stacks or 0
local numStacks = data.applications or 0
self.auraInstanceID = data.auraInstanceID
self.spellId = data.spellId
self.frame = frame
self.stacks = stacks
if self.showStacks and numStacks > 0 then
@@ -77,12 +86,23 @@ function IconIndicator:Show(data)
self.expirationTime = data.expirationTime
self.updateThrottle = 0
end
if self.showTooltip then
frame:SetScript("OnEnter", function()
GameTooltip:SetOwner(frame, "ANCHOR_RIGHT")
GameTooltip:SetSpellByID(self.spellId)
GameTooltip:Show()
end)
frame:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
end
if data.icon then
self:SetIcon(data.icon)
else
self:SetIcon(self.icon)
end
frame:Show()
self:UpdateAlpha()
end
--- Set the icon of the Icon Indicator
@@ -131,22 +151,23 @@ function IconIndicator:Update(data)
if data.icon then
self:SetIcon(data.icon)
end
local numStacks = data.stacks or 0
local numStacks = data.applications or 0
if numStacks > 0 then
self.stacks:SetText(numStacks)
self.stacks:Show()
end
self.expirationTime = data.expirationTime
self.frame:SetAlpha(1)
self.auraInstanceID = data.auraInstanceID
self.spellId = data.spellId
self:UpdateAlpha()
end
function IconIndicator:OnUpdate(dt)
dt = self.updateThrottle + dt
if dt < 0.04 then
self.updateThrottle = dt
function IconIndicator:UpdateAlpha()
if self.expirationTime == 0 then
self.frame:SetAlpha(1)
return
else
self.updateThrottle = 0
end
local timeLeft = self.expirationTime - GetTime()
@@ -159,15 +180,36 @@ function IconIndicator:OnUpdate(dt)
elseif timeLeft < fadeTime then
local alpha = timeLeft / fadeTime
self.frame:SetAlpha(alpha)
else
self.frame:SetAlpha(1)
end
end
function IconIndicator:OnUpdate(dt)
dt = self.updateThrottle + dt
if dt < 0.04 then
self.updateThrottle = dt
return
else
self.updateThrottle = 0
end
self:UpdateAlpha()
end
--- Hide the square indicator.
function IconIndicator:Hide()
local frame = self.frame
if frame == nil then
return
end
self.stacks:Hide()
self.frame = nil
self.stacks = nil
self.instanceId = nil
self.spellId = nil
frame:SetScript("OnUpdate", nil)
frame:SetScript("OnLeave", nil)
frame:SetScript("OnEnter", nil)
iconPool:Release(frame)
end
+66 -24
View File
@@ -21,7 +21,7 @@ local Trigger = types.Trigger
---AuraTrigger is a Trigger that can be attached to AuraList as datasource
---@class AuraTrigger: Trigger
---@field spellId number
---@field spellIds table<number, true>
---@field count number
---@field requiredCount number
local AuraTrigger = types.CreateClass("AuraTrigger", Trigger)
@@ -33,7 +33,8 @@ types.AuraTrigger = AuraTrigger
---@param config table
---@return AuraTrigger
function AuraTrigger.CreateFromConfig(unit, config)
local trigger = AuraTrigger:new(config.spellId, config.own, config.requiredCount, config.invert, config.defaultData)
local trigger =
AuraTrigger:new(config.spellIds, config.own, config.requiredCount, config.invert, config.defaultData)
unit.auras:AddTrigger(trigger)
return trigger
end
@@ -47,29 +48,33 @@ function AuraTrigger.new(cls, ...)
end
--- Initialize a new AuraTrigger object
---@param spellId number
---@param spellIds table<number, true>
---@param own boolean
---@param requiredCount number | nil
---@param invert boolean | nil
---@param defaultData table | nil
function AuraTrigger:Init(spellId, own, requiredCount, invert, defaultData)
function AuraTrigger:Init(spellIds, own, requiredCount, invert, defaultData)
Trigger.Init(self, invert, defaultData)
self.spellId = spellId
self.spellIds = spellIds
self.instanceData = {}
self.requiredCount = requiredCount or 1
self.own = own
self.count = 0
self.bestAuraID = nil
end
--- Reset the AuraTrigger to the default state
function AuraTrigger:Reset()
self.count = 0
self:SetState(self.count >= self.requiredCount, false)
self.bestAuraID = nil
table.wipe(self.instanceData)
self:SetStateAndData(self.count >= self.requiredCount, {})
end
---Check if a given aura matches this AuraTrigger
---@param aura UnitAuraInfo
function AuraTrigger:IsMatching(aura)
if aura.spellId ~= aura.spellId then
if not self.spellIds[aura.spellId] then
return false
end
if self.own and aura.sourceUnit ~= "player" then
@@ -78,35 +83,68 @@ function AuraTrigger:IsMatching(aura)
return true
end
-- Get the ID of the current best matching aura in AuraTrigger.instanceData
function AuraTrigger:BestAuraID()
local found = nil
for k, v in pairs(self.instanceData) do
if not found then
found = k
elseif v.expirationTime > self.instanceData[found].expirationTime then
found = k
end
end
return found
end
---Grab the best aura data and update the current recorded best aura
---It returns data if the current best aura is different from the previous
---@param updatedInstanceId number|nil the aura id that was recently updated
function AuraTrigger:BestAuraData(updatedInstanceId)
local bid = self:BestAuraID()
if bid == nil then
self.bestAuraID = nil
return nil
end
local data = nil
if bid ~= self.bestAuraID or (updatedInstanceId and bid == updatedInstanceId) then
local aura = self.instanceData[bid]
data = {
stacks = aura.applications,
duration = aura.duration,
expirationTime = aura.expirationTime,
icon = aura.icon,
}
self.bestAuraID = bid
end
return data
end
---Inform the trigger about an added aura
---@param aura UnitAuraInfo
function AuraTrigger:AddAura(aura)
if not self:IsMatching(aura) then
return
end
local aid = aura.auraInstanceID
self.instanceData[aid] = aura
self.count = self.count + 1
self:SetData({
stacks = aura.applications,
duration = aura.duration,
expirationTime = aura.expirationTime,
icon = aura.icon,
})
self:SetState(self.count >= self.requiredCount, false)
local newData = self:BestAuraData(nil)
self:SetStateAndData(self.count >= self.requiredCount, newData)
end
---Inform the trigger about an updated aura
---@param before UnitAuraInfo
---@param after UnitAuraInfo
function AuraTrigger:UpdateAura(before, after)
self:SetData({
stacks = after.applications,
duration = after.duration,
expirationTime = after.expirationTime,
icon = after.icon,
})
if self.active then
self.indicator:Update(self.data)
if not self:IsMatching(after) then
return
end
local aid = after.auraInstanceID
self.instanceData[aid] = after
local newData = self:BestAuraData(aid)
self:SetStateAndData(self.count >= self.requiredCount, newData)
end
---Inform the trigger about an aura that got removed
@@ -115,7 +153,11 @@ function AuraTrigger:RemoveAura(aura)
if not self:IsMatching(aura) then
return
end
local aid = aura.auraInstanceID
self.instanceData[aid] = nil
self.count = self.count - 1
self:SetData({})
self:SetState(self.count >= self.requiredCount, false)
local newData = self:BestAuraData(nil)
self:SetStateAndData(self.count >= self.requiredCount, newData)
end
+4 -7
View File
@@ -92,8 +92,7 @@ function MultiTrigger:OnChildActivate(idx, trigger, data)
table.sort(activeChildren)
-- The highest priority active trigger has changed
if activeChild ~= activeChildren[1] then
self:SetData(data)
self:SetState(true, true)
self:SetStateAndData(true, data)
end
end
@@ -117,11 +116,9 @@ function MultiTrigger:OnChildDeactivate(idx, trigger, data)
local newActiveChild = activeChildren[1]
if activeChild ~= newActiveChild then
if activeChildren[1] ~= nil then
self:SetData(childrenData[newActiveChild])
self:SetState(true, true)
self:SetStateAndData(true, childrenData[newActiveChild])
else
self:SetData({})
self:SetState(false, false)
self:SetStateAndData(false, {})
end
end
end
@@ -139,5 +136,5 @@ end
-- Reset the trigger to the default state. If this changes the activation of the
-- trigger then the target will be notified.
function MultiTrigger:Reset()
self:SetState(false)
self:SetStateAndData(false, {})
end
+1 -1
View File
@@ -58,5 +58,5 @@ end
-- status:
-- Must be a valid UnitAuraInfo
function StatusTrigger:UpdateStatus(count)
self:SetState(count >= self.requiredCount, false)
self:SetStateAndData(count >= self.requiredCount, nil)
end
+18 -4
View File
@@ -47,7 +47,9 @@ function Trigger:Init(invert, defaultData)
end
---Save new data from the datasource into the trigger. This method will make
---sure the default data is always present
---sure the default data is always present. This method will not ensure the
---target gets notified of new state or new data. Subclasses of Trigger should
---use Trigger:SetStateAndData instead.
---@param data table
function Trigger:SetData(data)
if self.defaultData then
@@ -69,9 +71,21 @@ function Trigger:SetTarget(target)
end
end
---Set the state of the trigger. Will activate the indicator if needed.
---Set the data and state of the trigger. Will update the trigger as needed.
---
--- If the state changes this function will call Show or Hide on the indicator.
--- If the state remains the same and the data is not nil, it will call Update
--- on the indicator.
---
---@param state boolean
function Trigger:SetState(state, doUpdate)
---@param data table|nil
function Trigger:SetStateAndData(state, data)
local doUpdate = false
if data then
doUpdate = true
self:SetData(data)
end
state = state ~= self.invert -- state xor inverted
if self.active ~= state then
if state then
@@ -88,5 +102,5 @@ end
-- Reset the trigger to the default state. If this changes the activation of the
-- trigger then the target will be notified.
function Trigger:Reset()
self:SetState(false, false)
self:SetStateAndData(false, nil)
end
+83 -8
View File
@@ -17,6 +17,11 @@
local omif = select(2, ...)
local types = omif.GetModule("types")
local NameFont = CreateFont("OicronFrames_NameFont")
NameFont:SetFont("Interface\\AddOns\\OmicronFrames\\media\\fonts\\roboto\\Roboto-Bold.ttf", 13, "")
NameFont:SetShadowColor(0, 0, 0)
NameFont:SetShadowOffset(1, -1)
---@class StatusBar
local StatusBar = types.StatusBar
@@ -101,13 +106,13 @@ function UnitFrame:Init(unit, config)
self.absorb = StatusBar:new(self, width, height, 1, true, texture_top)
self.absorb:SetColor(unpack(colors.absorb))
self.absorb:SetFillStyle("REVERSE")
self.absorb:SetFillStyle(Enum.StatusBarFillStyle.Reverse)
self.shield = StatusBar:new(self, width, height, 1, true, texture_bot)
self.shield:SetColor(unpack(colors.shield))
self.shield:SetRange(0, 1)
self.shield:SetValue(0.6)
self.shield:SetFillStyle("REVERSE")
self.shield:SetFillStyle(Enum.StatusBarFillStyle.Reverse)
self.auras = AuraList:new(self)
@@ -121,6 +126,8 @@ function UnitFrame:Init(unit, config)
self:CreateTriggers(config.triggers)
self:InitDebuffs()
self:RegisterEvents()
self:Enable()
end
@@ -182,10 +189,8 @@ function UnitFrame:CreateName()
local name = self.overlays:CreateFontString(nil, "BACKGROUND")
self.name = name
name:SetFont("Interface\\AddOns\\OmicronFrames\\media\\fonts\\roboto\\Roboto-Bold.ttf", 13, "")
name:SetFontObject(NameFont)
name:SetTextColor(0.8, 0.6, 0.1)
name:SetShadowColor(0, 0, 0)
name:SetShadowOffset(1, -1)
name:SetPoint("CENTER")
name:SetText("")
name:Show()
@@ -389,10 +394,9 @@ function UnitFrame:Disable()
if self.hideInRaid then
UnregisterAttributeDriver(self.secureFrame, "state-visibility")
elseif self.unit ~= "player" then
UnregisterUnitWatch(self.secure_frame, self.condition)
else
self.secureFrame:Hide()
UnregisterUnitWatch(self.secureFrame, false)
end
self.secureFrame:Hide()
end
-- returns true if this unit is a target unit
@@ -489,6 +493,74 @@ function UnitFrame:GROUP_ROSTER_UPDATE()
end
end
-- FIXME: This is a total hack job, just quickly want to get debuffs rendering on my unit frames to learn new dungeons
function UnitFrame:InitDebuffs()
local icons = {}
self.debuffIndicators = icons
for i = 1, 5 do
local icon = IconIndicator:new(self, 17, "BOTTOMRIGHT", -2 - (i - 1) * 19, 2, true, 10.0, nil, true)
icons[i] = icon
end
end
local ignoredDebuffs = {
[57723] = true, -- Sated, shaman lust debuff (alliance)
[57724] = true, -- Sated, shaman lust debuff (horde)
[80354] = true, -- Temporal displacement
[390435] = true, -- Exhausstion
[264689] = true, -- Fatigued
[87024] = true, -- Cauterized
[45181] = true, -- Cheated Death
[41425] = true, -- hypothermia
[124275] = true, -- Light stagger
[124274] = true, -- moderate stagger
[124273] = true, -- heavy stagger
[25771] = true, -- Forbearance
[456447] = true, -- Battle-Scarred Veteran
[382912] = true, -- Well-Honed Instincts
[1223611] = true, -- Ethereal Exhaustion
[456779] = true, -- Will of the Dawn
[448005] = true, -- Light of the Martyr
[157131] = true, -- Recently Saved by the Light
[387847] = true,
[206151] = true, -- Challenger's Burden
[113942] = true, -- Demonic Gateway
[1216943] = true, -- void pulsar
[462661] = true, -- Voidbinding
[1239229] = true, -- k'areshi surge
[449042] = true, -- Radiant Light
-- blood draw
}
function UnitFrame:UpdateDebuffs()
local auras = {}
local i = 1
while #auras < 5 do
local aura = C_UnitAuras.GetAuraDataByIndex(self.unit, i, "HARMFUL")
if aura == nil then
break
end
if not ignoredDebuffs[aura.spellId] then
table.insert(auras, aura)
end
i = i + 1
end
for i = 1, 5 do
local aura = auras[i]
local icon = self.debuffIndicators[i]
if aura then
if icon.frame then
icon:Update(aura)
else
icon:Show(aura)
end
elseif icon.frame then
icon:Hide()
end
end
end
function UnitFrame:UNIT_AURA(unit, info)
if self:HasUnitChanged() then
self:UpdateAll(true)
@@ -497,6 +569,8 @@ function UnitFrame:UNIT_AURA(unit, info)
if self.auras:Update(info) then
self:UpdateHealthColor()
end
self:UpdateDebuffs()
end
function UnitFrame:UNIT_HEALTH()
@@ -600,6 +674,7 @@ function UnitFrame:UpdateAll(unitChanged)
self:UpdateRange()
self:UpdateName()
self:UpdateRole() -- Also calls UpdatePower if power is visible
self:UpdateDebuffs()
end
function UnitFrame:UpdateHealth()
+12 -11
View File
@@ -32,9 +32,10 @@ local function RoleValue(role)
end
local function UnitFrameDefaultCompare(lhs, rhs)
-- visible < invisible
if lhs.secureFrame:IsShown() ~= rhs.secureFrame:IsShown() then
return lhs.secureFrame:IsShown()
-- exists < not exists
local lexists, rexists = UnitExists(lhs.unit), UnitExists(rhs.unit)
if lexists ~= rexists then
return lexists
end
local lunit, runit = lhs.unit, rhs.unit
@@ -69,7 +70,6 @@ function UnitGroup:Init(left, top, width, height)
self.top = top
self.left = left
self.units = {}
self.sortAfterCombat = false
self:RegisterEvents()
end
@@ -84,6 +84,7 @@ function UnitGroup:RegisterEvents()
frame:RegisterEvent("GROUP_ROSTER_UPDATE")
frame:RegisterEvent("PLAYER_REGEN_ENABLED")
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
frame:RegisterEvent("UNIT_PET")
end
function UnitGroup:GROUP_ROSTER_UPDATE()
@@ -94,23 +95,23 @@ function UnitGroup:PLAYER_ENTERING_WORLD()
self:OnRosterUpdate()
end
function UnitGroup:UNIT_PET()
self:OnRosterUpdate()
end
function UnitGroup:PLAYER_REGEN_ENABLED()
self:OnLeaveCombat()
end
function UnitGroup:OnLeaveCombat()
if self.sortAfterCombat then
self:Sort()
self.sortAfterCombat = false
end
self:Sort()
end
function UnitGroup:OnRosterUpdate()
if InCombatLockdown() then
self.sortAfterCombat = true
else
self:Sort()
return
end
self:Sort()
end
function UnitGroup:AddUnitFrame(unit)