diff --git a/.vscode/settings.json b/.vscode/settings.json index 7a3af099..1d0ebf1f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -523,6 +523,6 @@ "libs\\oUF_Plugins", "Modules", "Themes", - "~\\.vscode\\extensions\\ketho.wow-api-0.17.6\\Annotations" + "~\\.vscode\\extensions\\ketho.wow-api-0.17.8\\Annotations" ] } diff --git a/libs/oUF/.luacheckrc b/libs/oUF/.luacheckrc index b93b0b7b..99f35950 100644 --- a/libs/oUF/.luacheckrc +++ b/libs/oUF/.luacheckrc @@ -83,6 +83,7 @@ read_globals = { 'GetUnitTotalModifiedMaxHealthPercent', 'HasLFGRestrictions', 'InCombatLockdown', + 'IsInInstance', 'IsLoggedIn', 'IsPlayerSpell', 'IsResting', @@ -107,11 +108,11 @@ read_globals = { 'UnitClassBase', 'UnitExists', 'UnitFactionGroup', + 'UnitGUID', 'UnitGetIncomingHeals', 'UnitGetTotalAbsorbs', 'UnitGetTotalHealAbsorbs', 'UnitGroupRolesAssigned', - 'UnitGUID', 'UnitHasIncomingResurrection', 'UnitHasVehiclePlayerFrameUI', 'UnitHasVehicleUI', @@ -119,6 +120,7 @@ read_globals = { 'UnitHealthMax', 'UnitHonorLevel', 'UnitInParty', + 'UnitInPartyIsAI', 'UnitInRaid', 'UnitInRange', 'UnitIsConnected', @@ -126,13 +128,14 @@ read_globals = { 'UnitIsGroupLeader', 'UnitIsMercenary', 'UnitIsOwnerOrControllerOfUnit', - 'UnitIsPlayer', 'UnitIsPVP', 'UnitIsPVPFreeForAll', + 'UnitIsPlayer', 'UnitIsQuestBoss', 'UnitIsTapDenied', 'UnitIsUnit', 'UnitIsVisible', + 'UnitLeadsAnyGroup', 'UnitPhaseReason', 'UnitPlayerControlled', 'UnitPower', diff --git a/libs/oUF/LICENSE b/libs/oUF/LICENSE.txt similarity index 100% rename from libs/oUF/LICENSE rename to libs/oUF/LICENSE.txt diff --git a/libs/oUF/blizzard.lua b/libs/oUF/blizzard.lua index 5b160bc7..c0cfca47 100644 --- a/libs/oUF/blizzard.lua +++ b/libs/oUF/blizzard.lua @@ -2,7 +2,7 @@ local _, ns = ... local oUF = ns.oUF -- sourced from Blizzard_UnitFrame/TargetFrame.lua -local MAX_BOSS_FRAMES = _G.MAX_BOSS_FRAMES or 5 +local MAX_BOSS_FRAMES = 8 -- blizzard can spawn more than the default 5 apparently -- sourced from Blizzard_FrameXMLBase/Shared/Constants.lua local MEMBERS_PER_RAID_GROUP = _G.MEMBERS_PER_RAID_GROUP or 5 diff --git a/libs/oUF/elements/alternativepower.lua b/libs/oUF/elements/alternativepower.lua index c0ca6bc1..5700f435 100644 --- a/libs/oUF/elements/alternativepower.lua +++ b/libs/oUF/elements/alternativepower.lua @@ -69,13 +69,15 @@ local function updateTooltip(self) end local function onEnter(self) - if(not self:IsVisible()) then return end + if(GameTooltip:IsForbidden() or not self:IsVisible()) then return end GameTooltip_SetDefaultAnchor(GameTooltip, self) self:UpdateTooltip() end local function onLeave() + if(GameTooltip:IsForbidden()) then return end + GameTooltip:Hide() end diff --git a/libs/oUF/elements/combatindicator.lua b/libs/oUF/elements/combatindicator.lua index 4717be05..cdea8160 100644 --- a/libs/oUF/elements/combatindicator.lua +++ b/libs/oUF/elements/combatindicator.lua @@ -1,7 +1,7 @@ --[[ # Element: Combat Indicator -Toggles the visibility of an indicator based on the player's combat status. +Toggles the visibility of an indicator based on the unit's combat status. ## Widget @@ -25,7 +25,8 @@ A default texture will be applied if the widget is a Texture and doesn't have a local _, ns = ... local oUF = ns.oUF -local function Update(self, event) +local function Update(self, event, unit) + if(not unit or self.unit ~= unit) then return end local element = self.CombatIndicator --[[ Callback: CombatIndicator:PreUpdate() @@ -37,7 +38,7 @@ local function Update(self, event) element:PreUpdate() end - local inCombat = UnitAffectingCombat('player') + local inCombat = UnitAffectingCombat(unit) if(inCombat) then element:Show() else @@ -48,7 +49,7 @@ local function Update(self, event) Called after the element has been updated. * self - the CombatIndicator element - * inCombat - indicates if the player is affecting combat (boolean) + * inCombat - indicates if the unit is affecting combat (boolean) --]] if(element.PostUpdate) then return element:PostUpdate(inCombat) @@ -71,12 +72,11 @@ end local function Enable(self, unit) local element = self.CombatIndicator - if(element and UnitIsUnit(unit, 'player')) then + if(element) then element.__owner = self element.ForceUpdate = ForceUpdate - self:RegisterEvent('PLAYER_REGEN_DISABLED', Path, true) - self:RegisterEvent('PLAYER_REGEN_ENABLED', Path, true) + self:RegisterEvent('UNIT_FLAGS', Path) if(element:IsObjectType('Texture') and not element:GetTexture()) then element:SetTexture([[Interface\CharacterFrame\UI-StateIcon]]) @@ -92,8 +92,7 @@ local function Disable(self) if(element) then element:Hide() - self:UnregisterEvent('PLAYER_REGEN_DISABLED', Path) - self:UnregisterEvent('PLAYER_REGEN_ENABLED', Path) + self:UnregisterEvent('UNIT_FLAGS', Path) end end diff --git a/libs/oUF/elements/leaderindicator.lua b/libs/oUF/elements/leaderindicator.lua index f5c981f2..2d9334df 100644 --- a/libs/oUF/elements/leaderindicator.lua +++ b/libs/oUF/elements/leaderindicator.lua @@ -48,7 +48,13 @@ local function Update(self, event) -- UnitLeadsAnyGroup(unit). Inside the group formed by the dungeon finder UnitIsGroupLeader(unit) will only return -- true for the instance leader. local isInLFGInstance = HasLFGRestrictions() - local isLeader = UnitIsGroupLeader(unit) + local isLeader + if(IsInInstance()) then + isLeader = UnitIsGroupLeader(unit) + else + isLeader = UnitLeadsAnyGroup(unit) + end + if(isLeader) then if(isInLFGInstance) then element:SetTexture([[Interface\LFGFrame\UI-LFG-ICON-PORTRAITROLES]]) @@ -96,6 +102,7 @@ local function Enable(self) element.__owner = self element.ForceUpdate = ForceUpdate + self:RegisterEvent('UNIT_FLAGS', Path) self:RegisterEvent('PARTY_LEADER_CHANGED', Path, true) self:RegisterEvent('GROUP_ROSTER_UPDATE', Path, true) @@ -108,6 +115,7 @@ local function Disable(self) if(element) then element:Hide() + self:UnregisterEvent('UNIT_FLAGS', Path) self:UnregisterEvent('PARTY_LEADER_CHANGED', Path) self:UnregisterEvent('GROUP_ROSTER_UPDATE', Path) end diff --git a/libs/oUF/elements/phaseindicator.lua b/libs/oUF/elements/phaseindicator.lua index 4242a7f1..5ada3c3d 100644 --- a/libs/oUF/elements/phaseindicator.lua +++ b/libs/oUF/elements/phaseindicator.lua @@ -50,7 +50,7 @@ local function UpdateTooltip(element) end local function onEnter(element) - if(not element:IsVisible()) then return end + if(GameTooltip:IsForbidden() or not element:IsVisible()) then return end if(element.reason) then GameTooltip:SetOwner(element, 'ANCHOR_BOTTOMRIGHT') @@ -59,6 +59,8 @@ local function onEnter(element) end local function onLeave() + if(GameTooltip:IsForbidden()) then return end + GameTooltip:Hide() end diff --git a/libs/oUF/elements/portrait.lua b/libs/oUF/elements/portrait.lua index 1a6f9bf9..538bd65f 100644 --- a/libs/oUF/elements/portrait.lua +++ b/libs/oUF/elements/portrait.lua @@ -71,7 +71,13 @@ local function Update(self, event, unit) element:SetUnit(unit) end else - local class = element.showClass and UnitClassBase(unit) + local class, _ + if(element.showClass) then + -- BUG: UnitClassBase can't be trusted + -- https://github.com/Stanzilla/WoWUIBugs/issues/621 + _, class = UnitClass(unit) + end + if(class) then element:SetAtlas('classicon-' .. class) else diff --git a/libs/oUF/elements/power.lua b/libs/oUF/elements/power.lua index bab26240..9028c3de 100644 --- a/libs/oUF/elements/power.lua +++ b/libs/oUF/elements/power.lua @@ -32,6 +32,9 @@ The following options are listed by priority. The first check that returns true .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://warcraft.wiki.gg/wiki/API_UnitThreatSituation) (boolean) +.colorPowerAtlas - Use `self.colors.power[token].atlas` to replace the texture whenever it's available. The previously + defined texture (if any) will be restored if the color changes to one that doesn't have an atlas + (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 @@ -120,7 +123,7 @@ local function UpdateColor(self, event, unit) local pType, pToken, altR, altG, altB = UnitPowerType(unit) - local r, g, b, color + local r, g, b, color, atlas if(element.colorDisconnected and not UnitIsConnected(unit)) then color = self.colors.disconnected elseif(element.colorTapping and not UnitPlayerControlled(unit) and UnitIsTapDenied(unit)) then @@ -146,6 +149,10 @@ local function UpdateColor(self, event, unit) else color = self.colors.power[ALTERNATE_POWER_INDEX] end + + if(element.colorPowerAtlas and color) then + atlas = color.atlas + end elseif(element.colorClass and (UnitIsPlayer(unit) or UnitInPartyIsAI(unit))) or (element.colorClassNPC and not (UnitIsPlayer(unit) or UnitInPartyIsAI(unit))) or (element.colorClassPet and UnitPlayerControlled(unit) and not UnitIsPlayer(unit)) then @@ -160,31 +167,41 @@ local function UpdateColor(self, event, unit) r, g, b = self:ColorGradient((element.cur or 1) + adjust, (element.max or 1) + adjust, unpack(element.smoothGradient or self.colors.smooth)) end - if(color) then - r, g, b = color[1], color[2], color[3] - end + if(atlas) then + element:SetStatusBarTexture(atlas) + element:SetStatusBarColor(1, 1, 1) + else + if(color) then + r, g, b = color[1], color[2], color[3] + end - if(b) then - element:SetStatusBarColor(r, g, b) + if(b) then + if(element.__texture) then + element:SetStatusBarTexture(element.__texture) + end - local bg = element.bg - if(bg) then - local mu = bg.multiplier or 1 - bg:SetVertexColor(r * mu, g * mu, b * mu) + element:SetStatusBarColor(r, g, b) + + local bg = element.bg + if(bg) then + local mu = bg.multiplier or 1 + bg:SetVertexColor(r * mu, g * mu, b * mu) + end end end --[[ Callback: Power:PostUpdateColor(unit, r, g, b) Called after the element color has been updated. - * self - the Power element - * unit - the unit for which the update has been triggered (string) - * r - the red component of the used color (number)[0-1] - * g - the green component of the used color (number)[0-1] - * b - the blue component of the used color (number)[0-1] + * self - the Power element + * unit - the unit for which the update has been triggered (string) + * r - the red component of the used color (number?)[0-1] + * g - the green component of the used color (number?)[0-1] + * b - the blue component of the used color (number?)[0-1] + * atlas - the atlas used instead of color (string?) --]] if(element.PostUpdateColor) then - element:PostUpdateColor(unit, r, g, b) + element:PostUpdateColor(unit, r, g, b, atlas) end end @@ -219,7 +236,8 @@ local function Update(self, event, unit) end local cur, max = UnitPower(unit, displayType), UnitPowerMax(unit, displayType) - element:SetMinMaxValues(min or 0, max) + min = min or 0 -- ensure we always have a minimum value to avoid errors + element:SetMinMaxValues(min, max) if(UnitIsConnected(unit)) then element:SetValue(cur) @@ -398,6 +416,10 @@ local function Enable(self) element:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]]) end + if(element.colorPowerAtlas) then + element.__texture = element.__texture or element:GetStatusBarTexture():GetTexture() + end + if(not element.GetDisplayPower) then element.GetDisplayPower = GetDisplayPower end diff --git a/libs/oUF/elements/runes.lua b/libs/oUF/elements/runes.lua index f86639d2..ac397226 100644 --- a/libs/oUF/elements/runes.lua +++ b/libs/oUF/elements/runes.lua @@ -142,6 +142,7 @@ local function Update(self, event) hasSortOrder = false end + local currentTime = GetTime() local rune, start, duration, runeReady for index, runeID in next, runemap do rune = element[index] @@ -156,7 +157,7 @@ local function Update(self, event) rune:SetValue(1) rune:SetScript('OnUpdate', nil) elseif(start) then - rune.duration = GetTime() - start + rune.duration = currentTime - start rune:SetMinMaxValues(0, duration) rune:SetValue(0) rune:SetScript('OnUpdate', onUpdate) diff --git a/libs/oUF/elements/totems.lua b/libs/oUF/elements/totems.lua index b8541414..6cf71a6f 100644 --- a/libs/oUF/elements/totems.lua +++ b/libs/oUF/elements/totems.lua @@ -23,7 +23,7 @@ OnEnter and OnLeave script handlers will be set to display a Tooltip if the `Tot ## Examples local Totems = {} - for index = 1, 5 do + for index = 1, 4 do -- Position and size of the totem indicator local Totem = CreateFrame('Button', nil, self) Totem:SetSize(40, 40) @@ -48,18 +48,25 @@ OnEnter and OnLeave script handlers will be set to display a Tooltip if the `Tot local _, ns = ... local oUF = ns.oUF +local TOTEM_PRIORITIES = _G.STANDARD_TOTEM_PRIORITIES +if(UnitClassBase('player') == 'SHAMAN') then + TOTEM_PRIORITIES = _G.SHAMAN_TOTEM_PRIORITIES +end + local function UpdateTooltip(self) GameTooltip:SetTotem(self:GetID()) end local function OnEnter(self) - if(not self:IsVisible()) then return end + if(GameTooltip:IsForbidden() or not self:IsVisible()) then return end GameTooltip:SetOwner(self, 'ANCHOR_BOTTOMRIGHT') self:UpdateTooltip() end local function OnLeave() + if(GameTooltip:IsForbidden()) then return end + GameTooltip:Hide() end @@ -75,7 +82,7 @@ local function UpdateTotem(self, event, slot) --]] if(element.PreUpdate) then element:PreUpdate(slot) end - local totem = element[slot] + local totem = element[TOTEM_PRIORITIES[slot]] local haveTotem, name, start, duration, icon = GetTotemInfo(slot) if(haveTotem and duration > 0) then if(totem.Icon) then @@ -135,8 +142,7 @@ local function Enable(self) element.ForceUpdate = ForceUpdate for i = 1, #element do - local totem = element[i] - + local totem = element[TOTEM_PRIORITIES[i]] totem:SetID(i) if(totem:IsMouseEnabled()) then diff --git a/libs/oUF/oUF.lua b/libs/oUF/oUF.lua index e1e59317..e048f4f6 100644 --- a/libs/oUF/oUF.lua +++ b/libs/oUF/oUF.lua @@ -834,11 +834,13 @@ function oUF:SpawnNamePlates(namePrefix, nameplateCallback, nameplateCVars) if(nameplate.UnitFrame) then if(nameplate.UnitFrame.WidgetContainer) then nameplate.UnitFrame.WidgetContainer:SetParent(nameplate.unitFrame) + nameplate.UnitFrame.WidgetContainer:SetIgnoreParentAlpha(true) nameplate.unitFrame.WidgetContainer = nameplate.UnitFrame.WidgetContainer end if(nameplate.UnitFrame.SoftTargetFrame) then nameplate.UnitFrame.SoftTargetFrame:SetParent(nameplate.unitFrame) + nameplate.UnitFrame.SoftTargetFrame:SetIgnoreParentAlpha(true) nameplate.unitFrame.SoftTargetFrame = nameplate.UnitFrame.SoftTargetFrame end end