flickerstreak@7
|
1 -- main.lua
|
flickerstreak@1
|
2 --
|
flickerstreak@1
|
3 -- Top-level file for the ReAction Action Bar add-on
|
flickerstreak@1
|
4 --
|
flickerstreak@7
|
5 -- implemented in terms of the Ace 2 development framework library: http://www.wowace.com
|
flickerstreak@1
|
6 --
|
flickerstreak@1
|
7
|
flickerstreak@7
|
8 -- Ace Library local object initialization
|
flickerstreak@7
|
9 local L = AceLibrary("AceLocale-2.2"):new("ReAction")
|
flickerstreak@7
|
10 local dewdrop = AceLibrary("Dewdrop-2.0")
|
flickerstreak@7
|
11 local tablet = AceLibrary("Tablet-2.0")
|
flickerstreak@10
|
12 local ReBound = AceLibrary("ReBound-1.0")
|
flickerstreak@1
|
13
|
flickerstreak@7
|
14 -- private functions
|
flickerstreak@2
|
15 local function tcopy(t)
|
flickerstreak@2
|
16 local r = { }
|
flickerstreak@2
|
17 for k, v in pairs(t) do
|
flickerstreak@2
|
18 r[k] = (type(v) == "table" and tcopy(v) or v)
|
flickerstreak@2
|
19 end
|
flickerstreak@2
|
20 return r
|
flickerstreak@2
|
21 end
|
flickerstreak@2
|
22
|
flickerstreak@7
|
23 -- private constants
|
flickerstreak@7
|
24 local EMPTY_BAR_SLOT = -1
|
flickerstreak@7
|
25
|
flickerstreak@7
|
26 -- key binding label constants
|
flickerstreak@7
|
27 BINDING_HEADER_REACTION = L["ReAction"]
|
flickerstreak@7
|
28 BINDING_NAME_REACTION_TOGGLELOCK = L["Toggle ReAction Bar Lock"]
|
flickerstreak@10
|
29 BINDING_NAME_REACTION_TOGGLEKEYBIND = L["ReAction Keybinding Mode"]
|
flickerstreak@7
|
30
|
flickerstreak@10
|
31 -- UI panel strings
|
flickerstreak@10
|
32 REACTION_KEYBIND_TITLE = L["ReAction Keybinding"]
|
flickerstreak@10
|
33 REACTION_KEYBIND_SUBTITLE = L["Click Buttons to Set Keybindings"]
|
flickerstreak@10
|
34 REACTION_KEYBIND_DONE = L["Save"]
|
flickerstreak@10
|
35 REACTION_KEYBIND_REVERT = L["Revert"]
|
flickerstreak@7
|
36
|
flickerstreak@10
|
37
|
flickerstreak@10
|
38
|
flickerstreak@10
|
39 ------------------------------
|
flickerstreak@10
|
40 -- AceAddon setup
|
flickerstreak@10
|
41 ------------------------------
|
flickerstreak@7
|
42 local main = AceLibrary("AceAddon-2.0"):new(
|
flickerstreak@7
|
43 "AceConsole-2.0",
|
flickerstreak@7
|
44 "AceEvent-2.0",
|
flickerstreak@7
|
45 "AceDB-2.0",
|
flickerstreak@7
|
46 "FuBarPlugin-2.0"
|
flickerstreak@7
|
47 )
|
flickerstreak@1
|
48
|
flickerstreak@10
|
49 function main:OnInitialize()
|
flickerstreak@10
|
50 self:RegisterChatCommand( {L["/reaction"], L["/rxn"]}, ReActionConsoleOptions, "REACTION" )
|
flickerstreak@10
|
51 self:RegisterDB("ReActionDB","ReActionDBPC")
|
flickerstreak@10
|
52 self:RegisterDefaults("profile", ReAction_DefaultProfile)
|
flickerstreak@10
|
53 self:RegisterEvent("PLAYER_REGEN_DISABLED","CombatLockdown")
|
flickerstreak@10
|
54 self:RegisterEvent("PLAYER_ENTERING_WORLD","HideDefaultBars")
|
flickerstreak@10
|
55 self:DisableDefaultKeybindings()
|
flickerstreak@1
|
56
|
flickerstreak@10
|
57 -- initial non-persistent state
|
flickerstreak@10
|
58 self.locked = true
|
flickerstreak@10
|
59 self.bars = { }
|
flickerstreak@10
|
60 end
|
flickerstreak@7
|
61
|
flickerstreak@10
|
62 -- OnEnable is called at startup (startup = true, oldConfig = nil),
|
flickerstreak@10
|
63 -- and when the profile is changed (startup = false, oldConfig ~= nil )
|
flickerstreak@10
|
64 function main:OnEnable( startup, oldConfig )
|
flickerstreak@10
|
65 if self.db.profile.firstRunDone ~= true then
|
flickerstreak@10
|
66 self.db.profile.bars = tcopy(ReAction_DefaultBlizzardBars)
|
flickerstreak@10
|
67 end
|
flickerstreak@10
|
68 self:DestroyAllBars()
|
flickerstreak@10
|
69 self:SetupBars()
|
flickerstreak@10
|
70 self:UpgradeProfile()
|
flickerstreak@10
|
71 self:SetupKeybindings( oldConfig and oldConfig.bindings )
|
flickerstreak@10
|
72 if self.db.profile.firstRunDone ~= true then
|
flickerstreak@10
|
73 self:Unlock()
|
flickerstreak@10
|
74 end
|
flickerstreak@10
|
75 self.db.profile.firstRunDone = true
|
flickerstreak@10
|
76 end
|
flickerstreak@7
|
77
|
flickerstreak@10
|
78 function main:OnDisable()
|
flickerstreak@10
|
79 self:Lock()
|
flickerstreak@10
|
80 end
|
flickerstreak@10
|
81
|
flickerstreak@10
|
82 -- OnProfileEnable() is only called when switching profiles, NOT for the initial profile at load time.
|
flickerstreak@10
|
83 function main:OnProfileEnable( oldName, oldData )
|
flickerstreak@10
|
84 self:OnEnable(false, oldData)
|
flickerstreak@10
|
85 end
|
flickerstreak@10
|
86
|
flickerstreak@10
|
87 function main:UpgradeProfile()
|
flickerstreak@10
|
88 if self.db.profile.firstRunDone ~= true and #self.db.profile.bindings == 0 then
|
flickerstreak@10
|
89 for _, bar in pairs(self.bars) do
|
flickerstreak@10
|
90 for _, button in pairs(bar.buttons) do
|
flickerstreak@10
|
91 local key = ReBound:GetBinding(button:GetActionFrame(),"LeftButton")
|
flickerstreak@10
|
92 if key and #key > 0 and not self.db.profile.bindings[key] then
|
flickerstreak@10
|
93 self:REBOUND_BIND(key,button:GetActionFrame():GetName(),"LeftButton")
|
flickerstreak@10
|
94 end
|
flickerstreak@10
|
95 end
|
flickerstreak@10
|
96 end
|
flickerstreak@10
|
97 end
|
flickerstreak@10
|
98 end
|
flickerstreak@10
|
99
|
flickerstreak@10
|
100
|
flickerstreak@10
|
101
|
flickerstreak@10
|
102
|
flickerstreak@10
|
103 --------------------------------------------
|
flickerstreak@7
|
104 -- FuBar plugin setup
|
flickerstreak@10
|
105 -- Even if FuBar isn't installed, the plugin
|
flickerstreak@10
|
106 -- provides a nice minimap-button interface.
|
flickerstreak@10
|
107 ---------------------------------------------
|
flickerstreak@7
|
108 main.hasIcon = "Interface\\Icons\\INV_Qiraj_JewelEncased"
|
flickerstreak@7
|
109 main.hasNoColor = true
|
flickerstreak@7
|
110 main.hideMenuTitle = true
|
flickerstreak@7
|
111 main.defaultPosition = "LEFT"
|
flickerstreak@7
|
112 main.defaultMinimapPosition = 240 -- degrees
|
flickerstreak@7
|
113 main.OnMenuRequest = tcopy(ReActionGlobalMenuOptions) -- use a copy, or bar menus will have FuBar inserted items
|
flickerstreak@7
|
114 main.independentProfile = true
|
flickerstreak@7
|
115
|
flickerstreak@7
|
116 -- set the handler for the global bar menu options
|
flickerstreak@7
|
117 -- have to do this after tcopy() above, otherwise it will try to copy the handler object (bad idea)
|
flickerstreak@7
|
118 ReActionGlobalMenuOptions.handler = main
|
flickerstreak@7
|
119
|
flickerstreak@7
|
120 function main:OnTooltipUpdate()
|
flickerstreak@7
|
121 local c = tablet:AddCategory("columns", 2)
|
flickerstreak@7
|
122 c:AddLine("text", L["Bar lock"], "text2", self.locked and ("|cffff0000"..L["Locked"].."|r") or ("|cffffcc00"..L["Unlocked"].."|r"))
|
flickerstreak@7
|
123 c:AddLine("text", L["Button lock"], "text2", LOCK_ACTIONBAR == "1" and ("|cffcc0000"..L["Locked"].."|r") or ("|cff00cc00"..L["Unlocked"].."|r"))
|
flickerstreak@10
|
124 c:AddLine("text", L["Kebinding mode"], "text2", self:GetKeybindMode() and ("|cff33ff33"..L["On"].."|r") or ("|cffffcc00"..L["Off"].."|r"))
|
flickerstreak@7
|
125 tablet:SetHint(L["|cffffcc00Shift-Click for bar lock|n|cff33ff33Alt-Click|r for keybindings|nRight-click for menu"])
|
flickerstreak@7
|
126 end
|
flickerstreak@7
|
127
|
flickerstreak@7
|
128 function main:OnClick(button)
|
flickerstreak@7
|
129 if IsShiftKeyDown() then
|
flickerstreak@7
|
130 self:ToggleLocked()
|
flickerstreak@7
|
131 self:UpdateDisplay()
|
flickerstreak@7
|
132 elseif IsAltKeyDown() then
|
flickerstreak@10
|
133 self:ToggleKeybindMode()
|
flickerstreak@7
|
134 self:UpdateDisplay()
|
flickerstreak@7
|
135 end
|
flickerstreak@7
|
136 end
|
flickerstreak@7
|
137
|
flickerstreak@7
|
138
|
flickerstreak@10
|
139
|
flickerstreak@10
|
140
|
flickerstreak@10
|
141 ------------------------------
|
flickerstreak@10
|
142 -- Key binding functions
|
flickerstreak@10
|
143 ------------------------------
|
flickerstreak@10
|
144 function main:DisableDefaultKeybindings()
|
flickerstreak@10
|
145 -- change the labels on all actionbar keybindings in the default
|
flickerstreak@10
|
146 -- interface.
|
flickerstreak@10
|
147 local label = "|cff999999("..L["Use ReAction"]..")|r"
|
flickerstreak@10
|
148 for i = 1, 12 do
|
flickerstreak@10
|
149 setglobal("BINDING_NAME_ACTIONBUTTON"..i,label)
|
flickerstreak@10
|
150 for j = 1, 4 do
|
flickerstreak@10
|
151 setglobal("BINDING_NAME_MULTIACTIONBAR"..j.."BUTTON"..i,label)
|
flickerstreak@10
|
152 end
|
flickerstreak@10
|
153 end
|
flickerstreak@10
|
154 for i = 1, 6 do
|
flickerstreak@10
|
155 setglobal("BINDING_NAME_ACTIONPAGE"..i,label)
|
flickerstreak@10
|
156 end
|
flickerstreak@10
|
157 for i = 1, 10 do
|
flickerstreak@10
|
158 setglobal("BINDING_NAME_BONUSACTIONBUTTON"..i,label)
|
flickerstreak@10
|
159 setglobal("BINDING_NAME_SHAPESHIFTBUTTON"..i,label)
|
flickerstreak@10
|
160 end
|
flickerstreak@10
|
161 BINDING_HEADER_ACTIONBAR = "|cff999999"..L["Action Bar Functions Disabled"].."|r"
|
flickerstreak@10
|
162 BINDING_HEADER_MULTIACTIONBAR = "|cff999999"..L["Multi-Action Bar Functions Disabled"].."|r"
|
flickerstreak@10
|
163 BINDING_NAME_NEXTACTIONPAGE = label
|
flickerstreak@10
|
164 BINDING_NAME_PREVIOUSACTIONPAGE = label
|
flickerstreak@10
|
165 end
|
flickerstreak@10
|
166
|
flickerstreak@10
|
167 function main:SetupKeybindings( previous )
|
flickerstreak@10
|
168 if previous then
|
flickerstreak@10
|
169 self:UnregisterEvent("REBOUND_BIND")
|
flickerstreak@10
|
170 self:UnregisterEvent("REBOUND_UNBIND")
|
flickerstreak@10
|
171 for key, binding in pairs(previous) do
|
flickerstreak@10
|
172 ReBound:ClearBinding(key, getglobal(binding.target), binding.button, true)
|
flickerstreak@10
|
173 end
|
flickerstreak@10
|
174 end
|
flickerstreak@10
|
175 if self.db.profile.firstRunDone ~= true then
|
flickerstreak@10
|
176 self:StealKeyBindings()
|
flickerstreak@10
|
177 else
|
flickerstreak@10
|
178 for key, binding in pairs(self.db.profile.bindings) do
|
flickerstreak@10
|
179 ReBound:SetBinding(key, getglobal(binding.target), binding.button)
|
flickerstreak@10
|
180 end
|
flickerstreak@10
|
181 end
|
flickerstreak@10
|
182 SaveBindings(GetCurrentBindingSet())
|
flickerstreak@10
|
183 self:RegisterEvent("REBOUND_BIND")
|
flickerstreak@10
|
184 self:RegisterEvent("REBOUND_UNBIND")
|
flickerstreak@10
|
185 end
|
flickerstreak@10
|
186
|
flickerstreak@10
|
187 function main:StealKeyBindings()
|
flickerstreak@10
|
188 -- steal the keybindings of the main action bar and assign them to rebar 1, buttons 1-12
|
flickerstreak@10
|
189 for i = 1, 12 do
|
flickerstreak@10
|
190 local key = GetBindingKey("ACTIONBUTTON"..i)
|
flickerstreak@10
|
191 if key and #key > 0 then
|
flickerstreak@10
|
192 ReBound:ClearBinding(key,nil,nil,true) -- suppress notification printouts
|
flickerstreak@10
|
193 ReBound:SetBinding(key, self.bars[1].buttons[i]:GetActionFrame(), "LeftButton")
|
flickerstreak@10
|
194 end
|
flickerstreak@10
|
195 end
|
flickerstreak@10
|
196 SaveBindings(GetCurrentBindingSet())
|
flickerstreak@10
|
197 end
|
flickerstreak@10
|
198
|
flickerstreak@10
|
199 function main:REBOUND_BIND(key, target, button)
|
flickerstreak@10
|
200 if key and target then
|
flickerstreak@10
|
201 self.db.profile.bindings[key] = { target = target, button = button }
|
flickerstreak@10
|
202 end
|
flickerstreak@10
|
203 end
|
flickerstreak@10
|
204
|
flickerstreak@10
|
205 function main:REBOUND_UNBIND(key)
|
flickerstreak@10
|
206 if key then
|
flickerstreak@10
|
207 self.db.profile.bindings[key] = nil
|
flickerstreak@10
|
208 end
|
flickerstreak@10
|
209 end
|
flickerstreak@10
|
210
|
flickerstreak@10
|
211 function main:ToggleKeybindMode()
|
flickerstreak@10
|
212 self:SetKeybindMode(not self:GetKeybindMode())
|
flickerstreak@10
|
213 end
|
flickerstreak@10
|
214
|
flickerstreak@10
|
215 function main:GetKeybindMode()
|
flickerstreak@10
|
216 return self.keybindMode
|
flickerstreak@10
|
217 end
|
flickerstreak@10
|
218
|
flickerstreak@10
|
219 function main:SetKeybindMode(enabled)
|
flickerstreak@10
|
220 if not InCombatLockdown() then
|
flickerstreak@10
|
221 self.keybindMode = enabled
|
flickerstreak@10
|
222 for _, bar in pairs(self.bars) do
|
flickerstreak@10
|
223 for __, button in pairs(bar.buttons) do
|
flickerstreak@10
|
224 if button and button ~= EMPTY_BAR_SLOT then
|
flickerstreak@10
|
225 button:TempShow(enabled)
|
flickerstreak@10
|
226 end
|
flickerstreak@10
|
227 end
|
flickerstreak@10
|
228 end
|
flickerstreak@10
|
229 if enabled then
|
flickerstreak@10
|
230 ReBound:ShowAll()
|
flickerstreak@10
|
231 ReActionKeybindDialog:Show()
|
flickerstreak@10
|
232 else
|
flickerstreak@10
|
233 ReBound:HideAll()
|
flickerstreak@10
|
234 if ReActionKeybindDialog:IsShown() then
|
flickerstreak@10
|
235 ReActionKeybindDialog:Hide()
|
flickerstreak@10
|
236 end
|
flickerstreak@10
|
237 end
|
flickerstreak@10
|
238 else
|
flickerstreak@10
|
239 UIErrorsFrame:AddMessage(ERROR_NOT_IN_COMBAT)
|
flickerstreak@10
|
240 end
|
flickerstreak@10
|
241 end
|
flickerstreak@10
|
242
|
flickerstreak@10
|
243
|
flickerstreak@10
|
244
|
flickerstreak@10
|
245
|
flickerstreak@10
|
246 ----------------------------
|
flickerstreak@10
|
247 -- Bar lock/unlock functions
|
flickerstreak@10
|
248 ----------------------------
|
flickerstreak@10
|
249 function main:CombatLockdown()
|
flickerstreak@10
|
250 if not self:IsLocked() then
|
flickerstreak@10
|
251 self:Lock()
|
flickerstreak@10
|
252 UIErrorsFrame:AddMessage(L["ReAction bars locked when in combat"])
|
flickerstreak@10
|
253 end
|
flickerstreak@10
|
254 ReActionKeybindDialog:Hide()
|
flickerstreak@10
|
255 end
|
flickerstreak@10
|
256
|
flickerstreak@7
|
257 function main:SetLocked( lock )
|
flickerstreak@2
|
258 if lock ~= self.locked then
|
flickerstreak@2
|
259 if not lock and InCombatLockdown() then
|
flickerstreak@10
|
260 UIErrorsFrame:AddMessage(ERROR_NOT_IN_COMBAT)
|
flickerstreak@2
|
261 else
|
flickerstreak@2
|
262 self.locked = lock and true or false -- force data integrity
|
flickerstreak@2
|
263 for _, bar in pairs(self.bars) do
|
flickerstreak@7
|
264 if bar ~= EMPTY_BAR_SLOT then
|
flickerstreak@7
|
265 if self.locked then
|
flickerstreak@7
|
266 bar:HideControls()
|
flickerstreak@7
|
267 -- close any dewdrop menu owned by the bar
|
flickerstreak@7
|
268 if bar:GetControlFrame() == dewdrop:GetOpenedParent() then
|
flickerstreak@7
|
269 dewdrop:Close()
|
flickerstreak@7
|
270 end
|
flickerstreak@7
|
271 else
|
flickerstreak@7
|
272 bar:ShowControls()
|
flickerstreak@7
|
273 end
|
flickerstreak@7
|
274 end
|
flickerstreak@2
|
275 end
|
flickerstreak@2
|
276 end
|
flickerstreak@1
|
277 end
|
flickerstreak@1
|
278 end
|
flickerstreak@1
|
279
|
flickerstreak@7
|
280 function main:IsLocked()
|
flickerstreak@1
|
281 return self.locked
|
flickerstreak@1
|
282 end
|
flickerstreak@1
|
283
|
flickerstreak@7
|
284 function main:Lock()
|
flickerstreak@1
|
285 self:SetLocked(true)
|
flickerstreak@1
|
286 end
|
flickerstreak@1
|
287
|
flickerstreak@7
|
288 function main:Unlock()
|
flickerstreak@1
|
289 self:SetLocked(false)
|
flickerstreak@1
|
290 end
|
flickerstreak@1
|
291
|
flickerstreak@7
|
292 function main:ToggleLocked()
|
flickerstreak@7
|
293 main:SetLocked( not(self.locked) )
|
flickerstreak@1
|
294 end
|
flickerstreak@1
|
295
|
flickerstreak@1
|
296
|
flickerstreak@1
|
297
|
flickerstreak@10
|
298 --------------------------------------------------------
|
flickerstreak@10
|
299 -- Functions to hide the default Blizzard main bar parts
|
flickerstreak@10
|
300 --------------------------------------------------------
|
flickerstreak@7
|
301 function main:HideArt()
|
flickerstreak@1
|
302 if self.db.profile.hideArt then
|
flickerstreak@7
|
303 -- the pet bar is a child of MainMenuBar, and can't be hidden. Need to reparent it
|
flickerstreak@7
|
304 PetActionBarFrame:SetParent(UIParent)
|
flickerstreak@1
|
305 MainMenuBar:Hide() -- this also hides the bags, xp bar, lag meter, and micro menu buttons.
|
flickerstreak@7
|
306 -- these two are the pet bar background
|
flickerstreak@7
|
307 -- unfortunately UIParent_ManageFramePositions() shows and hides these too
|
flickerstreak@7
|
308 -- so they get reparented to MainMenuBar
|
flickerstreak@7
|
309 SlidingActionBarTexture0:SetParent(MainMenuBar)
|
flickerstreak@7
|
310 SlidingActionBarTexture1:SetParent(MainMenuBar)
|
flickerstreak@1
|
311 else
|
flickerstreak@7
|
312 SlidingActionBarTexture0:SetParent(PetActionBarFrame)
|
flickerstreak@7
|
313 SlidingActionBarTexture1:SetParent(PetActionBarFrame)
|
flickerstreak@1
|
314 MainMenuBar:Show()
|
flickerstreak@1
|
315 end
|
flickerstreak@1
|
316 end
|
flickerstreak@1
|
317
|
flickerstreak@7
|
318 function main:IsArtHidden()
|
flickerstreak@1
|
319 return self.db.profile.hideArt
|
flickerstreak@1
|
320 end
|
flickerstreak@1
|
321
|
flickerstreak@7
|
322 function main:SetHideArt( hide )
|
flickerstreak@2
|
323 if InCombatLockdown() then
|
flickerstreak@2
|
324 UIErrorsFrame:AddMessage(SPELL_FAILED_AFFECTING_COMBAT)
|
flickerstreak@2
|
325 else
|
flickerstreak@2
|
326 self.db.profile.hideArt = hide and true or false -- force data integrity
|
flickerstreak@2
|
327 self:HideArt()
|
flickerstreak@2
|
328 end
|
flickerstreak@1
|
329 end
|
flickerstreak@1
|
330
|
flickerstreak@7
|
331 function main:ToggleHideArt()
|
flickerstreak@1
|
332 self:SetHideArt( not self:IsArtHidden() )
|
flickerstreak@1
|
333 end
|
flickerstreak@1
|
334
|
flickerstreak@1
|
335 -- Hide default Blizzard bars
|
flickerstreak@1
|
336 local blizzDefaultBars = {
|
flickerstreak@1
|
337 ActionButton1,
|
flickerstreak@1
|
338 ActionButton2,
|
flickerstreak@1
|
339 ActionButton3,
|
flickerstreak@1
|
340 ActionButton4,
|
flickerstreak@1
|
341 ActionButton5,
|
flickerstreak@1
|
342 ActionButton6,
|
flickerstreak@1
|
343 ActionButton7,
|
flickerstreak@1
|
344 ActionButton8,
|
flickerstreak@1
|
345 ActionButton9,
|
flickerstreak@1
|
346 ActionButton10,
|
flickerstreak@1
|
347 ActionButton11,
|
flickerstreak@1
|
348 ActionButton12,
|
flickerstreak@7
|
349 PetActionButton1,
|
flickerstreak@7
|
350 PetActionButton2,
|
flickerstreak@7
|
351 PetActionButton3,
|
flickerstreak@7
|
352 PetActionButton4,
|
flickerstreak@7
|
353 PetActionButton5,
|
flickerstreak@7
|
354 PetActionButton6,
|
flickerstreak@7
|
355 PetActionButton7,
|
flickerstreak@7
|
356 PetActionButton8,
|
flickerstreak@7
|
357 PetActionButton9,
|
flickerstreak@7
|
358 PetActionButton10,
|
flickerstreak@7
|
359 -- NOT the PetActionBarFrame, though - we need that to auto-hide/show our pet action bars
|
flickerstreak@7
|
360 MainMenuBarPageNumber,
|
flickerstreak@7
|
361 ActionBarUpButton,
|
flickerstreak@7
|
362 ActionBarDownButton,
|
flickerstreak@1
|
363 BonusActionBarFrame,
|
flickerstreak@7
|
364 ShapeshiftBarFrame,
|
flickerstreak@1
|
365 MultiBarLeft,
|
flickerstreak@1
|
366 MultiBarRight,
|
flickerstreak@1
|
367 MultiBarBottomLeft,
|
flickerstreak@7
|
368 MultiBarBottomRight,
|
flickerstreak@1
|
369 }
|
flickerstreak@1
|
370
|
flickerstreak@7
|
371 local function disableUIOptions()
|
flickerstreak@7
|
372 -- disable the buttons to hide/show the blizzard multiaction bars
|
flickerstreak@7
|
373 -- see UIOptionsFrame.lua and .xml
|
flickerstreak@7
|
374 -- This is called every time the options panel is shown, after it is set up
|
flickerstreak@7
|
375 for _, idx in pairs( { 33, 34, 35, 36, 37, 40 } ) do
|
flickerstreak@7
|
376 local f = getglobal("UIOptionsFrameCheckButton"..idx)
|
flickerstreak@7
|
377 f.disabled = true
|
flickerstreak@7
|
378 OptionsFrame_DisableCheckBox(f)
|
flickerstreak@7
|
379 f:SetChecked(false)
|
flickerstreak@7
|
380 end
|
flickerstreak@7
|
381 end
|
flickerstreak@1
|
382
|
flickerstreak@7
|
383 function main:HideDefaultBars()
|
flickerstreak@7
|
384 for _, f in pairs(blizzDefaultBars) do
|
flickerstreak@7
|
385 f:Hide()
|
flickerstreak@7
|
386 f:ClearAllPoints()
|
flickerstreak@7
|
387 f:SetParent(ReAction.recycler)
|
flickerstreak@7
|
388 f:SetPoint("TOPLEFT")
|
flickerstreak@7
|
389 end
|
flickerstreak@7
|
390
|
flickerstreak@7
|
391 MainMenuBar:SetFrameStrata("LOW") -- otherwise it appears on top of bars, if it isn't hidden
|
flickerstreak@7
|
392 hooksecurefunc("UIOptionsFrame_Load",disableUIOptions)
|
flickerstreak@7
|
393 end
|
flickerstreak@7
|
394
|
flickerstreak@7
|
395
|
flickerstreak@10
|
396
|
flickerstreak@10
|
397
|
flickerstreak@10
|
398 ---------------------------------------
|
flickerstreak@10
|
399 -- Bar setup and manipulation functions
|
flickerstreak@10
|
400 ---------------------------------------
|
flickerstreak@7
|
401 -- Reset bars to blizzard defaults
|
flickerstreak@7
|
402 function main:ResetBars()
|
flickerstreak@2
|
403 if InCombatLockdown() then
|
flickerstreak@2
|
404 UIErrorsFrame:AddMessage(SPELL_FAILED_AFFECTING_COMBAT)
|
flickerstreak@2
|
405 else
|
flickerstreak@7
|
406 self:DestroyAllBars()
|
flickerstreak@7
|
407 self.db.profile.bars = tcopy(ReAction_DefaultBlizzardBars)
|
flickerstreak@2
|
408 self:SetupBars()
|
flickerstreak@2
|
409 end
|
flickerstreak@1
|
410 end
|
flickerstreak@1
|
411
|
flickerstreak@7
|
412 function main:DestroyAllBars()
|
flickerstreak@7
|
413 -- destroy any existing bars
|
flickerstreak@7
|
414 for id = 1, table.maxn(self.bars) do
|
flickerstreak@7
|
415 self:DestroyBar(id)
|
flickerstreak@7
|
416 end
|
flickerstreak@7
|
417 end
|
flickerstreak@7
|
418
|
flickerstreak@7
|
419 function main:SetupBars()
|
flickerstreak@1
|
420 -- hide the default Blizzard art, if configued
|
flickerstreak@1
|
421 self:HideArt()
|
flickerstreak@1
|
422
|
flickerstreak@1
|
423 -- set up the bars from the profile
|
flickerstreak@2
|
424 -- note the use of table.maxn rather than # or ipairs:
|
flickerstreak@2
|
425 -- our array of bars can in fact contain holes
|
flickerstreak@2
|
426 for id = 1, table.maxn(self.db.profile.bars) do
|
flickerstreak@2
|
427 local config = self.db.profile.bars[id]
|
flickerstreak@2
|
428 if config then
|
flickerstreak@7
|
429 self:CreateBar(config, id)
|
flickerstreak@2
|
430 end
|
flickerstreak@1
|
431 end
|
flickerstreak@1
|
432
|
flickerstreak@1
|
433 -- anchor the bars, have to do this in a second pass because
|
flickerstreak@1
|
434 -- they might be anchored to each other in a non-ordered way
|
flickerstreak@2
|
435 for _, bar in pairs(self.bars) do
|
flickerstreak@7
|
436 if bar ~= EMPTY_BAR_SLOT then
|
flickerstreak@7
|
437 bar:ApplyAnchor()
|
flickerstreak@2
|
438 end
|
flickerstreak@2
|
439 end
|
flickerstreak@1
|
440 end
|
flickerstreak@1
|
441
|
flickerstreak@7
|
442 function main:CreateBar( config, id )
|
flickerstreak@7
|
443 local bar = ReBar:new(config, id)
|
flickerstreak@7
|
444 local buttonType = ReAction:GetButtonType(config.btnConfig.subtype)
|
flickerstreak@1
|
445
|
flickerstreak@7
|
446 if buttonType then
|
flickerstreak@7
|
447 self.bars[id] = bar
|
flickerstreak@7
|
448 self.db.profile.bars[id] = config
|
flickerstreak@7
|
449
|
flickerstreak@7
|
450 -- initialize dewdrop menu
|
flickerstreak@7
|
451 local cf = bar:GetControlFrame()
|
flickerstreak@7
|
452 dewdrop:Register(cf,
|
flickerstreak@7
|
453 'children',
|
flickerstreak@7
|
454 function()
|
flickerstreak@7
|
455 dewdrop:FeedAceOptionsTable(ReActionGlobalMenuOptions)
|
flickerstreak@7
|
456 dewdrop:FeedAceOptionsTable(GenerateReActionBarOptions(bar,self))
|
flickerstreak@7
|
457 dewdrop:FeedAceOptionsTable(buttonType:GenerateOptionsTable(config.btnConfig, function() return bar:GetButtonList() end))
|
flickerstreak@7
|
458 end,
|
flickerstreak@7
|
459 'cursorX', true,
|
flickerstreak@7
|
460 'cursorY', true
|
flickerstreak@7
|
461 )
|
flickerstreak@7
|
462
|
flickerstreak@7
|
463 bar:GetControlFrame():SetScript("OnClick",
|
flickerstreak@7
|
464 function(btn)
|
flickerstreak@7
|
465 if btn == "RightButton" then
|
flickerstreak@7
|
466 dewdrop:Open(cf)
|
flickerstreak@7
|
467 end
|
flickerstreak@7
|
468 end
|
flickerstreak@7
|
469 )
|
flickerstreak@7
|
470
|
flickerstreak@7
|
471 if not self.locked then
|
flickerstreak@7
|
472 bar:ShowControls()
|
flickerstreak@7
|
473 end
|
flickerstreak@7
|
474 return bar
|
flickerstreak@7
|
475 else
|
flickerstreak@7
|
476 if bar then
|
flickerstreak@7
|
477 bar:Destroy()
|
flickerstreak@7
|
478 end
|
flickerstreak@7
|
479 error(L["Tried to create a button of unknown type"])
|
flickerstreak@7
|
480 end
|
flickerstreak@7
|
481 end
|
flickerstreak@7
|
482
|
flickerstreak@7
|
483 function main:DestroyBar( id )
|
flickerstreak@7
|
484 local bar = self.bars[id]
|
flickerstreak@7
|
485 if bar and bar ~= EMPTY_BAR_SLOT then
|
flickerstreak@7
|
486 local cf = bar:GetControlFrame()
|
flickerstreak@7
|
487 if cf == dewdrop:GetOpenedParent() then
|
flickerstreak@7
|
488 dewdrop:Close()
|
flickerstreak@7
|
489 dewdrop:Unregister(cf)
|
flickerstreak@7
|
490 end
|
flickerstreak@7
|
491 bar:Destroy()
|
flickerstreak@7
|
492 -- we can't do tremove because each bar ID is encoded into the
|
flickerstreak@7
|
493 -- frame names as they're created. Need a blank entry in the table.
|
flickerstreak@7
|
494 -- The nice thing is that table.insert in NewBar() will automatically
|
flickerstreak@7
|
495 -- find the lowest numbered nil slot.
|
flickerstreak@7
|
496 self.bars[id] = EMPTY_BAR_SLOT
|
flickerstreak@7
|
497 end
|
flickerstreak@7
|
498 end
|
flickerstreak@7
|
499
|
flickerstreak@10
|
500 --
|
flickerstreak@10
|
501 -- this function is a wrapper for CreateBar() which looks up the bar type
|
flickerstreak@10
|
502 -- and constructs a new configuration object of the right type.
|
flickerstreak@7
|
503 function main:NewBar( type )
|
flickerstreak@7
|
504 if InCombatLockdown() then
|
flickerstreak@7
|
505 UIErrorsFrame:AddMessage(SPELL_FAILED_AFFECTING_COMBAT)
|
flickerstreak@7
|
506 else
|
flickerstreak@7
|
507 local t = ReAction:GetButtonType(type)
|
flickerstreak@7
|
508 if t then
|
flickerstreak@7
|
509 local c = tcopy(ReAction_DefaultBarConfig["ReAction"][type])
|
flickerstreak@7
|
510 local id = nil
|
flickerstreak@7
|
511 for i = 1, table.maxn(self.bars) + 1 do -- there may be holes, so #self.bars won't work
|
flickerstreak@7
|
512 if self.bars[i] == nil or self.bars[i] == EMPTY_BAR_SLOT then
|
flickerstreak@7
|
513 id = i
|
flickerstreak@7
|
514 break
|
flickerstreak@7
|
515 end
|
flickerstreak@7
|
516 end
|
flickerstreak@7
|
517 local bar = self:CreateBar(c, id)
|
flickerstreak@7
|
518 bar:ApplyAnchor()
|
flickerstreak@7
|
519 self:Unlock()
|
flickerstreak@7
|
520 end
|
flickerstreak@7
|
521 end
|
flickerstreak@7
|
522 end
|
flickerstreak@7
|
523
|
flickerstreak@10
|
524 --
|
flickerstreak@10
|
525 -- This function is a wrapper for DestroyBar() which does in-combat
|
flickerstreak@10
|
526 -- checking and updates the config.
|
flickerstreak@7
|
527 function main:DeleteBar(id)
|
flickerstreak@2
|
528 if InCombatLockdown() then
|
flickerstreak@2
|
529 UIErrorsFrame:AddMessage(SPELL_FAILED_AFFECTING_COMBAT)
|
flickerstreak@2
|
530 else
|
flickerstreak@2
|
531 if self.bars[id] then
|
flickerstreak@7
|
532 self:DestroyBar(id)
|
flickerstreak@2
|
533 self.db.profile.bars[id] = nil
|
flickerstreak@2
|
534 end
|
flickerstreak@1
|
535 end
|
flickerstreak@1
|
536 end
|
flickerstreak@1
|
537
|
flickerstreak@10
|
538
|
flickerstreak@10
|
539
|
flickerstreak@10
|
540
|
flickerstreak@10
|
541 -----------------
|
flickerstreak@10
|
542 -- General utility
|
flickerstreak@10
|
543 -----------------
|
flickerstreak@7
|
544 function main:ToggleIds()
|
flickerstreak@7
|
545 if self.showIds then
|
flickerstreak@7
|
546 ReAction:HideAllIds()
|
flickerstreak@1
|
547 else
|
flickerstreak@7
|
548 ReAction:ShowAllIds()
|
flickerstreak@1
|
549 end
|
flickerstreak@7
|
550 self.showIds = not self.showIds
|
flickerstreak@1
|
551 end
|
flickerstreak@1
|
552
|
flickerstreak@7
|
553 function main:AreIdsVisible()
|
flickerstreak@7
|
554 return self.showIds
|
flickerstreak@1
|
555 end
|
flickerstreak@1
|
556
|
flickerstreak@10
|
557 -- set a global variable for Bindings.xml
|
flickerstreak@10
|
558 ReActionAddOn = main
|
flickerstreak@1
|
559
|
flickerstreak@1
|
560
|