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 keybind = {
|
flickerstreak@184
|
69 type = "execute",
|
flickerstreak@184
|
70 name = L["Key Bindings"],
|
flickerstreak@184
|
71 desc = L["Show the keybinding dialogue"],
|
flickerstreak@184
|
72 func = "OptionLaunchKeybindMode",
|
flickerstreak@194
|
73 order = 6,
|
flickerstreak@184
|
74 },
|
flickerstreak@184
|
75 skipProfileWarning = {
|
flickerstreak@184
|
76 type = "toggle",
|
flickerstreak@184
|
77 name = L["Skip profile keybind warning"],
|
flickerstreak@184
|
78 desc = L["Don't show a warning about updating keybinds when switching profiles"],
|
flickerstreak@184
|
79 get = "OptionGetSkipKeybindWarning",
|
flickerstreak@184
|
80 set = "OptionSetSkipKeybindWarning",
|
flickerstreak@184
|
81 width = "double",
|
flickerstreak@194
|
82 order = 7,
|
flickerstreak@184
|
83 },
|
flickerstreak@184
|
84 }
|
flickerstreak@184
|
85 },
|
flickerstreak@184
|
86 profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db),
|
flickerstreak@184
|
87 }
|
flickerstreak@184
|
88 }
|
flickerstreak@182
|
89
|
flickerstreak@184
|
90 AceConfigReg:RegisterOptionsTable(configID,options)
|
flickerstreak@182
|
91
|
flickerstreak@184
|
92 local f = AceConfigDialog:AddToBlizOptions(configID, displayName, nil, "general")
|
flickerstreak@184
|
93
|
flickerstreak@184
|
94 if f and f.obj then
|
flickerstreak@184
|
95 f.obj:SetCallback("default",
|
flickerstreak@184
|
96 function()
|
flickerstreak@184
|
97 self.db:ResetProfile()
|
flickerstreak@184
|
98 AceConfigReg:NotifyChange(configID)
|
flickerstreak@184
|
99 end )
|
flickerstreak@184
|
100 end
|
flickerstreak@184
|
101
|
flickerstreak@184
|
102 AceConfigDialog:AddToBlizOptions(configID, options.args.profiles.name, configID, "profiles")
|
flickerstreak@182
|
103
|
flickerstreak@182
|
104 self.db.RegisterCallback(self,"OnProfileChanged")
|
flickerstreak@182
|
105 self.db.RegisterCallback(self,"OnProfileReset", "OnProfileChanged")
|
flickerstreak@182
|
106 self.db.RegisterCallback(self,"OnProfileCopied","OnProfileChanged")
|
flickerstreak@182
|
107
|
flickerstreak@184
|
108 SlashCmdList["REACTION"] = function(option)
|
flickerstreak@184
|
109 option = string.match(option or "", "^%s*(%S+)")
|
flickerstreak@184
|
110 if option == "config" or option == "options" then
|
flickerstreak@184
|
111 ReAction:ShowOptions()
|
flickerstreak@184
|
112 elseif option == "edit" then
|
flickerstreak@184
|
113 ReAction:ShowEditor()
|
flickerstreak@184
|
114 elseif option == "unlock" then
|
flickerstreak@184
|
115 ReAction:SetConfigMode(true)
|
flickerstreak@184
|
116 elseif option == "lock" then
|
flickerstreak@184
|
117 ReAction:SetConfigMode(false)
|
flickerstreak@184
|
118 elseif option == "kb" then
|
flickerstreak@184
|
119 ReAction:SetKeybindMode(true)
|
flickerstreak@184
|
120 else
|
flickerstreak@185
|
121 print(("%s %s %s"):format(L["ReAction"], ReAction.version, L["Usage:"]))
|
flickerstreak@184
|
122 print("/rxn config")
|
flickerstreak@184
|
123 print("/rxn edit")
|
flickerstreak@184
|
124 print("/rxn lock")
|
flickerstreak@184
|
125 print("/rxn unlock")
|
flickerstreak@184
|
126 print("/rxn kb")
|
flickerstreak@184
|
127 end
|
flickerstreak@184
|
128 end
|
flickerstreak@184
|
129
|
flickerstreak@182
|
130 _G["SLASH_REACTION1"] = "/reaction"
|
flickerstreak@182
|
131 _G["SLASH_REACTION2"] = "/rxn"
|
flickerstreak@182
|
132
|
flickerstreak@182
|
133 StaticPopupDialogs["REACTION_KB_WARN"] = {
|
flickerstreak@182
|
134 text = L["ReAction profile changed: check your keybinds, they may need to be updated."],
|
flickerstreak@182
|
135 button1 = L["OK"],
|
flickerstreak@182
|
136 hideOnEscape = true,
|
flickerstreak@182
|
137 enterClicksFirstButton = true,
|
flickerstreak@182
|
138 timeout = 0,
|
flickerstreak@182
|
139 showAlert = true,
|
flickerstreak@182
|
140 whileDead = true,
|
flickerstreak@182
|
141 }
|
flickerstreak@182
|
142 end
|
flickerstreak@182
|
143
|
flickerstreak@182
|
144
|
flickerstreak@182
|
145 function ReAction:ShowOptions()
|
flickerstreak@182
|
146 InterfaceOptionsFrame_OpenToCategory(configID)
|
flickerstreak@182
|
147 end
|
flickerstreak@182
|
148
|
flickerstreak@182
|
149
|
flickerstreak@184
|
150 function ReAction:OnProfileChanged()
|
flickerstreak@184
|
151 self:RebuildAll()
|
flickerstreak@182
|
152 if not self.db.global.skipKeybindWarning then
|
flickerstreak@182
|
153 StaticPopup_Show("REACTION_KB_WARN")
|
flickerstreak@182
|
154 end
|
flickerstreak@182
|
155 end
|
flickerstreak@182
|
156
|
flickerstreak@184
|
157
|
flickerstreak@184
|
158 function ReAction:OptionSetConfigMode(info, value)
|
flickerstreak@184
|
159 self:SetConfigMode(value)
|
flickerstreak@182
|
160 end
|
flickerstreak@182
|
161
|
flickerstreak@182
|
162
|
flickerstreak@184
|
163 function ReAction:OptionShowEditor()
|
flickerstreak@184
|
164 self:ShowEditor()
|
flickerstreak@194
|
165 InterfaceOptionsFrame:Hide()
|
flickerstreak@184
|
166 end
|
flickerstreak@184
|
167
|
flickerstreak@184
|
168
|
flickerstreak@184
|
169 function ReAction:OptionLaunchKeybindMode()
|
flickerstreak@184
|
170 self:SetKeybindMode(true)
|
flickerstreak@184
|
171 end
|
flickerstreak@184
|
172
|
flickerstreak@184
|
173
|
flickerstreak@184
|
174 function ReAction:OptionGetSkipKeybindWarning()
|
flickerstreak@184
|
175 return self.db.global.skipKeybindWarning
|
flickerstreak@184
|
176 end
|
flickerstreak@184
|
177
|
flickerstreak@184
|
178
|
flickerstreak@184
|
179 function ReAction:OptionSetSkipKeybindWarning(info, value)
|
flickerstreak@184
|
180 self.db.global.skipKeybindWarning = value
|
flickerstreak@184
|
181 end
|
flickerstreak@184
|
182
|
flickerstreak@184
|
183
|
flickerstreak@182
|
184 -- export to LDB
|
flickerstreak@184
|
185 local LDB = LibStub:GetLibrary("LibDataBroker-1.1")
|
flickerstreak@184
|
186 if LDB then
|
flickerstreak@184
|
187 LDB:NewDataObject( "ReAction",
|
flickerstreak@182
|
188 {
|
flickerstreak@182
|
189 type = "launcher",
|
flickerstreak@182
|
190 icon = "Interface\\Icons\\INV_Qiraj_JewelEncased",
|
flickerstreak@182
|
191
|
flickerstreak@182
|
192 OnClick = function( frame, button )
|
flickerstreak@182
|
193 if not InCombatLockdown() then
|
flickerstreak@182
|
194 if IsAltKeyDown() then
|
flickerstreak@182
|
195 ReAction:SetKeybindMode( not ReAction:GetKeybindMode() )
|
flickerstreak@182
|
196 elseif IsShiftKeyDown() then
|
flickerstreak@182
|
197 ReAction:SetConfigMode( not ReAction:GetConfigMode() )
|
flickerstreak@182
|
198 elseif button == "RightButton" then
|
flickerstreak@182
|
199 ReAction:ShowEditor()
|
flickerstreak@182
|
200 else
|
flickerstreak@182
|
201 ReAction:ShowOptions()
|
flickerstreak@182
|
202 end
|
flickerstreak@182
|
203 else
|
flickerstreak@182
|
204 ReAction:UserError(L["ReAction: can't configure in combat"])
|
flickerstreak@182
|
205 end
|
flickerstreak@182
|
206 end,
|
flickerstreak@182
|
207
|
flickerstreak@182
|
208 -- this isn't included in the 'launcher' type LDB spec but it seems all launcher displays use it
|
flickerstreak@182
|
209 OnTooltipShow = function( tooltip )
|
flickerstreak@182
|
210 tooltip:AddLine(format("|cffffffff%s|r %s",L["Click"],L["for options"]))
|
flickerstreak@182
|
211 tooltip:AddLine(format("|cffffd200%s|r %s",L["Right-click"],L["for bar editor dialog"]))
|
flickerstreak@182
|
212 tooltip:AddLine(format("|cff00ff00%s|r %s",L["Shift-click"],L["to unlock bars"]))
|
flickerstreak@182
|
213 tooltip:AddLine(format("|cff00cccc%s|r %s",L["Alt-click"],L["for keybind mode"]))
|
flickerstreak@182
|
214 end,
|
flickerstreak@182
|
215
|
flickerstreak@184
|
216 })
|
flickerstreak@184
|
217 end
|