-
Notifications
You must be signed in to change notification settings - Fork 2
/
OptionsFrame.lua
151 lines (133 loc) · 5.29 KB
/
OptionsFrame.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
local addonName, ADDON = ...
ADDON.AAOptionsFrame = CreateFrame('FRAME', 'AAOptionsFrame', UIParent)
ADDON.AAOptionsFrame:SetFrameStrata('DIALOG')
ADDON.AAOptionsFrame:SetFrameLevel(5)
ADDON.AAOptionsFrame:SetHeight(400)
ADDON.AAOptionsFrame:SetWidth(550)
ADDON.AAOptionsFrame:SetPoint('CENTER', UIParent, 'CENTER')
ADDON.AAOptionsFrame:SetResizable(true)
ADDON.AAOptionsFrame:SetResizeBounds(510, 145)
ADDON.AAOptionsFrame:SetMovable(true)
ADDON.AAOptionsFrame:EnableMouse(true)
ADDON.AAOptionsFrame:RegisterForDrag('LeftButton')
ADDON.AAOptionsFrame:EnableKeyboard(true)
ADDON.AAOptionsFrame:SetPropagateKeyboardInput(true)
ADDON.AAOptionsFrame:SetClampedToScreen(true)
ADDON.AAOptionsFrame.background = ADDON.AAOptionsFrame:CreateTexture(nil, 'BACKGROUND')
ADDON.AAOptionsFrame.background:SetAllPoints( ADDON.AAOptionsFrame)
ADDON.AAOptionsFrame.background:SetColorTexture(0, 0, 0, .70)
ADDON.AAOptionsFrame:Hide()
ADDON.AAOptionsFrame:SetScript('OnKeyDown', function(self, key)
if key == 'ESCAPE' then
self:SetPropagateKeyboardInput(false)
ADDON.AAOptionsFrame:Hide()
end
end)
local corner = CreateFrame('FRAME', 'spellOptionsDrag', ADDON.AAOptionsFrame)
corner:SetFrameStrata('DIALOG')
corner:SetFrameLevel(ADDON.AAOptionsFrame:GetFrameLevel() + 10)
corner:SetSize(8, 8)
corner:SetPoint('BOTTOMRIGHT', ADDON.AAOptionsFrame, 'BOTTOMRIGHT', -3, 3)
corner:RegisterForDrag('LeftButton')
corner:EnableMouse(true)
corner:SetMovable(true)
corner:SetClampedToScreen(true)
local cornerTexture = corner:CreateTexture('ARTWORK')
cornerTexture:SetSize(8, 8)
cornerTexture:SetTexture('Interface\\AddOns\\AstralAnalytics\\Media\\Texture\\Corner')
cornerTexture:SetPoint('BOTTOMRIGHT', corner, 'BOTTOMRIGHT')
local MIN_RESIZE_TIME = 0.01
local function MenuBarResize_OnUpdate(self, elapsed)
self.timeSinceUpdate = self.timeSinceUpdate + elapsed
if self.timeSinceUpdate > MIN_RESIZE_TIME then
AAFrameMenuBar.texture:SetHeight(self:GetHeight())
self.timeSinceUpdate = 0
end
end
ADDON.AAOptionsFrame:SetScript('OnDragStart', function(self)
self:StartMoving()
end)
ADDON.AAOptionsFrame:SetScript('OnDragStop', function(self)
self:StopMovingOrSizing()
end)
corner:SetScript('OnDragStart', function(self)
local left, bottom, height = self:GetParent():GetRect()
self:GetParent().left = left
self:GetParent().bottom = bottom
self:GetParent().top = (bottom + height)
self:GetParent():StartSizing()
AAFrameMenuBar:SetScript('OnUpdate', MenuBarResize_OnUpdate)
end)
corner:SetScript('OnDragStop', function(self)
self:GetParent():StopMovingOrSizing()
self:GetParent():ClearAllPoints()
end)
ADDON.SpellRow = {}
ADDON.SpellRow.__index = ADDON.SpellRow
function ADDON.SpellRow:CreateRow(parent, index, spell)
local frame = CreateFrame('BUTTON', 'spellIdRow' .. index, parent:GetParent())
frame:SetSize(290, 20)
frame.background = frame:CreateTexture(nil, 'BACKGROUND')
frame.background:SetAllPoints(frame)
frame.background:SetTexture([[Interface\AddOns\AstralAnalytics\Media\Texture\Flat.tga]])
frame.background:SetAlpha(.6)
frame.background:Show()
frame.name = frame:CreateFontString(nil, 'OVERLAY', 'AstralFontBigger')
frame.name:SetPoint('LEFT', frame, 'LEFT', 4, -1)
frame.name:SetTextColor(1, 1, 1)
frame.checkbox = frame:CreateTexture()
frame.checkbox:SetSize(14, 14)
frame.checkbox:SetPoint('RIGHT', frame, 'RIGHT')
frame.checkbox:SetTexture('Interface\\AddOns\\AstralAnalytics\\Media\\Texture\\baseline-done-small@2x')
return frame
end
function ADDON.SpellRow:SetSpell(self, spell)
local spellInfo = C_Spell.GetSpellInfo(spell)
local name = spellInfo.name
local icon = spellInfo.iconID
if name == nil then
if spell == nil then
self.name:SetText("Can't resolve spell id to a number")
else
self.name:SetText("Invalid spell id: "..spell)
end
self:SetScript('OnClick', function() end)
else
self.name:SetText("|T"..icon..":20|t" .. name .. " (" .. spell .. ")")
ADDON:AddDefaultSettings('combatEvents', spell, {reportChannel = 'console', isEnabled = true})
self.checkbox:SetShown(AstralAnalytics.options.combatEvents[spell].isEnabled)
if not AstralAnalytics.options.combatEvents[spell].isEnabled then
self.background:SetAlpha(0)
else
self.background:SetAlpha(0.6)
end
self:SetScript('OnClick', function(self)
AstralAnalytics.options.combatEvents[spell].isEnabled = not AstralAnalytics.options.combatEvents[spell].isEnabled
self.checkbox:SetShown(AstralAnalytics.options.combatEvents[spell].isEnabled)
if not AstralAnalytics.options.combatEvents[spell].isEnabled then
self.background:SetAlpha(0)
else
self.background:SetAlpha(0.6)
end
end)
end
self:Show()
end
function ADDON.SpellRow:ClearSpell(self)
self.name:SetText('')
self:Hide()
end
local closeButton = CreateFrame('BUTTON', '$parentCloseButton', ADDON.AAOptionsFrame)
closeButton:SetPoint('TOPRIGHT', ADDON.AAOptionsFrame, 'TOPRIGHT', -5, -5)
closeButton:SetNormalTexture('Interface\\AddOns\\AstralAnalytics\\Media\\Texture\\baseline-close-24px@2x')
closeButton:SetSize(10, 10)
closeButton:GetNormalTexture():SetVertexColor(.8, .8, .8, 0.8)
closeButton:SetScript('OnClick', function()
ADDON.AAOptionsFrame:Hide()
end)
closeButton:SetScript('OnEnter', function(self)
self:GetNormalTexture():SetVertexColor(126/255, 126/255, 126/255, 0.8)
end)
closeButton:SetScript('OnLeave', function(self)
self:GetNormalTexture():SetVertexColor(0.8, 0.8, 0.8, 0.8)
end)