/
MicroMenu.lua
126 lines (109 loc) · 3.53 KB
/
MicroMenu.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
local T, C, L, _ = unpack(select(2, ...))
if C.actionbar.enable ~= true or C.actionbar.micromenu ~= true then return end
----------------------------------------------------------------------------------------
-- Micro menu(by Elv22)
----------------------------------------------------------------------------------------
local microbuttons = {
"CharacterMicroButton",
"SpellbookMicroButton",
"TalentMicroButton",
"AchievementMicroButton",
"QuestLogMicroButton",
"GuildMicroButton",
"PVPMicroButton",
"LFDMicroButton",
"CompanionsMicroButton",
"EJMicroButton",
"MainMenuMicroButton",
"HelpMicroButton"
}
local frame = CreateFrame("Frame", "MicroAnchor", UIParent)
frame:Point(unpack(C.position.micro_menu))
frame:Width(((CharacterMicroButton:GetWidth() + 4) * 9) + 12)
frame:Height(CharacterMicroButton:GetHeight() - 28)
frame.shown = false
if C.actionbar.micromenu_mouseover == true then frame:SetAlpha(0) end
UpdateMicroButtonsParent(frame)
local function CheckFade(self, elapsed)
local mouseactive
for i, button in pairs(microbuttons) do
local b = _G[button]
if b.mouseover == true then
mouseactive = true
end
end
if C.actionbar.micromenu_mouseover ~= true then return end
if frame.mouseover == true then
mouseactive = true
if GameTooltip:IsShown() then
GameTooltip:Hide()
end
end
if mouseactive == true then
if frame.shown ~= true then
frame:SetAlpha(1)
frame.shown = true
end
else
if frame.shown == true then
frame:SetAlpha(0)
frame.shown = false
end
end
end
frame:SetScript("OnUpdate", CheckFade)
for i, button in pairs(microbuttons) do
local m = _G[button]
local pushed = m:GetPushedTexture()
local normal = m:GetNormalTexture()
local disabled = m:GetDisabledTexture()
m:SetParent(frame)
m.SetParent = T.dummy
_G[button.."Flash"]:SetTexture("")
m:SetHighlightTexture("")
m.SetHighlightTexture = T.dummy
local f = CreateFrame("Frame", nil, m)
f:SetFrameLevel(1)
f:SetFrameStrata("BACKGROUND")
f:Point("BOTTOMLEFT", m, "BOTTOMLEFT", 2, 0)
f:Point("TOPRIGHT", m, "TOPRIGHT", -2, -28)
f:SetTemplate("Default")
m.frame = f
pushed:SetTexCoord(0.17, 0.87, 0.5, 0.908)
pushed:ClearAllPoints()
pushed:Point("TOPLEFT", m.frame, "TOPLEFT", 2, -2)
pushed:Point("BOTTOMRIGHT", m.frame, "BOTTOMRIGHT", -2, 2)
normal:SetTexCoord(0.17, 0.87, 0.5, 0.908)
normal:ClearAllPoints()
normal:Point("TOPLEFT", m.frame, "TOPLEFT", 2, -2)
normal:Point("BOTTOMRIGHT", m.frame, "BOTTOMRIGHT", -2, 2)
if disabled then
disabled:SetTexCoord(0.17, 0.87, 0.5, 0.908)
disabled:ClearAllPoints()
disabled:Point("TOPLEFT", m.frame, "TOPLEFT", 2, -2)
disabled:Point("BOTTOMRIGHT", m.frame, "BOTTOMRIGHT", -2, 2)
end
m.mouseover = false
m:HookScript("OnEnter", function(self)
self.frame:SetBackdropBorderColor(T.color.r, T.color.g, T.color.b)
self.mouseover = true
end)
m:HookScript("OnLeave", function(self)
self.frame:SetBackdropBorderColor(unpack(C.media.border_color))
self.mouseover = false
end)
end
-- Fix/Create textures for buttons
do
MicroButtonPortrait:ClearAllPoints()
MicroButtonPortrait:Point("TOPLEFT", CharacterMicroButton.frame, "TOPLEFT", 2, -2)
MicroButtonPortrait:Point("BOTTOMRIGHT", CharacterMicroButton.frame, "BOTTOMRIGHT", -2, 2)
end
hooksecurefunc("UpdateMicroButtons", function()
GuildMicroButtonTabard:ClearAllPoints()
GuildMicroButtonTabard:Point("TOP", GuildMicroButton.frame, "TOP", 0, 25)
end)
CharacterMicroButton:ClearAllPoints()
CharacterMicroButton:Point("BOTTOMLEFT", frame, "BOTTOMLEFT", -2, 0)
CharacterMicroButton.SetPoint = T.dummy
CharacterMicroButton.ClearAllPoints = T.dummy