Skip to content

Commit 0a24577

Browse files
committed
Add vehicles back for Wrath
Code taken from Nevcairiel#25
1 parent 2f67753 commit 0a24577

14 files changed

Lines changed: 245 additions & 14 deletions

ShadowedUnitFrames.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
ShadowUF = select(2, ...)
66

77
local L = ShadowUF.L
8+
9+
local WoWWrath = (WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC)
10+
811
ShadowUF.dbRevision = 61
912
ShadowUF.dbRevisionClassic = 5
1013
ShadowUF.playerUnit = "player"
@@ -13,7 +16,7 @@ ShadowUF.modules = {}
1316
ShadowUF.moduleOrder = {}
1417
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"}
1518
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}
16-
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"]}
19+
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"]}
1720
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"]}
1821

1922
-- Cache the units so we don't have to concat every time it updates
@@ -678,6 +681,12 @@ function ShadowUF:HideBlizzardFrames()
678681

679682
-- We keep these in case someone is still using the default auras, otherwise it messes up vehicle stuff
680683
PlayerFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
684+
if WoWWrath then
685+
PlayerFrame:RegisterEvent("UNIT_ENTERING_VEHICLE")
686+
PlayerFrame:RegisterEvent("UNIT_ENTERED_VEHICLE")
687+
PlayerFrame:RegisterEvent("UNIT_EXITING_VEHICLE")
688+
PlayerFrame:RegisterEvent("UNIT_EXITED_VEHICLE")
689+
end
681690
PlayerFrame:SetMovable(true)
682691
PlayerFrame:SetUserPlaced(true)
683692
PlayerFrame:SetDontSavePosition(true)

ShadowedUnitFrames.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<Ui xmlns="http://www.blizzard.com/wow/ui/">
22
<Button name="SUF_SecureUnitTemplate" virtual="true" inherits="SecureUnitButtonTemplate, SecureHandlerStateTemplate">
3+
<Attributes>
4+
<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" />
5+
<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" />
6+
</Attributes>
37
</Button>
48
</Ui>

modules/auraindicators.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Indicators.auraConfig = setmetatable({}, {
2323
return tbl[index]
2424
end})
2525

26-
local playerUnits = {player = true, pet = true}
26+
local playerUnits = {player = true, vehicle = true, pet = true}
2727
local backdropTbl = {bgFile = "Interface\\Addons\\ShadowedUnitFrames\\mediabackdrop", edgeFile = "Interface\\Addons\\ShadowedUnitFrames\\media\\backdrop", tile = true, tileSize = 1, edgeSize = 1}
2828

2929
function Indicators:OnEnable(frame)

modules/auras.lua

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local Auras = {}
2-
local playerUnits = {player = true, pet = true}
2+
local playerUnits = {player = true, vehicle = true, pet = true}
33
local mainHand, offHand, tempEnchantScan = {time = 0}, {time = 0}
44
local canCure = ShadowUF.Units.canCure
55
ShadowUF:RegisterModule(Auras, "auras", ShadowUF.L["Auras"])
@@ -236,7 +236,11 @@ local function hideTooltip(self)
236236
end
237237

238238
local function cancelAura(self, mouse)
239-
if( mouse ~= "RightButton" or not UnitIsUnit(self.parent.unit, "player") or InCombatLockdown() or self.filter == "TEMP" ) then
239+
if(
240+
mouse ~= "RightButton"
241+
or ( not UnitIsUnit(self.parent.unit, "player") and not UnitIsUnit(self.parent.unit, "vehicle") )
242+
or InCombatLockdown() or self.filter == "TEMP"
243+
) then
240244
return
241245
end
242246

@@ -477,6 +481,17 @@ end
477481

478482
-- Unfortunately, temporary enchants have basically no support beyond hacks. So we will hack!
479483
tempEnchantScan = function(self, elapsed)
484+
if( self.parent.unit == self.parent.vehicleUnit and self.lastTemporary > 0 ) then
485+
mainHand.has = false
486+
offHand.has = false
487+
488+
self.temporaryEnchants = 0
489+
self.lastTemporary = 0
490+
491+
Auras:Update(self.parent)
492+
return
493+
end
494+
480495
timeElapsed = timeElapsed + elapsed
481496
if( timeElapsed < 0.50 ) then return end
482497
timeElapsed = timeElapsed - 0.50

modules/combopoints.lua

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
if( not ShadowUF.ComboPoints ) then return end
22

3+
local WoWWrath = (WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC)
4+
35
local Combo = setmetatable({}, {__index = ShadowUF.ComboPoints})
46
ShadowUF:RegisterModule(Combo, "comboPoints", ShadowUF.L["Combo points"])
57
local cpConfig = {max = MAX_COMBO_POINTS, key = "comboPoints", colorKey = "COMBOPOINTS", powerType = Enum.PowerType.ComboPoints, eventType = "COMBO_POINTS", icon = "Interface\\AddOns\\ShadowedUnitFrames\\media\\textures\\combo"}
@@ -30,11 +32,21 @@ function Combo:GetMaxPoints()
3032
end
3133

