WoWInterface SVN RecapFu

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk/FuBar_RecapFu/libs/FuBarPlugin-2.0
    from Rev 2 to Rev 3
    Reverse comparison

Rev 2 → Rev 3

FuBarPlugin-2.0.lua
1,18 → 1,20
--[[
--[[
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
23,6 → 25,7
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)
124,36 → 127,39
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 = "靠左"
161,9 → 167,12
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"
188,53 → 197,78
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()
291,12 → 325,16
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()
306,7 → 344,7
if not CheckFuBar() then
return true
end
return self.panel == AceLibrary(MINIMAPCONTAINER_MAJOR_VERSION)
return self.panel == MinimapContainer
end
 
function FuBarPlugin:Update()
339,6 → 377,10
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 = {}
396,12 → 438,18
'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
411,6 → 459,42
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)
441,7 → 525,7
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
457,7 → 541,9
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
474,7 → 560,7
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
728,11 → 814,15
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)
743,11 → 833,15
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
806,7 → 900,11
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()
816,20 → 914,24
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")
842,63 → 944,73
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
918,26 → 1030,26
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
945,34 → 1057,34
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
982,13 → 1094,24
 
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
1054,8 → 1177,10
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
 
1122,6 → 1247,7
end
 
local recheckPlugins
local AceConsole
function FuBarPlugin.OnEmbedEnable(FuBarPlugin, self)
if not self.userDefinedFrame then
if self:IsIconShown() then
1136,13 → 1262,13
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
1157,9 → 1283,10
 
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
1167,7 → 1294,7
end
end
end
FuBarPlugin:ScheduleEvent(recheckPlugins, 0)
FuBarPlugin:ScheduleEvent("FuBarPlugin-recheckPlugins", recheckPlugins, 0)
end
end
 
1191,14 → 1318,15
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
1248,7 → 1376,7
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,
1267,7 → 1395,7
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,
1360,7 → 1488,6
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
1371,8 → 1498,9
 
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
1384,8 → 1512,6
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)
1405,68 → 1531,99
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()
1543,39 → 1700,47
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
1586,7 → 1751,7
end
 
function MinimapContainer:GetNumPlugins()
return table.getn(self.plugins)
return #self.plugins
end
 
function MinimapContainer:IndexOfPlugin(plugin)
1607,23 → 1772,23
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()
1635,34 → 1800,34
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)