-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbindings.lua
92 lines (76 loc) · 2.66 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
local Nameplates = select(2, ...)
local Binding = Nameplates:NewModule("Bindings", "AceEvent-3.0")
local L = Nameplates.L
local updateQueued
-- The reason we hijack this as a button instead of hooking the Show* functions is mainly sanity, it's just easier to do this
function Binding:OnInitialize()
if( not self.enemyBinding ) then
self.enemyBinding = CreateFrame("Button", "NPEnemyBinding")
self.enemyBinding:SetScript("OnMouseDown", self.EnemyBindings)
end
if( not self.friendlyBinding ) then
self.friendlyBinding = CreateFrame("Button", "NPFriendlyBinding")
self.friendlyBinding:SetScript("OnMouseDown", self.FriendlyBindings)
end
if( not self.allBinding ) then
self.allBinding = CreateFrame("Button", "NPAllBinding")
self.allBinding:SetScript("OnMouseDown", self.AllBindings)
end
self:RegisterEvent("UPDATE_BINDINGS")
self:RegisterEvent("PLAYER_REGEN_ENABLED")
self:UPDATE_BINDINGS()
end
-- Update bindings since it was changed in combat
function Binding:PLAYER_REGEN_ENABLED()
if( updateQueued ) then
updateQueued = nil
self:UPDATE_BINDINGS()
end
end
function Binding:SetupBindings(frame, ...)
ClearOverrideBindings(frame)
for i=1, select("#", ...) do
SetOverrideBindingClick(frame, false, (select(i, ...)), frame:GetName())
end
end
-- Update our override bindings
function Binding:UPDATE_BINDINGS()
if( InCombatLockdown() ) then
updateQueued = true
return
end
self:SetupBindings(self.enemyBinding, GetBindingKey("NAMEPLATES"))
self:SetupBindings(self.friendlyBinding, GetBindingKey("FRIENDNAMEPLATES"))
self:SetupBindings(self.allBinding, GetBindingKey("ALLNAMEPLATES"))
end
-- Toggle Messages
function Binding:EnemyBindings()
RunBinding("NAMEPLATES")
if( Nameplates.db.profile.bindings ) then
if( GetCVarBool("nameplateShowEnemies") and not GetCVarBool("nameplateShowFriends") ) then
Nameplates:Print(L["Enemy player/npc name plates are now visible."])
else
Nameplates:Print(L["Enemy player/npc name plates are now hidden."])
end
end
end
function Binding:FriendlyBindings()
RunBinding("FRIENDNAMEPLATES")
if( Nameplates.db.profile.bindings ) then
if( GetCVarBool("nameplateShowFriends") and not GetCVarBool("nameplateShowEnemies") ) then
Nameplates:Print(L["Friendly player/npc name plates are now visible."])
else
Nameplates:Print(L["Friendly player/npc name plates are now hidden."])
end
end
end
function Binding:AllBindings()
RunBinding( "ALLNAMEPLATES" )
if( Nameplates.db.profile.bindings ) then
if( GetCVarBool("nameplateShowEnemies") and GetCVarBool("nameplateShowFriends") ) then
Nameplates:Print(L["All name plates are now visible."])
else
Nameplates:Print(L["All name plates are now hidden."])
end
end
end