3234
function Combo:GetPoints(unit)
33-
return UnitPower("player", cpConfig.powerType)
35+
-- For Malygos dragons, they also self cast their CP on themselves, which is why we check CP on ourself
36+
if( WoWWrath and UnitHasVehicleUI("player") and UnitHasVehiclePlayerFrameUI("player") ) then
37+
local points = GetComboPoints("vehicle", "target")
38+
if( points == 0 ) then
39+
points = GetComboPoints("vehicle", "vehicle")
40+
end
41+
42+
return points
43+
else
44+
return UnitPower("player", cpConfig.powerType)
45+
end
3446
end
3547

3648
function Combo:Update(frame, event, unit, powerType)
37-
if( not event or ( unit == frame.unit or unit == "player" ) ) then
49+
if( not event or ( unit == frame.unit or unit == frame.vehicleUnit or unit == "player" or unit == "vehicle" ) ) then
3850
ShadowUF.ComboPoints.Update(self, frame, event, unit, powerType)
3951
end
4052
end

modules/defaultlayout.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ function ShadowUF:LoadDefaultLayout(useMerge)
138138
MONK = {r = 0.0, g = 1.00 , b = 0.59},
139139
DEMONHUNTER = {r = 0.64, g = 0.19, b = 0.79},
140140
PET = {r = 0.20, g = 0.90, b = 0.20},
141+
VEHICLE = {r = 0.23, g = 0.41, b = 0.23},
141142
}
142143
config.powerColors = {
143144
MANA = {r = 0.30, g = 0.50, b = 0.85},

modules/druid.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function Druid:OnLayoutApplied(frame)
2222
end
2323

2424
function Druid:PowerChanged(frame)
25-
local visible = UnitPowerType(frame.unit) ~= Enum.PowerType.Mana
25+
local visible = UnitPowerType(frame.unit) ~= Enum.PowerType.Mana and not frame.inVehicle
2626
local type = visible and "RegisterUnitEvent" or "UnregisterSingleEvent"
2727

2828
frame[type](frame, "UNIT_POWER_FREQUENT", self, "Update")

modules/health.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ function Health:UpdateColor(frame)
9191
return
9292
elseif( ShadowUF.db.profile.units[frame.unitType].healthBar.colorDispel and frame.healthBar.hasDebuff ) then
9393
color = DebuffTypeColor[frame.healthBar.hasDebuff]
94+
elseif( frame.inVehicle ) then
95+
color = ShadowUF.db.profile.classColors.VEHICLE
9496
elseif( not UnitPlayerControlled(unit) and UnitIsTapDenied(unit) and UnitCanAttack("player", unit) ) then
9597
color = ShadowUF.db.profile.healthColors.tapped
9698
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

modules/indicators.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
local Indicators = {list = {"status", "pvp", "leader", "resurrect", "masterLoot", "raidTarget", "ready", "role", "class", "phase", "happiness" }}
22

3+
local WoWWrath = (WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC)
4+
35
ShadowUF:RegisterModule(Indicators, "indicators", ShadowUF.L["Indicators"])
46

57
function Indicators:UpdateClass(frame)
@@ -131,6 +133,12 @@ local function combatMonitor(self, elapsed)
131133
end
132134
end
133135

136+
-- 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
137+
function Indicators:CheckVehicle(frame)
138+
frame.indicators.timeElapsed = 0
139+
frame.indicators:SetScript("OnUpdate", frame.inVehicle and combatMonitor or nil)
140+
end
141+
134142
function Indicators:UpdateStatus(frame)
135143
if( not frame.indicators.status or not frame.indicators.status.enabled ) then return end
136144

@@ -260,6 +268,9 @@ function Indicators:OnEnable(frame)
260268
frame.indicators.parent = frame
261269

262270
if( frame.unitType == "player" ) then
271+
if WoWWrath then
272+
frame:RegisterUpdateFunc(self, "CheckVehicle")
273+
end
263274
frame:RegisterNormalEvent("PLAYER_REGEN_ENABLED", self, "UpdateStatus")
264275
frame:RegisterNormalEvent("PLAYER_REGEN_DISABLED", self, "UpdateStatus")
265276
frame:RegisterNormalEvent("PLAYER_UPDATE_RESTING", self, "UpdateStatus")

modules/tags.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,17 @@ Tags.defaultTags = {
792792
return ShadowUF.L["Offline"]
793793
end
794794
end]],
795-
["cpoints"] = [[function(unit, unitOwner)
795+
["cpoints"] = WoWWrath and [[function(unit, unitOwner)
796+
if( UnitHasVehicleUI("player") and UnitHasVehiclePlayerFrameUI("player") ) then
797+
local points = GetComboPoints("vehicle")
798+
if( points == 0 ) then
799+
points = GetComboPoints("vehicle", "vehicle")
800+
end
801+
return points
802+
else
803+
return UnitPower("player", Enum.PowerType.ComboPoints)
804+
end
805+
end]] or [[function(unit, unitOwner)
796806
return UnitPower("player", Enum.PowerType.ComboPoints)
797807
end]],
798808
["smartlevel"] = [[function(unit, unitOwner)

0 commit comments

Comments
 (0)