From e2c64deff4b8fea39ccfdc83b73b9077d33a9c67 Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Wed, 8 Sep 2021 17:44:27 +0200 Subject: [PATCH 01/13] Bump BCC TOC --- ShadowedUnitFrames.toc | 4 ++-- options/ShadowedUF_Options.toc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ShadowedUnitFrames.toc b/ShadowedUnitFrames.toc index cbc7028c..2d055bbe 100755 --- a/ShadowedUnitFrames.toc +++ b/ShadowedUnitFrames.toc @@ -1,6 +1,6 @@ -## Interface: 20501 +## Interface: 20502 ## Interface-Classic: 11307 -## Interface-BCC: 20501 +## Interface-BCC: 20502 ## Title: Shadowed Unit Frames ## Notes: Moooooooooooooooooo ## Author: Shadowed diff --git a/options/ShadowedUF_Options.toc b/options/ShadowedUF_Options.toc index 90cfb9f5..aca4c461 100755 --- a/options/ShadowedUF_Options.toc +++ b/options/ShadowedUF_Options.toc @@ -1,6 +1,6 @@ -## Interface: 20501 +## Interface: 20502 ## Interface-Classic: 11307 -## Interface-BCC: 20501 +## Interface-BCC: 20502 ## Title: Shadowed UF (Options) ## Notes: Configuration for Shadowed Unit Frames. ## Author: Shadowed From 3ef820ff9d6029adf87508f86e8d476fb60934fd Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Mon, 27 Sep 2021 18:44:09 +0200 Subject: [PATCH 02/13] Replace HealComm by API-based heal information (ported from retail) --- .pkgmeta | 2 - ShadowedUnitFrames.toc | 3 +- modules/incheal.lua | 251 +++++++++++++++++------------------------ options/config.lua | 14 ++- 4 files changed, 114 insertions(+), 156 deletions(-) diff --git a/.pkgmeta b/.pkgmeta index a993a9ca..655c789e 100755 --- a/.pkgmeta +++ b/.pkgmeta @@ -18,8 +18,6 @@ externals: url: https://repos.curseforge.com/wow/libclassicdurations libs/LibClassicCasterino: url: https://github.com/rgd87/LibClassicCasterino.git - libs/LibHealComm-4.0: - url: https://repos.wowace.com/wow/libhealcomm-4-0 options/libs/AceConfig-3.0: url: https://repos.wowace.com/wow/ace3/trunk/AceConfig-3.0 options/libs/AceDBOptions-3.0: diff --git a/ShadowedUnitFrames.toc b/ShadowedUnitFrames.toc index 2d055bbe..447cfa55 100755 --- a/ShadowedUnitFrames.toc +++ b/ShadowedUnitFrames.toc @@ -11,7 +11,7 @@ ## OptionalDeps: Ace3, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, LibSpellRange-1.0, Clique, LibHealComm-4.0 #@end-version-bcc@ #@non-version-bcc@ -# ## OptionalDeps: Ace3, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, LibSpellRange-1.0, LibClassicDurations, Clique, LibHealComm-4.0, LibClassicCasterino +# ## OptionalDeps: Ace3, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, LibSpellRange-1.0, LibClassicDurations, Clique, LibClassicCasterino #@end-non-version-bcc@ ## X-Curse-Project-ID: 19268 ## X-WoWI-ID: 13494 @@ -26,7 +26,6 @@ libs\LibSpellRange-1.0\lib.xml # libs\LibClassicDurations\LibClassicDurations.xml # libs\LibClassicCasterino\LibClassicCasterino.lua #@end-non-version-bcc@ -libs\LibHealComm-4.0\LibHealComm-4.0.xml #@end-no-lib-strip@ localization\enUS.lua diff --git a/modules/incheal.lua b/modules/incheal.lua index 5060319d..38fe2dbe 100644 --- a/modules/incheal.lua +++ b/modules/incheal.lua @@ -1,189 +1,146 @@ -local HealComm = LibStub("LibHealComm-4.0", true) -if( not HealComm ) then return end - -local IncHeal = {} -local frames = {} +local IncHeal = {["frameKey"] = "incHeal", ["colorKey"] = "inc", ["frameLevelMod"] = 2} +ShadowUF.IncHeal = IncHeal ShadowUF:RegisterModule(IncHeal, "incHeal", ShadowUF.L["Incoming heals"]) -ShadowUF.Tags.customEvents["HEALCOMM"] = IncHeal - --- How far ahead to show heals at most -local INCOMING_SECONDS = 3 function IncHeal:OnEnable(frame) - frames[frame] = true frame.incHeal = frame.incHeal or ShadowUF.Units:CreateBar(frame) frame:RegisterUnitEvent("UNIT_MAXHEALTH", self, "UpdateFrame") frame:RegisterUnitEvent("UNIT_HEALTH", self, "UpdateFrame") - frame:RegisterUpdateFunc(self, "UpdateFrame") + frame:RegisterUnitEvent("UNIT_HEAL_PREDICTION", self, "UpdateFrame") - self:Setup() + frame:RegisterUpdateFunc(self, "UpdateFrame") end function IncHeal:OnDisable(frame) frame:UnregisterAll(self) - frame.incHeal:Hide() - - if( not frame.hasHCTag ) then - frames[frame] = nil - self:Setup() - end + frame[self.frameKey]:Hide() end function IncHeal:OnLayoutApplied(frame) - if( frame.visibility.incHeal and frame.visibility.healthBar ) then - frame.incHeal:SetHeight(frame.healthBar:GetHeight()) - frame.incHeal:SetStatusBarTexture(ShadowUF.Layout.mediaPath.statusbar) - frame.incHeal:SetStatusBarColor(ShadowUF.db.profile.healthColors.inc.r, ShadowUF.db.profile.healthColors.inc.g, ShadowUF.db.profile.healthColors.inc.b, ShadowUF.db.profile.bars.alpha) - frame.incHeal:GetStatusBarTexture():SetHorizTile(false) - frame.incHeal:Hide() - - -- When we can cheat and put the incoming bar right behind the health bar, we can efficiently show the incoming heal bar - -- if the main bar has a transparency set, then we need a more complicated method to stop the health bar from being darker with incoming heals up - if( ( ShadowUF.db.profile.units[frame.unitType].healthBar.invert and ShadowUF.db.profile.bars.backgroundAlpha == 0 ) or ( not ShadowUF.db.profile.units[frame.unitType].healthBar.invert and ShadowUF.db.profile.bars.alpha == 1 ) ) then - frame.incHeal.simple = true - frame.incHeal:SetWidth(frame.healthBar:GetWidth() * ShadowUF.db.profile.units[frame.unitType].incHeal.cap) - frame.incHeal:SetFrameLevel(frame.topFrameLevel - 3) - - frame.incHeal:ClearAllPoints() - frame.incHeal:SetPoint("TOPLEFT", frame.healthBar) - frame.incHeal:SetPoint("BOTTOMLEFT", frame.healthBar) - else - frame.incHeal.simple = nil - frame.incHeal:SetFrameLevel(frame.topFrameLevel) - frame.incHeal:SetWidth(1) - frame.incHeal:SetMinMaxValues(0, 1) - frame.incHeal:SetValue(1) - - local x, y = select(4, frame.healthBar:GetPoint()) - frame.incHeal:ClearAllPoints() - frame.incHeal.healthX = x - frame.incHeal.healthY = y - frame.incHeal.healthWidth = frame.healthBar:GetWidth() - frame.incHeal.maxWidth = frame.incHeal.healthWidth * ShadowUF.db.profile.units[frame.unitType].incHeal.cap - frame.incHeal.cappedWidth = frame.incHeal.healthWidth * (ShadowUF.db.profile.units[frame.unitType].incHeal.cap - 1) - end + local bar = frame[self.frameKey] + if( not frame.visibility[self.frameKey] or not frame.visibility.healthBar ) then return end + + if( UnitGetTotalHealAbsorbs and frame.visibility.healAbsorb ) then + frame:RegisterUnitEvent("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", self, "UpdateFrame") + else + frame:UnregisterSingleEvent("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", self, "UpdateFrame") end -end --- Since I don't want a more complicated system where both incheal.lua and tags.lua are watching the same events --- I'll update the HC tags through here instead -function IncHeal:EnableTag(frame) - frames[frame] = true - frame.hasHCTag = true + -- Since we're hiding, reset state + bar.total = nil - self:Setup() -end + bar:SetSize(frame.healthBar:GetSize()) + bar:SetStatusBarTexture(ShadowUF.Layout.mediaPath.statusbar) + bar:SetStatusBarColor(ShadowUF.db.profile.healthColors[self.colorKey].r, ShadowUF.db.profile.healthColors[self.colorKey].g, ShadowUF.db.profile.healthColors[self.colorKey].b, ShadowUF.db.profile.bars.alpha) + bar:GetStatusBarTexture():SetHorizTile(false) + bar:SetOrientation(frame.healthBar:GetOrientation()) + bar:SetReverseFill(frame.healthBar:GetReverseFill()) + bar:Hide() + + local cap = ShadowUF.db.profile.units[frame.unitType][self.frameKey].cap or 1.30 -function IncHeal:DisableTag(frame) - frame.hasHCTag = nil + -- When we can cheat and put the incoming bar right behind the health bar, we can efficiently show the incoming heal bar + -- if the main bar has a transparency set, then we need a more complicated method to stop the health bar from being darker with incoming heals up + if( ( ShadowUF.db.profile.units[frame.unitType].healthBar.invert and ShadowUF.db.profile.bars.backgroundAlpha == 0 ) or ( not ShadowUF.db.profile.units[frame.unitType].healthBar.invert and ShadowUF.db.profile.bars.alpha == 1 ) ) then + bar.simple = true + bar:SetFrameLevel(frame.topFrameLevel - self.frameLevelMod) + + if( bar:GetOrientation() == "HORIZONTAL" ) then + bar:SetWidth(frame.healthBar:GetWidth() * cap) + else + bar:SetHeight(frame.healthBar:GetHeight() * cap) + end + + bar:ClearAllPoints() + + local point = bar:GetReverseFill() and "RIGHT" or "LEFT" + bar:SetPoint("TOP" .. point, frame.healthBar) + bar:SetPoint("BOTTOM" .. point, frame.healthBar) + else + bar.simple = nil + bar:SetFrameLevel(frame.topFrameLevel - self.frameLevelMod + 3) + bar:SetWidth(1) + bar:SetMinMaxValues(0, 1) + bar:SetValue(1) + bar:ClearAllPoints() + + bar.orientation = bar:GetOrientation() + bar.reverseFill = bar:GetReverseFill() + + if( bar.orientation == "HORIZONTAL" ) then + bar.healthSize = frame.healthBar:GetWidth() + bar.positionPoint = bar.reverseFill and "TOPRIGHT" or "TOPLEFT" + bar.positionRelative = bar.reverseFill and "BOTTOMRIGHT" or "BOTTOMLEFT" + else + bar.healthSize = frame.healthBar:GetHeight() + bar.positionPoint = bar.reverseFill and "TOPLEFT" or "BOTTOMLEFT" + bar.positionRelative = bar.reverseFill and "TOPRIGHT" or "BOTTOMRIGHT" + end - if( not frame.visibility.incHeal ) then - frames[frame] = nil - self:Setup() + bar.positionMod = bar.reverseFill and -1 or 1 + bar.maxSize = bar.healthSize * cap end end --- Check if we need to register callbacks -function IncHeal:Setup() - local enabled - for frame in pairs(frames) do - enabled = true - break +function IncHeal:PositionBar(frame, incAmount) + local bar = frame[self.frameKey] + -- If incoming is <= 0 ir health is <= 0 we can hide it + if( incAmount <= 0 ) then + bar.total = nil + bar:Hide() + return end - if( not enabled ) then - if( HealComm ) then - HealComm:UnregisterAllCallbacks(IncHeal) - end + local health = UnitHealth(frame.unit) + if( health <= 0 ) then + bar.total = nil + bar:Hide() return end - HealComm.RegisterCallback(self, "HealComm_HealStarted", "HealComm_HealUpdated") - HealComm.RegisterCallback(self, "HealComm_HealStopped") - HealComm.RegisterCallback(self, "HealComm_HealDelayed", "HealComm_HealUpdated") - HealComm.RegisterCallback(self, "HealComm_HealUpdated") - HealComm.RegisterCallback(self, "HealComm_ModifierChanged") - HealComm.RegisterCallback(self, "HealComm_GUIDDisappeared") -end + local maxHealth = UnitHealthMax(frame.unit) + if( maxHealth <= 0 ) then + bar.total = nil + bar:Hide() + return + end --- Update any tags using HC -function IncHeal:UpdateTags(frame, amount) - if( not frame.fontStrings or not frame.hasHCTag ) then return end + if( not bar.total ) then bar:Show() end + bar.total = incAmount - for _, fontString in pairs(frame.fontStrings) do - if( fontString.HEALCOMM ) then - fontString.incoming = amount > 0 and amount or nil - fontString:UpdateTags() + -- When the primary bar has an alpha of 100%, we can cheat and do incoming heals easily. Otherwise we need to do it a more complex way to keep it looking good + if( bar.simple ) then + bar.total = health + incAmount + bar:SetMinMaxValues(0, maxHealth * (ShadowUF.db.profile.units[frame.unitType][self.frameKey].cap or 1.30)) + bar:SetValue(bar.total) + else + local healthSize = bar.healthSize * (health / maxHealth) + local incSize = bar.healthSize * (incAmount / maxHealth) + + if( (healthSize + incSize) > bar.maxSize ) then + incSize = bar.maxSize - healthSize end - end -end -local function updateHealthBar(frame, interrupted) - -- This makes sure that when a heal like Tranquility is cast, it won't show the entire cast but cap it at 4 seconds into the future - local time = GetTime() - local healed = (HealComm:GetHealAmount(frame.unitGUID, HealComm.ALL_HEALS, time + INCOMING_SECONDS) or 0) * HealComm:GetHealModifier(frame.unitGUID) - - -- Update any tags that are using HC data - IncHeal:UpdateTags(frame, healed) - - -- Bar is also supposed to be enabled, lets update that too - if( frame.visibility.incHeal and frame.visibility.healthBar ) then - if( healed > 0 ) then - frame.incHeal.healed = healed - frame.incHeal:Show() - - -- When the primary bar has an alpha of 100%, we can cheat and do incoming heals easily. Otherwise we need to do it a more complex way to keep it looking good - if( frame.incHeal.simple ) then - frame.incHeal.total = UnitHealth(frame.unit) + healed - frame.incHeal:SetMinMaxValues(0, UnitHealthMax(frame.unit) * ShadowUF.db.profile.units[frame.unitType].incHeal.cap) - frame.incHeal:SetValue(frame.incHeal.total) - else - local health, maxHealth = UnitHealth(frame.unit), UnitHealthMax(frame.unit) - local healthWidth = frame.incHeal.healthWidth * (health / maxHealth) - local incWidth = frame.healthBar:GetWidth() * (healed / health) - if( (healthWidth + incWidth) > frame.incHeal.maxWidth ) then - incWidth = frame.incHeal.cappedWidth - end - - frame.incHeal:SetWidth(incWidth) - frame.incHeal:SetPoint("TOPLEFT", frame, "TOPLEFT", frame.incHeal.healthX + healthWidth, frame.incHeal.healthY) - end + if( bar.orientation == "HORIZONTAL" ) then + bar:SetWidth(incSize) + bar:SetPoint(bar.positionPoint, frame.healthBar, bar.positionMod * healthSize, 0) + bar:SetPoint(bar.positionRelative, frame.healthBar, bar.positionMod * healthSize, 0) else - frame.incHeal.total = nil - frame.incHeal.healed = nil - frame.incHeal:Hide() + bar:SetHeight(incSize) + bar:SetPoint(bar.positionPoint, frame.healthBar, 0, bar.positionMod * healthSize) + bar:SetPoint(bar.positionRelative, frame.healthBar, 0, bar.positionMod * healthSize) end end end function IncHeal:UpdateFrame(frame) - updateHealthBar(frame, true) -end + if( not frame.visibility[self.frameKey] or not frame.visibility.healthBar ) then return end -function IncHeal:UpdateIncoming(interrupted, ...) - for frame in pairs(frames) do - for i=1, select("#", ...) do - if( select(i, ...) == frame.unitGUID ) then - updateHealthBar(frame, interrupted) - end - end + local amount = UnitGetIncomingHeals(frame.unit) or 0 + if( amount > 0 and frame.visibility.healAbsorb ) then + amount = amount + (UnitGetTotalHealAbsorbs and UnitGetTotalHealAbsorbs(frame.unit) or 0) end -end - --- Handle callbacks from HealComm -function IncHeal:HealComm_HealUpdated(event, casterGUID, spellID, healType, endTime, ...) - self:UpdateIncoming(nil, ...) -end - -function IncHeal:HealComm_HealStopped(event, casterGUID, spellID, healType, interrupted, ...) - self:UpdateIncoming(interrupted, ...) -end - -function IncHeal:HealComm_ModifierChanged(event, guid) - self:UpdateIncoming(nil, guid) -end -function IncHeal:HealComm_GUIDDisappeared(event, guid) - self:UpdateIncoming(true, guid) + self:PositionBar(frame, amount) end diff --git a/options/config.lua b/options/config.lua index c55025cc..b75b5a2e 100755 --- a/options/config.lua +++ b/options/config.lua @@ -3428,19 +3428,23 @@ local function loadUnitOptions() type = "group", inline = false, name = L["Incoming heals"], - hidden = hideRestrictedOption, + hidden = function(info) return ShadowUF.Units.zoneUnits[info[2]] or hideRestrictedOption(info) end, disabled = function(info) return not getVariable(info[2], "healthBar", nil, "enabled") end, args = { - enabled = { + heals = { order = 1, type = "toggle", - name = string.format(L["Enable %s"], L["Incoming heals"]), - desc = L["Adds a bar inside the health bar indicating how much healing someone is estimated to be receiving."], + name = L["Show incoming heals"], + desc = L["Adds a bar inside the health bar indicating how much healing someone will receive."], arg = "incHeal.enabled", hidden = false, + set = function(info, value) + setUnit(info, value) + setDirectUnit(info[2], "incHeal", nil, "enabled", getVariable(info[2], "incHeal", nil, "enabled")) + end }, cap = { - order = 2, + order = 3, type = "range", name = L["Outside bar limit"], desc = L["Percentage value of how far outside the unit frame the incoming heal bar can go. 130% means it will go 30% outside the frame, 100% means it will not go outside."], From 8c8a831ca0a8970a8f711f4ce4dca644a22d7bb0 Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Mon, 5 Sep 2022 12:52:58 +0200 Subject: [PATCH 03/13] Remove casting API overrides for BC, as this was fixed --- modules/cast.lua | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/modules/cast.lua b/modules/cast.lua index 32364b81..d1fdf712 100755 --- a/modules/cast.lua +++ b/modules/cast.lua @@ -28,19 +28,6 @@ if WoWClassic then end end end -if WoWBC then - UnitCastingInfo = function(unit) - -- nonInterruptible is missing from the returns - local name, text, texture, startTime, endTime, isTradeSkill, castID, spellID = _G.UnitCastingInfo(unit) - return name, text, texture, startTime, endTime, isTradeSkill, castID, nil, spellID - end - - UnitChannelInfo = function(unit) - -- nonInterruptible is missing from the returns - local name, text, texture, startTime, endTime, isTradeSkill, spellID = _G.UnitChannelInfo(unit) - return name, text, texture, startTime, endTime, isTradeSkill, nil, spellID - end -end function Cast:OnEnable(frame) if( not frame.castBar ) then From 594331745c47bed2322eb3bf1e96f827f9ba58e5 Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Thu, 15 Sep 2022 08:56:26 +0200 Subject: [PATCH 04/13] Update TOC for Wrath support --- ShadowedUnitFrames.toc | 19 +++++++++++-------- options/ShadowedUF_Options.toc | 6 +++--- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ShadowedUnitFrames.toc b/ShadowedUnitFrames.toc index 447cfa55..344a6291 100755 --- a/ShadowedUnitFrames.toc +++ b/ShadowedUnitFrames.toc @@ -1,6 +1,6 @@ -## Interface: 20502 -## Interface-Classic: 11307 -## Interface-BCC: 20502 +## Interface: 30400 +## Interface-Classic: 11403 +## Interface-BCC: 20504 ## Title: Shadowed Unit Frames ## Notes: Moooooooooooooooooo ## Author: Shadowed @@ -8,8 +8,11 @@ ## SavedVariables: ShadowedUFDB ## X-Website: https://www.wowace.com/addons/shadowed-unit-frames/ #@version-bcc@ -## OptionalDeps: Ace3, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, LibSpellRange-1.0, Clique, LibHealComm-4.0 +## OptionalDeps: Ace3, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, LibSpellRange-1.0, Clique #@end-version-bcc@ +#@version-wrath@ +## OptionalDeps: Ace3, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, LibSpellRange-1.0, Clique +#@end-version-wrath@ #@non-version-bcc@ # ## OptionalDeps: Ace3, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, LibSpellRange-1.0, LibClassicDurations, Clique, LibClassicCasterino #@end-non-version-bcc@ @@ -22,10 +25,10 @@ libs\CallbackHandler-1.0\CallbackHandler-1.0.xml libs\LibSharedMedia-3.0\lib.xml libs\AceDB-3.0\AceDB-3.0.xml libs\LibSpellRange-1.0\lib.xml -#@non-version-bcc@ -# libs\LibClassicDurations\LibClassicDurations.xml -# libs\LibClassicCasterino\LibClassicCasterino.lua -#@end-non-version-bcc@ +#@version-classic@ +libs\LibClassicDurations\LibClassicDurations.xml +libs\LibClassicCasterino\LibClassicCasterino.lua +#@end-version-classic@ #@end-no-lib-strip@ localization\enUS.lua diff --git a/options/ShadowedUF_Options.toc b/options/ShadowedUF_Options.toc index aca4c461..a368f390 100755 --- a/options/ShadowedUF_Options.toc +++ b/options/ShadowedUF_Options.toc @@ -1,6 +1,6 @@ -## Interface: 20502 -## Interface-Classic: 11307 -## Interface-BCC: 20502 +## Interface: 30400 +## Interface-Classic: 11403 +## Interface-BCC: 20504 ## Title: Shadowed UF (Options) ## Notes: Configuration for Shadowed Unit Frames. ## Author: Shadowed From b19cd2d3ae108959d7c15bdd005db98fb8c66a7e Mon Sep 17 00:00:00 2001 From: Desarc Date: Fri, 2 Sep 2022 20:17:44 +0200 Subject: [PATCH 05/13] Shamans can now remove curses --- modules/units.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/units.lua b/modules/units.lua index ff8ec6c8..08b02bf9 100755 --- a/modules/units.lua +++ b/modules/units.lua @@ -1322,7 +1322,7 @@ local curableSpells = { ["DRUID"] = {[2893] = {"Poison"}, [8946] = {"Poison"}, [2782] = {"Curse"}}, ["PRIEST"] = {[527] = {"Magic"}, [528] = {"Disease"}, [552] = {"Disease"}}, ["PALADIN"] = {[1152] = {"Poison", "Disease"}, [4987] = {"Poison", "Disease", "Magic"}}, - ["SHAMAN"] = {[2870] = {"Disease"}, [8170] = {"Disease"}, [526] = {"Poison"}, [8166] = {"Poison"}}, + ["SHAMAN"] = {[2870] = {"Disease"}, [8170] = {"Disease"}, [526] = {"Poison"}, [8166] = {"Poison"}, [51886] = {"Poison", "Disease", "Curse"}}, ["MAGE"] = {[475] = {"Curse"}}, } From 8aa3cda729c19c9002ce8566b4a41b725dcd4af1 Mon Sep 17 00:00:00 2001 From: Desarc Date: Fri, 2 Sep 2022 20:17:52 +0200 Subject: [PATCH 06/13] Temporary fix for main tank frames to handle role selection issues --- ShadowedUnitFrames.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ShadowedUnitFrames.lua b/ShadowedUnitFrames.lua index 5628b0b5..b45bfdc6 100755 --- a/ShadowedUnitFrames.lua +++ b/ShadowedUnitFrames.lua @@ -431,7 +431,7 @@ function ShadowUF:LoadUnitDefaults() self.defaults.profile.units.raidpet.fader = {enabled = false, combatAlpha = 1.0, inactiveAlpha = 0.60} self.defaults.profile.units.raidpet.combatText.enabled = false -- MAINTANK - self.defaults.profile.units.maintank.roleFilter = "TANK" + -- self.defaults.profile.units.maintank.roleFilter = "TANK" self.defaults.profile.units.maintank.groupFilter = "MAINTANK" self.defaults.profile.units.maintank.groupBy = "GROUP" self.defaults.profile.units.maintank.sortOrder = "ASC" From e896d656b2b426d209fa7f87851e4e866f14b6d1 Mon Sep 17 00:00:00 2001 From: Desarc Date: Fri, 2 Sep 2022 20:40:09 +0200 Subject: [PATCH 07/13] Add Death Knight rune bar --- .luacheckrc | 1 + ShadowedUnitFrames.lua | 1 + ShadowedUnitFrames.toc | 1 + modules/defaultlayout.lua | 8 ++- modules/runes.lua | 145 ++++++++++++++++++++++++++++++++++++++ modules/tags.lua | 14 ++++ options/config.lua | 44 +++++++++++- 7 files changed, 212 insertions(+), 2 deletions(-) create mode 100644 modules/runes.lua diff --git a/.luacheckrc b/.luacheckrc index a7f9236e..2190747f 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -62,6 +62,7 @@ read_globals = { "GetRaidTargetIndex", "GetReadyCheckStatus", "GetRuneCooldown", + "GetRuneType", "GetSpecialization", "GetSpecializationInfoByID", "GetSpellInfo", diff --git a/ShadowedUnitFrames.lua b/ShadowedUnitFrames.lua index b45bfdc6..838fd4b2 100755 --- a/ShadowedUnitFrames.lua +++ b/ShadowedUnitFrames.lua @@ -351,6 +351,7 @@ function ShadowUF:LoadUnitDefaults() self.defaults.profile.units.player.healthBar.predicted = true self.defaults.profile.units.player.powerBar.predicted = true self.defaults.profile.units.player.indicators.status.enabled = true + self.defaults.profile.units.player.runeBar = {enabled = false} self.defaults.profile.units.player.totemBar = {enabled = false} self.defaults.profile.units.player.druidBar = {enabled = false} self.defaults.profile.units.player.xpBar = {enabled = false} diff --git a/ShadowedUnitFrames.toc b/ShadowedUnitFrames.toc index 344a6291..bdf0954b 100755 --- a/ShadowedUnitFrames.toc +++ b/ShadowedUnitFrames.toc @@ -68,6 +68,7 @@ modules\combopoints.lua modules\range.lua modules\empty.lua modules\druid.lua +modules\runes.lua #@do-not-package@ options\config.lua #@end-do-not-package@ diff --git a/modules/defaultlayout.lua b/modules/defaultlayout.lua index fb46ad9d..28ae3d37 100755 --- a/modules/defaultlayout.lua +++ b/modules/defaultlayout.lua @@ -145,6 +145,10 @@ function ShadowUF:LoadDefaultLayout(useMerge) FOCUS = {r = 1.0, g = 0.50, b = 0.25}, ENERGY = {r = 1.0, g = 0.85, b = 0.10}, RUNES = {r = 0.50, g = 0.50, b = 0.50}, + RUNES_BLOOD = {r = 0.95, g = 0.0, b = 0.08}, + RUNES_FROST = {r = 0.0, g = 0.85, b = 1.0}, + RUNES_UNHOLY = {r = 0.0, g = 1.0, b = 0.35}, + RUNES_DEATH = {r = 0.69, g = 0.15, b = 1.0}, RUNIC_POWER = {b = 0.60, g = 0.45, r = 0.35}, AMMOSLOT = {r = 0.85, g = 0.60, b = 0.55}, FUEL = {r = 0.85, g = 0.47, b = 0.36}, @@ -331,6 +335,7 @@ function ShadowUF:LoadDefaultLayout(useMerge) castBar = {order = 60}, xpBar = {order = 55}, fader = {enabled = false, combatAlpha = 1.0, inactiveAlpha = 0.6}, + runeBar = {enabled = true, background = false, height = 0.40, order = 70}, totemBar = {enabled = true, background = false, height = 0.40, order = 70}, druidBar = {enabled = true, background = true, height = 0.40, order = 70}, comboPoints = {enabled = true, anchorTo = "$parent", order = 60, anchorPoint = "BR", x = -3, y = 8, size = 14, spacing = -4, growth = "LEFT", isBar = true, height = 0.40}, @@ -347,7 +352,8 @@ function ShadowUF:LoadDefaultLayout(useMerge) {text = "[perpp]"}, {text = "[curmaxpp]"}, {text = "[(()afk() )][name][( ()group())]"}, - {text = ""} + {text = ""}, + {enabled = true, width = 1, name = L["Timer Text"], text = "[rune:timer]", anchorTo = "$runeBar", anchorPoint = "C", size = 0, x = 0, y = 0, default = true, block = true}, }, }, party = { diff --git a/modules/runes.lua b/modules/runes.lua new file mode 100644 index 00000000..73fe25e2 --- /dev/null +++ b/modules/runes.lua @@ -0,0 +1,145 @@ +local Runes = {} + +ShadowUF:RegisterModule(Runes, "runeBar", ShadowUF.L["Rune bar"], true, "DEATHKNIGHT") +ShadowUF.BlockTimers:Inject(Runes, "RUNE_TIMER") +ShadowUF.DynamicBlocks:Inject(Runes) + +function Runes:OnEnable(frame) + if( not frame.runeBar ) then + frame.runeBar = CreateFrame("StatusBar", nil, frame) + frame.runeBar:SetMinMaxValues(0, 1) + frame.runeBar:SetValue(0) + frame.runeBar.runes = {} + frame.runeBar.blocks = frame.runeBar.runes + + for i = 1, 6 do + local rune = ShadowUF.Units:CreateBar(frame.runeBar) + rune.id = i + + if( i > 1 ) then + rune:SetPoint("TOPLEFT", frame.runeBar.runes[i-1], "TOPRIGHT", 1, 0) + else + rune:SetPoint("TOPLEFT", frame.runeBar, "TOPLEFT", 0, 0) + end + + frame.runeBar.runes[i] = rune + end + end + + frame:RegisterNormalEvent("RUNE_POWER_UPDATE", self, "UpdateUsable") + frame:RegisterNormalEvent("RUNE_TYPE_UPDATE", self, "UpdateType") + frame:RegisterUpdateFunc(self, "UpdateUsable") +end + +function Runes:OnDisable(frame) + frame:UnregisterAll(self) +end + +function Runes:OnLayoutApplied(frame) + if( not frame.visibility.runeBar ) then return end + + local barWidth = (frame.runeBar:GetWidth() - 5) / 6 + for runeNumber, rune in pairs(frame.runeBar.runes) do + if( ShadowUF.db.profile.units[frame.unitType].runeBar.background ) then + rune.background:Show() + else + rune.background:Hide() + end + + rune.background:SetTexture(ShadowUF.Layout.mediaPath.statusbar) + rune.background:SetHorizTile(false) + rune:SetStatusBarTexture(ShadowUF.Layout.mediaPath.statusbar) + rune:GetStatusBarTexture():SetHorizTile(false) + rune:SetWidth(barWidth) + + frame:SetBlockColor(rune, "runeBar", 0.5, 0.5, 0.5) + self:UpdateType(frame, "RUNE_TYPE_UPDATE", runeNumber) + end +end + +local function runeMonitor(self, elapsed) + local time = GetTime() + self:SetValue(time) + + if( time >= self.endTime ) then + self:SetValue(self.endTime) + self:SetAlpha(1.0) + self:SetScript("OnUpdate", nil) + self.endTime = nil + end + + if( self.fontString ) then + self.fontString:UpdateTags() + end +end + +-- Updates the timers on runes +function Runes:UpdateUsable(frame, event, runeNumber, usable) + local order = {1, 2, 5, 6, 3, 4} + if( not runeNumber or not order[runeNumber] ) then + return + end + + local index = order[runeNumber] + if( not index or not frame.runeBar.runes[index] ) then + return + end + + local rune = frame.runeBar.runes[index] + + local startTime, cooldown, cooled = GetRuneCooldown(runeNumber) + -- Blizzard changed something with this API apparently and now it can be true/false/nil + if( cooled == nil ) then return end + + if( not cooled ) then + rune.endTime = startTime + cooldown + rune:SetMinMaxValues(startTime, rune.endTime) + rune:SetValue(GetTime()) + rune:SetAlpha(0.40) + rune:SetScript("OnUpdate", runeMonitor) + else + rune:SetMinMaxValues(0, 1) + rune:SetValue(1) + rune:SetAlpha(1.0) + rune:SetScript("OnUpdate", nil) + rune.endTime = nil + end + + if( rune.fontString ) then + rune.fontString:UpdateTags() + end + + self:UpdateType(frame, event, runeNumber) +end + +-- Updates the color +function Runes:UpdateType(frame, event, runeNumber, ...) + if( not runeNumber or not frame.runeBar.runes[runeNumber] ) then + return + end + + local rune = frame.runeBar.runes[runeNumber] + + -- Colorize by rune type + local runeType = GetRuneType(runeNumber) + -- RUNETYPE_BLOOD + if(runeType == 1) then + local color = ShadowUF.db.profile.powerColors.RUNES_BLOOD + frame:SetBlockColor(rune, "runeBar", color.r, color.g, color.b) + end + -- RUNETYPE_CHROMATIC ("CHROMATIC" refers to Unholy runes) + if(runeType == 2) then + local color = ShadowUF.db.profile.powerColors.RUNES_UNHOLY + frame:SetBlockColor(rune, "runeBar", color.r, color.g, color.b) + end + -- RUNETYPE_FROST + if(runeType == 3) then + local color = ShadowUF.db.profile.powerColors.RUNES_FROST + frame:SetBlockColor(rune, "runeBar", color.r, color.g, color.b) + end + -- RUNETYPE_DEATH + if(runeType == 4) then + local color = ShadowUF.db.profile.powerColors.RUNES_DEATH + frame:SetBlockColor(rune, "runeBar", color.r, color.g, color.b) + end +end diff --git a/modules/tags.lua b/modules/tags.lua index a4709d5b..20710fcd 100755 --- a/modules/tags.lua +++ b/modules/tags.lua @@ -391,6 +391,10 @@ Druid.FlightForm = GetSpellInfo(33943) ShadowUF.Druid = Druid Tags.defaultTags = { + ["rune:timer"] = [[function(unit, unitOwner, fontString) + local endTime = fontString.block.endTime + return endTime and string.format("%.1f", endTime - GetTime()) or nil + end]], ["totem:timer"] = [[function(unit, unitOwner, fontString) local endTime = fontString.block.endTime return endTime and string.format("%.1f", endTime - GetTime()) or nil @@ -982,6 +986,7 @@ Tags.defaultTags = { -- Default tag events Tags.defaultEvents = { ["totem:timer"] = "SUF_TOTEM_TIMER", + ["rune:timer"] = "SUF_RUNE_TIMER", ["hp:color"] = "UNIT_HEALTH UNIT_HEALTH_FREQUENT UNIT_MAXHEALTH", ["short:druidform"] = "UNIT_AURA", ["druidform"] = "UNIT_AURA", @@ -1064,6 +1069,7 @@ Tags.defaultFrequents = { -- Default tag categories Tags.defaultCategories = { ["totem:timer"] = "classtimer", + ["rune:timer"] = "classtimer", ["hp:color"] = "health", ["smart:curmaxhp"] = "health", ["smart:curmaxpp"] = "health", @@ -1143,6 +1149,7 @@ Tags.defaultCategories = { -- Default tag help Tags.defaultHelp = { ["totem:timer"] = L["How many seconds a totem has left before disappearing."], + ["rune:timer"] = L["How many seconds before a rune recharges."], ["abs:incabsorb"] = L["Absolute damage absorption value on the unit, if 10,000 damage will be absorbed, it will show 10,000."], ["incabsorb"] = L["Shorten damage absorption, if 13,000 damage will e absorbed, it will show 13k."], ["incabsorb:name"] = L["If the unit has a damage absorption shield on them, it will show the absolute absorb value, otherwise the units name."], @@ -1224,6 +1231,7 @@ Tags.defaultHelp = { Tags.defaultNames = { ["totem:timer"] = L["Totem Timer"], + ["rune:timer"] = L["Rune Timer"], ["abs:incabsorb"] = L["Damage absorption (Absolute)"], ["incabsorb"] = L["Damage absorption (Short)"], ["incabsorb:name"] = L["Damage absorption/Name"], @@ -1333,6 +1341,8 @@ Tags.eventType = { ["PARTY_LOOT_METHOD_CHANGED"] = "unitless", ["READY_CHECK"] = "unitless", ["READY_CHECK_FINISHED"] = "unitless", + ["RUNE_POWER_UPDATE"] = "unitless", + ["RUNE_TYPE_UPDATE"] = "unitless", ["UPDATE_FACTION"] = "unitless", } @@ -1345,10 +1355,12 @@ Tags.unitBlacklist = { Tags.unitRestrictions = { ["pvp:time"] = "player", ["totem:timer"] = "player", + ["rune:timer"] = "player" } Tags.anchorRestriction = { ["totem:timer"] = "$totemBar", + ["rune:timer"] = "$runeBar" } -- Event scanner to automatically figure out what events a tag will need @@ -1384,6 +1396,8 @@ local function loadAPIEvents() ["GetTotemInfo"] = "PLAYER_TOTEM_UPDATE", ["GetXPExhaustion"] = "UPDATE_EXHAUSTION", ["GetWatchedFactionInfo"] = "UPDATE_FACTION", + ["GetRuneCooldown"] = "RUNE_POWER_UPDATE", + ["GetRuneType"] = "RUNE_TYPE_UPDATE", ["GetRaidTargetIndex"] = "RAID_TARGET_UPDATE", ["GetComboPoints"] = "UNIT_POWER_FREQUENT", ["GetNumSubgroupMembers"] = "GROUP_ROSTER_UPDATE", diff --git a/options/config.lua b/options/config.lua index b75b5a2e..272dad69 100755 --- a/options/config.lua +++ b/options/config.lua @@ -1100,6 +1100,40 @@ local function loadGeneralOptions() arg = "powerColors.ENERGY", width = "half", }, + RUNIC_POWER = { + order = 6, + type = "color", + name = L["Runic Power"], + arg = "powerColors.RUNIC_POWER", + }, + RUNES_BLOOD = { + order = 7, + type = "color", + name = "Runes (Blood)", + arg = "powerColors.RUNES_BLOOD", + hidden = function(info) return select(2, UnitClass("player")) ~= "DEATHKNIGHT" end, + }, + RUNES_FROST = { + order = 8, + type = "color", + name = "Runes (Frost)", + arg = "powerColors.RUNES_FROST", + hidden = function(info) return select(2, UnitClass("player")) ~= "DEATHKNIGHT" end, + }, + RUNES_UNHOLY = { + order = 9, + type = "color", + name = "Runes (Unholy)", + arg = "powerColors.RUNES_UNHOLY", + hidden = function(info) return select(2, UnitClass("player")) ~= "DEATHKNIGHT" end, + }, + RUNES_DEATH = { + order = 10, + type = "color", + name = "Runes (Death)", + arg = "powerColors.RUNES_DEATH", + hidden = function(info) return select(2, UnitClass("player")) ~= "DEATHKNIGHT" end, + }, COMBOPOINTS = { order = 11, type = "color", @@ -3296,12 +3330,20 @@ local function loadUnitOptions() hidden = function(info) local unit = info[2] if( unit == "global" ) then - return not globalConfig.totemBar and not globalConfig.druidBar and not globalConfig.xpBar + return not globalConfig.runeBar and not globalConfig.totemBar and not globalConfig.druidBar and not globalConfig.xpBar else return unit ~= "player" and unit ~= "pet" end end, args = { + runeBar = { + order = 1, + type = "toggle", + name = string.format(L["Enable %s"], L["Rune bar"]), + desc = L["Adds rune bars and timers before runes refresh to the player frame."], + hidden = hideRestrictedOption, + arg = "runeBar.enabled", + }, druidBar = { order = 3, type = "toggle", From b893bbeb9875c97334398c55dbfd819d7ad8c00b Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Thu, 15 Sep 2022 09:22:46 +0200 Subject: [PATCH 08/13] Add migration code to add rune bars to existing frames --- ShadowedUnitFrames.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ShadowedUnitFrames.lua b/ShadowedUnitFrames.lua index 838fd4b2..1b8135af 100755 --- a/ShadowedUnitFrames.lua +++ b/ShadowedUnitFrames.lua @@ -6,7 +6,7 @@ ShadowUF = select(2, ...) local L = ShadowUF.L ShadowUF.dbRevision = 61 -ShadowUF.dbRevisionClassic = 4 +ShadowUF.dbRevisionClassic = 5 ShadowUF.playerUnit = "player" ShadowUF.enabledUnits = {} ShadowUF.modules = {} @@ -118,6 +118,26 @@ end function ShadowUF:CheckUpgrade() local revisionClassic = self.db.profile.revisionClassic or (self.db.profile.revision and 1 or self.dbRevisionClassic) local revision = self.db.profile.revision or self.dbRevision + if( revisionClassic <= 4 ) then + -- new resources + self.db.profile.powerColors.RUNES_BLOOD = {r = 0.95, g = 0.0, b = 0.08} + self.db.profile.powerColors.RUNES_FROST = {r = 0.0, g = 0.85, b = 1.0} + self.db.profile.powerColors.RUNES_UNHOLY = {r = 0.0, g = 1.0, b = 0.35} + self.db.profile.powerColors.RUNES_DEATH = {r = 0.69, g = 0.15, b = 1.0} + + -- new bars + local config = self.db.profile.units + config.player.runeBar = {enabled = true, background = false, height = 0.40, order = 70} + local hasRuneText = false + for i, text in ipairs(config.player.text) do + if text and text.anchorTo == "$runeBar" and text == "[rune:timer]" then + hasRuneText = true + end + end + if not hasRuneText then + table.insert(config.player.text, {enabled = true, width = 1, name = L["Timer Text"], text = "[rune:timer]", anchorTo = "$runeBar", anchorPoint = "C", size = 0, x = 0, y = 0, default = true, block = true}) + end + end if( revisionClassic <= 4 or not self.db.profile.revisionClassic ) then ShadowUF:LoadDefaultLayout(true) end From de24fe7c6cda9cad9c29a1cd47b3568cff525f50 Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Thu, 15 Sep 2022 09:28:22 +0200 Subject: [PATCH 09/13] Update packaging to create a unified classic package --- .github/workflows/packager.yml | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/workflows/packager.yml b/.github/workflows/packager.yml index bbdcbc80..da91440c 100644 --- a/.github/workflows/packager.yml +++ b/.github/workflows/packager.yml @@ -17,6 +17,10 @@ jobs: # The type of runner that the job will run on runs-on: ubuntu-latest + env: + CF_API_KEY: ${{ secrets.CF_API_KEY }} + GITHUB_OAUTH: ${{ secrets.GITHUB_TOKEN }} + # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it @@ -30,14 +34,6 @@ jobs: luarocks install --local luacheck /home/runner/.luarocks/bin/luacheck . --no-color -q - - name: Create Classic Package - run: curl -s https://raw.githubusercontent.com/BigWigsMods/packager/master/release.sh | bash -s -- -g classic - env: - CF_API_KEY: ${{ secrets.CF_API_KEY }} - GITHUB_OAUTH: ${{ secrets.GITHUB_TOKEN }} - - - name: Create BCC Package - run: curl -s https://raw.githubusercontent.com/BigWigsMods/packager/master/release.sh | bash -s -- -g bcc - env: - CF_API_KEY: ${{ secrets.CF_API_KEY }} - GITHUB_OAUTH: ${{ secrets.GITHUB_TOKEN }} + - uses: BigWigsMods/packager@v2 + with: + args: -S From 0acfacf1ffcf83ef46989ddc225b19f5cc74f6ac Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Tue, 20 Sep 2022 00:42:53 +0200 Subject: [PATCH 10/13] Add Threat API to emulation during moving --- modules/movers.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/movers.lua b/modules/movers.lua index 2866d046..c08cf56a 100755 --- a/modules/movers.lua +++ b/modules/movers.lua @@ -78,6 +78,8 @@ local function createConfigEnv() UnitIsAFK = function(unit) return false end, UnitFactionGroup = function(unit) return _G.UnitFactionGroup("player") end, UnitAffectingCombat = function() return true end, + UnitThreatSituation = function() return 0 end, + UnitDetailedThreatSituation = function() return nil end, UnitCastingInfo = function(unit) -- 1 -> 10: spell, displayName, icon, startTime, endTime, isTradeSkill, castID, notInterruptible, spellID local data = unitConfig["UnitCastingInfo" .. unit] or {} From c919633ffd3c7286affe16410f1b6927c000e7d2 Mon Sep 17 00:00:00 2001 From: Casey Raethke Date: Mon, 10 Oct 2022 17:14:54 -0500 Subject: [PATCH 11/13] Revert "Remove vehicle stuff" This reverts commit 42feaa1644712271eb17ffa4a621e830e021bde5. --- ShadowedUnitFrames.lua | 6 +- ShadowedUnitFrames.xml | 4 ++ modules/auraindicators.lua | 2 +- modules/auras.lua | 15 ++++- modules/combopoints.lua | 14 ++++- modules/defaultlayout.lua | 1 + modules/druid.lua | 2 +- modules/health.lua | 2 + modules/indicators.lua | 7 +++ modules/tags.lua | 11 +++- modules/totems.lua | 15 ++++- modules/units.lua | 115 +++++++++++++++++++++++++++++++++++-- modules/xp.lua | 2 +- options/config.lua | 37 ++++++++++++ 14 files changed, 219 insertions(+), 14 deletions(-) diff --git a/ShadowedUnitFrames.lua b/ShadowedUnitFrames.lua index 1b8135af..9535ed1a 100755 --- a/ShadowedUnitFrames.lua +++ b/ShadowedUnitFrames.lua @@ -13,7 +13,7 @@ ShadowUF.modules = {} ShadowUF.moduleOrder = {} ShadowUF.unitList = {"player", "pet", "pettarget", "target", "targettarget", "targettargettarget", "focus", "focustarget", "party", "partypet", "partytarget", "partytargettarget", "raid", "raidpet", "boss", "bosstarget", "maintank", "maintanktarget", "mainassist", "mainassisttarget", "arena", "arenatarget", "arenapet", "battleground", "battlegroundtarget", "battlegroundpet", "arenatargettarget", "battlegroundtargettarget", "maintanktargettarget", "mainassisttargettarget", "bosstargettarget"} ShadowUF.fakeUnits = {["targettarget"] = true, ["targettargettarget"] = true, ["pettarget"] = true, ["arenatarget"] = true, ["arenatargettarget"] = true, ["focustarget"] = true, ["focustargettarget"] = true, ["partytarget"] = true, ["raidtarget"] = true, ["bosstarget"] = true, ["maintanktarget"] = true, ["mainassisttarget"] = true, ["battlegroundtarget"] = true, ["partytargettarget"] = true, ["battlegroundtargettarget"] = true, ["maintanktargettarget"] = true, ["mainassisttargettarget"] = true, ["bosstargettarget"] = true} -L.units = {["raidpet"] = L["Raid pet"], ["PET"] = L["Pet"], ["arena"] = L["Arena"], ["arenapet"] = L["Arena Pet"], ["arenatarget"] = L["Arena Target"], ["arenatargettarget"] = L["Arena Target of Target"], ["boss"] = L["Boss"], ["bosstarget"] = L["Boss Target"], ["focus"] = L["Focus"], ["focustarget"] = L["Focus Target"], ["mainassist"] = L["Main Assist"], ["mainassisttarget"] = L["Main Assist Target"], ["maintank"] = L["Main Tank"], ["maintanktarget"] = L["Main Tank Target"], ["party"] = L["Party"], ["partypet"] = L["Party Pet"], ["partytarget"] = L["Party Target"], ["pet"] = L["Pet"], ["pettarget"] = L["Pet Target"], ["player"] = L["Player"],["raid"] = L["Raid"], ["target"] = L["Target"], ["targettarget"] = L["Target of Target"], ["targettargettarget"] = L["Target of Target of Target"], ["battleground"] = L["Battleground"], ["battlegroundpet"] = L["Battleground Pet"], ["battlegroundtarget"] = L["Battleground Target"], ["partytargettarget"] = L["Party Target of Target"], ["battlegroundtargettarget"] = L["Battleground Target of Target"], ["maintanktargettarget"] = L["Main Tank Target of Target"], ["mainassisttargettarget"] = L["Main Assist Target of Target"], ["bosstargettarget"] = L["Boss Target of Target"]} +L.units = {["raidpet"] = L["Raid pet"], ["PET"] = L["Pet"], ["VEHICLE"] = L["Vehicle"], ["arena"] = L["Arena"], ["arenapet"] = L["Arena Pet"], ["arenatarget"] = L["Arena Target"], ["arenatargettarget"] = L["Arena Target of Target"], ["boss"] = L["Boss"], ["bosstarget"] = L["Boss Target"], ["focus"] = L["Focus"], ["focustarget"] = L["Focus Target"], ["mainassist"] = L["Main Assist"], ["mainassisttarget"] = L["Main Assist Target"], ["maintank"] = L["Main Tank"], ["maintanktarget"] = L["Main Tank Target"], ["party"] = L["Party"], ["partypet"] = L["Party Pet"], ["partytarget"] = L["Party Target"], ["pet"] = L["Pet"], ["pettarget"] = L["Pet Target"], ["player"] = L["Player"],["raid"] = L["Raid"], ["target"] = L["Target"], ["targettarget"] = L["Target of Target"], ["targettargettarget"] = L["Target of Target of Target"], ["battleground"] = L["Battleground"], ["battlegroundpet"] = L["Battleground Pet"], ["battlegroundtarget"] = L["Battleground Target"], ["partytargettarget"] = L["Party Target of Target"], ["battlegroundtargettarget"] = L["Battleground Target of Target"], ["maintanktargettarget"] = L["Main Tank Target of Target"], ["mainassisttargettarget"] = L["Main Assist Target of Target"], ["bosstargettarget"] = L["Boss Target of Target"]} L.shortUnits = {["battleground"] = L["BG"], ["battlegroundtarget"] = L["BG Target"], ["battlegroundpet"] = L["BG Pet"], ["battlegroundtargettarget"] = L["BG ToT"], ["arenatargettarget"] = L["Arena ToT"], ["partytargettarget"] = L["Party ToT"], ["bosstargettarget"] = L["Boss ToT"], ["maintanktargettarget"] = L["MT ToT"], ["mainassisttargettarget"] = L["MA ToT"]} -- Cache the units so we don't have to concat every time it updates @@ -762,6 +762,10 @@ function ShadowUF:HideBlizzardFrames() -- We keep these in case someone is still using the default auras, otherwise it messes up vehicle stuff PlayerFrame:RegisterEvent("PLAYER_ENTERING_WORLD") + PlayerFrame:RegisterEvent("UNIT_ENTERING_VEHICLE") + PlayerFrame:RegisterEvent("UNIT_ENTERED_VEHICLE") + PlayerFrame:RegisterEvent("UNIT_EXITING_VEHICLE") + PlayerFrame:RegisterEvent("UNIT_EXITED_VEHICLE") PlayerFrame:SetMovable(true) PlayerFrame:SetUserPlaced(true) PlayerFrame:SetDontSavePosition(true) diff --git a/ShadowedUnitFrames.xml b/ShadowedUnitFrames.xml index 9ce821a8..ec6af43d 100644 --- a/ShadowedUnitFrames.xml +++ b/ShadowedUnitFrames.xml @@ -1,4 +1,8 @@ diff --git a/modules/auraindicators.lua b/modules/auraindicators.lua index 6af6a0c0..b1e1499d 100755 --- a/modules/auraindicators.lua +++ b/modules/auraindicators.lua @@ -23,7 +23,7 @@ Indicators.auraConfig = setmetatable({}, { return tbl[index] end}) -local playerUnits = {player = true, pet = true} +local playerUnits = {player = true, vehicle = true, pet = true} local backdropTbl = {bgFile = "Interface\\Addons\\ShadowedUnitFrames\\mediabackdrop", edgeFile = "Interface\\Addons\\ShadowedUnitFrames\\media\\backdrop", tile = true, tileSize = 1, edgeSize = 1} function Indicators:OnEnable(frame) diff --git a/modules/auras.lua b/modules/auras.lua index 1f6c244d..5d2b31bc 100755 --- a/modules/auras.lua +++ b/modules/auras.lua @@ -1,5 +1,5 @@ local Auras = {} -local playerUnits = {player = true, pet = true} +local playerUnits = {player = true, vehicle = true, pet = true} local mainHand, offHand, tempEnchantScan = {time = 0}, {time = 0} local canCure = ShadowUF.Units.canCure ShadowUF:RegisterModule(Auras, "auras", ShadowUF.L["Auras"]) @@ -236,7 +236,7 @@ local function hideTooltip(self) end local function cancelAura(self, mouse) - if( mouse ~= "RightButton" or not UnitIsUnit(self.parent.unit, "player") or InCombatLockdown() or self.filter == "TEMP" ) then + if( mouse ~= "RightButton" or ( not UnitIsUnit(self.parent.unit, "player") and not UnitIsUnit(self.parent.unit, "vehicle") ) or InCombatLockdown() or self.filter == "TEMP" ) then return end @@ -465,6 +465,17 @@ end -- Unfortunately, temporary enchants have basically no support beyond hacks. So we will hack! tempEnchantScan = function(self, elapsed) + if( self.parent.unit == self.parent.vehicleUnit and self.lastTemporary > 0 ) then + mainHand.has = false + offHand.has = false + + self.temporaryEnchants = 0 + self.lastTemporary = 0 + + Auras:Update(self.parent) + return + end + timeElapsed = timeElapsed + elapsed if( timeElapsed < 0.50 ) then return end timeElapsed = timeElapsed - 0.50 diff --git a/modules/combopoints.lua b/modules/combopoints.lua index eb01a898..f3f55f11 100755 --- a/modules/combopoints.lua +++ b/modules/combopoints.lua @@ -30,11 +30,21 @@ function Combo:GetMaxPoints() end function Combo:GetPoints(unit) - return UnitPower("player", cpConfig.powerType) + -- For Malygos dragons, they also self cast their CP on themselves, which is why we check CP on ourself + if( UnitHasVehicleUI("player") and UnitHasVehiclePlayerFrameUI("player") ) then + local points = GetComboPoints("vehicle") + if( points == 0 ) then + points = GetComboPoints("vehicle", "vehicle") + end + + return points + else + return UnitPower("player", cpConfig.powerType) + end end function Combo:Update(frame, event, unit, powerType) - if( not event or ( unit == frame.unit or unit == "player" ) ) then + if( not event or ( unit == frame.unit or unit == frame.vehicleUnit or unit == "player" or unit == "vehicle" ) ) then ShadowUF.ComboPoints.Update(self, frame, event, unit, powerType) end end diff --git a/modules/defaultlayout.lua b/modules/defaultlayout.lua index 28ae3d37..05ae2205 100755 --- a/modules/defaultlayout.lua +++ b/modules/defaultlayout.lua @@ -138,6 +138,7 @@ function ShadowUF:LoadDefaultLayout(useMerge) MONK = {r = 0.0, g = 1.00 , b = 0.59}, DEMONHUNTER = {r = 0.64, g = 0.19, b = 0.79}, PET = {r = 0.20, g = 0.90, b = 0.20}, + VEHICLE = {r = 0.23, g = 0.41, b = 0.23}, } config.powerColors = { MANA = {r = 0.30, g = 0.50, b = 0.85}, diff --git a/modules/druid.lua b/modules/druid.lua index f42aa868..51d0c199 100755 --- a/modules/druid.lua +++ b/modules/druid.lua @@ -22,7 +22,7 @@ function Druid:OnLayoutApplied(frame) end function Druid:PowerChanged(frame) - local visible = UnitPowerType(frame.unit) ~= Enum.PowerType.Mana + local visible = UnitPowerType(frame.unit) ~= Enum.PowerType.Mana and not frame.inVehicle local type = visible and "RegisterUnitEvent" or "UnregisterSingleEvent" frame[type](frame, "UNIT_POWER_FREQUENT", self, "Update") diff --git a/modules/health.lua b/modules/health.lua index 81c5ecf7..fccd24d9 100755 --- a/modules/health.lua +++ b/modules/health.lua @@ -91,6 +91,8 @@ function Health:UpdateColor(frame) return elseif( ShadowUF.db.profile.units[frame.unitType].healthBar.colorDispel and frame.healthBar.hasDebuff ) then color = DebuffTypeColor[frame.healthBar.hasDebuff] + elseif( frame.inVehicle ) then + color = ShadowUF.db.profile.classColors.VEHICLE elseif( not UnitPlayerControlled(unit) and UnitIsTapDenied(unit) and UnitCanAttack("player", unit) ) then color = ShadowUF.db.profile.healthColors.tapped elseif( not UnitPlayerOrPetInRaid(unit) and not UnitPlayerOrPetInParty(unit) and ( ( ( reactionType == "player" or reactionType == "both" ) and UnitIsPlayer(unit) and not UnitIsFriend(unit, "player") ) or ( ( reactionType == "npc" or reactionType == "both" ) and not UnitIsPlayer(unit) ) ) ) then diff --git a/modules/indicators.lua b/modules/indicators.lua index 24fe634c..29a752a2 100755 --- a/modules/indicators.lua +++ b/modules/indicators.lua @@ -131,6 +131,12 @@ local function combatMonitor(self, elapsed) end end +-- It looks like the combat check for players is a bit buggy when they are in a vehicle, so swap it to also check polling +function Indicators:CheckVehicle(frame) + frame.indicators.timeElapsed = 0 + frame.indicators:SetScript("OnUpdate", frame.inVehicle and combatMonitor or nil) +end + function Indicators:UpdateStatus(frame) if( not frame.indicators.status or not frame.indicators.status.enabled ) then return end @@ -259,6 +265,7 @@ function Indicators:OnEnable(frame) frame.indicators.parent = frame if( frame.unitType == "player" ) then + frame:RegisterUpdateFunc(self, "CheckVehicle") frame:RegisterNormalEvent("PLAYER_REGEN_ENABLED", self, "UpdateStatus") frame:RegisterNormalEvent("PLAYER_REGEN_DISABLED", self, "UpdateStatus") frame:RegisterNormalEvent("PLAYER_UPDATE_RESTING", self, "UpdateStatus") diff --git a/modules/tags.lua b/modules/tags.lua index 20710fcd..9213e988 100755 --- a/modules/tags.lua +++ b/modules/tags.lua @@ -793,7 +793,16 @@ Tags.defaultTags = { end end]], ["cpoints"] = [[function(unit, unitOwner) - return UnitPower("player", Enum.PowerType.ComboPoints) + if( UnitHasVehicleUI("player") and UnitHasVehiclePlayerFrameUI("player") ) then + local points = GetComboPoints("vehicle") + if( points == 0 ) then + points = GetComboPoints("vehicle", "vehicle") + end + + return points + else + return UnitPower("player", Enum.PowerType.ComboPoints) + end end]], ["smartlevel"] = [[function(unit, unitOwner) local classif = UnitClassification(unit) diff --git a/modules/totems.lua b/modules/totems.lua index 26d04e01..6c6f3420 100755 --- a/modules/totems.lua +++ b/modules/totems.lua @@ -44,6 +44,7 @@ function Totems:OnEnable(frame) end frame:RegisterNormalEvent("PLAYER_TOTEM_UPDATE", self, "Update") + frame:RegisterUpdateFunc(self, "UpdateVisibility") frame:RegisterUpdateFunc(self, "Update") end @@ -107,7 +108,7 @@ local function totemMonitor(self, elapsed) self:SetScript("OnUpdate", nil) self.endTime = nil - if( MAX_TOTEMS == 1 ) then + if( not self.parent.inVehicle and MAX_TOTEMS == 1 ) then ShadowUF.Layout:SetBarVisibility(self.parent, "totemBar", false) end end @@ -117,6 +118,18 @@ local function totemMonitor(self, elapsed) end end +function Totems:UpdateVisibility(frame) + if( frame.totemBar.inVehicle ~= frame.inVehicle ) then + frame.totemBar.inVehicle = frame.inVehicle + + if( frame.inVehicle ) then + ShadowUF.Layout:SetBarVisibility(frame, "totemBar", false) + elseif( MAX_TOTEMS ~= 1 ) then + self:Update(frame) + end + end +end + function Totems:Update(frame) local totalActive = 0 for _, indicator in pairs(frame.totemBar.totems) do diff --git a/modules/units.lua b/modules/units.lua index 08b02bf9..bff9ce8f 100755 --- a/modules/units.lua +++ b/modules/units.lua @@ -37,7 +37,7 @@ local function ReregisterUnitEvents(self) if( hasHandler ) then self:UnregisterEvent(event) - self:BlizzRegisterUnitEvent(event, self.unitOwner, nil) + self:BlizzRegisterUnitEvent(event, self.unitOwner, self.vehicleUnit) end end end @@ -52,7 +52,7 @@ local function RegisterNormalEvent(self, event, handler, func, unitOverride) end if( unitEvents[event] and not ShadowUF.fakeUnits[self.unitRealType] ) then - self:BlizzRegisterUnitEvent(event, unitOverride or self.unitOwner, nil) + self:BlizzRegisterUnitEvent(event, unitOverride or self.unitOwner, self.vehicleUnit) if unitOverride then self.unitEventOverrides = self.unitEventOverrides or {} self.unitEventOverrides[event] = unitOverride @@ -285,6 +285,62 @@ local function SetVisibility(self) end end +-- Vehicles do not always return their data right away, a pure OnUpdate check seems to be the most accurate unfortunately +local function checkVehicleData(self, elapsed) + self.timeElapsed = self.timeElapsed + elapsed + if( self.timeElapsed >= 0.50 ) then + self.timeElapsed = 0 + self.dataAttempts = self.dataAttempts + 1 + + -- Took too long to get vehicle data, or they are no longer in a vehicle + if( self.dataAttempts >= 6 or not UnitHasVehicleUI(self.unitOwner) or not UnitHasVehiclePlayerFrameUI(self.unitOwner) ) then + self.timeElapsed = nil + self.dataAttempts = nil + self:SetScript("OnUpdate", nil) + + self.inVehicle = false + self.unit = self.unitOwner + self:FullUpdate() + + -- Got data, stop checking and do a full frame update + elseif( UnitIsConnected(self.unit) or UnitHealthMax(self.unit) > 0 ) then + self.timeElapsed = nil + self.dataAttempts = nil + self:SetScript("OnUpdate", nil) + + self.unitGUID = UnitGUID(self.unit) + self:FullUpdate() + end + end +end + +-- Check if a unit entered a vehicle +function Units:CheckVehicleStatus(frame, event, unit) + if( event and frame.unitOwner ~= unit ) then return end + + -- Not in a vehicle yet, and they entered one that has a UI or they were in a vehicle but the GUID changed (vehicle -> vehicle) + if( ( not frame.inVehicle or frame.unitGUID ~= UnitGUID(frame.vehicleUnit) ) and UnitHasVehicleUI(frame.unitOwner) and UnitHasVehiclePlayerFrameUI(frame.unitOwner) and not ShadowUF.db.profile.units[frame.unitType].disableVehicle ) then + frame.inVehicle = true + frame.unit = frame.vehicleUnit + + if( not UnitIsConnected(frame.unit) or UnitHealthMax(frame.unit) == 0 ) then + frame.timeElapsed = 0 + frame.dataAttempts = 0 + frame:SetScript("OnUpdate", checkVehicleData) + else + frame.unitGUID = UnitGUID(frame.unit) + frame:FullUpdate() + end + + -- Was in a vehicle, no longer has a UI + elseif( frame.inVehicle and ( not UnitHasVehicleUI(frame.unitOwner) or not UnitHasVehiclePlayerFrameUI(frame.unitOwner) or ShadowUF.db.profile.units[frame.unitType].disableVehicle ) ) then + frame.inVehicle = false + frame.unit = frame.unitOwner + frame.unitGUID = UnitGUID(frame.unit) + frame:FullUpdate() + end +end + -- Handles checking for GUID changes for doing a full update, this fixes frames sometimes showing the wrong unit when they change function Units:CheckUnitStatus(frame) local guid = frame.unit and UnitGUID(frame.unit) @@ -310,8 +366,15 @@ end -- OnAttributeChanged won't do anything because the frame is already setup, however, the active unit is non-existant -- while the primary unit is. So if we see they're in a vehicle with this case, we force the full update to get the vehicle change function Units:CheckGroupedUnitStatus(frame) - frame.unitGUID = UnitGUID(frame.unit) - frame:FullUpdate() + if( frame.inVehicle and not UnitExists(frame.unit) and UnitExists(frame.unitOwner) ) then + frame.inVehicle = false + frame.unit = frame.unitOwner + frame.unitGUID = UnitGUID(frame.unit) + frame:FullUpdate() + else + frame.unitGUID = UnitGUID(frame.unit) + frame:FullUpdate() + end end -- More fun with sorting, due to sorting magic we have to check if we want to create stuff when the frame changes of partys too @@ -349,6 +412,7 @@ end -- unitType = Unitid minus numbers in it, used for configuration -- unitRealType = The actual unit type, if party is shown in raid this will be "party" while unitType is still "raid" -- unitOwner = Always the units owner even when unit changes due to vehicles +-- vehicleUnit = Unit to use when the unitOwner is in a vehicle OnAttributeChanged = function(self, name, unit) if( name ~= "unit" or not unit or unit == self.unitOwner ) then return end @@ -362,6 +426,8 @@ OnAttributeChanged = function(self, name, unit) self.unitRealType = string.gsub(unit, "([0-9]+)", "") self.unitType = self.unitUnmapped and string.gsub(self.unitUnmapped, "([0-9]+)", "") or self.unitType or self.unitRealType self.unitOwner = unit + self.vehicleUnit = self.unitOwner == "player" and "vehicle" or self.unitRealType == "party" and "partypet" .. self.unitID or self.unitRealType == "raid" and "raidpet" .. self.unitID or nil + self.inVehicle = nil -- Split everything into two maps, this is the simple parentUnit -> frame map -- This is for things like finding a party parent for party target/pet, the main map for doing full updates is @@ -396,6 +462,13 @@ OnAttributeChanged = function(self, name, unit) ClickCastFrames[self] = true end + -- Handles switching the internal unit variable to that of their vehicle + if( self.unit == "player" or self.unitRealType == "party" or self.unitRealType == "raid" ) then + self:RegisterNormalEvent("UNIT_ENTERED_VEHICLE", Units, "CheckVehicleStatus") + self:RegisterNormalEvent("UNIT_EXITED_VEHICLE", Units, "CheckVehicleStatus") + self:RegisterUpdateFunc(Units, "CheckVehicleStatus") + end + -- Phase change, do a full update on it self:RegisterUnitEvent("UNIT_PHASE", self, "FullUpdate") @@ -405,6 +478,33 @@ OnAttributeChanged = function(self, name, unit) self:SetAttribute("unitRealOwner", self.unitRealOwner) self:RegisterNormalEvent("UNIT_PET", Units, "CheckPetUnitUpdated") + if( self.unit == "pet" ) then + self:SetAttribute("disableVehicleSwap", ShadowUF.db.profile.units.player.disableVehicle) + else + self:SetAttribute("disableVehicleSwap", ShadowUF.db.profile.units.party.disableVehicle) + end + + -- Logged out in a vehicle + if( UnitHasVehicleUI(self.unitRealOwner) and UnitHasVehiclePlayerFrameUI(self.unitRealOwner) ) then + self:SetAttribute("unitIsVehicle", true) + end + + -- Hide any pet that became a vehicle, we detect this by the owner being untargetable but they have a pet out + stateMonitor:WrapScript(self, "OnAttributeChanged", [[ + if( name == "state-vehicleupdated" ) then + self:SetAttribute("unitIsVehicle", UnitHasVehicleUI(self:GetAttribute("unitRealOwner")) and value == "vehicle" and true or false) + elseif( name == "disablevehicleswap" or name == "state-unitexists" or name == "unitisvehicle" ) then + -- Unit does not exist, OR unit is a vehicle and vehicle swap is not disabled, hide frame + if( not self:GetAttribute("state-unitexists") or ( self:GetAttribute("unitIsVehicle") and not self:GetAttribute("disableVehicleSwap") ) ) then + self:Hide() + -- Unit exists, show it + else + self:Show() + end + end + ]]) + RegisterStateDriver(self, "vehicleupdated", string.format("[target=%s, nohelp, noharm] vehicle; pet", self.unitRealOwner, self.unit)) + -- Automatically do a full update on target change elseif( self.unit == "target" ) then self.isUnitVolatile = true @@ -418,6 +518,11 @@ OnAttributeChanged = function(self, name, unit) self:RegisterUnitEvent("UNIT_TARGETABLE_CHANGED", self, "FullUpdate") elseif( self.unit == "player" ) then + -- this should not get called in combat, but just in case make sure we are not actually in combat + if not InCombatLockdown() then + self:SetAttribute("toggleForVehicle", true) + end + -- Force a full update when the player is alive to prevent freezes when releasing in a zone that forces a ressurect (naxx/tk/etc) self:RegisterNormalEvent("PLAYER_ALIVE", self, "FullUpdate") @@ -491,6 +596,8 @@ local secureInitializeUnit = [[ self:SetWidth(header:GetAttribute("style-width")) self:SetScale(header:GetAttribute("style-scale")) + self:SetAttribute("toggleForVehicle", true) + self:SetAttribute("*type1", "target") self:SetAttribute("*type2", "togglemenu") self:SetAttribute("type2", "togglemenu") diff --git a/modules/xp.lua b/modules/xp.lua index f16c5071..207e4672 100755 --- a/modules/xp.lua +++ b/modules/xp.lua @@ -107,7 +107,7 @@ end function XP:UpdateXP(frame) -- At the level cap or XP is disabled, or the pet is actually a vehicle right now, swap to reputation bar (or hide it) - if( UnitLevel(frame.unitOwner) == MAX_PLAYER_LEVEL ) then + if( UnitLevel(frame.unitOwner) == MAX_PLAYER_LEVEL or ( frame.unitOwner == "pet" and UnitExists("vehicle") ) ) then frame.xpBar.xp:Hide() return end diff --git a/options/config.lua b/options/config.lua index 272dad69..ed49240e 100755 --- a/options/config.lua +++ b/options/config.lua @@ -2463,6 +2463,43 @@ local function loadUnitOptions() set = setUnit, get = getUnit, args = { + vehicle = { + order = 1, + type = "group", + inline = true, + name = L["Vehicles"], + hidden = function(info) return info[2] ~= "player" and info[2] ~= "party" or not ShadowUF.db.profile.advanced end, + args = { + disable = { + order = 0, + type = "toggle", + name = L["Disable vehicle swap"], + desc = L["Disables the unit frame from turning into a vehicle when the player enters one."], + set = function(info, value) + setUnit(info, value) + local unit = info[2] + if( unit == "player" ) then + if( ShadowUF.Units.unitFrames.pet ) then + ShadowUF.Units.unitFrames.pet:SetAttribute("disableVehicleSwap", ShadowUF.db.profile.units[unit].disableVehicle) + end + + if( ShadowUF.Units.unitFrames.player ) then + ShadowUF.Units:CheckVehicleStatus(ShadowUF.Units.unitFrames.player) + end + elseif( unit == "party" ) then + for frame in pairs(ShadowUF.Units.unitFrames) do + if( frame.unitType == "partypet" ) then + frame:SetAttribute("disableVehicleSwap", ShadowUF.db.profile.units[unit].disableVehicle) + elseif( frame.unitType == "party" ) then + ShadowUF.Units:CheckVehicleStatus(frame) + end + end + end + end, + arg = "disableVehicle", + }, + }, + }, portrait = { order = 2, type = "group", From c837dd5a2412b44da2fef84eb41eecd72def64c8 Mon Sep 17 00:00:00 2001 From: Casey Raethke Date: Mon, 10 Oct 2022 20:40:59 -0500 Subject: [PATCH 12/13] Add explicit target to vehicle combo point check --- modules/combopoints.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/combopoints.lua b/modules/combopoints.lua index f3f55f11..4ead8752 100755 --- a/modules/combopoints.lua +++ b/modules/combopoints.lua @@ -32,7 +32,7 @@ end function Combo:GetPoints(unit) -- For Malygos dragons, they also self cast their CP on themselves, which is why we check CP on ourself if( UnitHasVehicleUI("player") and UnitHasVehiclePlayerFrameUI("player") ) then - local points = GetComboPoints("vehicle") + local points = GetComboPoints("vehicle", "target") if( points == 0 ) then points = GetComboPoints("vehicle", "vehicle") end From 6786a685776dc1e4dc2c7137ccde1c320e5a86da Mon Sep 17 00:00:00 2001 From: Casey Raethke Date: Mon, 10 Oct 2022 21:19:02 -0500 Subject: [PATCH 13/13] Add WoWWrath version checks --- ShadowedUnitFrames.lua | 13 +++++++---- modules/combopoints.lua | 4 +++- modules/indicators.lua | 6 ++++- modules/tags.lua | 6 ++++- modules/totems.lua | 6 ++++- modules/units.lua | 52 ++++++++++++++++++++++------------------- options/config.lua | 6 +++-- 7 files changed, 59 insertions(+), 34 deletions(-) diff --git a/ShadowedUnitFrames.lua b/ShadowedUnitFrames.lua index 9535ed1a..fbe2e76f 100755 --- a/ShadowedUnitFrames.lua +++ b/ShadowedUnitFrames.lua @@ -5,6 +5,9 @@ ShadowUF = select(2, ...) local L = ShadowUF.L + +local WoWWrath = (WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC) + ShadowUF.dbRevision = 61 ShadowUF.dbRevisionClassic = 5 ShadowUF.playerUnit = "player" @@ -762,10 +765,12 @@ function ShadowUF:HideBlizzardFrames() -- We keep these in case someone is still using the default auras, otherwise it messes up vehicle stuff PlayerFrame:RegisterEvent("PLAYER_ENTERING_WORLD") - PlayerFrame:RegisterEvent("UNIT_ENTERING_VEHICLE") - PlayerFrame:RegisterEvent("UNIT_ENTERED_VEHICLE") - PlayerFrame:RegisterEvent("UNIT_EXITING_VEHICLE") - PlayerFrame:RegisterEvent("UNIT_EXITED_VEHICLE") + if WoWWrath then + PlayerFrame:RegisterEvent("UNIT_ENTERING_VEHICLE") + PlayerFrame:RegisterEvent("UNIT_ENTERED_VEHICLE") + PlayerFrame:RegisterEvent("UNIT_EXITING_VEHICLE") + PlayerFrame:RegisterEvent("UNIT_EXITED_VEHICLE") + end PlayerFrame:SetMovable(true) PlayerFrame:SetUserPlaced(true) PlayerFrame:SetDontSavePosition(true) diff --git a/modules/combopoints.lua b/modules/combopoints.lua index 4ead8752..0f64799d 100755 --- a/modules/combopoints.lua +++ b/modules/combopoints.lua @@ -1,5 +1,7 @@ if( not ShadowUF.ComboPoints ) then return end +local WoWWrath = (WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC) + local Combo = setmetatable({}, {__index = ShadowUF.ComboPoints}) ShadowUF:RegisterModule(Combo, "comboPoints", ShadowUF.L["Combo points"]) local cpConfig = {max = MAX_COMBO_POINTS, key = "comboPoints", colorKey = "COMBOPOINTS", powerType = Enum.PowerType.ComboPoints, eventType = "COMBO_POINTS", icon = "Interface\\AddOns\\ShadowedUnitFrames\\media\\textures\\combo"} @@ -31,7 +33,7 @@ end function Combo:GetPoints(unit) -- For Malygos dragons, they also self cast their CP on themselves, which is why we check CP on ourself - if( UnitHasVehicleUI("player") and UnitHasVehiclePlayerFrameUI("player") ) then + if( WoWWrath and UnitHasVehicleUI("player") and UnitHasVehiclePlayerFrameUI("player") ) then local points = GetComboPoints("vehicle", "target") if( points == 0 ) then points = GetComboPoints("vehicle", "vehicle") diff --git a/modules/indicators.lua b/modules/indicators.lua index 29a752a2..9fdf1251 100755 --- a/modules/indicators.lua +++ b/modules/indicators.lua @@ -1,5 +1,7 @@ local Indicators = {list = {"status", "pvp", "leader", "resurrect", "masterLoot", "raidTarget", "ready", "role", "class", "phase", "happiness" }} +local WoWWrath = (WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC) + ShadowUF:RegisterModule(Indicators, "indicators", ShadowUF.L["Indicators"]) function Indicators:UpdateClass(frame) @@ -265,7 +267,9 @@ function Indicators:OnEnable(frame) frame.indicators.parent = frame if( frame.unitType == "player" ) then - frame:RegisterUpdateFunc(self, "CheckVehicle") + if WoWWrath then + frame:RegisterUpdateFunc(self, "CheckVehicle") + end frame:RegisterNormalEvent("PLAYER_REGEN_ENABLED", self, "UpdateStatus") frame:RegisterNormalEvent("PLAYER_REGEN_DISABLED", self, "UpdateStatus") frame:RegisterNormalEvent("PLAYER_UPDATE_RESTING", self, "UpdateStatus") diff --git a/modules/tags.lua b/modules/tags.lua index 9213e988..794e4b40 100755 --- a/modules/tags.lua +++ b/modules/tags.lua @@ -4,6 +4,8 @@ local L = ShadowUF.L ShadowUF.Tags = Tags +local WoWWrath = (WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC) + -- Map the numeric index to the string local numerics = {} for id, color in pairs(PowerBarColor) do @@ -792,7 +794,7 @@ Tags.defaultTags = { return ShadowUF.L["Offline"] end end]], - ["cpoints"] = [[function(unit, unitOwner) + ["cpoints"] = WoWWrath and [[function(unit, unitOwner) if( UnitHasVehicleUI("player") and UnitHasVehiclePlayerFrameUI("player") ) then local points = GetComboPoints("vehicle") if( points == 0 ) then @@ -803,6 +805,8 @@ Tags.defaultTags = { else return UnitPower("player", Enum.PowerType.ComboPoints) end + end]] or [[function(unit, unitOwner) + return UnitPower("player", Enum.PowerType.ComboPoints) end]], ["smartlevel"] = [[function(unit, unitOwner) local classif = UnitClassification(unit) diff --git a/modules/totems.lua b/modules/totems.lua index 6c6f3420..7b0f265e 100755 --- a/modules/totems.lua +++ b/modules/totems.lua @@ -2,6 +2,8 @@ local Totems = {} local totemColors = {} local MAX_TOTEMS = MAX_TOTEMS +local WoWWrath = (WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC) + -- Death Knights untalented ghouls are guardians and are considered totems........... so set it up for them local playerClass = select(2, UnitClass("player")) ShadowUF:RegisterModule(Totems, "totemBar", ShadowUF.L["Totem bar"], true, "SHAMAN") @@ -44,7 +46,9 @@ function Totems:OnEnable(frame) end frame:RegisterNormalEvent("PLAYER_TOTEM_UPDATE", self, "Update") - frame:RegisterUpdateFunc(self, "UpdateVisibility") + if WoWWrath then + frame:RegisterUpdateFunc(self, "UpdateVisibility") + end frame:RegisterUpdateFunc(self, "Update") end diff --git a/modules/units.lua b/modules/units.lua index bff9ce8f..0132c40c 100755 --- a/modules/units.lua +++ b/modules/units.lua @@ -11,6 +11,8 @@ local unitFrames, headerFrames, frameList, unitEvents, childUnits, headerUnits, local remappedUnits = Units.remappedUnits local _G = getfenv(0) +local WoWWrath = (WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC) + ShadowUF.Units = Units ShadowUF:RegisterModule(Units, "units") @@ -463,7 +465,7 @@ OnAttributeChanged = function(self, name, unit) end -- Handles switching the internal unit variable to that of their vehicle - if( self.unit == "player" or self.unitRealType == "party" or self.unitRealType == "raid" ) then + if( WoWWrath and self.unit == "player" or self.unitRealType == "party" or self.unitRealType == "raid" ) then self:RegisterNormalEvent("UNIT_ENTERED_VEHICLE", Units, "CheckVehicleStatus") self:RegisterNormalEvent("UNIT_EXITED_VEHICLE", Units, "CheckVehicleStatus") self:RegisterUpdateFunc(Units, "CheckVehicleStatus") @@ -478,32 +480,34 @@ OnAttributeChanged = function(self, name, unit) self:SetAttribute("unitRealOwner", self.unitRealOwner) self:RegisterNormalEvent("UNIT_PET", Units, "CheckPetUnitUpdated") - if( self.unit == "pet" ) then - self:SetAttribute("disableVehicleSwap", ShadowUF.db.profile.units.player.disableVehicle) - else - self:SetAttribute("disableVehicleSwap", ShadowUF.db.profile.units.party.disableVehicle) - end + if WoWWrath then + if( self.unit == "pet" ) then + self:SetAttribute("disableVehicleSwap", ShadowUF.db.profile.units.player.disableVehicle) + else + self:SetAttribute("disableVehicleSwap", ShadowUF.db.profile.units.party.disableVehicle) + end - -- Logged out in a vehicle - if( UnitHasVehicleUI(self.unitRealOwner) and UnitHasVehiclePlayerFrameUI(self.unitRealOwner) ) then - self:SetAttribute("unitIsVehicle", true) - end + -- Logged out in a vehicle + if( UnitHasVehicleUI(self.unitRealOwner) and UnitHasVehiclePlayerFrameUI(self.unitRealOwner) ) then + self:SetAttribute("unitIsVehicle", true) + end - -- Hide any pet that became a vehicle, we detect this by the owner being untargetable but they have a pet out - stateMonitor:WrapScript(self, "OnAttributeChanged", [[ - if( name == "state-vehicleupdated" ) then - self:SetAttribute("unitIsVehicle", UnitHasVehicleUI(self:GetAttribute("unitRealOwner")) and value == "vehicle" and true or false) - elseif( name == "disablevehicleswap" or name == "state-unitexists" or name == "unitisvehicle" ) then - -- Unit does not exist, OR unit is a vehicle and vehicle swap is not disabled, hide frame - if( not self:GetAttribute("state-unitexists") or ( self:GetAttribute("unitIsVehicle") and not self:GetAttribute("disableVehicleSwap") ) ) then - self:Hide() - -- Unit exists, show it - else - self:Show() + -- Hide any pet that became a vehicle, we detect this by the owner being untargetable but they have a pet out + stateMonitor:WrapScript(self, "OnAttributeChanged", [[ + if( name == "state-vehicleupdated" ) then + self:SetAttribute("unitIsVehicle", UnitHasVehicleUI(self:GetAttribute("unitRealOwner")) and value == "vehicle" and true or false) + elseif( name == "disablevehicleswap" or name == "state-unitexists" or name == "unitisvehicle" ) then + -- Unit does not exist, OR unit is a vehicle and vehicle swap is not disabled, hide frame + if( not self:GetAttribute("state-unitexists") or ( self:GetAttribute("unitIsVehicle") and not self:GetAttribute("disableVehicleSwap") ) ) then + self:Hide() + -- Unit exists, show it + else + self:Show() + end end - end - ]]) - RegisterStateDriver(self, "vehicleupdated", string.format("[target=%s, nohelp, noharm] vehicle; pet", self.unitRealOwner, self.unit)) + ]]) + RegisterStateDriver(self, "vehicleupdated", string.format("[target=%s, nohelp, noharm] vehicle; pet", self.unitRealOwner, self.unit)) + end -- Automatically do a full update on target change elseif( self.unit == "target" ) then diff --git a/options/config.lua b/options/config.lua index ed49240e..2b1bd95d 100755 --- a/options/config.lua +++ b/options/config.lua @@ -4,6 +4,8 @@ local playerClass = select(2, UnitClass("player")) local modifyUnits, globalConfig = {}, {} local L = ShadowUF.L +local WoWWrath = (WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC) + ShadowUF.Config = Config --[[ @@ -2463,7 +2465,7 @@ local function loadUnitOptions() set = setUnit, get = getUnit, args = { - vehicle = { + vehicle = WoWWrath and { order = 1, type = "group", inline = true, @@ -2499,7 +2501,7 @@ local function loadUnitOptions() arg = "disableVehicle", }, }, - }, + } or nil, portrait = { order = 2, type = "group",