-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAMpanel.lua
120 lines (87 loc) · 3.5 KB
/
AMpanel.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
---------------------------------------------------------------------------------------------------
-- addons monitor dev panel
---------------------------------------------------------------------------------------------------
local AMutils = _G.AddonsManagerStuff.AMutils
local oAM = nil
local AMpanel = {}
--- public interface below ---
function AMpanel:new()
local o = {}
setmetatable(o, self)
self.__index = self
oAM = _G.AddonsManagerStuff.oAM
o:_init()
return o
end
function AMpanel:GetConfiguration()
local tConfig = {}
tConfig.tMainWndPos = {self.wMain:GetAnchorOffsets()}
tConfig.bIsHorizontal = self.bIsHorizontal
return tConfig
end
function AMpanel:SetConfiguration(tConfig, iAddonVersion)
self.bIsHorizontal = tConfig.bIsHorizontal
self:SetOrientation()
self.wMain:SetAnchorOffsets(unpack(tConfig.tMainWndPos))
if self.bIsHorizontal and self.wMain:GetWidth() ~= 147 then
self.wMain:SetAnchorOffsets(tConfig.tMainWndPos[1], tConfig.tMainWndPos[2], tConfig.tMainWndPos[1] + 147, tConfig.tMainWndPos[4])
elseif not self.bIsHorizontal and self.wMain:GetHeight() ~= 147 then
self.wMain:SetAnchorOffsets(tConfig.tMainWndPos[1], tConfig.tMainWndPos[2], tConfig.tMainWndPos[3], tConfig.tMainWndPos[2] + 147)
end
return tConfig
end
--- private methods below ---
function AMpanel:_init()
self.wMain = Apollo.LoadForm("AMpanel.xml", "DevPanel", nil, self)
Apollo.LoadSprites("AMpanel_Sprites.xml")
self.wMain:FindChild("OpenAddonsMonitor"):SetSprite("sprAddonsMonitorLive")
self.wMain:FindChild("OpenRover"):SetSprite("sprRover")
self.wMain:FindChild("OpenGeminiProfiler"):SetSprite("sprGeminiProfiler")
self.wMain:FindChild("OpenGeminiConsole"):SetSprite("sprGeminiConsole")
self.wMain:FindChild("OpenGeminiEditor"):SetSprite("sprGeminiEditor")
self.bIsHorizontal = true
end
function AMpanel:OnRequestChangeOrientation()
self.bIsHorizontal = not self.bIsHorizontal
self:SetOrientation()
end
function AMpanel:SetOrientation()
local iWidth = self.wMain:GetWidth()
local iHeight = self.wMain:GetHeight()
local bIsHorzNow = (iWidth > iHeight)
if (bIsHorzNow and self.bIsHorizontal) or (not bIsHorzNow and not self.bIsHorizontal) then
return
end
local iLeft, iTop = self.wMain:GetAnchorOffsets()
self.wMain:SetAnchorOffsets(iLeft, iTop, iLeft + iHeight, iTop + iWidth)
for _, wChild in pairs(self.wMain:GetChildren()) do
local iLeft, iTop, iRight, iBottom = wChild:GetAnchorOffsets()
wChild:SetAnchorOffsets(iTop, iLeft, iBottom, iRight)
end
end
function AMpanel:ButtonHoverOn(wCurrent)
wCurrent:SetBGColor("xkcdBrightCyan")
end
function AMpanel:ButtonHoverOff(wCurrent)
wCurrent:SetBGColor("xkcdAcidGreen")
end
function AMpanel:ButtonClickStart(wCurrent)
wCurrent:SetBGColor("xkcdLightBlue")
end
function AMpanel:ButtonClickEnd(wCurrent)
local sName = wCurrent:GetName()
wCurrent:SetBGColor("xkcdBrightCyan")
if sName == "OpenAddonsMonitor" then
oAM:Toggle()
elseif sName == "OpenRover" then
Apollo.FindWindowByName("RoverForm"):Show(not Apollo.FindWindowByName("RoverForm"):IsShown())
elseif sName == "OpenGeminiProfiler" then
Apollo.FindWindowByName("GeminiProfilerWindow"):Show(not Apollo.FindWindowByName("GeminiProfilerWindow"):IsShown())
elseif sName == "OpenGeminiConsole" then
Event_FireGenericEvent("GeminiConsole_ButtonClick")
elseif sName == "OpenGeminiEditor" then
Apollo.FindWindowByName("GeminiEditorMain"):Show(not Apollo.FindWindowByName("GeminiEditorMain"):IsShown())
end
self.wMain:ToFront()
end
_G.AddonsManagerStuff.AMpanel = AMpanel