Implement fade and flash behavior for square indicators

This commit is contained in:
2023-07-28 14:15:50 +02:00
parent 877560cb58
commit e20887d46b
4 changed files with 298 additions and 124 deletions

View File

@@ -26,6 +26,7 @@ local colors = {
poison = { 0.0, 0.7, 0.7 }, poison = { 0.0, 0.7, 0.7 },
curse = { 0.7, 0.0, 0.7 }, curse = { 0.7, 0.0, 0.7 },
red = { 1, 0, 0 }, red = { 1, 0, 0 },
blue = { .4, 0.4, 1 },
} }
local function RangeConfig() local function RangeConfig()
@@ -55,8 +56,20 @@ local function MouseConfig()
return { return {
-- No modifier -- No modifier
{ button = "mouse1", mods = {}, kind = "target" }, { button = "mouse1", mods = {}, kind = "target" },
{button="mouse2", mods={}, kind="macro", data="/use [@UNIT,dead,help]Ancestral Vision; [@UNIT,help]Chain Heal"}, {
{button="mouse3", mods={}, kind="macro", data="/use [@UNIT,dead,help]Ancestral Spirit; [@UNIT,help]Purify Spirit"}, button = "mouse2",
mods = {},
kind = "macro",
data =
"/use [@UNIT,dead,help]Ancestral Vision; [@UNIT,help]Chain Heal"
},
{
button = "mouse3",
mods = {},
kind = "macro",
data =
"/use [@UNIT,dead,help]Ancestral Spirit; [@UNIT,help]Purify Spirit"
},
{ button = "wheel-up", mods = {}, kind = "macro", data = "/use [@UNIT,help]Healing Surge" }, { button = "wheel-up", mods = {}, kind = "macro", data = "/use [@UNIT,help]Healing Surge" },
{ button = "wheel-down", mods = {}, kind = "macro", data = "/use [@UNIT,help]Riptide" }, { button = "wheel-down", mods = {}, kind = "macro", data = "/use [@UNIT,help]Riptide" },
@@ -66,14 +79,30 @@ local function MouseConfig()
-- Shift -- Shift
{ button = "mouse2", mods = { shift = true }, kind = "togglemenu" }, { button = "mouse2", mods = { shift = true }, kind = "togglemenu" },
{button="wheel-up", mods={shift=true}, kind="macro", data="/cast [@UNIT,help]Water Walking;\n/stopspelltarget"}, {
button = "wheel-up",
mods = { shift = true },
kind = "macro",
data =
"/cast [@UNIT,help]Water Walking;\n/stopspelltarget"
},
} }
elseif class == "PRIEST" then elseif class == "PRIEST" then
return { return {
-- No modifier -- No modifier
{ button = "mouse1", mods = {}, kind = "target" }, { button = "mouse1", mods = {}, kind = "target" },
{button="mouse2", mods={}, kind="macro", data="/use [@UNIT,dead,help]Mass Resurrection; [@UNIT,help]Power Word: Radiance"}, {
{button="mouse3", mods={}, kind="macro", data="/use [@UNIT,dead,help]Resurrection; [@UNIT,help]Purify"}, button = "mouse2",
mods = {},
kind = "macro",
data = "/use [@UNIT,dead,help]Mass Resurrection; [@UNIT,help]Power Word: Radiance"
},
{
button = "mouse3",
mods = {},
kind = "macro",
data = "/use [@UNIT,dead,help]Resurrection; [@UNIT,help]Purify"
},
{ button = "mouse4", mods = {}, kind = "spell", data = "Shadow Covenant" }, { button = "mouse4", mods = {}, kind = "spell", data = "Shadow Covenant" },
{ button = "wheel-up", mods = {}, kind = "macro", data = "/use [@UNIT,help]Flash Heal" }, { button = "wheel-up", mods = {}, kind = "macro", data = "/use [@UNIT,help]Flash Heal" },
{ button = "wheel-down", mods = {}, kind = "macro", data = "/use [@UNIT,help]Renew" }, { button = "wheel-down", mods = {}, kind = "macro", data = "/use [@UNIT,help]Renew" },
@@ -87,8 +116,18 @@ local function MouseConfig()
-- Shift -- Shift
{ button = "mouse2", mods = { shift = true }, kind = "togglemenu" }, { button = "mouse2", mods = { shift = true }, kind = "togglemenu" },
{button="wheel-up", mods={shift=true}, kind="macro", data="/cast [@UNIT,help]Levitate;\n/stopspelltarget"}, {
{button="wheel-down", mods={shift=true}, kind="macro", data="/cast [@UNIT,help]Leap of Faith;\n/stopspelltarget"}, button = "wheel-up",
mods = { shift = true },
kind = "macro",
data = "/cast [@UNIT,help]Levitate;\n/stopspelltarget"
},
{
button = "wheel-down",
mods = { shift = true },
kind = "macro",
data = "/cast [@UNIT,help]Leap of Faith;\n/stopspelltarget"
},
} }
else else
return { return {
@@ -99,44 +138,56 @@ local function MouseConfig()
end end
end end
local function TriggerConfig() local function TriggerClassConfig()
local _, class = UnitClass("player") local _, class = UnitClass("player")
if class == "SHAMAN" then if class == "SHAMAN" then
return { return {
{ {
kind="AuraTrigger", spellId=383648, own=true, -- Second Earth Shield on yourself kind = "AuraTrigger",
spellId = 383648,
own = true, -- Second Earth Shield on yourself
indicator = { indicator = {
kind = "SquareIndicator", kind = "SquareIndicator",
size = 17, size = 17,
point = "TOPLEFT", point = "TOPLEFT",
x=3, y=-3, x = 3,
y = -3,
color = colors.white, color = colors.white,
showStacks = true, showStacks = true,
} }
}, },
{ {
kind="AuraTrigger", spellId=974, own=true, -- Second Earth Shield on yourself kind = "AuraTrigger",
spellId = 974,
own = true, -- Second Earth Shield on yourself
indicator = { indicator = {
kind = "SquareIndicator", kind = "SquareIndicator",
size = 17, size = 17,
point = "TOPLEFT", point = "TOPLEFT",
x=3, y=-3, x = 3,
y = -3,
color = colors.white, color = colors.white,
showStacks = true, showStacks = true,
} }
}, },
{ {
kind="AuraTrigger", spellId=61295, own=true, -- Riptide kind = "AuraTrigger",
spellId = 61295,
own = true, -- Riptide
indicator = { indicator = {
kind = "SquareIndicator", kind = "SquareIndicator",
size = 17, size = 17,
point = "BOTTOMLEFT", point = "BOTTOMLEFT",
x=3, y=3, x = 3,
y = 3,
color = colors.cyan, color = colors.cyan,
fadeTime = 10.0,
} }
}, },
{ {
kind="StatusTrigger", status="Burn", invert=false, kind = "StatusTrigger",
status = "Burn",
invert = false,
indicator = { indicator = {
kind = "BorderIndicator", kind = "BorderIndicator",
thickness = 3.0, thickness = 3.0,
@@ -148,57 +199,81 @@ local function TriggerConfig()
elseif class == "PRIEST" then elseif class == "PRIEST" then
return { return {
{ {
kind="AuraTrigger", spellId=17, own=true, -- Power Word: Shield kind = "AuraTrigger",
spellId = 17,
own = true, -- Power Word: Shield
indicator = { indicator = {
kind = "SquareIndicator", kind = "SquareIndicator",
size = 17, size = 17,
point = "TOPLEFT", point = "TOPLEFT",
x=3, y=-3, x = 3,
y = -3,
color = colors.white, color = colors.white,
fadeTime = 10.0,
} }
}, },
{ {
kind="AuraTrigger", spellId=33206, own=true, -- Pain Suppression kind = "AuraTrigger",
spellId = 33206,
own = true, -- Pain Suppression
indicator = { indicator = {
kind = "SquareIndicator", kind = "SquareIndicator",
size = 17, size = 17,
point = "TOPLEFT", point = "TOPLEFT",
x=22, y=-3, x = 22,
y = -3,
color = colors.orange, color = colors.orange,
fadeTime = 10.0,
flashTime = 1.3,
} }
}, },
{ {
kind="AuraTrigger", spellId=139, own=true, -- Renew kind = "AuraTrigger",
spellId = 139,
own = true, -- Renew
indicator = { indicator = {
kind = "SquareIndicator", kind = "SquareIndicator",
size = 17, size = 17,
point = "BOTTOMLEFT", point = "BOTTOMLEFT",
x=3, y=3, x = 3,
y = 3,
color = colors.cyan, color = colors.cyan,
fadeTime = 10.0,
} }
}, },
{ {
kind="AuraTrigger", spellId=194384, own=true, -- Atonement kind = "AuraTrigger",
spellId = 194384,
own = true, -- Atonement
indicator = { indicator = {
kind = "SquareIndicator", kind = "SquareIndicator",
size = 17, size = 17,
point = "BOTTOMLEFT", point = "BOTTOMLEFT",
x=22, y=3, x = 22,
y = 3,
color = colors.white, color = colors.white,
fadeTime = 10.0,
flashTime = 1.3,
} }
}, },
{ {
kind="AuraTrigger", spellId=10060, own=true, -- Power Infusion kind = "AuraTrigger",
spellId = 10060,
own = true, -- Power Infusion
indicator = { indicator = {
kind = "SquareIndicator", kind = "SquareIndicator",
size = 17, size = 17,
point = "BOTTOMLEFT", point = "BOTTOMLEFT",
x=41, y=3, x = 41,
y = 3,
color = colors.violet, color = colors.violet,
fadeTime = 10.0,
} }
}, },
{ {
kind="StatusTrigger", status="Burn", invert=false, kind = "StatusTrigger",
status = "Burn",
invert = false,
indicator = { indicator = {
kind = "BorderIndicator", kind = "BorderIndicator",
thickness = 3.0, thickness = 3.0,
@@ -227,6 +302,65 @@ local function TriggerConfig()
end end
end end
-- Quick helper function to create a config for debuff triggers
local function MakeDebuffTrigger(slot, spellid, color, stacks)
if stacks == nil then
stacks = false
end
return {
kind = "AuraTrigger",
spellId = spellid,
indicator = {
kind = "SquareIndicator",
size = 15,
point = "TOPRIGHT",
x = -17 * slot,
y = -3,
color = color,
showStacks = stacks,
}
}
end
local function TriggerConfig()
local triggers = TriggerClassConfig()
-- slot, spellid, color, stacks
local debuffs = {
-- Kezzara, Aberrus
{ 1, 406525, colors.orange }, -- Dread Rift
{ 2, 402253, colors.red }, -- Ray of Anguish
{ 3, 404743, colors.violet, true }, -- Terror Claws
-- Forgotten Experiment, Aberrus
{ 1, 406365, colors.red, true }, -- Rending Charge (p1)
{ 1, 407327, colors.cyan, true }, -- Unstable Essence (p2/p3)
{ 3, 407313, colors.violet, true }, -- Infused Strikes
-- Uldaman: Legacy of Tyr
{ 1, 377510, colors.cyan, true }, -- Stolen Time
-- Brackenhide Hollow
{ 1, 367521, colors.cyan, true }, -- Bone Bolt
-- The Underrot
--{1, 273226, colors.green, true}, -- Decaying Spores
-- Sarkareth, Aberrus
{ 3, 401330, colors.violet }, -- Burning Claws (P1 tank)
{ 3, 411241, colors.violet }, -- Void Claws (P2 tank)
{ 3, 408429, colors.violet }, -- Void Slash (P3 tank)
{ 2, 404218, colors.blue }, -- Void Fracture (carry bomb)
{ 1, 401951, colors.cyan, true }, -- Oblivion
}
for _, debuff in ipairs(debuffs) do
table.insert(triggers, MakeDebuffTrigger(debuff[1], debuff[2], debuff[3], debuff[4]))
end
return triggers
end
local types = omif.GetModule("types") local types = omif.GetModule("types")
local UnitFrame = types.UnitFrame local UnitFrame = types.UnitFrame
local UnitGroup = types.UnitGroup local UnitGroup = types.UnitGroup
@@ -307,4 +441,5 @@ function CreateFrames()
CreateTargetFrames(110 * 3 + 50 - 0.05, -245.05, config) CreateTargetFrames(110 * 3 + 50 - 0.05, -245.05, config)
HideBlizzardFrames() HideBlizzardFrames()
end end
omif.SetEventHandler("OMICRON_LOADING", CreateFrames) omif.SetEventHandler("OMICRON_LOADING", CreateFrames)

View File

@@ -45,7 +45,9 @@ end
---@param y number ---@param y number
---@param color number[] ---@param color number[]
---@param showStacks boolean ---@param showStacks boolean
function SquareIndicator:Init(unitframe, size, point, x, y, color, showStacks) ---@param doFade nil|number
---@param doFlash nil|number
function SquareIndicator:Init(unitframe, size, point, x, y, color, showStacks, fadeTime, flashTime)
self.unitframe = unitframe self.unitframe = unitframe
self.frameParent = unitframe.overlays self.frameParent = unitframe.overlays
self.size = size self.size = size
@@ -54,6 +56,8 @@ function SquareIndicator:Init(unitframe, size, point, x, y, color, showStacks)
self.y = y self.y = y
self.color = color self.color = color
self.showStacks = showStacks self.showStacks = showStacks
self.fadeTime = fadeTime
self.flashTime = flashTime
end end
--- Set the color of the Square Indicator --- Set the color of the Square Indicator
@@ -77,6 +81,13 @@ function SquareIndicator:Show(data)
stacks:SetText(numStacks) stacks:SetText(numStacks)
stacks:Show() stacks:Show()
end end
if self.flashTime or self.fadeTime then
self.frame:SetScript("OnUpdate", function(frame, dt)
self:OnUpdate(dt)
end)
self.expirationTime = data.expirationTime
self.updateThrottle = 0
end
if data.color then if data.color then
self:SetColor(data.color) self:SetColor(data.color)
else else
@@ -108,6 +119,7 @@ function SquareIndicator:GetFrame()
frame:SetParent(self.frameParent) frame:SetParent(self.frameParent)
frame:SetPoint(self.point, self.x, self.y) frame:SetPoint(self.point, self.x, self.y)
frame:SetBackdropBorderColor(0, 0, 0, 1) frame:SetBackdropBorderColor(0, 0, 0, 1)
frame:SetAlpha(1)
stacks = frame.stacks stacks = frame.stacks
return frame, stacks return frame, stacks
end end
@@ -122,6 +134,30 @@ function SquareIndicator:Update(data)
self.stacks:SetText(numStacks) self.stacks:SetText(numStacks)
self.stacks:Show() self.stacks:Show()
end end
self.expirationTime = data.expirationTime
self.frame:SetAlpha(1)
end
function SquareIndicator:OnUpdate(dt)
dt = self.updateThrottle + dt
if dt < 0.04 then
self.updateThrottle = dt
return
else
self.updateThrottle = 0
end
local timeLeft = self.expirationTime - GetTime()
local fadeTime = self.fadeTime or 0
local flashTime = self.flashTime or 0
if timeLeft < flashTime then
local alpha = ((timeLeft * 4) % 1)
self.frame:SetAlpha(alpha)
elseif timeLeft < fadeTime then
local alpha = timeLeft / fadeTime
self.frame:SetAlpha(alpha)
end
end end
--- Hide the square indicator. --- Hide the square indicator.
@@ -130,5 +166,6 @@ function SquareIndicator:Hide()
self.stacks:Hide() self.stacks:Hide()
self.frame = nil self.frame = nil
self.stacks = nil self.stacks = nil
frame:SetScript("OnUpdate", nil)
squarePool:Release(frame) squarePool:Release(frame)
end end

View File

@@ -92,7 +92,7 @@ function AuraTrigger:AddAura(aura)
return return
end end
self.count = self.count + 1 self.count = self.count + 1
self:SetData({stacks=aura.applications}) self:SetData({ stacks = aura.applications, duration = aura.duration, expirationTime = aura.expirationTime })
self:SetState(self.count >= self.requiredCount, false) self:SetState(self.count >= self.requiredCount, false)
end end
@@ -100,7 +100,7 @@ end
---@param before UnitAuraInfo ---@param before UnitAuraInfo
---@param after UnitAuraInfo ---@param after UnitAuraInfo
function AuraTrigger:UpdateAura(before, after) function AuraTrigger:UpdateAura(before, after)
self:SetData({stacks=after.applications}) self:SetData({ stacks = after.applications, duration = after.duration, expirationTime = after.expirationTime })
if self.active then if self.active then
self.indicator:Update(self.data) self.indicator:Update(self.data)
end end

View File

@@ -125,7 +125,9 @@ function UnitFrame:CreateIndicator(indicator)
indicator.x, indicator.x,
indicator.y, indicator.y,
indicator.color, indicator.color,
indicator.showStacks indicator.showStacks,
indicator.fadeTime,
indicator.flashTime
) )
elseif kind == "BorderIndicator" then elseif kind == "BorderIndicator" then
return BorderIndicator:new( return BorderIndicator:new(