diff --git a/Titan/Titan.lua b/Titan/Titan.lua index a06da76..8f8356e 100644 --- a/Titan/Titan.lua +++ b/Titan/Titan.lua @@ -1775,7 +1775,8 @@ function TitanPanel_RemoveButton(id) local currentButton = TitanUtils_GetButton(id); -- safeguard ... - if id then AceTimer.CancelAllTimers({}) end -- ??? seems confused 0 or 1 params "TitanPanel" .. id +---@diagnostic disable-next-line: missing-parameter + if id then AceTimer.CancelAllTimers() end -- ??? seems confused 0 or 1 params "TitanPanel" .. id TitanPanel_ReOrder(i); table.remove(TitanPanelSettings.Buttons, TitanUtils_GetCurrentIndex(TitanPanelSettings.Buttons, id)); diff --git a/Titan/TitanConfig.lua b/Titan/TitanConfig.lua index 23f374b..138e32e 100644 --- a/Titan/TitanConfig.lua +++ b/Titan/TitanConfig.lua @@ -789,6 +789,10 @@ print("Config Y set" width = "normal", name = "", --v.locale_name, order = position, + disabled = function(info) + local frame_str = TitanVariables_GetFrameName(info[1]) + return (TitanBarDataVars[frame_str].texure == Titan_Global.COLOR) + end, get = function(info) local frame_str = TitanVariables_GetFrameName(info[1]) return TitanBarDataVars[frame_str].skin.path @@ -853,6 +857,10 @@ print("Config Y set" min = 0, max = 1, step = 0.01, + disabled = function(info) + local frame_str = TitanVariables_GetFrameName(info[1]) + return (TitanBarDataVars[frame_str].texure == Titan_Global.COLOR) + end, get = function(info) local frame_str = TitanVariables_GetFrameName(info[1]) return TitanBarDataVars[frame_str].skin.alpha @@ -885,6 +893,10 @@ print("Config Y set" order = position, -- disabled = (v.vert == TITAN_TOP or v.vert == TITAN_BOTTOM), hasAlpha = true, + disabled = function(info) + local frame_str = TitanVariables_GetFrameName(info[1]) + return (TitanBarDataVars[frame_str].texure == Titan_Global.SKIN) + end, get = function(info) local frame_str = TitanVariables_GetFrameName(info[1]) local color = TitanBarDataVars[frame_str].color diff --git a/Titan/TitanGlobal.lua b/Titan/TitanGlobal.lua index 577c4e4..291c7a3 100644 --- a/Titan/TitanGlobal.lua +++ b/Titan/TitanGlobal.lua @@ -186,6 +186,15 @@ Titan_Global.colors = { yellow = "ffff00", -- YELLOW_FONT_COLOR } +--type for debug +---@class PluginTopicType +---@field enabled boolean Whether this particular topic debug is enabled +---@field topic string The topic description + +---@class PluginDebugType +---@field enabled boolean Whether this particular plugin debug is enabled +---@field topics PluginTopicType[] The numeric list of possible debug + -- type for plugin registry ---@class PluginRegistryType ---@field id string The unique name of the plugin @@ -197,16 +206,33 @@ Titan_Global.colors = { ---@field tooltipTitle? string Localized string for the menu ---@field tooltipTextFunction? string | function Function to call for a simple tooltip (OnEnter) ---@field tooltipCustomFunction? function Function to call for a complex tooltip (OnEnter) +---@field debugClass? PluginDebugType Function to call to enable / disable debug (Titan Config) ---@field icon? string Path to the plugin icon ---@field iconWidth? integer Path to the plugin icon ---@field notes? string Brief description shown in Titan > Config > Plugins when this plugin is selected ---@field controlVariables? table Show or not on menu - set to true or false - ShowIcon ShowLabelText ShowColoredText DisplayOnRightSide ---@field savedVariables? table Initial value of any saved variables for this plugin; should include control variables +---API Return an empty debug class. +---@return PluginDebugType +---This routine was added for use with an IDE with Intellisense that supports Lua. It can be but might not be used. +---Each plugin is welcome to add more topics. +--- debug_info = Titan_Global.NewDebug() +function Titan_Global.NewDebug() + local reg = { + enabled = false, + topics = { + [1] = { enabled = false, topic = "Events"}, + [2] = { enabled = false, topic = "Flow"}, + } + } ---@type PluginDebugType + return reg +end + ---API Return an empty registry - only the id is set. ---@param id string The unique name of the plugin ---@return PluginRegistryType ----This routine was added for use with an IDE with Intellisense that supports Lua. +---This routine was added for use with an IDE with Intellisense that supports Lua. It can be but might not be used. --- reg = Titan_Global.NewRegistry("MyAddon") function Titan_Global.NewRegistry(id) local reg = { id = id } ---@type PluginRegistryType diff --git a/Titan/TitanHistory.lua b/Titan/TitanHistory.lua index da9c5c2..013f39a 100644 --- a/Titan/TitanHistory.lua +++ b/Titan/TitanHistory.lua @@ -15,6 +15,18 @@ Green - 'header' - Titan or plugin Highlight - notes. tips. and details --]] Titan_Global.recent_changes = "" +.. TitanUtils_GetGoldText("8.1.6 : 2024/12/09\n") +.. TitanUtils_GetGreenText("Gold : \n") +.. TitanUtils_GetHighlightText("" +.. "- Warband gold updated properly in tooltip." +) +.. TitanUtils_GetGreenText("Titan : \n") +.. TitanUtils_GetHighlightText("" +.. "- Update ACE3 libs." +.. "- Bars - Config Color picker now works; changed in 10.2.5 (Jan 2024)." +.. "- Bars - Config when selecting Skin vs Color the 'other' controls are disabled." +) +.. "\n\n" .. TitanUtils_GetGoldText("8.1.5 : 2024/11/20\n") .. TitanUtils_GetGreenText("Loot - Classic Era : \n") .. TitanUtils_GetHighlightText("" @@ -27,6 +39,7 @@ Titan_Global.recent_changes = "" .. "- Cata TOC to 4.4.1." .. "- Classic Era TOC to 1.15.5" ) +.. "\n\n" .. TitanUtils_GetGoldText("8.1.4 : 2024/10/24\n") .. TitanUtils_GetGreenText("Gold : \n") .. TitanUtils_GetHighlightText("" @@ -58,20 +71,6 @@ Titan_Global.recent_changes = "" .. "- Classic Era TOC to 1.15.4." ) .. "\n\n" -.. TitanUtils_GetGoldText("8.1.2 : 2024/08/24\n") -.. TitanUtils_GetGreenText("Titan : \n") -.. TitanUtils_GetHighlightText("" -.. "- Fix for short bars drifting when using some Titan scaling other than one (1)." -) -.. TitanUtils_GetGreenText("Gold : \n") -.. TitanUtils_GetHighlightText("" -.. "- Restore starting gold for gold per hour calc. #1404\n" -) -.. TitanUtils_GetGreenText("XP : \n") -.. TitanUtils_GetHighlightText("" -.. "- Reduce update timer to 10 from 30 seconds.\n" -) -.. "\n\n" Titan_Global.recent_changes = "" .. TitanUtils_GetGoldText("8.1.0 : 2024/08/06\n") .. TitanUtils_GetGreenText("Titan : \n") diff --git a/Titan/TitanUtils.lua b/Titan/TitanUtils.lua index 3311aff..3d52b15 100644 --- a/Titan/TitanUtils.lua +++ b/Titan/TitanUtils.lua @@ -2398,6 +2398,41 @@ function TitanPluginDebug(id, debug_message) _G["DEFAULT_CHAT_FRAME"]:AddMessage(msg) end +---API: Output a topic debug message in a consistent format. +---@param id string Plugin id +---@param topic integer Topic id +---@param debug_message string Message to output to Chat +function TitanTopicDebug(id, topic, debug_message) + + local plugin = TitanUtils_GetPlugin(id) ---@type PluginRegistryType + local str = "" + local id_str = id or "?" + local dbg = id_str.." "..tostring(topic).." " + + if plugin and plugin.debugClass then + if plugin.debugClass.enabled == true then + if plugin.debugClass.topics[topic] then + if plugin.debugClass.topics[topic].enabled == true then -- topic description exists + str = tostring(topic) .. " " .. plugin.debugClass.topics[topic].topic + local msg = + TitanUtils_GetGoldText(date("%H:%M:%S") .. "<" .. tostring(id_str) .. "> " .. str ) + .. " " .. TitanUtils_GetHexText(tostring(debug_message), Titan_Global.colors.orange) + _G["DEFAULT_CHAT_FRAME"]:AddMessage(msg) + else + dbg = dbg.."~topic enabled" + end + else + dbg = dbg.."~topic" + end + else + dbg = dbg.."~enabled" + end +--print(dbg) + else + -- not sure why this routine was called + end +end + ---Titan: Output the current list of registered plugins. function TitanDumpPluginList() -- Just dump the current list of plugins diff --git a/Titan/_TitanIDE.lua b/Titan/_TitanIDE.lua index 56da416..e646399 100644 --- a/Titan/_TitanIDE.lua +++ b/Titan/_TitanIDE.lua @@ -151,6 +151,12 @@ C_Bank = {} -- 11.0.0 New Warbank - Hopefully WoW API extension will catch up so ---@field TIME_PLAYED_MSG table Override default - XP ---@field short_name string Placeholder for short bar name +-- Ace references +AceGUIWidgetLSMlists = {} + +--====== Ace Drop down menu +L_UIDROPDOWNMENU_MENU_LEVEL = 1 +L_UIDROPDOWNMENU_MENU_VALUE = 1 --====== WoW Drop down menu UIDROPDOWNMENU_MENU_VALUE = 1 diff --git a/Titan/_Titan_Lib_Notes.txt b/Titan/_Titan_Lib_Notes.txt index 4434cde..16125ad 100644 --- a/Titan/_Titan_Lib_Notes.txt +++ b/Titan/_Titan_Lib_Notes.txt @@ -2,6 +2,7 @@ From: Ace3 - https://www.curseforge.com/wow/addons/ace3 AceGUI-3.0-SharedMediaWidgets - https://www.curseforge.com/wow/addons/ace-gui-3-0-shared-media-widgets +LibQTip-1.0 - https://www.curseforge.com/wow/addons/libqtip-1-0 LibSharedMedia-3.0 - https://www.curseforge.com/wow/addons/libsharedmedia-3-0 LibUIDropDownMenu - https://www.curseforge.com/wow/addons/libuidropdownmenu diff --git a/Titan/libs/Ace/!LibUIDropDownMenu/!LibUIDropDownMenu-BCC.toc b/Titan/libs/Ace/!LibUIDropDownMenu/!LibUIDropDownMenu-BCC.toc index d8d57f2..50233de 100644 --- a/Titan/libs/Ace/!LibUIDropDownMenu/!LibUIDropDownMenu-BCC.toc +++ b/Titan/libs/Ace/!LibUIDropDownMenu/!LibUIDropDownMenu-BCC.toc @@ -1,7 +1,7 @@ ## Interface: 20504 ## Title: Lib: UIDropDownMenu ## Notes: A Replacement for standard UIDropDownMenu -## Version: v4.21.10010550587 +## Version: v4.26.10020553040 ## X-Category: Libraries ## X-Website: https://www.wowace.com/projects/libuidropdownmenu ## OptionalDeps: LibStub diff --git a/Titan/libs/Ace/!LibUIDropDownMenu/!LibUIDropDownMenu-Classic.toc b/Titan/libs/Ace/!LibUIDropDownMenu/!LibUIDropDownMenu-Classic.toc index 14e2066..3f6fb3f 100644 --- a/Titan/libs/Ace/!LibUIDropDownMenu/!LibUIDropDownMenu-Classic.toc +++ b/Titan/libs/Ace/!LibUIDropDownMenu/!LibUIDropDownMenu-Classic.toc @@ -1,7 +1,7 @@ -## Interface: 11403 +## Interface: 11500 ## Title: Lib: UIDropDownMenu ## Notes: A Replacement for standard UIDropDownMenu -## Version: v4.21.10010550587 +## Version: v4.26.10020553040 ## X-Category: Libraries ## X-Website: https://www.wowace.com/projects/libuidropdownmenu ## OptionalDeps: LibStub diff --git a/Titan/libs/Ace/!LibUIDropDownMenu/!LibUIDropDownMenu-WOTLKC.toc b/Titan/libs/Ace/!LibUIDropDownMenu/!LibUIDropDownMenu-WOTLKC.toc index 0094b37..6743d1d 100644 --- a/Titan/libs/Ace/!LibUIDropDownMenu/!LibUIDropDownMenu-WOTLKC.toc +++ b/Titan/libs/Ace/!LibUIDropDownMenu/!LibUIDropDownMenu-WOTLKC.toc @@ -1,7 +1,7 @@ -## Interface: 30402 +## Interface: 30403 ## Title: Lib: UIDropDownMenu ## Notes: A Replacement for standard UIDropDownMenu -## Version: v4.21.10010550587 +## Version: v4.26.10020553040 ## X-Category: Libraries ## X-Website: https://www.wowace.com/projects/libuidropdownmenu ## OptionalDeps: LibStub diff --git a/Titan/libs/Ace/!LibUIDropDownMenu/!LibUIDropDownMenu.toc b/Titan/libs/Ace/!LibUIDropDownMenu/!LibUIDropDownMenu.toc index 46d19f3..4211700 100644 --- a/Titan/libs/Ace/!LibUIDropDownMenu/!LibUIDropDownMenu.toc +++ b/Titan/libs/Ace/!LibUIDropDownMenu/!LibUIDropDownMenu.toc @@ -1,7 +1,7 @@ -## Interface: 100105 +## Interface: 100205 ## Title: Lib: UIDropDownMenu ## Notes: A Replacement for standard UIDropDownMenu -## Version: v4.21.10010550587 +## Version: v4.26.10020553040 ## X-Category: Libraries ## X-Website: https://www.wowace.com/projects/libuidropdownmenu ## OptionalDeps: LibStub diff --git a/Titan/libs/Ace/!LibUIDropDownMenu/Docs/Revision.txt b/Titan/libs/Ace/!LibUIDropDownMenu/Docs/Revision.txt index 33114f8..50f9f30 100644 --- a/Titan/libs/Ace/!LibUIDropDownMenu/Docs/Revision.txt +++ b/Titan/libs/Ace/!LibUIDropDownMenu/Docs/Revision.txt @@ -1,8 +1,31 @@ -$Id: Revision.txt 123 2023-07-29 01:42:12Z arithmandar $ +$Id: Revision.txt 135 2024-02-05 16:50:14Z arithmandar $ Revision History: ================= +v4.26.10020553040 (2024/02/06) +------------------------------ +- OpenColorPicker related feature's compatibility enhancement + +v4.25.10020553040 (2024/01/30) +------------------------------ +- Enhanced frame or texture's creation to set the name as nil when parent frame name is also nil +- Further error handling for NewFeature + +v4.24.10020553007 (2024/01/23) +------------------------------ +- Fixed issue of version confliction when older version was loaded first and then newer version was to replace the library. + What has been created won't have the "NewFeature" frame there. + +v4.23.10020553007 (2024/01/22) +------------------------------ +- Fixed issue with the compatibility with WoW 3.4.3 / 1.15.0 + +v4.22.10020553007 (2024/01/21) +------------------------------ +- Toc update to support WoW 10.2.5 / 3.4.3 / 1.15.0 +- function sync with build 53007 + v4.21.10010550587 (2023/07/29) ------------------------------ - Toc update to support WoW 10.1.5 / 3.4.2 diff --git a/Titan/libs/Ace/!LibUIDropDownMenu/LibUIDropDownMenu/LibUIDropDownMenu.lua b/Titan/libs/Ace/!LibUIDropDownMenu/LibUIDropDownMenu/LibUIDropDownMenu.lua index 8898ed0..908eba4 100644 --- a/Titan/libs/Ace/!LibUIDropDownMenu/LibUIDropDownMenu/LibUIDropDownMenu.lua +++ b/Titan/libs/Ace/!LibUIDropDownMenu/LibUIDropDownMenu/LibUIDropDownMenu.lua @@ -1,4 +1,4 @@ --- $Id: LibUIDropDownMenu.lua 123 2023-07-29 01:42:12Z arithmandar $ +-- $Id: LibUIDropDownMenu.lua 135 2024-02-05 16:50:14Z arithmandar $ -- ---------------------------------------------------------------------------- -- Localized Lua globals. -- ---------------------------------------------------------------------------- @@ -18,7 +18,7 @@ local GameTooltip_SetTitle, GameTooltip_AddInstructionLine, GameTooltip_AddNorma -- ---------------------------------------------------------------------------- local MAJOR_VERSION = "LibUIDropDownMenu-4.0" -local MINOR_VERSION = 90000 + tonumber(("$Rev: 123 $"):match("%d+")) +local MINOR_VERSION = 90000 + tonumber(("$Rev: 135 $"):match("%d+")) local LibStub = _G.LibStub @@ -169,6 +169,9 @@ local function create_MenuButton(name, parent) end if (WoWRetail) then GetValueOrCallFunction(self, "funcOnEnter", self); + if self.NewFeature then + self.NewFeature:Hide(); + end end end @@ -240,11 +243,11 @@ local function create_MenuButton(name, parent) -- UIDropDownMenuButtonIcon Script BEGIN local function icon_OnClick(self, button) - local button = self:GetParent() - if not button then + local buttonParent = self:GetParent() + if not buttonParent then return end - button_OnClick(self, button) + button_OnClick(buttonParent, button) end local function icon_OnEnter(self) @@ -279,6 +282,7 @@ local function create_MenuButton(name, parent) button_OnLeave(button); end + local function icon_OnMouseUp(self, button) if ( button == "LeftButton" ) then icon_OnClick(self, button) @@ -286,31 +290,33 @@ local function create_MenuButton(name, parent) end -- UIDropDownMenuButtonIcon Script END + -- Button Frame local f = CreateFrame("Button", name, parent or nil) f:SetWidth(100) f:SetHeight(16) f:SetFrameLevel(f:GetParent():GetFrameLevel()+2) - f.Highlight = f:CreateTexture(name.."Highlight", "BACKGROUND") + f.Highlight = f:CreateTexture( name and (name.."Highlight") or nil, "BACKGROUND") f.Highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") f.Highlight:SetBlendMode("ADD") f.Highlight:SetAllPoints() f.Highlight:Hide() - f.Check = f:CreateTexture(name.."Check", "ARTWORK") + f.Check = f:CreateTexture( name and (name.."Check") or nil, "ARTWORK") f.Check:SetTexture("Interface\\Common\\UI-DropDownRadioChecks") f.Check:SetSize(16, 16) f.Check:SetPoint("LEFT", f, 0, 0) f.Check:SetTexCoord(0, 0.5, 0.5, 1) - f.UnCheck = f:CreateTexture(name.."UnCheck", "ARTWORK") + f.UnCheck = f:CreateTexture( name and (name.."UnCheck") or nil, "ARTWORK") f.UnCheck:SetTexture("Interface\\Common\\UI-DropDownRadioChecks") f.UnCheck:SetSize(16, 16) f.UnCheck:SetPoint("LEFT", f, 0, 0) f.UnCheck:SetTexCoord(0.5, 1, 0.5, 1) + -- Icon Texture local fIcon - fIcon = f:CreateTexture(name.."Icon", "ARTWORK") + fIcon = f:CreateTexture( name and (name.."Icon") or nil, "ARTWORK") fIcon:SetSize(16, 16) fIcon:SetPoint("RIGHT", f, 0, 0) fIcon:Hide() @@ -329,17 +335,17 @@ local function create_MenuButton(name, parent) -- ColorSwatch local fcw - fcw = CreateFrame("Button", name.."ColorSwatch", f, BackdropTemplateMixin and DropDownMenuButtonMixin and "BackdropTemplate,ColorSwatchTemplate" or BackdropTemplateMixin and "BackdropTemplate" or nil) + fcw = CreateFrame("Button", name and (name.."ColorSwatch") or nil, f, BackdropTemplateMixin and DropDownMenuButtonMixin and "BackdropTemplate,ColorSwatchTemplate" or BackdropTemplateMixin and "BackdropTemplate" or nil) fcw:SetPoint("RIGHT", f, -6, 0) fcw:Hide() if not DropDownMenuButtonMixin then fcw:SetSize(16, 16) - fcw.SwatchBg = fcw:CreateTexture(name.."ColorSwatchSwatchBg", "BACKGROUND") + fcw.SwatchBg = fcw:CreateTexture( name and (name.."ColorSwatchSwatchBg") or nil, "BACKGROUND") fcw.SwatchBg:SetVertexColor(1, 1, 1) fcw.SwatchBg:SetWidth(14) fcw.SwatchBg:SetHeight(14) fcw.SwatchBg:SetPoint("CENTER", fcw, 0, 0) - local button1NormalTexture = fcw:CreateTexture(name.."ColorSwatchNormalTexture") + local button1NormalTexture = fcw:CreateTexture( name and (name.."ColorSwatchNormalTexture") or nil) button1NormalTexture:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch") button1NormalTexture:SetAllPoints() fcw:SetNormalTexture(button1NormalTexture) @@ -360,12 +366,11 @@ local function create_MenuButton(name, parent) f.ColorSwatch = fcw -- ExpandArrow - local fea = CreateFrame("Button", name.."ExpandArrow", f) - + local fea = CreateFrame("Button", name and (name.."ExpandArrow") or nil, f) fea:SetSize(16, 16) fea:SetPoint("RIGHT", f, 0, 0) fea:Hide() - local button2NormalTexture = fea:CreateTexture(name.."ExpandArrowNormalTexture") + local button2NormalTexture = fea:CreateTexture( name and (name.."ExpandArrowNormalTexture") or nil) button2NormalTexture:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow") button2NormalTexture:SetAllPoints() fea:SetNormalTexture(button2NormalTexture) @@ -392,7 +397,7 @@ local function create_MenuButton(name, parent) f.ExpandArrow = fea -- InvisibleButton - local fib = CreateFrame("Button", name.."InvisibleButton", f) + local fib = CreateFrame("Button", name and (name.."InvisibleButton") or nil, f) fib:Hide() fib:SetPoint("TOPLEFT", f, 0, 0) fib:SetPoint("BOTTOMLEFT", f, 0, 0) @@ -430,7 +435,20 @@ local function create_MenuButton(name, parent) tooltip:Hide(); end) f.invisibleButton = fib + + -- NewFeature + if (WoWRetail) then + local fnf = CreateFrame("Frame", name and (name.."NewFeature") or nil, f, "NewFeatureLabelTemplate"); + fnf:SetFrameStrata("HIGH"); + fnf:SetScale(0.8); + fnf:SetFrameLevel(100); + fnf:SetSize(1, 1); + fnf:Hide(); + + f.NewFeature = fnf; + end + -- MenuButton scripts f:SetScript("OnClick", function(self, button) button_OnClick(self, button) end) @@ -447,7 +465,7 @@ local function create_MenuButton(name, parent) self.invisibleButton:Show() end) - local text1 = f:CreateFontString(name.."NormalText") + local text1 = f:CreateFontString( name and (name.."NormalText") or nil) f:SetFontString(text1) text1:SetPoint("LEFT", f, -5, 0) f:SetNormalFontObject("GameFontHighlightSmallLeft") @@ -480,26 +498,41 @@ local function creatre_DropDownList(name, parent) insets = { left = 5, right = 5, top = 5, bottom = 5 }, } - local f = _G[name] or CreateFrame("Button", name) + local f = name and _G[name] or CreateFrame("Button", name) f:SetParent(parent or nil) f:Hide() f:SetFrameStrata("DIALOG") f:EnableMouse(true) - local fbd = _G[name.."Backdrop"] or CreateFrame("Frame", name.."Backdrop", f, BackdropTemplateMixin and "DialogBorderDarkTemplate" or nil) + local fbd = name and _G[name.."Backdrop"] or CreateFrame("Frame", name and (name.."Backdrop") or nil, f, BackdropTemplateMixin and "DialogBorderDarkTemplate" or nil) fbd:SetAllPoints() fbd.backdropInfo = BACKDROP_DIALOG_DARK f.Backdrop = fbd - local fmb = _G[name.."MenuBackdrop"] or CreateFrame("Frame", name.."MenuBackdrop", f, TooltipBackdropTemplateMixin and "TooltipBackdropTemplate" or nil) + local fmb = name and _G[name.."MenuBackdrop"] or CreateFrame("Frame", name and (name.."MenuBackdrop") or nil, f, TooltipBackdropTemplateMixin and "TooltipBackdropTemplate" or nil) fmb:SetAllPoints() fmb.backdropInfo = BACKDROP_TOOLTIP_16_16_5555 fmb:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b) fmb:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b) f.MenuBackdrop = fmb - f.Button1 = _G[name.."Button1"] or create_MenuButton(name.."Button1", f) -- to replace the inherits of "UIDropDownMenuButtonTemplate" + f.Button1 = name and _G[name.."Button1"] or create_MenuButton(name and (name.."Button1") or nil, f) -- to replace the inherits of "UIDropDownMenuButtonTemplate" f.Button1:SetID(1) + + -- Checking if NewFeature exists or not + if (WoWRetail) then + if not f.Button1.NewFeature then + local fnf = CreateFrame("Frame", name and (name.."NewFeature") or nil, f, "NewFeatureLabelTemplate"); + fnf:SetFrameStrata("HIGH"); + fnf:SetScale(0.8); + fnf:SetFrameLevel(100); + fnf:SetSize(1, 1); + fnf:Hide(); + + f.Button1.NewFeature = fnf; + end + end + f:SetScript("OnClick", function(self) self:Hide() @@ -589,64 +622,64 @@ local function create_DropDownMenu(name, parent) f = CreateFrame("Frame", name, parent or nil) end - if not name then name = "" end + --if not name then name = "" end f:SetSize(40, 32) - f.Left = f:CreateTexture(name.."Left", "ARTWORK") + f.Left = f:CreateTexture( name and (name.."Left") or nil, "ARTWORK") f.Left:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame") f.Left:SetSize(25, 64) f.Left:SetPoint("TOPLEFT", f, 0, 17) f.Left:SetTexCoord(0, 0.1953125, 0, 1) - f.Middle = f:CreateTexture(name.."Middle", "ARTWORK") + f.Middle = f:CreateTexture( name and (name.."Middle") or nil, "ARTWORK") f.Middle:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame") f.Middle:SetSize(115, 64) f.Middle:SetPoint("LEFT", f.Left, "RIGHT") f.Middle:SetTexCoord(0.1953125, 0.8046875, 0, 1) - f.Right = f:CreateTexture(name.."Right", "ARTWORK") + f.Right = f:CreateTexture( name and (name.."Right") or nil, "ARTWORK") f.Right:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame") f.Right:SetSize(25, 64) f.Right:SetPoint("LEFT", f.Middle, "RIGHT") f.Right:SetTexCoord(0.8046875, 1, 0, 1) - f.Text = f:CreateFontString(name.."Text", "ARTWORK", "GameFontHighlightSmall") + f.Text = f:CreateFontString( name and (name.."Text") or nil, "ARTWORK", "GameFontHighlightSmall") f.Text:SetWordWrap(false) f.Text:SetJustifyH("RIGHT") f.Text:SetSize(0, 10) f.Text:SetPoint("RIGHT", f.Right, -43, 2) - f.Icon = f:CreateTexture(name.."Icon", "OVERLAY") + f.Icon = f:CreateTexture( name and (name.."Icon") or nil, "OVERLAY") f.Icon:Hide() f.Icon:SetSize(16, 16) f.Icon:SetPoint("LEFT", 30, 2) -- // UIDropDownMenuButtonScriptTemplate - f.Button = CreateFrame("Button", name.."Button", f) + f.Button = CreateFrame("Button", name and (name.."Button") or nil, f) f.Button:SetMotionScriptsWhileDisabled(true) f.Button:SetSize(24, 24) f.Button:SetPoint("TOPRIGHT", f.Right, -16, -18) - f.Button.NormalTexture = f.Button:CreateTexture(name.."NormalTexture") + f.Button.NormalTexture = f.Button:CreateTexture( name and (name.."NormalTexture") or nil) f.Button.NormalTexture:SetTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Up") f.Button.NormalTexture:SetSize(24, 24) f.Button.NormalTexture:SetPoint("RIGHT", f.Button, 0, 0) f.Button:SetNormalTexture(f.Button.NormalTexture) - f.Button.PushedTexture = f.Button:CreateTexture(name.."PushedTexture") + f.Button.PushedTexture = f.Button:CreateTexture( name and (name.."PushedTexture") or nil) f.Button.PushedTexture:SetTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Down") f.Button.PushedTexture:SetSize(24, 24) f.Button.PushedTexture:SetPoint("RIGHT", f.Button, 0, 0) f.Button:SetPushedTexture(f.Button.PushedTexture) - f.Button.DisabledTexture = f.Button:CreateTexture(name.."DisabledTexture") + f.Button.DisabledTexture = f.Button:CreateTexture( name and (name.."DisabledTexture") or nil) f.Button.DisabledTexture:SetTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Disabled") f.Button.DisabledTexture:SetSize(24, 24) f.Button.DisabledTexture:SetPoint("RIGHT", f.Button, 0, 0) f.Button:SetDisabledTexture(f.Button.DisabledTexture) - f.Button.HighlightTexture = f.Button:CreateTexture(name.."HighlightTexture") + f.Button.HighlightTexture = f.Button:CreateTexture( name and (name.."HighlightTexture") or nil) f.Button.HighlightTexture:SetTexture("Interface\\Buttons\\UI-Common-MouseHilight") f.Button.HighlightTexture:SetSize(24, 24) f.Button.HighlightTexture:SetPoint("RIGHT", f.Button, 0, 0) @@ -767,6 +800,9 @@ function lib:UIDropDownMenu_Initialize(frame, initFunction, displayMode, level, local dropDownList = _G["L_DropDownList"..level]; dropDownList.dropdown = frame; dropDownList.shouldRefresh = true; + if (WoWRetail) then + dropDownList:SetWindow(frame:GetWindow()); + end lib:UIDropDownMenu_SetDisplayMode(frame, displayMode); end @@ -889,6 +925,7 @@ info.mouseOverIcon = [TEXTURE] -- An override icon when a button is moused over. info.ignoreAsMenuSelection [nil, true] -- Never set the menu text/icon to this, even when this button is checked info.registerForRightClick [nil, true] -- Register dropdown buttons for right clicks info.registerForAnyClick [nil, true] -- Register dropdown buttons for any clicks +info.showNewLabel ]] -- Create (return) empty table @@ -1117,6 +1154,7 @@ function lib:UIDropDownMenu_AddButton(info, level) if (WoWRetail) then button.iconXOffset = info.iconXOffset; button.ignoreAsMenuSelection = info.ignoreAsMenuSelection; + button.showNewLabel = info.showNewLabel; else button.classicChecks = info.classicChecks; end @@ -1301,7 +1339,10 @@ function lib:UIDropDownMenu_AddButton(info, level) _G[listFrameName.."Button"..index.."UnCheck"]:Hide(); end button.checked = info.checked; - + if (WoWRetail and button.NewFeature) then + button.NewFeature:SetShown(button.showNewLabel); + end + -- If has a colorswatch, show it and vertex color it local colorSwatch = _G[listFrameName.."Button"..index.."ColorSwatch"]; if ( info.hasColorSwatch ) then @@ -1413,6 +1454,9 @@ function lib:UIDropDownMenu_GetButtonWidth(button) if ( button.hasArrow or button.hasColorSwatch ) then width = width + 10; end + if (WoWRetail and button.showNewLabel and button.NewFeature) then + width = width + button.NewFeature.Label:GetUnboundedStringWidth(); + end if ( button.notCheckable ) then width = width - 30; end @@ -1485,6 +1529,12 @@ function lib:UIDropDownMenu_Refresh(frame, useValue, dropdownLevel) end end + if (WoWRetail and button.NewFeature) then + local normalText = _G[button:GetName().."NormalText"]; + button.NewFeature:SetShown(button.showNewLabel); + button.NewFeature:SetPoint("LEFT", normalText, "RIGHT", 20, 0); + end + if ( button:IsShown() ) then local width = lib:UIDropDownMenu_GetButtonWidth(button); if ( width > maxWidth ) then @@ -2034,7 +2084,11 @@ function lib:UIDropDownMenuButton_OpenColorPicker(self, button) button = self; end L_UIDROPDOWNMENU_MENU_VALUE = button.value; - lib:OpenColorPicker(button); + if (WoWRetail) then + ColorPickerFrame:SetupColorPickerAndShow(button); + else + lib:OpenColorPicker(button); + end end function lib:UIDropDownMenu_DisableButton(level, id) @@ -2143,20 +2197,29 @@ function lib:UIDropDownMenu_GetValue(id) end function lib:OpenColorPicker(info) - ColorPickerFrame.func = info.swatchFunc; - ColorPickerFrame.hasOpacity = info.hasOpacity; - ColorPickerFrame.opacityFunc = info.opacityFunc; - ColorPickerFrame.opacity = info.opacity; - ColorPickerFrame.previousValues = {r = info.r, g = info.g, b = info.b, opacity = info.opacity}; - ColorPickerFrame.cancelFunc = info.cancelFunc; - ColorPickerFrame.extraInfo = info.extraInfo; - -- This must come last, since it triggers a call to ColorPickerFrame.func() - ColorPickerFrame:SetColorRGB(info.r, info.g, info.b); - ShowUIPanel(ColorPickerFrame); + if (WoWRetail) then + ColorPickerFrame:SetupColorPickerAndShow(info); + else + ColorPickerFrame.func = info.swatchFunc; + ColorPickerFrame.hasOpacity = info.hasOpacity; + ColorPickerFrame.opacityFunc = info.opacityFunc; + ColorPickerFrame.opacity = info.opacity; + ColorPickerFrame.previousValues = {r = info.r, g = info.g, b = info.b, opacity = info.opacity}; + ColorPickerFrame.cancelFunc = info.cancelFunc; + ColorPickerFrame.extraInfo = info.extraInfo; + -- This must come last, since it triggers a call to ColorPickerFrame.func() + ColorPickerFrame:SetColorRGB(info.r, info.g, info.b); + ShowUIPanel(ColorPickerFrame); + end end function lib:ColorPicker_GetPreviousValues() - return ColorPickerFrame.previousValues.r, ColorPickerFrame.previousValues.g, ColorPickerFrame.previousValues.b; + if (WoWRetail) then + local r, g, b = ColorPickerFrame:GetPreviousValues(); + return r, g, b; + else + return ColorPickerFrame.previousValues.r, ColorPickerFrame.previousValues.g, ColorPickerFrame.previousValues.b; + end end -- ////////////////////////////////////////////////////////////// @@ -2250,6 +2313,13 @@ function lib.UIDropDownCustomMenuEntryMixin:GetContextData() return self.contextData; end + +lib.ColorSwatchMixin = {} + +function lib.ColorSwatchMixin:SetColor(color) + self.Color:SetVertexColor(color:GetRGB()); +end + -- ////////////////////////////////////////////////////////////// -- L_UIDropDownCustomMenuEntryTemplate function lib:Create_UIDropDownCustomMenuEntry(name, parent) diff --git a/Titan/libs/Ace/Ace3.toc b/Titan/libs/Ace/Ace3.toc index 13f0d97..6cfd277 100644 --- a/Titan/libs/Ace/Ace3.toc +++ b/Titan/libs/Ace/Ace3.toc @@ -1,4 +1,4 @@ -## Interface: 100105 +## Interface: 11503, 40400, 100207, 110000, 110002 ## Title: Lib: Ace3 ## Notes: AddOn development framework @@ -6,7 +6,7 @@ ## X-Website: http://www.wowace.com ## X-Category: Library ## X-License: Limited BSD -## Version: Release-r1309 +## Version: Release-r1349 LibStub\LibStub.lua CallbackHandler-1.0\CallbackHandler-1.0.xml diff --git a/Titan/libs/Ace/Ace3_TBC.toc b/Titan/libs/Ace/Ace3_TBC.toc deleted file mode 100644 index 3cd438e..0000000 --- a/Titan/libs/Ace/Ace3_TBC.toc +++ /dev/null @@ -1,28 +0,0 @@ -## Interface: 20504 - -## Title: Lib: Ace3 -## Notes: AddOn development framework -## Author: Ace3 Development Team -## X-Website: http://www.wowace.com -## X-Category: Library -## X-License: Limited BSD -## Version: Release-r1309 - -LibStub\LibStub.lua -CallbackHandler-1.0\CallbackHandler-1.0.xml -AceAddon-3.0\AceAddon-3.0.xml -AceEvent-3.0\AceEvent-3.0.xml -AceTimer-3.0\AceTimer-3.0.xml -AceBucket-3.0\AceBucket-3.0.xml -AceHook-3.0\AceHook-3.0.xml -AceDB-3.0\AceDB-3.0.xml -AceDBOptions-3.0\AceDBOptions-3.0.xml -AceLocale-3.0\AceLocale-3.0.xml -AceConsole-3.0\AceConsole-3.0.xml -AceGUI-3.0\AceGUI-3.0.xml -AceConfig-3.0\AceConfig-3.0.xml -AceComm-3.0\AceComm-3.0.xml -AceTab-3.0\AceTab-3.0.xml -AceSerializer-3.0\AceSerializer-3.0.xml - -Ace3.lua diff --git a/Titan/libs/Ace/Ace3_Vanilla.toc b/Titan/libs/Ace/Ace3_Vanilla.toc deleted file mode 100644 index 1386798..0000000 --- a/Titan/libs/Ace/Ace3_Vanilla.toc +++ /dev/null @@ -1,28 +0,0 @@ -## Interface: 11403 - -## Title: Lib: Ace3 -## Notes: AddOn development framework -## Author: Ace3 Development Team -## X-Website: http://www.wowace.com -## X-Category: Library -## X-License: Limited BSD -## Version: Release-r1309 - -LibStub\LibStub.lua -CallbackHandler-1.0\CallbackHandler-1.0.xml -AceAddon-3.0\AceAddon-3.0.xml -AceEvent-3.0\AceEvent-3.0.xml -AceTimer-3.0\AceTimer-3.0.xml -AceBucket-3.0\AceBucket-3.0.xml -AceHook-3.0\AceHook-3.0.xml -AceDB-3.0\AceDB-3.0.xml -AceDBOptions-3.0\AceDBOptions-3.0.xml -AceLocale-3.0\AceLocale-3.0.xml -AceConsole-3.0\AceConsole-3.0.xml -AceGUI-3.0\AceGUI-3.0.xml -AceConfig-3.0\AceConfig-3.0.xml -AceComm-3.0\AceComm-3.0.xml -AceTab-3.0\AceTab-3.0.xml -AceSerializer-3.0\AceSerializer-3.0.xml - -Ace3.lua diff --git a/Titan/libs/Ace/Ace3_Wrath.toc b/Titan/libs/Ace/Ace3_Wrath.toc deleted file mode 100644 index b26899f..0000000 --- a/Titan/libs/Ace/Ace3_Wrath.toc +++ /dev/null @@ -1,28 +0,0 @@ -## Interface: 30402 - -## Title: Lib: Ace3 -## Notes: AddOn development framework -## Author: Ace3 Development Team -## X-Website: http://www.wowace.com -## X-Category: Library -## X-License: Limited BSD -## Version: Release-r1309 - -LibStub\LibStub.lua -CallbackHandler-1.0\CallbackHandler-1.0.xml -AceAddon-3.0\AceAddon-3.0.xml -AceEvent-3.0\AceEvent-3.0.xml -AceTimer-3.0\AceTimer-3.0.xml -AceBucket-3.0\AceBucket-3.0.xml -AceHook-3.0\AceHook-3.0.xml -AceDB-3.0\AceDB-3.0.xml -AceDBOptions-3.0\AceDBOptions-3.0.xml -AceLocale-3.0\AceLocale-3.0.xml -AceConsole-3.0\AceConsole-3.0.xml -AceGUI-3.0\AceGUI-3.0.xml -AceConfig-3.0\AceConfig-3.0.xml -AceComm-3.0\AceComm-3.0.xml -AceTab-3.0\AceTab-3.0.xml -AceSerializer-3.0\AceSerializer-3.0.xml - -Ace3.lua diff --git a/Titan/libs/Ace/AceConfig-3.0/AceConfig-3.0.lua b/Titan/libs/Ace/AceConfig-3.0/AceConfig-3.0.lua index 5071cdc..ab91c9e 100644 --- a/Titan/libs/Ace/AceConfig-3.0/AceConfig-3.0.lua +++ b/Titan/libs/Ace/AceConfig-3.0/AceConfig-3.0.lua @@ -3,7 +3,7 @@ -- as well as associate it with a slash command. -- @class file -- @name AceConfig-3.0 --- @release $Id: AceConfig-3.0.lua 1202 2019-05-15 23:11:22Z nevcairiel $ +-- @release $Id: AceConfig-3.0.lua 1335 2024-05-05 19:35:16Z nevcairiel $ --[[ AceConfig-3.0 @@ -27,7 +27,7 @@ if not AceConfig then return end local pcall, error, type, pairs = pcall, error, type, pairs -- ------------------------------------------------------------------- --- :RegisterOptionsTable(appName, options, slashcmd, persist) +-- :RegisterOptionsTable(appName, options, slashcmd) -- -- - appName - (string) application name -- - options - table or function ref, see AceConfigRegistry diff --git a/Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua b/Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua index d57b008..ec811d0 100644 --- a/Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua +++ b/Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua @@ -1,7 +1,7 @@ --[[----------------------------------------------------------------------------- ColorPicker Widget -------------------------------------------------------------------------------]] -local Type, Version = "ColorPicker", 25 +local Type, Version = "ColorPicker", 28 local AceGUI = LibStub and LibStub("AceGUI-3.0", true) if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end @@ -11,13 +11,24 @@ local pairs = pairs -- WoW APIs local CreateFrame, UIParent = CreateFrame, UIParent +-- Unfortunately we have no way to realistically detect if a client uses inverted alpha +-- as no API will tell you. Wrath uses the old colorpicker, era uses the new one, both are inverted +local INVERTED_ALPHA = (WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE) + --[[----------------------------------------------------------------------------- Support functions -------------------------------------------------------------------------------]] local function ColorCallback(self, r, g, b, a, isAlpha) + if INVERTED_ALPHA and a then + a = 1 - a + end if not self.HasAlpha then a = 1 end + -- no change, skip update + if r == self.r and g == self.g and b == self.b and a == self.a then + return + end self:SetColor(r, g, b, a) if ColorPickerFrame:IsVisible() then --colorpicker is still open @@ -50,30 +61,63 @@ local function ColorSwatch_OnClick(frame) ColorPickerFrame:SetFrameLevel(frame:GetFrameLevel() + 10) ColorPickerFrame:SetClampedToScreen(true) - ColorPickerFrame.func = function() - local r, g, b = ColorPickerFrame:GetColorRGB() - local a = 1 - OpacitySliderFrame:GetValue() - ColorCallback(self, r, g, b, a) - end - - ColorPickerFrame.hasOpacity = self.HasAlpha - ColorPickerFrame.opacityFunc = function() - local r, g, b = ColorPickerFrame:GetColorRGB() - local a = 1 - OpacitySliderFrame:GetValue() - ColorCallback(self, r, g, b, a, true) - end - - local r, g, b, a = self.r, self.g, self.b, self.a - if self.HasAlpha then - ColorPickerFrame.opacity = 1 - (a or 0) - end - ColorPickerFrame:SetColorRGB(r, g, b) - - ColorPickerFrame.cancelFunc = function() - ColorCallback(self, r, g, b, a, true) + if ColorPickerFrame.SetupColorPickerAndShow then -- 10.2.5 color picker overhaul + local r2, g2, b2, a2 = self.r, self.g, self.b, (self.a or 1) + if INVERTED_ALPHA then + a2 = 1 - a2 + end + + local info = { + swatchFunc = function() + local r, g, b = ColorPickerFrame:GetColorRGB() + local a = ColorPickerFrame:GetColorAlpha() + ColorCallback(self, r, g, b, a) + end, + + hasOpacity = self.HasAlpha, + opacityFunc = function() + local r, g, b = ColorPickerFrame:GetColorRGB() + local a = ColorPickerFrame:GetColorAlpha() + ColorCallback(self, r, g, b, a, true) + end, + opacity = a2, + + cancelFunc = function() + ColorCallback(self, r2, g2, b2, a2, true) + end, + + r = r2, + g = g2, + b = b2, + } + + ColorPickerFrame:SetupColorPickerAndShow(info) + else + ColorPickerFrame.func = function() + local r, g, b = ColorPickerFrame:GetColorRGB() + local a = OpacitySliderFrame:GetValue() + ColorCallback(self, r, g, b, a) + end + + ColorPickerFrame.hasOpacity = self.HasAlpha + ColorPickerFrame.opacityFunc = function() + local r, g, b = ColorPickerFrame:GetColorRGB() + local a = OpacitySliderFrame:GetValue() + ColorCallback(self, r, g, b, a, true) + end + + local r, g, b, a = self.r, self.g, self.b, 1 - (self.a or 1) + if self.HasAlpha then + ColorPickerFrame.opacity = a + end + ColorPickerFrame:SetColorRGB(r, g, b) + + ColorPickerFrame.cancelFunc = function() + ColorCallback(self, r, g, b, a, true) + end + + ColorPickerFrame:Show() end - - ColorPickerFrame:Show() end AceGUI:ClearFocus() end diff --git a/Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua b/Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua index bb1e4fd..f2a238b 100644 --- a/Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua +++ b/Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua @@ -1,7 +1,7 @@ --[[----------------------------------------------------------------------------- EditBox Widget -------------------------------------------------------------------------------]] -local Type, Version = "EditBox", 28 +local Type, Version = "EditBox", 29 local AceGUI = LibStub and LibStub("AceGUI-3.0", true) if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end @@ -10,7 +10,7 @@ local tostring, pairs = tostring, pairs -- WoW APIs local PlaySound = PlaySound -local GetCursorInfo, ClearCursor, GetSpellInfo = GetCursorInfo, ClearCursor, GetSpellInfo +local GetCursorInfo, ClearCursor = GetCursorInfo, ClearCursor local CreateFrame, UIParent = CreateFrame, UIParent local _G = _G @@ -76,12 +76,16 @@ end local function EditBox_OnReceiveDrag(frame) local self = frame.obj - local type, id, info = GetCursorInfo() + local type, id, info, extra = GetCursorInfo() local name if type == "item" then name = info elseif type == "spell" then - name = GetSpellInfo(id, info) + if C_Spell and C_Spell.GetSpellName then + name = C_Spell.GetSpellName(extra) + else + name = GetSpellInfo(id, info) + end elseif type == "macro" then name = GetMacroInfo(id) end diff --git a/Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua b/Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua index bacb2be..f0095b5 100644 --- a/Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua +++ b/Titan/libs/Ace/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua @@ -1,4 +1,4 @@ -local Type, Version = "MultiLineEditBox", 32 +local Type, Version = "MultiLineEditBox", 33 local AceGUI = LibStub and LibStub("AceGUI-3.0", true) if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end @@ -6,7 +6,7 @@ if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end local pairs = pairs -- WoW APIs -local GetCursorInfo, GetSpellInfo, ClearCursor = GetCursorInfo, GetSpellInfo, ClearCursor +local GetCursorInfo, ClearCursor = GetCursorInfo, ClearCursor local CreateFrame, UIParent = CreateFrame, UIParent local _G = _G @@ -100,9 +100,13 @@ local function OnMouseUp(self) end local function OnReceiveDrag(self) -- EditBox / ScrollFrame - local type, id, info = GetCursorInfo() + local type, id, info, extra = GetCursorInfo() if type == "spell" then - info = GetSpellInfo(id, info) + if C_Spell and C_Spell.GetSpellName then + info = C_Spell.GetSpellName(extra) + else + info = GetSpellInfo(id, info) + end elseif type ~= "item" then return end diff --git a/Titan/libs/Ace/AceTimer-3.0/AceTimer-3.0.lua b/Titan/libs/Ace/AceTimer-3.0/AceTimer-3.0.lua index 8776da2..78fb4ed 100644 --- a/Titan/libs/Ace/AceTimer-3.0/AceTimer-3.0.lua +++ b/Titan/libs/Ace/AceTimer-3.0/AceTimer-3.0.lua @@ -15,7 +15,7 @@ -- make into AceTimer. -- @class file -- @name AceTimer-3.0 --- @release $Id: AceTimer-3.0.lua 1284 2022-09-25 09:15:30Z nevcairiel $ +-- @release $Id: AceTimer-3.0.lua 1342 2024-05-26 11:49:35Z nevcairiel $ local MAJOR, MINOR = "AceTimer-3.0", 17 -- Bump minor on changes local AceTimer, oldminor = LibStub:NewLibrary(MAJOR, MINOR) @@ -78,7 +78,7 @@ end --- Schedule a new one-shot timer. -- The timer will fire once in `delay` seconds, unless canceled before. --- @param callback Callback function for the timer pulse (funcref or method name). +-- @param func Callback function for the timer pulse (funcref or method name). -- @param delay Delay for the timer, in seconds. -- @param ... An optional, unlimited amount of arguments to pass to the callback function. -- @usage @@ -107,7 +107,7 @@ end --- Schedule a repeating timer. -- The timer will fire every `delay` seconds, until canceled. --- @param callback Callback function for the timer pulse (funcref or method name). +-- @param func Callback function for the timer pulse (funcref or method name). -- @param delay Delay for the timer, in seconds. -- @param ... An optional, unlimited amount of arguments to pass to the callback function. -- @usage diff --git a/Titan/libs/Ace/CHANGES.txt b/Titan/libs/Ace/CHANGES.txt index 6a71b16..e9aeca1 100644 --- a/Titan/libs/Ace/CHANGES.txt +++ b/Titan/libs/Ace/CHANGES.txt @@ -1,109 +1,53 @@ ------------------------------------------------------------------------ -r1308 | nevcairiel | 2023-07-12 10:15:09 +0000 (Wed, 12 Jul 2023) | 1 line +r1348 | nevcairiel | 2024-07-23 11:23:40 +0000 (Tue, 23 Jul 2024) | 1 line Changed paths: - M /trunk M /trunk/changelog.txt Update changelog ------------------------------------------------------------------------ -r1307 | funkehdude | 2023-07-12 02:24:07 +0000 (Wed, 12 Jul 2023) | 1 line +r1347 | nevcairiel | 2024-07-23 11:23:22 +0000 (Tue, 23 Jul 2024) | 1 line Changed paths: M /trunk/Ace3.toc -bump toc +Remove outdated TOC versions that are no longer maintained/tested ------------------------------------------------------------------------ -r1306 | nevcairiel | 2023-06-23 14:55:09 +0000 (Fri, 23 Jun 2023) | 9 lines +r1346 | nevcairiel | 2024-07-20 07:10:33 +0000 (Sat, 20 Jul 2024) | 1 line Changed paths: M /trunk M /trunk/.luacheckrc - M /trunk/AceDB-3.0/AceDB-3.0.lua - -AceDB-3.0: Add fallbacks for region names - -PTRs now return region 72, instead of extending the table fallback to -GetCurrentRegionName(), and an absolute fallback if even that fails, so -AceDB does not error out on loading. - -GetCurrentRegionName() could be used as the primary source, instead of -the look-up table, however we need to confirm first that the region keys -would remain stable. ------------------------------------------------------------------------- -r1305 | funkehdude | 2023-06-21 11:59:15 +0000 (Wed, 21 Jun 2023) | 1 line -Changed paths: - M /trunk/Ace3_Wrath.toc - -bump wrath toc ------------------------------------------------------------------------- -r1304 | nevcairiel | 2023-05-19 19:50:10 +0000 (Fri, 19 May 2023) | 1 line -Changed paths: - M /trunk - M /trunk/AceDBOptions-3.0/AceDBOptions-3.0.lua - -AceDBOptions-3.0: Minor locale fixes for russian ------------------------------------------------------------------------- -r1303 | nevcairiel | 2023-05-16 15:05:10 +0000 (Tue, 16 May 2023) | 3 lines -Changed paths: - M /trunk - M /trunk/AceDBOptions-3.0/AceDBOptions-3.0.lua + M /trunk/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua + M /trunk/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua -AceDBOptions-3.0: Update locale strings - -Fixes WoWAce #629 +AceGUI-3.0: Editboxes: Update spell drag-and-drop for WoW 11.0 ------------------------------------------------------------------------ -r1302 | nevcairiel | 2023-05-03 07:00:09 +0000 (Wed, 03 May 2023) | 1 line +r1345 | funkehdude | 2024-07-09 19:31:35 +0000 (Tue, 09 Jul 2024) | 1 line Changed paths: - M /trunk M /trunk/Ace3.toc -Update TOC for 10.1 ------------------------------------------------------------------------- -r1301 | funkehdude | 2023-03-22 02:53:32 +0000 (Wed, 22 Mar 2023) | 1 line -Changed paths: - M /trunk/Ace3.toc - -bump toc ------------------------------------------------------------------------- -r1300 | funkehdude | 2023-01-28 00:06:37 +0000 (Sat, 28 Jan 2023) | 1 line -Changed paths: - M /trunk/Ace3.toc - -bump toc ------------------------------------------------------------------------- -r1299 | funkehdude | 2023-01-22 03:36:39 +0000 (Sun, 22 Jan 2023) | 1 line -Changed paths: - M /trunk/Ace3_Wrath.toc - bump toc ------------------------------------------------------------------------ -r1298 | nevcairiel | 2022-12-12 15:10:10 +0000 (Mon, 12 Dec 2022) | 1 line +r1344 | nevcairiel | 2024-07-03 10:50:13 +0000 (Wed, 03 Jul 2024) | 1 line Changed paths: M /trunk - M /trunk/.luacheckrc - M /trunk/CallbackHandler-1.0/CallbackHandler-1.0.lua + M /trunk/Ace3.toc -Update CallbackHandler to rev 8 +Add 11.0.2 TOC ------------------------------------------------------------------------ -r1297 | funkehdude | 2022-11-15 01:19:09 +0000 (Tue, 15 Nov 2022) | 1 line +r1343 | funkehdude | 2024-06-06 06:04:02 +0000 (Thu, 06 Jun 2024) | 1 line Changed paths: M /trunk/Ace3.toc + D /trunk/Ace3_Cata.toc + D /trunk/Ace3_TBC.toc + D /trunk/Ace3_Vanilla.toc + D /trunk/Ace3_Wrath.toc -bump toc +Update toc structure ------------------------------------------------------------------------ -r1296 | nevcairiel | 2022-11-04 18:50:10 +0000 (Fri, 04 Nov 2022) | 4 lines +r1342 | nevcairiel | 2024-05-26 11:49:35 +0000 (Sun, 26 May 2024) | 1 line Changed paths: M /trunk - M /trunk/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua - M /trunk/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.lua + M /trunk/AceTimer-3.0/AceTimer-3.0.lua -AceConfigDialog-3.0: Add support for displaying items on hover in GameTooltip - -This adds a new element to the config table, "tooltipHyperlink", which -will be used to fill the tooltip when hovering over the element. ------------------------------------------------------------------------- -r1295 | funkehdude | 2022-10-26 01:18:39 +0000 (Wed, 26 Oct 2022) | 1 line -Changed paths: - M /trunk/Ace3.toc - -bump toc +AceTimer-3.0: fix callback parameter name in docs ------------------------------------------------------------------------ diff --git a/Titan/libs/Ace/LibQTip-1.0/CHANGELOG.md b/Titan/libs/Ace/LibQTip-1.0/CHANGELOG.md new file mode 100644 index 0000000..a4fdb13 --- /dev/null +++ b/Titan/libs/Ace/LibQTip-1.0/CHANGELOG.md @@ -0,0 +1,10 @@ +# Lib: QTip-1.0 + +## [10.0.7.1](https://github.com/Torhal/LibQTip-1.0/tree/10.0.7.1) (2023-03-29) +[Full Changelog](https://github.com/Torhal/LibQTip-1.0/compare/9.0.1.2...10.0.7.1) [Previous Releases](https://github.com/Torhal/LibQTip-1.0/releases) + +- Create release.yml + Add release configuration for the BigWigs Packager. +- Update ToC Interface and add X-Curse-Project-ID to support the BigWigs Packager. +- Create README.md +- update for WoW 9.1.5's new TooltipBackdropTemplate diff --git a/Titan/libs/Ace/LibQTip-1.0/CHANGES.txt b/Titan/libs/Ace/LibQTip-1.0/CHANGES.txt deleted file mode 100644 index 904cffc..0000000 --- a/Titan/libs/Ace/LibQTip-1.0/CHANGES.txt +++ /dev/null @@ -1,10 +0,0 @@ -lightweight tag 5f307596c9a7618e36d529b7af3c331e4808be9f 9.0.1.2 -Author: James D. Callahan III <darkenelf@gmail.com> -Date: Sun Oct 25 17:33:10 2020 -0500 - -commit 5f307596c9a7618e36d529b7af3c331e4808be9f -Author: James D. Callahan III <darkenelf@gmail.com> -Date: Sun Oct 25 17:33:10 2020 -0500 - - Update ToC Interface for the WoW 9.0.1 version. - diff --git a/Titan/libs/Ace/LibQTip-1.0/LibQTip-1.0.lua b/Titan/libs/Ace/LibQTip-1.0/LibQTip-1.0.lua index b7c7ce3..586bcca 100644 --- a/Titan/libs/Ace/LibQTip-1.0/LibQTip-1.0.lua +++ b/Titan/libs/Ace/LibQTip-1.0/LibQTip-1.0.lua @@ -1,5 +1,5 @@ local MAJOR = "LibQTip-1.0" -local MINOR = 48 -- Should be manually increased +local MINOR = 49 -- Should be manually increased local LibStub = _G.LibStub assert(LibStub, MAJOR .. " requires LibStub") @@ -7,7 +7,7 @@ assert(LibStub, MAJOR .. " requires LibStub") local lib, oldMinor = LibStub:NewLibrary(MAJOR, MINOR) if not lib then - return + return end -- No upgrade needed ------------------------------------------------------------------------------ @@ -37,12 +37,7 @@ local geterrorhandler = _G.geterrorhandler ------------------------------------------------------------------------------ -- Tables and locals ------------------------------------------------------------------------------ -if BackdropTemplateMixin and oldMinor and (oldMinor < 48) and lib.frameMetatable then - -- mix new BackdropTemplateMixin into frame metatable - Mixin(lib.frameMetatable["__index"], BackdropTemplateMixin) -else - lib.frameMetatable = lib.frameMetatable or {__index = CreateFrame("Frame", nil, nil, BackdropTemplateMixin and "BackdropTemplate")} -end +lib.frameMetatable = lib.frameMetatable or {__index = CreateFrame("Frame")} lib.tipPrototype = lib.tipPrototype or setmetatable({}, lib.frameMetatable) lib.tipMetatable = lib.tipMetatable or {__index = lib.tipPrototype} @@ -100,7 +95,7 @@ local SetFrameScript, ClearFrameScripts ------------------------------------------------------------------------------ -- @debug @ local usedTables, usedFrames, usedTooltips = 0, 0, 0 ---@end-debug@ +--@end-debug@]==] ------------------------------------------------------------------------------ -- Internal constants to tweak the layout @@ -121,51 +116,51 @@ local CELL_MARGIN_V = 3 -- @usage Acquire a tooltip with at least 5 columns, justification : left, center, left, left, left -- <pre>local tip = LibStub('LibQTip-1.0'):Acquire('MyFooBarTooltip', 5, "LEFT", "CENTER")</pre> function lib:Acquire(key, ...) - if key == nil then - error("attempt to use a nil key", 2) - end + if key == nil then + error("attempt to use a nil key", 2) + end - local tooltip = activeTooltips[key] + local tooltip = activeTooltips[key] - if not tooltip then - tooltip = AcquireTooltip() - InitializeTooltip(tooltip, key) - activeTooltips[key] = tooltip - end + if not tooltip then + tooltip = AcquireTooltip() + InitializeTooltip(tooltip, key) + activeTooltips[key] = tooltip + end - if select("#", ...) > 0 then - -- Here we catch any error to properly report it for the calling code - local ok, msg = pcall(tooltip.SetColumnLayout, tooltip, ...) + if select("#", ...) > 0 then + -- Here we catch any error to properly report it for the calling code + local ok, msg = pcall(tooltip.SetColumnLayout, tooltip, ...) - if not ok then - error(msg, 2) - end - end + if not ok then + error(msg, 2) + end + end - return tooltip + return tooltip end function lib:Release(tooltip) - local key = tooltip and tooltip.key + local key = tooltip and tooltip.key - if not key or activeTooltips[key] ~= tooltip then - return - end + if not key or activeTooltips[key] ~= tooltip then + return + end - ReleaseTooltip(tooltip) - activeTooltips[key] = nil + ReleaseTooltip(tooltip) + activeTooltips[key] = nil end function lib:IsAcquired(key) - if key == nil then - error("attempt to use a nil key", 2) - end + if key == nil then + error("attempt to use a nil key", 2) + end - return not (not activeTooltips[key]) + return not (not activeTooltips[key]) end function lib:IterateTooltips() - return pairs(activeTooltips) + return pairs(activeTooltips) end ------------------------------------------------------------------------------ @@ -174,26 +169,26 @@ end local frameHeap = lib.frameHeap local function AcquireFrame(parent) - local frame = tremove(frameHeap) or CreateFrame("Frame", nil, nil, BackdropTemplateMixin and "BackdropTemplate") - frame:SetParent(parent) - --[===[@debug@ - usedFrames = usedFrames + 1 - --@end-debug@]===] - return frame + local frame = tremove(frameHeap) or CreateFrame("Frame", nil, nil, BackdropTemplateMixin and "BackdropTemplate") + frame:SetParent(parent) + --[==[@debug@ + usedFrames = usedFrames + 1 + --@end-debug@]==] + return frame end local function ReleaseFrame(frame) - frame:Hide() - frame:SetParent(nil) - frame:ClearAllPoints() - frame:SetBackdrop(nil) + frame:Hide() + frame:SetParent(nil) + frame:ClearAllPoints() + frame:SetBackdrop(nil) - ClearFrameScripts(frame) + ClearFrameScripts(frame) - tinsert(frameHeap, frame) - --[===[@debug@ - usedFrames = usedFrames - 1 - --@end-debug@]===] + tinsert(frameHeap, frame) + --[==[@debug@ + usedFrames = usedFrames - 1 + --@end-debug@]==] end ------------------------------------------------------------------------------ @@ -202,18 +197,18 @@ end local timerHeap = lib.timerHeap local function AcquireTimer(parent) - local frame = tremove(timerHeap) or CreateFrame("Frame") - frame:SetParent(parent) - return frame + local frame = tremove(timerHeap) or CreateFrame("Frame") + frame:SetParent(parent) + return frame end local function ReleaseTimer(frame) - frame:Hide() - frame:SetParent(nil) + frame:Hide() + frame:SetParent(nil) - ClearFrameScripts(frame) + ClearFrameScripts(frame) - tinsert(timerHeap, frame) + tinsert(timerHeap, frame) end ------------------------------------------------------------------------------ @@ -225,18 +220,18 @@ local layoutCleaner = lib.layoutCleaner layoutCleaner.registry = layoutCleaner.registry or {} function layoutCleaner:RegisterForCleanup(tooltip) - self.registry[tooltip] = true - self:Show() + self.registry[tooltip] = true + self:Show() end function layoutCleaner:CleanupLayouts() - self:Hide() + self:Hide() - for tooltip in pairs(self.registry) do - FixCellSizes(tooltip) - end + for tooltip in pairs(self.registry) do + FixCellSizes(tooltip) + end - wipe(self.registry) + wipe(self.registry) end layoutCleaner:SetScript("OnUpdate", layoutCleaner.CleanupLayouts) @@ -245,136 +240,137 @@ layoutCleaner:SetScript("OnUpdate", layoutCleaner.CleanupLayouts) -- CellProvider and Cell ------------------------------------------------------------------------------ function providerPrototype:AcquireCell() - local cell = tremove(self.heap) + local cell = tremove(self.heap) - if not cell then - cell = setmetatable(CreateFrame("Frame", nil, UIParent), self.cellMetatable) + if not cell then + cell = CreateFrame("Frame", nil, UIParent, BackdropTemplateMixin and "BackdropTemplate") + setmetatable(cell, self.cellMetatable) - if type(cell.InitializeCell) == "function" then - cell:InitializeCell() - end - end + if type(cell.InitializeCell) == "function" then + cell:InitializeCell() + end + end - self.cells[cell] = true + self.cells[cell] = true - return cell + return cell end function providerPrototype:ReleaseCell(cell) - if not self.cells[cell] then - return - end + if not self.cells[cell] then + return + end - if type(cell.ReleaseCell) == "function" then - cell:ReleaseCell() - end + if type(cell.ReleaseCell) == "function" then + cell:ReleaseCell() + end - self.cells[cell] = nil - tinsert(self.heap, cell) + self.cells[cell] = nil + tinsert(self.heap, cell) end function providerPrototype:GetCellPrototype() - return self.cellPrototype, self.cellMetatable + return self.cellPrototype, self.cellMetatable end function providerPrototype:IterateCells() - return pairs(self.cells) + return pairs(self.cells) end function lib:CreateCellProvider(baseProvider) - local cellBaseMetatable, cellBasePrototype + local cellBaseMetatable, cellBasePrototype - if baseProvider and baseProvider.GetCellPrototype then - cellBasePrototype, cellBaseMetatable = baseProvider:GetCellPrototype() - else - cellBaseMetatable = cellMetatable - end + if baseProvider and baseProvider.GetCellPrototype then + cellBasePrototype, cellBaseMetatable = baseProvider:GetCellPrototype() + else + cellBaseMetatable = cellMetatable + end - local newCellPrototype = setmetatable({}, cellBaseMetatable) - local newCellProvider = setmetatable({}, providerMetatable) + local newCellPrototype = setmetatable({}, cellBaseMetatable) + local newCellProvider = setmetatable({}, providerMetatable) - newCellProvider.heap = {} - newCellProvider.cells = {} - newCellProvider.cellPrototype = newCellPrototype - newCellProvider.cellMetatable = {__index = newCellPrototype} + newCellProvider.heap = {} + newCellProvider.cells = {} + newCellProvider.cellPrototype = newCellPrototype + newCellProvider.cellMetatable = {__index = newCellPrototype} - return newCellProvider, newCellPrototype, cellBasePrototype + return newCellProvider, newCellPrototype, cellBasePrototype end ------------------------------------------------------------------------------ -- Basic label provider ------------------------------------------------------------------------------ if not lib.LabelProvider then - lib.LabelProvider, lib.LabelPrototype = lib:CreateCellProvider() + lib.LabelProvider, lib.LabelPrototype = lib:CreateCellProvider() end local labelProvider = lib.LabelProvider local labelPrototype = lib.LabelPrototype function labelPrototype:InitializeCell() - self.fontString = self:CreateFontString() - self.fontString:SetFontObject(_G.GameTooltipText) + self.fontString = self:CreateFontString() + self.fontString:SetFontObject(_G.GameTooltipText) end function labelPrototype:SetupCell(tooltip, value, justification, font, leftPadding, rightPadding, maxWidth, minWidth, ...) - local fontString = self.fontString - local line = tooltip.lines[self._line] + local fontString = self.fontString + local line = tooltip.lines[self._line] - -- detatch fs from cell for size calculations - fontString:ClearAllPoints() - fontString:SetFontObject(font or (line.is_header and tooltip:GetHeaderFont() or tooltip:GetFont())) - fontString:SetJustifyH(justification) - fontString:SetText(tostring(value)) + -- detatch fs from cell for size calculations + fontString:ClearAllPoints() + fontString:SetFontObject(font or (line.is_header and tooltip:GetHeaderFont() or tooltip:GetFont())) + fontString:SetJustifyH(justification) + fontString:SetText(tostring(value)) - leftPadding = leftPadding or 0 - rightPadding = rightPadding or 0 + leftPadding = leftPadding or 0 + rightPadding = rightPadding or 0 - local width = fontString:GetStringWidth() + leftPadding + rightPadding + local width = fontString:GetStringWidth() + leftPadding + rightPadding - if maxWidth and minWidth and (maxWidth < minWidth) then - error("maximum width cannot be lower than minimum width: " .. tostring(maxWidth) .. " < " .. tostring(minWidth), 2) - end + if maxWidth and minWidth and (maxWidth < minWidth) then + error("maximum width cannot be lower than minimum width: " .. tostring(maxWidth) .. " < " .. tostring(minWidth), 2) + end - if maxWidth and (maxWidth < (leftPadding + rightPadding)) then - error("maximum width cannot be lower than the sum of paddings: " .. tostring(maxWidth) .. " < " .. tostring(leftPadding) .. " + " .. tostring(rightPadding), 2) - end + if maxWidth and (maxWidth < (leftPadding + rightPadding)) then + error("maximum width cannot be lower than the sum of paddings: " .. tostring(maxWidth) .. " < " .. tostring(leftPadding) .. " + " .. tostring(rightPadding), 2) + end - if minWidth and width < minWidth then - width = minWidth - end + if minWidth and width < minWidth then + width = minWidth + end - if maxWidth and maxWidth < width then - width = maxWidth - end + if maxWidth and maxWidth < width then + width = maxWidth + end - fontString:SetWidth(width - (leftPadding + rightPadding)) - -- Use GetHeight() instead of GetStringHeight() so lines which are longer than width will wrap. - local height = fontString:GetHeight() + fontString:SetWidth(width - (leftPadding + rightPadding)) + -- Use GetHeight() instead of GetStringHeight() so lines which are longer than width will wrap. + local height = fontString:GetHeight() - -- reanchor fs to cell - fontString:SetWidth(0) - fontString:SetPoint("TOPLEFT", self, "TOPLEFT", leftPadding, 0) - fontString:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -rightPadding, 0) - --~ fs:SetPoint("TOPRIGHT", self, "TOPRIGHT", -r_pad, 0) + -- reanchor fs to cell + fontString:SetWidth(0) + fontString:SetPoint("TOPLEFT", self, "TOPLEFT", leftPadding, 0) + fontString:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -rightPadding, 0) + --~ fs:SetPoint("TOPRIGHT", self, "TOPRIGHT", -r_pad, 0) - self._paddingL = leftPadding - self._paddingR = rightPadding + self._paddingL = leftPadding + self._paddingR = rightPadding - return width, height + return width, height end function labelPrototype:getContentHeight() - local fontString = self.fontString - fontString:SetWidth(self:GetWidth() - (self._paddingL + self._paddingR)) + local fontString = self.fontString + fontString:SetWidth(self:GetWidth() - (self._paddingL + self._paddingR)) - local height = self.fontString:GetHeight() - fontString:SetWidth(0) + local height = self.fontString:GetHeight() + fontString:SetWidth(0) - return height + return height end function labelPrototype:GetPosition() - return self._line, self._column + return self._line, self._column end ------------------------------------------------------------------------------ @@ -384,93 +380,102 @@ local tooltipHeap = lib.tooltipHeap -- Returns a tooltip function AcquireTooltip() - local tooltip = tremove(tooltipHeap) + local tooltip = tremove(tooltipHeap) - if not tooltip then - tooltip = CreateFrame("Frame", nil, UIParent) + if not tooltip then + local template = (TooltipBackdropTemplateMixin and "TooltipBackdropTemplate") or (BackdropTemplateMixin and "BackdropTemplate") + tooltip = CreateFrame("Frame", nil, UIParent, template) - local scrollFrame = CreateFrame("ScrollFrame", nil, tooltip) - scrollFrame:SetPoint("TOP", tooltip, "TOP", 0, -TOOLTIP_PADDING) - scrollFrame:SetPoint("BOTTOM", tooltip, "BOTTOM", 0, TOOLTIP_PADDING) - scrollFrame:SetPoint("LEFT", tooltip, "LEFT", TOOLTIP_PADDING, 0) - scrollFrame:SetPoint("RIGHT", tooltip, "RIGHT", -TOOLTIP_PADDING, 0) - tooltip.scrollFrame = scrollFrame + local scrollFrame = CreateFrame("ScrollFrame", nil, tooltip) + scrollFrame:SetPoint("TOP", tooltip, "TOP", 0, -TOOLTIP_PADDING) + scrollFrame:SetPoint("BOTTOM", tooltip, "BOTTOM", 0, TOOLTIP_PADDING) + scrollFrame:SetPoint("LEFT", tooltip, "LEFT", TOOLTIP_PADDING, 0) + scrollFrame:SetPoint("RIGHT", tooltip, "RIGHT", -TOOLTIP_PADDING, 0) + tooltip.scrollFrame = scrollFrame - local scrollChild = CreateFrame("Frame", nil, tooltip.scrollFrame) - scrollFrame:SetScrollChild(scrollChild) - tooltip.scrollChild = scrollChild + local scrollChild = CreateFrame("Frame", nil, tooltip.scrollFrame) + scrollFrame:SetScrollChild(scrollChild) + tooltip.scrollChild = scrollChild - setmetatable(tooltip, tipMetatable) - end + setmetatable(tooltip, tipMetatable) + end - --[===[@debug@ - usedTooltips = usedTooltips + 1 - --@end-debug@]===] - return tooltip + --[==[@debug@ + usedTooltips = usedTooltips + 1 + --@end-debug@]==] + return tooltip end -- Cleans the tooltip and stores it in the cache function ReleaseTooltip(tooltip) - if tooltip.releasing then - return - end + if tooltip.releasing then + return + end + + tooltip.releasing = true + tooltip:Hide() + + local releaseHandler = lib.onReleaseHandlers[tooltip] - tooltip.releasing = true - tooltip:Hide() + if releaseHandler then + lib.onReleaseHandlers[tooltip] = nil - local releaseHandler = lib.onReleaseHandlers[tooltip] + local success, errorMessage = pcall(releaseHandler, tooltip) - if releaseHandler then - lib.onReleaseHandlers[tooltip] = nil + if not success then + geterrorhandler()(errorMessage) + end + elseif tooltip.OnRelease then + local success, errorMessage = pcall(tooltip.OnRelease, tooltip) + if not success then + geterrorhandler()(errorMessage) + end - local success, errorMessage = pcall(releaseHandler, tooltip) + tooltip.OnRelease = nil + end - if not success then - geterrorhandler()(errorMessage) - end - elseif tooltip.OnRelease then - local success, errorMessage = pcall(tooltip.OnRelease, tooltip) - if not success then - geterrorhandler()(errorMessage) - end + tooltip.releasing = nil + tooltip.key = nil + tooltip.step = nil - tooltip.OnRelease = nil - end + ClearTooltipScripts(tooltip) - tooltip.releasing = nil - tooltip.key = nil - tooltip.step = nil + tooltip:SetAutoHideDelay(nil) + tooltip:ClearAllPoints() + tooltip:Clear() - ClearTooltipScripts(tooltip) + if tooltip.slider then + tooltip.slider:SetValue(0) + tooltip.slider:Hide() + tooltip.scrollFrame:SetPoint("RIGHT", tooltip, "RIGHT", -TOOLTIP_PADDING, 0) + tooltip:EnableMouseWheel(false) + end - tooltip:SetAutoHideDelay(nil) - tooltip:ClearAllPoints() - tooltip:Clear() + for i, column in ipairs(tooltip.columns) do + tooltip.columns[i] = ReleaseFrame(column) + end - if tooltip.slider then - tooltip.slider:SetValue(0) - tooltip.slider:Hide() - tooltip.scrollFrame:SetPoint("RIGHT", tooltip, "RIGHT", -TOOLTIP_PADDING, 0) - tooltip:EnableMouseWheel(false) - end + tooltip.columns = ReleaseTable(tooltip.columns) + tooltip.lines = ReleaseTable(tooltip.lines) + tooltip.colspans = ReleaseTable(tooltip.colspans) - for i, column in ipairs(tooltip.columns) do - tooltip.columns[i] = ReleaseFrame(column) - end + layoutCleaner.registry[tooltip] = nil - tooltip.columns = ReleaseTable(tooltip.columns) - tooltip.lines = ReleaseTable(tooltip.lines) - tooltip.colspans = ReleaseTable(tooltip.colspans) + if TooltipBackdropTemplateMixin and not tooltip.NineSlice then + -- don't recycle outdated tooltips into heap + tooltip = nil + end - layoutCleaner.registry[tooltip] = nil - tinsert(tooltipHeap, tooltip) + if tooltip then + tinsert(tooltipHeap, tooltip) + end - highlightTexture:SetTexture(DEFAULT_HIGHLIGHT_TEXTURE_PATH) - highlightTexture:SetTexCoord(0, 1, 0, 1) + highlightTexture:SetTexture(DEFAULT_HIGHLIGHT_TEXTURE_PATH) + highlightTexture:SetTexCoord(0, 1, 0, 1) - --[===[@debug@ - usedTooltips = usedTooltips - 1 - --@end-debug@]===] + --[==[@debug@ + usedTooltips = usedTooltips - 1 + --@end-debug@]==] end ------------------------------------------------------------------------------ @@ -478,36 +483,36 @@ end ------------------------------------------------------------------------------ -- Returns a cell for the given tooltip from the given provider function AcquireCell(tooltip, provider) - local cell = provider:AcquireCell(tooltip) + local cell = provider:AcquireCell(tooltip) - cell:SetParent(tooltip.scrollChild) - cell:SetFrameLevel(tooltip.scrollChild:GetFrameLevel() + 3) - cell._provider = provider + cell:SetParent(tooltip.scrollChild) + cell:SetFrameLevel(tooltip.scrollChild:GetFrameLevel() + 3) + cell._provider = provider - return cell + return cell end -- Cleans the cell hands it to its provider for storing function ReleaseCell(cell) - if cell.fontString and cell.r then - cell.fontString:SetTextColor(cell.r, cell.g, cell.b, cell.a) - end + if cell.fontString and cell.r then + cell.fontString:SetTextColor(cell.r, cell.g, cell.b, cell.a) + end - cell._font = nil - cell._justification = nil - cell._colSpan = nil - cell._line = nil - cell._column = nil + cell._font = nil + cell._justification = nil + cell._colSpan = nil + cell._line = nil + cell._column = nil - cell:Hide() - cell:ClearAllPoints() - cell:SetParent(nil) - cell:SetBackdrop(nil) + cell:Hide() + cell:ClearAllPoints() + cell:SetParent(nil) + cell:SetBackdrop(nil) - ClearFrameScripts(cell) + ClearFrameScripts(cell) - cell._provider:ReleaseCell(cell) - cell._provider = nil + cell._provider:ReleaseCell(cell) + cell._provider = nil end ------------------------------------------------------------------------------ @@ -517,144 +522,153 @@ local tableHeap = lib.tableHeap -- Returns a table function AcquireTable() - local tbl = tremove(tableHeap) or {} - --[===[@debug@ - usedTables = usedTables + 1 - --@end-debug@]===] - return tbl + local tbl = tremove(tableHeap) or {} + --[==[@debug@ + usedTables = usedTables + 1 + --@end-debug@]==] + return tbl end -- Cleans the table and stores it in the cache function ReleaseTable(tableInstance) - wipe(tableInstance) - tinsert(tableHeap, tableInstance) - --[===[@debug@ - usedTables = usedTables - 1 - --@end-debug@]===] + wipe(tableInstance) + tinsert(tableHeap, tableInstance) + --[==[@debug@ + usedTables = usedTables - 1 + --@end-debug@]==] end ------------------------------------------------------------------------------ -- Tooltip prototype ------------------------------------------------------------------------------ function InitializeTooltip(tooltip, key) - ---------------------------------------------------------------------- - -- (Re)set frame settings - ---------------------------------------------------------------------- - local backdrop = GameTooltip:GetBackdrop() - - tooltip:SetBackdrop(backdrop) - - if backdrop then - tooltip:SetBackdropColor(GameTooltip:GetBackdropColor()) - tooltip:SetBackdropBorderColor(GameTooltip:GetBackdropBorderColor()) - end - - tooltip:SetScale(GameTooltip:GetScale()) - tooltip:SetAlpha(1) - tooltip:SetFrameStrata("TOOLTIP") - tooltip:SetClampedToScreen(false) - - ---------------------------------------------------------------------- - -- Internal data. Since it's possible to Acquire twice without calling - -- release, check for pre-existence. - ---------------------------------------------------------------------- - tooltip.key = key - tooltip.columns = tooltip.columns or AcquireTable() - tooltip.lines = tooltip.lines or AcquireTable() - tooltip.colspans = tooltip.colspans or AcquireTable() - tooltip.regularFont = _G.GameTooltipText - tooltip.headerFont = _G.GameTooltipHeaderText - tooltip.labelProvider = labelProvider - tooltip.cell_margin_h = tooltip.cell_margin_h or CELL_MARGIN_H - tooltip.cell_margin_v = tooltip.cell_margin_v or CELL_MARGIN_V - - ---------------------------------------------------------------------- - -- Finishing procedures - ---------------------------------------------------------------------- - tooltip:SetAutoHideDelay(nil) - tooltip:Hide() - ResetTooltipSize(tooltip) + ---------------------------------------------------------------------- + -- (Re)set frame settings + ---------------------------------------------------------------------- + if TooltipBackdropTemplateMixin then + tooltip.layoutType = GameTooltip.layoutType + NineSlicePanelMixin.OnLoad(tooltip.NineSlice) + if GameTooltip.layoutType then + tooltip.NineSlice:SetCenterColor(GameTooltip.NineSlice:GetCenterColor()) + tooltip.NineSlice:SetBorderColor(GameTooltip.NineSlice:GetBorderColor()) + end + else + local backdrop = GameTooltip:GetBackdrop() + + tooltip:SetBackdrop(backdrop) + + if backdrop then + tooltip:SetBackdropColor(GameTooltip:GetBackdropColor()) + tooltip:SetBackdropBorderColor(GameTooltip:GetBackdropBorderColor()) + end + end + + tooltip:SetScale(GameTooltip:GetScale()) + tooltip:SetAlpha(1) + tooltip:SetFrameStrata("TOOLTIP") + tooltip:SetClampedToScreen(false) + + ---------------------------------------------------------------------- + -- Internal data. Since it's possible to Acquire twice without calling + -- release, check for pre-existence. + ---------------------------------------------------------------------- + tooltip.key = key + tooltip.columns = tooltip.columns or AcquireTable() + tooltip.lines = tooltip.lines or AcquireTable() + tooltip.colspans = tooltip.colspans or AcquireTable() + tooltip.regularFont = _G.GameTooltipText + tooltip.headerFont = _G.GameTooltipHeaderText + tooltip.labelProvider = labelProvider + tooltip.cell_margin_h = tooltip.cell_margin_h or CELL_MARGIN_H + tooltip.cell_margin_v = tooltip.cell_margin_v or CELL_MARGIN_V + + ---------------------------------------------------------------------- + -- Finishing procedures + ---------------------------------------------------------------------- + tooltip:SetAutoHideDelay(nil) + tooltip:Hide() + ResetTooltipSize(tooltip) end function tipPrototype:SetDefaultProvider(myProvider) - if not myProvider then - return - end + if not myProvider then + return + end - self.labelProvider = myProvider + self.labelProvider = myProvider end function tipPrototype:GetDefaultProvider() - return self.labelProvider + return self.labelProvider end local function checkJustification(justification, level, silent) - if justification ~= "LEFT" and justification ~= "CENTER" and justification ~= "RIGHT" then - if silent then - return false - end - error("invalid justification, must one of LEFT, CENTER or RIGHT, not: " .. tostring(justification), level + 1) - end + if justification ~= "LEFT" and justification ~= "CENTER" and justification ~= "RIGHT" then + if silent then + return false + end + error("invalid justification, must one of LEFT, CENTER or RIGHT, not: " .. tostring(justification), level + 1) + end - return true + return true end function tipPrototype:SetColumnLayout(numColumns, ...) - if type(numColumns) ~= "number" or numColumns < 1 then - error("number of columns must be a positive number, not: " .. tostring(numColumns), 2) - end + if type(numColumns) ~= "number" or numColumns < 1 then + error("number of columns must be a positive number, not: " .. tostring(numColumns), 2) + end - for i = 1, numColumns do - local justification = select(i, ...) or "LEFT" + for i = 1, numColumns do + local justification = select(i, ...) or "LEFT" - checkJustification(justification, 2) + checkJustification(justification, 2) - if self.columns[i] then - self.columns[i].justification = justification - else - self:AddColumn(justification) - end - end + if self.columns[i] then + self.columns[i].justification = justification + else + self:AddColumn(justification) + end + end end function tipPrototype:AddColumn(justification) - justification = justification or "LEFT" - checkJustification(justification, 2) + justification = justification or "LEFT" + checkJustification(justification, 2) - local colNum = #self.columns + 1 - local column = self.columns[colNum] or AcquireFrame(self.scrollChild) + local colNum = #self.columns + 1 + local column = self.columns[colNum] or AcquireFrame(self.scrollChild) - column:SetFrameLevel(self.scrollChild:GetFrameLevel() + 1) - column.justification = justification - column.width = 0 - column:SetWidth(1) - column:SetPoint("TOP", self.scrollChild) - column:SetPoint("BOTTOM", self.scrollChild) + column:SetFrameLevel(self.scrollChild:GetFrameLevel() + 1) + column.justification = justification + column.width = 0 + column:SetWidth(1) + column:SetPoint("TOP", self.scrollChild) + column:SetPoint("BOTTOM", self.scrollChild) - if colNum > 1 then - local h_margin = self.cell_margin_h or CELL_MARGIN_H + if colNum > 1 then + local h_margin = self.cell_margin_h or CELL_MARGIN_H - column:SetPoint("LEFT", self.columns[colNum - 1], "RIGHT", h_margin, 0) - SetTooltipSize(self, self.width + h_margin, self.height) - else - column:SetPoint("LEFT", self.scrollChild) - end + column:SetPoint("LEFT", self.columns[colNum - 1], "RIGHT", h_margin, 0) + SetTooltipSize(self, self.width + h_margin, self.height) + else + column:SetPoint("LEFT", self.scrollChild) + end - column:Show() - self.columns[colNum] = column + column:Show() + self.columns[colNum] = column - return colNum + return colNum end ------------------------------------------------------------------------------ -- Convenient methods ------------------------------------------------------------------------------ function tipPrototype:Release() - lib:Release(self) + lib:Release(self) end function tipPrototype:IsAcquiredBy(key) - return key ~= nil and self.key == key + return key ~= nil and self.key == key end ------------------------------------------------------------------------------ @@ -663,774 +677,774 @@ end local RawSetScript = lib.frameMetatable.__index.SetScript function ClearTooltipScripts(tooltip) - if tooltip.scripts then - for scriptType in pairs(tooltip.scripts) do - RawSetScript(tooltip, scriptType, nil) - end + if tooltip.scripts then + for scriptType in pairs(tooltip.scripts) do + RawSetScript(tooltip, scriptType, nil) + end - tooltip.scripts = ReleaseTable(tooltip.scripts) - end + tooltip.scripts = ReleaseTable(tooltip.scripts) + end end function tipPrototype:SetScript(scriptType, handler) - RawSetScript(self, scriptType, handler) + RawSetScript(self, scriptType, handler) - if handler then - if not self.scripts then - self.scripts = AcquireTable() - end + if handler then + if not self.scripts then + self.scripts = AcquireTable() + end - self.scripts[scriptType] = true - elseif self.scripts then - self.scripts[scriptType] = nil - end + self.scripts[scriptType] = true + elseif self.scripts then + self.scripts[scriptType] = nil + end end -- That might break some addons ; those addons were breaking other -- addons' tooltip though. function tipPrototype:HookScript() - geterrorhandler()(":HookScript is not allowed on LibQTip tooltips") + geterrorhandler()(":HookScript is not allowed on LibQTip tooltips") end ------------------------------------------------------------------------------ -- Scrollbar data and functions ------------------------------------------------------------------------------ local BACKDROP_SLIDER_8_8 = BACKDROP_SLIDER_8_8 or { - bgFile = "Interface\\Buttons\\UI-SliderBar-Background", - edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", - tile = true, - tileEdge = true, - tileSize = 8, - edgeSize = 8, - insets = { left = 3, right = 3, top = 6, bottom = 6 }, + bgFile = "Interface\\Buttons\\UI-SliderBar-Background", + edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", + tile = true, + tileEdge = true, + tileSize = 8, + edgeSize = 8, + insets = { left = 3, right = 3, top = 6, bottom = 6 }, }; local function slider_OnValueChanged(self) - self.scrollFrame:SetVerticalScroll(self:GetValue()) + self.scrollFrame:SetVerticalScroll(self:GetValue()) end local function tooltip_OnMouseWheel(self, delta) - local slider = self.slider - local currentValue = slider:GetValue() - local minValue, maxValue = slider:GetMinMaxValues() - local stepValue = self.step or 10 + local slider = self.slider + local currentValue = slider:GetValue() + local minValue, maxValue = slider:GetMinMaxValues() + local stepValue = self.step or 10 - if delta < 0 and currentValue < maxValue then - slider:SetValue(min(maxValue, currentValue + stepValue)) - elseif delta > 0 and currentValue > minValue then - slider:SetValue(max(minValue, currentValue - stepValue)) - end + if delta < 0 and currentValue < maxValue then + slider:SetValue(min(maxValue, currentValue + stepValue)) + elseif delta > 0 and currentValue > minValue then + slider:SetValue(max(minValue, currentValue - stepValue)) + end end -- Set the step size for the scroll bar function tipPrototype:SetScrollStep(step) - self.step = step + self.step = step end -- will resize the tooltip to fit the screen and show a scrollbar if needed function tipPrototype:UpdateScrolling(maxheight) - self:SetClampedToScreen(false) + self:SetClampedToScreen(false) - -- all data is in the tooltip; fix colspan width and prevent the layout cleaner from messing up the tooltip later - FixCellSizes(self) - layoutCleaner.registry[self] = nil + -- all data is in the tooltip; fix colspan width and prevent the layout cleaner from messing up the tooltip later + FixCellSizes(self) + layoutCleaner.registry[self] = nil - local scale = self:GetScale() - local topside = self:GetTop() - local bottomside = self:GetBottom() - local screensize = UIParent:GetHeight() / scale - local tipsize = (topside - bottomside) + local scale = self:GetScale() + local topside = self:GetTop() + local bottomside = self:GetBottom() + local screensize = UIParent:GetHeight() / scale + local tipsize = (topside - bottomside) - -- if the tooltip would be too high, limit its height and show the slider - if bottomside < 0 or topside > screensize or (maxheight and tipsize > maxheight) then - local shrink = (bottomside < 0 and (5 - bottomside) or 0) + (topside > screensize and (topside - screensize + 5) or 0) + -- if the tooltip would be too high, limit its height and show the slider + if bottomside < 0 or topside > screensize or (maxheight and tipsize > maxheight) then + local shrink = (bottomside < 0 and (5 - bottomside) or 0) + (topside > screensize and (topside - screensize + 5) or 0) - if maxheight and tipsize - shrink > maxheight then - shrink = tipsize - maxheight - end + if maxheight and tipsize - shrink > maxheight then + shrink = tipsize - maxheight + end - self:SetHeight(2 * TOOLTIP_PADDING + self.height - shrink) - self:SetWidth(2 * TOOLTIP_PADDING + self.width + 20) - self.scrollFrame:SetPoint("RIGHT", self, "RIGHT", -(TOOLTIP_PADDING + 20), 0) + self:SetHeight(2 * TOOLTIP_PADDING + self.height - shrink) + self:SetWidth(2 * TOOLTIP_PADDING + self.width + 20) + self.scrollFrame:SetPoint("RIGHT", self, "RIGHT", -(TOOLTIP_PADDING + 20), 0) - if not self.slider then - local slider = CreateFrame("Slider", nil, self, BackdropTemplateMixin and "BackdropTemplate") - slider.scrollFrame = self.scrollFrame + if not self.slider then + local slider = CreateFrame("Slider", nil, self, BackdropTemplateMixin and "BackdropTemplate") + slider.scrollFrame = self.scrollFrame - slider:SetOrientation("VERTICAL") - slider:SetPoint("TOPRIGHT", self, "TOPRIGHT", -TOOLTIP_PADDING, -TOOLTIP_PADDING) - slider:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -TOOLTIP_PADDING, TOOLTIP_PADDING) - slider:SetBackdrop(BACKDROP_SLIDER_8_8) - slider:SetThumbTexture([[Interface\Buttons\UI-SliderBar-Button-Vertical]]) - slider:SetMinMaxValues(0, 1) - slider:SetValueStep(1) - slider:SetWidth(12) - slider:SetScript("OnValueChanged", slider_OnValueChanged) - slider:SetValue(0) + slider:SetOrientation("VERTICAL") + slider:SetPoint("TOPRIGHT", self, "TOPRIGHT", -TOOLTIP_PADDING, -TOOLTIP_PADDING) + slider:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -TOOLTIP_PADDING, TOOLTIP_PADDING) + slider:SetBackdrop(BACKDROP_SLIDER_8_8) + slider:SetThumbTexture([[Interface\Buttons\UI-SliderBar-Button-Vertical]]) + slider:SetMinMaxValues(0, 1) + slider:SetValueStep(1) + slider:SetWidth(12) + slider:SetScript("OnValueChanged", slider_OnValueChanged) + slider:SetValue(0) - self.slider = slider - end + self.slider = slider + end - self.slider:SetMinMaxValues(0, shrink) - self.slider:Show() + self.slider:SetMinMaxValues(0, shrink) + self.slider:Show() - self:EnableMouseWheel(true) - self:SetScript("OnMouseWheel", tooltip_OnMouseWheel) - else - self:SetHeight(2 * TOOLTIP_PADDING + self.height) - self:SetWidth(2 * TOOLTIP_PADDING + self.width) + self:EnableMouseWheel(true) + self:SetScript("OnMouseWheel", tooltip_OnMouseWheel) + else + self:SetHeight(2 * TOOLTIP_PADDING + self.height) + self:SetWidth(2 * TOOLTIP_PADDING + self.width) - self.scrollFrame:SetPoint("RIGHT", self, "RIGHT", -TOOLTIP_PADDING, 0) + self.scrollFrame:SetPoint("RIGHT", self, "RIGHT", -TOOLTIP_PADDING, 0) - if self.slider then - self.slider:SetValue(0) - self.slider:Hide() + if self.slider then + self.slider:SetValue(0) + self.slider:Hide() - self:EnableMouseWheel(false) - self:SetScript("OnMouseWheel", nil) - end - end + self:EnableMouseWheel(false) + self:SetScript("OnMouseWheel", nil) + end + end end ------------------------------------------------------------------------------ -- Tooltip methods for changing its contents. ------------------------------------------------------------------------------ function tipPrototype:Clear() - for i, line in ipairs(self.lines) do - for _, cell in pairs(line.cells) do - if cell then - ReleaseCell(cell) - end - end + for i, line in ipairs(self.lines) do + for _, cell in pairs(line.cells) do + if cell then + ReleaseCell(cell) + end + end - ReleaseTable(line.cells) + ReleaseTable(line.cells) - line.cells = nil - line.is_header = nil + line.cells = nil + line.is_header = nil - ReleaseFrame(line) + ReleaseFrame(line) - self.lines[i] = nil - end + self.lines[i] = nil + end - for _, column in ipairs(self.columns) do - column.width = 0 - column:SetWidth(1) - end + for _, column in ipairs(self.columns) do + column.width = 0 + column:SetWidth(1) + end - wipe(self.colspans) + wipe(self.colspans) - self.cell_margin_h = nil - self.cell_margin_v = nil + self.cell_margin_h = nil + self.cell_margin_v = nil - ResetTooltipSize(self) + ResetTooltipSize(self) end function tipPrototype:SetCellMarginH(size) - if #self.lines > 0 then - error("Unable to set horizontal margin while the tooltip has lines.", 2) - end + if #self.lines > 0 then + error("Unable to set horizontal margin while the tooltip has lines.", 2) + end - if not size or type(size) ~= "number" or size < 0 then - error("Margin size must be a positive number or zero.", 2) - end + if not size or type(size) ~= "number" or size < 0 then + error("Margin size must be a positive number or zero.", 2) + end - self.cell_margin_h = size + self.cell_margin_h = size end function tipPrototype:SetCellMarginV(size) - if #self.lines > 0 then - error("Unable to set vertical margin while the tooltip has lines.", 2) - end + if #self.lines > 0 then + error("Unable to set vertical margin while the tooltip has lines.", 2) + end - if not size or type(size) ~= "number" or size < 0 then - error("Margin size must be a positive number or zero.", 2) - end + if not size or type(size) ~= "number" or size < 0 then + error("Margin size must be a positive number or zero.", 2) + end - self.cell_margin_v = size + self.cell_margin_v = size end function SetTooltipSize(tooltip, width, height) - tooltip.height = height - tooltip.width = width + tooltip.height = height + tooltip.width = width - tooltip:SetHeight(2 * TOOLTIP_PADDING + height) - tooltip:SetWidth(2 * TOOLTIP_PADDING + width) + tooltip:SetHeight(2 * TOOLTIP_PADDING + height) + tooltip:SetWidth(2 * TOOLTIP_PADDING + width) - tooltip.scrollChild:SetHeight(height) - tooltip.scrollChild:SetWidth(width) + tooltip.scrollChild:SetHeight(height) + tooltip.scrollChild:SetWidth(width) end -- Add 2 pixels to height so dangling letters (g, y, p, j, etc) are not clipped. function ResetTooltipSize(tooltip) - local h_margin = tooltip.cell_margin_h or CELL_MARGIN_H + local h_margin = tooltip.cell_margin_h or CELL_MARGIN_H - SetTooltipSize(tooltip, max(0, (h_margin * (#tooltip.columns - 1)) + (h_margin / 2)), 2) + SetTooltipSize(tooltip, max(0, (h_margin * (#tooltip.columns - 1)) + (h_margin / 2)), 2) end local function EnlargeColumn(tooltip, column, width) - if width > column.width then - SetTooltipSize(tooltip, tooltip.width + width - column.width, tooltip.height) + if width > column.width then + SetTooltipSize(tooltip, tooltip.width + width - column.width, tooltip.height) - column.width = width - column:SetWidth(width) - end + column.width = width + column:SetWidth(width) + end end local function ResizeLine(tooltip, line, height) - SetTooltipSize(tooltip, tooltip.width, tooltip.height + height - line.height) + SetTooltipSize(tooltip, tooltip.width, tooltip.height + height - line.height) - line.height = height - line:SetHeight(height) + line.height = height + line:SetHeight(height) end function FixCellSizes(tooltip) - local columns = tooltip.columns - local colspans = tooltip.colspans - local lines = tooltip.lines - local h_margin = tooltip.cell_margin_h or CELL_MARGIN_H - - -- resize columns to make room for the colspans - while next(colspans) do - local maxNeedCols - local maxNeedWidthPerCol = 0 - - -- calculate the colspan with the highest additional width need per column - for colRange, width in pairs(colspans) do - local left, right = colRange:match("^(%d+)%-(%d+)$") - - left, right = tonumber(left), tonumber(right) - - for col = left, right - 1 do - width = width - columns[col].width - h_margin - end - - width = width - columns[right].width - - if width <= 0 then - colspans[colRange] = nil - else - width = width / (right - left + 1) - - if width > maxNeedWidthPerCol then - maxNeedCols = colRange - maxNeedWidthPerCol = width - end - end - end - - -- resize all columns for that colspan - if maxNeedCols then - local left, right = maxNeedCols:match("^(%d+)%-(%d+)$") - - for col = left, right do - EnlargeColumn(tooltip, columns[col], columns[col].width + maxNeedWidthPerCol) - end - - colspans[maxNeedCols] = nil - end - end - - --now that the cell width is set, recalculate the rows' height - for _, line in ipairs(lines) do - if #(line.cells) > 0 then - local lineheight = 0 - - for _, cell in pairs(line.cells) do - if cell then - lineheight = max(lineheight, cell:getContentHeight()) - end - end - - if lineheight > 0 then - ResizeLine(tooltip, line, lineheight) - end - end - end + local columns = tooltip.columns + local colspans = tooltip.colspans + local lines = tooltip.lines + local h_margin = tooltip.cell_margin_h or CELL_MARGIN_H + + -- resize columns to make room for the colspans + while next(colspans) do + local maxNeedCols + local maxNeedWidthPerCol = 0 + + -- calculate the colspan with the highest additional width need per column + for colRange, width in pairs(colspans) do + local left, right = colRange:match("^(%d+)%-(%d+)$") + + left, right = tonumber(left), tonumber(right) + + for col = left, right - 1 do + width = width - columns[col].width - h_margin + end + + width = width - columns[right].width + + if width <= 0 then + colspans[colRange] = nil + else + width = width / (right - left + 1) + + if width > maxNeedWidthPerCol then + maxNeedCols = colRange + maxNeedWidthPerCol = width + end + end + end + + -- resize all columns for that colspan + if maxNeedCols then + local left, right = maxNeedCols:match("^(%d+)%-(%d+)$") + + for col = left, right do + EnlargeColumn(tooltip, columns[col], columns[col].width + maxNeedWidthPerCol) + end + + colspans[maxNeedCols] = nil + end + end + + --now that the cell width is set, recalculate the rows' height + for _, line in ipairs(lines) do + if #(line.cells) > 0 then + local lineheight = 0 + + for _, cell in pairs(line.cells) do + if cell then + lineheight = max(lineheight, cell:getContentHeight()) + end + end + + if lineheight > 0 then + ResizeLine(tooltip, line, lineheight) + end + end + end end local function _SetCell(tooltip, lineNum, colNum, value, font, justification, colSpan, provider, ...) - local line = tooltip.lines[lineNum] - local cells = line.cells - - -- Unset: be quick - if value == nil then - local cell = cells[colNum] - - if cell then - for i = colNum, colNum + cell._colSpan - 1 do - cells[i] = nil - end - - ReleaseCell(cell) - end - - return lineNum, colNum - end - - font = font or (line.is_header and tooltip.headerFont or tooltip.regularFont) - - -- Check previous cell - local cell - local prevCell = cells[colNum] - - if prevCell then - -- There is a cell here - justification = justification or prevCell._justification - colSpan = colSpan or prevCell._colSpan - - -- Clear the currently marked colspan - for i = colNum + 1, colNum + prevCell._colSpan - 1 do - cells[i] = nil - end - - if provider == nil or prevCell._provider == provider then - -- Reuse existing cell - cell = prevCell - provider = cell._provider - else - -- A new cell is required - cells[colNum] = ReleaseCell(prevCell) - end - elseif prevCell == nil then - -- Creating a new cell, using meaningful defaults. - provider = provider or tooltip.labelProvider - justification = justification or tooltip.columns[colNum].justification or "LEFT" - colSpan = colSpan or 1 - else - error("overlapping cells at column " .. colNum, 3) - end - - local tooltipWidth = #tooltip.columns - local rightColNum - - if colSpan > 0 then - rightColNum = colNum + colSpan - 1 - - if rightColNum > tooltipWidth then - error("ColSpan too big, cell extends beyond right-most column", 3) - end - else - -- Zero or negative: count back from right-most columns - rightColNum = max(colNum, tooltipWidth + colSpan) - -- Update colspan to its effective value - colSpan = 1 + rightColNum - colNum - end - - -- Cleanup colspans - for i = colNum + 1, rightColNum do - local columnCell = cells[i] - - if columnCell then - ReleaseCell(columnCell) - elseif columnCell == false then - error("overlapping cells at column " .. i, 3) - end - - cells[i] = false - end - - -- Create the cell - if not cell then - cell = AcquireCell(tooltip, provider) - cells[colNum] = cell - end - - -- Anchor the cell - cell:SetPoint("LEFT", tooltip.columns[colNum]) - cell:SetPoint("RIGHT", tooltip.columns[rightColNum]) - cell:SetPoint("TOP", line) - cell:SetPoint("BOTTOM", line) - - -- Store the cell settings directly into the cell - -- That's a bit risky but is really cheap compared to other ways to do it - cell._font, cell._justification, cell._colSpan, cell._line, cell._column = font, justification, colSpan, lineNum, colNum - - -- Setup the cell content - local width, height = cell:SetupCell(tooltip, value, justification, font, ...) - cell:Show() - - if colSpan > 1 then - -- Postpone width changes until the tooltip is shown - local colRange = colNum .. "-" .. rightColNum - - tooltip.colspans[colRange] = max(tooltip.colspans[colRange] or 0, width) - layoutCleaner:RegisterForCleanup(tooltip) - else - -- Enlarge the column and tooltip if need be - EnlargeColumn(tooltip, tooltip.columns[colNum], width) - end - - -- Enlarge the line and tooltip if need be - if height > line.height then - SetTooltipSize(tooltip, tooltip.width, tooltip.height + height - line.height) - - line.height = height - line:SetHeight(height) - end - - if rightColNum < tooltipWidth then - return lineNum, rightColNum + 1 - else - return lineNum, nil - end + local line = tooltip.lines[lineNum] + local cells = line.cells + + -- Unset: be quick + if value == nil then + local cell = cells[colNum] + + if cell then + for i = colNum, colNum + cell._colSpan - 1 do + cells[i] = nil + end + + ReleaseCell(cell) + end + + return lineNum, colNum + end + + font = font or (line.is_header and tooltip.headerFont or tooltip.regularFont) + + -- Check previous cell + local cell + local prevCell = cells[colNum] + + if prevCell then + -- There is a cell here + justification = justification or prevCell._justification + colSpan = colSpan or prevCell._colSpan + + -- Clear the currently marked colspan + for i = colNum + 1, colNum + prevCell._colSpan - 1 do + cells[i] = nil + end + + if provider == nil or prevCell._provider == provider then + -- Reuse existing cell + cell = prevCell + provider = cell._provider + else + -- A new cell is required + cells[colNum] = ReleaseCell(prevCell) + end + elseif prevCell == nil then + -- Creating a new cell, using meaningful defaults. + provider = provider or tooltip.labelProvider + justification = justification or tooltip.columns[colNum].justification or "LEFT" + colSpan = colSpan or 1 + else + error("overlapping cells at column " .. colNum, 3) + end + + local tooltipWidth = #tooltip.columns + local rightColNum + + if colSpan > 0 then + rightColNum = colNum + colSpan - 1 + + if rightColNum > tooltipWidth then + error("ColSpan too big, cell extends beyond right-most column", 3) + end + else + -- Zero or negative: count back from right-most columns + rightColNum = max(colNum, tooltipWidth + colSpan) + -- Update colspan to its effective value + colSpan = 1 + rightColNum - colNum + end + + -- Cleanup colspans + for i = colNum + 1, rightColNum do + local columnCell = cells[i] + + if columnCell then + ReleaseCell(columnCell) + elseif columnCell == false then + error("overlapping cells at column " .. i, 3) + end + + cells[i] = false + end + + -- Create the cell + if not cell then + cell = AcquireCell(tooltip, provider) + cells[colNum] = cell + end + + -- Anchor the cell + cell:SetPoint("LEFT", tooltip.columns[colNum]) + cell:SetPoint("RIGHT", tooltip.columns[rightColNum]) + cell:SetPoint("TOP", line) + cell:SetPoint("BOTTOM", line) + + -- Store the cell settings directly into the cell + -- That's a bit risky but is really cheap compared to other ways to do it + cell._font, cell._justification, cell._colSpan, cell._line, cell._column = font, justification, colSpan, lineNum, colNum + + -- Setup the cell content + local width, height = cell:SetupCell(tooltip, value, justification, font, ...) + cell:Show() + + if colSpan > 1 then + -- Postpone width changes until the tooltip is shown + local colRange = colNum .. "-" .. rightColNum + + tooltip.colspans[colRange] = max(tooltip.colspans[colRange] or 0, width) + layoutCleaner:RegisterForCleanup(tooltip) + else + -- Enlarge the column and tooltip if need be + EnlargeColumn(tooltip, tooltip.columns[colNum], width) + end + + -- Enlarge the line and tooltip if need be + if height > line.height then + SetTooltipSize(tooltip, tooltip.width, tooltip.height + height - line.height) + + line.height = height + line:SetHeight(height) + end + + if rightColNum < tooltipWidth then + return lineNum, rightColNum + 1 + else + return lineNum, nil + end end do - local function CreateLine(tooltip, font, ...) - if #tooltip.columns == 0 then - error("column layout should be defined before adding line", 3) - end + local function CreateLine(tooltip, font, ...) + if #tooltip.columns == 0 then + error("column layout should be defined before adding line", 3) + end - local lineNum = #tooltip.lines + 1 - local line = tooltip.lines[lineNum] or AcquireFrame(tooltip.scrollChild) + local lineNum = #tooltip.lines + 1 + local line = tooltip.lines[lineNum] or AcquireFrame(tooltip.scrollChild) - line:SetFrameLevel(tooltip.scrollChild:GetFrameLevel() + 2) - line:SetPoint("LEFT", tooltip.scrollChild) - line:SetPoint("RIGHT", tooltip.scrollChild) + line:SetFrameLevel(tooltip.scrollChild:GetFrameLevel() + 2) + line:SetPoint("LEFT", tooltip.scrollChild) + line:SetPoint("RIGHT", tooltip.scrollChild) - if lineNum > 1 then - local v_margin = tooltip.cell_margin_v or CELL_MARGIN_V + if lineNum > 1 then + local v_margin = tooltip.cell_margin_v or CELL_MARGIN_V - line:SetPoint("TOP", tooltip.lines[lineNum - 1], "BOTTOM", 0, -v_margin) - SetTooltipSize(tooltip, tooltip.width, tooltip.height + v_margin) - else - line:SetPoint("TOP", tooltip.scrollChild) - end + line:SetPoint("TOP", tooltip.lines[lineNum - 1], "BOTTOM", 0, -v_margin) + SetTooltipSize(tooltip, tooltip.width, tooltip.height + v_margin) + else + line:SetPoint("TOP", tooltip.scrollChild) + end - tooltip.lines[lineNum] = line + tooltip.lines[lineNum] = line - line.cells = line.cells or AcquireTable() - line.height = 0 - line:SetHeight(1) - line:Show() + line.cells = line.cells or AcquireTable() + line.height = 0 + line:SetHeight(1) + line:Show() - local colNum = 1 + local colNum = 1 - for i = 1, #tooltip.columns do - local value = select(i, ...) + for i = 1, #tooltip.columns do + local value = select(i, ...) - if value ~= nil then - lineNum, colNum = _SetCell(tooltip, lineNum, i, value, font, nil, 1, tooltip.labelProvider) - end - end + if value ~= nil then + lineNum, colNum = _SetCell(tooltip, lineNum, i, value, font, nil, 1, tooltip.labelProvider) + end + end - return lineNum, colNum - end + return lineNum, colNum + end - function tipPrototype:AddLine(...) - return CreateLine(self, self.regularFont, ...) - end + function tipPrototype:AddLine(...) + return CreateLine(self, self.regularFont, ...) + end - function tipPrototype:AddHeader(...) - local line, col = CreateLine(self, self.headerFont, ...) + function tipPrototype:AddHeader(...) + local line, col = CreateLine(self, self.headerFont, ...) - self.lines[line].is_header = true + self.lines[line].is_header = true - return line, col - end + return line, col + end end -- do-block local GenericBackdrop = { - bgFile = "Interface\\Tooltips\\UI-Tooltip-Background" + bgFile = "Interface\\Tooltips\\UI-Tooltip-Background" } function tipPrototype:AddSeparator(height, r, g, b, a) - local lineNum, colNum = self:AddLine() - local line = self.lines[lineNum] - local color = _G.NORMAL_FONT_COLOR + local lineNum, colNum = self:AddLine() + local line = self.lines[lineNum] + local color = _G.NORMAL_FONT_COLOR - height = height or 1 + height = height or 1 - SetTooltipSize(self, self.width, self.height + height) + SetTooltipSize(self, self.width, self.height + height) - line.height = height - line:SetHeight(height) - line:SetBackdrop(GenericBackdrop) - line:SetBackdropColor(r or color.r, g or color.g, b or color.b, a or 1) + line.height = height + line:SetHeight(height) + line:SetBackdrop(GenericBackdrop) + line:SetBackdropColor(r or color.r, g or color.g, b or color.b, a or 1) - return lineNum, colNum + return lineNum, colNum end function tipPrototype:SetCellColor(lineNum, colNum, r, g, b, a) - local cell = self.lines[lineNum].cells[colNum] + local cell = self.lines[lineNum].cells[colNum] - if cell then - local sr, sg, sb, sa = self:GetBackdropColor() + if cell then + local sr, sg, sb, sa = self:GetBackdropColor() - cell:SetBackdrop(GenericBackdrop) - cell:SetBackdropColor(r or sr, g or sg, b or sb, a or sa) - end + cell:SetBackdrop(GenericBackdrop) + cell:SetBackdropColor(r or sr, g or sg, b or sb, a or sa) + end end function tipPrototype:SetColumnColor(colNum, r, g, b, a) - local column = self.columns[colNum] + local column = self.columns[colNum] - if column then - local sr, sg, sb, sa = self:GetBackdropColor() - column:SetBackdrop(GenericBackdrop) - column:SetBackdropColor(r or sr, g or sg, b or sb, a or sa) - end + if column then + local sr, sg, sb, sa = self:GetBackdropColor() + column:SetBackdrop(GenericBackdrop) + column:SetBackdropColor(r or sr, g or sg, b or sb, a or sa) + end end function tipPrototype:SetLineColor(lineNum, r, g, b, a) - local line = self.lines[lineNum] + local line = self.lines[lineNum] - if line then - local sr, sg, sb, sa = self:GetBackdropColor() + if line then + local sr, sg, sb, sa = self:GetBackdropColor() - line:SetBackdrop(GenericBackdrop) - line:SetBackdropColor(r or sr, g or sg, b or sb, a or sa) - end + line:SetBackdrop(GenericBackdrop) + line:SetBackdropColor(r or sr, g or sg, b or sb, a or sa) + end end function tipPrototype:SetCellTextColor(lineNum, colNum, r, g, b, a) - local line = self.lines[lineNum] - local column = self.columns[colNum] + local line = self.lines[lineNum] + local column = self.columns[colNum] - if not line or not column then - return - end + if not line or not column then + return + end - local cell = self.lines[lineNum].cells[colNum] + local cell = self.lines[lineNum].cells[colNum] - if cell then - if not cell.fontString then - error("cell's label provider did not assign a fontString field", 2) - end + if cell then + if not cell.fontString then + error("cell's label provider did not assign a fontString field", 2) + end - if not cell.r then - cell.r, cell.g, cell.b, cell.a = cell.fontString:GetTextColor() - end + if not cell.r then + cell.r, cell.g, cell.b, cell.a = cell.fontString:GetTextColor() + end - cell.fontString:SetTextColor(r or cell.r, g or cell.g, b or cell.b, a or cell.a) - end + cell.fontString:SetTextColor(r or cell.r, g or cell.g, b or cell.b, a or cell.a) + end end function tipPrototype:SetColumnTextColor(colNum, r, g, b, a) - if not self.columns[colNum] then - return - end + if not self.columns[colNum] then + return + end - for lineIndex = 1, #self.lines do - self:SetCellTextColor(lineIndex, colNum, r, g, b, a) - end + for lineIndex = 1, #self.lines do + self:SetCellTextColor(lineIndex, colNum, r, g, b, a) + end end function tipPrototype:SetLineTextColor(lineNum, r, g, b, a) - local line = self.lines[lineNum] + local line = self.lines[lineNum] - if not line then - return - end + if not line then + return + end - for cellIndex = 1, #line.cells do - self:SetCellTextColor(lineNum, line.cells[cellIndex]._column, r, g, b, a) - end + for cellIndex = 1, #line.cells do + self:SetCellTextColor(lineNum, line.cells[cellIndex]._column, r, g, b, a) + end end function tipPrototype:SetHighlightTexture(...) - return highlightTexture:SetTexture(...) + return highlightTexture:SetTexture(...) end function tipPrototype:SetHighlightTexCoord(...) - highlightTexture:SetTexCoord(...) + highlightTexture:SetTexCoord(...) end do - local function checkFont(font, level, silent) - local bad = false - - if not font then - bad = true - elseif type(font) == "string" then - local ref = _G[font] - - if not ref or type(ref) ~= "table" or type(ref.IsObjectType) ~= "function" or not ref:IsObjectType("Font") then - bad = true - end - elseif type(font) ~= "table" or type(font.IsObjectType) ~= "function" or not font:IsObjectType("Font") then - bad = true - end - - if bad then - if silent then - return false - end - - error("font must be a Font instance or a string matching the name of a global Font instance, not: " .. tostring(font), level + 1) - end - return true - end - - function tipPrototype:SetFont(font) - local is_string = type(font) == "string" - - checkFont(font, 2) - self.regularFont = is_string and _G[font] or font - end - - function tipPrototype:SetHeaderFont(font) - local is_string = type(font) == "string" - - checkFont(font, 2) - self.headerFont = is_string and _G[font] or font - end - - -- TODO: fixed argument positions / remove checks for performance? - function tipPrototype:SetCell(lineNum, colNum, value, ...) - -- Mandatory argument checking - if type(lineNum) ~= "number" then - error("line number must be a number, not: " .. tostring(lineNum), 2) - elseif lineNum < 1 or lineNum > #self.lines then - error("line number out of range: " .. tostring(lineNum), 2) - elseif type(colNum) ~= "number" then - error("column number must be a number, not: " .. tostring(colNum), 2) - elseif colNum < 1 or colNum > #self.columns then - error("column number out of range: " .. tostring(colNum), 2) - end - - -- Variable argument checking - local font, justification, colSpan, provider - local i, arg = 1, ... - - if arg == nil or checkFont(arg, 2, true) then - i, font, arg = 2, ... - end - - if arg == nil or checkJustification(arg, 2, true) then - i, justification, arg = i + 1, select(i, ...) - end - - if arg == nil or type(arg) == "number" then - i, colSpan, arg = i + 1, select(i, ...) - end - - if arg == nil or type(arg) == "table" and type(arg.AcquireCell) == "function" then - i, provider = i + 1, arg - end - - return _SetCell(self, lineNum, colNum, value, font, justification, colSpan, provider, select(i, ...)) - end + local function checkFont(font, level, silent) + local bad = false + + if not font then + bad = true + elseif type(font) == "string" then + local ref = _G[font] + + if not ref or type(ref) ~= "table" or type(ref.IsObjectType) ~= "function" or not ref:IsObjectType("Font") then + bad = true + end + elseif type(font) ~= "table" or type(font.IsObjectType) ~= "function" or not font:IsObjectType("Font") then + bad = true + end + + if bad then + if silent then + return false + end + + error("font must be a Font instance or a string matching the name of a global Font instance, not: " .. tostring(font), level + 1) + end + return true + end + + function tipPrototype:SetFont(font) + local is_string = type(font) == "string" + + checkFont(font, 2) + self.regularFont = is_string and _G[font] or font + end + + function tipPrototype:SetHeaderFont(font) + local is_string = type(font) == "string" + + checkFont(font, 2) + self.headerFont = is_string and _G[font] or font + end + + -- TODO: fixed argument positions / remove checks for performance? + function tipPrototype:SetCell(lineNum, colNum, value, ...) + -- Mandatory argument checking + if type(lineNum) ~= "number" then + error("line number must be a number, not: " .. tostring(lineNum), 2) + elseif lineNum < 1 or lineNum > #self.lines then + error("line number out of range: " .. tostring(lineNum), 2) + elseif type(colNum) ~= "number" then + error("column number must be a number, not: " .. tostring(colNum), 2) + elseif colNum < 1 or colNum > #self.columns then + error("column number out of range: " .. tostring(colNum), 2) + end + + -- Variable argument checking + local font, justification, colSpan, provider + local i, arg = 1, ... + + if arg == nil or checkFont(arg, 2, true) then + i, font, arg = 2, ... + end + + if arg == nil or checkJustification(arg, 2, true) then + i, justification, arg = i + 1, select(i, ...) + end + + if arg == nil or type(arg) == "number" then + i, colSpan, arg = i + 1, select(i, ...) + end + + if arg == nil or type(arg) == "table" and type(arg.AcquireCell) == "function" then + i, provider = i + 1, arg + end + + return _SetCell(self, lineNum, colNum, value, font, justification, colSpan, provider, select(i, ...)) + end end -- do-block function tipPrototype:GetFont() - return self.regularFont + return self.regularFont end function tipPrototype:GetHeaderFont() - return self.headerFont + return self.headerFont end function tipPrototype:GetLineCount() - return #self.lines + return #self.lines end function tipPrototype:GetColumnCount() - return #self.columns + return #self.columns end ------------------------------------------------------------------------------ -- Frame Scripts ------------------------------------------------------------------------------ local scripts = { - OnEnter = function(frame, ...) - highlightFrame:SetParent(frame) - highlightFrame:SetAllPoints(frame) - highlightFrame:Show() - - if frame._OnEnter_func then - frame:_OnEnter_func(frame._OnEnter_arg, ...) - end - end, - OnLeave = function(frame, ...) - highlightFrame:Hide() - highlightFrame:ClearAllPoints() - highlightFrame:SetParent(nil) - - if frame._OnLeave_func then - frame:_OnLeave_func(frame._OnLeave_arg, ...) - end - end, - OnMouseDown = function(frame, ...) - frame:_OnMouseDown_func(frame._OnMouseDown_arg, ...) - end, - OnMouseUp = function(frame, ...) - frame:_OnMouseUp_func(frame._OnMouseUp_arg, ...) - end, - OnReceiveDrag = function(frame, ...) - frame:_OnReceiveDrag_func(frame._OnReceiveDrag_arg, ...) - end + OnEnter = function(frame, ...) + highlightFrame:SetParent(frame) + highlightFrame:SetAllPoints(frame) + highlightFrame:Show() + + if frame._OnEnter_func then + frame:_OnEnter_func(frame._OnEnter_arg, ...) + end + end, + OnLeave = function(frame, ...) + highlightFrame:Hide() + highlightFrame:ClearAllPoints() + highlightFrame:SetParent(nil) + + if frame._OnLeave_func then + frame:_OnLeave_func(frame._OnLeave_arg, ...) + end + end, + OnMouseDown = function(frame, ...) + frame:_OnMouseDown_func(frame._OnMouseDown_arg, ...) + end, + OnMouseUp = function(frame, ...) + frame:_OnMouseUp_func(frame._OnMouseUp_arg, ...) + end, + OnReceiveDrag = function(frame, ...) + frame:_OnReceiveDrag_func(frame._OnReceiveDrag_arg, ...) + end } function SetFrameScript(frame, script, func, arg) - if not scripts[script] then - return - end - - frame["_" .. script .. "_func"] = func - frame["_" .. script .. "_arg"] = arg - - if script == "OnMouseDown" or script == "OnMouseUp" or script == "OnReceiveDrag" then - if func then - frame:SetScript(script, scripts[script]) - else - frame:SetScript(script, nil) - end - end - - -- if at least one script is set, set the OnEnter/OnLeave scripts for the highlight - if frame._OnEnter_func or frame._OnLeave_func or frame._OnMouseDown_func or frame._OnMouseUp_func or frame._OnReceiveDrag_func then - frame:EnableMouse(true) - frame:SetScript("OnEnter", scripts.OnEnter) - frame:SetScript("OnLeave", scripts.OnLeave) - else - frame:EnableMouse(false) - frame:SetScript("OnEnter", nil) - frame:SetScript("OnLeave", nil) - end + if not scripts[script] then + return + end + + frame["_" .. script .. "_func"] = func + frame["_" .. script .. "_arg"] = arg + + if script == "OnMouseDown" or script == "OnMouseUp" or script == "OnReceiveDrag" then + if func then + frame:SetScript(script, scripts[script]) + else + frame:SetScript(script, nil) + end + end + + -- if at least one script is set, set the OnEnter/OnLeave scripts for the highlight + if frame._OnEnter_func or frame._OnLeave_func or frame._OnMouseDown_func or frame._OnMouseUp_func or frame._OnReceiveDrag_func then + frame:EnableMouse(true) + frame:SetScript("OnEnter", scripts.OnEnter) + frame:SetScript("OnLeave", scripts.OnLeave) + else + frame:EnableMouse(false) + frame:SetScript("OnEnter", nil) + frame:SetScript("OnLeave", nil) + end end function ClearFrameScripts(frame) - if frame._OnEnter_func or frame._OnLeave_func or frame._OnMouseDown_func or frame._OnMouseUp_func or frame._OnReceiveDrag_func then - frame:EnableMouse(false) + if frame._OnEnter_func or frame._OnLeave_func or frame._OnMouseDown_func or frame._OnMouseUp_func or frame._OnReceiveDrag_func then + frame:EnableMouse(false) - frame:SetScript("OnEnter", nil) - frame._OnEnter_func = nil - frame._OnEnter_arg = nil + frame:SetScript("OnEnter", nil) + frame._OnEnter_func = nil + frame._OnEnter_arg = nil - frame:SetScript("OnLeave", nil) - frame._OnLeave_func = nil - frame._OnLeave_arg = nil + frame:SetScript("OnLeave", nil) + frame._OnLeave_func = nil + frame._OnLeave_arg = nil - frame:SetScript("OnReceiveDrag", nil) - frame._OnReceiveDrag_func = nil - frame._OnReceiveDrag_arg = nil + frame:SetScript("OnReceiveDrag", nil) + frame._OnReceiveDrag_func = nil + frame._OnReceiveDrag_arg = nil - frame:SetScript("OnMouseDown", nil) - frame._OnMouseDown_func = nil - frame._OnMouseDown_arg = nil + frame:SetScript("OnMouseDown", nil) + frame._OnMouseDown_func = nil + frame._OnMouseDown_arg = nil - frame:SetScript("OnMouseUp", nil) - frame._OnMouseUp_func = nil - frame._OnMouseUp_arg = nil - end + frame:SetScript("OnMouseUp", nil) + frame._OnMouseUp_func = nil + frame._OnMouseUp_arg = nil + end end function tipPrototype:SetLineScript(lineNum, script, func, arg) - SetFrameScript(self.lines[lineNum], script, func, arg) + SetFrameScript(self.lines[lineNum], script, func, arg) end function tipPrototype:SetColumnScript(colNum, script, func, arg) - SetFrameScript(self.columns[colNum], script, func, arg) + SetFrameScript(self.columns[colNum], script, func, arg) end function tipPrototype:SetCellScript(lineNum, colNum, script, func, arg) - local cell = self.lines[lineNum].cells[colNum] + local cell = self.lines[lineNum].cells[colNum] - if cell then - SetFrameScript(cell, script, func, arg) - end + if cell then + SetFrameScript(cell, script, func, arg) + end end ------------------------------------------------------------------------------ @@ -1439,21 +1453,21 @@ end -- Script of the auto-hiding child frame local function AutoHideTimerFrame_OnUpdate(self, elapsed) - self.checkElapsed = self.checkElapsed + elapsed + self.checkElapsed = self.checkElapsed + elapsed - if self.checkElapsed > 0.1 then - if self.parent:IsMouseOver() or (self.alternateFrame and self.alternateFrame:IsMouseOver()) then - self.elapsed = 0 - else - self.elapsed = self.elapsed + self.checkElapsed + if self.checkElapsed > 0.1 then + if self.parent:IsMouseOver() or (self.alternateFrame and self.alternateFrame:IsMouseOver()) then + self.elapsed = 0 + else + self.elapsed = self.elapsed + self.checkElapsed - if self.elapsed >= self.delay then - lib:Release(self.parent) - end - end + if self.elapsed >= self.delay then + lib:Release(self.parent) + end + end - self.checkElapsed = 0 - end + self.checkElapsed = 0 + end end -- Usage: @@ -1461,65 +1475,65 @@ end -- :SetAutoHideDelay(0.25, someFrame) => hides after 0.25sec outside of both the tooltip and someFrame -- :SetAutoHideDelay() => disable auto-hiding (default) function tipPrototype:SetAutoHideDelay(delay, alternateFrame, releaseHandler) - local timerFrame = self.autoHideTimerFrame - delay = tonumber(delay) or 0 + local timerFrame = self.autoHideTimerFrame + delay = tonumber(delay) or 0 - if releaseHandler then - if type(releaseHandler) ~= "function" then - error("releaseHandler must be a function", 2) - end + if releaseHandler then + if type(releaseHandler) ~= "function" then + error("releaseHandler must be a function", 2) + end - lib.onReleaseHandlers[self] = releaseHandler - end + lib.onReleaseHandlers[self] = releaseHandler + end - if delay > 0 then - if not timerFrame then - timerFrame = AcquireTimer(self) - timerFrame:SetScript("OnUpdate", AutoHideTimerFrame_OnUpdate) + if delay > 0 then + if not timerFrame then + timerFrame = AcquireTimer(self) + timerFrame:SetScript("OnUpdate", AutoHideTimerFrame_OnUpdate) - self.autoHideTimerFrame = timerFrame - end + self.autoHideTimerFrame = timerFrame + end - timerFrame.parent = self - timerFrame.checkElapsed = 0 - timerFrame.elapsed = 0 - timerFrame.delay = delay - timerFrame.alternateFrame = alternateFrame - timerFrame:Show() - elseif timerFrame then - self.autoHideTimerFrame = nil + timerFrame.parent = self + timerFrame.checkElapsed = 0 + timerFrame.elapsed = 0 + timerFrame.delay = delay + timerFrame.alternateFrame = alternateFrame + timerFrame:Show() + elseif timerFrame then + self.autoHideTimerFrame = nil - timerFrame.alternateFrame = nil - timerFrame:SetScript("OnUpdate", nil) + timerFrame.alternateFrame = nil + timerFrame:SetScript("OnUpdate", nil) - ReleaseTimer(timerFrame) - end + ReleaseTimer(timerFrame) + end end ------------------------------------------------------------------------------ -- "Smart" Anchoring ------------------------------------------------------------------------------ local function GetTipAnchor(frame) - local x, y = frame:GetCenter() + local x, y = frame:GetCenter() - if not x or not y then - return "TOPLEFT", "BOTTOMLEFT" - end + if not x or not y then + return "TOPLEFT", "BOTTOMLEFT" + end - local hhalf = (x > UIParent:GetWidth() * 2 / 3) and "RIGHT" or (x < UIParent:GetWidth() / 3) and "LEFT" or "" - local vhalf = (y > UIParent:GetHeight() / 2) and "TOP" or "BOTTOM" + local hhalf = (x > UIParent:GetWidth() * 2 / 3) and "RIGHT" or (x < UIParent:GetWidth() / 3) and "LEFT" or "" + local vhalf = (y > UIParent:GetHeight() / 2) and "TOP" or "BOTTOM" - return vhalf .. hhalf, frame, (vhalf == "TOP" and "BOTTOM" or "TOP") .. hhalf + return vhalf .. hhalf, frame, (vhalf == "TOP" and "BOTTOM" or "TOP") .. hhalf end function tipPrototype:SmartAnchorTo(frame) - if not frame then - error("Invalid frame provided.", 2) - end + if not frame then + error("Invalid frame provided.", 2) + end - self:ClearAllPoints() - self:SetClampedToScreen(true) - self:SetPoint(GetTipAnchor(frame)) + self:ClearAllPoints() + self:SetClampedToScreen(true) + self:SetPoint(GetTipAnchor(frame)) end ------------------------------------------------------------------------------ @@ -1528,24 +1542,24 @@ end -- @debug @ local print = print local function PrintStats() - local tipCache = tostring(#tooltipHeap) - local frameCache = tostring(#frameHeap) - local tableCache = tostring(#tableHeap) - local header = false + local tipCache = tostring(#tooltipHeap) + local frameCache = tostring(#frameHeap) + local tableCache = tostring(#tableHeap) + local header = false - print("Tooltips used: " .. usedTooltips .. ", Cached: " .. tipCache .. ", Total: " .. tipCache + usedTooltips) - print("Frames used: " .. usedFrames .. ", Cached: " .. frameCache .. ", Total: " .. frameCache + usedFrames) - print("Tables used: " .. usedTables .. ", Cached: " .. tableCache .. ", Total: " .. tableCache + usedTables) + print("Tooltips used: " .. usedTooltips .. ", Cached: " .. tipCache .. ", Total: " .. tipCache + usedTooltips) + print("Frames used: " .. usedFrames .. ", Cached: " .. frameCache .. ", Total: " .. frameCache + usedFrames) + print("Tables used: " .. usedTables .. ", Cached: " .. tableCache .. ", Total: " .. tableCache + usedTables) - for k in pairs(activeTooltips) do - if not header then - print("Active tooltips:") - header = true - end - print("- " .. k) - end + for k in pairs(activeTooltips) do + if not header then + print("Active tooltips:") + header = true + end + print("- " .. k) + end end SLASH_LibQTip1 = "/qtip" _G.SlashCmdList["LibQTip"] = PrintStats ---@end-debug@ +--@end-debug@]==] diff --git a/Titan/libs/Ace/LibQTip-1.0/LibQTip-1.0.toc b/Titan/libs/Ace/LibQTip-1.0/LibQTip-1.0.toc index e26ee7b..42fd94e 100644 --- a/Titan/libs/Ace/LibQTip-1.0/LibQTip-1.0.toc +++ b/Titan/libs/Ace/LibQTip-1.0/LibQTip-1.0.toc @@ -1,12 +1,13 @@ -## Interface: 90001 +## Interface: 100007 ## Title: Lib: QTip-1.0 ## Notes: Library providing multi-column tooltips. ## Author: Torhal, Adirelle, Elkano, Tristanian -## Version: 9.0.1.2 +## Version: 10.0.7.1 ## LoadOnDemand: 1 -## X-Date: 2020-10-25T22:33:10Z ## X-Credits: Kaelten (input on initial design) ## X-Category: Library, Tooltip +## X-Curse-Project-ID: 15487 +## X-Date: 2023-03-29T21:01:29Z ## X-License: Ace3 BSD-like license ## X-Website: http://www.wowace.com/addons/libqtip-1-0/ diff --git a/Titan/libs/Ace/LibQTip-1.0/README.md b/Titan/libs/Ace/LibQTip-1.0/README.md new file mode 100644 index 0000000..61f5162 --- /dev/null +++ b/Titan/libs/Ace/LibQTip-1.0/README.md @@ -0,0 +1,30 @@ +# LibQTip-1.0 +LibQTip is designed replace GameTooltip - but with added functionality, such as multiple columns - from a minimalist design perspective. + +## Features +- Ability to display and handle multiple tooltips at the same time, +- Unlimited number of columns and lines, +- Column default and per cell justification, +- Tooltip default and per cell font setting, +- Colspans, +- Possibility to add custom cells, +- Optional scrollbar, +- Optional scripts for lines, columns, or cells, +- Optional automatic hiding, +- Frames and tables recycling to reduce resource footprint. + +## Caveats +Look [here](https://www.wowace.com/projects/libqtip-1-0/pages/getting-started) for information on embedding the latest beta/release. + +**In order to achieve effective frame recycling, tooltips must be released.** + +Holding a tooltip leads to the creation of a full set of frames for every AddOn which does not follow this practice. Moreover, releasing a tooltip has a very little overhead compared to its benefits. + +## Known issues +Alignment may be altered when using :SetScale after filling the tooltip. + +## Documentation +- [Getting Started Guide](https://www.wowace.com/projects/libqtip-1-0/pages/getting-started) +- [How to Add Custom Cells](https://www.wowace.com/projects/libqtip-1-0/pages/how-to-add-custom-cells) +- [API Reference](https://www.wowace.com/projects/libqtip-1-0/pages/api-reference) +- [Standard CellProvider API](https://www.wowace.com/projects/libqtip-1-0/pages/standard-cell-provider-api) diff --git a/Titan/libs/Ace/LibQTip-1.0/lib.xml b/Titan/libs/Ace/LibQTip-1.0/lib.xml index 55047ef..5531be0 100644 --- a/Titan/libs/Ace/LibQTip-1.0/lib.xml +++ b/Titan/libs/Ace/LibQTip-1.0/lib.xml @@ -1,4 +1,4 @@ <Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd"> <Script file="LibQTip-1.0.lua"/> -</Ui> +</Ui> \ No newline at end of file diff --git a/Titan/libs/Ace/LibSharedMedia-3.0/CHANGES.txt b/Titan/libs/Ace/LibSharedMedia-3.0/CHANGES.txt index d154389..98dd1b2 100644 --- a/Titan/libs/Ace/LibSharedMedia-3.0/CHANGES.txt +++ b/Titan/libs/Ace/LibSharedMedia-3.0/CHANGES.txt @@ -1,8 +1,7 @@ ------------------------------------------------------------------------ -r142 | funkehdude | 2023-10-11 11:07:08 +0000 (Wed, 11 Oct 2023) | 1 line +r154 | funkehdude | 2024-11-20 16:58:47 +0000 (Wed, 20 Nov 2024) | 1 line Changed paths: M /trunk/LibSharedMedia-3.0.toc - M /trunk/LibSharedMedia-3.0_Wrath.toc bump toc ------------------------------------------------------------------------ diff --git a/Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0.toc b/Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0.toc index 26614a8..61ff4fb 100644 --- a/Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0.toc +++ b/Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0.toc @@ -1,15 +1,15 @@ -## Interface: 100107 +## Interface: 11504, 11505, 20504, 30403, 40400, 40401, 110005, 110007, 110002 ## LoadOnDemand: 1 ## Title: Lib: SharedMedia-3.0 ## Notes: Shared handling of media data (fonts, sounds, textures, ...) between addons. ## Author: Elkano -## Version: 3.0-142 +## Version: 3.0-154 ## X-Website: https://www.curseforge.com/wow/addons/libsharedmedia-3-0 ## X-Category: Library -## X-Revision: 142 -## X-Date: 2023-10-11T11:07:08Z +## X-Revision: 154 +## X-Date: 2024-11-20T16:58:47Z LibStub\LibStub.lua CallbackHandler-1.0\CallbackHandler-1.0.lua diff --git a/Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0/LibSharedMedia-3.0.lua b/Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0/LibSharedMedia-3.0.lua index fb3446c..94ee292 100644 --- a/Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0/LibSharedMedia-3.0.lua +++ b/Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0/LibSharedMedia-3.0.lua @@ -1,7 +1,7 @@ --@curseforge-project-slug: libsharedmedia-3-0@ --[[ Name: LibSharedMedia-3.0 -Revision: $Revision: 128 $ +Revision: $Revision: 151 $ Author: Elkano (elkano@gmx.de) Inspired By: SurfaceLib by Haste/Otravi (troeks@gmail.com) Website: http://www.wowace.com/projects/libsharedmedia-3-0/ @@ -23,11 +23,9 @@ local type = _G.type local band = _G.bit.band local table_sort = _G.table.sort -local RESTRICTED_FILE_ACCESS = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE -- starting with 8.2, some rules for file access have changed; classic still uses the old way - local locale = GetLocale() local locale_is_western -local LOCALE_MASK = 0 +local LOCALE_MASK lib.LOCALE_BIT_koKR = 1 lib.LOCALE_BIT_ruRU = 2 lib.LOCALE_BIT_zhCN = 4 @@ -199,7 +197,7 @@ lib.DefaultMedia.statusbar = "Blizzard" -- SOUND if not lib.MediaTable.sound then lib.MediaTable.sound = {} end -lib.MediaTable.sound["None"] = RESTRICTED_FILE_ACCESS and 1 or [[Interface\Quiet.ogg]] -- Relies on the fact that PlaySound[File] doesn't error on these values. +lib.MediaTable.sound["None"] = 1 -- Relies on the fact that PlaySoundFile doesn't error on this value lib.DefaultMedia.sound = "None" local function rebuildMediaList(mediatype) @@ -230,7 +228,7 @@ function lib:Register(mediatype, key, data, langmask) end if type(data) == "string" and (mediatype == lib.MediaType.BACKGROUND or mediatype == lib.MediaType.BORDER or mediatype == lib.MediaType.STATUSBAR or mediatype == lib.MediaType.SOUND) then local path = data:lower() - if RESTRICTED_FILE_ACCESS and not path:find("^interface") then + if not path:find("^interface") then -- files accessed via path only allowed from interface folder return false end diff --git a/Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0_TBC.toc b/Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0_TBC.toc deleted file mode 100644 index 0c503dd..0000000 --- a/Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0_TBC.toc +++ /dev/null @@ -1,18 +0,0 @@ -## Interface: 20504 -## LoadOnDemand: 1 - -## Title: Lib: SharedMedia-3.0 -## Notes: Shared handling of media data (fonts, sounds, textures, ...) between addons. -## Author: Elkano -## Version: 3.0-142 -## X-Website: https://www.curseforge.com/wow/addons/libsharedmedia-3-0 -## X-Category: Library - -## X-Revision: 142 -## X-Date: 2023-10-11T11:07:08Z - -LibStub\LibStub.lua -CallbackHandler-1.0\CallbackHandler-1.0.lua - -LibSharedMedia-3.0\lib.xml - diff --git a/Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0_Vanilla.toc b/Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0_Vanilla.toc deleted file mode 100644 index 7dfa670..0000000 --- a/Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0_Vanilla.toc +++ /dev/null @@ -1,18 +0,0 @@ -## Interface: 11404 -## LoadOnDemand: 1 - -## Title: Lib: SharedMedia-3.0 -## Notes: Shared handling of media data (fonts, sounds, textures, ...) between addons. -## Author: Elkano -## Version: 3.0-142 -## X-Website: https://www.curseforge.com/wow/addons/libsharedmedia-3-0 -## X-Category: Library - -## X-Revision: 142 -## X-Date: 2023-10-11T11:07:08Z - -LibStub\LibStub.lua -CallbackHandler-1.0\CallbackHandler-1.0.lua - -LibSharedMedia-3.0\lib.xml - diff --git a/Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0_Wrath.toc b/Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0_Wrath.toc deleted file mode 100644 index 4a9f887..0000000 --- a/Titan/libs/Ace/LibSharedMedia-3.0/LibSharedMedia-3.0_Wrath.toc +++ /dev/null @@ -1,18 +0,0 @@ -## Interface: 30403 -## LoadOnDemand: 1 - -## Title: Lib: SharedMedia-3.0 -## Notes: Shared handling of media data (fonts, sounds, textures, ...) between addons. -## Author: Elkano -## Version: 3.0-142 -## X-Website: https://www.curseforge.com/wow/addons/libsharedmedia-3-0 -## X-Category: Library - -## X-Revision: 142 -## X-Date: 2023-10-11T11:07:08Z - -LibStub\LibStub.lua -CallbackHandler-1.0\CallbackHandler-1.0.lua - -LibSharedMedia-3.0\lib.xml - diff --git a/Titan/libs/Ace/changelog.txt b/Titan/libs/Ace/changelog.txt index 97c8a31..20e64ca 100644 --- a/Titan/libs/Ace/changelog.txt +++ b/Titan/libs/Ace/changelog.txt @@ -1,3 +1,16 @@ +Ace3 Release - Revision r1349 (July 23th, 2024) +----------------------------------------------- +- AceGUI-3.0: EditBoxes: Updated for WoW 11.0 API changes + +Ace3 Release - Revision r1341 (May 8th, 2024) +--------------------------------------------- +- AceComm-3.0: Updated ChatThrottleLib for new chat throttling in WoW 4.4.0 and 10.2.7+ +- AceGUI-3.0: Fixed ColorPicker alpha handling on WoW Classic + +Ace3 Release - Revision r1320 (January 17th, 2024) +-------------------------------------------------- +- AceGUI-3.0: Colorpicker: Compatibility for WoW 10.2.5 + Ace3 Release - Revision r1309 (July 12th, 2023) ----------------------------------------------- - AceDB-3.0: Fixed an issue due to a region change on the PTR diff --git a/TitanGold/TitanGold.lua b/TitanGold/TitanGold.lua index d689917..4a50ad6 100644 --- a/TitanGold/TitanGold.lua +++ b/TitanGold/TitanGold.lua @@ -43,8 +43,47 @@ local player_name = GetUnitName("Player") local FACTION_ALLIANCE = "Alliance_debug" local FACTION_HORDE = "Horde_debug" --]] + +-- Topic debug tool / scheme +local pdebug = Titan_Global.NewDebug() +pdebug.enabled = false +pdebug.topics[1].enabled = true +pdebug.topics[2].enabled = false +pdebug.topics[3] = { enabled = true, topic = "Tooltip"} + -- ******************************** Functions ******************************* +---local Take the total cash and make it into a nice, colorful string of g s c (gold silver copper) +---@param value number +---@param show_zero boolean +---@param show_neg boolean +---@return string outstr Formatted cash for output +---@return integer gold part of value +---@return integer silver part of value +---@return integer copper part of value +local function NiceCash(value, show_zero, show_neg) + local sep = "" + local dec = "" + if (TitanGetVar(TITAN_GOLD_ID, "UseSeperatorComma")) then + sep = "," + dec = "." + elseif (TitanGetVar(TITAN_GOLD_ID, "UseSeperatorPeriod")) then + sep = "." + dec = "," + elseif (TitanGetVar(TITAN_GOLD_ID, "UseSeperatorSpace")) then + sep = " " + dec = "." + end + + local outstr, gold, silver, copper = + TitanUtils_CashToString(value, sep, dec, + TitanGetVar(TITAN_GOLD_ID, "ShowGoldOnly"), + TitanGetVar(TITAN_GOLD_ID, "ShowCoinLabels"), + TitanGetVar(TITAN_GOLD_ID, "ShowCoinIcons"), + TitanGetVar(TITAN_GOLD_ID, "ShowColoredText")) + return outstr, gold, silver, copper +end + -- A bit overkill but make a class for the Warbank bank functions local Warband = { @@ -53,31 +92,14 @@ local Warband = { label = "", } ---local Warband Bank debug -function Warband.debug(reason) - print("WB " .. reason +function Gold_debug(reason) + local str = "" + .. "$" .. tostring(NiceCash(GetMoney(), false, false)) + .. " WB " .. reason .. " " .. tostring(Warband.active) .. " " .. tostring(Warband.label) - .. " " .. tostring(Warband.bank_sum) - ) -end - ----local Update Warband Bank info - sum -function Warband.SetSum() - Warband.bank_sum = C_Bank.FetchDepositedMoney(Enum.BankType.Account) - -- Warband.debug("SetSum") -end - ----local Set Warband Bank info -function Warband.Init() - -- check for func even though it does not work atm... 2024 Aug (Added 11.0.0) - Warband.active = (C_Bank and C_Bank.CanUseBank) and true or false - if Warband.active then - Warband.label = L["TITAN_WARBAND_BANK"] - Warband.SetSum() - else - -- Likely Classic version - end - -- Warband.debug("Init") + .. " " .. tostring(NiceCash(Warband.bank_sum, false, false)) + return str end ---local Check if Warband Bank is in this version and user requested @@ -93,21 +115,43 @@ function Warband.Use() else -- Likely Classic version end - return res end +---local Update Warband Bank info - sum +function Warband.SetSum() + if Warband.Use() then + -- Really just prevents errors if not implemented in the WoW version + Warband.bank_sum = C_Bank.FetchDepositedMoney(Enum.BankType.Account) + else + -- Likely Classic version + end + TitanTopicDebug(TITAN_GOLD_ID, 2, Gold_debug("SetSum")) +end + +---local Set Warband Bank info +function Warband.Init() + -- check for func in case either Classic implements (Added 11.0.0) + Warband.active = (C_Bank and C_Bank.CanUseBank) and true or false + if Warband.active then + Warband.label = L["TITAN_WARBAND_BANK"] + else + -- Likely Classic version + end + TitanTopicDebug(TITAN_GOLD_ID, 2, Gold_debug("Init")) +end + ---local Return Warband Bank info ---@return number function Warband.GetSum() - -- Warband.debug("GetSum") + TitanTopicDebug(TITAN_GOLD_ID, 2, Gold_debug("GetSum")) return Warband.bank_sum end ---local Return Warband Bank info ---@return string function Warband.GetName() - -- Warband.debug("GetName") + TitanTopicDebug(TITAN_GOLD_ID, 2, Gold_debug("GetName")) return Warband.label end @@ -124,6 +168,7 @@ local function Get_Money() -- Not accurate but safe money = 0 end + Warband.SetSum() -- update warbank as well return money end @@ -258,37 +303,6 @@ end ---local Take the total cash and make it into a nice, colorful string of g s c (gold silver copper) ---@param value number ----@param show_zero boolean ----@param show_neg boolean ----@return string outstr Formatted cash for output ----@return integer gold part of value ----@return integer silver part of value ----@return integer copper part of value -local function NiceCash(value, show_zero, show_neg) - local sep = "" - local dec = "" - if (TitanGetVar(TITAN_GOLD_ID, "UseSeperatorComma")) then - sep = "," - dec = "." - elseif (TitanGetVar(TITAN_GOLD_ID, "UseSeperatorPeriod")) then - sep = "." - dec = "," - elseif (TitanGetVar(TITAN_GOLD_ID, "UseSeperatorSpace")) then - sep = " " - dec = "." - end - - local outstr, gold, silver, copper = - TitanUtils_CashToString(value, sep, dec, - TitanGetVar(TITAN_GOLD_ID, "ShowGoldOnly"), - TitanGetVar(TITAN_GOLD_ID, "ShowCoinLabels"), - TitanGetVar(TITAN_GOLD_ID, "ShowCoinIcons"), - TitanGetVar(TITAN_GOLD_ID, "ShowColoredText")) - return outstr, gold, silver, copper -end - ----local Take the total cash and make it into a nice, colorful string of g s c (gold silver copper) ----@param value number ---@return string outstr Formatted cash for output ---@return integer gold part of value ---@return integer silver part of value @@ -637,10 +651,14 @@ local function GetTooltipText() -- === Add Warband Bank -- if Warband.Use() then + local cash = NiceCash(Warband.GetSum(), false, false) + local war_name = ""..Warband.GetName() -- localized currentMoneyRichText = currentMoneyRichText .. "\n" .. "------ \t +" .. "\n" - .. Warband.GetName() -- localized - .. "\t" .. NiceCash(Warband.GetSum(), false, false) + .. war_name + .. "\t" .. cash + local str = "" .. war_name .. " ".. cash + TitanTopicDebug(TITAN_GOLD_ID, 3, str) end @@ -769,14 +787,6 @@ local function Initialize_Array(self) if (GOLD_INITIALIZED) then -- already done else - self:UnregisterEvent("ADDON_LOADED"); - - -- See if this is a new toon to Gold - if (GoldSave[GOLD_INDEX] == nil) then - GoldSave[GOLD_INDEX] = {} - GoldSave[GOLD_INDEX] = { gold = Get_Money(), name = player_name } - end - -- Ensure the saved vars are usable for index, money in pairs(GoldSave) do local character, charserver, char_faction = GetIndexInfo(index) @@ -1021,7 +1031,7 @@ local function CreateMenu() if Warband.active then -- Function to toggle show / hide of Warbank gold info = {}; - info.text = L["TITAN_GOLD_INCLUDE_WARBANK"] -- .. " - " .. NiceTextCash(Warband.GetSum())..""; + info.text = L["TITAN_GOLD_INCLUDE_WARBANK"] info.checked = TitanGetVar(TITAN_GOLD_ID, "ShowWarband"); info.func = function() @@ -1173,6 +1183,7 @@ local function OnLoad(self) tooltipTitle = L["TITAN_GOLD_TOOLTIP"], tooltipTextFunction = GetTooltipText, buttonTextFunction = FindGold, + debugClass = pdebug, icon = "Interface\\AddOns\\TitanGold\\Artwork\\TitanGold", iconWidth = 16, notes = notes, @@ -1231,21 +1242,15 @@ local function OnShow(self) -- timer running or user does not want gold per hour end - -- Leave active so user can toggle - if Warband.active then - Warband.SetSum() - self:RegisterEvent("ACCOUNT_MONEY") -- register for changes - end + local dbg = "" + .." "..Gold_debug("OnShow") + TitanTopicDebug(TITAN_GOLD_ID, 1, dbg) end ---local When shown, unregister needed events and stop timer for gold per hour ---@param self Button local function OnHide(self) self:UnregisterEvent("PLAYER_MONEY"); - if Warband.active then - ---@diagnostic disable-next-line: param-type-mismatch - self:UnregisterEvent("ACCOUNT_MONEY") - end AceTimer:CancelTimer(GoldTimer) GoldTimerRunning = false end @@ -1255,21 +1260,11 @@ end ---@param event string ---@param ... any local function OnEvent(self, event, a1, ...) - --[[ -print("_OnEvent" -.." "..tostring(event).."" -) ---]] - if (event == "PLAYER_MONEY") then if (GOLD_INITIALIZED) then GoldSave[GOLD_INDEX].gold = Get_Money() TitanPanelButton_UpdateButton(TITAN_GOLD_ID) end - elseif (event == "ACCOUNT_MONEY") then - if (GOLD_INITIALIZED) then - Warband.SetSum() - end elseif (event == "ADDON_LOADED") then if a1 == addonName then realmName = GetRealmName() -- this realm @@ -1281,14 +1276,25 @@ print("_OnEvent" -- Faction is English to use as index NOT display GOLD_INDEX = CreateIndex(player_name, realmName, player_faction) + + -- See if this is a new toon to Gold saved vars + -- Set gold to 0; it will be set properly later + if (GoldSave[GOLD_INDEX] == nil) then + GoldSave[GOLD_INDEX] = {} + GoldSave[GOLD_INDEX] = { gold = 0, name = player_name } + end + + self:UnregisterEvent("ADDON_LOADED"); else -- Not this addon + return -- no debug, if enabled end elseif (event == "PLAYER_ENTERING_WORLD") then Initialize_Array(self); Warband.Init() TitanPanelButton_UpdateButton(TITAN_GOLD_ID) end + TitanTopicDebug(TITAN_GOLD_ID, 1, event) end ---Button clicks - only shift-left for now