-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenu.lua
More file actions
88 lines (73 loc) · 3.07 KB
/
Copy pathMenu.lua
File metadata and controls
88 lines (73 loc) · 3.07 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
-- Menu.lua (Right-click context menu)
--
-- Shared by the panel itself and the minimap / broker button, so a right-click
-- gives the same quick actions wherever you make it. Uses the modern MenuUtil
-- API (11.0+); if it's ever missing we just open the full options instead.
local addonName, SP = ...
local L = SP.L
local REFRESH = _G.MenuResponse and _G.MenuResponse.Refresh
function SP:ShowContextMenu(owner)
if not (MenuUtil and MenuUtil.CreateContextMenu) then
SP:OpenOptions()
return
end
MenuUtil.CreateContextMenu(owner, function(_, root)
root:CreateTitle("StatPanel")
-- Live toggles. Returning MenuResponse.Refresh keeps the menu open and
-- re-reads the checkbox so it visibly ticks/unticks under the cursor.
root:CreateCheckbox(L["Show panel"],
function() return SP.db.enabled end,
function() SP:TogglePanel(); SP.UI:RefreshAll(); return REFRESH end)
root:CreateCheckbox(L["Lock position"],
function() return SP.db.panel.locked end,
function()
SP.db.panel.locked = not SP.db.panel.locked
SP.UI:RefreshAll()
return REFRESH
end)
root:CreateCheckbox(L["Show FPS"],
function() return SP.db.footer.showFPS end,
function()
SP.db.footer.showFPS = not SP.db.footer.showFPS
SP:Refresh(); SP.UI:RefreshAll()
return REFRESH
end)
root:CreateDivider()
-- Presets submenu.
local presets = root:CreateButton(L["Apply preset"])
for _, name in ipairs(SP.Presets.order) do
presets:CreateButton(name, function()
SP.Presets:Apply(name)
SP.UI:RefreshAll()
end)
end
-- Profiles submenu, as a radio group so the active one shows a dot.
local profiles = root:CreateButton(L["Profile"])
for _, name in ipairs(SP.Config:ProfileList()) do
profiles:CreateRadio(name,
function() return SP.Config:CurrentProfile() == name end,
function()
SP.Config:SetProfile(name)
SP.UI:RefreshAll()
end)
end
root:CreateDivider()
-- Announce targets. "Print to my chat only" is first so a misclick
-- previews rather than broadcasts.
local announce = root:CreateButton(L["Announce to"])
for _, channel in ipairs(SP.Announce.channels) do
if channel.value ~= "WHISPER" then
announce:CreateButton(channel.name, function()
SP.Announce:Send(channel.value)
end)
end
end
root:CreateButton(L["Audit my gear"], function() SP.Gear:PrintReport() end)
root:CreateDivider()
root:CreateButton(L["Open options"], function() SP:OpenOptions() end)
root:CreateButton(L["Reset position"], function()
SP.db.panel.pos = SP.Config:DeepCopy(SP.Config.DEFAULTS.panel.pos)
SP:Refresh()
end)
end)
end