-
Notifications
You must be signed in to change notification settings - Fork 0
/
Restore.lua
58 lines (49 loc) · 1.68 KB
/
Restore.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
local addonName, addon = ...
function addon:RestoreDbBindings()
local profile = self.db.profile
self.db.global.update_bindings_trigger = false
-- clear
local index
for index = 1, GetNumBindings() do
local bind = { GetBinding(index) }
if bind[3] then
local key
for key in table.s2k_values({ select(3, unpack(bind)) }) do
SetBinding(key)
end
end
end
-- restore
local cmd, keys
for cmd, keys in pairs(profile.bindings) do
local key
for key in table.s2k_values(keys) do
SetBinding(key, cmd)
end
end
if LibStub("AceAddon-3.0"):GetAddon("Dominos", true) and profile.bindingsDominos then
for index = 1, 60 do
local key
-- clear
for key in table.s2k_values({ GetBindingKey(string.format("CLICK DominosActionButton%d:LeftButton", index)) }) do
SetBinding(key)
end
-- restore
if profile.bindingsDominos[index] then
for key in table.s2k_values(profile.bindingsDominos[index]) do
SetBindingClick(key, string.format("DominosActionButton%d", index), "LeftButton")
end
end
end
end
self.db.global.update_bindings_trigger = true
end
function addon:RestoreDefaultBindings()
self.db.global.update_bindings_trigger = false
self.db.profile.bindings = {}
self.db.profile.bindingsDominos = {}
LoadBindings(0)
self:SaveBindings()
self.db.global.update_bindings_trigger = true
self:Print("Succesfully reset '" .. self.db:GetCurrentProfile() .. "' to default keybinds")
end