/trunk/FuBar_RecapFu/libs/FuBarPlugin-2.0
--[[ |
--[[ |
Name: FuBarPlugin-2.0 |
Revision: $Rev: 29795 $ |
Revision: $Rev: 9 $ |
Author: Cameron Kenneth Knight (ckknight@gmail.com) |
Website: http://wiki.wowace.com/index.php/FuBarPlugin-2.0 |
Documentation: http://wiki.wowace.com/index.php/FuBarPlugin-2.0 |
SVN: svn://svn.wowace.com/root/branches/FuBar/FuBarPlugin-2.0/FuBarPlugin-2.0/ |
SVN: svn://svn.wowace.com/wowace/trunk/FuBarPlugin-2.0/FuBarPlugin-2.0/ |
Description: Plugin for FuBar. |
Dependencies: AceLibrary, AceOO-2.0, AceEvent-2.0, Tablet-2.0, Dewdrop-2.0 |
Dependencies: AceLibrary, AceOO-2.0, AceEvent-2.0, (optional) Tablet-2.0, Dewdrop-2.0 |
License: LGPL v2.1 |
Notes: When embeding this library, FuBar should be set as an optional dependency. |
]] |
local MAJOR_VERSION = "FuBarPlugin-2.0" |
local MINIMAPCONTAINER_MAJOR_VERSION = "FuBarPlugin-MinimapContainer-2.0" |
local MINOR_VERSION = "$Revision: 29795 $" |
local MINOR_VERSION = 90000 + tonumber(("$Revision: 9 $"):match("(%d+)")) |
-- This ensures the code is only executed if the libary doesn't already exist, or is a newer version |
if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary.") end |
local AceEvent = AceLibrary:HasInstance("AceEvent-2.0") and AceLibrary("AceEvent-2.0") |
local Tablet = AceLibrary:HasInstance("Tablet-2.0") and AceLibrary("Tablet-2.0") |
local Dewdrop = AceLibrary:HasInstance("Dewdrop-2.0") and AceLibrary("Dewdrop-2.0") |
local AceAddon |
local epsilon = 1e-5 |
local _G = getfenv(0) |
CLOSE_DESC = "Ferme le menu." |
elseif GetLocale() == "zhCN" then |
SHOW_ICON = "æ¾ç¤ºå¾æ " |
SHOW_ICON_DESC = "å¨é¢æ¿ä¸æ¾ç¤ºæ件å¾æ ." |
SHOW_ICON_DESC = "å¨é¢æ¿ä¸æ¾ç¤ºæ件å¾æ ã" |
SHOW_TEXT = "æ¾ç¤ºæå" |
SHOW_TEXT_DESC = "å¨é¢æ¿ä¸æ¾ç¤ºæåæ é¢." |
SHOW_TEXT_DESC = "å¨é¢æ¿ä¸æ¾ç¤ºæåæ é¢ã" |
SHOW_COLORED_TEXT = "æ¾ç¤ºå½©è²æå" |
SHOW_COLORED_TEXT_DESC = "å 许æ件æ¾ç¤ºå½©è²æå." |
SHOW_COLORED_TEXT_DESC = "å 许æ件æ¾ç¤ºå½©è²æåã" |
DETACH_TOOLTIP = "ç¬ç«æ示信æ¯" |
DETACH_TOOLTIP_DESC = "ä»é¢æ¿ä¸ç¬ç«æ示信æ¯." |
DETACH_TOOLTIP_DESC = "ä»é¢æ¿ä¸ç¬ç«æ示信æ¯ã" |
LOCK_TOOLTIP = "éå®æ示信æ¯" |
LOCK_TOOLTIP_DESC = "éå®æ示信æ¯ä½ç½®." |
LOCK_TOOLTIP_DESC = "éå®æ示信æ¯ä½ç½®ã" |
POSITION = "ä½ç½®" |
POSITION_DESC = "æ件å¨é¢æ¿ä¸çä½ç½®." |
POSITION_DESC = "æ件å¨é¢æ¿ä¸çä½ç½®ã" |
POSITION_LEFT = "å± å·¦" |
POSITION_RIGHT = "å± å³" |
POSITION_CENTER = "å± ä¸" |
ATTACH_TO_MINIMAP = "ä¾éå¨å°å°å¾" |
ATTACH_TO_MINIMAP_DESC = "æ件å¾æ ä¾éå¨å°å°å¾èä¸æ¾ç¤ºå¨é¢æ¿ä¸." |
HIDE_FUBAR_PLUGIN = "éèFuBaræ件" |
HIDE_FUBAR_PLUGIN_CMD = "Hidden" |
HIDE_FUBAR_PLUGIN_DESC = "å¨é¢æ¿ä¸éè该æ件." |
ATTACH_TO_MINIMAP_DESC = "æ件å¾æ ä¾éå¨å°å°å¾èä¸æ¾ç¤ºå¨é¢æ¿ä¸ã" |
HIDE_FUBAR_PLUGIN = "éè FuBar æ件" |
HIDE_FUBAR_PLUGIN_CMD = "éè" |
HIDE_FUBAR_PLUGIN_DESC = "å¨é¢æ¿ä¸éè该æ件ã" |
OTHER = "å ¶ä»" |
CLOSE = "å ³é" |
CLOSE_DESC = "å ³éèå" |
elseif GetLocale() == "zhTW" then |
SHOW_ICON = "顯示å示" |
SHOW_ICON_DESC = "å¨é¢æ¿ä¸é¡¯ç¤ºæ件å示ã" |
SHOW_TEXT = "顯示æå" |
SHOW_TEXT_DESC = "å¨é¢æ¿ä¸é¡¯ç¤ºæåæ¨é¡ã" |
SHOW_COLORED_TEXT = "顯示彩è²æå" |
SHOW_COLORED_TEXT_DESC = "å 許æ件顯示彩è²æåã" |
SHOW_TEXT_DESC = "å¨é¢æ¿ä¸é¡¯ç¤ºæ件æåã" |
SHOW_COLORED_TEXT = "å 許彩è²æå" |
SHOW_COLORED_TEXT_DESC = "å 許æ件å¨é¢æ¿ä¸ä½¿ç¨å½©è²æåã" |
DETACH_TOOLTIP = "ç¨ç«æ示è¨æ¯" |
DETACH_TOOLTIP_DESC = "å¾é¢æ¿ä¸ç¨ç«æ示è¨æ¯ã" |
LOCK_TOOLTIP = "éå®æ示è¨æ¯" |
LOCK_TOOLTIP_DESC = "éå®æ示è¨æ¯ä½ç½®ã" |
LOCK_TOOLTIP_DESC = "éå®æ示è¨æ¯ä½ç½®ãç¶æ示è¨æ¯éå®æï¼éè¦ç¨Altéµä½¿ç¨æ示è¨æ¯çåè½ã" |
POSITION = "ä½ç½®" |
POSITION_DESC = "æ件å¨é¢æ¿ä¸çä½ç½®ã" |
POSITION_LEFT = "é å·¦" |
POSITION_CENTER = "ç½®ä¸" |
ATTACH_TO_MINIMAP = "ä¾éå¨å°å°å" |
ATTACH_TO_MINIMAP_DESC = "æ件åæ¨ä¾éå¨å°å°åèä¸é¡¯ç¤ºå¨é¢æ¿ä¸ã" |
HIDE_FUBAR_PLUGIN = "é±èFuBaræ件" |
HIDE_FUBAR_PLUGIN_CMD = "Hidden" |
HIDE_FUBAR_PLUGIN_DESC = "å¨é¢æ¿ä¸é±è該æ件." |
HIDE_FUBAR_PLUGIN = "é±èæ件" |
HIDE_FUBAR_PLUGIN_CMD = "é±è" |
HIDE_FUBAR_PLUGIN_DESC = "å¨é¢æ¿æå°å°åä¸é±è該æ件ï¼ä½ä¿æå·è¡çæ ã" |
OTHER = "å ¶ä»" |
CLOSE = "éé" |
CLOSE_DESC = "ééé¸å®ã" |
elseif GetLocale() == "esES" then |
SHOW_ICON = "Mostrar icono" |
SHOW_ICON_DESC = "Muestra el icono del plugin en el panel" |
OTHER = "Otros" |
CLOSE = "Cerrar" |
CLOSE_DESC = "Cierra el men\195\186." |
elseif GetLocale() == "ruRU" then |
SHOW_ICON = "ÐоказÑваÑÑ Ð¸ÐºÐ¾Ð½ÐºÑ" |
SHOW_ICON_DESC = "ÐоказÑваÑÑ Ð¸ÐºÐ¾Ð½ÐºÑ Ð¿Ð»Ð°Ð³Ð¸Ð½Ð° на панели." |
SHOW_TEXT = "ÐоказÑваÑÑ ÑекÑÑ" |
SHOW_TEXT_DESC = "ÐоказÑваÑÑ ÑекÑÑ Ð¿Ð»Ð°Ð³Ð¸Ð½Ð° на панели." |
SHOW_COLORED_TEXT = "ÐоказÑваÑÑ ÑвеÑной ÑекÑÑ" |
SHOW_COLORED_TEXT_DESC = "ÐозволиÑÑ Ð¿Ð»Ð°Ð³Ð¸Ð½Ñ Ð¸ÑполÑзоваÑÑ ÐµÐ³Ð¾ ÑвеÑа в ÑекÑÑе." |
DETACH_TOOLTIP = "ÐÑделиÑÑ Ð¿Ð¾Ð´ÑказкÑ" |
DETACH_TOOLTIP_DESC = "ÐÑделиÑÑ Ð²ÑплÑваÑÑÑÑ Ð¿Ð¾Ð´ÑÐºÐ°Ð·ÐºÑ Ð¾Ñ Ð¿Ð°Ð½ÐµÐ»Ð¸." |
LOCK_TOOLTIP = "ÐакÑепиÑÑ Ð¿Ð¾Ð´ÑказкÑ" |
LOCK_TOOLTIP_DESC = "ÐакÑепиÑÑ Ð¿Ð¾Ð·Ð¸ÑÐ¸Ñ Ð²ÑплÑваÑÑей подÑказки. Ðогда вÑплÑваÑÑÐ°Ñ Ð¿Ð¾Ð´Ñказка закÑеплена, иÑполÑзÑйÑе Alt Ð´Ð»Ñ Ð¾ÑобÑÐ°Ð¶ÐµÐ½Ð¸Ñ ÐµÐµ Ñ Ð¼ÑÑи." |
POSITION = "ÐозиÑиÑ" |
POSITION_DESC = "ÐозиÑÐ¸Ñ Ð¿Ð»Ð°Ð³Ð¸Ð½Ð° на панели." |
POSITION_LEFT = "Слева" |
POSITION_RIGHT = "СпÑава" |
POSITION_CENTER = "Ðо ÑенÑÑÑ" |
ATTACH_TO_MINIMAP = "ÐакÑепиÑÑ Ñ Ð¼Ð¸Ð½Ð¸-каÑÑÑ" |
ATTACH_TO_MINIMAP_DESC = "ÐакÑепиÑÑ Ð¿Ð»Ð°Ð³Ð¸Ð½ Ñ Ð¼Ð¸Ð½Ð¸-каÑÑÑ, вмеÑÑо панели." |
HIDE_FUBAR_PLUGIN = "СкÑÑÑÑ Ð¿Ð»Ð°Ð³Ð¸Ð½" |
HIDE_FUBAR_PLUGIN_CMD = "СкÑÑÑÑ" |
HIDE_FUBAR_PLUGIN_DESC = "СкÑÑÑÑ Ð¿Ð»Ð°Ð³Ð¸Ð½ Ñ Ð¿Ð°Ð½ÐµÐ»Ð¸ или мини-каÑÑÑ, но оÑÑавиÑÑ Ð°Ð´Ð´Ð¾Ð½ в ÑабоÑем ÑоÑÑоÑнии." |
OTHER = "ÐÑÑгое" |
CLOSE = "ÐакÑÑÑÑ" |
CLOSE_DESC = "ÐакÑÑÑÑ Ð¼ÐµÐ½Ñ." |
end |
local AceOO = AceLibrary("AceOO-2.0") |
local FuBarPlugin = AceOO.Mixin { |
"GetTitle", |
"GetName", |
"GetCategory", |
"SetFontSize", |
"GetFrame", |
"Show", |
"Hide", |
"GetPanel", |
"IsTextColored", |
"ToggleTextColored", |
"IsMinimapAttached", |
"ToggleMinimapAttached", |
"Update", |
"UpdateDisplay", |
"UpdateData", |
"UpdateText", |
"UpdateTooltip", |
"SetIcon", |
"GetIcon", |
"CheckWidth", |
"SetText", |
"GetText", |
"IsIconShown", |
"ToggleIconShown", |
"ShowIcon", |
"HideIcon", |
"IsTextShown", |
"ToggleTextShown", |
"ShowText", |
"HideText", |
"IsTooltipDetached", |
"ToggleTooltipDetached", |
"DetachTooltip", |
"ReattachTooltip", |
"GetDefaultPosition", |
"SetPanel", |
"IsLoadOnDemand", |
"IsDisabled", |
"CreateBasicPluginFrame", |
"CreatePluginChildFrame", |
"OpenMenu", |
"AddImpliedMenuOptions", |
} |
"GetTitle", |
"GetName", |
"GetCategory", |
"SetFontSize", |
"GetFrame", |
"Show", |
"Hide", |
"GetPanel", |
"IsTextColored", |
"ToggleTextColored", |
"IsMinimapAttached", |
"ToggleMinimapAttached", |
"Update", |
"UpdateDisplay", |
"UpdateData", |
"UpdateText", |
"UpdateTooltip", |
"SetIcon", |
"GetIcon", |
"CheckWidth", |
"SetText", |
"GetText", |
"IsIconShown", |
"ToggleIconShown", |
"ShowIcon", |
"HideIcon", |
"IsTextShown", |
"ToggleTextShown", |
"ShowText", |
"HideText", |
"IsTooltipDetached", |
"ToggleTooltipDetached", |
"DetachTooltip", |
"ReattachTooltip", |
"GetDefaultPosition", |
"SetPanel", |
"IsLoadOnDemand", |
"IsDisabled", |
"CreateBasicPluginFrame", |
"CreatePluginChildFrame", |
"OpenMenu", |
"AddImpliedMenuOptions", |
} |
local MinimapContainer |
local good = nil |
local function CheckFuBar() |
if self.panel then |
self.panel:RemovePlugin(self) |
end |
FuBar:GetPanel(1):AddPlugin(self, nil, self.defaultPosition) |
if self.defaultPosition == "MINIMAP" then |
FuBar:GetPanel(1):AddPlugin(self, nil, "LEFT") |
else |
FuBar:GetPanel(1):AddPlugin(self, nil, self.defaultPosition) |
end |
else |
if self.panel then |
self.panel:RemovePlugin(self) |
end |
AceLibrary(MINIMAPCONTAINER_MAJOR_VERSION):AddPlugin(self) |
MinimapContainer:AddPlugin(self) |
end |
end |
Dewdrop:Close() |
if not CheckFuBar() then |
return true |
end |
return self.panel == AceLibrary(MINIMAPCONTAINER_MAJOR_VERSION) |
return self.panel == MinimapContainer |
end |
function FuBarPlugin:Update() |
end |
function FuBarPlugin:RegisterTablet() |
if self.blizzardTooltip or self.overrideTooltip or not Tablet then |
return |
end |
if not Tablet:IsRegistered(self.frame) then |
if self.db and self.db.profile and not self.db.profile.detachedTooltip then |
self.db.profile.detachedTooltip = {} |
'hideWhenEmpty', self.tooltipHiddenWhenEmpty |
) |
local func = self.frame:GetScript("OnEnter") |
local function newFunc(...) |
func(...) |
local function newFunc(this, ...) |
func(this, ...) |
if FuBar and FuBar.IsHidingTooltipsInCombat and FuBar:IsHidingTooltipsInCombat() and InCombatLockdown() then |
local frame = this.self.frame |
if Tablet:IsAttached(frame) then |
if self.blizzardTooltip then |
if GameTooltip:IsOwned(self:IsMinimapAttached() and self.minimapFrame or self.frame) then |
GameTooltip:Hide() |
end |
elseif self.overrideTooltip and type(self.CloseTooltip) == "function" then |
self:CloseTooltip() |
elseif not self.overrideTooltip and Tablet and Tablet:IsAttached(frame) then |
Tablet:Close(frame) |
end |
end |
end |
function FuBarPlugin:UpdateTooltip() |
if self.blizzardTooltip then |
if GameTooltip:IsOwned(self:IsMinimapAttached() and self.minimapFrame or self.frame) then |
GameTooltip:Hide() |
local frame = self:IsMinimapAttached() and self.minimapFrame or self.frame |
local anchor |
if frame:GetTop() > GetScreenHeight() / 2 then |
local x = frame:GetCenter() |
if x < GetScreenWidth() / 2 then |
anchor = "ANCHOR_BOTTOMRIGHT" |
else |
anchor = "ANCHOR_BOTTOMLEFT" |
end |
else |
local x = frame:GetCenter() |
if x < GetScreenWidth() / 2 then |
anchor = "ANCHOR_TOPLEFT" |
else |
anchor = "ANCHOR_TOPRIGHT" |
end |
end |
GameTooltip:SetOwner(frame, anchor) |
if type(self.OnTooltipUpdate) == "function" and not self:IsDisabled() then |
self:OnTooltipUpdate() |
end |
GameTooltip:Show() |
end |
return |
elseif self.overrideTooltip then |
if type(self.OnTooltipUpdate) == "function" and not self:IsDisabled() then |
self:OnTooltipUpdate() |
end |
return |
end |
if not Tablet then return end |
FuBarPlugin.RegisterTablet(self) |
if self:IsMinimapAttached() and not self:IsTooltipDetached() and self.minimapFrame then |
Tablet:Refresh(self.minimapFrame) |
end |
elseif not self.db or not self.db.profile.hidden then |
if panelId == 0 or not CheckFuBar() then |
AceLibrary(MINIMAPCONTAINER_MAJOR_VERSION):AddPlugin(self) |
MinimapContainer:AddPlugin(self) |
else |
FuBar:ShowPlugin(self, panelId or self.panelIdTmp) |
end |
end |
end |
if AceOO.inherits(self, "AceAddon-2.0") then |
local AceAddon = AceLibrary("AceAddon-2.0") |
if not AceAddon then |
AceAddon = AceLibrary("AceAddon-2.0") |
end |
if AceAddon.addonsEnabled and not AceAddon.addonsEnabled[self] then |
return |
end |
self.db.profile.hidden = true |
end |
if not self.hideWithoutStandby then |
if self.db and not self.overrideTooltip and not self.cannotDetachTooltip and self:IsTooltipDetached() and self.db.profile.detachedTooltip and self.db.profile.detachedTooltip.detached then |
if self.db and not self.overrideTooltip and not self.blizzardTooltip and not self.cannotDetachTooltip and self:IsTooltipDetached() and self.db.profile.detachedTooltip and self.db.profile.detachedTooltip.detached then |
self:ReattachTooltip() |
self.db.profile.detachedTooltip.detached = true |
end |
end |
function FuBarPlugin:IsTooltipDetached() |
if self.blizzardTooltip or self.overrideTooltip or not Tablet then return end |
FuBarPlugin.RegisterTablet(self) |
return not Tablet:IsAttached(self.frame) |
end |
function FuBarPlugin:ToggleTooltipDetached() |
if self.blizzardTooltip or self.overrideTooltip or not Tablet then return end |
FuBarPlugin.RegisterTablet(self) |
if self:IsTooltipDetached() then |
Tablet:Attach(self.frame) |
end |
function FuBarPlugin:DetachTooltip() |
if self.blizzardTooltip or self.overrideTooltip or not Tablet then return end |
FuBarPlugin.RegisterTablet(self) |
Tablet:Detach(self.frame) |
end |
function FuBarPlugin:ReattachTooltip() |
if self.blizzardTooltip or self.overrideTooltip or not Tablet then return end |
FuBarPlugin.RegisterTablet(self) |
Tablet:Attach(self.frame) |
end |
end |
function FuBarPlugin:IsLoadOnDemand() |
return IsAddOnLoadOnDemand(FuBarPlugin.folderNames[self] or self.folderName) |
local addon = FuBarPlugin.folderNames[self] or self.folderName |
if not addon then |
return |
end |
return IsAddOnLoadOnDemand(addon) |
end |
function FuBarPlugin:IsDisabled() |
function FuBarPlugin:OnInstanceInit(target) |
if not AceEvent then |
self:error(MAJOR_VERSION .. " requires AceEvent-2.0.") |
elseif not Tablet then |
self:error(MAJOR_VERSION .. " requires Tablet-2.0.") |
elseif not Dewdrop then |
self:error(MAJOR_VERSION .. " requires Dewdrop-2.0.") |
end |
self.registry[target] = true |
local folderName = select(3, debugstack(6, 1, 0):find("\\AddOns\\(.*)\\")) |
local folderName |
for i = 6, 3, -1 do |
folderName = debugstack(i, 1, 0):match("\\AddOns\\(.*)\\") |
if folderName then |
break |
end |
end |
target.folderName = folderName |
self.folderNames[target] = folderName |
end |
FuBarPlugin.OnManualEmbed = FuBarPlugin.OnInstanceInit |
local frame_OnClick, frame_OnDoubleClick, frame_OnMouseDown, frame_OnMouseUp, frame_OnReceiveDrag, frame_OnEnter, frame_OnLeave |
function FuBarPlugin:CreateBasicPluginFrame(name) |
local frame = CreateFrame("Button", name, UIParent) |
frame:SetFrameStrata("HIGH") |
frame:SetPoint("CENTER", UIParent, "CENTER") |
frame.self = self |
if not frame_OnEnter then |
function frame_OnEnter() |
if type(this.self.OnEnter) == "function" then |
this.self:OnEnter() |
function frame_OnEnter(this, ...) |
local self = this.self |
if self.blizzardTooltip then |
GameTooltip:SetOwner(self:IsMinimapAttached() and self.minimapFrame or self.frame, "ANCHOR_CURSOR") |
self:UpdateTooltip() |
end |
if type(self.OnEnter) == "function" then |
self:OnEnter(...) |
end |
end |
end |
frame:SetScript("OnEnter", frame_OnEnter) |
if not frame_OnLeave then |
function frame_OnLeave() |
if type(this.self.OnLeave) == "function" then |
this.self:OnLeave() |
function frame_OnLeave(this, ...) |
local self = this.self |
if type(self.OnLeave) == "function" then |
self:OnLeave(...) |
end |
if self.blizzardTooltip and GameTooltip:IsOwned(self:IsMinimapAttached() and self.minimapFrame or self.frame) then |
GameTooltip:Hide() |
end |
end |
end |
frame:SetScript("OnLeave", frame_OnLeave) |
if not frame_OnClick then |
function frame_OnClick() |
function frame_OnClick(this, ...) |
if this.self:IsMinimapAttached() and this.dragged then return end |
if type(this.self.OnClick) == "function" then |
this.self:OnClick(arg1) |
this.self:OnClick(...) |
end |
end |
end |
frame:SetScript("OnClick", frame_OnClick) |
if not frame_OnDoubleClick then |
function frame_OnDoubleClick() |
function frame_OnDoubleClick(this, ...) |
if type(this.self.OnDoubleClick) == "function" then |
this.self:OnDoubleClick(arg1) |
this.self:OnDoubleClick(...) |
end |
end |
end |
frame:SetScript("OnDoubleClick", frame_OnDoubleClick) |
if not frame_OnMouseDown then |
function frame_OnMouseDown() |
if arg1 == "RightButton" and not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then |
function frame_OnMouseDown(this, ...) |
if (...) == "RightButton" and not IsModifierKeyDown() then |
this.self:OpenMenu() |
return |
else |
HideDropDownMenu(1) |
if type(this.self.OnMouseDown) == "function" then |
this.self:OnMouseDown(arg1) |
this.self:OnMouseDown(...) |
end |
end |
end |
end |
frame:SetScript("OnMouseDown", frame_OnMouseDown) |
if not frame_OnMouseUp then |
function frame_OnMouseUp() |
function frame_OnMouseUp(this, ...) |
if type(this.self.OnMouseUp) == "function" then |
this.self:OnMouseUp(arg1) |
this.self:OnMouseUp(...) |
end |
end |
end |
frame:SetScript("OnMouseUp", frame_OnMouseUp) |
if not frame_OnReceiveDrag then |
function frame_OnReceiveDrag() |
if type(this.self.OnReceiveDrag) == "function" then |
this.self:OnReceiveDrag() |
function frame_OnReceiveDrag(this, ...) |
if (this.self:IsMinimapAttached() and not this.dragged) and type(this.self.OnReceiveDrag) == "function" then |
this.self:OnReceiveDrag(...) |
end |
end |
end |
end |
child.self = self |
if not child_OnEnter then |
function child_OnEnter(...) |
function child_OnEnter(this, ...) |
if this.self.frame:GetScript("OnEnter") then |
this.self.frame:GetScript("OnEnter")(...) |
this.self.frame:GetScript("OnEnter")(this, ...) |
end |
end |
end |
child:SetScript("OnEnter", child_OnEnter) |
if not child_OnLeave then |
function child_OnLeave(...) |
function child_OnLeave(this, ...) |
if this.self.frame:GetScript("OnLeave") then |
this.self.frame:GetScript("OnLeave")(...) |
this.self.frame:GetScript("OnLeave")(this, ...) |
end |
end |
end |
child:SetScript("OnLeave", child_OnLeave) |
if child:HasScript("OnClick") then |
if not child_OnClick then |
function child_OnClick(...) |
function child_OnClick(this, ...) |
if this.self.frame:HasScript("OnClick") and this.self.frame:GetScript("OnClick") then |
this.self.frame:GetScript("OnClick")(...) |
this.self.frame:GetScript("OnClick")(this, ...) |
end |
end |
end |
end |
if child:HasScript("OnDoubleClick") then |
if not child_OnDoubleClick then |
function child_OnDoubleClick(...) |
function child_OnDoubleClick(this, ...) |
if this.self.frame:HasScript("OnDoubleClick") and this.self.frame:GetScript("OnDoubleClick") then |
this.self.frame:GetScript("OnDoubleClick")(...) |
this.self.frame:GetScript("OnDoubleClick")(this, ...) |
end |
end |
end |
child:SetScript("OnDoubleClick", child_OnDoubleClick) |
end |
if not child_OnMouseDown then |
function child_OnMouseDown(...) |
function child_OnMouseDown(this, ...) |
if this.self.frame:HasScript("OnMouseDown") and this.self.frame:GetScript("OnMouseDown") then |
this.self.frame:GetScript("OnMouseDown")(...) |
this.self.frame:GetScript("OnMouseDown")(this, ...) |
end |
end |
end |
child:SetScript("OnMouseDown", child_OnMouseDown) |
if not child_OnMouseUp then |
function child_OnMouseUp(...) |
function child_OnMouseUp(this, ...) |
if this.self.frame:HasScript("OnMouseUp") and this.self.frame:GetScript("OnMouseUp") then |
this.self.frame:GetScript("OnMouseUp")(...) |
this.self.frame:GetScript("OnMouseUp")(this, ...) |
end |
end |
end |
child:SetScript("OnMouseUp", child_OnMouseUp) |
if not child_OnReceiveDrag then |
function child_OnReceiveDrag(this) |
function child_OnReceiveDrag(this, ...) |
if this.self.frame:HasScript("OnReceiveDrag") and this.self.frame:GetScript("OnReceiveDrag") then |
this.self.frame:GetScript("OnReceiveDrag")() |
this.self.frame:GetScript("OnReceiveDrag")(this, ...) |
end |
end |
end |
function FuBarPlugin:OpenMenu(frame) |
if not frame then |
frame = self:GetFrame() |
frame = self:IsMinimapAttached() and self.minimapFrame or self.frame |
end |
if not frame:IsVisible() then |
frame = UIParent |
end |
if not frame or not self:GetFrame() or Dewdrop:IsOpen(frame) then |
Dewdrop:Close() |
return |
end |
Tablet:Close() |
if self.blizzardTooltip then |
if GameTooltip:IsOwned(frame) then |
GameTooltip:Hide() |
end |
elseif self.overrideTooltip and type(self.CloseTooltip) == "function" then |
self:CloseTooltip() |
elseif not self.overrideTooltip and Tablet then |
Tablet:Close() |
end |
if not Dewdrop:IsRegistered(self:GetFrame()) then |
if type(self.OnMenuRequest) == "table" and (not self.OnMenuRequest.handler or self.OnMenuRequest.handler == self) and self.OnMenuRequest.type == "group" then |
end |
if frame == self:GetFrame() then |
Dewdrop:Open(self:GetFrame()) |
elseif frame ~= UIParent then |
Dewdrop:Open(frame, self:GetFrame()) |
else |
Dewdrop:Open(frame, self:GetFrame()) |
Dewdrop:Open(frame, self:GetFrame(), 'cursorX', true, 'cursorY', true) |
end |
end |
end |
local recheckPlugins |
local AceConsole |
function FuBarPlugin.OnEmbedEnable(FuBarPlugin, self) |
if not self.userDefinedFrame then |
if self:IsIconShown() then |
if FuBarPlugin.enabledPlugins[self] then |
CheckShow(self, self.panelIdTmp) |
else |
FuBarPlugin:ScheduleEvent(CheckShow, 0, self, self.panelIdTmp) |
FuBarPlugin:ScheduleEvent("FuBarPlugin-CheckShow-" .. tostring(self), CheckShow, 0, self, self.panelIdTmp) |
end |
end |
FuBarPlugin.enabledPlugins[self] = true |
if not self.overrideTooltip and not self.cannotDetachTooltip and self.db and self.db.profile.detachedTooltip and self.db.profile.detachedTooltip.detached then |
FuBarPlugin:ScheduleEvent(self.DetachTooltip, 0, self) |
if not self.blizzardTooltip and not self.overrideTooltip and not self.cannotDetachTooltip and self.db and self.db.profile.detachedTooltip and self.db.profile.detachedTooltip.detached then |
FuBarPlugin:ScheduleEvent("FuBarPlugin-DetachTooltip-" .. tostring(self), self.DetachTooltip, 0, self) |
end |
if self:IsLoadOnDemand() and CheckFuBar() then |
if CheckFuBar() and AceLibrary:HasInstance("AceConsole-2.0") then |
if not recheckPlugins then |
local AceConsole = AceLibrary("AceConsole-2.0") |
local AceOO = AceLibrary("AceOO-2.0") |
function recheckPlugins() |
if not AceConsole then |
AceConsole = AceLibrary("AceConsole-2.0") |
end |
recheckPlugins = function() |
for k,v in pairs(AceConsole.registry) do |
if type(v) == "table" and v.args and AceOO.inherits(v.handler, FuBarPlugin) and not v.handler.independentProfile then |
v.args.profile = nil |
end |
end |
end |
FuBarPlugin:ScheduleEvent(recheckPlugins, 0) |
FuBarPlugin:ScheduleEvent("FuBarPlugin-recheckPlugins", recheckPlugins, 0) |
end |
end |
if not self.db.profile.detachedTooltip then |
self.db.profile.detachedTooltip = {} |
end |
if Tablet.registry[self.frame] then |
Tablet:UpdateDetachedData(self.frame, self.db.profile.detachedTooltip) |
else |
FuBarPlugin.RegisterTablet(self) |
if not self.blizzardTooltip and not self.overrideTooltip and Tablet then |
if Tablet.registry[self.frame] then |
Tablet:UpdateDetachedData(self.frame, self.db.profile.detachedTooltip) |
else |
FuBarPlugin.RegisterTablet(self) |
end |
end |
local MinimapContainer = AceLibrary(MINIMAPCONTAINER_MAJOR_VERSION) |
if MinimapContainer:HasPlugin(self) then |
AceLibrary(MINIMAPCONTAINER_MAJOR_VERSION):ReadjustLocation(self) |
MinimapContainer:ReadjustLocation(self) |
end |
end |
end |
get = "IsTooltipDetached", |
set = "ToggleTooltipDetached", |
hidden = function() |
return self.overrideTooltip or self.cannotDetachTooltip or self:IsDisabled() |
return not Tablet or self.blizzardTooltip or self.overrideTooltip or self.cannotDetachTooltip or self:IsDisabled() |
end, |
order = -13.4, |
handler = self, |
return not self:IsTooltipDetached() |
end, |
hidden = function() |
return self.overrideTooltip or self.cannotDetachTooltip or self:IsDisabled() |
return not Tablet or self.blizzardTooltip or self.overrideTooltip or self.cannotDetachTooltip or self:IsDisabled() |
end, |
order = -13.3, |
handler = self, |
local function external(self, major, instance) |
if major == "AceEvent-2.0" then |
AceEvent = instance |
AceEvent:embed(self) |
elseif major == "Tablet-2.0" then |
Tablet = instance |
AceLibrary:Register(FuBarPlugin, MAJOR_VERSION, MINOR_VERSION, activate, nil, external) |
local MinimapContainer = {} |
MinimapContainer = {} |
local minimap_OnMouseDown, minimap_OnMouseUp |
function MinimapContainer:AddPlugin(plugin) |
if CheckFuBar() and FuBar:IsChangingProfile() then |
return |
if not plugin.minimapFrame then |
local frame = CreateFrame("Button", plugin.frame:GetName() .. "MinimapButton", Minimap) |
plugin.minimapFrame = frame |
AceLibrary(MAJOR_VERSION).RegisterTablet(plugin) |
Tablet:Register(frame, plugin.frame) |
frame.plugin = plugin |
frame:SetWidth(31) |
frame:SetHeight(31) |
icon:SetHeight(20) |
icon:SetPoint("TOPLEFT", frame, "TOPLEFT", 7, -5) |
local overlay = frame:CreateTexture(frame:GetName() .. "Overlay","OVERLAY") |
overlay:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder") |
overlay:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder") |
overlay:SetWidth(53) |
overlay:SetHeight(53) |
overlay:SetPoint("TOPLEFT",frame,"TOPLEFT") |
frame:EnableMouse(true) |
frame:RegisterForClicks("LeftButtonUp") |
frame.plugin = plugin |
frame:SetScript("OnClick", function() |
if type(plugin.OnClick) == "function" then |
if not this.dragged then |
plugin:OnClick(arg1) |
frame.self = plugin |
if not frame_OnEnter then |
function frame_OnEnter(this, ...) |
if type(this.self.OnEnter) == "function" then |
this.self:OnEnter(...) |
end |
end |
end) |
frame:SetScript("OnDoubleClick", function() |
if type(plugin.OnDoubleClick) == "function" then |
plugin:OnDoubleClick(arg1) |
end |
frame:SetScript("OnEnter", frame_OnEnter) |
if not frame_OnLeave then |
function frame_OnLeave(this, ...) |
if type(this.self.OnLeave) == "function" then |
this.self:OnLeave(...) |
end |
end |
end) |
frame:SetScript("OnReceiveDrag", function() |
if type(plugin.OnReceiveDrag) == "function" then |
if not this.dragged then |
plugin:OnReceiveDrag() |
end |
frame:SetScript("OnLeave", frame_OnLeave) |
if not frame_OnClick then |
function frame_OnClick(this, ...) |
if this.self:IsMinimapAttached() and this.dragged then return end |
if type(this.self.OnClick) == "function" then |
this.self:OnClick(...) |
end |
end |
end) |
frame:SetScript("OnMouseDown", function() |
this.dragged = false |
if arg1 == "LeftButton" and not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then |
HideDropDownMenu(1) |
if type(plugin.OnMouseDown) == "function" then |
plugin:OnMouseDown(arg1) |
end |
frame:SetScript("OnClick", frame_OnClick) |
if not frame_OnDoubleClick then |
function frame_OnDoubleClick(this, ...) |
if type(this.self.OnDoubleClick) == "function" then |
this.self:OnDoubleClick(...) |
end |
elseif arg1 == "RightButton" and not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then |
plugin:OpenMenu(frame) |
else |
HideDropDownMenu(1) |
if type(plugin.OnMouseDown) == "function" then |
plugin:OnMouseDown(arg1) |
end |
end |
frame:SetScript("OnDoubleClick", frame_OnDoubleClick) |
if not frame_OnReceiveDrag then |
function frame_OnReceiveDrag(this, ...) |
if (this.self:IsMinimapAttached() and not this.dragged) and type(this.self.OnReceiveDrag) == "function" then |
this.self:OnReceiveDrag(...) |
end |
end |
if plugin.OnClick or plugin.OnMouseDown or plugin.OnMouseUp or plugin.OnDoubleClick then |
if this.plugin.minimapIcon:GetTexture():sub(1, 16) == "Interface\\Icons\\" then |
plugin.minimapIcon:SetTexCoord(0.14, 0.86, 0.14, 0.86) |
end |
frame:SetScript("OnReceiveDrag", frame_OnReceiveDrag) |
if not minimap_OnMouseDown then |
function minimap_OnMouseDown(this, ...) |
this.dragged = false |
if (...) == "RightButton" and not IsModifierKeyDown() then |
this.self:OpenMenu(this) |
else |
plugin.minimapIcon:SetTexCoord(0.1, 0.9, 0.1, 0.9) |
HideDropDownMenu(1) |
if type(this.self.OnMouseDown) == "function" then |
this.self:OnMouseDown(...) |
end |
end |
if this.self.OnClick or this.self.OnMouseDown or this.self.OnMouseUp or this.self.OnDoubleClick then |
if this.self.minimapIcon:GetTexture():sub(1, 16) == "Interface\\Icons\\" then |
this.self.minimapIcon:SetTexCoord(0.14, 0.86, 0.14, 0.86) |
else |
this.self.minimapIcon:SetTexCoord(0.1, 0.9, 0.1, 0.9) |
end |
end |
end |
end) |
frame:SetScript("OnMouseUp", function() |
if not this.dragged and type(plugin.OnMouseUp) == "function" then |
plugin:OnMouseUp(arg1) |
end |
frame:SetScript("OnMouseDown", minimap_OnMouseDown) |
if not minimap_OnMouseUp then |
function minimap_OnMouseUp(this, ...) |
if not this.dragged and type(this.self.OnMouseUp) == "function" then |
this.self:OnMouseUp(...) |
end |
if this.self.minimapIcon:GetTexture():sub(1, 16) == "Interface\\Icons\\" then |
this.self.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95) |
else |
this.self.minimapIcon:SetTexCoord(0, 1, 0, 1) |
end |
end |
if this.plugin.minimapIcon:GetTexture():sub(1, 16) == "Interface\\Icons\\" then |
plugin.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95) |
else |
plugin.minimapIcon:SetTexCoord(0, 1, 0, 1) |
end |
end) |
end |
frame:SetScript("OnMouseUp", minimap_OnMouseUp) |
frame:RegisterForDrag("LeftButton") |
frame:SetScript("OnDragStart", self.OnDragStart) |
frame:SetScript("OnDragStop", self.OnDragStop) |
if not plugin.blizzardTooltip and not plugin.overrideTooltip and Tablet then |
-- Note that we have to do this after :SetScript("OnEnter"), etc, |
-- so that Tablet-2.0 can override it properly. |
FuBarPlugin.RegisterTablet(plugin) |
Tablet:Register(frame, plugin.frame) |
end |
end |
plugin.frame:Hide() |
plugin.minimapFrame:Show() |
round = false |
end |
elseif minimapShape == "SIDE-TOP" then |
if sin > 0 then |
if sin < 0 then |
round = false |
end |
elseif minimapShape == "SIDE-BOTTOM" then |
if sin < 0 then |
if sin > 0 then |
round = false |
end |
elseif minimapShape == "TRICORNER-TOPRIGHT" then |
if cos < 0 and sin > 0 then |
if cos < 0 and sin < 0 then |
round = false |
end |
elseif minimapShape == "TRICORNER-TOPLEFT" then |
if cos > 0 and sin > 0 then |
if cos > 0 and sin < 0 then |
round = false |
end |
elseif minimapShape == "TRICORNER-BOTTOMRIGHT" then |
if cos < 0 and sin < 0 then |
if cos < 0 and sin > 0 then |
round = false |
end |
elseif minimapShape == "TRICORNER-BOTTOMLEFT" then |
if cos > 0 and sin < 0 then |
if cos > 0 and sin > 0 then |
round = false |
end |
end |
if round then |
x = cos * 80 |
y = sin * 80 |
else |
x = 110 * cos |
y = 110 * sin |
x = math.max(-82, math.min(x, 84)) |
y = math.max(-86, math.min(y, 82)) |
x = 80 * 2^0.5 * cos |
y = 80 * 2^0.5 * sin |
if x < -80 then |
x = -80 |
elseif x > 80 then |
x = 80 |
end |
if y < -80 then |
y = -80 |
elseif y > 80 then |
y = 80 |
end |
end |
frame:SetPoint("CENTER", Minimap, "CENTER", x, y) |
end |
end |
function MinimapContainer:GetNumPlugins() |
return table.getn(self.plugins) |
return #self.plugins |
end |
function MinimapContainer:IndexOfPlugin(plugin) |
return "MINIMAP" |
end |
function MinimapContainer.OnDragStart() |
function MinimapContainer.OnDragStart(this) |
this.dragged = true |
this:LockHighlight() |
this:SetScript("OnUpdate", MinimapContainer.OnUpdate) |
if this.plugin.minimapIcon:GetTexture():sub(1, 16) == "Interface\\Icons\\" then |
this.plugin.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95) |
if this.self.minimapIcon:GetTexture():sub(1, 16) == "Interface\\Icons\\" then |
this.self.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95) |
else |
this.plugin.minimapIcon:SetTexCoord(0, 1, 0, 1) |
this.self.minimapIcon:SetTexCoord(0, 1, 0, 1) |
end |
end |
function MinimapContainer.OnDragStop() |
function MinimapContainer.OnDragStop(this) |
this:SetScript("OnUpdate", nil) |
this:UnlockHighlight() |
end |
function MinimapContainer.OnUpdate() |
function MinimapContainer.OnUpdate(this) |
if not IsAltKeyDown() then |
local mx, my = Minimap:GetCenter() |
local px, py = GetCursorPosition() |
elseif position > 360 then |
position = position - 360 |
end |
if this.plugin.db then |
this.plugin.db.profile.minimapPosition = position |
this.plugin.db.profile.minimapPositionX = nil |
this.plugin.db.profile.minimapPositionY = nil |
this.plugin.db.profile.minimapPositionWild = nil |
if this.self.db then |
this.self.db.profile.minimapPosition = position |
this.self.db.profile.minimapPositionX = nil |
this.self.db.profile.minimapPositionY = nil |
this.self.db.profile.minimapPositionWild = nil |
else |
this.plugin.minimapPosition = position |
this.plugin.minimapPositionX = nil |
this.plugin.minimapPositionY = nil |
this.plugin.minimapPositionWild = nil |
this.self.minimapPosition = position |
this.self.minimapPositionX = nil |
this.self.minimapPositionY = nil |
this.self.minimapPositionWild = nil |
end |
else |
local px, py = GetCursorPosition() |
local scale = UIParent:GetEffectiveScale() |
px, py = px / scale, py / scale |
if this.plugin.db then |
this.plugin.db.profile.minimapPositionX = px |
this.plugin.db.profile.minimapPositionY = py |
this.plugin.db.profile.minimapPosition = nil |
this.plugin.db.profile.minimapPositionWild = true |
if this.self.db then |
this.self.db.profile.minimapPositionX = px |
this.self.db.profile.minimapPositionY = py |
this.self.db.profile.minimapPosition = nil |
this.self.db.profile.minimapPositionWild = true |
else |
this.plugin.minimapPositionX = px |
this.plugin.minimapPositionY = py |
this.plugin.minimapPosition = nil |
this.plugin.minimapPositionWild = true |
this.self.minimapPositionX = px |
this.self.minimapPositionY = py |
this.self.minimapPosition = nil |
this.self.minimapPositionWild = true |
end |
end |
MinimapContainer:ReadjustLocation(this.plugin) |
MinimapContainer:ReadjustLocation(this.self) |
end |
local function activate(self, oldLib, oldDeactivate) |