This repository was archived by the owner on Jul 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpluginAmpere.lua
More file actions
109 lines (95 loc) · 3.41 KB
/
Copy pathpluginAmpere.lua
File metadata and controls
109 lines (95 loc) · 3.41 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
-- is ampere here?
local findAmpere = function()
local kids = { InterfaceOptionsFramePanelContainer:GetChildren() };
for _, child in ipairs(kids) do
if child.name == "Ampere" then return child end
end
return nil
end
local ampere_config_frame = findAmpere()
if ampere_config_frame == nil then return end
-- thanks Tekkub for this (ripped from Ampere itself hehe)
local MakeButton = function(parent)
local butt = CreateFrame("Button", nil, parent)
butt:SetWidth(60) butt:SetHeight(22)
butt:SetHighlightFontObject(GameFontHighlightSmall)
butt:SetNormalFontObject(GameFontNormalSmall)
butt:SetNormalTexture("Interface\\Buttons\\UI-Panel-Button-Up")
butt:SetPushedTexture("Interface\\Buttons\\UI-Panel-Button-Down")
butt:SetHighlightTexture("Interface\\Buttons\\UI-Panel-Button-Highlight")
butt:SetDisabledTexture("Interface\\Buttons\\UI-Panel-Button-Disabled")
butt:GetNormalTexture():SetTexCoord(0, 0.625, 0, 0.6875)
butt:GetPushedTexture():SetTexCoord(0, 0.625, 0, 0.6875)
butt:GetHighlightTexture():SetTexCoord(0, 0.625, 0, 0.6875)
butt:GetDisabledTexture():SetTexCoord(0, 0.625, 0, 0.6875)
butt:GetHighlightTexture():SetBlendMode("ADD")
return butt
end
-- load menu
local InvokeLoadMenu = function(addon, ...)
local menu = { { text = "Load profile:", isTitle = true} }
for profile, _ in pairs(_G.asDB) do
table.insert(menu, { text = profile, func = function() SlashCmdList["ADDONSWITCHER"]("load "..profile) end })
end
local menuFrame = CreateFrame("Frame", "ExampleMenuFrame", UIParent, "UIDropDownMenuTemplate")
EasyMenu(menu, menuFrame, "cursor", 0 , 0, "MENU")
end
-- save as
local currentName
StaticPopupDialogs["AddonSwitcherPluginAmpereSaveAs"] = {
text = "Enter new profile's name:",
button1 = ACCEPT,
button2 = CANCEL,
hasEditBox = 1,
OnAccept = function(self)
local text = self.editBox:GetText();
SlashCmdList["ADDONSWITCHER"]("save "..text)
end,
EditBoxOnEnterPressed = function(self)
local text = self:GetParent().editBox:GetText();
SlashCmdList["ADDONSWITCHER"]("save "..text)
self:GetParent():Hide();
end,
OnShow = function(self)
self.editBox:SetText("");
self.editBox:SetFocus();
end,
OnHide = function(self)
self.editBox:SetText("");
end,
timeout = 0,
whileDead = 1,
hideOnEscape = 1,
maxLetters = 1024,
}
local InvokeSaveMenu = function(addon, ...)
local menu = {
{ text = "Save as:", isTitle = true},
{ text = "New profile...",func = function()
currentName = "default"
StaticPopup_Show("AddonSwitcherPluginAmpereSaveAs")
end }
}
for profile, _ in pairs(_G.asDB) do
table.insert(menu, { text = profile, func = function() SlashCmdList["ADDONSWITCHER"]("save "..profile) end })
end
local menuFrame = CreateFrame("Frame", "ExampleMenuFrame", UIParent, "UIDropDownMenuTemplate")
EasyMenu(menu, menuFrame, "cursor", 0 , 0, "MENU")
end
-- inject new buttons into Ampere! screen
local load = MakeButton(ampere_config_frame)
load:SetFrameStrata("HIGH")
load:SetPoint("BOTTOMLEFT", ampere_config_frame, "BOTTOMLEFT", 184, 16)
load:SetText("Load")
load:SetScript("OnClick", InvokeLoadMenu)
local save = MakeButton(ampere_config_frame)
save:SetFrameStrata("HIGH")
save:SetPoint("LEFT", load, "RIGHT", 4, 0)
save:SetText("Save")
save:SetScript("OnClick", InvokeSaveMenu)
-- small Bonus: open ampere with /amp or /ampere
SLASH_SHOWAMPERE1 = "/ampere"
SLASH_SHOWAMPERE2 = "/amp"
SlashCmdList["SHOWAMPERE"] = function()
InterfaceOptionsFrame_OpenToCategory(ampere_config_frame)
end