From 3a782622e0b5227f56c131e409daa1fdf489f96b Mon Sep 17 00:00:00 2001 From: Nuno Freire Date: Mon, 26 Oct 2020 00:15:22 +0000 Subject: [PATCH] Refactoring and tweaks --- CHANGELOG.md | 9 +++ api.lua | 61 ++++++++------- config/debuffs.lua | 22 +++--- config/defaults.lua | 155 +++++++++++++++++++++++++++----------- elements/auras.lua | 55 +++++++++----- elements/bartimers.lua | 74 ++++++++++++------ elements/castbar.lua | 4 +- elements/nameplates.lua | 59 +++------------ functions.lua | 163 +++++++++------------------------------- shared.lua | 4 +- tasks.todo | 9 ++- units/party.lua | 57 +++++--------- units/pet.lua | 2 +- units/player.lua | 43 ++++++++++- units/target.lua | 2 +- 15 files changed, 371 insertions(+), 348 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c001d01..e727e9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +### Version 9.2.0: + +- Refactoring +- Update Rogue filters +- Refactor AuraBar Filters and settings +- Add fonts and media to defaults +- Update player visibility function +- Update Target Quest Icon + ### Version 9.1.1: - Update frame visibility options diff --git a/api.lua b/api.lua index 16f5968..2ba15d4 100644 --- a/api.lua +++ b/api.lua @@ -56,47 +56,52 @@ function api:RaidColor(unit) return color and {color.r, color.g, color.b} or {.5, .5, .5} end --- Create Border -function api:CreateBorder(self, frame, e_size, f_level, texture) - local border = {edgeFile = texture, edgeSize = e_size} - frame:SetPoint("TOPLEFT", self, "TOPLEFT", -2, 2) - frame:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 2, -2) - frame:SetBackdrop(border) - frame:SetFrameLevel(f_level) - frame:Hide() -end - --- Set the Backdrop -function api:SetBackdrop(frame, inset_l, inset_r, inset_t, inset_b) +-- Set the frame backdrop +function api:SetBackdrop(self, insetLeft, insetRight, insetTop, insetBottom, color) + local frame = self + + if self:GetObjectType() == "Texture" then + frame = self:GetParent() + end + + local lvl = frame:GetFrameLevel() + if not frame.Backdrop then local backdrop = CreateFrame("Frame", nil, frame, "BackdropTemplate") - backdrop = CreateFrame("Frame", nil, frame, "BackdropTemplate") - backdrop:SetAllPoints() - backdrop:SetFrameLevel(frame:GetFrameLevel()) + backdrop:SetAllPoints(frame) + backdrop:SetFrameLevel(lvl == 0 and 0 or lvl - 1) backdrop:SetBackdrop { bgFile = "Interface\\ChatFrame\\ChatFrameBackground", tile = false, tileSize = 0, insets = { - left = -inset_l, - right = -inset_r, - top = -inset_t, - bottom = -inset_b + left = -insetLeft, + right = -insetRight, + top = -insetTop, + bottom = -insetBottom } } - - backdrop:SetBackdropColor( - cfg.colors.backdrop.r, - cfg.colors.backdrop.g, - cfg.colors.backdrop.b, - cfg.colors.backdrop.a - ) - + backdrop:SetBackdropColor(unpack(color or cfg.colors.backdrop)) frame.Backdrop = backdrop end end +-- Create a backdrop border +function api:CreateBorder(self, borderFrame, edgeSize, frameLevel, texture) + if borderFrame:GetObjectType() == "Texture" then + borderFrame = self:GetParent() + end + + local backdrop = {edgeFile = texture or "Interface\\ChatFrame\\ChatFrameBackground", edgeSize = edgeSize} + borderFrame:SetPoint("TOPLEFT", self, "TOPLEFT", -2, 2) + borderFrame:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 2, -2) + borderFrame:SetBackdrop(backdrop) + borderFrame:SetFrameLevel(frameLevel or borderFrame:GetFrameLevel() - 1) + borderFrame:SetBackdropBorderColor(0, 0, 0) + borderFrame:Hide() +end + -- Fontstring Function function api:CreateFontstring(frame, font, size, outline, layer, sublayer, inheritsFrom) local fs = frame:CreateFontString(nil, layer or "OVERLAY", sublayer or 0, inheritsFrom or nil) @@ -128,7 +133,7 @@ function api:CreateDropShadow(frame, point, edge, color) } ) shadow:SetBackdropColor(0, 0, 0, 0) - shadow:SetBackdropBorderColor(unpack(color)) + shadow:SetBackdropBorderColor(unpack(color or cfg.frames.shadow.color)) end -- Frame Fader diff --git a/config/debuffs.lua b/config/debuffs.lua index 1503da9..7177e9d 100644 --- a/config/debuffs.lua +++ b/config/debuffs.lua @@ -9,18 +9,18 @@ ns.debuffs = debuffs debuffs.list = { player = { - [GetSpellInfo(45181) or "Cheated Death"] = true, - [GetSpellInfo(57723) or "Exhaustion"] = true, - [GetSpellInfo(264689) or "Fatigued"] = true, - [GetSpellInfo(95809) or "Insanity"] = true, - [GetSpellInfo(57724) or "Sated"] = true, - [GetSpellInfo(80354) or "Temporal Displacement"] = true + [45181 or "Cheated Death"] = true, + [57723 or "Exhaustion"] = true, + [264689 or "Fatigued"] = true, + [95809 or "Insanity"] = true, + [57724 or "Sated"] = true, + [80354 or "Temporal Displacement"] = true }, party = { - [GetSpellInfo(57723) or "Exhaustion"] = true, - [GetSpellInfo(264689) or "Fatigued"] = true, - [GetSpellInfo(95809) or "Insanity"] = true, - [GetSpellInfo(57724) or "Sated"] = true, - [GetSpellInfo(80354) or "Temporal Displacement"] = true + [57723 or "Exhaustion"] = true, + [264689 or "Fatigued"] = true, + [95809 or "Insanity"] = true, + [57724 or "Sated"] = true, + [80354 or "Temporal Displacement"] = true } } diff --git a/config/defaults.lua b/config/defaults.lua index 3bfc14e..aeacf44 100644 --- a/config/defaults.lua +++ b/config/defaults.lua @@ -55,7 +55,7 @@ cfg.healingSpecs = { -- ----------------------------------- cfg.colors = { - backdrop = {r = 0, g = 0, b = 0, a = 1}, -- Backdrop Color (Some frames might not be affected) + backdrop = {0, 0, 0, 0.9}, -- Backdrop Color (Some frames might not be affected) health = {0.2, 0.2, 0.2, 1}, -- Fallback color inverted = {0.1, 0.1, 0.1, 1} -- Inverted Color } @@ -102,7 +102,7 @@ cfg.frames = { }, shadow = { show = true, -- Use frame drop shadows - opacity = 0.7 + color = {0, 0, 0, 0.7} }, range = { insideAlpha = 1, @@ -110,6 +110,45 @@ cfg.frames = { } } +-- ----------------------------------- +-- > Elements +-- ----------------------------------- + +cfg.elements = { + castbar = { + backdrop = { + color = {0, 0, 0, 0.9} + }, + timeToHold = 1.5, + fader = { + fadeInAlpha = 1, + fadeInDuration = 0.1, + fadeOutAlpha = 0, + fadeOutDuration = 0.3, + fadeOutDelay = 0.5 + } + }, + experiencebar = { + show = true, + height = 3, + width = Minimap:GetWidth() + 4, + pos = {a1 = "TOPLEFT", a2 = "BOTTOMLEFT", af = "Minimap", x = -2, y = -12} + }, + artifactpowerbar = { + show = true, + height = 3, + width = Minimap:GetWidth() + 4, + pos = {a1 = "TOPLEFT", a2 = "BOTTOMLEFT", af = "Minimap", x = -2, y = -24} + }, + altpowerbar = { + show = true + }, + mirrorTimers = { + width = 220, + height = cfg.frames.main.height + 2 + } +} + -- ----------------------------------- -- > UNITS -- ----------------------------------- @@ -151,8 +190,13 @@ cfg.units = { } }, auras = { + buffs = { + show = false, + spellName = false + }, debuffs = { - show = true + show = true, + spellName = true }, barTimers = { show = true @@ -195,7 +239,12 @@ cfg.units = { }, auras = { buffs = { - show = true + show = true, + spellName = false + }, + debuffs = { + show = false, + spellName = false }, barTimers = { show = true @@ -226,6 +275,16 @@ cfg.units = { frequentUpdates = false, smooth = true }, + auras = { + buffs = { + show = false, + spellName = false + }, + debuffs = { + show = false, + spellName = false + } + }, fader = { fadeInAlpha = 1, fadeInDuration = 0.3, @@ -257,6 +316,16 @@ cfg.units = { width = 282, height = cfg.frames.main.height }, + auras = { + buffs = { + show = false, + spellName = false + }, + debuffs = { + show = false, + spellName = false + } + }, fader = { fadeInAlpha = 1, fadeInDuration = 0.3, @@ -288,8 +357,15 @@ cfg.units = { frequentUpdates = false, smooth = true }, - buffs = { - filter = true + auras = { + buffs = { + show = false, + filter = true + }, + debuffs = { + show = false, + spellName = false + } }, visibility = "[petbattle][overridebar][vehicleui][possessbar][shapeshift][channeling] hide; [pet,mod][pet,harm][pet,combat] show; hide", fader = { @@ -323,6 +399,16 @@ cfg.units = { color = {5 / 255, 107 / 255, 246 / 255}, width = 282, height = cfg.frames.main.height + }, + auras = { + buffs = { + show = false, + spellName = false + }, + debuffs = { + show = false, + spellName = false + } } }, arena = { @@ -342,6 +428,16 @@ cfg.units = { classColored = false, frequentUpdates = false, smooth = true + }, + auras = { + buffs = { + show = false, + spellName = false + }, + debuffs = { + show = false, + spellName = false + } } }, party = { @@ -363,6 +459,16 @@ cfg.units = { frequentUpdates = false, smooth = true }, + auras = { + buffs = { + show = false, + spellName = false + }, + debuffs = { + show = true, + spellName = false + } + }, showPortraits = true, forceRole = false }, @@ -372,7 +478,7 @@ cfg.units = { nameplate = { show = true, width = 120, - height = 8, + height = 6, pos = {a1 = "CENTER", a2 = "CENTER", af = "UIParent", x = 0, y = 0}, power = { height = 4, @@ -394,38 +500,3 @@ cfg.units = { showHighlight = false } } - -cfg.elements = { - castbar = { - backdrop = { - color = {r = 0, g = 0, b = 0, a = 0.85} - }, - timeToHold = 1.5, - fader = { - fadeInAlpha = 1, - fadeInDuration = 0.1, - fadeOutAlpha = 0, - fadeOutDuration = 0.3, - fadeOutDelay = 0.5 - } - }, - experiencebar = { - show = true, - height = 3, - width = Minimap:GetWidth() + 4, - pos = {a1 = "TOPLEFT", a2 = "BOTTOMLEFT", af = "Minimap", x = -2, y = -12} - }, - artifactpowerbar = { - show = true, - height = 3, - width = Minimap:GetWidth() + 4, - pos = {a1 = "TOPLEFT", a2 = "BOTTOMLEFT", af = "Minimap", x = -2, y = -24} - }, - altpowerbar = { - show = true - }, - mirrorTimers = { - width = 220, - height = cfg.frames.main.height + 2 - } -} diff --git a/elements/auras.lua b/elements/auras.lua index 178d3cc..ae95033 100644 --- a/elements/auras.lua +++ b/elements/auras.lua @@ -8,25 +8,9 @@ local max = max -- > AURAS RELATED FUNCTIONS -- ------------------------------------------------------------------------ -function lum:AuraTimer_OnUpdate(icon, elapsed) - if icon.timeLeft then - icon.timeLeft = max(icon.timeLeft - elapsed, 0) - - -- text color - if icon.timeLeft > 0 and icon.timeLeft < 60 then - icon.time:SetFormattedText(core:FormatTime(icon.timeLeft)) - if icon.timeLeft < 6 then - icon.time:SetTextColor(0.9, 0.05, 0.05) - else - icon.time:SetTextColor(1, 1, 0.60) - end - else - icon.time:SetText() - end - end -end +local function PostCreateIcon(self, button) + local unit = self.__owner.unit -local function PostCreateIcon(Auras, button) local count = button.count count:ClearAllPoints() count:SetFont(m.fonts.font, 12, "OUTLINE") @@ -49,6 +33,40 @@ local function PostCreateIcon(Auras, button) button.time:SetJustifyH("CENTER") end +local function OnUpdate(icon, elapsed) + if icon.timeLeft then + icon.timeLeft = max(icon.timeLeft - elapsed, 0) + + -- text color + if icon.timeLeft > 0 and icon.timeLeft < 60 then + icon.time:SetFormattedText(core:FormatTime(icon.timeLeft)) + if icon.timeLeft < 6 then + icon.time:SetTextColor(0.9, 0.05, 0.05) + else + icon.time:SetTextColor(1, 1, 0.60) + end + else + icon.time:SetText() + end + end +end + +local function PostUpdateIcon(icons, unit, icon, index) + local name, _, count, dtype, duration, expirationTime = UnitAura(unit, index, icon.filter) + + if duration and duration > 0 then + icon.timeLeft = expirationTime - GetTime() + else + icon.timeLeft = math.huge + end + + if (icon.spell) then + icon.spell:SetText(name) + end + + icon:SetScript("OnUpdate", OnUpdate) +end + function lum:CreateAura(self, num, rows, size, spacing) local auras = CreateFrame("Frame", nil, self) auras:SetSize((num * (size + 9)) / rows, (size + 9) * rows) @@ -57,5 +75,6 @@ function lum:CreateAura(self, num, rows, size, spacing) auras.spacing = spacing or 9 auras.disableCooldown = true auras.PostCreateIcon = PostCreateIcon + auras.PostUpdateIcon = PostUpdateIcon return auras end diff --git a/elements/bartimers.lua b/elements/bartimers.lua index 27e9942..2225066 100644 --- a/elements/bartimers.lua +++ b/elements/bartimers.lua @@ -5,45 +5,70 @@ local lum, core, api, cfg, m, G, oUF = ns.lum, ns.core, ns.api, ns.cfg, ns.m, ns local max = max -- ------------------------------------------------------------------------ --- > BARTIME AURAS RELATED FUNCTIONS +-- > BarTimer Auras -- ------------------------------------------------------------------------ -function lum:BarTimer_OnUpdate(icon, elapsed) - if icon.timeLeft then - icon.timeLeft = max(icon.timeLeft - elapsed, 0) - icon.bar:SetValue(icon.timeLeft) -- update the statusbar +local function OnUpdate(self, elapsed) + if self.timeLeft then + self.timeLeft = max(self.timeLeft - elapsed, 0) + self.bar:SetValue(self.timeLeft) -- update the statusbar -- text color - if icon.timeLeft > 0 and icon.timeLeft < 60 then - icon.time:SetFormattedText(core:FormatTime(icon.timeLeft)) - if icon.timeLeft < 6 then - icon.time:SetTextColor(1, 0.25, 0.25) - elseif icon.timeLeft < 10 then - icon.time:SetTextColor(1, 0.9, 0.5) + if self.timeLeft > 0 and self.timeLeft < 60 then + self.time:SetFormattedText(core:FormatTime(self.timeLeft)) + if self.timeLeft < 6 then + self.time:SetTextColor(1, 0.25, 0.25) + elseif self.timeLeft < 10 then + self.time:SetTextColor(1, 0.9, 0.5) else - icon.time:SetTextColor(1, 1, 1) + self.time:SetTextColor(1, 1, 1) end - elseif icon.timeLeft > 60 and icon.timeLeft < 60 * 5 then - icon.time:SetTextColor(1, 1, 1) - icon.time:SetFormattedText(core:FormatTime(icon.timeLeft)) + elseif self.timeLeft > 60 and self.timeLeft < 60 * 5 then + self.time:SetTextColor(1, 1, 1) + self.time:SetFormattedText(core:FormatTime(self.timeLeft)) else - icon.time:SetText() + self.time:SetText() end end end -local SortAuras = function(a, b) +local PostUpdateBar = function(element, unit, button, index) + local name, _, count, dtype, duration, expirationTime = UnitAura(unit, index, button.filter) + + if duration and duration > 0 then + button.timeLeft = expirationTime - GetTime() + button.bar:SetMinMaxValues(0, duration) + button.bar:SetValue(button.timeLeft) + + if button.isDebuff then -- bar color + button.bar:SetStatusBarColor(1, 0.1, 0.2) + else + button.bar:SetStatusBarColor(0, 0.4, 1) + end + else + -- Permanent buff / debuff + button.timeLeft = math.huge + button.bar:SetStatusBarColor(0.6, 0, 0.8) + end + + -- set spell name + button.spell:SetText(name) + + button:SetScript("OnUpdate", OnUpdate) +end + +local function SortAuras(a, b) if a and b and a.timeLeft and b.timeLeft then return a.timeLeft > b.timeLeft end end -local PreSetPosition = function(Auras) - table.sort(Auras, SortAuras) +local function PreSetPosition(self) + table.sort(self, SortAuras) return 1 end -local PostCreateBar = function(Auras, button) +local function PostCreateBar(self, button) button.icon:SetTexCoord(0, 1, 0, 1) button.overlay:SetTexture(m.textures.border) @@ -55,8 +80,8 @@ local PostCreateBar = function(Auras, button) button.bar = CreateFrame("StatusBar", nil, button) button.bar:SetStatusBarTexture(m.textures.status_texture) button.bar:SetPoint("TOPLEFT", button, "TOPRIGHT", 4, -2) - button.bar:SetHeight(Auras.size - 4) - button.bar:SetWidth(cfg.frames.main.width - Auras.size - 2) + button.bar:SetHeight(self.size - 4) + button.bar:SetWidth(cfg.frames.main.width - self.size - 2) api:SetBackdrop(button.bar, 2, 2, 2, 2) button.bar.bg = button.bar:CreateTexture(nil, "BORDER") @@ -95,7 +120,8 @@ function lum:CreateBarTimer(self, num, rows, size, spacing) auras.size = size auras.spacing = spacing or 4 auras.disableCooldown = true - auras.PreSetPosition = PreSetPosition -- sort auras by time remaining - auras.PostCreateIcon = PostCreateBar -- set overlay, cd, count, timer + auras.PreSetPosition = PreSetPosition -- Sort auras by time remaining + auras.PostCreateIcon = PostCreateBar -- Set overlay, cd, count, timer + auras.PostUpdateIcon = PostUpdateBar return auras end diff --git a/elements/castbar.lua b/elements/castbar.lua index 38a396b..3614c65 100644 --- a/elements/castbar.lua +++ b/elements/castbar.lua @@ -63,6 +63,8 @@ function lum:CreateCastbar(self) return end + local backdropColor = cfg.elements.castbar.backdrop.color + local Castbar = CreateFrame("StatusBar", nil, self) Castbar:SetStatusBarTexture(m.textures.status_texture) Castbar:GetStatusBarTexture():SetHorizTile(false) @@ -100,7 +102,7 @@ function lum:CreateCastbar(self) Castbar.Max:SetPoint("RIGHT", Time, "LEFT", 0, 0) if (unit == "player") then - api:SetBackdrop(Castbar, cfg.units.player.castbar.height + 4, 2, 2, 2) + api:SetBackdrop(Castbar, cfg.units.player.castbar.height + 4, 2, 2, 2, backdropColor) Castbar:SetStatusBarColor(unpack(cfg.units.player.castbar.color)) Castbar:SetWidth(cfg.units.player.castbar.width - cfg.units.player.castbar.height + 6) Castbar:SetHeight(cfg.units.player.castbar.height) diff --git a/elements/nameplates.lua b/elements/nameplates.lua index 19db132..9558e0f 100644 --- a/elements/nameplates.lua +++ b/elements/nameplates.lua @@ -91,7 +91,7 @@ local function AddTargetIndicators(self) -- Target Border self.TargetBorder = CreateFrame("Frame", nil, self, "BackdropTemplate") - api:CreateBorder(self, self.TargetBorder, 1, 3, "Interface\\ChatFrame\\ChatFrameBackground") + api:CreateBorder(self, self.TargetBorder, 1, 3) -- Targeted Arrow if self.cfg.showTargetArrow then @@ -169,12 +169,9 @@ local function CreateCastbar(self) Icon:SetHeight(self.cfg.height + cfg.units.nameplate.castbar.height + 4) Icon:SetWidth(self.cfg.height + cfg.units.nameplate.castbar.height + 4) Icon:SetPoint("TOPLEFT", self, "TOPRIGHT", 6, 0) - - local iconborder = CreateFrame("Frame", nil, self, "BackdropTemplate") - api:CreateBorder(Icon, iconborder, 2, 3, "Interface\\ChatFrame\\ChatFrameBackground") - iconborder:SetBackdropColor(0, 0, 0, 1) - iconborder:SetBackdropBorderColor(0, 0, 0, 1) - Icon.border = iconborder + Icon.border = CreateFrame("Frame", nil, Castbar, "BackdropTemplate") + api:CreateBorder(Icon, Icon.border, 2) + Icon.border:Show() local CheckForSpellInterrupt = function(self, unit) local initialColor = cfg.units.nameplate.castbar.color @@ -228,24 +225,6 @@ local PostUpdateHealth = function(health, unit, min, max) health.percent:SetTextColor(color:GetRGB()) end --- Post Update Aura Icon -local PostUpdateIcon = function(icons, unit, icon, index, offset, filter, isDebuff) - local name, _, count, dtype, duration, expirationTime = UnitAura(unit, index, icon.filter) - - if duration and duration > 0 then - icon.timeLeft = expirationTime - GetTime() - else - icon.timeLeft = math.huge - end - - icon:SetScript( - "OnUpdate", - function(self, elapsed) - lum:AuraTimer_OnUpdate(self, elapsed) - end - ) -end - local PostCreateIcon = function(Auras, button) local count = button.count count:ClearAllPoints() @@ -280,13 +259,11 @@ local PostUpdatePlates = function(self, event, unit) if event == "NAME_PLATE_UNIT_ADDED" or event == "PLAYER_TARGET_CHANGED" then self.isPlayer = UnitIsPlayer(unit) - - self.Castbar.Icon.border:Hide() OnTargetChanged(self) end if not self.isPlayer then - lum:CreateNameString(self, font, cfg.fontsize - 5, "THINOUTLINE", 0, 5, "CENTER", self.cfg.width - 4) + lum:CreateNameString(self, font, cfg.fontsize - 5, "THINOUTLINE", 0, 4, "CENTER", self.cfg.width - 4) self:Tag(self.Name, "[lum:levelplus][lum:classificationshort] [lum:name]") end end @@ -306,7 +283,7 @@ local createStyle = function(self, unit) -- Size and position self:SetSize(self.cfg.width, self.cfg.height) self:SetPoint("CENTER", 0, -10) - api:CreateDropShadow(self, 5, 5, {0, 0, 0, cfg.frames.shadow.opacity}) + api:CreateDropShadow(self, 6, 6) -- Health bar local health = CreateFrame("StatusBar", nil, self) @@ -323,10 +300,10 @@ local createStyle = function(self, unit) health.bg = health:CreateTexture(nil, "BACKGROUND") health.bg:SetAllPoints(health) - health.bg:SetAlpha(0.20) + health.bg:SetAlpha(0.2) health.bg:SetTexture(m.textures.bg_texture) - api:SetBackdrop(health, 2, 2, 2, 2) + api:SetBackdrop(health, 2, 2, 2, 2, {0, 0, 0, 0.8}) self.Health = health @@ -338,24 +315,6 @@ local createStyle = function(self, unit) health.percent:SetTextColor(0.8, 0.8, 0.8, 1) self:Tag(health.percent, "[lum:hpperc]") - -- -- Power Bar - -- local power = CreateFrame("StatusBar", nil, self) - -- power:SetHeight(self.cfg.power.height) - -- power:SetWidth(self.cfg.width) - -- power:SetStatusBarTexture(m.textures.status_texture) - -- power:GetStatusBarTexture():SetHorizTile(false) - -- power:SetPoint("TOP", self.Health, "BOTTOM", 0, -cfg.frames.main.health.margin) - -- power.colorPower = true - - -- power.bg = self:CreateTexture(nil, "BACKGROUND") - -- power.bg:SetAllPoints(power) - -- power.bg:SetTexture(m.textures.bg_texture) - -- power.bg:SetAlpha(0.2) - - -- api:SetBackdrop(power, 2, 2, 2, 2) - - -- self.Power = power - -- Class Power (Combo Points, Insanity, etc...) if cfg.units.nameplate.classpower then classPower = api:CreateFontstring(self.Health, font, cfg.fontsize - 2, "THINOUTLINE", "BACKGROUND") @@ -381,7 +340,7 @@ local createStyle = function(self, unit) debuffs["growth-x"] = "RIGHT" debuffs["growth-y"] = "UP" debuffs.onlyShowPlayer = true - debuffs.PostUpdateIcon = PostUpdateIcon + -- debuffs.PostUpdateIcon = PostUpdateIcon debuffs.PostCreateIcon = PostCreateIcon self.Debuffs = debuffs end diff --git a/functions.lua b/functions.lua index b836a5e..ca1b991 100644 --- a/functions.lua +++ b/functions.lua @@ -11,59 +11,6 @@ local font = m.fonts.font -- > Auras -- ----------------------------------- -local PostCreateIcon = function(Auras, button) - local count = button.count - count:ClearAllPoints() - count:SetFont(m.fonts.font, 12, "OUTLINE") - count:SetPoint("TOPRIGHT", button, 3, 3) - - button.icon:SetTexCoord(.08, .92, .08, .92) - - button.overlay:SetTexture(m.textures.border) - button.overlay:SetTexCoord(0, 1, 0, 1) - button.overlay.Hide = function(self) - self:SetVertexColor(0.3, 0.3, 0.3) - end - - button.spell = button:CreateFontString(nil, "OVERLAY") - button.spell:SetPoint("RIGHT", button, "LEFT", -4, 0) - button.spell:SetFont(m.fonts.font, 16, "THINOUTLINE") - button.spell:SetTextColor(1, 1, 1) - button.spell:SetShadowOffset(1, -1) - button.spell:SetShadowColor(0, 0, 0, 1) - button.spell:SetJustifyH("RIGHT") - button.spell:SetWordWrap(false) - - button.time = button:CreateFontString(nil, "OVERLAY") - button.time:SetFont(m.fonts.font, 12, "THINOUTLINE") - button.time:SetPoint("BOTTOMLEFT", button, -2, -2) - button.time:SetTextColor(1, 1, 0.65) - button.time:SetShadowOffset(1, -1) - button.time:SetShadowColor(0, 0, 0, 1) - button.time:SetJustifyH("CENTER") -end - -local PostUpdateIcon = function(icons, unit, icon, index, offset, filter, isDebuff) - local name, _, count, dtype, duration, expirationTime = UnitAura(unit, index, icon.filter) - - if duration and duration > 0 then - icon.timeLeft = expirationTime - GetTime() - else - icon.timeLeft = math.huge - end - - if (icon.spell) then - icon.spell:SetText(name) - end - - icon:SetScript( - "OnUpdate", - function(self, elapsed) - lum:AuraTimer_OnUpdate(self, elapsed) - end - ) -end - function lum:SetBuffAuras( self, frame, @@ -77,12 +24,9 @@ function lum:SetBuffAuras( posX, posY, initialAnchor, - growthY, growthX, - showStealableBuffs, - CustomFilter, - PostCreate, - PostUpdate) + growthY, + showStealableBuffs) if not cfg.units[frame].auras.buffs.show then return end @@ -92,9 +36,9 @@ function lum:SetBuffAuras( buffs.initialAnchor = initialAnchor buffs["growth-y"] = growthY or "DOWN" buffs["growth-x"] = growthX or "RIGHT" - buffs.showStealableBuffs = true - buffs.PostUpdateIcon = PostUpdate or PostUpdateIcon + buffs.showStealableBuffs = showStealableBuffs self.Buffs = buffs + return buffs end function lum:SetDebuffAuras( @@ -110,12 +54,9 @@ function lum:SetDebuffAuras( posX, posY, initialAnchor, - growthY, growthX, - showDebuffType, - CustomFilter, - PostCreate, - PostUpdate) + growthY, + showDebuffType) if not cfg.units[frame].auras.debuffs.show then return end @@ -135,56 +76,10 @@ function lum:SetDebuffAuras( debuffs.initialAnchor = initialAnchor debuffs["growth-y"] = growthY or "DOWN" debuffs["growth-x"] = growthX or "RIGHT" - debuffs.showDebuffType = showDebuffType or true - debuffs.CustomFilter = CustomFilter or DebuffsCustomFilter - debuffs.PostCreateIcon = PostCreate or PostCreateIcon - debuffs.PostUpdateIcon = PostUpdate or PostUpdateIcon + debuffs.showDebuffType = showDebuffType + debuffs.CustomFilter = DebuffsCustomFilter self.Debuffs = debuffs -end - -local PostUpdateBarTimer = function(element, unit, button, index) - local name, _, count, dtype, duration, expirationTime = UnitAura(unit, index, button.filter) - - if duration and duration > 0 then - button.timeLeft = expirationTime - GetTime() - button.bar:SetMinMaxValues(0, duration) - button.bar:SetValue(button.timeLeft) - - if button.isDebuff then -- bar color - button.bar:SetStatusBarColor(1, 0.1, 0.2) - else - button.bar:SetStatusBarColor(0, 0.4, 1) - end - else - button.timeLeft = math.huge - button.bar:SetStatusBarColor(0.6, 0, 0.8) -- permenant buff / debuff - end - - button.spell:SetText(name) -- set spell name - - button:SetScript( - "OnUpdate", - function(self, elapsed) - lum:BarTimer_OnUpdate(self, elapsed) - end - ) -end - -local PlayerCustomFilter = function(...) - local spellID = select(13, ...) - if spellID then - if filters["ALL"].buffs[spellID] or filters[G.playerClass].buffs[spellID] then - return true - end - end -end - -local TargetCustomFilter = function(element, unit, button, name, _, _, _, duration, _, _, _, _, spellID) - if spellID then - if (filters[G.playerClass].debuffs[spellID] and button.isPlayer) then - return true - end - end + return debuffs end function lum:SetBarTimerAuras( @@ -200,28 +95,44 @@ function lum:SetBarTimerAuras( posX, posY, initialAnchor, - growthY, - CustomFilter, - PostUpdate) + growthY) if not cfg.units[frame].auras.barTimers.show then return end + local PlayerCustomFilter = function(...) + local spellID = select(13, ...) + if spellID then + if filters["ALL"].buffs[spellID] or filters[G.playerClass].buffs[spellID] then + return true + end + end + end + + local TargetCustomFilter = function(element, unit, button, name, _, _, _, duration, _, _, _, _, spellID) + if spellID then + if (filters[G.playerClass].debuffs[spellID] and button.isPlayer) then + return true + end + end + end + local barTimers = lum:CreateBarTimer(self, numAuras, numRows, size, spacing) barTimers:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, cfg.frames.secondary.height + 16) barTimers.initialAnchor = "BOTTOMLEFT" barTimers["growth-y"] = "UP" - barTimers.PostUpdateIcon = PostUpdate or PostUpdateBarTimer if frame == "player" then - barTimers.CustomFilter = CustomFilter or PlayerCustomFilter + barTimers.CustomFilter = PlayerCustomFilter self.Buffs = barTimers end if frame == "target" then - barTimers.CustomFilter = CustomFilter or TargetCustomFilter + barTimers.CustomFilter = TargetCustomFilter self.Debuffs = barTimers end + + return barTimers end -- ----------------------------------- @@ -239,7 +150,7 @@ end -- Create Party / Raid health warning status border function lum:CreateHealthBorder(self) self.HPborder = CreateFrame("Frame", nil, self, "BackdropTemplate") - api:CreateBorder(self, self.HPborder, 1, 4, "Interface\\ChatFrame\\ChatFrameBackground") + api:CreateBorder(self, self.HPborder, 1, 4) self.HPborder:SetBackdropBorderColor(180 / 255, 255 / 255, 0 / 255, 1) end @@ -264,7 +175,7 @@ end -- Create Party / Raid Threat Status Border function lum:CreateThreatBorder(self) self.ThreatBorder = CreateFrame("Frame", nil, self, "BackdropTemplate") - api:CreateBorder(self, self.ThreatBorder, 1, 3, "Interface\\ChatFrame\\ChatFrameBackground") + api:CreateBorder(self, self.ThreatBorder, 1, 3) self:RegisterEvent("UNIT_THREAT_LIST_UPDATE", UpdateThreat) self:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE", UpdateThreat) end @@ -328,6 +239,7 @@ local function PostUpdateClassPower(element, cur, max, diff, powerType) if not LastBar then return end + LastBar:SetStatusBarColor(r, g, b) LastBar.bg:SetColorTexture(r * 0.2, g * 0.2, b * 0.2) end @@ -407,7 +319,7 @@ local function CreateRuneBar(self) Rune:SetSize(width, 2) Rune:SetStatusBarTexture(m.textures.status_texture) - api:SetBackdrop(Rune, 2, 2, 2, 2) -- Backdrop + api:SetBackdrop(Rune, 2, 2, 2, 2) if (index == 1) then Rune:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -8) @@ -705,7 +617,7 @@ end -- ------------------------------------------ -- Group Role Indicator -local function UpdateRoleIcon(event) +local function UpdateRoleIcon(self, event) local lfdrole = self.GroupRoleIndicator local role = UnitGroupRolesAssigned(self.unit) @@ -727,8 +639,7 @@ function lum:CreateGroupRoleIndicator(self) local roleIcon = self.Health:CreateTexture(nil, "OVERLAY") roleIcon:SetPoint("LEFT", self, 8, 0) roleIcon:SetSize(16, 16) - roleIcon.Override = core.UpdateRoleIcon - + roleIcon.Override = UpdateRoleIcon self:RegisterEvent("UNIT_CONNECTION", UpdateRoleIcon) return roleIcon end diff --git a/shared.lua b/shared.lua index fc5d5ff..88dbd5e 100644 --- a/shared.lua +++ b/shared.lua @@ -54,7 +54,7 @@ function lum:SharedStyle(self, type) self.Health.bg = self.Health:CreateTexture(nil, "BACKGROUND") self.Health.bg:SetAllPoints(self.Health) - self.Health.bg:SetAlpha(0.1) + self.Health.bg:SetAlpha(0.05) self.Health.bg:SetTexture(m.textures.bg_texture) -- Power Bar @@ -103,6 +103,6 @@ function lum:SharedStyle(self, type) -- Drop Shadow if cfg.frames.shadow.show then - api:CreateDropShadow(self, 5, 5, {0, 0, 0, cfg.frames.shadow.opacity}) + api:CreateDropShadow(self, 6, 6) end end diff --git a/tasks.todo b/tasks.todo index c9d7d35..34b8069 100644 --- a/tasks.todo +++ b/tasks.todo @@ -1,10 +1,11 @@ general: - ☐ Add scale back to frames (player, party, target, etc) + ☐ Refactor @today + ✔ Add scale back to frames (player, party, target, etc) @done(20-10-25 20:12) party: ✔ Health is showing as depleted when 100% @bug @done(20-10-22 22:01) ☐ Finish the party frames - ☐ Add debuffs + ✔ Add debuffs @done(20-10-25 20:12) ☐ Add buffs? ☐ Add seperate layouts for healing specs and rest (even to detect spec on joining party) ☐ Add PhaseIndicator @@ -15,5 +16,5 @@ raid: ☐ Add PhaseIndicator nameplates: - ☐ Icon backdrop border not showing - ☐ Paladin holy power not showing on nameplate + ✔ Icon backdrop border not showing @done(20-10-26 00:12) + ✔ Paladin holy power not showing on nameplate @done(20-10-26 00:12) diff --git a/units/party.lua b/units/party.lua index 17eb67b..d82cf6b 100644 --- a/units/party.lua +++ b/units/party.lua @@ -74,34 +74,6 @@ local PostUpdatePower = function(power, unit, min, max) end end --- Post Update Aura Icon -local PostUpdateIcon = function(element, unit, icon, index) - local name, _, count, _, duration, expirationTime = UnitAura(unit, index, icon.filter) - - if duration and duration > 0 then - icon.timeLeft = expirationTime - GetTime() - else - icon.timeLeft = math.huge - end - - icon:SetScript( - "OnUpdate", - function(self, elapsed) - lum:AuraTimer_OnUpdate(self, elapsed) - end - ) -end - --- Filter Debuffs -local PartyDebuffsFilter = function(icons, unit, icon, name) - if name then - if debuffs.list[frame][name] or duration == 0 then -- Ignore debuffs in the party list - return false - end - end - return true -end - local PostUpdatePortrait = function(element, unit) element:SetModelAlpha(0.15) element:SetDesaturation(1) @@ -130,6 +102,7 @@ local createStyle = function(self) lum:CreateHealthValueString(self, font, cfg.fontsize - 2, "THINOUTLINE", 4, 8, "LEFT") lum:CreatePartyNameString(self, font, cfg.fontsize) + if self.cfg.health.classColoredText then self:Tag(self.Name, "[lum:playerstatus] [lum:leader] [raidcolor][lum:name]") end @@ -148,16 +121,24 @@ local createStyle = function(self) self.Portrait = Portrait end - -- Defuffs - local debuffs = lum:CreateAura(self, 12, 2, self.cfg.height / 2 + 2, 3) - debuffs:SetPoint("TOPRIGHT", self, "TOPLEFT", -6, 2) - debuffs.initialAnchor = "TOPRIGHT" - debuffs["growth-x"] = "LEFT" - debuffs["growth-y"] = "DOWN" - debuffs.showDebuffType = true - debuffs.CustomFilter = PartyDebuffsFilter - debuffs.PostUpdateIcon = PostUpdateIcon - self.Debuffs = debuffs + -- Debuffs + lum:SetDebuffAuras( + self, + frame, + 12, + 2, + self.cfg.height / 2 + 2, + 3, + "TOPRIGHT", + self, + "TOPLEFT", + -6, + 2, + "TOPRIGHT", + "LEFT", + "DOWN", + true + ) -- Group Role Icon local GroupRoleIndicator = lum:CreateGroupRoleIndicator(self) diff --git a/units/pet.lua b/units/pet.lua index a3c7f50..0bebbff 100644 --- a/units/pet.lua +++ b/units/pet.lua @@ -77,7 +77,7 @@ local createStyle = function(self) buffs.initialAnchor = "BOTTOMLEFT" buffs["growth-x"] = "RIGHT" buffs.PostUpdateIcon = PostUpdateIcon - if (self.cfg.buffs.filter) then + if (self.cfg.auras.buffs.filter) then buffs.CustomFilter = PetBuffsFilter end self.Buffs = buffs diff --git a/units/player.lua b/units/player.lua index 539d544..0ff0f6b 100644 --- a/units/player.lua +++ b/units/player.lua @@ -26,6 +26,43 @@ local PostUpdateHealth = function(health, unit, min, max) end end +local function PostCreateIcon(self, button) + local unit = self.__owner.unit + + local count = button.count + count:ClearAllPoints() + count:SetFont(m.fonts.font, 12, "OUTLINE") + count:SetPoint("TOPRIGHT", button, 3, 3) + + button.icon:SetTexCoord(.08, .92, .08, .92) + + button.overlay:SetTexture(m.textures.border) + button.overlay:SetTexCoord(0, 1, 0, 1) + button.overlay.Hide = function(self) + self:SetVertexColor(0.1, 0.1, 0.1) + end + + button.time = button:CreateFontString(nil, "OVERLAY") + button.time:SetFont(m.fonts.font, 12, "THINOUTLINE") + button.time:SetPoint("BOTTOMLEFT", button, -2, -2) + button.time:SetTextColor(1, 1, 0.65) + button.time:SetShadowOffset(1, -1) + button.time:SetShadowColor(0, 0, 0, 1) + button.time:SetJustifyH("CENTER") + + -- For player debuffs show the spell name + if cfg.units[unit].auras.debuffs.spellName then + button.spell = button:CreateFontString(nil, "OVERLAY") + button.spell:SetPoint("RIGHT", button, "LEFT", -4, 0) + button.spell:SetFont(m.fonts.font, 16, "THINOUTLINE") + button.spell:SetTextColor(1, 1, 1) + button.spell:SetShadowOffset(1, -1) + button.spell:SetShadowColor(0, 0, 0, 1) + button.spell:SetJustifyH("RIGHT") + button.spell:SetWordWrap(false) + end +end + -- ----------------------------------- -- > PLAYER STYLE -- ----------------------------------- @@ -66,7 +103,8 @@ local createStyle = function(self) lum:CreateArtifactPowerBar(self) -- Auras - lum:SetDebuffAuras( + local debuffs = + lum:SetDebuffAuras( self, frame, 12, @@ -79,10 +117,11 @@ local createStyle = function(self) -56, -2, "BOTTOMRIGHT", - "UP", nil, + "UP", true ) + debuffs.PostCreateIcon = PostCreateIcon lum:SetBarTimerAuras( self, diff --git a/units/target.lua b/units/target.lua index 948f49b..8855a00 100644 --- a/units/target.lua +++ b/units/target.lua @@ -67,8 +67,8 @@ local createStyle = function(self) 0, 2, "BOTTOMLEFT", - nil, "RIGHT", + "DOWN", true )