forked from phriked/AstralKeys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFrame Functions.lua
235 lines (193 loc) · 6.98 KB
/
Frame Functions.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
235
local e, L = unpack(select(2, ...))
local BACKDROP = {
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = nil, tile = true, tileSize = 16, edgeSize = 16,
insets = {left = 0, right = 0, top = 0, bottom = 0}
}
local BACKDROPBUTTON = {
bgFile = nil,
edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", tile = true, tileSize = 16, edgeSize = 1,
insets = {left = 0, right = 0, top = 0, bottom = 0}
}
function e.CreateCheckBox(parent, label, width)
local checkbox = CreateFrame('CheckButton', nil, parent)
checkbox:SetSize(width or 200, 20)
checkbox:SetBackdrop(nil)
checkbox:SetBackdropBorderColor(85/255, 85/255, 85/255)
checkbox:SetNormalFontObject(InterUIRegular_Normal)
checkbox:SetText(label)
checkbox:SetNormalTexture(nil)
checkbox:SetBackdropColor(0, 0, 0)
checkbox:SetPushedTextOffset(1,-1)
local tex = checkbox:CreateTexture('PUSHED_TEXTURE_BOX', 'BACKGROUND')
tex:SetSize(12, 12)
tex:SetPoint('LEFT', checkbox, 'LEFT', -2, 0)
tex:SetTexture('Interface\\AddOns\\AstralKeys\\Media\\box2.tga')
tex:SetVertexColor(0.3, 0.3, 0.3)
checkbox.t = checkbox:CreateTexture('PUSHEDTEXTURE', 'BACKGROUND')
checkbox.t:SetSize(12, 12)
checkbox.t:SetPoint('CENTER', tex, 'CENTER', 0, 0)
checkbox.t:SetTexture('Interface\\AddOns\\AstralKeys\\Media\\Texture\\[email protected]')
checkbox:SetCheckedTexture(checkbox.t)
if label then
checkbox:GetFontString():SetPoint('LEFT', tex, 'RIGHT', 5, 0)
end
return checkbox
end
local BACKDROP2 = {
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", tile = true, tileSize = 16, edgeSize = 1,
insets = {left = 0, right = 0, top = 0, bottom = 0}
}
local menuFrame = CreateFrame('FRAME', 'AstralMenuFrame', UIParent)
menuFrame:Hide()
menuFrame.dtbl = {}
menuFrame:SetFrameStrata('TOOLTIP')
menuFrame:SetWidth(150)
menuFrame:SetHeight(40)
menuFrame.background = menuFrame:CreateTexture(nil, 'BACKGROUND')
menuFrame.background:SetAllPoints(menuFrame)
menuFrame.background:SetColorTexture(0, 0, 0, 1)
menuFrame:EnableKeyboard(true)
menuFrame:SetScript('OnKeyDown', function(self, key)
if key == 'ESCAPE' then
AstralMenuFrame:Hide()
end
end)
menuFrame:SetScript('OnShow', function(self)
self:SetPropagateKeyboardInput(true)
end)
menuFrame.title = menuFrame:CreateFontString(nil, 'ARTWORK', 'InterUIMedium_Normal')
--menuFrame.title:SetFont(FONT_CONTENT, FONT_SIZE - 1)
menuFrame.title:SetJustifyH('LEFT')
menuFrame.title:SetSize(120, 15)
menuFrame.title:SetPoint('TOPLEFT', menuFrame, 'TOPLEFT', 10, -5)
local function HideMenu()
menuFrame:Hide()
end
function menuFrame:SetUnit(unitID)
self.unit = unitID
if e.FrameListShown() == 'GUILD' then
self.title:SetText(e.UnitName(unitID))
else
self.title:SetText(e.FriendName(unitID))
end
end
function menuFrame:NewObject(name, func, onShow)
local btn = CreateFrame('BUTTON', nil, menuFrame)
btn:SetSize(135, 20)
btn:SetBackdrop(BACKDROP2)
btn:SetBackdropBorderColor(0, 0, 0, 0)
btn:SetBackdropColor(25/255, 25/255, 25/255)
btn:SetNormalFontObject(InterUIBlack_Normal)
local texture = btn:CreateTexture()
texture:SetColorTexture(0.5, 0.5, 0.5, .2)
texture:SetPoint('TOPLEFT', 1, -1)
texture:SetPoint('BOTTOMRIGHT', -1, 1)
btn:SetHighlightTexture(texture)
btn:SetText(name)
btn:SetScript('OnClick', func)
if onShow and type(onShow) == 'function' then
btn:SetScript('OnShow', onShow)
end
return btn
end
function menuFrame:AddSelection(name, onClick, onShow)
local dtbl = self.dtbl
dtbl[#dtbl + 1] = self:NewObject(name, onClick, onShow)
self:SetHeight(#dtbl * 20 + 30)
if onClick then
dtbl[#dtbl]:HookScript('OnClick', HideMenu)
end
dtbl[#dtbl]:SetPoint('TOPLEFT', self, 'TOPLEFT', 15, -20*(#dtbl) -5)
end
local reportFrame = CreateFrame('FRAME', 'AstralReportFrame', UIParent)
reportFrame:Hide()
reportFrame:SetFrameStrata('TOOLTIP')
reportFrame:SetWidth(100)
reportFrame:SetHeight(70)
reportFrame.background = reportFrame:CreateTexture(nil, 'BACKGROUND')
reportFrame.background:SetAllPoints(reportFrame)
reportFrame.background:SetColorTexture(0, 0, 0, 1)
reportFrame:EnableKeyboard(true)
local partyButton = CreateFrame('BUTTON', nil, reportFrame)
partyButton:SetSize(90, 20)
partyButton:SetBackdrop(BACKDROP2)
partyButton:SetBackdropBorderColor(0, 0, 0, 0)
partyButton:SetBackdropColor(25/255, 25/255, 25/255)
partyButton:SetNormalFontObject(InterUIBlack_Normal)
local partyHighlightTexture = partyButton:CreateTexture()
partyHighlightTexture:SetColorTexture(0.5, 0.5, 0.5, .2)
partyHighlightTexture:SetPoint('TOPLEFT', 1, -1)
partyHighlightTexture:SetPoint('BOTTOMRIGHT', -1, 1)
partyButton:SetHighlightTexture(partyHighlightTexture)
partyButton:SetPoint('TOPLEFT', reportFrame, 'TOPLEFT', 5, -5)
partyButton:SetText(L['PARTY'])
partyButton:SetScript('OnClick', function()
e.AnnounceCharacterKeys('PARTY')
reportFrame:Hide()
end)
local guildButton = CreateFrame('BUTTON', nil, reportFrame)
guildButton:SetSize(90, 20)
guildButton:SetBackdrop(BACKDROP2)
guildButton:SetBackdropBorderColor(0, 0, 0, 0)
guildButton:SetBackdropColor(25/255, 25/255, 25/255)
guildButton:SetNormalFontObject(InterUIBlack_Normal)
local guildHighlightTexture = guildButton:CreateTexture()
guildHighlightTexture:SetColorTexture(0.5, 0.5, 0.5, .2)
guildHighlightTexture:SetPoint('TOPLEFT', 1, -1)
guildHighlightTexture:SetPoint('BOTTOMRIGHT', -1, 1)
guildButton:SetHighlightTexture(guildHighlightTexture)
guildButton:SetPoint('TOPLEFT', partyButton, 'BOTTOMLEFT', 0, -1)
guildButton:SetText(L['GUILD'])
guildButton:SetScript('OnClick', function()
e.AnnounceCharacterKeys('GUILD')
reportFrame:Hide()
end)
local cancelButton = CreateFrame('BUTTON', nil, reportFrame)
cancelButton:SetSize(90, 20)
cancelButton:SetBackdrop(BACKDROP2)
cancelButton:SetBackdropBorderColor(0, 0, 0, 0)
cancelButton:SetBackdropColor(25/255, 25/255, 25/255)
cancelButton:SetNormalFontObject(InterUIBlack_Normal)
local cancelHighlightTexture = cancelButton:CreateTexture()
cancelHighlightTexture:SetColorTexture(0.5, 0.5, 0.5, .2)
cancelHighlightTexture:SetPoint('TOPLEFT', 1, -1)
cancelHighlightTexture:SetPoint('BOTTOMRIGHT', -1, 1)
cancelButton:SetHighlightTexture(cancelHighlightTexture)
cancelButton:SetPoint('TOPLEFT', guildButton, 'BOTTOMLEFT', 0, -1)
cancelButton:SetText(L['CANCEL'])
cancelButton:SetScript('OnClick', function()
reportFrame:Hide()
end)
function e.AddEscHandler(frame)
if not frame and type(frame) ~= 'table' then
error('frame expcted, got '.. type(frame))
end
if frame:GetScript('OnKeyDown') then
frame:HookScript('OnKeyDown', function(self, key)
if key == 'ESCAPE' then
self:SetPropagateKeyboardInput(false)
self:Hide()
end
end)
else
frame:EnableKeyboard(true)
frame:SetPropagateKeyboardInput(true)
frame:SetScript('OnKeyDown', function(self, key)
if key == 'ESCAPE' then
self:SetPropagateKeyboardInput(false)
self:Hide()
end
end)
end
if frame:GetScript('OnShow') then
frame:HookScript('OnShow', function(self)
self:SetPropagateKeyboardInput(true)
end)
else
frame:SetScript('OnShow', function(self)
self:SetPropagateKeyboardInput(true)
end)
end
end