- added new panel to consolidate plugins and panels from the main addon into only one frame.
This commit is contained in:
+284
-1
@@ -417,4 +417,287 @@
|
||||
|
||||
return options_frame
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function _detalhes:CreatePluginWindowContainer()
|
||||
|
||||
local f = CreateFrame ("frame", "DetailsPluginContainerWindow", UIParent)
|
||||
f:EnableMouse (true)
|
||||
f:SetMovable (true)
|
||||
f:SetPoint ("center", UIParent, "center")
|
||||
f:SetBackdrop (_detalhes.PluginDefaults and _detalhes.PluginDefaults.Backdrop or {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1})
|
||||
f:SetBackdropColor (0, 0, 0, 0.3)
|
||||
|
||||
f:Hide()
|
||||
|
||||
--> members
|
||||
f.MenuX = -5
|
||||
f.MenuY = -26
|
||||
f.MenuButtonWidth = 150
|
||||
f.MenuButtonHeight = 20
|
||||
f.TitleHeight = 20
|
||||
f.FrameWidth = 925
|
||||
f.FrameHeight = 600
|
||||
|
||||
--> store button references for the left menu
|
||||
f.MenuButtons = {}
|
||||
--> store all plugins embed
|
||||
f.EmbedPlugins = {}
|
||||
|
||||
--> lib window
|
||||
f:SetSize (f.FrameWidth, f.FrameHeight)
|
||||
local LibWindow = LibStub ("LibWindow-1.1")
|
||||
LibWindow.RegisterConfig (f, _detalhes.plugin_window_pos)
|
||||
LibWindow.RestorePosition (f)
|
||||
LibWindow.MakeDraggable (f)
|
||||
LibWindow.SavePosition (f)
|
||||
|
||||
--> menu background
|
||||
local menuBackground = CreateFrame ("frame", nil, f)
|
||||
_detalhes:FormatBackground (menuBackground)
|
||||
|
||||
--> point
|
||||
menuBackground:SetPoint ("topright", f, "topleft", -2, 0)
|
||||
menuBackground:SetPoint ("bottomright", f, "bottomleft", -2, 0)
|
||||
menuBackground:SetWidth (f.MenuButtonWidth + 6)
|
||||
|
||||
--> plugins menu title bar
|
||||
local titlebar_plugins = CreateFrame ("frame", nil, menuBackground)
|
||||
titlebar_plugins:SetPoint ("topleft", menuBackground, "topleft", 2, -3)
|
||||
titlebar_plugins:SetPoint ("topright", menuBackground, "topright", -2, -3)
|
||||
titlebar_plugins:SetHeight (f.TitleHeight)
|
||||
titlebar_plugins:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]], tileSize = 64, tile = true})
|
||||
titlebar_plugins:SetBackdropColor (.5, .5, .5, 1)
|
||||
titlebar_plugins:SetBackdropBorderColor (0, 0, 0, 1)
|
||||
--> title
|
||||
local titleLabel = _detalhes.gump:NewLabel (titlebar_plugins, titlebar_plugins, nil, "titulo", "Plugins", "GameFontHighlightLeft", 12, {227/255, 186/255, 4/255})
|
||||
titleLabel:SetPoint ("center", titlebar_plugins , "center")
|
||||
titleLabel:SetPoint ("top", titlebar_plugins , "top", 0, -5)
|
||||
|
||||
--> plugins menu title bar
|
||||
local titlebar_tools = CreateFrame ("frame", nil, menuBackground)
|
||||
titlebar_tools:SetHeight (f.TitleHeight)
|
||||
titlebar_tools:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]], tileSize = 64, tile = true})
|
||||
titlebar_tools:SetBackdropColor (.5, .5, .5, 1)
|
||||
titlebar_tools:SetBackdropBorderColor (0, 0, 0, 1)
|
||||
--> title
|
||||
local titleLabel = _detalhes.gump:NewLabel (titlebar_tools, titlebar_tools, nil, "titulo", "Tools", "GameFontHighlightLeft", 12, {227/255, 186/255, 4/255})
|
||||
titleLabel:SetPoint ("center", titlebar_tools , "center")
|
||||
titleLabel:SetPoint ("top", titlebar_tools , "top", 0, -5)
|
||||
|
||||
--> scripts
|
||||
f:SetScript ("OnShow", function()
|
||||
|
||||
end)
|
||||
|
||||
f:SetScript ("OnHide", function()
|
||||
|
||||
end)
|
||||
|
||||
f:SetScript ("OnMouseDown", function (self, button)
|
||||
if (button == "RightButton") then
|
||||
f.ClosePlugin()
|
||||
end
|
||||
end)
|
||||
|
||||
f.Debug = false
|
||||
function f.DebugMsg (...)
|
||||
if (f.Debug) then
|
||||
print ("[Details! Debug]", ...)
|
||||
end
|
||||
end
|
||||
|
||||
--> templates
|
||||
_detalhes.gump:InstallTemplate ("button", "DETAILS_PLUGINPANEL_BUTTON_TEMPLATE",
|
||||
{
|
||||
backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
|
||||
backdropcolor = {0, 0, 0, .5},
|
||||
backdropbordercolor = {0, 0, 0, 1},
|
||||
}
|
||||
)
|
||||
_detalhes.gump:InstallTemplate ("button", "DETAILS_PLUGINPANEL_BUTTONSELECTED_TEMPLATE",
|
||||
{
|
||||
backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
|
||||
backdropcolor = {0, 0, 0, .5},
|
||||
backdropbordercolor = {1, 1, 0, 1},
|
||||
}
|
||||
)
|
||||
|
||||
function f.OnMenuClick (_, _, pluginAbsName, callRefresh)
|
||||
|
||||
--> get the plugin
|
||||
local pluginObject = _detalhes:GetPlugin (pluginAbsName)
|
||||
if (not pluginObject) then
|
||||
for index, plugin in ipairs (f.EmbedPlugins) do
|
||||
if (plugin.real_name == pluginAbsName) then
|
||||
pluginObject = plugin
|
||||
end
|
||||
end
|
||||
|
||||
if (not pluginObject) then
|
||||
f.DebugMsg ("Plugin not found")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--> hide or show plugin windows
|
||||
for index, plugin in ipairs (f.EmbedPlugins) do
|
||||
if (plugin ~= pluginObject) then
|
||||
--> hide this plugin
|
||||
if (plugin.Frame:IsShown()) then
|
||||
plugin.Frame:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--> re set the point of the frame within the main plugin window
|
||||
f.RefreshFrame (pluginObject.__var_Frame)
|
||||
C_Timer.After (0.016, function ()
|
||||
f.RefreshFrame (pluginObject.__var_Frame)
|
||||
end)
|
||||
|
||||
--> show the plugin window
|
||||
if (pluginObject.RefreshWindow and callRefresh) then
|
||||
local okay, errortext = pcall (pluginObject.RefreshWindow)
|
||||
if (not okay) then
|
||||
f.DebugMsg (errortext)
|
||||
end
|
||||
end
|
||||
|
||||
--> highlight the plugin button on the menu
|
||||
for index, button in ipairs (f.MenuButtons) do
|
||||
button:Show()
|
||||
|
||||
if (button.PluginAbsName == pluginAbsName) then
|
||||
--> emphatizate this button
|
||||
button:SetTemplate (_detalhes.gump:GetTemplate ("button", "DETAILS_PLUGINPANEL_BUTTONSELECTED_TEMPLATE"))
|
||||
else
|
||||
--> make this button regular
|
||||
button:SetTemplate (_detalhes.gump:GetTemplate ("button", "DETAILS_PLUGINPANEL_BUTTON_TEMPLATE"))
|
||||
end
|
||||
end
|
||||
|
||||
--> show the container
|
||||
f:Show()
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function f.CreatePluginMenuButton (pluginObject, isUtility)
|
||||
--> create the button
|
||||
local newButton = _detalhes.gump:CreateButton (f, f.OnMenuClick, f.MenuButtonWidth, f.MenuButtonHeight, pluginObject.__name, pluginObject.real_name, true)
|
||||
newButton.PluginAbsName = pluginObject.real_name
|
||||
newButton.PluginName = pluginObject.__name
|
||||
newButton.IsUtility = isUtility
|
||||
|
||||
--> add a template
|
||||
newButton:SetTemplate (_detalhes.gump:GetTemplate ("button", "DETAILS_PLUGINPANEL_BUTTON_TEMPLATE"))
|
||||
newButton:SetText (pluginObject.__name)
|
||||
newButton.textsize = 10
|
||||
|
||||
--> set icon
|
||||
newButton:SetIcon (pluginObject.__icon)
|
||||
|
||||
--> add it to menu table
|
||||
tinsert (f.MenuButtons, newButton)
|
||||
|
||||
return newButton
|
||||
end
|
||||
|
||||
local on_hide = function (self)
|
||||
DetailsPluginContainerWindow.ClosePlugin()
|
||||
end
|
||||
|
||||
function f.RefreshFrame (frame)
|
||||
frame:EnableMouse (false)
|
||||
frame:SetSize (f.FrameWidth, f.FrameHeight)
|
||||
frame:SetScript ("OnMouseDown", nil)
|
||||
frame:SetScript ("OnMouseUp", nil)
|
||||
--frame:SetScript ("OnHide", on_hide)
|
||||
frame:HookScript ("OnHide", on_hide)
|
||||
frame:ClearAllPoints()
|
||||
frame:SetPoint ("topleft", f, "topleft", 0, 0)
|
||||
frame:Show()
|
||||
end
|
||||
|
||||
--> a plugin request to be embed into the main plugin window
|
||||
function f.EmbedPlugin (pluginObject, frame, isUtility)
|
||||
--> check if the plugin has a frame
|
||||
if (not pluginObject.Frame) then
|
||||
f.DebugMsg ("plugin doesn't have a frame.")
|
||||
return
|
||||
end
|
||||
|
||||
--> create a button for this plugin
|
||||
local newMenuButtom = f.CreatePluginMenuButton (pluginObject, isUtility)
|
||||
|
||||
--> utility is true when the object isn't a real plugin, but instead a tool frame from the main addon being embed on this panel
|
||||
if (isUtility) then
|
||||
pluginObject.__var_Utility = true
|
||||
end
|
||||
pluginObject.__var_Frame = frame
|
||||
|
||||
--> sort buttons alphabetically, put utilities at the end
|
||||
table.sort (f.MenuButtons, function (t1, t2)
|
||||
if (t1.IsUtility) then
|
||||
return false
|
||||
elseif (t2.IsUtility) then
|
||||
return true
|
||||
else
|
||||
return t1.PluginName < t2.PluginName
|
||||
end
|
||||
end)
|
||||
|
||||
--> reset the buttons points
|
||||
local addingTools = false
|
||||
for index, button in ipairs (f.MenuButtons) do
|
||||
button:ClearAllPoints()
|
||||
button:SetPoint ("center", menuBackground, "center")
|
||||
|
||||
if (button.IsUtility) then
|
||||
--> add -20 to add a gap between plugins and utilities
|
||||
|
||||
if (not addingTools) then
|
||||
--> add the header
|
||||
addingTools = true
|
||||
titlebar_tools:SetPoint ("topleft", menuBackground, "topleft", 2, f.MenuY + ( (index-1) * -f.MenuButtonHeight ) - index - 20)
|
||||
titlebar_tools:SetPoint ("topright", menuBackground, "topright", -2, f.MenuY + ( (index-1) * -f.MenuButtonHeight ) - index - 20)
|
||||
end
|
||||
|
||||
button:SetPoint ("top", menuBackground, "top", 0, f.MenuY + ( (index-1) * -f.MenuButtonHeight ) - index - 40)
|
||||
else
|
||||
button:SetPoint ("top", menuBackground, "top", 0, f.MenuY + ( (index-1) * -f.MenuButtonHeight ) - index)
|
||||
end
|
||||
end
|
||||
|
||||
--> format the plugin main frame
|
||||
f.RefreshFrame (frame)
|
||||
--> add the plugin to embed table
|
||||
tinsert (f.EmbedPlugins, pluginObject)
|
||||
|
||||
f.DebugMsg ("plugin added", pluginObject.__name)
|
||||
end
|
||||
|
||||
function f.OpenPlugin (pluginObject)
|
||||
--> just simulate a click on the menu button
|
||||
f.OnMenuClick (_, _, pluginObject.real_name)
|
||||
end
|
||||
|
||||
function f.ClosePlugin()
|
||||
--> hide all embed plugins
|
||||
for index, plugin in ipairs (f.EmbedPlugins) do
|
||||
plugin.Frame:Hide()
|
||||
end
|
||||
--> hide the main frame
|
||||
f:Hide()
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--stop auto complete: doe enda endb
|
||||
Reference in New Issue
Block a user