Skip to content

Commit

Permalink
Remove vehicle hack
Browse files Browse the repository at this point in the history
  • Loading branch information
Aviana committed Jan 18, 2023
1 parent 4d4a1c8 commit c9e1181
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 128 deletions.
139 changes: 12 additions & 127 deletions LunaUnitFrames.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- Luna Unit Frames 4.0 by Aviana

LUF = select(2, ...)
LUF.version = 4343
LUF.version = 4344

local L = LUF.L
local ACR = LibStub("AceConfigRegistry-3.0", true)
Expand Down Expand Up @@ -31,17 +31,11 @@ LUF.stateMonitor:WrapScript(LUF.stateMonitor, "OnAttributeChanged", [[
if name == "state-vehiclestatus" or name == "hidepetinvehicle" then
local hidepetinvehicle = self:GetAttribute("hidepetinvehicle")
local vehiclestatus = self:GetAttribute("state-vehiclestatus")
if vehiclestatus == "vehicle" then
if hidepetinvehicle then
self:GetFrameRef("petFrame"):SetAttribute("unit", "none")
self:GetFrameRef("petFrame"):Hide()
else
self:GetFrameRef("petFrame"):SetAttribute("unit", "player")
end
self:GetFrameRef("playerFrame"):SetAttribute("unit", "pet")
if vehiclestatus == "vehicle" and hidepetinvehicle then
self:GetFrameRef("petFrame"):SetAttribute("unit", "none")
self:GetFrameRef("petFrame"):Hide()
else
self:GetFrameRef("petFrame"):SetAttribute("unit", "pet")
self:GetFrameRef("playerFrame"):SetAttribute("unit", "player")
end
return
end
Expand Down Expand Up @@ -1457,7 +1451,7 @@ local initialConfigFunction = [[
self:SetScale(parent:GetAttribute("x-scale") or 1)
]]

local refreshUnitChangePartyPet = [[
local refreshUnitChange = [[
local unit = self:GetAttribute("unit")
if unit and not strmatch(unit, "pet") then
if unit == "player" then
Expand All @@ -1474,111 +1468,6 @@ local refreshUnitChangePartyPet = [[
end
]]

local refreshUnitChangeRaid = [[
local unit = self:GetAttribute("unit")
if unit == "player" or unit == "pet" then
RegisterStateDriver(self, 'vehicleui', '[@player' .. ',unithasvehicleui]vehicle; novehicle')
if UnitHasVehicleUI("player") then
self:SetAttribute("unit", "pet")
else
self:SetAttribute("unit", "player")
end
return
end
local grptype, id, petunit
if (unit) then
unit = gsub(unit,"pet","")
petunit = gsub(unit, "^(%a+)(%d+)$", "%1pet%2")
RegisterStateDriver(self, 'vehicleui', '[@' .. unit .. ',unithasvehicleui]vehicle; novehicle')
else
UnregisterStateDriver(self, 'vehicleui')
return
end
if UnitHasVehicleUI(unit) then
self:SetAttribute("unit", petunit)
else
self:SetAttribute("unit", unit)
end
]]

local onstatevehicleuiRaid = [[
local unit = self:GetAttribute("unit")
if not unit then return end
if unit == "player" or unit == "pet" then
if newstate == "vehicle" then
self:SetAttribute("unit", "pet")
else
self:SetAttribute("unit", "player")
end
return
end
unit = gsub(unit,"pet","")
local petunit = gsub(unit, "^(%a+)(%d+)$", "%1pet%2")
if newstate == "vehicle" then
self:SetAttribute("unit", petunit)
else
self:SetAttribute("unit", unit)
end
]]

local refreshUnitChangeRaidPet = [[
local unit = self:GetAttribute("unit")
if unit == "player" or unit == "pet" then
RegisterStateDriver(self, 'vehicleui', '[@player' .. ',unithasvehicleui]vehicle; novehicle')
if UnitHasVehicleUI("player") then
self:SetAttribute("unit", "player")
else
self:SetAttribute("unit", "pet")
end
return
end
local grptype, id, petunit
if (unit) then
unit = gsub(unit,"pet","")
petunit = gsub(unit, "^(%a+)(%d+)$", "%1pet%2")
RegisterStateDriver(self, 'vehicleui', '[@' .. unit .. ',unithasvehicleui]vehicle; novehicle')
else
UnregisterStateDriver(self, 'vehicleui')
return
end
if UnitHasVehicleUI(unit) then
self:SetAttribute("unit", unit)
else
self:SetAttribute("unit", petunit)
end
]]

local onstatevehicleuiRaidPet = [[
local unit = self:GetAttribute("unit")
if not unit then return end
if unit == "player" or unit == "pet" then
if newstate == "vehicle" then
self:SetAttribute("unit", "player")
else
self:SetAttribute("unit", "pet")
end
return
end
unit = gsub(unit,"pet","")
local petunit = gsub(unit, "^(%a+)(%d+)$", "%1pet%2")
if newstate == "vehicle" then
self:SetAttribute("unit", unit)
else
self:SetAttribute("unit", petunit)
end
]]

function LUF:SpawnUnits()
oUF:RegisterStyle("LunaUnitFrames", self.InitializeUnit)
oUF:RegisterInitCallback(function(frame) LUF.PlaceModules(frame) LUF.ApplySettings(frame) end)
Expand All @@ -1589,8 +1478,6 @@ function LUF:SpawnUnits()
for id=1,10 do
local data = config.positions[id]
self.frameIndex["raid"..id] = oUF:SpawnHeader("LUFHeaderraid"..id, nil, nil, "oUF-initialConfigFunction", format(initialConfigFunction, "raid"))
self.frameIndex["raid"..id]:SetAttribute("_initialAttribute-refreshUnitChange", refreshUnitChangeRaid)
self.frameIndex["raid"..id]:SetAttribute('_initialAttribute-_onstate-vehicleui', onstatevehicleuiRaid)
self.frameIndex["raid"..id]:Show() --Set Show() early to allow child spawning
self.frameIndex["raid"..id]:SetAttribute("oUF-headerType", unit)
end
Expand Down Expand Up @@ -1619,16 +1506,15 @@ function LUF:SpawnUnits()
local frame = oUF:Spawn(unit..i, "LUFHeader"..unit.."UnitButton"..i)
frame:SetParent(_G["LUFHeader"..unit])
end
elseif unit == "raidpet" then
self.frameIndex[unit] = oUF:SpawnHeader("LUFHeader"..unit, "SecureGroupPetHeaderTemplate", nil, "oUF-initialConfigFunction", format(initialConfigFunction, unit))
self.frameIndex[unit]:SetAttribute("_initialAttribute-refreshUnitChange", refreshUnitChangeRaidPet)
self.frameIndex[unit]:SetAttribute("_initialAttribute-_onstate-vehicleui", onstatevehicleuiRaidPet)
self.frameIndex[unit]:Show() --Set Show() early to allow child spawning
self.frameIndex[unit]:SetAttribute("oUF-headerType", unit)
else
self.frameIndex[unit] = oUF:SpawnHeader("LUFHeader"..unit, nil, nil, "oUF-initialConfigFunction", format(initialConfigFunction, unit))
local template

if unit == "raidpet" then
template = "SecureGroupPetHeaderTemplate"
end
self.frameIndex[unit] = oUF:SpawnHeader("LUFHeader"..unit, template, nil, "oUF-initialConfigFunction", format(initialConfigFunction, unit))
if unit == "partypet" then
self.frameIndex[unit]:SetAttribute("_initialAttribute-refreshUnitChange", refreshUnitChangePartyPet)
self.frameIndex[unit]:SetAttribute("_initialAttribute-refreshUnitChange", refreshUnitChange)
end
self.frameIndex[unit]:Show() --Set Show() early to allow child spawning
self.frameIndex[unit]:SetAttribute("oUF-headerType", unit)
Expand All @@ -1644,7 +1530,6 @@ function LUF:SpawnUnits()
frame:SetFrameStrata(self.db.profile.strata)
end
local config = self.db.profile.units
self.stateMonitor:SetFrameRef("playerFrame", self.frameIndex["player"])
self.stateMonitor:SetFrameRef("partyFrame", self.frameIndex["party"])
self.stateMonitor:SetFrameRef("partytargetFrame", self.frameIndex["partytarget"])
self.stateMonitor:SetFrameRef("partypetFrame", self.frameIndex["partypet"])
Expand Down
2 changes: 1 addition & 1 deletion LunaUnitFrames.toc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Title: Luna Unit Frames
## Notes:
## Author: Aviana
## Version: 4343
## Version: 4344
## SavedVariables: LunaUFDB
## OptionalDeps: Ace3, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, Clique
## X-License: WTFPL (http://www.wtfpl.net/about/)
Expand Down

0 comments on commit c9e1181

Please sign in to comment.