From 2f69f2a89f66dc619b2dc2db4741011f20d3391a Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Thu, 16 May 2024 19:06:08 +0700 Subject: [PATCH 01/21] health: Add temp max health loss sub-widget --- elements/health.lua | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/elements/health.lua b/elements/health.lua index 3e834ef4..5def924f 100644 --- a/elements/health.lua +++ b/elements/health.lua @@ -173,16 +173,24 @@ local function Update(self, event, unit) element.cur = cur element.max = max - --[[ Callback: Health:PostUpdate(unit, cur, max) + local lossPerc = 0 + if(element.TempLoss) then + lossPerc = Clamp(GetUnitTotalModifiedMaxHealthPercent(unit), 0, 1) + + element.TempLoss:SetValue(lossPerc) + end + + --[[ Callback: Health:PostUpdate(unit, cur, max, lossPerc) Called after the element has been updated. - * self - the Health element - * unit - the unit for which the update has been triggered (string) - * cur - the unit's current health value (number) - * max - the unit's maximum possible health value (number) + * self - the Health element + * unit - the unit for which the update has been triggered (string) + * cur - the unit's current health value (number) + * max - the unit's maximum possible health value (number) + * lossPerc - the percent by which the unit's max health has been temporarily reduced (number) --]] if(element.PostUpdate) then - element:PostUpdate(unit, cur, max) + element:PostUpdate(unit, cur, max, lossPerc) end end @@ -310,6 +318,21 @@ local function Enable(self) element:Show() + if(element.TempLoss) then + self:RegisterEvent('UNIT_MAX_HEALTH_MODIFIERS_CHANGED', Path) + + if(element.TempLoss:IsObjectType('StatusBar')) then + element.TempLoss:SetMinMaxValues(0, 1) + element.TempLoss:SetValue(0) + + if(not element.TempLoss:GetStatusBarTexture()) then + element.TempLoss:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]]) + end + end + + element.TempLoss:Show() + end + return true end end @@ -325,6 +348,11 @@ local function Disable(self) self:UnregisterEvent('UNIT_FACTION', ColorPath) self:UnregisterEvent('UNIT_FLAGS', ColorPath) self:UnregisterEvent('UNIT_THREAT_LIST_UPDATE', ColorPath) + self:UnregisterEvent('UNIT_MAX_HEALTH_MODIFIERS_CHANGED', Path) + + if(element.TempLoss) then + element.TempLoss:Hide() + end end end From 6d9f462e90ea744825ffe2b1682fc4a92ec78aa6 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Sat, 15 Jun 2024 22:59:27 +0700 Subject: [PATCH 02/21] grouproleindicator: Update API --- elements/grouproleindicator.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/elements/grouproleindicator.lua b/elements/grouproleindicator.lua index cc7329f1..b80c10e8 100644 --- a/elements/grouproleindicator.lua +++ b/elements/grouproleindicator.lua @@ -25,6 +25,17 @@ A default texture will be applied if the widget is a Texture and doesn't have a local _, ns = ... local oUF = ns.oUF +-- sourced from Interface\AddOns\Blizzard_Deprecated\Deprecated_10_1_5.lua +local function GetTexCoordsForRoleSmallCircle(role) + if(role == 'TANK') then + return 0, 19 / 64, 22 / 64, 41 / 64 + elseif(role == 'HEALER') then + return 20 / 64, 39 / 64, 1 / 64, 20 / 64 + elseif(role == 'DAMAGER') then + return 20 / 64, 39 / 64, 22 / 64, 41 / 64 + end +end + local function Update(self, event) local element = self.GroupRoleIndicator From 95c244a6fb9fe65e8728171ad0db4cd57c83bb47 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Sat, 15 Jun 2024 23:00:09 +0700 Subject: [PATCH 03/21] range: Use events to drive updates --- elements/range.lua | 39 ++------------------------------------- 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/elements/range.lua b/elements/range.lua index 071e32d3..892bf84c 100644 --- a/elements/range.lua +++ b/elements/range.lua @@ -28,11 +28,6 @@ Offline units are handled as if they are in range. local _, ns = ... local oUF = ns.oUF -local _FRAMES = {} -local OnRangeFrame - -local UnitInRange, UnitIsConnected = UnitInRange, UnitIsConnected - local function Update(self, event) local element = self.Range local unit = self.unit @@ -83,22 +78,6 @@ local function Path(self, ...) return (self.Range.Override or Update) (self, ...) end --- Internal updating method -local timer = 0 -local function OnRangeUpdate(_, elapsed) - timer = timer + elapsed - - if(timer >= .20) then - for _, object in next, _FRAMES do - if(object:IsShown()) then - Path(object, 'OnUpdate') - end - end - - timer = 0 - end -end - local function Enable(self) local element = self.Range if(element) then @@ -106,13 +85,7 @@ local function Enable(self) element.insideAlpha = element.insideAlpha or 1 element.outsideAlpha = element.outsideAlpha or 0.55 - if(not OnRangeFrame) then - OnRangeFrame = CreateFrame('Frame') - OnRangeFrame:SetScript('OnUpdate', OnRangeUpdate) - end - - table.insert(_FRAMES, self) - OnRangeFrame:Show() + self:RegisterEvent('UNIT_IN_RANGE_UPDATE', Path) return true end @@ -121,17 +94,9 @@ end local function Disable(self) local element = self.Range if(element) then - for index, frame in next, _FRAMES do - if(frame == self) then - table.remove(_FRAMES, index) - break - end - end self:SetAlpha(element.insideAlpha) - if(#_FRAMES == 0) then - OnRangeFrame:Hide() - end + self:UnregisterEvent('UNIT_IN_RANGE_UPDATE', Path) end end From 441c3f8bfd295689ab0878634c1740c73c06ebf6 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Sat, 15 Jun 2024 23:08:05 +0700 Subject: [PATCH 04/21] healthprediction: Add optional element size adjustment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's needed due to the nature of the element, but if layout devs want to do something else they can always override the whole thing 😵 --- elements/healthprediction.lua | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/elements/healthprediction.lua b/elements/healthprediction.lua index 19e61c42..dc225151 100644 --- a/elements/healthprediction.lua +++ b/elements/healthprediction.lua @@ -81,6 +81,30 @@ A default texture will be applied to the Texture widgets if they don't have a te local _, ns = ... local oUF = ns.oUF +local function UpdateSize(self, event, unit) + if(not self.Health or self.unit ~= unit) then return end + + local element = self.HealthPrediction + local isHoriz = self.Health:GetOrientation() == 'HORIZONTAL' + local newSize = self.Health[isHoriz and 'GetWidth' or 'GetHeight'](self.Health) + + if(element.myBar) then + element.myBar[isHoriz and 'SetWidth' or 'SetHeight'](element.myBar, newSize) + end + + if(element.otherBar) then + element.otherBar[isHoriz and 'SetWidth' or 'SetHeight'](element.otherBar, newSize) + end + + if(element.absorbBar) then + element.absorbBar[isHoriz and 'SetWidth' or 'SetHeight'](element.absorbBar, newSize) + end + + if(element.healAbsorbBar) then + element.healAbsorbBar[isHoriz and 'SetWidth' or 'SetHeight'](element.healAbsorbBar, newSize) + end +end + local function Update(self, event, unit) if(self.unit ~= unit) then return end @@ -194,7 +218,11 @@ local function Update(self, event, unit) end end -local function Path(self, ...) +local function Path(self, event, ...) + if(event == 'UpdateAllElements' or event == 'UNIT_MAX_HEALTH_MODIFIERS_CHANGED') then + (self.HealthPrediction.UpdateSize or UpdateSize) (self, event, ...) + end + --[[ Override: HealthPrediction.Override(self, event, unit) Used to completely override the internal update function. @@ -202,7 +230,7 @@ local function Path(self, ...) * event - the event triggering the update (string) * unit - the unit accompanying the event --]] - return (self.HealthPrediction.Override or Update) (self, ...) + return (self.HealthPrediction.Override or Update) (self, event, ...) end local function ForceUpdate(element) @@ -220,6 +248,7 @@ local function Enable(self) self:RegisterEvent('UNIT_HEAL_PREDICTION', Path) self:RegisterEvent('UNIT_ABSORB_AMOUNT_CHANGED', Path) self:RegisterEvent('UNIT_HEAL_ABSORB_AMOUNT_CHANGED', Path) + self:RegisterEvent('UNIT_MAX_HEALTH_MODIFIERS_CHANGED', Path) if(not element.maxOverflow) then element.maxOverflow = 1.05 @@ -299,6 +328,7 @@ local function Disable(self) self:UnregisterEvent('UNIT_HEAL_PREDICTION', Path) self:UnregisterEvent('UNIT_ABSORB_AMOUNT_CHANGED', Path) self:UnregisterEvent('UNIT_HEAL_ABSORB_AMOUNT_CHANGED', Path) + self:UnregisterEvent('UNIT_MAX_HEALTH_MODIFIERS_CHANGED', Path) end end From b4ec20f119be0c223b8909b1436984f6e2be21c9 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Sat, 15 Jun 2024 23:15:33 +0700 Subject: [PATCH 05/21] Make linter happy --- .luacheckrc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.luacheckrc b/.luacheckrc index 62e10fe5..5ec1b6b0 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -24,6 +24,7 @@ read_globals = { -- FrameXML 'BossTargetFrameContainer', + 'Clamp', 'ColorMixin', 'ComboFrame', 'CompactArenaFrame', @@ -78,6 +79,7 @@ read_globals = { 'GetUnitPowerBarInfo', 'GetUnitPowerBarInfoByID', 'GetUnitPowerBarStringsByID', + 'GetUnitTotalModifiedMaxHealthPercent', 'HasLFGRestrictions', 'InCombatLockdown', 'IsLoggedIn', From 9d2853f46fee7f992d47a5fa1b0facf4fd7b197c Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Sun, 16 Jun 2024 01:09:44 +0700 Subject: [PATCH 06/21] powerprediction: Update API --- .luacheckrc | 1 + elements/powerprediction.lua | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.luacheckrc b/.luacheckrc index 5ec1b6b0..b93b0b7b 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -54,6 +54,7 @@ read_globals = { 'C_IncomingSummon', 'C_NamePlate', 'C_PvP', + 'C_Spell', 'C_UnitAuras', -- API diff --git a/elements/powerprediction.lua b/elements/powerprediction.lua index 16ea122f..0b3c2f00 100644 --- a/elements/powerprediction.lua +++ b/elements/powerprediction.lua @@ -71,7 +71,9 @@ local function Update(self, event, unit) local mainCost, altCost = 0, 0 if(event == 'UNIT_SPELLCAST_START' and startTime ~= endTime) then - local costTable = GetSpellPowerCost(spellID) + local costTable = C_Spell.GetSpellPowerCost(spellID) + if(not costTable) then return end + -- hasRequiredAura is always false if there's only 1 subtable local checkRequiredAura = #costTable > 1 From cc254bdf398d4b434d0e52fbc6112867e2eee592 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Sun, 16 Jun 2024 18:48:35 +0700 Subject: [PATCH 07/21] health: Keep max hp reduction event registered --- elements/health.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/elements/health.lua b/elements/health.lua index 5def924f..fd01e21f 100644 --- a/elements/health.lua +++ b/elements/health.lua @@ -311,6 +311,7 @@ local function Enable(self) self:RegisterEvent('UNIT_HEALTH', Path) self:RegisterEvent('UNIT_MAXHEALTH', Path) + self:RegisterEvent('UNIT_MAX_HEALTH_MODIFIERS_CHANGED', Path) if(element:IsObjectType('StatusBar') and not element:GetStatusBarTexture()) then element:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]]) @@ -319,8 +320,6 @@ local function Enable(self) element:Show() if(element.TempLoss) then - self:RegisterEvent('UNIT_MAX_HEALTH_MODIFIERS_CHANGED', Path) - if(element.TempLoss:IsObjectType('StatusBar')) then element.TempLoss:SetMinMaxValues(0, 1) element.TempLoss:SetValue(0) From 40fc8ae3c0b1fa97bdf1fc7fc9516d7178b004f8 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Sun, 16 Jun 2024 19:29:13 +0700 Subject: [PATCH 08/21] healthprediction: Use legit events --- elements/healthprediction.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elements/healthprediction.lua b/elements/healthprediction.lua index dc225151..e0cf654b 100644 --- a/elements/healthprediction.lua +++ b/elements/healthprediction.lua @@ -219,7 +219,7 @@ local function Update(self, event, unit) end local function Path(self, event, ...) - if(event == 'UpdateAllElements' or event == 'UNIT_MAX_HEALTH_MODIFIERS_CHANGED') then + if(event == 'OnShow' or event == 'RefreshUnit' or event == 'UNIT_MAX_HEALTH_MODIFIERS_CHANGED') then (self.HealthPrediction.UpdateSize or UpdateSize) (self, event, ...) end From b498fadd878c1c4482c92d717ad54f49ad0e6ed9 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Sun, 16 Jun 2024 20:17:16 +0700 Subject: [PATCH 09/21] healthprediction: Remove dynamic size adjustment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For now... 😵 --- elements/healthprediction.lua | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/elements/healthprediction.lua b/elements/healthprediction.lua index e0cf654b..19e61c42 100644 --- a/elements/healthprediction.lua +++ b/elements/healthprediction.lua @@ -81,30 +81,6 @@ A default texture will be applied to the Texture widgets if they don't have a te local _, ns = ... local oUF = ns.oUF -local function UpdateSize(self, event, unit) - if(not self.Health or self.unit ~= unit) then return end - - local element = self.HealthPrediction - local isHoriz = self.Health:GetOrientation() == 'HORIZONTAL' - local newSize = self.Health[isHoriz and 'GetWidth' or 'GetHeight'](self.Health) - - if(element.myBar) then - element.myBar[isHoriz and 'SetWidth' or 'SetHeight'](element.myBar, newSize) - end - - if(element.otherBar) then - element.otherBar[isHoriz and 'SetWidth' or 'SetHeight'](element.otherBar, newSize) - end - - if(element.absorbBar) then - element.absorbBar[isHoriz and 'SetWidth' or 'SetHeight'](element.absorbBar, newSize) - end - - if(element.healAbsorbBar) then - element.healAbsorbBar[isHoriz and 'SetWidth' or 'SetHeight'](element.healAbsorbBar, newSize) - end -end - local function Update(self, event, unit) if(self.unit ~= unit) then return end @@ -218,11 +194,7 @@ local function Update(self, event, unit) end end -local function Path(self, event, ...) - if(event == 'OnShow' or event == 'RefreshUnit' or event == 'UNIT_MAX_HEALTH_MODIFIERS_CHANGED') then - (self.HealthPrediction.UpdateSize or UpdateSize) (self, event, ...) - end - +local function Path(self, ...) --[[ Override: HealthPrediction.Override(self, event, unit) Used to completely override the internal update function. @@ -230,7 +202,7 @@ local function Path(self, event, ...) * event - the event triggering the update (string) * unit - the unit accompanying the event --]] - return (self.HealthPrediction.Override or Update) (self, event, ...) + return (self.HealthPrediction.Override or Update) (self, ...) end local function ForceUpdate(element) @@ -248,7 +220,6 @@ local function Enable(self) self:RegisterEvent('UNIT_HEAL_PREDICTION', Path) self:RegisterEvent('UNIT_ABSORB_AMOUNT_CHANGED', Path) self:RegisterEvent('UNIT_HEAL_ABSORB_AMOUNT_CHANGED', Path) - self:RegisterEvent('UNIT_MAX_HEALTH_MODIFIERS_CHANGED', Path) if(not element.maxOverflow) then element.maxOverflow = 1.05 @@ -328,7 +299,6 @@ local function Disable(self) self:UnregisterEvent('UNIT_HEAL_PREDICTION', Path) self:UnregisterEvent('UNIT_ABSORB_AMOUNT_CHANGED', Path) self:UnregisterEvent('UNIT_HEAL_ABSORB_AMOUNT_CHANGED', Path) - self:UnregisterEvent('UNIT_MAX_HEALTH_MODIFIERS_CHANGED', Path) end end From d8b4df8d612eb68356c0f080f56002ff226029d9 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Mon, 17 Jun 2024 10:26:04 +0700 Subject: [PATCH 10/21] healthprediction: Add dynamic size adjustment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Again... But this time around it should actually work 😅 --- elements/healthprediction.lua | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/elements/healthprediction.lua b/elements/healthprediction.lua index 19e61c42..776d339b 100644 --- a/elements/healthprediction.lua +++ b/elements/healthprediction.lua @@ -81,6 +81,26 @@ A default texture will be applied to the Texture widgets if they don't have a te local _, ns = ... local oUF = ns.oUF +local function UpdateSize(self, event, unit) + local element = self.HealthPrediction + + if(element.myBar) then + element.myBar[element.isHoriz and 'SetWidth' or 'SetHeight'](element.myBar, element.size) + end + + if(element.otherBar) then + element.otherBar[element.isHoriz and 'SetWidth' or 'SetHeight'](element.otherBar, element.size) + end + + if(element.absorbBar) then + element.absorbBar[element.isHoriz and 'SetWidth' or 'SetHeight'](element.absorbBar, element.size) + end + + if(element.healAbsorbBar) then + element.healAbsorbBar[element.isHoriz and 'SetWidth' or 'SetHeight'](element.healAbsorbBar, element.size) + end +end + local function Update(self, event, unit) if(self.unit ~= unit) then return end @@ -194,7 +214,24 @@ local function Update(self, event, unit) end end +local function shouldUpdateSize(self) + if(not self.Health) then return end + + local isHoriz = self.Health:GetOrientation() == 'HORIZONTAL' + local newSize = self.Health[isHoriz and 'GetWidth' or 'GetHeight'](self.Health) + if(isHoriz ~= self.HealthPrediction.isHoriz or newSize ~= self.HealthPrediction.size) then + self.HealthPrediction.isHoriz = isHoriz + self.HealthPrediction.size = newSize + + return true + end +end + local function Path(self, ...) + if(shouldUpdateSize(self)) then + (self.HealthPrediction.UpdateSize or UpdateSize) (self, ...) + end + --[[ Override: HealthPrediction.Override(self, event, unit) Used to completely override the internal update function. @@ -206,6 +243,9 @@ local function Path(self, ...) end local function ForceUpdate(element) + element.isHoriz = nil + element.size = nil + return Path(element.__owner, 'ForceUpdate', element.__owner.unit) end @@ -220,6 +260,7 @@ local function Enable(self) self:RegisterEvent('UNIT_HEAL_PREDICTION', Path) self:RegisterEvent('UNIT_ABSORB_AMOUNT_CHANGED', Path) self:RegisterEvent('UNIT_HEAL_ABSORB_AMOUNT_CHANGED', Path) + self:RegisterEvent('UNIT_MAX_HEALTH_MODIFIERS_CHANGED', Path) if(not element.maxOverflow) then element.maxOverflow = 1.05 @@ -299,6 +340,7 @@ local function Disable(self) self:UnregisterEvent('UNIT_HEAL_PREDICTION', Path) self:UnregisterEvent('UNIT_ABSORB_AMOUNT_CHANGED', Path) self:UnregisterEvent('UNIT_HEAL_ABSORB_AMOUNT_CHANGED', Path) + self:UnregisterEvent('UNIT_MAX_HEALTH_MODIFIERS_CHANGED', Path) end end From 1b749ac9482411fb0ac8d6292eacb018e663d57d Mon Sep 17 00:00:00 2001 From: Adrian L Lange Date: Tue, 9 Jul 2024 17:57:14 +0200 Subject: [PATCH 11/21] Point links to warcraft.wiki.gg --- colors.lua | 4 ++-- elements/additionalpower.lua | 2 +- elements/alternativepower.lua | 8 ++++---- elements/auras.lua | 6 +++--- elements/classpower.lua | 2 +- elements/grouproleindicator.lua | 2 +- elements/health.lua | 8 ++++---- elements/power.lua | 14 +++++++------- elements/runes.lua | 2 +- elements/threatindicator.lua | 4 ++-- ouf.lua | 2 +- 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/colors.lua b/colors.lua index 613fc004..ccf84d4d 100644 --- a/colors.lua +++ b/colors.lua @@ -33,7 +33,7 @@ local colorMixin = { } --[[ Colors: oUF:CreateColor(r, g, b[, a]) -Wrapper for [SharedXML\Color.lua's ColorMixin](https://wowpedia.fandom.com/wiki/ColorMixin), extended to support indexed colors used in oUF, as +Wrapper for [SharedXML\Color.lua's ColorMixin](https://warcraft.wiki.gg/wiki/ColorMixin), extended to support indexed colors used in oUF, as well as extra methods for dealing with atlases. The rgb values can be either normalized (0-1) or bytes (0-255). @@ -211,7 +211,7 @@ local function colorsAndPercent(a, b, ...) return relperc, select((segment * 3) + 1, ...) end --- http://www.wowwiki.com/ColorGradient +-- https://warcraft.wiki.gg/wiki/ColorGradient --[[ Colors: oUF:RGBColorGradient(a, b, ...) Used to convert a percent value (the quotient of `a` and `b`) into a gradient from 2 or more RGB colors. If more than 2 colors are passed, the gradient will be between the two colors which perc lies in an evenly divided range. A RGB color diff --git a/elements/additionalpower.lua b/elements/additionalpower.lua index 2047a78d..7c528bdf 100644 --- a/elements/additionalpower.lua +++ b/elements/additionalpower.lua @@ -27,7 +27,7 @@ The following options are listed by priority. The first check that returns true .colorPower - Use `self.colors.power[token]` to color the bar based on the player's additional power type (boolean) .colorClass - Use `self.colors.class[class]` to color the bar based on unit class. `class` is defined by the - second return of [UnitClass](http://wowprogramming.com/docs/api/UnitClass.html) (boolean) + second return of [UnitClass](https://warcraft.wiki.gg/wiki/API_UnitClass) (boolean) .colorSmooth - Use `self.colors.smooth` to color the bar with a smooth gradient based on the player's current additional power percentage (boolean) diff --git a/elements/alternativepower.lua b/elements/alternativepower.lua index 735d58fd..f8194ce0 100644 --- a/elements/alternativepower.lua +++ b/elements/alternativepower.lua @@ -22,18 +22,18 @@ A default texture will be applied if the widget is a StatusBar and doesn't have The following options are listed by priority. The first check that returns true decides the color of the bar. .colorThreat - Use `self.colors.threat[threat]` to color the bar based on the unit's threat status. `threat` is - defined by the first return of [UnitThreatSituation](https://wow.gamepedia.com/API_UnitThreatSituation) (boolean) + defined by the first return of [UnitThreatSituation](https://warcraft.wiki.gg/wiki/API_UnitThreatSituation) (boolean) .colorPower - Use `self.colors.power[token]` to color the bar based on the unit's alternative power type (boolean) .colorClass - Use `self.colors.class[class]` to color the bar based on unit class. `class` is defined by the - second return of [UnitClass](http://wowprogramming.com/docs/api/UnitClass.html) (boolean) + second return of [UnitClass](https://warcraft.wiki.gg/wiki/API_UnitClass) (boolean) .colorClassNPC - Use `self.colors.class[class]` to color the bar if the unit is a NPC (boolean) .colorSelection - Use `self.colors.selection[selection]` to color the bar based on the unit's selection color. `selection` is defined by the return value of Private.unitSelectionType, a wrapper function - for [UnitSelectionType](https://wow.gamepedia.com/API_UnitSelectionType) (boolean) + for [UnitSelectionType](https://warcraft.wiki.gg/wiki/API_UnitSelectionType) (boolean) .colorReaction - Use `self.colors.reaction[reaction]` to color the bar based on the player's reaction towards the unit. `reaction` is defined by the return value of - [UnitReaction](http://wowprogramming.com/docs/api/UnitReaction.html) (boolean) + [UnitReaction](https://warcraft.wiki.gg/wiki/API_UnitReaction) (boolean) .colorSmooth - Use `self.colors.smooth` to color the bar with a smooth gradient based on the unit's current alternative power percentage (boolean) diff --git a/elements/auras.lua b/elements/auras.lua index 4eb9c2d9..31b12320 100644 --- a/elements/auras.lua +++ b/elements/auras.lua @@ -236,7 +236,7 @@ local function updateAura(element, unit, data, position) * self - the widget holding the aura buttons * button - the updated aura button (Button) * unit - the unit for which the update has been triggered (string) - * data - the [UnitAuraInfo](https://wowpedia.fandom.com/wiki/Struct_UnitAuraInfo) object (table) + * data - the [AuraData](https://warcraft.wiki.gg/wiki/Struct_AuraData) object (table) * position - the actual position of the aura button (number) --]] if(element.PostUpdateButton) then @@ -273,7 +273,7 @@ local function processData(element, unit, data) * self - the widget holding the aura buttons * unit - the unit for which the update has been triggered (string) - * data - [UnitAuraInfo](https://wowpedia.fandom.com/wiki/Struct_UnitAuraInfo) object (table) + * data - [AuraData](https://warcraft.wiki.gg/wiki/Struct_AuraData) object (table) ## Returns @@ -333,7 +333,7 @@ local function UpdateAuras(self, event, unit, updateInfo) * self - the widget holding the aura buttons * unit - the unit for which the update has been triggered (string) - * data - [UnitAuraInfo](https://wowpedia.fandom.com/wiki/Struct_UnitAuraInfo) object (table) + * data - [AuraData](https://warcraft.wiki.gg/wiki/Struct_AuraData) object (table) ## Returns diff --git a/elements/classpower.lua b/elements/classpower.lua index 8ad91a07..3f497b2e 100644 --- a/elements/classpower.lua +++ b/elements/classpower.lua @@ -5,7 +5,7 @@ Handles the visibility and updating of the player's class resources (like Chi Or ## Widget -ClassPower - An `table` consisting of as many StatusBars as the theoretical maximum return of [UnitPowerMax](http://wowprogramming.com/docs/api/UnitPowerMax.html). +ClassPower - An `table` consisting of as many StatusBars as the theoretical maximum return of [UnitPowerMax](https://warcraft.wiki.gg/wiki/API_UnitPowerMax). ## Sub-Widgets diff --git a/elements/grouproleindicator.lua b/elements/grouproleindicator.lua index b80c10e8..00d6f139 100644 --- a/elements/grouproleindicator.lua +++ b/elements/grouproleindicator.lua @@ -60,7 +60,7 @@ local function Update(self, event) Called after the element has been updated. * self - the GroupRoleIndicator element - * role - the role as returned by [UnitGroupRolesAssigned](http://wowprogramming.com/docs/api/UnitGroupRolesAssigned.html) + * role - the role as returned by [UnitGroupRolesAssigned](https://warcraft.wiki.gg/wiki/API_UnitGroupRolesAssigned) --]] if(element.PostUpdate) then return element:PostUpdate(role) diff --git a/elements/health.lua b/elements/health.lua index fd01e21f..0c0f4b05 100644 --- a/elements/health.lua +++ b/elements/health.lua @@ -26,18 +26,18 @@ The following options are listed by priority. The first check that returns true .colorDisconnected - Use `self.colors.disconnected` to color the bar if the unit is offline (boolean) .colorTapping - Use `self.colors.tapping` to color the bar if the unit isn't tapped by the player (boolean) .colorThreat - Use `self.colors.threat[threat]` to color the bar based on the unit's threat status. `threat` is - defined by the first return of [UnitThreatSituation](https://wow.gamepedia.com/API_UnitThreatSituation) (boolean) + defined by the first return of [UnitThreatSituation](https://warcraft.wiki.gg/wiki/API_UnitThreatSituation) (boolean) .colorClass - Use `self.colors.class[class]` to color the bar based on unit class. `class` is defined by the - second return of [UnitClass](http://wowprogramming.com/docs/api/UnitClass.html) (boolean) + second return of [UnitClass](https://warcraft.wiki.gg/wiki/API_UnitClass) (boolean) .colorClassNPC - Use `self.colors.class[class]` to color the bar if the unit is a NPC (boolean) .colorClassPet - Use `self.colors.class[class]` to color the bar if the unit is player controlled, but not a player (boolean) .colorSelection - Use `self.colors.selection[selection]` to color the bar based on the unit's selection color. `selection` is defined by the return value of Private.unitSelectionType, a wrapper function - for [UnitSelectionType](https://wow.gamepedia.com/API_UnitSelectionType) (boolean) + for [UnitSelectionType](https://warcraft.wiki.gg/wiki/API_UnitSelectionType) (boolean) .colorReaction - Use `self.colors.reaction[reaction]` to color the bar based on the player's reaction towards the unit. `reaction` is defined by the return value of - [UnitReaction](http://wowprogramming.com/docs/api/UnitReaction.html) (boolean) + [UnitReaction](https://warcraft.wiki.gg/wiki/API_UnitReaction) (boolean) .colorSmooth - Use `smoothGradient` if present or `self.colors.smooth` to color the bar with a smooth gradient based on the player's current health percentage (boolean) .colorHealth - Use `self.colors.health` to color the bar. This flag is used to reset the bar color back to default diff --git a/elements/power.lua b/elements/power.lua index 64705d02..8768142d 100644 --- a/elements/power.lua +++ b/elements/power.lua @@ -31,24 +31,24 @@ The following options are listed by priority. The first check that returns true .colorDisconnected - Use `self.colors.disconnected` to color the bar if the unit is offline (boolean) .colorTapping - Use `self.colors.tapping` to color the bar if the unit isn't tapped by the player (boolean) .colorThreat - Use `self.colors.threat[threat]` to color the bar based on the unit's threat status. `threat` is - defined by the first return of [UnitThreatSituation](https://wow.gamepedia.com/API_UnitThreatSituation) (boolean) + defined by the first return of [UnitThreatSituation](https://warcraft.wiki.gg/wiki/API_UnitThreatSituation) (boolean) .colorPower - Use `self.colors.power[token]` to color the bar based on the unit's power type. This method will fall-back to `:GetAlternativeColor()` if it can't find a color matching the token. If this function isn't defined, then it will attempt to color based upon the alternative power colors returned by - [UnitPowerType](http://wowprogramming.com/docs/api/UnitPowerType.html). If these aren't + [UnitPowerType](https://warcraft.wiki.gg/wiki/API_UnitPowerType). If these aren't defined, then it will attempt to color the bar based upon `self.colors.power[type]`. In case of failure it'll default to `self.colors.power.MANA` (boolean) .colorClass - Use `self.colors.class[class]` to color the bar based on unit class. `class` is defined by the - second return of [UnitClass](http://wowprogramming.com/docs/api/UnitClass.html) (boolean) + second return of [UnitClass](https://warcraft.wiki.gg/wiki/API_UnitClass) (boolean) .colorClassNPC - Use `self.colors.class[class]` to color the bar if the unit is a NPC (boolean) .colorClassPet - Use `self.colors.class[class]` to color the bar if the unit is player controlled, but not a player (boolean) .colorSelection - Use `self.colors.selection[selection]` to color the bar based on the unit's selection color. `selection` is defined by the return value of Private.unitSelectionType, a wrapper function - for [UnitSelectionType](https://wow.gamepedia.com/API_UnitSelectionType) (boolean) + for [UnitSelectionType](https://warcraft.wiki.gg/wiki/API_UnitSelectionType) (boolean) .colorReaction - Use `self.colors.reaction[reaction]` to color the bar based on the player's reaction towards the unit. `reaction` is defined by the return value of - [UnitReaction](http://wowprogramming.com/docs/api/UnitReaction.html) (boolean) + [UnitReaction](https://warcraft.wiki.gg/wiki/API_UnitReaction) (boolean) .colorSmooth - Use `smoothGradient` if present or `self.colors.smooth` to color the bar with a smooth gradient based on the player's current power percentage (boolean) @@ -98,8 +98,8 @@ local ALTERNATE_POWER_INDEX = Enum.PowerType.Alternate or 10 --[[ Override: Power:GetDisplayPower() Used to get info on the unit's alternative power, if any. -Should return the power type index (see [Enum.PowerType.Alternate](https://wow.gamepedia.com/Enum_Unit.PowerType)) -and the minimum value for the given power type (see [info.minPower](https://wow.gamepedia.com/API_GetUnitPowerBarInfo)) +Should return the power type index (see [Enum.PowerType.Alternate](https://warcraft.wiki.gg/wiki/Enum.PowerType)) +and the minimum value for the given power type (see [info.minPower](https://warcraft.wiki.gg/wiki/API_GetUnitPowerBarInfo)) or nil if the unit has no alternative (alternate) power or it should not be displayed. In case of a nil return, the element defaults to the primary power type and zero for the minimum value. diff --git a/elements/runes.lua b/elements/runes.lua index 6c42c7bd..f86639d2 100644 --- a/elements/runes.lua +++ b/elements/runes.lua @@ -18,7 +18,7 @@ A default texture will be applied if the sub-widgets are StatusBars and don't ha ## Options .colorSpec - Use `self.colors.runes[specID]` to color the bar based on player's spec. `specID` is defined by the return - value of [GetSpecialization](http://wowprogramming.com/docs/api/GetSpecialization.html) (boolean) + value of [GetSpecialization](https://warcraft.wiki.gg/wiki/API_GetSpecialization) (boolean) .sortOrder - Sorting order. Sorts by the remaining cooldown time, 'asc' - from the least cooldown time remaining (fully charged) to the most (fully depleted), 'desc' - the opposite (string?)['asc', 'desc'] diff --git a/elements/threatindicator.lua b/elements/threatindicator.lua index 21f42f06..6d1c10ce 100644 --- a/elements/threatindicator.lua +++ b/elements/threatindicator.lua @@ -15,7 +15,7 @@ A default texture will be applied if the widget is a Texture and doesn't have a ## Options .feedbackUnit - The unit whose threat situation is being requested. If defined, it'll be passed as the first argument to - [UnitThreatSituation](https://wow.gamepedia.com/API_UnitThreatSituation). + [UnitThreatSituation](https://warcraft.wiki.gg/wiki/API_UnitThreatSituation). ## Examples @@ -78,7 +78,7 @@ local function Update(self, event, unit) * self - the ThreatIndicator element * unit - the unit for which the update has been triggered (string) - * status - the unit's threat status (see [UnitThreatSituation](http://wowprogramming.com/docs/api/UnitThreatSituation.html)) + * status - the unit's threat status (see [UnitThreatSituation](https://warcraft.wiki.gg/wiki/API_UnitThreatSituation)) * r - the red color component based on the unit's threat status (number?)[0-1] * g - the green color component based on the unit's threat status (number?)[0-1] * b - the blue color component based on the unit's threat status (number?)[0-1] diff --git a/ouf.lua b/ouf.lua index 4eae223b..879165c8 100644 --- a/ouf.lua +++ b/ouf.lua @@ -620,7 +620,7 @@ do * template - name of a template to be used for creating the header. Defaults to `'SecureGroupHeaderTemplate'` (string?) * visibility - macro conditional(s) which define when to display the header (string). - * ... - further argument pairs. Consult [Group Headers](http://wowprogramming.com/docs/secure_template/Group_Headers.html) + * ... - further argument pairs. Consult [Group Headers](https://warcraft.wiki.gg/wiki/SecureGroupHeaderTemplate) for possible values. In addition to the standard group headers, oUF implements some of its own attributes. These can be supplied by the From ee21f06f76f4a5ae9188c76f233e70bac8e2f001 Mon Sep 17 00:00:00 2001 From: Adrian L Lange Date: Tue, 9 Jul 2024 17:58:56 +0200 Subject: [PATCH 12/21] colors: Use provided enum --- colors.lua | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/colors.lua b/colors.lua index ccf84d4d..858f561c 100644 --- a/colors.lua +++ b/colors.lua @@ -168,32 +168,32 @@ for power, color in next, PowerBarColor do end end --- sourced from FrameXML/Constants.lua -colors.power[0] = colors.power.MANA -colors.power[1] = colors.power.RAGE -colors.power[2] = colors.power.FOCUS -colors.power[3] = colors.power.ENERGY -colors.power[4] = colors.power.COMBO_POINTS -colors.power[5] = colors.power.RUNES -colors.power[6] = colors.power.RUNIC_POWER -colors.power[7] = colors.power.SOUL_SHARDS -colors.power[8] = colors.power.LUNAR_POWER -colors.power[9] = colors.power.HOLY_POWER -colors.power[11] = colors.power.MAELSTROM -colors.power[12] = colors.power.CHI -colors.power[13] = colors.power.INSANITY -colors.power[16] = colors.power.ARCANE_CHARGES -colors.power[17] = colors.power.FURY -colors.power[18] = colors.power.PAIN +-- fallback integer index to named index +colors.power[Enum.PowerType.Mana] = colors.power.MANA +colors.power[Enum.PowerType.Rage] = colors.power.RAGE +colors.power[Enum.PowerType.Focus] = colors.power.FOCUS +colors.power[Enum.PowerType.Energy] = colors.power.ENERGY +colors.power[Enum.PowerType.ComboPoints] = colors.power.COMBO_POINTS +colors.power[Enum.PowerType.Runes] = colors.power.RUNES +colors.power[Enum.PowerType.RunicPower] = colors.power.RUNIC_POWER +colors.power[Enum.PowerType.SoulShards] = colors.power.SOUL_SHARDS +colors.power[Enum.PowerType.LunarPower] = colors.power.LUNAR_POWER +colors.power[Enum.PowerType.HolyPower] = colors.power.HOLY_POWER +colors.power[Enum.PowerType.Maelstrom] = colors.power.MAELSTROM +colors.power[Enum.PowerType.Chi] = colors.power.CHI +colors.power[Enum.PowerType.Insanity] = colors.power.INSANITY +colors.power[Enum.PowerType.ArcaneCharges] = colors.power.ARCANE_CHARGES +colors.power[Enum.PowerType.Fury] = colors.power.FURY +colors.power[Enum.PowerType.Pain] = colors.power.PAIN -- there's no official colour for evoker's essence -- use the average colour of the essence texture instead colors.power.ESSENCE = oUF:CreateColor(100, 173, 206) -colors.power[19] = colors.power.ESSENCE +colors.power[Enum.PowerType.Essence] = colors.power.ESSENCE --- alternate power, sourced from FrameXML/CompactUnitFrame.lua +-- alternate power, originally sourced from CompactUnitFrame.lua colors.power.ALTERNATE = oUF:CreateColor(0.7, 0.7, 0.6) -colors.power[10] = colors.power.ALTERNATE +colors.power[Enum.PowerType.Alternate] = colors.power.ALTERNATE for i = 0, 3 do colors.threat[i] = oUF:CreateColor(GetThreatStatusColor(i)) From 2c3f13a93b33fd32b985827175db6e418957bc50 Mon Sep 17 00:00:00 2001 From: Adrian L Lange Date: Tue, 9 Jul 2024 17:59:38 +0200 Subject: [PATCH 13/21] auras: Link directly to symbol --- elements/auras.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/elements/auras.lua b/elements/auras.lua index 31b12320..4b717418 100644 --- a/elements/auras.lua +++ b/elements/auras.lua @@ -449,12 +449,12 @@ local function UpdateAuras(self, event, unit, updateInfo) --[[ Override: Auras:SortBuffs(a, b) Defines a custom sorting algorithm for ordering the auras. - Defaults to [AuraUtil.DefaultAuraCompare](https://github.com/Gethe/wow-ui-source/search?q=DefaultAuraCompare). + Defaults to [AuraUtil.DefaultAuraCompare](https://github.com/Gethe/wow-ui-source/search?q=symbol:DefaultAuraCompare). --]] --[[ Override: Auras:SortAuras(a, b) Defines a custom sorting algorithm for ordering the auras. - Defaults to [AuraUtil.DefaultAuraCompare](https://github.com/Gethe/wow-ui-source/search?q=DefaultAuraCompare). + Defaults to [AuraUtil.DefaultAuraCompare](https://github.com/Gethe/wow-ui-source/search?q=symbol:DefaultAuraCompare). Overridden by the more specific SortBuffs and/or SortDebuffs overrides if they are defined. --]] @@ -480,7 +480,7 @@ local function UpdateAuras(self, event, unit, updateInfo) --[[ Override: Auras:SortDebuffs(a, b) Defines a custom sorting algorithm for ordering the auras. - Defaults to [AuraUtil.DefaultAuraCompare](https://github.com/Gethe/wow-ui-source/search?q=DefaultAuraCompare). + Defaults to [AuraUtil.DefaultAuraCompare](https://github.com/Gethe/wow-ui-source/search?q=symbol:DefaultAuraCompare). --]] table.sort(auras.sortedDebuffs, auras.SortDebuffs or auras.SortAuras or SortAuras) end From 317a89e96e723e3bfa9606ef6133b708ea0edf3e Mon Sep 17 00:00:00 2001 From: Adrian L Lange Date: Tue, 9 Jul 2024 17:59:55 +0200 Subject: [PATCH 14/21] classpower: Update docs to match implementation --- elements/classpower.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/elements/classpower.lua b/elements/classpower.lua index 3f497b2e..eb7e4d4b 100644 --- a/elements/classpower.lua +++ b/elements/classpower.lua @@ -22,6 +22,7 @@ If the sub-widgets are StatusBars, their minimum and maximum values will be set Supported class powers: - All - Combo Points + - Evoker - Essence - Mage - Arcane Charges - Monk - Chi Orbs - Paladin - Holy Power From 1c88a01bc1dd705c07ca17129b81368985304027 Mon Sep 17 00:00:00 2001 From: Adrian L Lange Date: Tue, 9 Jul 2024 18:17:22 +0200 Subject: [PATCH 15/21] Update source comments --- blizzard.lua | 4 ++-- colors.lua | 9 ++++++--- elements/additionalpower.lua | 3 ++- elements/alternativepower.lua | 3 ++- elements/classpower.lua | 3 ++- elements/grouproleindicator.lua | 2 +- elements/power.lua | 2 +- elements/powerprediction.lua | 3 ++- elements/pvpclassificationindicator.lua | 2 +- elements/stagger.lua | 5 ++--- elements/summonindicator.lua | 2 +- 11 files changed, 22 insertions(+), 16 deletions(-) diff --git a/blizzard.lua b/blizzard.lua index 8912f86e..5b160bc7 100644 --- a/blizzard.lua +++ b/blizzard.lua @@ -1,10 +1,10 @@ local _, ns = ... local oUF = ns.oUF --- sourced from FrameXML/TargetFrame.lua +-- sourced from Blizzard_UnitFrame/TargetFrame.lua local MAX_BOSS_FRAMES = _G.MAX_BOSS_FRAMES or 5 --- sourced from FrameXML/RaidFrame.lua +-- sourced from Blizzard_FrameXMLBase/Shared/Constants.lua local MEMBERS_PER_RAID_GROUP = _G.MEMBERS_PER_RAID_GROUP or 5 local hookedFrames = {} diff --git a/colors.lua b/colors.lua index 858f561c..6b3d65b0 100644 --- a/colors.lua +++ b/colors.lua @@ -169,6 +169,7 @@ for power, color in next, PowerBarColor do end -- fallback integer index to named index +-- sourced from PowerBarColor - Blizzard_UnitFrame/Mainline/PowerBarColorUtil.lua colors.power[Enum.PowerType.Mana] = colors.power.MANA colors.power[Enum.PowerType.Rage] = colors.power.RAGE colors.power[Enum.PowerType.Focus] = colors.power.FOCUS @@ -180,18 +181,20 @@ colors.power[Enum.PowerType.SoulShards] = colors.power.SOUL_SHARDS colors.power[Enum.PowerType.LunarPower] = colors.power.LUNAR_POWER colors.power[Enum.PowerType.HolyPower] = colors.power.HOLY_POWER colors.power[Enum.PowerType.Maelstrom] = colors.power.MAELSTROM -colors.power[Enum.PowerType.Chi] = colors.power.CHI colors.power[Enum.PowerType.Insanity] = colors.power.INSANITY -colors.power[Enum.PowerType.ArcaneCharges] = colors.power.ARCANE_CHARGES colors.power[Enum.PowerType.Fury] = colors.power.FURY colors.power[Enum.PowerType.Pain] = colors.power.PAIN +-- these two don't have fallback values in PowerBarColor, but we want them +colors.power[Enum.PowerType.Chi] = colors.power.CHI +colors.power[Enum.PowerType.ArcaneCharges] = colors.power.ARCANE_CHARGES + -- there's no official colour for evoker's essence -- use the average colour of the essence texture instead colors.power.ESSENCE = oUF:CreateColor(100, 173, 206) colors.power[Enum.PowerType.Essence] = colors.power.ESSENCE --- alternate power, originally sourced from CompactUnitFrame.lua +-- alternate power, sourced from Blizzard_UnitFrame/Mainline/CompactUnitFrame.lua colors.power.ALTERNATE = oUF:CreateColor(0.7, 0.7, 0.6) colors.power[Enum.PowerType.Alternate] = colors.power.ALTERNATE diff --git a/elements/additionalpower.lua b/elements/additionalpower.lua index 7c528bdf..ee0f0640 100644 --- a/elements/additionalpower.lua +++ b/elements/additionalpower.lua @@ -59,8 +59,9 @@ local oUF = ns.oUF local _, playerClass = UnitClass('player') --- sourced from FrameXML/AlternatePowerBar.lua +-- sourced from Blizzard_UnitFrame/AlternatePowerBar.lua local ALT_POWER_BAR_PAIR_DISPLAY_INFO = _G.ALT_POWER_BAR_PAIR_DISPLAY_INFO + local ADDITIONAL_POWER_BAR_NAME = 'MANA' local ADDITIONAL_POWER_BAR_INDEX = 0 diff --git a/elements/alternativepower.lua b/elements/alternativepower.lua index f8194ce0..bb76358f 100644 --- a/elements/alternativepower.lua +++ b/elements/alternativepower.lua @@ -56,8 +56,9 @@ local Private = oUF.Private local unitSelectionType = Private.unitSelectionType --- sourced from FrameXML/UnitPowerBarAlt.lua +-- sourced from Blizzard_UnitFrame/UnitPowerBarAlt.lua local ALTERNATE_POWER_INDEX = Enum.PowerType.Alternate or 10 + local ALTERNATE_POWER_NAME = 'ALTERNATE' local function updateTooltip(self) diff --git a/elements/classpower.lua b/elements/classpower.lua index eb7e4d4b..d96f20da 100644 --- a/elements/classpower.lua +++ b/elements/classpower.lua @@ -50,10 +50,11 @@ local oUF = ns.oUF local _, PlayerClass = UnitClass('player') --- sourced from FrameXML/Constants.lua +-- sourced from Blizzard_FrameXMLBase/Constants.lua local SPEC_MAGE_ARCANE = _G.SPEC_MAGE_ARCANE or 1 local SPEC_MONK_WINDWALKER = _G.SPEC_MONK_WINDWALKER or 3 local SPEC_WARLOCK_DESTRUCTION = _G.SPEC_WARLOCK_DESTRUCTION or 3 + local SPELL_POWER_ENERGY = Enum.PowerType.Energy or 3 local SPELL_POWER_COMBO_POINTS = Enum.PowerType.ComboPoints or 4 local SPELL_POWER_SOUL_SHARDS = Enum.PowerType.SoulShards or 7 diff --git a/elements/grouproleindicator.lua b/elements/grouproleindicator.lua index 00d6f139..887013ce 100644 --- a/elements/grouproleindicator.lua +++ b/elements/grouproleindicator.lua @@ -25,7 +25,7 @@ A default texture will be applied if the widget is a Texture and doesn't have a local _, ns = ... local oUF = ns.oUF --- sourced from Interface\AddOns\Blizzard_Deprecated\Deprecated_10_1_5.lua +-- originally sourced from Blizzard_Deprecated/Deprecated_10_1_5.lua local function GetTexCoordsForRoleSmallCircle(role) if(role == 'TANK') then return 0, 19 / 64, 22 / 64, 41 / 64 diff --git a/elements/power.lua b/elements/power.lua index 8768142d..72a3dd6a 100644 --- a/elements/power.lua +++ b/elements/power.lua @@ -93,7 +93,7 @@ local Private = oUF.Private local unitSelectionType = Private.unitSelectionType --- sourced from FrameXML/UnitPowerBarAlt.lua +-- sourced from Blizzard_UnitFrame/UnitPowerBarAlt.lua local ALTERNATE_POWER_INDEX = Enum.PowerType.Alternate or 10 --[[ Override: Power:GetDisplayPower() diff --git a/elements/powerprediction.lua b/elements/powerprediction.lua index 0b3c2f00..f2530860 100644 --- a/elements/powerprediction.lua +++ b/elements/powerprediction.lua @@ -43,8 +43,9 @@ A default texture will be applied if the widget is a StatusBar and doesn't have local _, ns = ... local oUF = ns.oUF --- sourced from FrameXML/AlternatePowerBar.lua +-- sourced from Blizzard_UnitFrame/AlternatePowerBar.lua local ALT_POWER_BAR_PAIR_DISPLAY_INFO = _G.ALT_POWER_BAR_PAIR_DISPLAY_INFO + local ADDITIONAL_POWER_BAR_INDEX = 0 local _, playerClass = UnitClass('player') diff --git a/elements/pvpclassificationindicator.lua b/elements/pvpclassificationindicator.lua index 126ebc9a..7a51adc3 100644 --- a/elements/pvpclassificationindicator.lua +++ b/elements/pvpclassificationindicator.lua @@ -29,7 +29,7 @@ This element updates by changing the texture. local _, ns = ... local oUF = ns.oUF --- sourced from FrameXML/CompactUnitFrame.lua +-- sourced from Blizzard_UnitFrame/Mainline/CompactUnitFrame.lua local ICONS = { [Enum.PvPUnitClassification.FlagCarrierHorde or 0] = "nameplates-icon-flag-horde", [Enum.PvPUnitClassification.FlagCarrierAlliance or 1] = "nameplates-icon-flag-alliance", diff --git a/elements/stagger.lua b/elements/stagger.lua index 76cc586f..8fd35ca2 100644 --- a/elements/stagger.lua +++ b/elements/stagger.lua @@ -34,11 +34,10 @@ if(select(2, UnitClass('player')) ~= 'MONK') then return end local _, ns = ... local oUF = ns.oUF --- sourced from FrameXML/Constants.lua +-- sourced from Blizzard_FrameXMLBase/Constants.lua local SPEC_MONK_BREWMASTER = _G.SPEC_MONK_BREWMASTER or 1 --- sourced from FrameXML/MonkStaggerBar.lua -local BREWMASTER_POWER_BAR_NAME = _G.BREWMASTER_POWER_BAR_NAME or 'STAGGER' +local BREWMASTER_POWER_BAR_NAME = 'STAGGER' -- percentages at which bar should change color local STAGGER_YELLOW_TRANSITION = _G.STAGGER_YELLOW_TRANSITION or 0.3 diff --git a/elements/summonindicator.lua b/elements/summonindicator.lua index bc8e833a..686de296 100644 --- a/elements/summonindicator.lua +++ b/elements/summonindicator.lua @@ -25,7 +25,7 @@ This element updates by changing the texture. local _, ns = ... local oUF = ns.oUF --- sourced from Blizzard_APIDocumentation/IncomingSummonDocumentation.lua +-- sourced from Blizzard_APIDocumentationGenerated/IncomingSummonDocumentation.lua local SUMMON_STATUS_NONE = Enum.SummonStatus.None or 0 local SUMMON_STATUS_PENDING = Enum.SummonStatus.Pending or 1 local SUMMON_STATUS_ACCEPTED = Enum.SummonStatus.Accepted or 2 From 12fc45a27664ac415d11e26ec1ef01bdfc3a71c6 Mon Sep 17 00:00:00 2001 From: Adrian L Lange Date: Tue, 9 Jul 2024 18:17:48 +0200 Subject: [PATCH 16/21] colors: We like fallback values --- colors.lua | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/colors.lua b/colors.lua index 6b3d65b0..0bd94752 100644 --- a/colors.lua +++ b/colors.lua @@ -170,33 +170,33 @@ end -- fallback integer index to named index -- sourced from PowerBarColor - Blizzard_UnitFrame/Mainline/PowerBarColorUtil.lua -colors.power[Enum.PowerType.Mana] = colors.power.MANA -colors.power[Enum.PowerType.Rage] = colors.power.RAGE -colors.power[Enum.PowerType.Focus] = colors.power.FOCUS -colors.power[Enum.PowerType.Energy] = colors.power.ENERGY -colors.power[Enum.PowerType.ComboPoints] = colors.power.COMBO_POINTS -colors.power[Enum.PowerType.Runes] = colors.power.RUNES -colors.power[Enum.PowerType.RunicPower] = colors.power.RUNIC_POWER -colors.power[Enum.PowerType.SoulShards] = colors.power.SOUL_SHARDS -colors.power[Enum.PowerType.LunarPower] = colors.power.LUNAR_POWER -colors.power[Enum.PowerType.HolyPower] = colors.power.HOLY_POWER -colors.power[Enum.PowerType.Maelstrom] = colors.power.MAELSTROM -colors.power[Enum.PowerType.Insanity] = colors.power.INSANITY -colors.power[Enum.PowerType.Fury] = colors.power.FURY -colors.power[Enum.PowerType.Pain] = colors.power.PAIN +colors.power[Enum.PowerType.Mana or 0] = colors.power.MANA +colors.power[Enum.PowerType.Rage or 1] = colors.power.RAGE +colors.power[Enum.PowerType.Focus or 2] = colors.power.FOCUS +colors.power[Enum.PowerType.Energy or 3] = colors.power.ENERGY +colors.power[Enum.PowerType.ComboPoints or 4] = colors.power.COMBO_POINTS +colors.power[Enum.PowerType.Runes or 5] = colors.power.RUNES +colors.power[Enum.PowerType.RunicPower or 6] = colors.power.RUNIC_POWER +colors.power[Enum.PowerType.SoulShards or 7] = colors.power.SOUL_SHARDS +colors.power[Enum.PowerType.LunarPower or 8] = colors.power.LUNAR_POWER +colors.power[Enum.PowerType.HolyPower or 9] = colors.power.HOLY_POWER +colors.power[Enum.PowerType.Maelstrom or 11] = colors.power.MAELSTROM +colors.power[Enum.PowerType.Insanity or 13] = colors.power.INSANITY +colors.power[Enum.PowerType.Fury or 17] = colors.power.FURY +colors.power[Enum.PowerType.Pain or 18] = colors.power.PAIN -- these two don't have fallback values in PowerBarColor, but we want them -colors.power[Enum.PowerType.Chi] = colors.power.CHI -colors.power[Enum.PowerType.ArcaneCharges] = colors.power.ARCANE_CHARGES +colors.power[Enum.PowerType.Chi or 12] = colors.power.CHI +colors.power[Enum.PowerType.ArcaneCharges or 16] = colors.power.ARCANE_CHARGES -- there's no official colour for evoker's essence -- use the average colour of the essence texture instead colors.power.ESSENCE = oUF:CreateColor(100, 173, 206) -colors.power[Enum.PowerType.Essence] = colors.power.ESSENCE +colors.power[Enum.PowerType.Essence or 19] = colors.power.ESSENCE -- alternate power, sourced from Blizzard_UnitFrame/Mainline/CompactUnitFrame.lua colors.power.ALTERNATE = oUF:CreateColor(0.7, 0.7, 0.6) -colors.power[Enum.PowerType.Alternate] = colors.power.ALTERNATE +colors.power[Enum.PowerType.Alternate or 10] = colors.power.ALTERNATE for i = 0, 3 do colors.threat[i] = oUF:CreateColor(GetThreatStatusColor(i)) From 17c43998bb6c5bfc13b85303192f89f1809f3d1e Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Tue, 16 Jul 2024 22:13:35 +0700 Subject: [PATCH 17/21] core: Only update visible eventless frames --- units.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/units.lua b/units.lua index 2a720707..aae4c613 100644 --- a/units.lua +++ b/units.lua @@ -204,7 +204,7 @@ local function createOnUpdate(timer) self.elapsed = (self.elapsed or 0) + elapsed if(self.elapsed > timer) then for _, object in next, objects do - if(object.unit and unitExists(object.unit)) then + if(object:IsVisible() and object.unit and unitExists(object.unit)) then object:UpdateAllElements('OnUpdate') end end From 07e3f10c4575214bd91f080a44080d7f92408fec Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Tue, 16 Jul 2024 22:43:54 +0700 Subject: [PATCH 18/21] powerprediction: Add dynamic size adjustment --- elements/powerprediction.lua | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/elements/powerprediction.lua b/elements/powerprediction.lua index f2530860..572fef28 100644 --- a/elements/powerprediction.lua +++ b/elements/powerprediction.lua @@ -50,6 +50,18 @@ local ADDITIONAL_POWER_BAR_INDEX = 0 local _, playerClass = UnitClass('player') +local function UpdateSize(self, event, unit) + local element = self.PowerPrediction + + if(element.mainBar and element.mainSize) then + element.mainBar[element.isMainHoriz and 'SetWidth' or 'SetHeight'](element.mainBar, element.mainSize) + end + + if(element.altBar and element.altSize) then + element.altBar[element.isAltHoriz and 'SetWidth' or 'SetHeight'](element.altBar, element.altSize) + end +end + local function Update(self, event, unit) if(self.unit ~= unit) then return end @@ -129,7 +141,45 @@ local function Update(self, event, unit) end end +local function shouldUpdateMainSize(self) + if(not self.Power) then return end + + local isHoriz = self.Power:GetOrientation() == 'HORIZONTAL' + local newSize = self.Power[isHoriz and 'GetWidth' or 'GetHeight'](self.Power) + if(isHoriz ~= self.PowerPrediction.isMainHoriz or newSize ~= self.PowerPrediction.mainSize) then + self.PowerPrediction.isMainHoriz = isHoriz + self.PowerPrediction.mainSize = newSize + + return true + end +end + +local function shouldUpdateAltSize(self) + if(not self.AdditionalPower) then return end + + local isHoriz = self.AdditionalPower:GetOrientation() == 'HORIZONTAL' + local newSize = self.AdditionalPower[isHoriz and 'GetWidth' or 'GetHeight'](self.AdditionalPower) + if(isHoriz ~= self.PowerPrediction.isAltHoriz or newSize ~= self.PowerPrediction.altSize) then + self.PowerPrediction.isAltHoriz = isHoriz + self.PowerPrediction.altSize = newSize + + return true + end +end + local function Path(self, ...) + --[[ Override: PowerPrediction.UpdateSize(self, event, unit, ...) + Used to completely override the internal function for updating the widgets' size. + + * self - the parent object + * event - the event triggering the update (string) + * unit - the unit accompanying the event (string) + * ... - the arguments accompanying the event + --]] + if(shouldUpdateMainSize(self) or shouldUpdateAltSize(self)) then + (self.PowerPrediction.UpdateSize or UpdateSize) (self, ...) + end + --[[ Override: PowerPrediction.Override(self, event, unit, ...) Used to completely override the internal update function. From 806f70a36d7742700000cf8834d3c4ceb368e739 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Tue, 16 Jul 2024 22:44:10 +0700 Subject: [PATCH 19/21] healthprediction: Add missing docs --- elements/healthprediction.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/elements/healthprediction.lua b/elements/healthprediction.lua index 776d339b..b2021ec0 100644 --- a/elements/healthprediction.lua +++ b/elements/healthprediction.lua @@ -228,6 +228,14 @@ local function shouldUpdateSize(self) end local function Path(self, ...) + --[[ Override: HealthPrediction.UpdateSize(self, event, unit, ...) + Used to completely override the internal function for updating the widgets' size. + + * self - the parent object + * event - the event triggering the update (string) + * unit - the unit accompanying the event (string) + * ... - the arguments accompanying the event + --]] if(shouldUpdateSize(self)) then (self.HealthPrediction.UpdateSize or UpdateSize) (self, ...) end From add83a0b9006160e10cbf249f1b0cddc84ddbdc8 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Wed, 17 Jul 2024 13:39:34 +0700 Subject: [PATCH 20/21] health: Update docs --- elements/health.lua | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/elements/health.lua b/elements/health.lua index 0c0f4b05..081b9275 100644 --- a/elements/health.lua +++ b/elements/health.lua @@ -9,7 +9,8 @@ Health - A `StatusBar` used to represent the unit's health. ## Sub-Widgets -.bg - A `Texture` used as a background. It will inherit the color of the main StatusBar. +.TempLoss - A `StatusBar` used to represent temporary max health reduction. +.bg - A `Texture` used as a background. It will inherit the color of the main StatusBar. ## Notes @@ -58,7 +59,7 @@ The following options are listed by priority. The first check that returns true -- Add a background local Background = Health:CreateTexture(nil, 'BACKGROUND') - Background:SetAllPoints(Health) + Background:SetAllPoints() Background:SetTexture(1, 1, 1, .5) -- Options @@ -74,6 +75,39 @@ The following options are listed by priority. The first check that returns true -- Register it with oUF Health.bg = Background self.Health = Health + + -- Alternatively, if .TempLoss is being used + local TempLoss = CreateFrame('StatusBar', nil, self) + TempLoss:SetReverseFill(true) + TempLoss:SetHeight(20) + TempLoss:SetPoint('TOP') + TempLoss:SetPoint('LEFT') + TempLoss:SetPoint('RIGHT') + + local Health = CreateFrame('StatusBar', nil, self) + Health:SetPoint('LEFT') + Health:SetPoint('TOPRIGHT', TempLoss:GetStatusBarTexture(), 'TOPLEFT') + Health:SetPoint('BOTTOMRIGHT', TempLoss:GetStatusBarTexture(), 'BOTTOMLEFT') + + -- Add a background + local Background = TempLoss:CreateTexture(nil, 'BACKGROUND') + Background:SetAllPoints() + Background:SetTexture(1, 1, 1, .5) + + -- Options + Health.colorTapping = true + Health.colorDisconnected = true + Health.colorClass = true + Health.colorReaction = true + Health.colorHealth = true + + -- Make the background darker. + Background.multiplier = .5 + + -- Register it with oUF + Health.TempLoss = TempLoss + Health.bg = Background + self.Health = Health --]] local _, ns = ... From 373b8563060f627dad964881c6dd0bc47cb377b1 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Thu, 18 Jul 2024 19:30:53 +0700 Subject: [PATCH 21/21] healthprediction: Add showRawAbsorb option --- elements/healthprediction.lua | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/elements/healthprediction.lua b/elements/healthprediction.lua index b2021ec0..f47e28e1 100644 --- a/elements/healthprediction.lua +++ b/elements/healthprediction.lua @@ -13,7 +13,8 @@ myBar - A `StatusBar` used to represent incoming heals from the player. otherBar - A `StatusBar` used to represent incoming heals from others. absorbBar - A `StatusBar` used to represent damage absorbs. healAbsorbBar - A `StatusBar` used to represent heal absorbs. -overAbsorb - A `Texture` used to signify that the amount of damage absorb is greater than the unit's missing health. +overAbsorb - A `Texture` used to signify that the amount of damage absorb is greater than either the unit's missing + health or the unit's maximum health, if .showRawAbsorb is enabled. overHealAbsorb - A `Texture` used to signify that the amount of heal absorb is greater than the unit's current health. ## Notes @@ -23,8 +24,9 @@ A default texture will be applied to the Texture widgets if they don't have a te ## Options -.maxOverflow - The maximum amount of overflow past the end of the health bar. Set this to 1 to disable the overflow. - Defaults to 1.05 (number) +.maxOverflow - The maximum amount of overflow past the end of the health bar. Set this to 1 to disable the overflow. + Defaults to 1.05 (number) +.showRawAbsorb - Makes the element show the raw amount of damage absorb (boolean) ## Examples @@ -149,7 +151,11 @@ local function Update(self, event, unit) end local hasOverAbsorb = false - if(health + allIncomingHeal + absorb >= maxHealth) then + if(element.showRawAbsorb) then + if(absorb > maxHealth) then + hasOverAbsorb = true + end + elseif(health + allIncomingHeal + absorb >= maxHealth) then if(absorb > 0) then hasOverAbsorb = true end @@ -206,7 +212,7 @@ local function Update(self, event, unit) * otherIncomingHeal - the amount of incoming healing done by others (number) * absorb - the amount of damage the unit can absorb without losing health (number) * healAbsorb - the amount of healing the unit can absorb without gaining health (number) - * hasOverAbsorb - indicates if the amount of damage absorb is higher than the unit's missing health (boolean) + * hasOverAbsorb - indicates if the amount of damage absorb is higher than either the unit's missing health or the unit's maximum health, if .showRawAbsorb is enabled (boolean) * hasOverHealAbsorb - indicates if the amount of heal absorb is higher than the unit's current health (boolean) --]] if(element.PostUpdate) then