flickerstreak@1
|
1 -- ReAction.lua
|
flickerstreak@1
|
2 --
|
flickerstreak@1
|
3 -- Top-level file for the ReAction Action Bar add-on
|
flickerstreak@1
|
4 --
|
flickerstreak@1
|
5 -- ReAction is implemented in terms of the Ace 2 library: http://www.wowace.com
|
flickerstreak@1
|
6 --
|
flickerstreak@1
|
7
|
flickerstreak@1
|
8 -- key binding label constants
|
flickerstreak@1
|
9 BINDING_HEADER_REACTION = "ReAction"
|
flickerstreak@1
|
10 BINDING_NAME_REACTION_TOGGLELOCK = "Lock/Unlock ReAction"
|
flickerstreak@1
|
11
|
flickerstreak@1
|
12 -- ReAction addon setup via Ace 2
|
flickerstreak@1
|
13 ReAction = AceLibrary("AceAddon-2.0"):new(
|
flickerstreak@1
|
14 "AceConsole-2.0",
|
flickerstreak@1
|
15 "AceEvent-2.0",
|
flickerstreak@1
|
16 "AceDB-2.0",
|
flickerstreak@1
|
17 "FuBarPlugin-2.0"
|
flickerstreak@1
|
18 )
|
flickerstreak@1
|
19
|
flickerstreak@1
|
20 -- FuBar plugin setup
|
flickerstreak@1
|
21 ReAction.hasIcon = false
|
flickerstreak@1
|
22 ReAction.hasNoColor = true
|
flickerstreak@1
|
23 ReAction.defaultPosition = "RIGHT"
|
flickerstreak@1
|
24 ReAction.defaultMinimapPosition = 240 -- degrees
|
flickerstreak@1
|
25 ReAction.OnMenuRequest = ReActionGlobalMenuOptions
|
flickerstreak@1
|
26
|
flickerstreak@1
|
27 -- initial non-persistent state
|
flickerstreak@1
|
28 ReAction.locked = true
|
flickerstreak@1
|
29
|
flickerstreak@1
|
30 -- localization
|
flickerstreak@1
|
31 -- local L = AceLibrary("AceLocale-2.0"):new("ReAction")
|
flickerstreak@1
|
32
|
flickerstreak@1
|
33
|
flickerstreak@1
|
34
|
flickerstreak@1
|
35 -- Event handling
|
flickerstreak@1
|
36 function ReAction:OnInitialize()
|
flickerstreak@1
|
37 self:RegisterChatCommand( {"/reaction", "/rxn"}, ReActionConsoleOptions, "REACTION" )
|
flickerstreak@1
|
38
|
flickerstreak@1
|
39 self:RegisterDB("ReActionDB","ReActionDBPC")
|
flickerstreak@1
|
40 self:RegisterDefaults("profile", ReActionProfileDefaults)
|
flickerstreak@1
|
41 self:RegisterEvent("PLAYER_REGEN_DISABLED","CombatLockdown")
|
flickerstreak@1
|
42
|
flickerstreak@1
|
43 AceLibrary("Dewdrop-2.0"):InjectAceOptionsTable(self, ReActionProfileMenuOptions)
|
flickerstreak@1
|
44 end
|
flickerstreak@1
|
45
|
flickerstreak@1
|
46 function ReAction:OnEnable()
|
flickerstreak@1
|
47 if self.db.profile.firstRunDone ~= true then
|
flickerstreak@1
|
48 -- Do some "first-run" setup
|
flickerstreak@1
|
49 self.db.profile.firstRunDone = true
|
flickerstreak@1
|
50 elseif self.db.profile.disabled == true then
|
flickerstreak@1
|
51 -- print some kind of a warning
|
flickerstreak@1
|
52 else
|
flickerstreak@1
|
53 self:SetupBars()
|
flickerstreak@1
|
54 end
|
flickerstreak@1
|
55 end
|
flickerstreak@1
|
56
|
flickerstreak@1
|
57 function ReAction:OnDisable()
|
flickerstreak@1
|
58 self:Lock()
|
flickerstreak@1
|
59 end
|
flickerstreak@1
|
60
|
flickerstreak@1
|
61 function ReAction:OnProfileEnable()
|
flickerstreak@1
|
62 -- handle profile switching
|
flickerstreak@1
|
63 self:SetupBars()
|
flickerstreak@1
|
64 self:Lock()
|
flickerstreak@1
|
65 end
|
flickerstreak@1
|
66
|
flickerstreak@1
|
67 function ReAction:CombatLockdown()
|
flickerstreak@1
|
68 if not self:IsLocked() then
|
flickerstreak@1
|
69 self:Lock()
|
flickerstreak@1
|
70 UIErrorsFrame:AddMessage("ReAction bars locked when in combat")
|
flickerstreak@1
|
71 end
|
flickerstreak@1
|
72 end
|
flickerstreak@1
|
73
|
flickerstreak@1
|
74
|
flickerstreak@1
|
75 -- lock/unlock ReAction
|
flickerstreak@1
|
76 function ReAction:SetLocked( lock )
|
flickerstreak@1
|
77 self.locked = lock and true or false -- force data integrity
|
flickerstreak@1
|
78 if not self.locked then
|
flickerstreak@1
|
79 self:Print("Buttons disabled while unlocked")
|
flickerstreak@1
|
80 end
|
flickerstreak@1
|
81 for _, bar in ipairs(self.bars) do
|
flickerstreak@1
|
82 if self.locked then bar:HideControls() else bar:ShowControls() end
|
flickerstreak@1
|
83 end
|
flickerstreak@1
|
84 end
|
flickerstreak@1
|
85
|
flickerstreak@1
|
86 function ReAction:IsLocked()
|
flickerstreak@1
|
87 return self.locked
|
flickerstreak@1
|
88 end
|
flickerstreak@1
|
89
|
flickerstreak@1
|
90 function ReAction:Lock()
|
flickerstreak@1
|
91 self:SetLocked(true)
|
flickerstreak@1
|
92 end
|
flickerstreak@1
|
93
|
flickerstreak@1
|
94 function ReAction:Unlock()
|
flickerstreak@1
|
95 self:SetLocked(false)
|
flickerstreak@1
|
96 end
|
flickerstreak@1
|
97
|
flickerstreak@1
|
98 function ReAction:ToggleLocked()
|
flickerstreak@1
|
99 ReAction:SetLocked( not(self.locked) )
|
flickerstreak@1
|
100 end
|
flickerstreak@1
|
101
|
flickerstreak@1
|
102
|
flickerstreak@1
|
103
|
flickerstreak@1
|
104 -- Hide the default Blizzard main bar artwork
|
flickerstreak@1
|
105 function ReAction:HideArt()
|
flickerstreak@1
|
106 if self.db.profile.hideArt then
|
flickerstreak@1
|
107 MainMenuBar:Hide() -- this also hides the bags, xp bar, lag meter, and micro menu buttons.
|
flickerstreak@1
|
108 else
|
flickerstreak@1
|
109 MainMenuBar:Show()
|
flickerstreak@1
|
110 end
|
flickerstreak@1
|
111 end
|
flickerstreak@1
|
112
|
flickerstreak@1
|
113 function ReAction:IsArtHidden()
|
flickerstreak@1
|
114 return self.db.profile.hideArt
|
flickerstreak@1
|
115 end
|
flickerstreak@1
|
116
|
flickerstreak@1
|
117 function ReAction:SetHideArt( hide )
|
flickerstreak@1
|
118 self.db.profile.hideArt = hide and true or false -- force data integrity
|
flickerstreak@1
|
119 self:HideArt()
|
flickerstreak@1
|
120 end
|
flickerstreak@1
|
121
|
flickerstreak@1
|
122 function ReAction:ToggleHideArt()
|
flickerstreak@1
|
123 self:SetHideArt( not self:IsArtHidden() )
|
flickerstreak@1
|
124 end
|
flickerstreak@1
|
125
|
flickerstreak@1
|
126
|
flickerstreak@1
|
127
|
flickerstreak@1
|
128 -- Keybinding color coding
|
flickerstreak@1
|
129 function ReAction:SetKeyColorCoding( cc )
|
flickerstreak@1
|
130 self.db.profile.keyColorCode = cc
|
flickerstreak@1
|
131 end
|
flickerstreak@1
|
132
|
flickerstreak@1
|
133 function ReAction:IsKeyColorCodeEnabled()
|
flickerstreak@1
|
134 return self.db.profile.keyColorCode
|
flickerstreak@1
|
135 end
|
flickerstreak@1
|
136
|
flickerstreak@1
|
137 function ReAction:ToggleKeyColorCoding()
|
flickerstreak@1
|
138 self:SetKeyColorCoding(not self.db.profile.keyColorCode)
|
flickerstreak@1
|
139 end
|
flickerstreak@1
|
140
|
flickerstreak@1
|
141
|
flickerstreak@1
|
142
|
flickerstreak@1
|
143 -- Hide default Blizzard bars
|
flickerstreak@1
|
144 local blizzDefaultBars = {
|
flickerstreak@1
|
145 ActionButton1,
|
flickerstreak@1
|
146 ActionButton2,
|
flickerstreak@1
|
147 ActionButton3,
|
flickerstreak@1
|
148 ActionButton4,
|
flickerstreak@1
|
149 ActionButton5,
|
flickerstreak@1
|
150 ActionButton6,
|
flickerstreak@1
|
151 ActionButton7,
|
flickerstreak@1
|
152 ActionButton8,
|
flickerstreak@1
|
153 ActionButton9,
|
flickerstreak@1
|
154 ActionButton10,
|
flickerstreak@1
|
155 ActionButton11,
|
flickerstreak@1
|
156 ActionButton12,
|
flickerstreak@1
|
157 BonusActionBarFrame,
|
flickerstreak@1
|
158 MultiBarLeft,
|
flickerstreak@1
|
159 MultiBarRight,
|
flickerstreak@1
|
160 MultiBarBottomLeft,
|
flickerstreak@1
|
161 MultiBarBottomRight
|
flickerstreak@1
|
162 }
|
flickerstreak@1
|
163
|
flickerstreak@1
|
164 function ReAction:HideDefaultBars()
|
flickerstreak@1
|
165 for _, f in pairs(blizzDefaultBars) do
|
flickerstreak@1
|
166 f:Hide()
|
flickerstreak@1
|
167 f:ClearAllPoints()
|
flickerstreak@1
|
168 f:SetParent(ReActionButtonRecycler)
|
flickerstreak@1
|
169 f:UnregisterAllEvents()
|
flickerstreak@1
|
170 end
|
flickerstreak@1
|
171 end
|
flickerstreak@1
|
172
|
flickerstreak@1
|
173
|
flickerstreak@1
|
174 -- Reset bars to defaults
|
flickerstreak@1
|
175 function ReAction:ResetBars()
|
flickerstreak@1
|
176 self.db.profile.bars = ReActionProfileDefaults.bars
|
flickerstreak@1
|
177 self:SetupBars()
|
flickerstreak@1
|
178 end
|
flickerstreak@1
|
179
|
flickerstreak@1
|
180
|
flickerstreak@1
|
181 -- re-sync action IDs
|
flickerstreak@1
|
182 function ReAction:ResyncActionIDs()
|
flickerstreak@1
|
183 -- TODO
|
flickerstreak@1
|
184 end
|
flickerstreak@1
|
185
|
flickerstreak@1
|
186
|
flickerstreak@1
|
187
|
flickerstreak@1
|
188 -- Bar manipulation
|
flickerstreak@1
|
189 ReAction.bars = { }
|
flickerstreak@1
|
190
|
flickerstreak@1
|
191 function ReAction:SetupBars()
|
flickerstreak@1
|
192 -- hide the default Blizzard art, if configued
|
flickerstreak@1
|
193 self:HideArt()
|
flickerstreak@1
|
194 -- hide the default Blizzard bars
|
flickerstreak@1
|
195 self:HideDefaultBars()
|
flickerstreak@1
|
196
|
flickerstreak@1
|
197 -- set up the bars from the profile
|
flickerstreak@1
|
198 for id, info in ipairs(self.db.profile.bars) do
|
flickerstreak@1
|
199 if self.bars[id] then self.bars[id]:Destroy() end -- remove old version of bar if switching profiles
|
flickerstreak@1
|
200 self.bars[id] = ReBar:new(info, id)
|
flickerstreak@1
|
201 end
|
flickerstreak@1
|
202
|
flickerstreak@1
|
203 -- remove excess bars
|
flickerstreak@1
|
204 while #self.bars > #self.db.profile.bars do
|
flickerstreak@1
|
205 table.remove(self.bars):Destroy()
|
flickerstreak@1
|
206 end
|
flickerstreak@1
|
207
|
flickerstreak@1
|
208 -- anchor the bars, have to do this in a second pass because
|
flickerstreak@1
|
209 -- they might be anchored to each other in a non-ordered way
|
flickerstreak@1
|
210 for _, bar in ipairs(self.bars) do
|
flickerstreak@1
|
211 bar:ApplyAnchor()
|
flickerstreak@1
|
212 end
|
flickerstreak@1
|
213 end
|
flickerstreak@1
|
214
|
flickerstreak@1
|
215
|
flickerstreak@1
|
216 function ReAction:NewBar()
|
flickerstreak@1
|
217 local c = ReActionBarConfigDefaults
|
flickerstreak@1
|
218 table.insert(self.bars, ReBar:new(c, #self.bars + 1))
|
flickerstreak@1
|
219 table.insert(self.db.profile.bars, c)
|
flickerstreak@1
|
220 self:Unlock()
|
flickerstreak@1
|
221 end
|
flickerstreak@1
|
222
|
flickerstreak@1
|
223
|
flickerstreak@1
|
224 function ReAction:DeleteBar(id)
|
flickerstreak@1
|
225 if self.bars[id] then
|
flickerstreak@1
|
226 table.remove(self.bars, id):Destroy()
|
flickerstreak@1
|
227 table.remove( self.db.profile.bars, id )
|
flickerstreak@1
|
228 end
|
flickerstreak@1
|
229 end
|
flickerstreak@1
|
230
|
flickerstreak@1
|
231 function ReAction:ToggleActionID()
|
flickerstreak@1
|
232 if self.showActionIDs then
|
flickerstreak@1
|
233 ReActionButton:HideAllActionIDs()
|
flickerstreak@1
|
234 else
|
flickerstreak@1
|
235 ReActionButton:ShowAllActionIDs()
|
flickerstreak@1
|
236 end
|
flickerstreak@1
|
237 self.showActionIDs = not self.showActionIDs
|
flickerstreak@1
|
238 end
|
flickerstreak@1
|
239
|
flickerstreak@1
|
240 function ReAction:IsActionIDVisible()
|
flickerstreak@1
|
241 return self.showActionIDs
|
flickerstreak@1
|
242 end
|
flickerstreak@1
|
243
|
flickerstreak@1
|
244
|
flickerstreak@1
|
245
|
flickerstreak@1
|
246 -- FuBar plugin methods
|
flickerstreak@1
|
247 local tablet = AceLibrary("Tablet-2.0")
|
flickerstreak@1
|
248
|
flickerstreak@1
|
249 function ReAction:OnTooltipUpdate()
|
flickerstreak@1
|
250 local c = tablet:AddCategory("columns", 2)
|
flickerstreak@1
|
251 c:AddLine("text", "ReAction bar lock", "text2", self.locked and "|cffcc0000Locked|r" or "|cff00cc00Unlocked|r")
|
flickerstreak@1
|
252 tablet:SetHint("|cffcc6600Shift-Click|r to toggle action bar lock. Right-click for options.")
|
flickerstreak@1
|
253 end
|
flickerstreak@1
|
254
|
flickerstreak@1
|
255 function ReAction:OnClick(button)
|
flickerstreak@1
|
256 if IsShiftKeyDown() then
|
flickerstreak@1
|
257 self:ToggleLocked()
|
flickerstreak@1
|
258 end
|
flickerstreak@1
|
259 self:UpdateDisplay()
|
flickerstreak@1
|
260 end
|