-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMinimapButton.lua
More file actions
138 lines (114 loc) · 3.85 KB
/
Copy pathMinimapButton.lua
File metadata and controls
138 lines (114 loc) · 3.85 KB
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
local addon, ns = ...
local L = ns.L
local listFrame = AddonMgrAddonList
local addonToggle = function() listFrame:SetShown(not listFrame:IsShown()) end
local menu = LibStub("LibSFDropDown-1.5"):SetMixin({})
listFrame.minimapBtnMenu = menu
menu:ddSetDisplayMode(listFrame.isMainline and "menu" or "menuBackdrop")
menu:ddSetInitFunc(function(dd, level)
local info = {}
info.keepShownOnClick = true
info.isTitle = true
info.notCheckable = true
info.text = L["Profiles"]
dd:ddAddButton(info, level)
local lastLoadName = listFrame:getLastLoadProfileName()
local func = function(btn) listFrame:loadProfileAddons(btn.value, true) end
local list = {}
for i, profile in ipairs(listFrame.profiles) do
list[i] = {
notCheckable = true,
text = listFrame:getProfileDisplayName(profile, lastLoadName),
value = profile,
func = func,
}
end
info.list = list
dd:ddAddButton(info, level)
end)
local function addOddLine(tooltip, text1, text2)
tooltip:AddDoubleLine(text1, text2, 1,1,1,1,1,1)
end
local function addEvenLine(tooltip, text1, text2)
tooltip:AddDoubleLine(text1, text2, .8,1,1,.8,1,1)
end
C_Timer.After(0, function()
local ldb_icon = LibStub("LibDataBroker-1.1"):NewDataObject(addon, {
type = "launcher",
text = addon,
icon = C_AddOns.GetAddOnMetadata(addon, "IconTexture"),
OnClick = function(self, button)
if button == "RightButton" then
if #listFrame.profiles == 0 then return end
menu:ddSetNoGlobalMouseEvent(true, self)
menu:ddToggle(1, nil, self, "TOPRIGHT", "BOTTOMRIGHT")
elseif button == "MiddleButton" then
if not IsControlKeyDown() then
collectgarbage()
end
listFrame:updateAddonMemoryUsage(true)
local func = self:GetScript("OnEnter")
if func then func(self) end
else
menu:ddCloseMenus()
addonToggle()
end
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
end,
OnTooltipShow = function(tooltip)
if listFrame.db.omb.dontShowTooltip then return end
local title = C_AddOns.GetAddOnMetadata(addon, "Title")
local version = C_AddOns.GetAddOnMetadata(addon, "Version")
tooltip:SetText(("%s (|cffff7f3f%s|r)"):format(title, version))
local totalMem = 0
local maxAddons = 10
local topAddons = {}
listFrame:updateAddonMemoryUsage()
for i = 1, C_AddOns.GetNumAddOns() do
local mem = GetAddOnMemoryUsage(i)
if mem > 0 then
totalMem = totalMem + mem
for j = 1, maxAddons do
if not topAddons[j] or topAddons[j].mem < mem then
for k = maxAddons, j + 1, -1 do
topAddons[k] = topAddons[k - 1]
end
topAddons[j] = {index = i, mem = mem}
break
end
end
end
end
tooltip:AddLine(" ")
addOddLine(tooltip, L["UI Memory:"], listFrame:formatMemory(collectgarbage("count")))
addEvenLine(tooltip, TOTAL_MEM_MB_ABBR:gsub("%%.+", ""):trim(), listFrame:formatMemory(totalMem))
tooltip:AddLine(" ")
for i = 1, #topAddons do
local name = C_AddOns.GetAddOnInfo(topAddons[i].index)
local mem = listFrame:formatMemory(topAddons[i].mem)
if i % 2 == 0 then addEvenLine(tooltip, name, mem)
else addOddLine(tooltip, name, mem) end
end
tooltip:AddLine(" ")
tooltip:AddLine(listFrame.LEFT_MOUSE_ICON..L["Left click to open the Addon Manargl"])
if #listFrame.profiles ~= 0 then
tooltip:AddLine(listFrame.RIGHT_MOUSE_ICON..L["Right click to open the Profile Menu"])
end
tooltip:AddLine(listFrame.MIDDLE_MOUSE_ICON..L["Middle click to clean the memory"])
end,
})
local ldbi = LibStub("LibDBIcon-1.0")
ldbi:Register(addon, ldb_icon, listFrame.db.omb)
menu:ddHideWhenButtonHidden(ldbi:GetMinimapButton(addon))
end)
SLASH_ADDONMRGL1 = "/addonmrgl"
SLASH_ADDONMRGL2 = "/mrgl"
SLASH_ADDONMRGL3 = "/am"
SlashCmdList["ADDONMRGL"] = function(text)
local load, name = (" "):split(text, 2)
if load:lower() == "-lp" then
listFrame:loadProfileByName(name, true, true)
else
addonToggle()
end
end