Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vehicles back for Wrath #25

Open
wants to merge 6 commits into
base: classic
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ShadowedUnitFrames.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 6
ShadowUF.playerUnit = "player"
Expand Down Expand Up @@ -772,6 +775,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")
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)
Expand Down
4 changes: 4 additions & 0 deletions ShadowedUnitFrames.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Button name="SUF_SecureUnitTemplate" virtual="true" inherits="SecureUnitButtonTemplate, SecureHandlerStateTemplate">
<Attributes>
<Attribute name="refreshUnitChange" type="string" value="local unit = self:GetAttribute('unit'); if unit then RegisterStateDriver(self, 'vehicleui', ('[target=%s,unithasvehicleui]vehicle; no'):format(unit)) else UnregisterStateDriver(self, 'vehicleui') end" />
<Attribute name="_onstate-vehicleui" type="string" value="local unit = self:GetAttribute('unit'); if unit and newstate == 'vehicle' and UnitPlayerOrPetInRaid(unit) and not UnitTargetsVehicleInRaidUI(unit) then self:SetAttribute('toggleForVehicle', false) else self:SetAttribute('toggleForVehicle', true) end" />
</Attributes>
</Button>
</Ui>
2 changes: 1 addition & 1 deletion modules/auraindicators.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 13 additions & 2 deletions modules/auras.lua
Original file line number Diff line number Diff line change
@@ -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"])
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
16 changes: 14 additions & 2 deletions modules/combopoints.lua
Original file line number Diff line number Diff line change
@@ -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"}
Expand Down Expand Up @@ -30,11 +32,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( WoWWrath and UnitHasVehicleUI("player") and UnitHasVehiclePlayerFrameUI("player") ) then
local points = GetComboPoints("vehicle", "target")
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
2 changes: 1 addition & 1 deletion modules/druid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions modules/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions modules/indicators.lua
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -131,6 +133,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

Expand Down Expand Up @@ -260,6 +268,9 @@ function Indicators:OnEnable(frame)
frame.indicators.parent = frame

if( frame.unitType == "player" ) then
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")
Expand Down
15 changes: 14 additions & 1 deletion modules/tags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -792,7 +794,18 @@ 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
points = GetComboPoints("vehicle", "vehicle")
end

return points
else
return UnitPower("player", Enum.PowerType.ComboPoints)
end
end]] or [[function(unit, unitOwner)
return UnitPower("player", Enum.PowerType.ComboPoints)
end]],
["sshards"] = [[function(unit, unitOwner)
Expand Down
19 changes: 18 additions & 1 deletion modules/totems.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -44,6 +46,9 @@ function Totems:OnEnable(frame)
end

frame:RegisterNormalEvent("PLAYER_TOTEM_UPDATE", self, "Update")
if WoWWrath then
frame:RegisterUpdateFunc(self, "UpdateVisibility")
end
frame:RegisterUpdateFunc(self, "Update")
end

Expand Down Expand Up @@ -107,7 +112,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
Expand All @@ -117,6 +122,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
Expand Down
Loading