You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

280 lines
9.0 KiB

4 years ago
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
local _detalhes = _G.Details
3 years ago
local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" )
4 years ago
local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
local _
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
--local pointers
4 years ago
-- none
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
--details api functions
4 years ago
3 years ago
--create a button which will be displayed on tooltip
4 years ago
function _detalhes.ToolBar:NewPluginToolbarButton (func, icon, pluginname, tooltip, w, h, framename, menu_function)
3 years ago
--random name if nameless
4 years ago
if (not framename) then
3 years ago
framename = "DetailsToolbarButton" .. math.random(1, 100000)
4 years ago
end
3 years ago
--create button from template
local button = CreateFrame("button", framename, _detalhes.listener, "DetailsToolbarButton")
4 years ago
3 years ago
--sizes
4 years ago
if (w) then
3 years ago
button:SetWidth(w)
4 years ago
end
if (h) then
3 years ago
button:SetHeight(h)
4 years ago
end
button.x = 0
button.y = 0
3 years ago
--tooltip and function on click
4 years ago
button.tooltip = tooltip
button.menu = menu_function
3 years ago
button:SetScript("OnClick", func)
4 years ago
3 years ago
--textures
button:SetNormalTexture(icon)
button:SetPushedTexture(icon)
button:SetDisabledTexture(icon)
button:SetHighlightTexture(icon, "ADD")
4 years ago
button.__icon = icon
button.__name = pluginname
3 years ago
--blizzard built-in animation
--local FourCornerAnimeFrame = CreateFrame("frame", framename.."Blink", button) --, "IconIntroAnimTemplate" --stop using 'IconIntroAnimTemplate' as older versions of the game doesn't have it
--FourCornerAnimeFrame:SetPoint("center", button)
--FourCornerAnimeFrame:SetWidth(w or 14)
--FourCornerAnimeFrame:SetHeight(w or 14)
--FourCornerAnimeFrame.glow:SetScript("OnFinished", nil)
--button.blink = FourCornerAnimeFrame
4 years ago
_detalhes.ToolBar.AllButtons [#_detalhes.ToolBar.AllButtons+1] = button
return button
end
3 years ago
--show your plugin icon on tooltip
4 years ago
function _detalhes:ShowToolbarIcon (Button, Effect)
local LastIcon
3 years ago
--get the lower number instance
4 years ago
local lower_instance = _detalhes:GetLowerInstanceNumber()
if (not lower_instance) then
return
end
3 years ago
local instance = _detalhes:GetInstance(lower_instance)
4 years ago
if (#_detalhes.ToolBar.Shown > 0) then
3 years ago
--already shown
4 years ago
if (_detalhes:tableIN (_detalhes.ToolBar.Shown, Button)) then
return
end
LastIcon = _detalhes.ToolBar.Shown [#_detalhes.ToolBar.Shown]
else
LastIcon = instance.baseframe.cabecalho.report
end
_detalhes.ToolBar.Shown [#_detalhes.ToolBar.Shown+1] = Button
3 years ago
Button:SetPoint("left", LastIcon.widget or LastIcon, "right", Button.x, Button.y)
4 years ago
Button:Show()
if (instance.auto_hide_menu.left and not instance.is_interacting) then
instance:ToolbarMenuButtons()
3 years ago
Button:SetAlpha(0)
4 years ago
return
end
if (Effect) then
3 years ago
if (type(Effect) == "string") then
4 years ago
if (Effect == "blink") then
3 years ago
--Button.blink.glow:Play() --.blink and .glow doesn't exists anymore due to removal of the template 'IconIntroAnimTemplate'
4 years ago
elseif (Effect == "star") then
3 years ago
--Button.StarAnim:Play()
4 years ago
end
elseif (Effect) then
3 years ago
--Button.blink.glow:Play()
4 years ago
end
end
_detalhes.ToolBar:ReorganizeIcons (true)
return true
end
3 years ago
--hide your plugin icon from toolbar
4 years ago
function _detalhes:HideToolbarIcon (Button)
local index = _detalhes:tableIN (_detalhes.ToolBar.Shown, Button)
if (not index) then
3 years ago
--current not shown
4 years ago
return
end
Button:Hide()
table.remove (_detalhes.ToolBar.Shown, index)
3 years ago
--reorganize icons
4 years ago
_detalhes.ToolBar:ReorganizeIcons (true)
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
--internal functions
4 years ago
do
3 years ago
local PluginDescPanel = CreateFrame("frame", "DetailsPluginDescPanel", UIParent)
PluginDescPanel:SetFrameStrata("tooltip")
4 years ago
PluginDescPanel:Hide()
3 years ago
PluginDescPanel:SetWidth(205)
4 years ago
PluginDescPanel.BackdropTable = {}
3 years ago
local background = PluginDescPanel:CreateTexture(nil, "artwork")
background:SetPoint("topleft", 0, 0)
background:SetPoint("bottomright", 0, 0)
4 years ago
PluginDescPanel.background = background
3 years ago
local icon, title, desc = PluginDescPanel:CreateTexture(nil, "overlay"), PluginDescPanel:CreateFontString(nil, "overlay", "GameFontNormal"), PluginDescPanel:CreateFontString(nil, "overlay", "GameFontNormal")
icon:SetPoint("topleft", 10, -10)
icon:SetSize(16, 16)
title:SetPoint("left", icon, "right", 2, 0)
desc:SetPoint("topleft", 13, -30)
desc:SetWidth(180)
desc:SetJustifyH("left")
_detalhes:SetFontColor(desc, "white")
4 years ago
PluginDescPanel.icon = icon
PluginDescPanel.title = title
PluginDescPanel.desc = desc
end
--[[global]] function DetailsToolbarButtonOnEnter (button)
local lower_instance = _detalhes:GetLowerInstanceNumber()
if (lower_instance) then
3 years ago
_detalhes.OnEnterMainWindow(_detalhes:GetInstance(lower_instance), button, 3)
4 years ago
end
if (button.tooltip) then
if (button.menu) then
3 years ago
_detalhes.gump:QuickDispatch(button.menu)
4 years ago
local next_check = 0.8
--check if the mouse is still interacting with the menu or with the button
3 years ago
button:SetScript("OnUpdate", function(self, elapsed)
4 years ago
next_check = next_check - elapsed
if (next_check < 0) then
if (not GameCooltipFrame1:IsMouseOver() and not button:IsMouseOver()) then
GameCooltip2:Hide()
3 years ago
button:SetScript("OnUpdate", nil)
4 years ago
return
end
next_check = 0.8
end
end)
--disable the hider menu if the cooltip is required in another place
hooksecurefunc (GameCooltip2, "ShowCooltip", function()
3 years ago
button:SetScript("OnUpdate", nil)
4 years ago
end)
return
end
GameCooltip:Hide()
local plugin_object = _detalhes:GetPlugin (button.__name)
local f = DetailsPluginDescPanel
3 years ago
f.icon:SetTexture(button.__icon)
f.title:SetText(button.__name)
f.desc:SetText(plugin_object:GetPluginDescription())
_detalhes:SetFontSize(f.desc, _detalhes.font_sizes.menus)
4 years ago
_detalhes:SetFontFace (f.desc, _detalhes.font_faces.menus)
3 years ago
--f.background:SetTexture(_detalhes.tooltip.menus_bg_texture)
f.background:SetTexCoord(unpack(_detalhes.tooltip.menus_bg_coords))
f.background:SetVertexColor(unpack(_detalhes.tooltip.menus_bg_color))
--f.background:SetDesaturated(true)
4 years ago
f.BackdropTable.bgFile = _detalhes.tooltip_backdrop.bgFile
f.BackdropTable.edgeFile = [[Interface\Buttons\WHITE8X8]] --_detalhes.tooltip_backdrop.edgeFile
f.BackdropTable.tile = _detalhes.tooltip_backdrop.tile
f.BackdropTable.edgeSize = 1 --_detalhes.tooltip_backdrop.edgeSize
f.BackdropTable.tileSize = _detalhes.tooltip_backdrop.tileSize
3 years ago
f:SetBackdrop(f.BackdropTable)
local r, g, b, a = _detalhes.gump:ParseColors(_detalhes.tooltip_border_color)
f:SetBackdropBorderColor(r, g, b, a)
4 years ago
3 years ago
f:SetHeight(40 + f.desc:GetStringHeight())
f:SetPoint("bottom", button, "top", 0, 10)
4 years ago
f:Show()
--SharedMedia:Fetch ("font", "Friz Quadrata TT")
end
end
--[[global]] function DetailsToolbarButtonOnLeave (button)
local lower_instance = _detalhes:GetLowerInstanceNumber()
if (lower_instance) then
3 years ago
_detalhes.OnLeaveMainWindow(_detalhes:GetInstance(lower_instance), button, 3)
4 years ago
end
if (button.tooltip) then
DetailsPluginDescPanel:Hide()
end
end
_detalhes:RegisterEvent(_detalhes.ToolBar, "DETAILS_INSTANCE_OPEN", "OnInstanceOpen")
_detalhes:RegisterEvent(_detalhes.ToolBar, "DETAILS_INSTANCE_CLOSE", "OnInstanceClose")
3 years ago
_detalhes.ToolBar.Enabled = true --must have this member or wont receive the event
4 years ago
_detalhes.ToolBar.__enabled = true
function _detalhes.ToolBar:OnInstanceOpen()
_detalhes.ToolBar:ReorganizeIcons (true)
end
function _detalhes.ToolBar:OnInstanceClose()
_detalhes.ToolBar:ReorganizeIcons (true)
end
function _detalhes.ToolBar:ReorganizeIcons (just_refresh)
3 years ago
--get the lower number instance
4 years ago
local lower_instance = _detalhes:GetLowerInstanceNumber()
if (not lower_instance) then
3 years ago
for _, ThisButton in ipairs(_detalhes.ToolBar.Shown) do
4 years ago
ThisButton:Hide()
end
return
end
3 years ago
local instance = _detalhes:GetInstance(lower_instance)
4 years ago
if (not just_refresh) then
3 years ago
for _, instancia in pairs(_detalhes.tabela_instancias) do
4 years ago
if (instancia.baseframe and instancia:IsAtiva()) then
instancia:ReajustaGump()
end
end
instance:ChangeSkin()
else
instance:ToolbarMenuButtons()
3 years ago
instance:SetAutoHideMenu(nil, nil, true)
4 years ago
end
return true
end