flickerstreak@182
|
1 local addonName, addonTable = ...
|
flickerstreak@182
|
2 local ReAction = addonTable.ReAction
|
flickerstreak@182
|
3 local L = ReAction.L
|
flickerstreak@182
|
4 local InCombatLockdown = InCombatLockdown
|
flickerstreak@182
|
5
|
flickerstreak@182
|
6
|
flickerstreak@182
|
7 local configID = "ReAction"
|
flickerstreak@184
|
8 local displayName = L["ReAction"]
|
flickerstreak@182
|
9
|
flickerstreak@182
|
10
|
flickerstreak@182
|
11 function ReAction:InitializeOptions()
|
flickerstreak@184
|
12 local AceConfigReg = LibStub("AceConfigRegistry-3.0")
|
flickerstreak@182
|
13 local AceConfigDialog = LibStub("AceConfigDialog-3.0")
|
flickerstreak@182
|
14
|
flickerstreak@184
|
15 local options = {
|
flickerstreak@184
|
16 type = "group",
|
flickerstreak@184
|
17 name = displayName,
|
flickerstreak@184
|
18 handler = self,
|
flickerstreak@184
|
19 args = {
|
flickerstreak@184
|
20 general = {
|
flickerstreak@184
|
21 type = "group",
|
flickerstreak@184
|
22 name = displayName,
|
flickerstreak@184
|
23 args = {
|
flickerstreak@184
|
24 _desc = {
|
flickerstreak@184
|
25 type = "description",
|
flickerstreak@184
|
26 name = L["Customizable replacement for Blizzard's Action Bars"],
|
flickerstreak@184
|
27 order = 1,
|
flickerstreak@184
|
28 },
|
flickerstreak@184
|
29 unlock = {
|
flickerstreak@184
|
30 type = "toggle",
|
flickerstreak@184
|
31 name = L["Unlock Bars"],
|
flickerstreak@184
|
32 desc = L["Unlock bars for dragging and resizing with the mouse"],
|
flickerstreak@184
|
33 get = "GetConfigMode",
|
flickerstreak@184
|
34 set = "OptionSetConfigMode",
|
flickerstreak@184
|
35 width = "full",
|
flickerstreak@184
|
36 disabled = InCombatLockdown,
|
flickerstreak@184
|
37 order = 2,
|
flickerstreak@184
|
38 },
|
flickerstreak@184
|
39 hide = {
|
flickerstreak@184
|
40 type = "toggle",
|
flickerstreak@184
|
41 name = L["Hide Blizzard Action Bars"],
|
flickerstreak@184
|
42 desc = L["Hide the default main bar and extra action bars"],
|
flickerstreak@184
|
43 handler = self:GetModule("HideBlizzard"),
|
flickerstreak@184
|
44 get = "IsHidden",
|
flickerstreak@184
|
45 set = "SetHidden",
|
flickerstreak@184
|
46 disabled = "OptionDisabled",
|
flickerstreak@184
|
47 width = "full",
|
flickerstreak@184
|
48 order = 3,
|
flickerstreak@184
|
49 },
|
flickerstreak@184
|
50 hideVehicle = {
|
flickerstreak@184
|
51 type = "toggle",
|
flickerstreak@184
|
52 name = L["Hide Blizzard Vehicle Bar"],
|
flickerstreak@184
|
53 desc = L["Hide the default vechicle action bar"],
|
flickerstreak@184
|
54 handler = self:GetModule("HideBlizzard"),
|
flickerstreak@184
|
55 get = "IsHidden",
|
flickerstreak@184
|
56 set = "SetHidden",
|
flickerstreak@184
|
57 disabled = "OptionDisabled",
|
flickerstreak@184
|
58 width = "full",
|
flickerstreak@184
|
59 order = 4,
|
flickerstreak@184
|
60 },
|
flickerstreak@184
|
61 edit = {
|
flickerstreak@184
|
62 type = "execute",
|
flickerstreak@184
|
63 name = L["Edit Bars..."],
|
flickerstreak@184
|
64 desc = L["Show the ReAction Bar Editor dialogue"],
|
flickerstreak@184
|
65 func = "OptionShowEditor",
|
flickerstreak@184
|
66 order = 5,
|
flickerstreak@184
|
67 },
|
flickerstreak@184
|
68 _closeThis = {
|
flickerstreak@184
|
69 type = "toggle",
|
flickerstreak@184
|
70 name = L["Close on Launch"],
|
flickerstreak@184
|
71 desc = L["Close the Interface Options window when launching the ReAction Bar Editor"],
|
flickerstreak@184
|
72 get = "OptionGetCloseThis",
|
flickerstreak@184
|
73 set = "OptionSetCloseThis",
|
flickerstreak@184
|
74 order = 6,
|
flickerstreak@184
|
75 cmdHidden = true,
|
flickerstreak@184
|
76 dropdownHidden = true,
|
flickerstreak@184
|
77 },
|
flickerstreak@184
|
78 keybind = {
|
flickerstreak@184
|
79 type = "execute",
|
flickerstreak@184
|
80 name = L["Key Bindings"],
|
flickerstreak@184
|
81 desc = L["Show the keybinding dialogue"],
|
flickerstreak@184
|
82 func = "OptionLaunchKeybindMode",
|
flickerstreak@184
|
83 order = 7,
|
flickerstreak@184
|
84 },
|
flickerstreak@184
|
85 skipProfileWarning = {
|
flickerstreak@184
|
86 type = "toggle",
|
flickerstreak@184
|
87 name = L["Skip profile keybind warning"],
|
flickerstreak@184
|
88 desc = L["Don't show a warning about updating keybinds when switching profiles"],
|
flickerstreak@184
|
89 get = "OptionGetSkipKeybindWarning",
|
flickerstreak@184
|
90 set = "OptionSetSkipKeybindWarning",
|
flickerstreak@184
|
91 width = "double",
|
flickerstreak@184
|
92 order = 8,
|
flickerstreak@184
|
93 },
|
flickerstreak@184
|
94 }
|
flickerstreak@184
|
95 },
|
flickerstreak@184
|
96 profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db),
|
flickerstreak@184
|
97 }
|
flickerstreak@184
|
98 }
|
flickerstreak@182
|
99
|
flickerstreak@184
|
100 AceConfigReg:RegisterOptionsTable(configID,options)
|
flickerstreak@182
|
101
|
flickerstreak@184
|
102 local f = AceConfigDialog:AddToBlizOptions(configID, displayName, nil, "general")
|
flickerstreak@184
|
103
|
flickerstreak@184
|
104 if f and f.obj then
|
flickerstreak@184
|
105 f.obj:SetCallback("default",
|
flickerstreak@184
|
106 function()
|
flickerstreak@184
|
107 self.db:ResetProfile()
|
flickerstreak@184
|
108 AceConfigReg:NotifyChange(configID)
|
flickerstreak@184
|
109 end )
|
flickerstreak@184
|
110 end
|
flickerstreak@184
|
111
|
flickerstreak@184
|
112 AceConfigDialog:AddToBlizOptions(configID, options.args.profiles.name, configID, "profiles")
|
flickerstreak@182
|
113
|
flickerstreak@182
|
114 self.db.RegisterCallback(self,"OnProfileChanged")
|
flickerstreak@182
|
115 self.db.RegisterCallback(self,"OnProfileReset", "OnProfileChanged")
|
flickerstreak@182
|
116 self.db.RegisterCallback(self,"OnProfileCopied","OnProfileChanged")
|
flickerstreak@182
|
117
|
flickerstreak@184
|
118 SlashCmdList["REACTION"] = function(option)
|
flickerstreak@184
|
119 option = string.match(option or "", "^%s*(%S+)")
|
flickerstreak@184
|
120 if option == "config" or option == "options" then
|
flickerstreak@184
|
121 ReAction:ShowOptions()
|
flickerstreak@184
|
122 elseif option == "edit" then
|
flickerstreak@184
|
123 ReAction:ShowEditor()
|
flickerstreak@184
|
124 elseif option == "unlock" then
|
flickerstreak@184
|
125 ReAction:SetConfigMode(true)
|
flickerstreak@184
|
126 elseif option == "lock" then
|
flickerstreak@184
|
127 ReAction:SetConfigMode(false)
|
flickerstreak@184
|
128 elseif option == "kb" then
|
flickerstreak@184
|
129 ReAction:SetKeybindMode(true)
|
flickerstreak@184
|
130 else
|
flickerstreak@185
|
131 print(("%s %s %s"):format(L["ReAction"], ReAction.version, L["Usage:"]))
|
flickerstreak@184
|
132 print("/rxn config")
|
flickerstreak@184
|
133 print("/rxn edit")
|
flickerstreak@184
|
134 print("/rxn lock")
|
flickerstreak@184
|
135 print("/rxn unlock")
|
flickerstreak@184
|
136 print("/rxn kb")
|
flickerstreak@184
|
137 end
|
flickerstreak@184
|
138 end
|
flickerstreak@184
|
139
|
flickerstreak@182
|
140 _G["SLASH_REACTION1"] = "/reaction"
|
flickerstreak@182
|
141 _G["SLASH_REACTION2"] = "/rxn"
|
flickerstreak@182
|
142
|
flickerstreak@182
|
143 StaticPopupDialogs["REACTION_KB_WARN"] = {
|
flickerstreak@182
|
144 text = L["ReAction profile changed: check your keybinds, they may need to be updated."],
|
flickerstreak@182
|
145 button1 = L["OK"],
|
flickerstreak@182
|
146 hideOnEscape = true,
|
flickerstreak@182
|
147 enterClicksFirstButton = true,
|
flickerstreak@182
|
148 timeout = 0,
|
flickerstreak@182
|
149 showAlert = true,
|
flickerstreak@182
|
150 whileDead = true,
|
flickerstreak@182
|
151 }
|
flickerstreak@182
|
152 end
|
flickerstreak@182
|
153
|
flickerstreak@182
|
154
|
flickerstreak@182
|
155 function ReAction:ShowOptions()
|
flickerstreak@182
|
156 InterfaceOptionsFrame_OpenToCategory(configID)
|
flickerstreak@182
|
157 end
|
flickerstreak@182
|
158
|
flickerstreak@182
|
159
|
flickerstreak@184
|
160 function ReAction:OnProfileChanged()
|
flickerstreak@184
|
161 self:RebuildAll()
|
flickerstreak@182
|
162 if not self.db.global.skipKeybindWarning then
|
flickerstreak@182
|
163 StaticPopup_Show("REACTION_KB_WARN")
|
flickerstreak@182
|
164 end
|
flickerstreak@182
|
165 end
|
flickerstreak@182
|
166
|
flickerstreak@184
|
167
|
flickerstreak@184
|
168 function ReAction:OptionSetConfigMode(info, value)
|
flickerstreak@184
|
169 self:SetConfigMode(value)
|
flickerstreak@182
|
170 end
|
flickerstreak@182
|
171
|
flickerstreak@182
|
172
|
flickerstreak@184
|
173 function ReAction:OptionShowEditor()
|
flickerstreak@184
|
174 self:ShowEditor()
|
flickerstreak@184
|
175 if self.db.profile.closeOptionsOnEditorLaunch then
|
flickerstreak@184
|
176 InterfaceOptionsFrame:Hide()
|
flickerstreak@184
|
177 end
|
flickerstreak@184
|
178 end
|
flickerstreak@184
|
179
|
flickerstreak@184
|
180
|
flickerstreak@184
|
181 function ReAction:OptionGetCloseThis()
|
flickerstreak@184
|
182 return self.db.profile.closeOptionsOnEditorLaunch
|
flickerstreak@184
|
183 end
|
flickerstreak@184
|
184
|
flickerstreak@184
|
185
|
flickerstreak@184
|
186 function ReAction:OptionSetCloseThis(info,val)
|
flickerstreak@184
|
187 self.db.profile.closeOptionsOnEditorLaunch = val
|
flickerstreak@184
|
188 end
|
flickerstreak@184
|
189
|
flickerstreak@184
|
190
|
flickerstreak@184
|
191 function ReAction:OptionLaunchKeybindMode()
|
flickerstreak@184
|
192 self:SetKeybindMode(true)
|
flickerstreak@184
|
193 end
|
flickerstreak@184
|
194
|
flickerstreak@184
|
195
|
flickerstreak@184
|
196 function ReAction:OptionGetSkipKeybindWarning()
|
flickerstreak@184
|
197 return self.db.global.skipKeybindWarning
|
flickerstreak@184
|
198 end
|
flickerstreak@184
|
199
|
flickerstreak@184
|
200
|
flickerstreak@184
|
201 function ReAction:OptionSetSkipKeybindWarning(info, value)
|
flickerstreak@184
|
202 self.db.global.skipKeybindWarning = value
|
flickerstreak@184
|
203 end
|
flickerstreak@184
|
204
|
flickerstreak@184
|
205
|
flickerstreak@182
|
206 -- export to LDB
|
flickerstreak@184
|
207 local LDB = LibStub:GetLibrary("LibDataBroker-1.1")
|
flickerstreak@184
|
208 if LDB then
|
flickerstreak@184
|
209 LDB:NewDataObject( "ReAction",
|
flickerstreak@182
|
210 {
|
flickerstreak@182
|
211 type = "launcher",
|
flickerstreak@182
|
212 icon = "Interface\\Icons\\INV_Qiraj_JewelEncased",
|
flickerstreak@182
|
213
|
flickerstreak@182
|
214 OnClick = function( frame, button )
|
flickerstreak@182
|
215 if not InCombatLockdown() then
|
flickerstreak@182
|
216 if IsAltKeyDown() then
|
flickerstreak@182
|
217 ReAction:SetKeybindMode( not ReAction:GetKeybindMode() )
|
flickerstreak@182
|
218 elseif IsShiftKeyDown() then
|
flickerstreak@182
|
219 ReAction:SetConfigMode( not ReAction:GetConfigMode() )
|
flickerstreak@182
|
220 elseif button == "RightButton" then
|
flickerstreak@182
|
221 ReAction:ShowEditor()
|
flickerstreak@182
|
222 else
|
flickerstreak@182
|
223 ReAction:ShowOptions()
|
flickerstreak@182
|
224 end
|
flickerstreak@182
|
225 else
|
flickerstreak@182
|
226 ReAction:UserError(L["ReAction: can't configure in combat"])
|
flickerstreak@182
|
227 end
|
flickerstreak@182
|
228 end,
|
flickerstreak@182
|
229
|
flickerstreak@182
|
230 -- this isn't included in the 'launcher' type LDB spec but it seems all launcher displays use it
|
flickerstreak@182
|
231 OnTooltipShow = function( tooltip )
|
flickerstreak@182
|
232 tooltip:AddLine(format("|cffffffff%s|r %s",L["Click"],L["for options"]))
|
flickerstreak@182
|
233 tooltip:AddLine(format("|cffffd200%s|r %s",L["Right-click"],L["for bar editor dialog"]))
|
flickerstreak@182
|
234 tooltip:AddLine(format("|cff00ff00%s|r %s",L["Shift-click"],L["to unlock bars"]))
|
flickerstreak@182
|
235 tooltip:AddLine(format("|cff00cccc%s|r %s",L["Alt-click"],L["for keybind mode"]))
|
flickerstreak@182
|
236 end,
|
flickerstreak@182
|
237
|
flickerstreak@184
|
238 })
|
flickerstreak@184
|
239 end
|