This repository has been archived by the owner on Mar 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.lua
234 lines (204 loc) · 6.5 KB
/
core.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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
--[[
PREDATOR BUTTONS API
This addon wants to be understood as a ActionButton-framework.
The addon itsself handles the functionality of the buttons (which are taken from the default UI)
and handles the buttons positions in your UI.
The look and feel of the addons can be adjusted by a layout.
]]
PredatorButtons = {}
local ADDON_NAME, ns = ...
local _
local skin = {}
local settings = ns.settings
local lib = ns.lib
-- ########################################################################################################
-- ########################################################################################################
--[[ VOID SetActiveSkin(skinTable)
]]
function PredatorButtons:SetActiveSkin(skinTable)
table.wipe(skin)
if ( skinTable.tex ) then
skin.tex = skinTable.tex
if ( not skinTable.tex.normal ) then
skin.tex.normal = settings.defaultSkin.tex.normal
end
if ( not skinTable.tex.pushed ) then
skin.tex.pushed = settings.defaultSkin.tex.pushed
end
if ( not skinTable.tex.highlight ) then
skin.tex.highlight = settings.defaultSkin.tex.highlight
end
if ( not skinTable.tex.checked ) then
skin.tex.checked = settings.defaultSkin.tex.checked
end
else
skin.tex = settings.defaultSkin.tex
end
if ( skinTable.showHotKey ) then
skin.showHotKey = true
else
skin.showHotKey = false
end
if ( skinTable.HotKeySettings ) then
skin.HotKeySettings = skinTable.HotKeySettings
else
skin.HotKeySettings = settings.defaultSkin.HotKeySettings
end
if ( skinTable.showCount ) then
skin.showCount = true
else
skin.showCount = false
end
if ( skinTable.CountSettings ) then
skin.CountSettings = skinTable.CountSettings
else
skin.CountSettings = settings.defaultSkin.CountSettings
end
if ( skinTable.showName ) then
skin.showName = true
else
skin.showName = false
end
if ( skinTable.NameSettings ) then
skin.NameSettings = skinTable.NameSettings
else
skin.NameSettings = settings.defaultSkin.NameSettings
end
if ( skinTable.overrideFunc ) then
skin.overrideFunc = skinTable.overrideFunc
end
end
--[[ VOID ApplySkin(bar)
]]
function PredatorButtons:ApplySkin(bar)
local parent = _G[settings.static.BarName[bar]]
local i
if ( bar ~= 'TotemBar' ) then
for i = 1, PredatorButtonsSettings[bar].buttons do
lib.StyleButton(_G[settings.static.ButtonPrefix[bar]..i],
skin.tex.normal,
skin.tex.pushed,
skin.tex.highlight,
skin.tex.checked,
skin.showHotKey,
skin.HotKeySettings,
skin.showCount,
skin.CountSettings,
skin.showName,
skin.NameSettings,
skin.overrideFunc)
end
else
lib.debugging('styling TotemBar')
lib.StyleTotemSlotButton(_G['MultiCastSlotButton1'])
lib.StyleTotemSlotButton(_G['MultiCastSlotButton2'])
lib.StyleTotemSlotButton(_G['MultiCastSlotButton3'])
lib.StyleTotemSlotButton(_G['MultiCastSlotButton4'])
_G['MultiCastSummonSpellButtonHighlight']:Hide()
_G['MultiCastSummonSpellButtonHighlight'].Show = lib.noop
lib.StyleButton(_G['MultiCastSummonSpellButton'],
skin.tex.normal,
skin.tex.pushed,
skin.tex.highlight,
skin.tex.checked,
skin.showHotKey,
skin.HotKeySettings,
skin.showCount,
skin.CountSettings,
skin.showName,
skin.NameSettings,
skin.overrideFunc)
_G['MultiCastRecallSpellButtonHighlight']:Hide()
_G['MultiCastRecallSpellButtonHighlight'].Show = lib.noop
lib.StyleButton(_G['MultiCastRecallSpellButton'],
skin.tex.normal,
skin.tex.pushed,
skin.tex.highlight,
skin.tex.checked,
skin.showHotKey,
skin.HotKeySettings,
skin.showCount,
skin.CountSettings,
skin.showName,
skin.NameSettings,
skin.overrideFunc)
for i = 1, 12 do
_G['MultiCastActionButton'..i].overlayTex:Hide()
_G['MultiCastActionButton'..i].overlayTex.Show = lib.noop
lib.StyleButton(_G['MultiCastActionButton'..i],
skin.tex.normal,
skin.tex.pushed,
skin.tex.highlight,
skin.tex.checked,
skin.showHotKey,
skin.HotKeySettings,
skin.showCount,
skin.CountSettings,
skin.showName,
skin.NameSettings,
skin.overrideFunc)
end
end
end
-- ########################################################################################################
local PB = CreateFrame('Frame', nil, UIParent)
PB:RegisterEvent('ADDON_LOADED')
PB:SetScript('OnEvent', function(self, event, addon)
if ( addon ~= ADDON_NAME ) then return end
if ( not PredatorButtonsSettings ) then
PredatorButtonsSettings = settings.CreateDefaults()
end
_, settings.playerClass = UnitClass('player')
local i, j
local PB_AB = lib.CreateBar('ActionBar')
PB_AB:RegisterEvent('PLAYER_LOGIN')
PB_AB:RegisterEvent('KNOWN_CURRENCY_TYPES_UPDATE')
PB_AB:RegisterEvent('CURRENCY_DISPLAY_UPDATE')
PB_AB:RegisterEvent('BAG_UPDATE')
PB_AB:SetScript('OnEvent', function(self, event, ...)
if ( event == 'PLAYER_LOGIN' ) then
local i, button, list
for i = 1, settings.static.NumButtons['ActionBar'] do
button = _G[settings.static.ButtonPrefix['ActionBar']..i]
button:SetParent(self)
self:SetFrameRef('ActionButton'..i, button)
end
self:Execute([[
list = table.new()
for i = 1, 12 do
table.insert(list, self:GetFrameRef('ActionButton'..i))
end
]])
self:SetAttribute('_onstate-page', [[
for i, button in ipairs(list) do
button:SetAttribute('actionpage', tonumber(newstate))
end
]])
RegisterStateDriver(self, 'page', lib.GetActionBarPage())
else
MainMenuBar_OnEvent(self, event, ...) -- BLIZZARD
end
end)
local PB_MBBL = lib.CreateBar('MultiBarBottomLeft')
_G['MultiBarBottomLeft']:SetParent(PB_MBBL)
local PB_MBBR = lib.CreateBar('MultiBarBottomRight')
_G['MultiBarBottomRight']:SetParent(PB_MBBR)
local PB_MBR = lib.CreateBar('MultiBarRight')
_G['MultiBarRight']:SetParent(PB_MBR)
local PB_MBL = lib.CreateBar('MultiBarLeft')
_G['MultiBarLeft']:SetParent(PB_MBL)
local PB_PB = lib.CreateBar('PetBar')
_G['PetActionBarFrame']:SetParent(PB_PB)
local PB_SB = lib.CreateBar('StanceBar')
for i = 1, settings.static.NumButtons['StanceBar'] do
_G[settings.static.ButtonPrefix['StanceBar']..i]:SetParent(PB_SB)
end
hooksecurefunc('ShapeshiftBar_Update', lib.PredatorButtonsShapeshiftUpdate)
if ( settings.playerClass == 'SHAMAN' ) then
local PB_TB = lib.CreateTotemBar()
end
lib.HideBlizzard()
SLASH_PREDATORBUTTONS1, SLASH_PREDATORBUTTONS2 = '/predatorbuttons', '/pb'
SlashCmdList['PREDATORBUTTONS'] = lib.SlashCmdHandler
lib.debugging('loaded successfully!')
end)