-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathBindings.lua
219 lines (204 loc) · 9.24 KB
/
Bindings.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
if select(2,UnitClass("player")) ~= "SHAMAN" then return end
local _, TotemTimers = ...
local SpellNames = TotemTimers.SpellNames
local SpellIDs = TotemTimers.SpellIDs
local TRACKER_END = 8
local L = LibStub("AceLocale-3.0"):GetLocale("TotemTimers", true)
BINDING_NAME_TOTEMTIMERSSET1 = "Set 1"
BINDING_NAME_TOTEMTIMERSSET2 = "Set 2"
BINDING_NAME_TOTEMTIMERSSET3 = "Set 3"
BINDING_NAME_TOTEMTIMERSSET4 = "Set 4"
BINDING_NAME_TOTEMTIMERSSET5 = "Set 5"
BINDING_NAME_TOTEMTIMERSSET6 = "Set 6"
BINDING_NAME_TOTEMTIMERSSET7 = "Set 7"
BINDING_NAME_TOTEMTIMERSSET8 = "Set 8"
BINDING_NAME_TOTEMTIMERSCLOSE = "Close All Menus"
BINDING_NAME_TOTEMTIMERSMULTICAST = "Active Multicast (Call of Elements etc.)"
BINDING_NAME_TOTEMTIMERSMULTICASTMENU = "Open Multicast Menu"
local _G = getfenv()
for i=1,4 do
local e
if i==1 then e = L["Fire Button"] elseif i==2 then e=L["Earth Button"] elseif i==3 then e=L["Water Button"] else e=L["Air Button"] end
for j=1,8 do
_G["BINDING_NAME_TOTEMTIMERSCAST"..i..j] = e.." "..j
end
end
for i=1,10 do
_G["BINDING_NAME_TOTEMTIMERSCOOLDOWN"..i] = L["Cooldown"].." "..i
end
for i=1,8 do
_G["BINDING_NAME_TOTEMTIMERSLONGCOOLDOWN"..i] = L["Long Cooldown"].." "..i
end
local function SetupSpellNames()
BINDING_NAME_TOTEMTIMERSLIGHTNINGSHIELD = SpellNames[SpellIDs.LightningShield]
BINDING_NAME_TOTEMTIMERSWATERSHIELD = SpellNames[SpellIDs.WaterShield] or "Water Shield"
BINDING_NAME_TOTEMTIMERSTOTEMICCALL = SpellNames[SpellIDs.TotemicCall] or "Totemic Recall"
BINDING_NAME_TOTEMTIMERSEARTHSHOCK = SpellNames[SpellIDs.EarthShock]
BINDING_NAME_TOTEMTIMERSFLAMESHOCK = SpellNames[SpellIDs.FlameShock]
BINDING_NAME_TOTEMTIMERSFROSTSHOCK = SpellNames[SpellIDs.FrostShock]
end
local menubutton = "Button4"
local buttonnames = {
[AIR_TOTEM_SLOT] = "XiTimers_Timer"..AIR_TOTEM_SLOT,
[FIRE_TOTEM_SLOT] = "XiTimers_Timer"..FIRE_TOTEM_SLOT,
[WATER_TOTEM_SLOT] = "XiTimers_Timer"..WATER_TOTEM_SLOT,
[EARTH_TOTEM_SLOT] = "XiTimers_Timer"..EARTH_TOTEM_SLOT,
["es"] = "XiTimers_Timer7",
["wp"] = "XiTimers_Timer8",
}
local TotemTimers_Bindings = {
["TOTEMTIMERSAIR"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, buttonnames[AIR_TOTEM_SLOT])
_G[buttonnames[AIR_TOTEM_SLOT]].hotkey:SetText(GetBindingText(key, "KEY_", 1))
end,
["TOTEMTIMERSEARTH"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, buttonnames[EARTH_TOTEM_SLOT])
_G[buttonnames[EARTH_TOTEM_SLOT]].hotkey:SetText(GetBindingText(key, "KEY_", 1))
end,
["TOTEMTIMERSFIRE"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, buttonnames[FIRE_TOTEM_SLOT])
_G[buttonnames[FIRE_TOTEM_SLOT]].hotkey:SetText(GetBindingText(key, "KEY_", 1))
end,
["TOTEMTIMERSWATER"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, buttonnames[WATER_TOTEM_SLOT])
_G[buttonnames[WATER_TOTEM_SLOT]].hotkey:SetText(GetBindingText(key, "KEY_", 1))
end,
["TOTEMTIMERSAIRMENU"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, buttonnames[AIR_TOTEM_SLOT], menubutton)
end,
["TOTEMTIMERSEARTHMENU"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, buttonnames[EARTH_TOTEM_SLOT], menubutton)
end,
["TOTEMTIMERSFIREMENU"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, buttonnames[FIRE_TOTEM_SLOT], menubutton)
end,
["TOTEMTIMERSWATERMENU"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, buttonnames[WATER_TOTEM_SLOT], menubutton)
end,
["TOTEMTIMERSLIGHTNINGSHIELD"] = function(key)
SetOverrideBindingSpell(TotemTimersFrame, false, key, SpellNames[SpellIDs.LightningShield])
end,
["TOTEMTIMERSWATERSHIELD"] = function(key)
SetOverrideBindingSpell(TotemTimersFrame, false, key, SpellNames[SpellIDs.WaterShield])
end,
["TOTEMTIMERSTOTEMICCALL"] = function(key)
SetOverrideBindingSpell(TotemTimersFrame, false, key, SpellNames[SpellIDs.TotemicCall])
end,
["TOTEMTIMERSCALLOFELEMENTS"] = function(key)
SetOverrideBindingSpell(TotemTimersFrame, false, key, SpellNames[SpellIDs.CallOfElements])
end,
["TOTEMTIMERSCALLOFANCESTORS"] = function(key)
SetOverrideBindingSpell(TotemTimersFrame, false, key, SpellNames[SpellIDs.CallOfAncestors])
end,
["TOTEMTIMERSCALLOFSPIRITS"] = function(key)
SetOverrideBindingSpell(TotemTimersFrame, false, key, SpellNames[SpellIDs.CallOfSpirits])
end,
["TOTEMTIMERSEARTHSHIELDLEFT"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, buttonnames["es"])
end,
["TOTEMTIMERSEARTHSHIELDRIGHT"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, buttonnames["es"], "RightButton")
end,
["TOTEMTIMERSEARTHSHIELDMIDDLE"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, buttonnames["es"], "MiddleButton")
end,
["TOTEMTIMERSEARTHSHIELDBUTTON4"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, buttonnames["es"], "Button4")
end,
["TOTEMTIMERSWEAPONBUFF1"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, buttonnames["wp"])
end,
["TOTEMTIMERSWEAPONBUFF2"] = function(key)
local button = "RightButton"
if TotemTimers.ActiveProfile.WeaponMenuOnRightclick then button = "MiddleButton" end
SetOverrideBindingClick(TotemTimersFrame, false, key, buttonnames["wp"], button)
end,
["TOTEMTIMERSSET1"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, "TotemTimers_SetButton1")
end,
["TOTEMTIMERSSET2"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, "TotemTimers_SetButton2")
end,
["TOTEMTIMERSSET3"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, "TotemTimers_SetButton3")
end,
["TOTEMTIMERSSET4"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, "TotemTimers_SetButton4")
end,
["TOTEMTIMERSSET5"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, "TotemTimers_SetButton5")
end,
["TOTEMTIMERSSET6"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, "TotemTimers_SetButton6")
end,
["TOTEMTIMERSSET7"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, "TotemTimers_SetButton7")
end,
["TOTEMTIMERSSET8"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, "TotemTimers_SetButton8")
end,
["TOTEMTIMERSCLOSE"] = function(key)
SetOverrideBindingClick(TotemTimersFrame, false, key, "XiTimers_Timer1", "Button5")
end,
["TOTEMTIMERSMULTICAST"] = function(key)
if WOW_PROJECT_ID > WOW_PROJECT_BURNING_CRUSADE_CLASSIC then
SetOverrideBindingClick(TotemTimersFrame, false, key, "TotemTimers_MultiSpell")
TotemTimers_MultiSpellHotKey:SetText(GetBindingText(key, "KEY_", 1))
end
end,
["TOTEMTIMERSMULTICASTMENU"] = function(key)
if WOW_PROJECT_ID > WOW_PROJECT_BURNING_CRUSADE_CLASSIC then
SetOverrideBindingClick(TotemTimersFrame, false, key, "TotemTimers_MultiSpell", menubutton)
end
end,
}
function TotemTimers.SetBinding(key, binding)
if not TotemTimers_IsSetUp then return end
for i=1,11 do
if XiTimers.timers[i].button.hotkey:GetText() == key then
XiTimers.timers[i].button.hotkey:SetText("")
end
end
if TotemTimers_Bindings[binding] then
TotemTimers_Bindings[binding](key)
elseif string.sub(binding,1, 15) == "TOTEMTIMERSCAST" then
SetOverrideBindingClick(TotemTimersFrame, false, key, "TT_ActionButton"..string.sub(binding,16))
--[[ elseif string.sub(binding,1, 19) == "TOTEMTIMERSCOOLDOWN" then
SetOverrideBindingClick(TotemTimersFrame, false, key, TotemTimers.EnhanceCDs[tonumber(string.sub(binding,20))].button:GetName())
elseif string.sub(binding,1, 23) == "TOTEMTIMERSLONGCOOLDOWN" then
SetOverrideBindingClick(TotemTimersFrame, false, key, TotemTimers.LongCooldowns[tonumber(string.sub(binding,24))].button:GetName())
]]
end
TotemTimers.ProcessSetting("BarBindings")
end
function TotemTimers.InitializeBindings()
SetupSpellNames()
local key1, key2
for i=1,TRACKER_END do
if i~=7 then XiTimers.timers[i].button.hotkey:SetText("") end
end
for binding,_ in pairs(TotemTimers_Bindings) do
key1, key2 = GetBindingKey(binding)
if key2 then TotemTimers_Bindings[binding](key2) end
if key1 then TotemTimers_Bindings[binding](key1) end
end
local TotemCount = TotemTimers.TotemCount
for i=1,4 do
for j=1,TotemCount[i] do
key1, key2 = GetBindingKey("TOTEMTIMERSCAST"..i..j)
if key2 then SetOverrideBindingClick(TotemTimersFrame, false, key2, "TT_ActionButton"..i..j) end
if key1 then SetOverrideBindingClick(TotemTimersFrame, false, key1, "TT_ActionButton"..i..j) end
end
end
--[[ for i=1,10 do
key1, key2 = GetBindingKey("TOTEMTIMERSCOOLDOWN"..i)
if key2 then SetOverrideBindingClick(TotemTimersFrame, false, key2, TotemTimers.EnhanceCDs[i].button:GetName()) end
if key1 then SetOverrideBindingClick(TotemTimersFrame, false, key1, TotemTimers.EnhanceCDs[i].button:GetName()) end
end
for i=1,8 do
key1, key2 = GetBindingKey("TOTEMTIMERSLONGCOOLDOWN"..i)
if key2 then SetOverrideBindingClick(TotemTimersFrame, false, key2, TotemTimers.LongCooldowns[i].button:GetName()) end
if key1 then SetOverrideBindingClick(TotemTimersFrame, false, key1, TotemTimers.LongCooldowns[i].button:GetName()) end
end ]]
TotemTimers.ProcessSetting("BarBindings")
end