# HG changeset patch # User Chris Mellon # Date 1292252513 21600 # Node ID 9967caf18b2aac2e21e35c21bc6f4fdbb2bf8616 # Parent 547b70e235fe79d56f48592474684a03f08189af updates to how vehicle swapping is handled diff -r 547b70e235fe -r 9967caf18b2a KBF.lua --- a/KBF.lua Tue Nov 16 07:09:20 2010 -0600 +++ b/KBF.lua Mon Dec 13 09:01:53 2010 -0600 @@ -9,14 +9,15 @@ self.debuffFrames = {} self.anchor = self:CreateAnchorFrame() self:RegisterEvent("UNIT_AURA") - self:RegisterEvent("UNIT_ENTERING_VEHICLE") - self:RegisterEvent("UNIT_EXITING_VEHICLE") + self:RegisterEvent("UNIT_ENTERING_VEHICLE", "PollForVehicleChange") + self:RegisterEvent("UNIT_EXITING_VEHICLE", "PollForVehicleChange") -- set up the countdown timer -- TODO: Fancy enable/disable based on whether you have any timed buffs. -- Not a big deal, how often do you care about that -- also TODO: Maybe should bucket OnUpdates somehow -- AceTimer repeating events can only happen at 0.1 seconds, which is probably -- fast enough for updating, but makes the animation look jerky + -- need to experiment with using animation groups self.update = CreateFrame("FRAME") self.update:SetScript("OnUpdate", function() self:OnUpdate() end) self.dirty = true -- force an immediate scan on login @@ -29,27 +30,13 @@ -- a "bar" is a frame that has the icon, status bar, ect associated with it -- Secure aura header doesn't self-bind to vehicle, --- so this probably only works out of combat. But thats better than nothing... -function kbf:UNIT_ENTERING_VEHICLE(event, unit) +-- so this only works out of combat. But thats better than nothing... +function kbf:PollForVehicleChange(event, unit) if unit ~= "player" then return end self.dirty = true -- hax until SAH supports vehicles - do the swap after we come out of combat - if not InCombatLockdown() then - self.secureFrame:SetAttribute("unit", "vehicle") - else - self.pollForUnitChange = true - end -end - -function kbf:UNIT_EXITING_VEHICLE(event, unit) - if unit ~= "player" then return end - self.dirty = true - -- hax until SAH supports vehicles - do the swap after we come out of combat - if not InCombatLockdown() then - self.secureFrame:SetAttribute("unit", "player") - else - self.pollForUnitChange = true - end + -- always poll instead of insta-swapping OOC in order to simplify the UnitHasVehicleUI logic + self.pollForUnitChange = true end function kbf:HideBlizzardBuffFrames() @@ -69,6 +56,11 @@ function kbf:OnUpdate() if self.pollForUnitChange and not InCombatLockdown() then if UnitHasVehicleUI("player") then + -- only swap if we're in a "real" vehicle with its own actions + -- There is possibly a timing issue here where + -- we have set the poll flag but the unit is not + -- actually "in" the vehicle yet. I'm hoping thats + -- handled by using exited/entered events instead of exiting/entering self.secureFrame:SetAttribute("unit", "vehicle") else self.secureFrame:SetAttribute("unit", "player")