Mercurial > wow > kbf
comparison KBF.lua @ 45:ca720b4b5435
fix location not being stored, add a framework for doing stuff when OOC
author | Chris Mellon <arkanes@gmail.com> |
---|---|
date | Sat, 19 Feb 2011 07:23:26 -0600 |
parents | 81cade22f2f9 |
children | 04d0d145a676 |
comparison
equal
deleted
inserted
replaced
44:81cade22f2f9 | 45:ca720b4b5435 |
---|---|
4 | 4 |
5 local kbf = LibStub("AceAddon-3.0"):NewAddon(kbf, "KBF", "AceEvent-3.0", "AceConsole-3.0") | 5 local kbf = LibStub("AceAddon-3.0"):NewAddon(kbf, "KBF", "AceEvent-3.0", "AceConsole-3.0") |
6 | 6 |
7 | 7 |
8 function kbf:OnInitialize() | 8 function kbf:OnInitialize() |
9 -- create frames here so that they will be correctly stored in location cache by | |
10 -- the UI. | |
11 self.anchor, self.secureHeader, self.consolidateHeader, self.consolidateProxy = self:CreateCoreFrames() | |
9 self.debuffFrames = {} | 12 self.debuffFrames = {} |
10 local defaultSettings = { | 13 local defaultSettings = { |
11 -- global bar settings | 14 -- global bar settings |
12 -- overrides for buffs | 15 -- overrides for buffs |
13 -- overrides for debuffs | 16 -- overrides for debuffs |
14 } | 17 } |
15 self:RegisterEvent("UNIT_AURA") | 18 self:RegisterEvent("UNIT_AURA") |
16 self:RegisterEvent("UNIT_ENTERING_VEHICLE", "PollForVehicleChange") | 19 self:RegisterEvent("UNIT_ENTERING_VEHICLE", "PollForVehicleChange") |
17 self:RegisterEvent("UNIT_EXITING_VEHICLE", "PollForVehicleChange") | 20 self:RegisterEvent("UNIT_EXITING_VEHICLE", "PollForVehicleChange") |
18 self:RegisterChatCommand("kbf", "ToggleAnchor") | 21 self:RegisterChatCommand("kbf", "ToggleAnchor") |
22 | |
23 self.oocQueue = {} | |
19 end | 24 end |
20 | 25 |
21 function kbf:OnEnable() | 26 function kbf:OnEnable() |
22 self.anchor, self.secureHeader, self.consolidateHeader, self.consolidateProxy = self:CreateCoreFrames() | |
23 -- set up the countdown timer | 27 -- set up the countdown timer |
24 -- TODO: Fancy enable/disable based on whether you have any timed buffs. | 28 -- TODO: Fancy enable/disable based on whether you have any timed buffs. |
25 -- Not a big deal, how often do you care about that | 29 -- Not a big deal, how often do you care about that |
26 -- also TODO: Maybe should bucket OnUpdates somehow | 30 -- also TODO: Maybe should bucket OnUpdates somehow |
27 -- AceTimer repeating events can only happen at 0.1 seconds, which is probably | 31 -- AceTimer repeating events can only happen at 0.1 seconds, which is probably |
57 end | 61 end |
58 HideBlizFrame(BuffFrame) | 62 HideBlizFrame(BuffFrame) |
59 HideBlizFrame(ConsolidatedBuffs) | 63 HideBlizFrame(ConsolidatedBuffs) |
60 HideBlizFrame(TemporaryEnchantFrame) | 64 HideBlizFrame(TemporaryEnchantFrame) |
61 | 65 |
66 end | |
67 | |
68 -- enqueues a callable that will be run once in-combat lockdown is past | |
69 -- all callables will be executed in a single run, in the order they were enqueued | |
70 -- if called when OOC, the function will be called immediately, unless the alwaysQueue parameter is true, | |
71 -- in which case it will be appended normally | |
72 function kbf:QueueForOOC(func, alwaysQueue) | |
73 if InCombatLockDown() or alwaysQueue then | |
74 tinsert(self.oocQueue, func) | |
75 else | |
76 func() | |
77 end | |
62 end | 78 end |
63 | 79 |
64 function kbf:OnUpdate() | 80 function kbf:OnUpdate() |
65 if self.pollForUnitChange and not InCombatLockdown() then | 81 if self.pollForUnitChange and not InCombatLockdown() then |
66 if UnitHasVehicleUI("player") then | 82 if UnitHasVehicleUI("player") then |
73 else | 89 else |
74 self.secureHeader:SetAttribute("unit", "player") | 90 self.secureHeader:SetAttribute("unit", "player") |
75 end | 91 end |
76 self.pollForUnitChange = nil | 92 self.pollForUnitChange = nil |
77 end | 93 end |
94 | |
95 while #self.oocQueue > 0 do | |
96 func = table.remove(self.oocQueue) | |
97 func() | |
98 end | |
99 | |
78 local unit = self.secureHeader:GetAttribute("unit") | 100 local unit = self.secureHeader:GetAttribute("unit") |
79 local buffCount = 0 | 101 local buffCount = 0 |
80 for idx=1,99 do | 102 for idx=1,99 do |
81 local frame = self.secureHeader:GetAttribute("child"..idx) | 103 local frame = self.secureHeader:GetAttribute("child"..idx) |
82 if not (frame and frame:IsShown()) then break end | 104 if not (frame and frame:IsShown()) then break end |
84 if self.dirty then | 106 if self.dirty then |
85 if self:BindBarToBuff(frame, unit) then break end | 107 if self:BindBarToBuff(frame, unit) then break end |
86 end | 108 end |
87 self:UpdateBarExpirationTime(frame) | 109 self:UpdateBarExpirationTime(frame) |
88 -- Don't forget to refresh shown tooltips | 110 -- Don't forget to refresh shown tooltips |
89 if ( GameTooltip:IsOwned(frame) ) then | 111 if (GameTooltip:IsOwned(frame)) then |
90 self:OnEnter(frame) | 112 self:OnEnter(frame) |
91 end | 113 end |
92 end | 114 end |
93 | 115 |
94 -- consolidated buffs | 116 -- consolidated buffs |
125 self:UpdateBarExpirationTime(tempEnchant) | 147 self:UpdateBarExpirationTime(tempEnchant) |
126 buffCount = buffCount + 1 | 148 buffCount = buffCount + 1 |
127 -- SAH binds the offhand enchant to the main hand for removal purposes. | 149 -- SAH binds the offhand enchant to the main hand for removal purposes. |
128 -- fix it up if we're out of combat | 150 -- fix it up if we're out of combat |
129 -- TODO: maybe this should only happen if we're dirty | 151 -- TODO: maybe this should only happen if we're dirty |
130 if not InCombatLockdown() then | 152 QueueForOOC(function() tempEnchant:SetAttribute('target-slot', 17) end) |
131 tempEnchant:SetAttribute('target-slot', 17) | |
132 end | |
133 end | 153 end |
134 if ( tempEnchant and GameTooltip:IsOwned(tempEnchant) ) then | 154 if ( tempEnchant and GameTooltip:IsOwned(tempEnchant) ) then |
135 self:OnEnter(tempEnchant) | 155 self:OnEnter(tempEnchant) |
136 end | 156 end |
137 -- make a fake third buff bar. It can't be used to cancel the buff, but | 157 -- make a fake third buff bar. It can't be used to cancel the buff, but |
146 self.tempEnchant3:Show() | 166 self.tempEnchant3:Show() |
147 self.tempEnchant3:SetScript("OnEnter", function() kbf:OnEnter(self.tempEnchant3) end) | 167 self.tempEnchant3:SetScript("OnEnter", function() kbf:OnEnter(self.tempEnchant3) end) |
148 self.tempEnchant3:SetScript("OnLeave", function() GameTooltip:Hide() end) | 168 self.tempEnchant3:SetScript("OnLeave", function() GameTooltip:Hide() end) |
149 self.tempEnchant3:EnableMouse(true) | 169 self.tempEnchant3:EnableMouse(true) |
150 --TODO: queue up for setting when leaving combat | 170 --TODO: queue up for setting when leaving combat |
151 self.tempEnchant3:SetAttribute('target-slot', 18) | 171 QueueForOOC(function() self.tempEnchant3:SetAttribute('target-slot', 18) end) |
152 -- set up the tooltip | 172 -- set up the tooltip |
153 end | 173 end |
154 -- TODO: If we're out of combat and theres an OH enchant, | 174 -- TODO: If we're out of combat and theres an OH enchant, |
155 -- create a secure action button & position it relative | 175 -- create a secure action button & position it relative |
156 -- to that. What happens when the OH weapon enchant frame | 176 -- to that. What happens when the OH weapon enchant frame |