-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZHunterButtonAspect.lua
executable file
·148 lines (141 loc) · 6.35 KB
/
ZHunterButtonAspect.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
ZHunterMod_Saved["ZHunterButtonAspect"] = {}
ZHunterMod_Saved["ZHunterButtonAspect"]["spells"] = {ZHUNTER_ASPECT_HAWK, ZHUNTER_ASPECT_MONKEY, ZHUNTER_ASPECT_CHEETAH,
ZHUNTER_ASPECT_WILD, ZHUNTER_ASPECT_BEAST, ZHUNTER_ASPECT_PACK}
ZHunterMod_Saved["ZHunterButtonAspect"]["rows"] = 1
ZHunterMod_Saved["ZHunterButtonAspect"]["count"] = 6
ZHunterMod_Saved["ZHunterButtonAspect"]["horizontal"] = nil
ZHunterMod_Saved["ZHunterButtonAspect"]["vertical"] = nil
ZHunterMod_Saved["ZHunterButtonAspect"]["firstbutton"] = "RIGHT"
ZHunterMod_Saved["ZHunterButtonAspect"]["tooltip"] = 1
ZHunterMod_Saved["ZHunterButtonAspect"]["parent"] = {}
ZHunterMod_Saved["ZHunterButtonAspect"]["parent"]["size"] = 36
ZHunterMod_Saved["ZHunterButtonAspect"]["parent"]["hide"] = nil
ZHunterMod_Saved["ZHunterButtonAspect"]["parent"]["circle"] = 1
ZHunterMod_Saved["ZHunterButtonAspect"]["children"] = {}
ZHunterMod_Saved["ZHunterButtonAspect"]["children"]["size"] = 36
ZHunterMod_Saved["ZHunterButtonAspect"]["children"]["hideonclick"] = 1
function ZHunterButtonAspect_OnLoad()
this:RegisterEvent("VARIABLES_LOADED")
end
function ZHunterButtonAspect_OnEvent()
if event == "VARIABLES_LOADED" then
if UnitClass("player") ~= ZHUNTER_HUNTER then
ZHunterButtonAspect:UnregisterAllEvents()
ZHunterButtonAspect:Hide()
return
end
ZSpellButton_CreateChildren(ZHunterButtonAspect, "ZHunterButtonAspect", 11)
ZHunterButtonAspect.found = ZSpellButton_SetButtons(ZHunterButtonAspect, ZHunterMod_Saved["ZHunterButtonAspect"]["spells"])
if ZHunterButtonAspect.found > 0 and ZHunterButtonAspect.found < ZHunterMod_Saved["ZHunterButtonAspect"]["count"] then
ZHunterMod_Saved["ZHunterButtonAspect"]["count"] = ZHunterButtonAspect.found
end
ZHunterButtonAspect.options = ZHunterButtonAspectOptions
ZHunterButtonAspectAdjustment = CreateFrame("Frame", "ZHunterButtonAspectAdjustment")
ZHunterButtonAspectAdjustment:RegisterEvent("PLAYER_AURAS_CHANGED")
ZHunterButtonAspectAdjustment:RegisterEvent("PLAYER_ENTERING_WORLD")
ZHunterButtonAspectAdjustment:SetScript("OnEvent", ZHunterButtonAspectAdjustment_OnEvent)
ZHunterButtonAspect_Tooltip = CreateFrame("GameTooltip", "ZHunterButtonAspect_Tooltip", nil, "GameTooltipTemplate")
ZHunterButtonAspect_SetupOptions()
ZHunterButtonAspect_SetupSizeAndPosition()
end
end
function ZHunterButtonAspect_SetupSizeAndPosition()
ZSpellButton_SetSize(ZHunterButtonAspect, ZHunterMod_Saved["ZHunterButtonAspect"]["parent"]["size"])
ZSpellButton_SetSize(ZHunterButtonAspect, ZHunterMod_Saved["ZHunterButtonAspect"]["children"]["size"], 1)
ZSpellButton_SetExpandDirection(ZHunterButtonAspect, ZHunterMod_Saved["ZHunterButtonAspect"]["firstbutton"])
ZSpellButton_ArrangeChildren(ZHunterButtonAspect, ZHunterMod_Saved["ZHunterButtonAspect"]["rows"],
ZHunterMod_Saved["ZHunterButtonAspect"]["count"], ZHunterMod_Saved["ZHunterButtonAspect"]["horizontal"],
ZHunterMod_Saved["ZHunterButtonAspect"]["vertical"])
end
function ZHunterButtonAspect_Reset()
ZHunterMod_Saved["ZHunterButtonAspect"] = {}
ZHunterMod_Saved["ZHunterButtonAspect"]["spells"] = {ZHUNTER_ASPECT_HAWK, ZHUNTER_ASPECT_MONKEY, ZHUNTER_ASPECT_CHEETAH,
ZHUNTER_ASPECT_WILD, ZHUNTER_ASPECT_BEAST, ZHUNTER_ASPECT_PACK}
ZHunterMod_Saved["ZHunterButtonAspect"]["rows"] = 1
ZHunterMod_Saved["ZHunterButtonAspect"]["count"] = 6
ZHunterMod_Saved["ZHunterButtonAspect"]["horizontal"] = nil
ZHunterMod_Saved["ZHunterButtonAspect"]["vertical"] = nil
ZHunterMod_Saved["ZHunterButtonAspect"]["firstbutton"] = "RIGHT"
ZHunterMod_Saved["ZHunterButtonAspect"]["tooltip"] = 1
ZHunterMod_Saved["ZHunterButtonAspect"]["parent"] = {}
ZHunterMod_Saved["ZHunterButtonAspect"]["parent"]["size"] = 36
ZHunterMod_Saved["ZHunterButtonAspect"]["parent"]["hide"] = nil
ZHunterMod_Saved["ZHunterButtonAspect"]["parent"]["circle"] = 1
ZHunterMod_Saved["ZHunterButtonAspect"]["children"] = {}
ZHunterMod_Saved["ZHunterButtonAspect"]["children"]["size"] = 36
ZHunterMod_Saved["ZHunterButtonAspect"]["children"]["hideonclick"] = 1
end
function ZHunterButtonAspectAdjustment_OnEvent()
if event == "PLAYER_AURAS_CHANGED" or event == "PLAYER_ENTERING_WORLD" then
if not ZHunterButtonAspect1.id then
return
end
local buttontextures = {}
local button
for i=1, ZHunterButtonAspect.count do
button = getglobal(ZHunterButtonAspect.name..i)
button.icon = nil
if button.id then
buttontextures[GetSpellTexture(button.id, "spell")] = button
end
end
local i = 1
local texture = GetSpellTexture(ZHunterButtonAspect1.id, "spell")
local buff = UnitBuff("player", i)
local spellname, buffname
ZHunterButtonAspect.id = ZHunterButtonAspect1.id
while buff do
if texture == buff and ZHunterButtonAspect2.id then
ZHunterButtonAspect.id = ZHunterButtonAspect2.id
end
if buttontextures[buff] then
ZHunterButtonAspect_Tooltip:SetOwner(this, "ANCHOR_NONE")
ZHunterButtonAspect_Tooltip:SetUnitBuff("player", i)
buffname = ZHunterButtonAspect_TooltipTextLeft1:GetText()
spellname = GetSpellName(buttontextures[buff].id, "spell")
if buffname == spellname then
buttontextures[buff].icon = "Interface\\Icons\\Spell_Nature_WispSplode"
end
end
i = i + 1
buff = UnitBuff("player", i)
end
ZSpellButton_UpdateButton(ZHunterButtonAspect)
ZSpellButton_UpdateCooldown(ZHunterButtonAspect)
for i=1, ZHunterButtonAspect.count do
button = getglobal(ZHunterButtonAspect.name..i)
if button.id then
ZSpellButton_UpdateButton(button)
end
end
if GameTooltip:IsOwned(ZHunterButtonAspect) then
ZSpellButtonParent_OnEnter(ZHunterButtonAspect)
end
end
end
function ZHunterButtonAspect_KeyBinding(index)
local button
if index then
button = getglobal("ZHunterButtonAspect"..index)
else
button = ZHunterButtonAspect
end
if button.id then
CastSpell(button.id, "spell")
if ZHunterButtonAspect.hideonclick then
ZHunterButtonAspect.children:Hide()
end
end
end
SLASH_ZHunterButtonAspect1 = "/ZAspect"
SlashCmdList["ZHunterButtonAspect"] = function(msg)
if msg == "reset" then
ZHunterButtonAspect_Reset()
ZHunterButtonAspect:ClearAllPoints()
ZHunterButtonAspect:SetPoint("CENTER", UIParent, "CENTER", -60, 0)
elseif msg == "options" then
ZHunterButtonAspect.options:Show()
else
DEFAULT_CHAT_FRAME:AddMessage("Possible Commands: \"options\", \"reset\"", 0, 1, 1)
end
end