From eb2a2a7bc6f26b6ee8630272cb5eec906a594ac1 Mon Sep 17 00:00:00 2001 From: urnati Date: Sat, 6 Apr 2024 16:16:50 -0400 Subject: [PATCH] - Update TOC to 8.0.11 - Volume : Double click to toggle mute; icons now react to % - XP : Do not show time played; use /played in Chat - Config > Plugins : Add to Notes - Config > Skins : Add note to use Bar / All options to change skins / color - Titan : A LOT of annotation and comment changes; better handling of retail vs Classic API differences --- Titan/Titan.code-workspace | 137 +- Titan/Titan.lua | 599 ++---- Titan/TitanAutoHide.lua | 24 +- Titan/TitanConfig.lua | 227 +-- Titan/TitanGame.lua | 9 +- Titan/TitanGlobal.lua | 76 +- Titan/TitanHistory.lua | 75 + Titan/TitanIDE.lua | 189 -- Titan/TitanLDB.lua | 707 ++++--- Titan/TitanMovable.lua | 313 ++-- Titan/TitanPanelSetup-READ_ME_FIRST.txt | 12 - Titan/TitanPluginDoc.lua | 61 - Titan/TitanTemplate.lua | 1000 +++++----- Titan/TitanTemplate.xml | 4 +- Titan/TitanUtils.lua | 2335 +++++++++++------------- Titan/TitanVariables.lua | 459 ++--- Titan/Titan_Mainline.toc | 4 +- Titan/_ATitanDoc.lua | 338 ++++ Titan/_TitanIDE.lua | 201 ++ Titan/locale/Localization.BR.lua | 7 +- Titan/locale/Localization.CN.lua | 7 +- Titan/locale/Localization.DE.lua | 7 +- Titan/locale/Localization.ES.lua | 7 +- Titan/locale/Localization.FR.lua | 7 +- Titan/locale/Localization.IT.lua | 7 +- Titan/locale/Localization.KR.lua | 7 +- Titan/locale/Localization.MX.lua | 7 +- Titan/locale/Localization.RU.lua | 7 +- Titan/locale/Localization.TW.lua | 7 +- Titan/locale/Localization.lua | 7 +- TitanAmmo/TitanAmmo_Vanilla.toc | 4 +- TitanAmmo/TitanAmmo_Wrath.toc | 4 +- TitanAmmo/TitanClassicAmmo.lua | 9 +- TitanBag/TitanBag_Mainline.toc | 4 +- TitanBag/TitanBag_Vanilla.toc | 4 +- TitanBag/TitanBag_Wrath.toc | 4 +- TitanClassic/TitanClassic_Vanilla.toc | 5 +- TitanClassic/TitanClassic_Wrath.toc | 5 +- TitanClassic/TitanGame.lua | 4 +- TitanClock/TitanClock_Mainline.toc | 4 +- TitanClock/TitanClock_Vanilla.toc | 4 +- TitanClock/TitanClock_Wrath.toc | 4 +- TitanGold/TitanGold_Mainline.toc | 4 +- TitanGold/TitanGold_Vanilla.toc | 4 +- TitanGold/TitanGold_Wrath.toc | 4 +- TitanLocation/TitanLocation.lua | 10 +- TitanLocation/TitanLocation_Mainline.toc | 4 +- TitanLocation/TitanLocation_Vanilla.toc | 4 +- TitanLocation/TitanLocation_Wrath.toc | 4 +- TitanLootType/TitanClassicLootType.lua | 4 +- TitanLootType/TitanLootType_Mainline.toc | 4 +- TitanLootType/TitanLootType_Vanilla.toc | 4 +- TitanLootType/TitanLootType_Wrath.toc | 4 +- TitanPerformance/TitanPerformance.lua | 4 +- TitanPerformance/TitanPerformance_Mainline.toc | 4 +- TitanPerformance/TitanPerformance_Vanilla.toc | 4 +- TitanPerformance/TitanPerformance_Wrath.toc | 4 +- TitanRegen/TitanRegen.lua | 1 + TitanRegen/TitanRegen_Vanilla.toc | 4 +- TitanRegen/TitanRegen_Wrath.toc | 4 +- TitanRepair/TitanRepair.lua | 26 +- TitanRepair/TitanRepair_Mainline.toc | 4 +- TitanRepair/TitanRepair_Vanilla.toc | 4 +- TitanRepair/TitanRepair_Wrath.toc | 4 +- TitanVolume/TitanVolume.lua | 113 +- TitanVolume/TitanVolume_Mainline.toc | 4 +- TitanVolume/TitanVolume_Vanilla.toc | 4 +- TitanVolume/TitanVolume_Wrath.toc | 4 +- TitanXP/TitanXP.lua | 288 +-- TitanXP/TitanXP_Mainline.toc | 4 +- TitanXP/TitanXP_Vanilla.toc | 4 +- TitanXP/TitanXP_Wrath.toc | 4 +- 72 files changed, 3715 insertions(+), 3725 deletions(-) create mode 100644 Titan/TitanHistory.lua delete mode 100644 Titan/TitanIDE.lua delete mode 100644 Titan/TitanPluginDoc.lua create mode 100644 Titan/_ATitanDoc.lua create mode 100644 Titan/_TitanIDE.lua diff --git a/Titan/Titan.code-workspace b/Titan/Titan.code-workspace index 45392d3..84d2af7 100644 --- a/Titan/Titan.code-workspace +++ b/Titan/Titan.code-workspace @@ -233,7 +233,142 @@ "date", "C_PetBattles", "ID", - "UIParent_ManageFramePositions" + "UIParent_ManageFramePositions", + "MUTE", + "OFF", + "MUTED", + "show", + "Add", + "NOTE", + "setmetatable", + "assert", + "select", + "getmetatable", + "PlaySound", + "newproxy", + "unpack", + "rawequal", + "securecallfunction", + "WOW_PROJECT_ID", + "loadstring", + "GetCursorInfo", + "next", + "wipe", + "rawset", + "rawget", + "GetLocale", + "geterrorhandler", + "BackdropTemplateMixin", + "xpcall", + "GetSpellInfo", + "CreateFont", + "max", + "min", + "ceil", + "GetTime", + "C_Timer", + "issecurevariable", + "hooksecurefunc", + "ClearCursor", + "GetMacroInfo", + "WOW_PROJECT_MAINLINE", + "PlaySoundFile", + "IsLoggedIn", + "PetHasActionBar", + "HasPetUI", + "GetNumShapeshiftForms", + "SetCVar", + "InCombatLockdown", + "GetScreenHeight", + "CreateFromMixins", + "GetMouseFocus", + "EventRegistry", + "Clamp", + "SOUNDKIT", + "C_Texture", + "Mixin", + "UnitPowerType", + "UnitHealth", + "UnitHealthMax", + "UnitPower", + "UnitPowerMax", + "GetItemInfo", + "GetInventorySlotInfo", + "C_Item", + "GetBuildInfo", + "GetInventoryItemID", + "UnitClass", + "GetInventoryItemCount", + "GetGameTime", + "RequestTimePlayed", + "UnitFactionGroup", + "time", + "UnitXPMax", + "UnitXP", + "GetXPExhaustion", + "GetZonePVPInfo", + "GetZoneText", + "GetSubZoneText", + "C_Map", + "GetBindLocation", + "C_CVar", + "UpdateAddOnCPUUsage", + "UpdateAddOnMemoryUsage", + "collectgarbage", + "GetAddOnMemoryUsage", + "GetFramerate", + "GetNetStats", + "gcinfo", + "GetAddOnCPUUsage", + "IsModifierKeyDown", + "GetAutoCompleteRealms", + "getn", + "GetMoney", + "CLASS_SORT_ORDER", + "LOCALIZED_CLASS_NAMES_MALE", + "RandomRoll", + "UnitIsGroupLeader", + "GetLootMethod", + "sort", + "IsInRaid", + "IsInGroup", + "IsInGuild", + "UnitIsInMyGuild", + "tContains", + "GetGuildInfo", + "SendChatMessage", + "GetLootThreshold", + "GuildControlGetRankName", + "UnitInParty", + "random", + "tinsert", + "UnitInRaid", + "C_GuildInfo", + "UnitGUID", + "GetItemQualityColor", + "C_TooltipInfo", + "GetRepairAllCost", + "GetGuildBankWithdrawMoney", + "GetGuildBankMoney", + "RepairAllItems", + "CanMerchantRepair", + "CanGuildBankRepair", + "IsGuildLeader", + "GetInventoryItemDurability", + "GetSpecialization", + "GetLootSpecialization", + "GetRaidDifficultyID", + "GetDifficultyInfo", + "GetDungeonDifficultyID", + "GetSpecializationInfo", + "GetSpecializationInfoByID", + "SetDungeonDifficultyID", + "IsInInstance", + "UnitLevel", + "SetRaidDifficultyID", + "GetNumSubgroupMembers", + "GetNumGroupMembers", + "UnitExists" ] } } \ No newline at end of file diff --git a/Titan/Titan.lua b/Titan/Titan.lua index 94d0a04..f06a111 100644 --- a/Titan/Titan.lua +++ b/Titan/Titan.lua @@ -1,8 +1,8 @@ ---@diagnostic disable: duplicate-set-field ---[[ File -NAME: TitanPanel.lua -DESC: Contains the basic routines of Titan. All the event handler routines, initialization routines, Titan menu routines, and select plugin handler routines. ---]] +--[===[ File +Contains the basic routines of Titan. +All the event handler routines, initialization routines, Titan menu routines, and select plugin handler routines. +--]===] -- Locals local TPC = TITAN_PANEL_CONSTANTS -- shortcut @@ -22,6 +22,8 @@ local AceConfigDialog = LibStub("AceConfigDialog-3.0") -------------------------------------------------------------- -- + +---Titan Give the user an are you sure popup whether to reload the UI or not. function TitanPanel_OkToReload() StaticPopupDialogs["TITAN_RESET_RELOAD"] = { text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]) @@ -39,15 +41,7 @@ function TitanPanel_OkToReload() StaticPopup_Show("TITAN_RESET_RELOAD"); end ---[[ Titan -NAME: TitanPanel_ResetToDefault -DESC: Give the user a 'are you sure'. If the user accepts then reset current toon back to default Titan settings. -VAR: None -OUT: None -NOTE: -- Even if the user was using global profiles they will not when this is done. -:NOTE ---]] +---Titan Give the user a 'are you sure' popup whether to reset current toon back to default Titan settings. function TitanPanel_ResetToDefault() StaticPopupDialogs["TITAN_RESET_BAR"] = { text = TitanUtils_GetNormalText(L["TITAN_PANEL_MENU_TITLE"]) @@ -67,15 +61,8 @@ function TitanPanel_ResetToDefault() StaticPopup_Show("TITAN_RESET_BAR"); end ---[[ Titan -NAME: TitanPanel_SaveCustomProfile -DESC: The user wants to save a custom Titan profile. Show the user the dialog boxes to make it happen. -VAR: None -OUT: None -NOTE: -- The profile is written to the Titan saved variables. A reload of the UI is needed to ensure the profile is written to disk for the user to load later. -:NOTE ---]] +---Titan The user wants to save a custom Titan profile. Show the user the dialog boxes to make it happen. +--- The profile is written to the Titan saved variables. A reload of the UI is needed to ensure the profile is written to disk for the user to load later. function TitanPanel_SaveCustomProfile() -- Create the dialog box code we'll need... @@ -188,16 +175,10 @@ function TitanPanel_SaveCustomProfile() -- StaticPopupDialogs["TITAN_SAVE_CUSTOM_PROFILE"] = {} end ---[[ Titan -NAME: TitanSetPanelFont -DESC: Set or change the font and font size of text on the Titan bar. This affects ALL plugins. -VAR: fontname - The text name of the font to use. Defaults to Titan default if none given. -VAR: fontsize - The size of the font to use. Defaults to Titan default if none given. -OUT: None -NOTE: -- Each registered plugin will have its font updated. Then all plugins will be refreshed to show the new font. -:NOTE ---]] +---Titan Set or change the font and font size of text on the Titan bar. This affects ALL plugins. +--- Each registered plugin will have its font updated. Then all plugins will be refreshed to show the new font. +---@param fontname string path to font file +---@param fontsize number in points function TitanSetPanelFont(fontname, fontsize) -- a couple of arg checks to avoid unpleasant things... if not fontname then fontname = TPC.FONT_NAME end @@ -258,16 +239,10 @@ _G[TITAN_PANEL_CONTROL]:SetScript("OnEvent", function(_, event, ...) end) ---[[ Titan -NAME: TitanPanel_PlayerEnteringWorld -DESC: Do all the setup needed when a user logs in / reload UI / enter or leave an instance. -VAR: None -OUT: None -NOTE: -- This is called after the 'player entering world' event is fired by Blizz. -- This is also used when a LDB plugin is created after Titan runs the 'player entering world' code. -:NOTE ---]] +---Titan Do all the setup needed when a user logs in / reload UI / enter or leave an instance. +--- This is called after the 'player entering world' event is fired by Blizz. +--- This is also called when a LDB plugin is created after Titan runs the 'player entering world' code. +---@param reload boolean true if reload; false if character 'first' enter function TitanPanel_PlayerEnteringWorld(reload) --[[ print("PEW" @@ -375,7 +350,7 @@ print("PEW" -- Move frames if TITAN_ID == "TitanClassic" then TitanMovable_SecureFrames() - TitanPanel_AdjustFrames() + TitanPanel_AdjustFrames(true, "_PlayerEnteringWorld") else -- No need end @@ -402,39 +377,20 @@ end -- n/a end --]===] + + +---Titan Handle ADDON_LOADED Minimal setup in prep for player login. function TitanPanelBarButton:ADDON_LOADED(addon) if addon == TITAN_ID then - --[[ -print("ADDON_LOADED" -.." "..tostring(addon).."" -) ---]] _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_ENTERING_WORLD") TitanVariables_InitTitanSettings() -- Min table setup to start. - --[===[ - -- Determine WoW TOC Version - local wowversion = select(4, GetBuildInfo()) - if wowversion >= 100000 then -- Initialize Titan - _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_ENTERING_WORLD") - - TitanVariables_InitTitanSettings() -- Min table setup to start. - else - -- User loaded wrong Titan version; tried to use retail on Classic or Classic Era - -- Could save the user grief; Titan could mangle the saved vars on a version mismatch. - TitanPrint("Titan did not initialize!!!!" - , "error") - TitanPrint("This version needs API released with " - .." "..tostring(EXPANSION_NAME9).."" - .." (10.00.xx)" - , "error") - end ---]===] -- Unregister event - saves a few event calls. self:UnregisterEvent("ADDON_LOADED"); self.ADDON_LOADED = nil end end +---Titan Handle PLAYER_ENTERING_WORLD Initialize Titan, set and display Titan bars and plugins. function TitanPanelBarButton:PLAYER_ENTERING_WORLD(arg1, arg2) local call_success = nil local ret_val = nil @@ -480,6 +436,7 @@ print("_PlayerEnteringWorld" end end +---Titan Handle CVAR_UPDATE React to user changed WoW options. function TitanPanelBarButton:CVAR_UPDATE(cvarname, cvarvalue) if cvarname == "USE_UISCALE" or cvarname == "WINDOWED_MODE" @@ -488,7 +445,7 @@ function TitanPanelBarButton:CVAR_UPDATE(cvarname, cvarvalue) TitanPanel_InitPanelBarButton("CVAR_ " .. tostring(cvarname)) if TITAN_ID == "TitanClassic" then -- Adjust frame positions - TitanPanel_AdjustFrames("PLAYER_REGEN_ENABLED") + TitanPanel_AdjustFrames(true, "CVAR_UPDATE Scale") else -- No need end @@ -496,6 +453,7 @@ function TitanPanelBarButton:CVAR_UPDATE(cvarname, cvarvalue) end end +---Titan Handle PLAYER_LOGOUT On logout, set some debug data in saved variables. function TitanPanelBarButton:PLAYER_LOGOUT() if not IsTitanPanelReset then -- for debug @@ -508,39 +466,49 @@ function TitanPanelBarButton:PLAYER_LOGOUT() Titan__InitializedPEW = false end +---Titan Handle ZONE_CHANGED_INDOORS Hide Titan top bars if user requested to hide Top bar(s) in BG or arena function TitanPanelBarButton:ZONE_CHANGED() TitanPanelBarButton_DisplayBarsWanted("ZONE_CHANGED") end +---Titan Handle ZONE_CHANGED_INDOORS Hide Titan top bars if user requested to hide Top bar(s) in BG or arena function TitanPanelBarButton:ZONE_CHANGED_INDOORS() TitanPanelBarButton_DisplayBarsWanted("ZONE_CHANGED_INDOORS") end +---Titan Handle ZONE_CHANGED_INDOORS Hide Titan top bars if user requested to hide Top bar(s) in BG or arena function TitanPanelBarButton:ZONE_CHANGED_NEW_AREA() TitanPanelBarButton_DisplayBarsWanted("ZONE_CHANGED_NEW_AREA") end +---Titan Handle PET_BATTLE_CLOSE Hide Titan bars during pet battle. function TitanPanelBarButton:PET_BATTLE_OPENING_START() TitanPanelBarButton_DisplayBarsWanted("PET_BATTLE_OPENING_START") end +---Titan Handle PET_BATTLE_CLOSE Show Titan bars hidden bars during pet battle. function TitanPanelBarButton:PET_BATTLE_CLOSE() TitanPanelBarButton_DisplayBarsWanted("PET_BATTLE_CLOSE") end local in_combat = false -- seems InCombatLockdown may not be set fast enough to reliably hide bars... + +---Titan Handle PLAYER_REGEN_ENABLED Titan bars may be hidden during combat. +--- Use local in_combat - seems InCombatLockdown() may not be set fast enough to reliably hide bars... function TitanPanelBarButton:PLAYER_REGEN_ENABLED() in_combat = false TitanPanelBarButton_DisplayBarsWanted("PLAYER_REGEN_ENABLED") if TITAN_ID == "TitanClassic" then -- Adjust frame positions - TitanPanel_AdjustFrames() + TitanPanel_AdjustFrames(false, "PLAYER_REGEN_ENABLED") else -- No need end end +---Titan Handle PLAYER_REGEN_DISABLED Titan bars may have been hidden during combat. +--- Use local in_combat - seems InCombatLockdown() may not be set fast enough to reliably hide bars... function TitanPanelBarButton:PLAYER_REGEN_DISABLED() in_combat = true TitanPanelBarButton_DisplayBarsWanted("PLAYER_REGEN_DISABLED") @@ -562,7 +530,7 @@ if TITAN_ID == "TitanClassic" then function TitanPanelBarButton:UNIT_EXITED_VEHICLE(self, ...) -- A combat check will be done inside the adjust - TitanPanel_AdjustFrames(true) + TitanPanel_AdjustFrames(true, "UNIT_ENTERED_VEHICLE") end --]] @@ -571,24 +539,13 @@ else -- No need end ---[[ Titan -NAME: TitanPanelBarButton_OnClick -DESC: Handle the button clicks on any Titan bar. -VAR: self - expected to be a Titan bar -VAR: button - which mouse button was clicked -OUT: None -NOTE: -- This only reacts to the right or left mouse click without modifiers. -- Used in the set script for the Titan display and hider frames -:NOTE ---]] +---Titan Handle the button clicks on any Titan bar. +--- This only reacts to the right or left mouse click without modifiers. +--- Used in the set script for the Titan display and hider frames +---@param self table Titan bar frame +---@param button string Button clicked function TitanPanelBarButton_OnClick(self, button) -- ensure that the right-click menu will not appear on "hidden" bottom bar(s) - --[[ -print("_OnClick" -.." "..tostring(bar).."" -) ---]] if (button == "LeftButton") then TitanUtils_CloseAllControlFrames(); TitanUtils_CloseRightClickMenu(); @@ -603,15 +560,12 @@ end -- -- Slash command handler -- ---[[ local -NAME: TitanPanel_ParseSlashCmd -DESC: Helper to parse the user commands. -VAR: cmd - user string from the command 'window' -OUT: table - table of 'words' the user typed in -NOTE: -- each 'word' in words table is made lower case for comparison simplicity -:NOTE ---]] + + +---local Helper to parse the user commands from Chat. +---@param cmd any +---@return table cmds List of 'words' user typed +--- each 'word' is made lower case for comparison simplicity local function TitanPanel_ParseSlashCmd(cmd) local words = {} for w in string.gmatch(cmd, "%w+") do @@ -628,15 +582,8 @@ local function TitanPanel_ParseSlashCmd(cmd) return words end ---[[ local -NAME: handle_slash_help -DESC: Helper to tell the user the relevant Titan commands. -VAR: cmd - string 'all' | 'reset' | 'gui' | 'silent' -OUT: None -NOTE: -- Depending on cmd put to chat the appropriate help -:NOTE ---]] +---local Helper to tell the user the relevant Titan help commands. +---@param cmd string? 'all' default | 'reset' | 'gui' | 'silent' local function handle_slash_help(cmd) cmd = cmd or "all" @@ -682,12 +629,8 @@ local function handle_slash_help(cmd) end end ---[[ local -NAME: handle_reset_cmds -DESC: Helper to execute the various reset commands from the user. -VAR: cmd_list - A table containing the list of 'words' the user typed in -OUT: None ---]] +---local Helper to handle 'reset' commands. +---@param cmd_list table 'tipfont' | 'panelscale' | "spacing" | none - Reset to Titan defaults local function handle_reset_cmds(cmd_list) local cmd = cmd_list[1] local p1 = cmd_list[2] or nil @@ -717,7 +660,7 @@ local function handle_reset_cmds(cmd_list) TitanPanel_InitPanelBarButton("/panelscale reset ") if TITAN_ID == "TitanClassic" then -- Adjust frame positions - TitanPanel_AdjustFrames() + TitanPanel_AdjustFrames(true, "/panelscale reset ") else -- No need end @@ -734,12 +677,8 @@ local function handle_reset_cmds(cmd_list) end end ---[[ local -NAME: handle_giu_cmds -DESC: Helper to execute the gui related commands from the user. -VAR: cmd_list - A table containing the list of 'words' the user typed in -OUT: None ---]] +---local Helper to handle 'gui' commands - open Titan options. +---@param cmd_list table local function handle_giu_cmds(cmd_list) local cmd = cmd_list[1] local p1 = cmd_list[2] or nil @@ -753,12 +692,8 @@ local function handle_giu_cmds(cmd_list) -- so the below does not work as expected... end ---[[ local -NAME: handle_profile_cmds -DESC: Helper to execute the profile related commands from the user. -VAR: cmd_list - A table containing the list of 'words' the user typed in -OUT: None ---]] +---local Helper to handle 'profile' commands - Set to profile if not using global profile. +---@param cmd_list table local function handle_profile_cmds(cmd_list) local cmd = cmd_list[1] local p1 = cmd_list[2] or nil @@ -780,15 +715,10 @@ local function handle_profile_cmds(cmd_list) end end ---[[ local -NAME: handle_silent_cmds -DESC: Helper to execute the silent commands from the user. -VAR: cmd_list - A table containing the list of 'words' the user typed in -OUT: None ---]] +---local Helper to handle 'silent' commands - Toggle "Silenced" setting. +---@param cmd_list table local function handle_silent_cmds(cmd_list) local cmd = cmd_list[1] - local p1 = cmd_list[2] or nil -- sanity check if (not cmd == "silent") then return @@ -803,12 +733,8 @@ local function handle_silent_cmds(cmd_list) end end ---[[ local -NAME: handle_orderhall_cmds -DESC: Helper to execute the orderhall commands from the user. -VAR: cmd_list - A table containing the list of 'words' the user typed in -OUT: None ---]] +---local Helper to handle 'orderhall' commands - Toggle "OrderHall" setting. +---@param cmd_list table local function handle_orderhall_cmds(cmd_list) local cmd = cmd_list[1] local p1 = cmd_list[2] or nil @@ -854,12 +780,10 @@ local function handle_orderhall_cmds(cmd_list) end end ---[[ local -NAME: handle_help_cmds +--[=[ local DESC: Helper to execute the help commands from the user. VAR: cmd_list - A table containing the list of 'words' the user typed in OUT: None ---]] local function handle_help_cmds(cmd_list) local cmd = cmd_list[1] local p1 = cmd_list[2] or nil @@ -870,13 +794,10 @@ local function handle_help_cmds(cmd_list) handle_slash_help(p1 or "all") end +--]=] ---[[ local -NAME: TitanPanel_RegisterSlashCmd -DESC: Helper to parse and execute all the Titan slash commands from the user. -VAR: cmd - The command (string) the user typed in -OUT: None ---]] +---local Helper to parse and execute all the Titan slash commands from the user. +---@param cmd_str string local function TitanPanel_RegisterSlashCmd(cmd_str) local cmd_list = {} -- parse what the user typed @@ -893,9 +814,9 @@ local function TitanPanel_RegisterSlashCmd(cmd_str) elseif (cmd == "profile") then handle_profile_cmds(cmd_list) elseif (cmd == "silent") then - handle_silent_cmds(p1) + handle_silent_cmds(cmd_list) elseif (cmd == "orderhall") then - handle_orderhall_cmds(p1) + handle_orderhall_cmds(cmd_list) elseif (cmd == "help") then handle_slash_help(p1) else @@ -911,6 +832,12 @@ SLASH_TitanPanel2 = "/titan"; -------------------------------------------------------------- -- -- Texture routines + + +---local Set the Titan bar color per user selection +---@param frame string Titan bar name +---@param tex table Texture frame to set +---@param color table Color - RBGA local function Set_Color(frame, tex, color) --[[ print("_Set bar color" @@ -957,9 +884,11 @@ print("_Set bar color" --]] end +---local Set the Titan bar texture / skin per user selectable options +---@param frame string Titan bar name +---@param tex table Texture frame to set +---@param skin table Skin to use local function Set_Skin(frame, tex, skin) - -- Use the texture / skin per user selectable options - -- skins are in two parts - top & bottom... -- TODO : have Short bars choose top or bottom skin?? local edge = "" @@ -1002,6 +931,8 @@ print("_Skin" tex:SetAlpha(skin.alpha) end +---Titan Set the texture / skin of the bar per the user selection. +---@param frame string Titan bar frame name function TitanPanel_SetBarTexture(frame) if frame and TitanBarData[frame] then -- proceed @@ -1050,12 +981,10 @@ end -------------------------------------------------------------- -- -- auto hide event handlers ---[[ Titan -NAME: TitanPanelBarButton_OnLeave -DESC: On leaving the display check if we have to hide the Titan bar. A timer is used - when it expires the bar is hid. -VAR: self - expected to be a Titan bar -OUT: None ---]] + + +---Titan On leaving the display check if we have to hide the Titan bar. A timer is used - when it expires the bar is hidden. +---@param self table Titan bar frame function TitanPanelBarButton_OnLeave(self) local frame = (self and self:GetName() or nil) local bar = (TitanBarData[frame] and TitanBarData[frame].name or nil) @@ -1068,35 +997,21 @@ function TitanPanelBarButton_OnLeave(self) end end ---[[ Titan -NAME: TitanPanelBarButton_OnEnter -DESC: No code - this is a place holder for the XML template. -VAR: self - expected to be a Titan bar -OUT: None ---]] +---Titan No code - this is a place holder for the XML template. +---@param self table Titan Hider bar frame function TitanPanelBarButton_OnEnter(self) -- no work to do end ---[[ Titan -NAME: TitanPanelBarButtonHider_OnLeave -DESC: No code - this is a place holder for the XML template. -VAR: self - expected to be a Titan bar -OUT: None ---]] +---Titan No code - this is a place holder for the XML template. +---@param self table Titan Hider bar frame function TitanPanelBarButtonHider_OnLeave(self) -- no work to do end ---[[ Titan -NAME: TitanPanelBarButtonHider_OnEnter -DESC: On entering the hider check if we need to show the display bar. -VAR: self - expected to be a Titan hider bar -OUT: None -NOTE: -- No action is taken if the user is on combat. -:NOTE ---]] +---Titan On entering the hider, check if we need to show the display bar. +--- No action is taken if the user is on combat. +---@param self table Titan Hider bar frame function TitanPanelBarButtonHider_OnEnter(self) -- make sure self is valid local index = self and self:GetName() or nil @@ -1125,12 +1040,10 @@ end --========================== -- Routines to handle adjusting some UI frames -- ---[[ Titan -NAME: TitanPanelBarButton_ToggleAlign -DESC: Align the buttons per the user's new choice. -VAR: align - left or center -OUT: None ---]] + +--[[ Appears unsed... +---Titan Align the buttons per the user's new choice. +---@param align number left or center function TitanPanelBarButton_ToggleAlign(align) -- toggle between left or center if (TitanPanelGetVar(align) == TITAN_PANEL_BUTTONS_ALIGN_CENTER) then @@ -1142,13 +1055,10 @@ function TitanPanelBarButton_ToggleAlign(align) -- Justify button position TitanPanelButton_Justify(); end - ---[[ Titan -NAME: TitanPanelBarButton_ToggleAutoHide -DESC: Toggle the auto hide of the given Titan bar per the user's new choice. -VAR: frame - expected to be a Titan bar -OUT: None --]] + +---Titan Toggle the auto hide of the given Titan bar per the user's new choice. +---@param frame string Frame mame of the Titan bar function TitanPanelBarButton_ToggleAutoHide(frame) local frName = _G[frame] local plugin = (TitanBarData[frame] and TitanBarData[frame].auto_hide_plugin or nil) @@ -1158,33 +1068,20 @@ function TitanPanelBarButton_ToggleAutoHide(frame) end end ---[[ Titan -NAME: TitanPanelBarButton_ToggleScreenAdjust -DESC: Toggle whether Titan adjusts 'top' frames around Titan bars per the user's new choice. -VAR: None -NOTE: -- Another addon can tell Titan to NOT adjust some or all frames. -:NOTE ---]] +---Titan Toggle whether Titan adjusts 'top' frames around Titan bars per the user's new choice. +--- Another addon can tell Titan to NOT adjust some or all frames. function TitanPanelBarButton_ToggleScreenAdjust() -- Turn on / off adjusting of other frames around Titan TitanPanelToggleVar("ScreenAdjust"); - TitanPanel_AdjustFrames(true) + TitanPanel_AdjustFrames(true, "_ToggleScreenAdjust") end ---[[ Titan -NAME: TitanPanelBarButton_ToggleAuxScreenAdjust -DESC: Toggle whether Titan adjusts 'bottom' frames around Titan bars per the user's new choice. -VAR: None -OUT: None -NOTE: -- Another addon can tell Titan to NOT adjust some or all frames. -:NOTE ---]] +---Titan Toggle whether Titan adjusts 'bottom' frames around Titan bars per the user's new choice. +--- Another addon can tell Titan to NOT adjust some or all frames. function TitanPanelBarButton_ToggleAuxScreenAdjust() -- turn on / off adjusting of frames at the bottom of the screen TitanPanelToggleVar("AuxScreenAdjust"); - TitanPanel_AdjustFrames(true) + TitanPanel_AdjustFrames(true, "_ToggleAuxScreenAdjust") end --====== Titan Bar @@ -1193,13 +1090,12 @@ end -- Routines to handle moving and sizing of short bars -- ---[[ local -NAME: TitanPanel_SetScale -DESC: Set the scale of each plugin and each Titan bar. -VAR: None -OUT: None ---]] +---local Check the change in width; snap to edge of any part goes off screen. +---@param self table Titan short bar frame +---@param width number New width +---@return table result .ok boolean; .err string local function CheckBarBounds(self, width) + --- This is a touchy routine - change with care!! :) local trace = false -- true false local result = {} result.ok = true @@ -1357,12 +1253,8 @@ local function CheckBarBounds(self, width) return result end ---[[ local -NAME: OnMoveStart -DESC: Start the grap of a Short Titan bar if Shift and left mouse are held. -VAR: self - the bar frame -OUT: None ---]] +---local Start the grap of a Short Titan bar if Shift and left mouse are held. +---@param self table local function OnMoveStart(self) if IsShiftKeyDown() then if self:IsMovable() then @@ -1375,12 +1267,8 @@ local function OnMoveStart(self) end end ---[[ local -NAME: OnMovingStop -DESC: When a Short Titan bar drag is stopped. -VAR: self - the bar frame -OUT: None ---]] +---local When a Short Titan bar drag is stopped. +---@param self table local function OnMovingStop(self) self:StopMovingOrSizing() self.isMoving = nil @@ -1395,17 +1283,12 @@ local function OnMovingStop(self) -- Seems overkill - this will recalc all bars... end ---[[ local -NAME: OnMouseWheel -DESC: Change the width of a Short Titan bar when mouse is over the bar and Shift is held when the mouse wheel is used. -VAR: self - the bar frame -VAR: d - mouse wheel direction; assuming a 1 'click' is a pixel -OUT: None -NOTE: -- Can get noisy, "Initializes" all bars at each click to ensure the bar is drawn. -:NOTE ---]] +---local Change the width of a Short Titan bar when mouse is over the bar and Shift is held when the mouse wheel is used. +---@param self table Frame mouse is over +---@param d integer Mouse wheel direction (1 larger; -1 smaller) +--- Assuming a 1 'click' is a pixel local function OnMouseWheel(self, d) + -- Can get noisy, "Initializes" all bars at each click to ensure the bar is drawn. if IsShiftKeyDown() then local old_w = self:GetWidth() local delta = d @@ -1430,12 +1313,8 @@ print("wheel" end end ---[[ Titan -NAME: TitanPanelBarButton_ForceLDBLaunchersRight -DESC: Force all plugins created from LDB addons, visible or not, to be on the right side of the Titan bar. Any visible plugin will be forced to the right side on the same bar it is currently on. -VAR: None -OUT: None ---]] +---Titan Force all plugins created from LDB addons, visible or not, to be on the right side of the Titan bar. +--- Any visible plugin will be forced to the right side on the same bar it is currently on. function TitanPanelBarButton_ForceLDBLaunchersRight() local plugin = {} for index, id in pairs(TitanPluginsIndex) do @@ -1466,16 +1345,10 @@ function TitanPanelBarButton_ForceLDBLaunchersRight() end end ---[[ local -NAME: TitanAnchors -DESC: Helper to create the 'anchor' frames used by other addons that need to adjust so Titan can be visible. The anchor frames are adjusted depending on which Titan bars the user selects to show. -VAR: None -OUT: None -NOTE: -- TitanPanelTopAnchor - the frame at the bottom of the top bar(s) shown. -- TitanPanelBottomAnchor - the frame at the top of the bottom bar(s) shown. -:NOTE ---]] +---local Helper to create the 'anchor' frames used by other addons that need to adjust so Titan can be visible. +---The anchor frames are adjusted depending on which Titan bars the user selects to show. +--- - TitanPanelTopAnchor - the frame at the bottom of the top bar(s) shown. +--- - TitanPanelBottomAnchor - the frame at the top of the bottom bar(s) shown. local function TitanAnchors() local anchor_top = TitanMovable_GetPanelYOffset(TITAN_PANEL_PLACE_TOP) local anchor_bot = TitanMovable_GetPanelYOffset(TITAN_PANEL_PLACE_BOTTOM) @@ -1503,12 +1376,8 @@ TitanDebug("Anc top: "..top_y.." bot: "..bot_y end end ---[[ Titan -NAME: TitanPanelBarButton_DisplayBarsWanted -DESC: Show all the Titan bars the user has selected. -VAR: None -OUT: None ---]] +---Titan Show all the Titan bars the user has selected. +---@param reason string Debug note on where the call initiated function TitanPanelBarButton_DisplayBarsWanted(reason) local trace = false if trace then @@ -1528,28 +1397,24 @@ function TitanPanelBarButton_DisplayBarsWanted(reason) if TITAN_ID == "TitanClassic" then -- Adjust other frames because the bars shown / hidden may have changed - TitanPanel_AdjustFrames(true) + TitanPanel_AdjustFrames(true, "_DisplayBarsWanted") else -- Not needed with UI movable widgets end end ---[[ Titan -NAME: TitanPanelBarButton_HideAllBars -DESC: This routine will hide all the Titan bars (and hiders) regardless of what the user has selected. -VAR: None -OUT: None -NOTE: -- For example when the pet battle is active. We cannot figure out how to move the pet battle frame so we are punting and hiding Titan... -- We only need to hide the bars (and hiders) - not adjust frames -:NOTE ---]] +---Titan This routine will hide all the Titan bars (and hiders) regardless of what the user has selected. +--- For example when the pet battle is active. We cannot figure out how to move the pet battle frame so we are punting and hiding Titan... +--- We only need to hide the bars (and hiders) - not adjust frames function TitanPanelBarButton_HideAllBars() for idx, v in pairs(TitanBarData) do TitanPanelBarButton_Hide(idx) end end +---local Show the requested Titan bar. +---@param frame_str string Titan bar +---@return boolean CanShow False if there is a restricting condition local function showBar(frame_str) local flag = true -- only set false for known conditions @@ -1598,6 +1463,8 @@ print("showBar" return flag end +---local Set the position of the requested Titan bar. +---@param frame string Titan bar local function SetBar(frame) local trace = false local display = _G[frame]; @@ -1633,15 +1500,8 @@ local function SetBar(frame) end end ---[[ Titan -NAME: TitanPanelBarButton_Show -DESC: Show / hide the given Titan bar based on the user selection. -VAR: frame - expected to be a Titan bar name (string) -OUT: None -NOTE: -- Hide moves rather than just 'not shown'. Otherwise the buttons will stay visible defeating the purpose of hide. -:NOTE ---]] +---Titan Toggle the given Titan bar based on the user selection. +---@param frame string Frame mame of the Titan bar function TitanPanelBarButton_Show(frame) local display = _G[frame]; @@ -1675,16 +1535,10 @@ function TitanPanelBarButton_Show(frame) end end ---[[ Titan -NAME: TitanPanelBarButton_Hide -DESC: Hide the given Titan bar based on the user selection. -VAR: frame - expected to be a Titan bar name (string) -OUT: None -NOTE: -- Hide moves rather than just 'not shown'. Otherwise the buttons will stay visible defeating the purpose of hide. -- Also moves the hider bar if auto hide is not selected. -:NOTE ---]] +---Titan Hide the given Titan bar based on the user selection. +--- Hide moves rather than just 'not shown'. Otherwise the buttons will stay visible defeating the purpose of hide. +--- Also moves the hider bar if auto hide is not selected. +---@param frame string Frame mame of the Titan bar function TitanPanelBarButton_Hide(frame) if TITAN_PANEL_MOVING == 1 then return end @@ -1733,12 +1587,8 @@ print("_Hide" end end ---[[ Titan -NAME: TitanPanel_InitPanelButtons -DESC: Show all user selected plugins on the Titan bar(s) then justify per the user selection. -VAR: None -OUT: None ---]] +---Titan Show all user selected plugins on the Titan bar(s) then justify per the user selection. +--- This is done an all bars whether shown or not. function TitanPanel_InitPanelButtons() local button local r_prior = {} @@ -1838,27 +1688,19 @@ print("Bar plugins" TitanPanelButton_Justify(); end ---[[ Titan -NAME: TitanPanel_ReOrder -DESC: Reorder all the shown all user selected plugins on the Titan bar(s). Typically used after a button has been removed / hidden. -VAR: index - the index of the plugin removed so the list can be updated -OUT: None ---]] +---Titan Reorder all the shown all user selected plugins on the Titan bar(s). Typically used after a button has been removed / hidden. +---@param index number of the plugin removed function TitanPanel_ReOrder(index) for i = index, table.getn(TitanPanelSettings.Buttons) do TitanPanelSettings.Location[i] = TitanPanelSettings.Location[i + 1] end end ---[[ Titan -NAME: TitanPanel_RemoveButton -DESC: Remove a plugin then show all the shown all user selected plugins on the Titan bar(s). -VAR: id - the plugin name (string) -OUT: None -NOTE: -- This cancels all timers of name "TitanPanel"..id as a safeguard to destroy any active plugin timers based on a fixed naming convention : TitanPanel..id, eg. "TitanPanelClock" this prevents "rogue" timers being left behind by lack of an OnHide check -:NOTE ---]] +---Titan Remove a plugin then show all the shown all user selected plugins on the Titan bar(s). +--- This cancels all timers of name "TitanPanel"..id as a safeguard to destroy any active plugin timers +--- based on a fixed naming convention : TitanPanel..id, eg. "TitanPanelClock" this prevents "rogue" +--- timers being left behind by lack of an OnHide check +---@param id string Unique ID of the plugin function TitanPanel_RemoveButton(id) if (not TitanPanelSettings) then return; @@ -1868,7 +1710,7 @@ function TitanPanel_RemoveButton(id) local currentButton = TitanUtils_GetButton(id); -- safeguard ... - if id then AceTimer.CancelAllTimers("TitanPanel" .. id) end + 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)); @@ -1880,12 +1722,10 @@ function TitanPanel_RemoveButton(id) TitanPanel_InitPanelButtons(); end ---[[ Titan -NAME: TitanPanel_GetButtonNumber -DESC: Get the index of the given plugin from the Titan plugin displayed list. -VAR: id - the plugin name (string) -OUT: index of the plugin in the Titan plugin list or the end of the list. The routine returns +1 if not found so it is 'safe' to update / add to the Location ---]] +--- Titan Get the index of the given plugin from the Titan plugin displayed list. +--- The routine returns +1 if not found so it is 'safe' to add to the list +---@param id string Unique ID of the plugin +---@return number num position or num + 1 for end function TitanPanel_GetButtonNumber(id) if (TitanPanelSettings) then for i = 1, table.getn(TitanPanelSettings.Buttons) do @@ -1899,12 +1739,7 @@ function TitanPanel_GetButtonNumber(id) end end ---[[ Titan -NAME: TitanPanel_RefreshPanelButtons -DESC: Update / refresh each plugin from the Titan plugin list. Used when a Titan option is changed that effects all plugins. -VAR: None -OUT: None ---]] +---Titan Update / refresh each plugin from the Titan plugin list. Used when a Titan option is changed that effects all plugins. function TitanPanel_RefreshPanelButtons() if (TitanPanelSettings) then for i = 1, table.getn(TitanPanelSettings.Buttons) do @@ -1913,12 +1748,10 @@ function TitanPanel_RefreshPanelButtons() end end ---[[ Titan -NAME: TitanPanelButton_Justify -DESC: Justify the plugins on each Titan bar. Used when the user changes the 'center' option on a Titan bar. -VAR: None -OUT: None ---]] +---Titan Justify the plugins on each Titan bar. +--- Used when : +---- Init / show of a Titan bar +----the user changes the 'center' option on a Titan bar function TitanPanelButton_Justify() -- Only the left side buttons are justified. if (not TITAN_PANEL_BUTTONS_INIT_FLAG or not TitanPanelSettings) then @@ -2003,12 +1836,8 @@ local R_PLUGIN = "Plugin_" local R_SETTINGS = "Settings" local R_PROFILE = "Profile_" ---[[ local -NAME: BuildMainMenu -DESC: Show main Titan (right click) menu. -VAR: None -OUT: None ---]] +---local Show main Titan (right click) menu. +---@param frame string Frame to add to local function BuildMainMenu(frame) local locale_bar = TitanBarData[frame].locale_name local info = {}; @@ -2118,12 +1947,7 @@ local function BuildMainMenu(frame) TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); end ---[[ local -NAME: BuildServerProfilesMenu -DESC: Show list of servers / custom submenu off Profiles/Manage from the Titan (right click) menu. -VAR: None -OUT: None ---]] +---local Show list of servers / custom submenu off Profiles/Manage from the Titan (right click) menu. local function BuildServerProfilesMenu() local info = {}; local servers = {}; @@ -2175,12 +1999,7 @@ local function BuildServerProfilesMenu() end end ---[[ local -NAME: BuildPluginMenu -DESC: Show list of plugin defined options from the Titan right click menu. -VAR: None -OUT: None ---]] +---local Show list of plugin defined options from the Titan right click menu. local function BuildPluginMenu() -- local info = {}; @@ -2280,12 +2099,7 @@ local function BuildPluginMenu() end end ---[[ local -NAME: BuildPluginMenu -DESC: Show alphabetical list of toons submenu off Profiles/Manage/ from the Titan right click menu. -VAR: None -OUT: None ---]] +---local Show alphabetical list of toons submenu off Profiles/Manage/ from the Titan right click menu. local function BuildProfileMenu() -- local info = {}; @@ -2330,6 +2144,7 @@ local function BuildProfileMenu() .. " '" .. profname .. "' " .. L["TITAN_PANEL_MENU_PROFILE_DELETED"] , "info") + table.remove(Titan_Global.players, idx) TitanPanelRightClickMenu_Close(); end end @@ -2345,6 +2160,7 @@ local function BuildProfileMenu() setonce = 1; end info = {}; + info.disabled = off info.notCheckable = true info.text = player; info.value = index; @@ -2354,12 +2170,7 @@ local function BuildProfileMenu() end -- for players end ---[[ local -NAME: BuildAProfileMenu -DESC: Show save / load submenu off Profiles/Manage// from the Titan (right click) menu. -VAR: None -OUT: None ---]] +---local Show save / load submenu off Profiles/Manage// from the Titan (right click) menu. local function BuildAProfileMenu() local info = {}; @@ -2395,12 +2206,8 @@ local function BuildAProfileMenu() TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); end ---[[ local -NAME: BuildPluginCategoryMenu -DESC: Show the submenu with list of plugin off the category from the Titan (right click) menu. -VAR: None -OUT: None ---]] +---local Build the list of plugins for the category the mouse is over - Titan (right click) menu. +---@param frame string Frame to add to local function BuildPluginCategoryMenu(frame) local info = {}; local plugin; @@ -2430,11 +2237,11 @@ local function BuildPluginCategoryMenu(frame) if which_bar == nil then -- Plugin not shown else - if internal_bar == TitanBarData[frame].name then - info.text = info.text .. TitanUtils_GetGreenText(" (" .. which_bar .. ")") - else +-- if internal_bar == TitanBarData[frame].name then +-- info.text = info.text .. TitanUtils_GetGreenText(" (" .. which_bar .. ")") +-- else info.text = info.text .. TitanUtils_GetGoldText(" (" .. which_bar .. ")") - end +-- end end if plugin.controlVariables then @@ -2463,15 +2270,9 @@ local function BuildPluginCategoryMenu(frame) end end ---[[ Titan -NAME: TitanPanelRightClickMenu_PrepareBarMenu -DESC: This is the controller of the Titan (right click) menu. -VAR: self - expected to be the Titan bar that was right clicked -OUT: None -NOTE: -- Frame name used is RightClickMenu -:NOTE ---]] +---Titan This is the controller for the Titan (right click) menu. +---@param self table Titan bar frame that was right clicked +--- Frame name used is RightClickMenu function TitanPanelRightClickMenu_PrepareBarMenu(self) -- Determine which bar was clicked on -- local s, e, frame = string.find(self:GetName(), "(.*)RightClickMenu"); @@ -2543,24 +2344,20 @@ print("_prep R click" end end ---[[ Titan -NAME: TitanPanel_IsPluginShown -DESC: Determine if the given plugin is shown on a Titan bar. The Titan bar could be not shown or on auto hide and the plugin will still be 'shown'. -VAR: id - plugin name (string) -OUT: int - index of the plugin or nil ---]] +---Titan Determine if the given plugin is on any Titan bar. +---@param id string Unique ID of the plugin +---@return boolean shown True on a Titan bar even if hidden or on auto hide function TitanPanel_IsPluginShown(id) if (id and TitanPanelSettings) then - return TitanUtils_TableContainsValue(TitanPanelSettings.Buttons, id); + return TitanUtils_TableContainsValue(TitanPanelSettings.Buttons, id) + else + return false end end ---[[ Titan -NAME: TitanPanel_GetPluginSide -DESC: Determine if the given plugin is or would be on right or left of a Titan bar. This returns right or left regardless of whether the plugin is 'shown'. -VAR: id - plugin name (string) -OUT: string - "Right" or "Left" ---]] +---Titan Determine if the given plugin is / would be on right or left of a Titan bar. +---@param id string Unique ID of the plugin +---@return string R_L TITAN_RIGHT("Right") or TITAN_Left("Left") function TitanPanel_GetPluginSide(id) if (TitanGetVar(id, "DisplayOnRightSide")) then return TITAN_RIGHT; @@ -2580,12 +2377,8 @@ print("OnMoveStart" ) --]] ---[[ Titan -NAME: TitanPanel_InitPanelBarButton -DESC: Set the scale, texture (graphic), and transparancy of all the Titan bars based on the user selection. -VAR: None -OUT: None ---]] +---Titan Set the scale, texture (graphic), and transparancy of all the Titan bars based on the user selection. +---@param reason string Debug note on where the call initiated function TitanPanel_InitPanelBarButton(reason) -- Set initial Panel Scale TitanPanel_SetScale(); @@ -2595,12 +2388,6 @@ print("_InitPanelBarButton" ) --]] - --[===[ - for idx,v in pairs (TitanBarData) do - CheckBarBounds(_G[idx], 0) - TitanPanel_SetBarTexture(idx) - end ---]===] TitanPanelBarButton_DisplayBarsWanted("InitPanelBarButton") end @@ -2608,14 +2395,10 @@ end --========================== -- Routines to handle creation of Titan bars -- ---[[ Titan -NAME: TitanPanelButton_CreateBar(frame_str) -DESC: Create a Titan bar that can show plugins. -VAR: frame_str - name of the frame -NOTE: -- This assumes ... -:NOTE ---]] + + +---Titan Create a Titan bar that can show plugins. +---@param frame_str string Unique ID of the plugin function TitanPanelButton_CreateBar(frame_str) local this_bar = frame_str local a_bar = CreateFrame("Button", this_bar, UIParent, "Titan_Bar__Display_Template") diff --git a/Titan/TitanAutoHide.lua b/Titan/TitanAutoHide.lua index 5661c4b..afdb9b5 100644 --- a/Titan/TitanAutoHide.lua +++ b/Titan/TitanAutoHide.lua @@ -1,6 +1,5 @@ ---[[ File -NAME:TitanAutoHide.lua -DESC: Contains the routines of AutoHide Titan plugin to auto hide a Titan bar. +--[===[ File +Contains the routines of AutoHide Titan plugin to auto hide a Titan bar. Auto hide uses a data driven approach. Rather than seperate routines for each bar, auto hide is implemented in a general manner. The table TitanBarData hold relevant data needed to control auto hide. @@ -9,8 +8,9 @@ If auto hide is turned on these routines will show / hide the proper bar (and pl These routines control the 'push pin' on each bar, if shown. The hider bar is a 1/2 height bar used to catch the mouse over to show the bar again. -:DESC ---]] + +For documentation, this is treated as a Titan plugin +--]===] local AceTimer = LibStub("AceTimer-3.0") local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) local Dewdrop = nil @@ -38,7 +38,7 @@ local function Titan_AutoHide_SetIcon(self) end -- Event handlers ---[[ Titan +--[[ NAME: Titan_AutoHide_OnLoad DESC: Setup the plugin on the given bar. VAR: self - The bar @@ -61,7 +61,7 @@ function Titan_AutoHide_OnLoad(self) }; end ---[[ Titan +--[[ NAME: Titan_AutoHide_OnShow DESC: Show the plugin on the given bar. VAR: self - The bar @@ -71,7 +71,7 @@ function Titan_AutoHide_OnShow(self) Titan_AutoHide_SetIcon(self) end ---[[ Titan +--[[ NAME: Titan_AutoHide_OnClick DESC: Handle button clicks on the given bar. VAR: self - The bar @@ -85,7 +85,7 @@ function Titan_AutoHide_OnClick(self, button) end -- Auto hide routines ---[[ Titan +--[[ NAME: Titan_AutoHide_Timers DESC: This routine accepts the display bar frame and whether the cursor is entering or leaving. On enter kill the timers that are looking to hide the bar. On leave start the timer to hide the bar. VAR: frame - The bar @@ -110,7 +110,7 @@ function Titan_AutoHide_Timers(frame, action) end end ---[[ Titan +--[[ NAME: Titan_AutoHide_Init DESC: Show / hide the given bar per the user requested settings VAR: self - The bar @@ -142,7 +142,7 @@ function Titan_AutoHide_Init(frame) end end ---[[ Titan +--[[ NAME: Titan_AutoHide_ToggleAutoHide DESC: Toggle the user requested show / hide setting then show / hide given bar VAR: self - The bar @@ -158,7 +158,7 @@ function Titan_AutoHide_ToggleAutoHide(bar) Titan_AutoHide_Init(frame_str) end ---[[ Titan +--[[ NAME: Handle_OnUpdateAutoHide DESC: Hide the bar if the user has auto hide after the cursor leaves the display bar. VAR: frame - The bar diff --git a/Titan/TitanConfig.lua b/Titan/TitanConfig.lua index c1cd1b1..30894f0 100644 --- a/Titan/TitanConfig.lua +++ b/Titan/TitanConfig.lua @@ -1,13 +1,11 @@ ---[[ File -NAME: TitanConfig.lua -DESC: This file contains routines used by Titan to show and process the Titan options. +--[===[ File +This file contains routines used by Titan to show and process the Titan options. Titan uses Ace libraries to place the Titan options within the Blizzard option screens. Most routines in this file are local because they create the Titan options. These routines are called first when Titan processes the 'player entering world' event. If an options list (skins, extra, etc) is changed by the user then the Ace table needs to be updated and WoW server informed to 'redraw'. -:DESC ---]] +--]===] local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) local AceConfigDialog = LibStub("AceConfigDialog-3.0") @@ -18,108 +16,6 @@ local TitanSkinToRemove = "None"; local TitanSkinName, TitanSkinPath = "", ""; local TitanGlobalProfile = "" ---[[ -Use for notes and change log in game. -New Release Format -Gold - version & date -Green - 'header' -Highlight - notes. tips. and details - ---]] -local notes = "" -do - notes = notes - .. TitanUtils_GetGoldText("Downgrade from 8.x for ANY WoW version:\n") - .. TitanUtils_GetHighlightText("" - .. "- Titan Panel : Should DELETE Titan either manually or via addon manager.\n" - .. - "- Titan Panel saved variables : Should be fine for Retail; For CLassic (Wrath or Era) should DELETE Titan saved variables either manually or via addon manager.\n" - ) - .. TitanUtils_GetGoldText("Notes:\n") - .. TitanUtils_GetHighlightText("" - .. - "- Changing Titan Scaling : Short bars will move on screen. They should not go off screen. If Short bars move then drag to desired location. You may have to Reset the Short bar or temporarily disable top or bottom bars to drag the Short bar.\n" - ) - .. TitanUtils_GetGoldText("Known Issues:\n") - .. TitanUtils_GetHighlightText("" - .. "- Titan Bag : Opening bags is still an option until taint issue is resolved.\n" - ) -end - -local changes = "" -do -- recent change history - changes = changes - .. TitanUtils_GetGoldText("8.0.9 : 2024/03/19\n") - .. TitanUtils_GetGreenText("Titan : \n") - .. TitanUtils_GetHighlightText("" - .. "- TOC update for DragonFlight to 10.2.6.\n" - .. "- TOC update for Classic Era to 1.15.1.\n" - ) - .. "\n\n" - .. TitanUtils_GetGoldText("8.0.8 : 2024/03/08\n") - .. TitanUtils_GetGreenText("Location : \n") - .. TitanUtils_GetHighlightText("" - .. - "- Reverted change to TITAN_PANEL_MENU_CATEGORIES. Removal of this table broke a couple Titan plugins. Sorry about that.\n" - ) - .. "\n\n" - .. TitanUtils_GetGoldText("8.0.7 : 2024/03/05\n") - .. TitanUtils_GetGreenText("Titan : \n") - .. TitanUtils_GetHighlightText("" - .. "- Removed LDB and Titan examples due to Curse parsing checks.\n" - .. "- Updated the locale files for Categories.\n" - ) - .. TitanUtils_GetGreenText("Timers : \n") - .. TitanUtils_GetHighlightText("" - .. - "- Updates to TitanPeformance, TitanClock, TitanLocation, and TitanGold to ensure the respective timers are used properly..\n" - ) - .. "\n\n" - .. TitanUtils_GetGoldText("8.0.6 : 2024/03/03\n") - .. TitanUtils_GetGreenText("Titan : \n") - .. TitanUtils_GetHighlightText("" - .. "- Refactor code (cleanup, remove globals, IDE) for Visual Studio Code.\n" - .. "- Added icons to TOC (Retail only).\n" - .. "- Titan built-in plugins : Merged retail and Classic versions.\n" - ) - .. TitanUtils_GetGreenText("TitanRegen : \n") - .. TitanUtils_GetHighlightText("" - .. "- Removed two unneeded files.\n" - ) - .. TitanUtils_GetGreenText("TitanLoot : \n") - .. TitanUtils_GetHighlightText("" - .. "- Fixed version.\n" - ) - .. TitanUtils_GetGreenText("TitanRepair : \n") - .. TitanUtils_GetHighlightText("" - .. "- Re-added new process for showing repair costs with better formatting.\n" - ) - .. "\n\n" - .. TitanUtils_GetGoldText("8.0.5 : 2024/02/08\n") - .. TitanUtils_GetGreenText("Titan : \n") - .. TitanUtils_GetHighlightText("" - .. "- Add additional .registry (optional) to routine for right click menu explicit - used in example plugin.\n" - .. " Allow .registry routines to be local.\n" - .. "- Updated Interface value for 1.15.1 WoW CE release.\n" - ) - .. TitanUtils_GetGreenText("TitanBag : \n") - .. TitanUtils_GetHighlightText("" - .. - "- Changed method to determine profession bags by type not ID; should be ok if WoW adds new profession bags. Soul / Ammo / Quivers are included as profession bags (mainly for Classic).\n" - ) - .. TitanUtils_GetGreenText("TitanAmmo : \n") - .. TitanUtils_GetHighlightText("" - .. "- Made a couple routines local rather than global.\n" - ) - .. TitanUtils_GetGreenText("TitanRepair : \n") - .. TitanUtils_GetHighlightText("" - .. "- Added new process for showing repair costs with better formatting.\n" - .. "- Update for localizations for recent changes in TitanRepair.\n" - .. "- Cleanup debug statement; remove commented out code.\n" - ) - .. "\n\n" -end - local function TitanPanel_ScreenAdjustReload() if TitanPanelGetVar("ScreenAdjust") then -- if set then clear it - the screen will adjust @@ -213,9 +109,11 @@ local function TitanPanel_GetEmail() return TitanUtils_GetAddOnMetadata(TITAN_ID, "X-Email") or L["TITAN_PANEL_NA"]; end +--[[ not used local function TitanPanel_GetWebsite() return TitanUtils_GetAddOnMetadata(TITAN_ID, "X-Website") or L["TITAN_PANEL_NA"]; end +--]] local function TitanPanel_GetLicense() return TitanUtils_GetAddOnMetadata(TITAN_ID, "X-License") or L["TITAN_PANEL_NA"]; @@ -234,7 +132,7 @@ OUT: None Titan_AdjustScale() -- Adjust frame positions - TitanPanel_AdjustFrames(TITAN_PANEL_PLACE_BOTH) + TitanPanel_AdjustFrames(true, "TitanAdjustPanelScale") end -- helper functions @@ -354,8 +252,7 @@ local titan_entry = { confversiondesc = { order = 1, type = "description", - name = "" - .. notes, + name = "".. Titan_Global.config_notes, cmdHidden = true }, } @@ -1226,18 +1123,17 @@ OUT: None local function TitanUpdateConfigAddons() local args = optionsAddons.args local plug_in = nil + local plug_category = "" local plug_version = "" + local plug_ldb = "" + local plug_notes = "" wipe(args) for idx, value in pairs(TitanPluginsIndex) do plug_in = TitanUtils_GetPlugin(TitanPluginsIndex[idx]) if plug_in then - if plug_in.version then - plug_version = TitanUtils_GetGreenText(" (" .. plug_in.version .. ")") - else - plug_version = "" - end + local header = (plug_in.menuText or "") args[plug_in.id] = { type = "group", name = ColorVisible(plug_in.id, plug_in.menuText or ""), @@ -1245,7 +1141,7 @@ local function TitanUpdateConfigAddons() args = { name = { type = "header", - name = ((plug_in.menuText or "") .. plug_version), + name = header, order = 1, }, show = { @@ -1422,19 +1318,44 @@ local function TitanUpdateConfigAddons() type = "header", name = L["TITAN_PANEL_MENU_ADV_NOTES_PLUGIN"], } + if plug_in.version then + plug_version = TitanUtils_GetGreenText(" (" .. plug_in.version .. ")") + else + plug_version = "" + end + if plug_in.category then + plug_category = TitanUtils_GetGreenText(" " .. plug_in.category .. "") + else + plug_category = "" + end + if plug_in.notes then + plug_notes = TitanUtils_GetGreenText("" .. plug_in.notes .. "") + else + plug_notes = "" + end + if plug_in.ldb then + plug_ldb = TitanUtils_GetGreenText(" [LDB]") + else + plug_ldb = "" + end + local str = "" + ..plug_version + ..plug_category + .. _G["GREEN_FONT_COLOR_CODE"] .. plug_ldb .. "|r" + .."\n" + .. plug_notes if plug_in.notes then args[plug_in.id].args.notes = { type = "description", order = 61, - name = "" - .. _G["GREEN_FONT_COLOR_CODE"] .. plug_in.notes .. "|r", + name = str, cmdHidden = true, } else args[plug_in.id].args.notes = { type = "description", order = 61, - name = _G["GREEN_FONT_COLOR_CODE"] .. L["TITAN_PANEL_NONE"] .. "|r", + name = str, cmdHidden = true, } end @@ -2220,7 +2141,18 @@ local function Show_Skins(t, position) end) --]] local skin = "Skin" - for idx, v in pairs(TitanSkins) do + t[skin .. position] = { + type = "description", + name = "" + .. L["TITAN_PANEL_MENU_SKIN_CHANGE"].. "\n" + .. "- "..L["TITAN_PANEL_MENU_OPTIONS_BARS"].. "\n" + .. "- "..L["TITAN_PANEL_MENU_OPTIONS_BARS_ALL"].. "\n" + .. "", + cmdHidden = true, + order = position, + } + + for idx, v in pairs(TitanSkins) do position = position + 1 -- spacer t[skin .. position] = { type = "header", @@ -2796,7 +2728,7 @@ local optionsAdvanced = { name = L["TITAN_PANEL_MENU_ADV_OUTPUT"], type = "group", inline = true, - order = 3, + order = 100, args = { confdesc = { order = 110, @@ -2828,6 +2760,42 @@ local optionsAdvanced = { }, }, }, + devoutputdesc = { + name = "Developer Only", + type = "group", + inline = true, + order = 200, + args = { + confdesc = { + order = 110, + type = "description", + name = "Debug Output", + cmdHidden = true + }, + advname = { + name = "Tooltip", + desc = "Tooltip debug output to Chat", + order = 120, + type = "toggle", + width = "full", + get = function() return Titan_Global.debug.tool_tips end, + set = function(_, a) + Titan_Global.debug.tool_tips = not Titan_Global.debug.tool_tips + end, + }, + advplugins = { + name = "Plugin", + desc = "Plugin debug output to Chat", + order = 130, + type = "toggle", + width = "full", + get = function() return Titan_Global.debug.plugin_text end, + set = function(_, a) + Titan_Global.debug.plugin_text = not Titan_Global.debug.plugin_text + end, + }, + }, + }, }, } @@ -2865,7 +2833,7 @@ local changeHistory = { confversiondesc = { order = 1, type = "description", - name = "" .. changes, + name = "" .. Titan_Global.recent_changes, cmdHidden = true }, } @@ -2886,7 +2854,7 @@ local slashHelp = { type = "group", args = { confslash = { - name = (HELP or "Help"), + name = L["TITAN_PANEL_MENU_HELP"], order = 3, type = "group", inline = true, @@ -3059,15 +3027,10 @@ local helpBars = { ------------- ------------- ---[[ Titan -NAME: TitanUpdateConfig -DESC: This routine will handle the requests to update the various data items in Titan options screens. -VAR: None -OUT: None -NOTE: -- This is called after the plugins are registered in the 'player entering world' event. It can be called again as more plugins are registered. -:NOTE ---]] + +---Titan This routine will handle the requests to update the various data items in Titan options screens. +--- This is called after the plugins are registered in the 'player entering world' event. It can be called again as more plugins are registered. +---@param action string "init" or "nuke" function TitanUpdateConfig(action) if action == "init" then -- Update the tables for the latest lists diff --git a/Titan/TitanGame.lua b/Titan/TitanGame.lua index 37ba840..a5b5103 100644 --- a/Titan/TitanGame.lua +++ b/Titan/TitanGame.lua @@ -1,8 +1,7 @@ ---[[ File -NAME: TitanGame.lua -DESC: This file contains the 'game version' Titan or TitanClassic. Used to set up libs, locale, ... -:DESC ---]] +--[===[ File +This file contains the 'game version' - Titan or TitanClassic. +Used to set up libs, locale, ... per the WoW version the user is playing. +--]===] TITAN_ID = "Titan" diff --git a/Titan/TitanGlobal.lua b/Titan/TitanGlobal.lua index 148ec11..6c5595e 100644 --- a/Titan/TitanGlobal.lua +++ b/Titan/TitanGlobal.lua @@ -1,25 +1,35 @@ ---[[ File -NAME: TitanGlobal.lua -DESC: This file contains the global variables and constants used throughout Titan Panel. -:DESC ---]] +--[===[ File +This file contains the global variables and constants used throughout Titan Panel. + +Titan_Global is intended to reduce the global namespace through out Titan over time. +All variables in Global_Titan should be declared here even if set elsewhere. +--]===] ---@meta local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) --- Global variables +-- Global variables + +Titan_Global = {} -- begin the slow journey to a smaller _G footprint -Titan_Global = {} -- begin the slow journey to a smaller _G footprint +Titan_Global.recent_changes = "" -- Titan_History.lua +Titan_Global.config_notes = "" -- Titan_History.lua +Titan_Global.AdjList = { -- TODO : localize + ["UIWidgetTopCenterContainerFrame"] = { + frame_name = "UIWidgetTopCenterContainerFrame", + purpose = "Status for BG / Dungeon", + }, +} TITAN_PANEL_DEBUG_ARRAY_MAX = 100 TITAN_PANEL_NONMOVABLE_PLUGINS = {}; TITAN_PANEL_MENU_FUNC_HIDE = "TitanPanelRightClickMenu_Hide"; -TitanPlugins = {}; -- Used by plugins +TitanPlugins = {}; -- Used by plugins TitanPluginsIndex = {}; -TITAN_NOT_REGISTERED = _G["RED_FONT_COLOR_CODE"].."Not_Registered_Yet".._G["FONT_COLOR_CODE_CLOSE"] -TITAN_REGISTERED = _G["GREEN_FONT_COLOR_CODE"].."Registered".._G["FONT_COLOR_CODE_CLOSE"] -TITAN_REGISTER_FAILED = _G["RED_FONT_COLOR_CODE"].."Failed_to_Register".._G["FONT_COLOR_CODE_CLOSE"] +TITAN_NOT_REGISTERED = _G["RED_FONT_COLOR_CODE"] .. "Not_Registered_Yet" .. _G["FONT_COLOR_CODE_CLOSE"] +TITAN_REGISTERED = _G["GREEN_FONT_COLOR_CODE"] .. "Registered" .. _G["FONT_COLOR_CODE_CLOSE"] +TITAN_REGISTER_FAILED = _G["RED_FONT_COLOR_CODE"] .. "Failed_to_Register" .. _G["FONT_COLOR_CODE_CLOSE"] Titan__InitializedPEW = false Titan__Initialized_Settings = nil @@ -29,9 +39,11 @@ TITAN_AT = "@" TitanAll = nil; TitanSettings = nil; TitanPlayerSettings = nil -TitanPluginSettings = nil; -- Used by plugins +TitanPluginSettings = nil; -- Used by plugins TitanPanelSettings = nil; +Titan_Global.players = "" + TITAN_PANEL_UPDATE_BUTTON = 1; TITAN_PANEL_UPDATE_TOOLTIP = 2; TITAN_PANEL_UPDATE_ALL = 3; @@ -78,7 +90,7 @@ TITAN_PANEL_BACKGROUND_PREFIX = "TitanPanelBackground_" TITAN_PANEL_CLICK_MENU_SUFFIX = "RightClickMenu" TITAN_PANEL_TEXT = "Text" TITAN_PANEL_TEXTURE_VAR = "Texture" -TITAN_PANEL_BUTTON_TEXT = "Button"..TITAN_PANEL_TEXT +TITAN_PANEL_BUTTON_TEXT = "Button" .. TITAN_PANEL_TEXT TITAN_PANEL_CONSTANTS = { FONT_SIZE = 10, FONT_NAME = "Friz Quadrata TT" @@ -93,9 +105,9 @@ TITAN_PROFILE_INIT = "" AUTOHIDE_PREFIX = "TitanPanelAutoHide_" AUTOHIDE_SUFFIX = "Button" ---[[ API +--[===[ Var API Adding Categories to Titan Menu NAME: TITAN_PANEL_BUTTONS_PLUGIN_CATEGORY and TITAN_PANEL_MENU_CATEGORIES -DESC: These two tables hold the list of categories for the Titan menu. +These two tables hold the list of categories for the Titan menu. Logically they are category - text string pairs. Where category is the internal label to be used. Where text is the localized text. @@ -103,15 +115,16 @@ The category should be unique across the table or the menu navigation may be wha Some Titan plugins add to this list to make user navigation easier for their Titan plugins. Add to these lists by using table insert. Example : +Insert the internal name table.insert(TITAN_PANEL_BUTTONS_PLUGIN_CATEGORY, "CAT_ZONES") +Then insert the localized string for the user local categories = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true)["TITAN_PANEL_MENU_CATEGORIES"] table.insert(categories, "Zones") Titan uses AceLocale to simplify using localized strings. -:DESC ---]] +--]===] TITAN_PANEL_BUTTONS_PLUGIN_CATEGORY = - {"Built-ins","General","Combat","Information","Interface","Profession"} +{ "Built-ins", "General", "Combat", "Information", "Interface", "Profession" } ---@diagnostic disable-next-line: assign-type-mismatch L["TITAN_PANEL_MENU_CATEGORIES"] = { L["TITAN_PANEL_MENU_CATEGORIES_01"], @@ -129,10 +142,11 @@ Titan_Global.NONE = "none" -- For debug across Titan Panel Titan_Global.debug = {} -Titan_Global.debug.movable = false Titan_Global.debug.events = false Titan_Global.debug.ldb_setup = false +Titan_Global.debug.menu = false Titan_Global.debug.tool_tips = false +Titan_Global.debug.plugin_text = false Titan_Global.debug.plugin_register = false Titan_Global.debug.plugin_register_deep = false Titan_Global.debug.movable = false @@ -141,7 +155,12 @@ Titan_Global.debug.movable = false Titan_Global.literals = { low = LOW, high = HIGH, - } + yes = YES, + no = NO, + help = HELP_LABEL, + mute = MUTE, + muted = MUTED, +} -- type for plugin registry ---@class PluginRegistryType @@ -160,15 +179,12 @@ Titan_Global.literals = { ---@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 -- for IDE -NAME: Titan_Global.NewRegistry -DESC: Return an empty registry - only the id is set. -This routine is mainly for use with an IDE with Intellisense that supports Lua. -:DESC ---]] +---API Return an empty registry - only the id is set. ---@param id string The unique name of the plugin ----@return PluginRegistryType -Titan_Global.NewRegistry = function(id) - local reg = {id = id} ---@type PluginRegistryType +---@return PluginRegistryType +---This routine was added for use with an IDE with Intellisense that supports Lua. +--- reg = Titan_Global.NewRegistry("MyAddon") +function Titan_Global.NewRegistry(id) + local reg = { id = id } ---@type PluginRegistryType return reg - end +end diff --git a/Titan/TitanHistory.lua b/Titan/TitanHistory.lua new file mode 100644 index 0000000..4f1e237 --- /dev/null +++ b/Titan/TitanHistory.lua @@ -0,0 +1,75 @@ +--[===[ File +This file contains Config 'recent changes' and notes. +It should be updated for each Titan release! + +These are in a seperate file to +1) Increase the chance these strings get updated +2) Decrease the chance of breaking the code :). +--]===] + +--[[ Var Release Notes +Detail changes for last 4 - 5 releases. +Format : +Gold - version & date +Green - 'header' - Titan or plugin +Highlight - notes. tips. and details +--]] +Titan_Global.recent_changes = "" + .. TitanUtils_GetGoldText("8.0.11 : 2024/04/10\n") + .. TitanUtils_GetGreenText("Volume : \n") + .. TitanUtils_GetHighlightText("" + .. "- Double click (left) will mute / unmute. Note: tooltip will flash, not sure how to prevent that.\n" + .. "- Icon should reflect volume % : = 0 | <= 33% | <= 66% | <= 100% .\n" +) + .. TitanUtils_GetGreenText("XP : \n") + .. TitanUtils_GetHighlightText("" + .. "- Do not output time played - can spam Chat.\n" + .. "- /played Use this command instead to see same output.\n" + ) + .. TitanUtils_GetGreenText("Config : \n") + .. TitanUtils_GetHighlightText("" + .. "- Plugins : Add to Notes .\n" + .. "- Skins : Add text to use Bars / Bars - All to change skins.\n" + ) + .. TitanUtils_GetGreenText("Titan : \n") + .. TitanUtils_GetHighlightText("" + .. "- Changed annotations and comments for better documentation.\n" + .. "- Better handling of routines different between retail and Classic API.\n" + .. + "- Deprecated the Titan 'child' template, it has not been used in years. Template and param will be deleted in a future release.\n" + ) + .. "\n\n" + .. TitanUtils_GetGoldText("8.0.10 : 2024/03/14\n") + .. TitanUtils_GetGreenText("Titan : \n") + .. TitanUtils_GetHighlightText("" + .. "- TOC update only : Classic Era to 1.15.2.\n" + ) + .. "\n\n" + .. TitanUtils_GetGoldText("8.0.09 : 2024/03/20\n") + .. TitanUtils_GetGreenText("Titan : \n") + .. TitanUtils_GetHighlightText("" + .. "- TOC update only : Retail to 10.2.6; Classic Era to 1.15.1.\n" + ) + .. "\n\n" + .. TitanUtils_GetGoldText("8.0.8 : 2024/03/08\n") + .. TitanUtils_GetGreenText("Location : \n") + .. TitanUtils_GetHighlightText("" + .. + "- Reverted change to TITAN_PANEL_MENU_CATEGORIES. Removal of this table broke a couple Titan plugins. Sorry about that.\n" + ) + .. "\n\n" + +--[[ Var Notes +Use for important notes in the Titan Config About +--]] +Titan_Global.config_notes = "" + .. TitanUtils_GetGoldText("Notes:\n") + .. TitanUtils_GetHighlightText("" + .. + "- Changing Titan Scaling : Short bars will move on screen. They should not go off screen. If Short bars move then drag to desired location. You may have to Reset the Short bar or temporarily disable top or bottom bars to drag the Short bar.\n" + ) + .. "\n" + .. TitanUtils_GetGoldText("Known Issues:\n") + .. TitanUtils_GetHighlightText("" + .. "- Titan Bag : Opening bags is still an option until taint issue is resolved.\n" + ) diff --git a/Titan/TitanIDE.lua b/Titan/TitanIDE.lua deleted file mode 100644 index 683a7ea..0000000 --- a/Titan/TitanIDE.lua +++ /dev/null @@ -1,189 +0,0 @@ ---[[ IDE - This file is NOT to be included in the TOC file! - This is intended to be used for IDE Intellisense. - - Tools used: - Visual Studio Code - https://code.visualstudio.com/ - Other IDEs accept Lua Language Server, see if your prefered IDE will accept LLS - - Lua Language Server (LLS) - https://marketplace.visualstudio.com/items?itemName=sumneko.lua - https://github.com/LuaLS/lua-language-server - WoW API - LLS extension - https://marketplace.visualstudio.com/items?itemName=ketho.wow-api - https://github.com/Ketho/vscode-wow-api - - This file is to remove errors and warnings thrown by the tools used. - It declares variables and tables : - - That are not readily available to the IDE - - That are declared via indirection as the drop down lib is - - When Lua 'best practice' parser is stricter than Lua is - - When Titan is checking for an addon the user may or may not have loaded - - Titan may contain IDE annotations. - These are ---@ to help the parser understand the intent of the code. - - Some Titan files may contain lines beginning with ----@diagnostic - These remove LLS errors where - - Titan is handling Classic versions that use deprecated routines - - Possibly the WoW extension is out of date or the Blizz documentation is wrong - - Note the diagnostic could be by line, file, or workspace / project. ---]] - ---====== Frames from Titan Template XML -TitanPanelButtonTemplate = {} -TitanPanelChildButtonTemplate = {} -TitanPanelTextTemplate = {} -TitanPanelIconTemplate = {} -TitanPanelComboTemplate = {} -TitanOptionsSliderTemplate = {} -TitanPanelTooltip = {} -TitanPanelBarButtonHiderTemplate = {} -TitanPanelBarButton = {} -Titan_Bar__Display_Template = {} - ---====== Frames from Titan XML -TitanPanelTopAnchor = {} -TitanPanelBottomAnchor = {} - ---====== Frames from Titan plugins created in XML or in Titan code -TitanPanelAmmoButton = {} - -TitanRepairTooltip = {} - -TitanPanelLocationButton = {} -TitanMapPlayerLocation = {} -TitanMapCursorLocation = {} - -TitanPanelLootTypeFrame = {} -TitanPanelLootTypeButton = {} -TitanPanelLootTypeMainWindow = {} -TitanPanelLootTypeFrameClearButton = {} -TitanPanelLootTypeFrameAnnounceButton = {} -TitanPanelLootTypeFrameNotRolledButton = {} -TitanPanelLootTypeFrameRollButton = {} -TitanPanelLootTypeFramePassButton = {} -RollTrackerRollText = {} -TitanPanelLootTypeFrameStatusText = {} -TitanPanelLootTypeFrameHelperButton = {} -TitanPanelLootTypeMainWindowTitle = {} - -TitanPanelPerfControlFrame = {} - -TitanPanelMasterVolumeControlSlider = {} -TitanPanelAmbienceVolumeControlSlider = {} -TitanPanelDialogVolumeControlSlider = {} -TitanPanelSoundVolumeControlSlider = {} -TitanPanelMusicVolumeControlSlider = {} - -TitanPanelXPButton = {} -TitanPanelXPButtonIcon = {} - ---====== Libs that may exist or adjusting for libs -AceLibrary = {} -Tablet20Frame = {} ----@class AceAddon - -AceHook = {} --- @param obj string | function The object or frame to unhook from --- @param method function The name of the method, function or script to unhook from. -function AceHook:IsHooked(obj, method) - -- Ace does a parameter shift if obj is a string - -- But the param does not reflect this... -end - ---====== WoW localized globals -HELP = "" -CHANGE = "" - ---====== WoW frames -PetActionBarFrame = {} -StanceBarFrame = {} -PossessBarFrame = {} -MinimapBorderTop = {} -MinimapZoneTextButton = {} -MiniMapWorldMapButton = {} -VideoOptionsFrame = {} - ----@class FrameSizeBorder - ---====== WoW tables or routines -UIPARENT_MANAGED_FRAME_POSITIONS = {} -FCF_UpdateDockPosition = {} -TargetFrame_Update = {} -VideoOptionsFrameOkay_OnClick = {} - ---====== Convince IDE we know what we are doing --- Lua allows table updates but the IDE complains about 'injecting' a field it does not know about. --- Adding a function or variable to a frame in this case. - --- LDB ----@class Frame ----@field TitanLDBSetOwnerPosition function Anchor tooltip ----@field TitanLDBSetTooltip function Fill tooltip ----@field TitanLDBHandleScripts function Set frame scripts ----@field TitanLDBTextUpdate function Update plugin text ----@field TitanLDBIconUpdate function Update plugin icon ----@field TitanLDBCreateObject function Create plugin ----@field TitanCreatedBy string ----@field TitanType string ----@field TitanName string ----@field TitanAction string ----@field bar_name string ----@field registry table LDB or any plugin - ---====== WoW Drop down menu -UIDROPDOWNMENU_MENU_VALUE = 1 - ----@class LibUIDropDownMenu-4.0 ----@field UIDropDownMenu_InitializeHelper function ----@field Create_UIDropDownMenu function ----@field UIDropDownMenu_Initialize function ----@field UIDropDownMenu_SetInitializeFunction function ----@field UIDropDownMenu_SetDisplayMode function ----@field UIDropDownMenu_RefreshDropDownSize function ----@field UIDropDownMenu_StartCounting function ----@field UIDropDownMenu_StopCounting function ----@field UIDropDownMenu_CreateInfo function ----@field UIDropDownMenu_CreateFrames function ----@field UIDropDownMenu_AddSeparator function ----@field UIDropDownMenu_AddSpace function ----@field UIDropDownMenu_AddButton function ----@field UIDropDownMenu_CheckAddCustomFrame function ----@field UIDropDownMenu_RegisterCustomFrame function ----@field UIDropDownMenu_GetMaxButtonWidth function ----@field UIDropDownMenu_GetButtonWidth function ----@field UIDropDownMenu_Refresh function ----@field UIDropDownMenu_RefreshAll function ----@field UIDropDownMenu_SetIconImage function ----@field UIDropDownMenu_SetSelectedName function ----@field UIDropDownMenu_SetSelectedValue function ----@field UIDropDownMenu_GetSelectedName function ----@field UIDropDownMenu_GetSelectedID function ----@field UIDropDownMenu_SetSelectedID function ----@field UIDropDownMenu_GetSelectedValue function ----@field HideDropDownMenu function ----@field ToggleDropDownMenu function ----@field CloseDropDownMenus function ----@field UIDropDownMenu_SetWidth function ----@field UIDropDownMenu_SetButtonWidth function ----@field UIDropDownMenu_SetText function ----@field UIDropDownMenu_GetText function ----@field UIDropDownMenu_ClearAll function ----@field UIDropDownMenu_JustifyText function ----@field UIDropDownMenu_SetAnchor function ----@field UIDropDownMenu_GetCurrentDropDown function ----@field UIDropDownMenuButton_GetChecked function ----@field UIDropDownMenuButton_GetName function ----@field UIDropDownMenuButton_OpenColorPicker function ----@field UIDropDownMenu_DisableButton function ----@field UIDropDownMenu_EnableButton function ----@field UIDropDownMenu_SetButtonText function ----@field UIDropDownMenu_SetButtonNotClickable function ----@field UIDropDownMenu_SetButtonClickable function ----@field UIDropDownMenu_DisableDropDown function ----@field UIDropDownMenu_EnableDropDown function ----@field UIDropDownMenu_IsEnabled function ----@field UIDropDownMenu_GetValue function ----@field OpenColorPicker function ----@field ColorPicker_GetPreviousValues function diff --git a/Titan/TitanLDB.lua b/Titan/TitanLDB.lua index 1755dd1..76159f6 100644 --- a/Titan/TitanLDB.lua +++ b/Titan/TitanLDB.lua @@ -1,59 +1,71 @@ ---[[ File -NAME: LibDataBrokerToTitan.lua -DESC: A "bridge" module to ensure proper registration and communication of LDB plugins with Titan Panel ---]] ---[[ API -NAME: Titan LDB overview -DESC: Titan will automatically convert a LDB type addon to a Titan plugin. -Only LDB types listed in the LDB 1.1 spec are supported. Custom types are not supported. - -Supported type -- "launcher" become "icon" plugins +--[===[ File +A "bridge" module to ensure proper registration and communication of LDB plugins with Titan Panel + +By Titan Dev team +Originally by Tristanian aka "TristTitan" as a Titan member +Created and initially commited on : July 29th, 2008 +--]===] + +--[===[ Var Titan LDB overview +The spec: https://github.com/tekkub/libdatabroker-1-1 +LDB (libdatabroker) is a small library that enables an addon to hook into a 'display' addon such as Titan. + +=== Creation +The addon dev creates an LDB object which the lib places in storage accessible by lib:DataObjectIterator(). +It also fires a "LibDataBroker_DataObjectCreated" callback. + +LDB objects work by callbacks. +When an LDB addon changes one of its values, the lib fires a callback for the display addon. + +The LDB addon may declare scripts (tooltip, mouse clicks, etc.) per the spec for the display addon to use. + +=== Starting from Titan view +On PLAYER_ENTERING_WORLD, Titan will use the iterator to wrap each LDB type addon into a Titan plugin. +Once done processing the known LDB objects, +Titan registers for the callback to handle LDB objects created later or on demand. + +Titan registers for callbacks on text and icon updates - depending on the LDB type. + +=== Running from Titan view +The LDB addon is responsible for setting and changing its text and icon. +Titan is responsible for updating the Titan plugin in response. + +The Titan plugin will use the LDB addon scripts IF declared, again depending on the LDB type. + + +=== Supported +Only LDB types listed in the LDB 1.1 spec are supported by Titan. + +- "launcher" become "icon" plugins - TitanPanelIconTemplate icon* - always shown - OnClick* - - label^ - + OnClick* - + label^ - right side^ - default tooltip -- "data source" become "combo" plugins with icon; a tooltip/Click; and optional label - icon^ - - OnClick - +- "data source" become "combo" plugins - TitanPanelComboTemplate + icon^ - + OnClick - text*^ - or value & suffix - label^ - - OnEnter - - OnLeave - - tooltip - OnTooltipShow - - -- "macro" become "combo" plugins with icon; a tooltip/Click; and optional label - icon^ - - commandtext^ - - label^ - - OnEnter - - OnLeave - + label^ - + OnEnter - + OnLeave - tooltip OnTooltipShow - * required by LDB spec -^ user controlled show / hide -:DESC ---]] - ---[[ doc ------------------------------------------------------------------ --- By Titan Dev team --- Originally by Tristanian aka "TristTitan" as a Titan member --- Created and initially commited on : July 29th, 2008 ------------------------------------------------------------------ ---]] +^ Titan user controlled show / hide + +--]===] + local xcategories = { --- Titan categories mapping to match addon metadata information + -- Titan categories mapping to match addon metadata information ["Combat"] = "Combat", ["General"] = "General", ["Information"] = "Information", ["Interface"] = "Interface", ["Profession"] = "Profession", --- Ace2 table mapping to Titan categories in order to match --- addon metadata information + -- Ace2 table mapping to Titan categories in order to match + -- addon metadata information ["Action Bars"] = "Interface", ["Auction"] = "Information", ["Audio"] = "Interface", @@ -72,7 +84,7 @@ local xcategories = { ["Healer"] = "Information", ["Tank"] = "Information", ["Caster"] = "Information", --- ["Combat"] = "Combat", + -- ["Combat"] = "Combat", ["Compilations"] = "General", ["Data Export"] = "General", ["Development Tools "] = "General", @@ -92,59 +104,60 @@ local xcategories = { } local LAUNCHER = "launcher" local DATA_SOURCE = "data source" -local SupportedDOTypes = {DATA_SOURCE, LAUNCHER, "macro"} -- in the 1.1 spec +local SupportedDOTypes = { DATA_SOURCE, LAUNCHER } -- in the 1.1 spec +-- "macro" : this was attempted but Blizzard locked most macro to 'user click only'. +-- By adding a Titan template to any secure button, WoW thinks it could be a bot and errors. -- constants & variables local CALLBACK_PREFIX = "LibDataBroker_AttributeChanged_" local _G = getfenv(0); -local InCombatLockdown = _G.InCombatLockdown; +local InCombatLockdown = _G.InCombatLockdown; -- Create control frame so we can get events local LDBToTitan = CreateFrame("Frame", "LDBTitan") local ldb = LibStub:GetLibrary("LibDataBroker-1.1") local Tablet, LibQTip = nil, nil local media = LibStub("LibSharedMedia-3.0") -- generic icon in case the DO does not provide one -local iconTitanDefault = "Interface\\PVPFrame\\PVP-ArenaPoints-Icon"; +local iconTitanDefault = "Interface\\PVPFrame\\PVP-ArenaPoints-Icon"; -- Events we want for LDBToTitan LDBToTitan:RegisterEvent("PLAYER_LOGIN") --LDBToTitan:RegisterEvent("PLAYER_ENTERING_WORLD") +---local OK to show tooltip? +---@return boolean local function If_Show_Tooltip() - local use_mod = TitanAllGetVar("UseTooltipModifer") - local use_alt = TitanAllGetVar("TooltipModiferAlt") - local use_ctrl = TitanAllGetVar("TooltipModiferCtrl") - local use_shift = TitanAllGetVar("TooltipModiferShift") - local ok = false - local tmp_txt = "" - if use_mod then - if (use_alt and IsAltKeyDown()) - or (use_ctrl and IsControlKeyDown()) - or (use_shift and IsShiftKeyDown()) - then - ok = true - end - else - ok = true - end + local use_mod = TitanAllGetVar("UseTooltipModifer") + local use_alt = TitanAllGetVar("TooltipModiferAlt") + local use_ctrl = TitanAllGetVar("TooltipModiferCtrl") + local use_shift = TitanAllGetVar("TooltipModiferShift") + local ok = false + local tmp_txt = "" + if use_mod then + if (use_alt and IsAltKeyDown()) + or (use_ctrl and IsControlKeyDown()) + or (use_shift and IsShiftKeyDown()) + then + ok = true + end + else + ok = true + end return ok end ---[[ Titan -NAME: LDBToTitan:TitanLDBSetOwnerPosition -DESC: Properly anchor tooltips of the Titan (LDB) plugin -VAR: parent -VAR: anchorPoint -VAR: relativeToFrame -VAR: relativePoint -VAR: xOffset -VAR: yOffset -VAR: frame ---]] +---Titan Properly anchor tooltips of the Titan (LDB) plugin +---@param parent table Parent frame +---@param anchorPoint string +---@param relativeToFrame table +---@param relativePoint string +---@param xOffset number +---@param yOffset number +---@param frame table Tolltip frame function LDBToTitan:TitanLDBSetOwnerPosition(parent, anchorPoint, relativeToFrame, relativePoint, xOffset, yOffset, frame) if frame:GetName() == "GameTooltip" then - -- Changes for 9.1.5 Removed the background template from the GameTooltip - -- Making changes to it difficult and possibly changing the tooltip globally. + -- Changes for 9.1.5 Removed the background template from the GameTooltip + -- Making changes to it difficult and possibly changing the tooltip globally. frame:SetOwner(parent, "ANCHOR_NONE"); @@ -161,18 +174,14 @@ function LDBToTitan:TitanLDBSetOwnerPosition(parent, anchorPoint, relativeToFram frame:SetPoint(anchorPoint, relativeToFrame, relativePoint, xOffset, yOffset); end ---[[ Titan -NAME: LDBToTitan:TitanLDBSetTooltip -DESC: Fill in the tooltip for the Titan (LDB) plugin -VAR: name - Titan id of the plugin -VAR: frame - tooltip frame -VAR: func - tooltip function to be run -OUT: None ---]] +---Titan Fill in the tooltip for the Titan (LDB) plugin +---@param name string Plugin id name for LDB +---@param frame table Tooltip frame +---@param func function Tooltip function to be run function LDBToTitan:TitanLDBSetTooltip(name, frame, func) --- Check to see if we allow tooltips to be shown + -- Check to see if we allow tooltips to be shown if not TitanPanelGetVar("ToolTipsShown") - or (TitanPanelGetVar("HideTipsInCombat") and InCombatLockdown()) then + or (TitanPanelGetVar("HideTipsInCombat") and InCombatLockdown()) then return end @@ -180,7 +189,7 @@ function LDBToTitan:TitanLDBSetTooltip(name, frame, func) local scale = TitanPanelGetVar("Scale"); local offscreenX, offscreenY; local i = TitanPanel_GetButtonNumber(name); - local bar = TITAN_PANEL_DISPLAY_PREFIX..TitanUtils_GetWhichBar(name) + local bar = TITAN_PANEL_DISPLAY_PREFIX .. TitanUtils_GetWhichBar(name) local vert = TitanBarData[bar].vert -- Get TOP or BOTTOM for the anchor and relative anchor local rel_pt, pt @@ -191,18 +200,18 @@ function LDBToTitan:TitanLDBSetTooltip(name, frame, func) pt = "BOTTOM" rel_pt = "TOP" end - + if _G[bar] and button then - self:TitanLDBSetOwnerPosition(button, pt.."LEFT", button:GetName(), - rel_pt.."LEFT", -10, 0, frame); -- y 4 * scale + self:TitanLDBSetOwnerPosition(button, pt .. "LEFT", button:GetName(), + rel_pt .. "LEFT", -10, 0, frame); -- y 4 * scale -- Adjust frame position if it's off the screen offscreenX, offscreenY = TitanUtils_GetOffscreen(frame); - if ( offscreenX == -1 ) then - self:TitanLDBSetOwnerPosition(button, pt.."LEFT", bar, - rel_pt.."LEFT", 0, 0, frame); - elseif ( offscreenX == 1 ) then - self:TitanLDBSetOwnerPosition(button, pt.."RIGHT", bar, - rel_pt.."RIGHT", 0, 0, frame); + if (offscreenX == -1) then + self:TitanLDBSetOwnerPosition(button, pt .. "LEFT", bar, + rel_pt .. "LEFT", 0, 0, frame); + elseif (offscreenX == 1) then + self:TitanLDBSetOwnerPosition(button, pt .. "RIGHT", bar, + rel_pt .. "RIGHT", 0, 0, frame); end else end @@ -211,21 +220,16 @@ function LDBToTitan:TitanLDBSetTooltip(name, frame, func) frame:Show(); end ---[[ Titan -NAME: LDBToTitan:TitanLDBHandleScripts -DESC: Script Handler for the Titan (LDB) plugin -VAR: event - event to process -VAR: name - id of the plugin -VAR: _ - not used -VAR: func - function to be run -VAR: obj - LDB object -OUT: None -NOTE: -- This implementation will work fine for a static tooltip but may have implications for dynamic ones so for now, we'll only set it once (no callback) and see what happens -:NOTE ---]] +---Titan Script Handler for the Titan (LDB) plugin +--- This implementation will work fine for a static tooltip but may have implications for dynamic ones so for now, +--- we'll only set it once (no callback) and see what happens +---@param event string Event name +---@param name string Plugin id name for LDB +---@param _ any not used +---@param func function LDB data object +---@param obj table LDB data object function LDBToTitan:TitanLDBHandleScripts(event, name, _, func, obj) - local TitanPluginframe = _G["TitanPanel"..name.."Button"]; + local TitanPluginframe = _G["TitanPanel" .. name .. "Button"]; -- tooltip if event:find("tooltip") and not event:find("OnTooltipShow") then @@ -234,13 +238,13 @@ function LDBToTitan:TitanLDBHandleScripts(event, name, _, func, obj) TitanPluginframe:SetScript("OnEnter", function(self) TitanPanelButton_OnEnter(self); LDBToTitan:TitanLDBSetTooltip(name, pluginframe, nil) - end - ) + end + ) TitanPluginframe:SetScript("OnMouseDown", function(self) pluginframe:Hide(); - end - ) + end + ) if pluginframe:GetScript("OnLeave") then -- do nothing @@ -251,95 +255,95 @@ function LDBToTitan:TitanLDBHandleScripts(event, name, _, func, obj) end pluginframe:Hide(); TitanPanelButton_OnLeave(self); - end - ) + end + ) end - if pluginframe:GetName()~="GameTooltip" then + if pluginframe:GetName() ~= "GameTooltip" then if pluginframe:GetScript("OnShow") then -- do nothing else pluginframe:SetScript("OnShow", function(self) LDBToTitan:TitanLDBSetTooltip(name, pluginframe, nil) - end - ) + end + ) end end end - -- OnTooltipShow + -- OnTooltipShow elseif event:find("OnTooltipShow") then TitanPluginframe:SetScript("OnEnter", function(self) if TITAN_PANEL_MOVING == 0 and func then LDBToTitan:TitanLDBSetTooltip(name, GameTooltip, func); end TitanPanelButton_OnEnter(self); - end - ) + end + ) TitanPluginframe:SetScript("OnLeave", function(self) GameTooltip:Hide(); TitanPanelButton_OnLeave(self); - end - ) + end + ) - -- OnDoubleClick + -- OnDoubleClick elseif event:find("OnDoubleClick") and not event:find("OnClick") then TitanPluginframe:SetScript("OnDoubleClick", function(self, button) if TITAN_PANEL_MOVING == 0 then - func(self, button) - end + func(self, button) end - ) - - -- OnClick + end + ) + + -- OnClick elseif event:find("OnClick") then TitanPluginframe:SetScript("OnClick", function(self, button) if TITAN_PANEL_MOVING == 0 then func(self, button) end - -- implement a safeguard, since the DO may actually use + -- implement a safeguard, since the DO may actually use -- Blizzy dropdowns ! if not TitanPanelRightClickMenu_IsVisible() then TitanPanelButton_OnClick(self, button); else TitanUtils_CloseAllControlFrames(); end - end - ) - -- OnEnter + end + ) + -- OnEnter else TitanPluginframe:SetScript("OnEnter", function(self) - -- Check for tooltip libs without embedding them + -- Check for tooltip libs without embedding them if AceLibrary and AceLibrary:HasInstance("Tablet-2.0") then Tablet = AceLibrary("Tablet-2.0") end LibQTip = LibStub("LibQTip-1.0", true) -- Check to see if we allow tooltips to be shown if not TitanPanelGetVar("ToolTipsShown") - or (TitanPanelGetVar("HideTipsInCombat") and InCombatLockdown()) then + or (TitanPanelGetVar("HideTipsInCombat") and InCombatLockdown()) then -- if a plugin is using tablet, then detach and close the tooltip if Tablet and Tablet:IsRegistered(TitanPluginframe) - and Tablet:IsAttached(TitanPluginframe) then + and Tablet:IsAttached(TitanPluginframe) then Tablet:Detach(TitanPluginframe); Tablet:Close(TitanPluginframe); end return; else - -- if a plugin is using tablet, then re-attach the tooltip + -- if a plugin is using tablet, then re-attach the tooltip -- (it will auto-open on mouseover) if Tablet and Tablet:IsRegistered(TitanPluginframe) - and not Tablet:IsAttached(TitanPluginframe) then + and not Tablet:IsAttached(TitanPluginframe) then Tablet:Attach(TitanPluginframe); end end - -- if a plugin is using tablet then set its transparency + -- if a plugin is using tablet then set its transparency -- and font size accordingly if Tablet and Tablet:IsRegistered(TitanPluginframe) then Tablet:SetTransparency(TitanPluginframe, TitanPanelGetVar("TooltipTrans")) if not TitanPanelGetVar("DisableTooltipFont") then Tablet:SetFontSizePercent(TitanPluginframe, TitanPanelGetVar("TooltipFont")) elseif TitanPanelGetVar("DisableTooltipFont") - and Tablet:GetFontSizePercent(TitanPluginframe)~=1 then + and Tablet:GetFontSizePercent(TitanPluginframe) ~= 1 then Tablet:SetFontSizePercent(TitanPluginframe, 1) end end @@ -360,8 +364,8 @@ function LDBToTitan:TitanLDBHandleScripts(event, name, _, func, obj) for key, tip in LibQTip:IterateTooltips() do if tip then local _, relativeTo = tip:GetPoint() - if relativeTo - and relativeTo:GetName() == TitanPluginframe:GetName() then + if relativeTo + and relativeTo:GetName() == TitanPluginframe:GetName() then tt = tip break end @@ -371,39 +375,34 @@ function LDBToTitan:TitanLDBHandleScripts(event, name, _, func, obj) -- set transparency local red, green, blue, _ = tt:GetBackdropColor() local red2, green2, blue2, _ = tt:GetBackdropBorderColor() - tt:SetBackdropColor(red,green,blue, + tt:SetBackdropColor(red, green, blue, TitanPanelGetVar("TooltipTrans")) - tt:SetBackdropBorderColor(red2,green2,blue2, + tt:SetBackdropBorderColor(red2, green2, blue2, TitanPanelGetVar("TooltipTrans")) end end -- /LibQTip-1.0 support code - end - ) - - -- OnLeave + end + ) + + -- OnLeave TitanPluginframe:SetScript("OnLeave", function(self) if obj.OnLeave then obj.OnLeave(self) end TitanPanelButton_OnLeave(self); - end - ) + end + ) end end ---[[ Titan -NAME: LDBToTitan:TitanLDBTextUpdate -DESC: Text callback for the Titan (LDB) plugin when the LDB addon changes display text of the LDB object -VAR: _ - not used -VAR: name - id of the plugin -VAR: event - event to process -VAR: attr - LDB obj attribute (field) that changed -VAR: value - new value of attr -VAR: dataobj - LDB object -OUT: None ---]] -function LDBToTitan:TitanLDBTextUpdate(_, name, attr, value, dataobj) +---Titan Text callback for the Titan (LDB) plugin when the LDB addon changes display text of the LDB object +---@param _ any not used +---@param name string Plugin id name for LDB +---@param attr string "value" or "suffix" or "text" or "label" +---@param value any Should be string +---@param dataobj table LDB data object +function LDBToTitan:TitanLDBTextUpdate(_, name, attr, value, dataobj) -- just in case the LDB is active before Titan can register it... if not Titan__InitializedPEW then -- plugins have not been registered yet. @@ -422,22 +421,19 @@ function LDBToTitan:TitanLDBTextUpdate(_, name, attr, value, dataobj) if attr == "suffix" then ldb.suffix = value end if attr == "text" then ldb.text = value end if attr == "label" then ldb.label = value end - + -- Now update the button with the change TitanPanelButton_UpdateButton(name) end ---[[ Titan -NAME: TitanLDBShowText -DESC: Text callback for the Titan (LDB) plugin when the LDB addon changes display text -VAR: name - id of the plugin -OUT: label of text to show -OUT: text to show ---]] +---Titan Text callback when the LDB addon changes display text +---@param name string Plugin id name for LDB +---@return string label +---@return string value function TitanLDBShowText(name) -- Set 'label1' and 'value1' for the Titan button display - local nametrim = string.gsub (name, "LDBT_", ""); - local fontstring = _G[TitanUtils_ButtonName(nametrim)..TITAN_PANEL_TEXT]; + local nametrim = string.gsub(name, "LDBT_", ""); + local fontstring = _G[TitanUtils_ButtonName(nametrim) .. TITAN_PANEL_TEXT]; local separator = ": " local lab1, val1 = "", "" local plugin = TitanUtils_GetPlugin(name) @@ -454,7 +450,7 @@ function TitanLDBShowText(name) if lab1 == "" then -- leave alone else - lab1 = lab1..separator + lab1 = lab1 .. separator end -- Check for display text @@ -485,17 +481,13 @@ function TitanLDBShowText(name) return lab1, val1 end ---[[ Titan -NAME: LDBToTitan:TitanLDBTextUpdate -DESC: Icon callback for the Titan (LDB) plugin when the LDB addon changes the icon of the LDB object -VAR: _ - not used -VAR: name - id of the plugin -VAR: attr - LDB obj attribute (field) that changed -VAR: value - new value of attr -VAR: dataobj - LDB object -OUT: None ---]] -function LDBToTitan:TitanLDBIconUpdate(_, name, attr, value, dataobj) +---Titan Icon callback for the Titan (LDB) plugin when the LDB addon changes the icon of the LDB object +---@param _ any not used +---@param name string Plugin id name for LDB +---@param attr string "icon" or "iconCoords" or "iconR" "iconB" "iconR" +---@param value any icon : Path to icon file; iconCoords : coords +---@param dataobj table LDB data object +function LDBToTitan:TitanLDBIconUpdate(_, name, attr, value, dataobj) -- just in case the LDB is active before Titan can register it... if not Titan__InitializedPEW then -- no plugins are registered yet @@ -504,80 +496,67 @@ function LDBToTitan:TitanLDBIconUpdate(_, name, attr, value, dataobj) -- This check is overkill but just in case... local plugin = TitanUtils_GetPlugin(name) local ldb = plugin and plugin.LDBVariables - if not ldb then + if ldb then + if attr == "icon" then + TitanPlugins[name].icon = value; + TitanPanelButton_SetButtonIcon(name); + end + + -- support for iconCoords, iconR, iconG, iconB attributes + if attr == "iconCoords" then + TitanPanelButton_SetButtonIcon(name, value); + end + + if attr == "iconR" or attr == "iconB" or attr == "iconG" then + TitanPanelButton_SetButtonIcon(name, nil, + dataobj.iconR, dataobj.iconG, dataobj.iconB); + end + else -- This plugin is not registered yet return end - - if attr == "icon" then - TitanPlugins[name].icon = value; - TitanPanelButton_SetButtonIcon(name); - end - - -- support for iconCoords, iconR, iconG, iconB attributes - if attr == "iconCoords" then - TitanPanelButton_SetButtonIcon(name, value); - end - - if attr == "iconR" or attr == "iconB" or attr == "iconG" then - TitanPanelButton_SetButtonIcon(name, nil, - dataobj.iconR, dataobj.iconG, dataobj.iconB); - end end ---[[ Titan -NAME: TitanLDBRefreshButton -DESC: Refresh all text & icon for LDB addons that were successfully registered -VAR: None -OUT: None -NOTE: -- Ensure all the LDB buttons are updated. -- This is called once x seconds after PEW. This helps close the gap where LDB addons set their text on their PEW event -:NOTE ---]] +---Titan Refresh all text & icon for LDB addons that were successfully registered +--- Ensure all the LDB buttons are updated. +--- This is called once x seconds after PEW. This helps close the gap where LDB addons set their text on their PEW event function TitanLDBRefreshButton() --- TitanDebug("LDB: RefreshButton") + -- TitanDebug("LDB: RefreshButton") for name, obj in ldb:DataObjectIterator() do if obj then local unused = nil LDBToTitan:TitanLDBTextUpdate(unused, name, "text", (obj.text or ""), obj) LDBToTitan:TitanLDBIconUpdate(unused, name, "icon", (obj.icon or iconTitanDefault), obj) else --- TitanDebug("LDB: '"..name.."' no refresh") + -- TitanDebug("LDB: '"..name.."' no refresh") end end end ---[[ Titan -NAME: LDBToTitan:TitanLDBCreateObject -DESC: New DO (Data Object) gets created here -VAR: _ - not used -VAR: name - id of the plugin -VAR: obj - LDB object -OUT: None -NOTE: -- This is the heart of the LDB to Titan. It reads the LDB DO (Data Object)and creates a Titan plugin. -- This takes a stricter interpretation of the LDB 1.1 spec rather than guessing what LDB addon developers intended. -:NOTE ---]] +---Titan Create a Titan plugin from the DO (Data Object) +--- This is the heart of the LDB to Titan. It reads the LDB DO (Data Object) and creates a Titan plugin. +--- This takes a stricter interpretation of the LDB 1.1 spec rather than guessing what LDB addon developers intended. +---@param self table LDB frame +---@param name_str string LDB id name +---@param obj table LDB data object function TitanLDBCreateObject(self, name_str, obj) local name = name_str - if Titan_Global.debug.ldb_setup then - TitanDebug(tostring(name).." : Attempting to register "); + if Titan_Global.debug.ldb_setup then + TitanDebug(tostring(name) .. " : Attempting to register "); end - + -- couple sanity checks --- if not obj or not name then + -- if not obj or not name then if name and type(name) == 'string' then -- The name should be reasonable else local issue = "LDB request name " - .." '"..tostring(name).."'" - .." unrecognizable !!!!" + .. " '" .. tostring(name) .. "'" + .. " unrecognizable !!!!" if Titan_Global.debug.ldb_setup then TitanDebug(issue); end - error (issue) -- get out + error(issue) -- get out end if obj and type(obj) == 'table' then -- The LDB obj should be reasonable @@ -589,18 +568,18 @@ function TitanLDBCreateObject(self, name_str, obj) object = "does not exist" end local issue = "LDB request object for " - .." '"..tostring(name).."'" - .." "..tostring(object).."" - .." !!!!" + .. " '" .. tostring(name) .. "'" + .. " " .. tostring(object) .. "" + .. " !!!!" if Titan_Global.debug.ldb_setup then TitanDebug(issue); end - error (issue) -- get out + error(issue) -- get out end - + -- anything to pass to the developer / user local notes = "" - + -- sanity check for supported types obj.type = obj.type or "Unknown" local supported = false -- assume failure @@ -614,12 +593,12 @@ function TitanLDBCreateObject(self, name_str, obj) else -- Create enough of a plugin to tell the user / developer -- that this plugin failed miserably - local issue = "Unsupported LDB type '"..tostring(obj.type).."'" + local issue = "Unsupported LDB type '" .. tostring(obj.type) .. "'" if Titan_Global.debug.ldb_setup then - TitanDebug(TITAN_REGISTER_FAILED.." "..issue); + TitanDebug(TITAN_REGISTER_FAILED .. " " .. issue); end - error (issue) --- return TITAN_REGISTER_FAILED -- get out, there is nothing more that can be done + error(issue) + -- return TITAN_REGISTER_FAILED -- get out, there is nothing more that can be done end -- @@ -634,71 +613,71 @@ function TitanLDBCreateObject(self, name_str, obj) -- if .icon exists honor it and assume the addon may change it if obj.icon then - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_icon", "TitanLDBIconUpdate") + ldb.RegisterCallback(self, + CALLBACK_PREFIX .. name .. "_icon", "TitanLDBIconUpdate") end - + -- LAUNCHER text display elements if obj.type == LAUNCHER then if obj.label then - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_label", "TitanLDBTextUpdate") + ldb.RegisterCallback(self, + CALLBACK_PREFIX .. name .. "_label", "TitanLDBTextUpdate") elseif obj.text then -- This is a 'be nice' check. It technically violates the 1.1 spec. -- Blank the .text so the rest of the routines work ldb__label = obj.text obj.text = "" - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_text", "TitanLDBTextUpdate") - notes = notes.."\n" - .."This is a LDB '"..LAUNCHER - .."' without .label using .text instead!!!!" + ldb.RegisterCallback(self, + CALLBACK_PREFIX .. name .. "_text", "TitanLDBTextUpdate") + notes = notes .. "\n" + .. "This is a LDB '" .. LAUNCHER + .. "' without .label using .text instead!!!!" end end if Titan__InitializedPEW then - notes = notes.."\n" - .."Will be registered as single LDB plugin after the normal registration." + notes = notes .. "\n" + .. "Will be registered as single LDB plugin after the normal registration." end -- DATA_SOURCE text display elements if obj.type == DATA_SOURCE then -- .text so always allow it - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_text", "TitanLDBTextUpdate") + ldb.RegisterCallback(self, + CALLBACK_PREFIX .. name .. "_text", "TitanLDBTextUpdate") if obj.label then - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_label", "TitanLDBTextUpdate") + ldb.RegisterCallback(self, + CALLBACK_PREFIX .. name .. "_label", "TitanLDBTextUpdate") end if obj.suffix then - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_suffix", "TitanLDBTextUpdate") + ldb.RegisterCallback(self, + CALLBACK_PREFIX .. name .. "_suffix", "TitanLDBTextUpdate") end if obj.value then - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_value", "TitanLDBTextUpdate") + ldb.RegisterCallback(self, + CALLBACK_PREFIX .. name .. "_value", "TitanLDBTextUpdate") end end - + -- -- These are icon extensions listed within the 1.1 spec -- -- support for iconCoords, iconR, iconG, iconB attributes - -- Due to the callbacks being fired these can easily affect + -- Due to the callbacks being fired these can easily affect -- performance, BEWARE when using them ! -- -- capture the icon coords & color for the Titan plugin if obj.iconCoords then self:TitanLDBIconUpdate(nil, name, "iconCoords", obj.iconCoords, obj) - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_iconCoords", "TitanLDBIconUpdate") + ldb.RegisterCallback(self, + CALLBACK_PREFIX .. name .. "_iconCoords", "TitanLDBIconUpdate") end if obj.iconR and obj.iconG and obj.iconB then self:TitanLDBIconUpdate(nil, name, "iconR", obj.iconR, obj) - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_iconR", "TitanLDBIconUpdate") - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_iconG", "TitanLDBIconUpdate") - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_iconB", "TitanLDBIconUpdate") + ldb.RegisterCallback(self, + CALLBACK_PREFIX .. name .. "_iconR", "TitanLDBIconUpdate") + ldb.RegisterCallback(self, + CALLBACK_PREFIX .. name .. "_iconG", "TitanLDBIconUpdate") + ldb.RegisterCallback(self, + CALLBACK_PREFIX .. name .. "_iconB", "TitanLDBIconUpdate") end -- @@ -710,8 +689,8 @@ function TitanLDBCreateObject(self, name_str, obj) id = name, ldb = tostring(obj.type), -- per 1.1 spec if .label exists use it else use data object's name - menuText = obj.label or name, - buttonTextFunction = "TitanLDBShowText", + menuText = obj.label or name, + buttonTextFunction = "TitanLDBShowText", icon = ldb__icon, iconWidth = 16, controlVariables = { @@ -745,38 +724,38 @@ function TitanLDBCreateObject(self, name_str, obj) if Titan_Global.debug.ldb_setup then TitanDebug("" - .." type: '"..tostring(registry.ldb).."' " + .. " type: '" .. tostring(registry.ldb) .. "' " ) end -- Set the plugin category, if it exists, else default to "General" - -- Per the 1.1 LDB spec we check for a tocname attrib first, - -- if found we use it, if not we assume that the DO "name" + -- Per the 1.1 LDB spec we check for a tocname attrib first, + -- if found we use it, if not we assume that the DO "name" -- attribute is the same as the actual -- addon name, which might not always be the case. -- Titan defaults again to "General" if no categoy is found -- via a check in the menu implementation, later on. local addoncategory, addonversion; local tempname = obj.tocname or name; - - -- This was a sanity check but does not allow for multiple + + -- This was a sanity check but does not allow for multiple -- LDB to be within an addon yet act as their own addon. --- if IsAddOnLoaded(tempname) then - addoncategory = TitanUtils_GetAddOnMetadata(tempname, "X-Category"); - registry["category"]= (addoncategory and xcategories[addoncategory]) - or (obj.category) - or nil - addonversion = TitanUtils_GetAddOnMetadata(tempname, "Version") - or (obj.version) - or "" - registry["version"]= addonversion; - registry["notes"]= (TitanUtils_GetAddOnMetadata(tempname, "Notes") or "").."\n" --- end + -- if IsAddOnLoaded(tempname) then + addoncategory = TitanUtils_GetAddOnMetadata(tempname, "X-Category"); + registry.category = (addoncategory and xcategories[addoncategory]) + or (obj.category) + or "General" + addonversion = TitanUtils_GetAddOnMetadata(tempname, "Version") + or (obj.version) + or "" + registry["version"] = addonversion; + registry["notes"] = (TitanUtils_GetAddOnMetadata(tempname, "Notes") or "") .. "\n" + -- end -- Depending on the LDB type set the control and saved Variables appropriately if obj.type == LAUNCHER then -- controls - -- one interpretation of the LDB spec is launchers + -- one interpretation of the LDB spec is launchers -- should always have an icon. registry["controlVariables"].ShowIcon = true; registry["controlVariables"].ShowRegularText = false; -- no text @@ -784,37 +763,33 @@ function TitanLDBCreateObject(self, name_str, obj) registry["savedVariables"].ShowRegularText = false; registry["savedVariables"].DisplayOnRightSide = true; -- start on right side end - + if obj.type == DATA_SOURCE then -- controls registry["controlVariables"].ShowRegularText = true; -- defaults registry["savedVariables"].ShowRegularText = true; end - + -- -- Create the Titan frame for this LDB addon -- Titan _OnLoad will be used to request the plugin be registered by Titan (Template) local newTitanFrame -- a frame + --[===[ if obj.type == "macro" then -- custom newTitanFrame = CreateFrame("Button", - TitanUtils_ButtonName(name), - UIParent, "TitanPanelComboTemplate") --- UIParent, "SecureActionButtonTemplate, TitanPanelComboTemplate") + TitanUtils_ButtonName(name), + UIParent, "SecureActionButtonTemplate, TitanPanelComboTemplate") +-- UIParent, "TitanPanelComboTemplate") newTitanFrame:RegisterForClicks("AnyUp", "AnyDown") newTitanFrame:SetMouseClickEnabled(true) newTitanFrame:SetAttribute("type", "macro") -- newTitanFrame:SetAttribute("macro", obj.commandtext) newTitanFrame:SetAttribute("macrotext", obj.commandtext) - newTitanFrame:SetScript("OnClick", function(self, button, down) + newTitanFrame:SetScript("OnClick", function(self, button, down) SecureUnitButton_OnClick(self, button, down) - --TitanPanelBarButton_OnClick(self, button) + --TitanPanelBarButton_OnClick(self, button) end) ---[[ -print("LDB macrotext" -.." "..tostring(obj.commandtext).."" -) ---]] if Titan_Global.debug.ldb_setup then TitanDebug("" .." macrotext cmd: '"..tostring(obj.commandtext).."' " @@ -822,12 +797,16 @@ print("LDB macrotext" end else newTitanFrame = CreateFrame("Button", - TitanUtils_ButtonName(name), + TitanUtils_ButtonName(name), UIParent, "TitanPanelComboTemplate") end +--]===] + newTitanFrame = CreateFrame("Button", + TitanUtils_ButtonName(name), + UIParent, "TitanPanelComboTemplate") newTitanFrame.TitanCreatedBy = "LDB" - newTitanFrame.TitanType = "macro" + -- newTitanFrame.TitanType = "macro" newTitanFrame.TitanName = (name or "?") newTitanFrame.TitanAction = (obj.commandtext or "None") @@ -836,8 +815,8 @@ print("LDB macrotext" newTitanFrame:SetToplevel(true); newTitanFrame:RegisterForClicks("LeftButtonUp", "RightButtonUp"); - -- Use the routines given by the DO in this precedence - -- tooltip > OnEnter > OnTooltipShow > + -- Use the routines given by the DO in this precedence + -- tooltip > OnEnter > OnTooltipShow > -- or register a callback in case it is created later. Per the 1.1 LDB spec if obj.tooltip then self:TitanLDBHandleScripts("tooltip", name, nil, obj.tooltip, obj) @@ -847,32 +826,32 @@ print("LDB macrotext" self:TitanLDBHandleScripts("OnTooltipShow", name, nil, obj.OnTooltipShow, obj) else self:TitanLDBHandleScripts("OnEnter", name, nil, nil, obj) - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_OnEnter", "TitanLDBHandleScripts") - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_OnTooltipShow", "TitanLDBHandleScripts") + ldb.RegisterCallback(self, + CALLBACK_PREFIX .. name .. "_OnEnter", "TitanLDBHandleScripts") + ldb.RegisterCallback(self, + CALLBACK_PREFIX .. name .. "_OnTooltipShow", "TitanLDBHandleScripts") end - -- Use the OnClick given by the DO + -- Use the OnClick given by the DO -- or register a callback in case it is created later. if obj.OnClick then self:TitanLDBHandleScripts("OnClick", name, nil, obj.OnClick) else - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_OnClick", "TitanLDBHandleScripts") + ldb.RegisterCallback(self, + CALLBACK_PREFIX .. name .. "_OnClick", "TitanLDBHandleScripts") end -- - -- OnDoubleClick is UNDOCUMENTED in the 1.1 spec + -- OnDoubleClick is UNDOCUMENTED in the 1.1 spec -- but was implemented by the original developer -- - -- Use the OnDoubleClick given by the DO + -- Use the OnDoubleClick given by the DO -- or register a callback in case it is created later. if obj.OnDoubleClick then self:TitanLDBHandleScripts("OnDoubleClick", name, nil, obj.OnDoubleClick) else - ldb.RegisterCallback(self, - CALLBACK_PREFIX..name.."_OnDoubleClick", "TitanLDBHandleScripts") + ldb.RegisterCallback(self, + CALLBACK_PREFIX .. name .. "_OnDoubleClick", "TitanLDBHandleScripts") end local pew = "event" @@ -887,74 +866,62 @@ print("LDB macrotext" end if Titan_Global.debug.ldb_setup then TitanDebug("LDB create" - .." "..tostring(pew).."" - .." '"..tostring(registry.id).."'" - .." '"..tostring(registry.ldb).."'" - .."\n...'"..tostring(newTitanFrame:GetName()).."'" + .. " " .. tostring(pew) .. "" + .. " '" .. tostring(registry.id) .. "'" + .. " '" .. tostring(registry.ldb) .. "'" + .. "\n...'" .. tostring(newTitanFrame:GetName()) .. "'" ) end return "Success" end ---[[ Titan -NAME: LDBToTitan:SetScript -DESC: OnEvent handler for LDBToTitan -VAR: event - string -VAR: function -OUT: None -NOTE: -- PLAYER_LOGIN - Read through all the LDB objects requesting creation so far. Try to create cooresponding Titan plugins. -:NOTE ---]] ---function LDBToTitan:TitanLDBCreateObject(name, obj) +---Titan OnEvent handler for LDBToTitan +--- Read through all the LDB objects requesting creation so far. Try to create cooresponding Titan plugins. +---@param sender any !! Not Used !! +---@param name string LDB id name +---@param obj table LDB data object function LDBToTitan:TitanLDBCreateObject(sender, name, obj) local call_success = true local ret_val = "" - + call_success, -- needed for pcall ret_val = -- actual return values - pcall (TitanLDBCreateObject, self, name, obj) - + pcall(TitanLDBCreateObject, self, name, obj) + if call_success then -- Registration request created else -- Create enough of a plugin to tell the user / developer - -- that this plugin failed - local plugin = - { + -- that this plugin failed + local plugin = + { self = nil, button = nil, isChild = nil, name = tostring(name), issue = ret_val, - notes = "", + notes = "", status = TITAN_REGISTER_FAILED, category = "", plugin_type = tostring(obj.type or "LDB"), - } + } TitanUtils_PluginFail(plugin) end if Titan_Global.debug.ldb_setup then TitanDebug("LDB Create:" --- .." "..tostring(sender).."" - .." "..tostring(name).."" - .." "..tostring(call_success).."" - .." "..tostring(ret_val).."" - ) + -- .." "..tostring(sender).."" + .. " " .. tostring(name) .. "" + .. " " .. tostring(call_success) .. "" + .. " " .. tostring(ret_val) .. "" + ) end end ---[[ Titan -NAME: LDBToTitan:SetScript -DESC: OnEvent handler for LDBToTitan -VAR: event - string -VAR: function -OUT: None -NOTE: -- PLAYER_LOGIN - Read through all the LDB object created so far and create cooresponding Titan plugins. -:NOTE ---]] +--- OnEvent - PLAYER_LOGIN - handler for LDBToTitan +---@param self table Plugin frame +---@param event string Event name +---@param ... any Event args LDBToTitan:SetScript("OnEvent", function(self, event, ...) if (event == "PLAYER_LOGIN") then self:UnregisterEvent("PLAYER_LOGIN") @@ -962,44 +929,44 @@ LDBToTitan:SetScript("OnEvent", function(self, event, ...) for name, obj in ldb:DataObjectIterator() do local call_success = true local ret_val = "" - + -- Just in case, catch any errors call_success, -- needed for pcall - ret_val = -- actual return values - pcall (TitanLDBCreateObject, self, name, obj) - + ret_val = -- actual return values + pcall(TitanLDBCreateObject, self, name, obj) + if call_success then -- Registration request created else -- Create enough of a plugin to tell the user / developer - -- that this plugin failed - local plugin = - { + -- that this plugin failed + local plugin = + { self = nil, button = nil, isChild = nil, name = tostring(name), issue = ret_val, - notes = "", + notes = "", status = TITAN_REGISTER_FAILED, category = "", plugin_type = tostring(obj.type or "LDB"), - } + } TitanUtils_PluginFail(plugin) end if Titan_Global.debug.ldb_setup then TitanDebug("LDB" - .." "..tostring(name).."" - .." "..tostring(call_success).."" - .." "..tostring(ret_val).."" - ) + .. " " .. tostring(name) .. "" + .. " " .. tostring(call_success) .. "" + .. " " .. tostring(ret_val) .. "" + ) end end -- In case a LDB plugin is created later... - ldb.RegisterCallback(self, + ldb.RegisterCallback(self, "LibDataBroker_DataObjectCreated", "TitanLDBCreateObject") end end -) \ No newline at end of file +) diff --git a/Titan/TitanMovable.lua b/Titan/TitanMovable.lua index db28d41..8e14a32 100755 --- a/Titan/TitanMovable.lua +++ b/Titan/TitanMovable.lua @@ -1,15 +1,15 @@ ---@diagnostic disable: param-type-mismatch ---[[ File -NAME: TitanMovable.lua -DESC: DragonFlight introduced an Edit Mode for the user to move various frames where they want them. +--[===[ File +Titan adjusts some WoW frames based on the WoW version! +Mainly used for Classic versions where TITAN_ID == "TitanClassic" + +DragonFlight introduced an Edit Mode for the user to move various frames where they want them. Titan no longer needs to do this work for most frames. There are a small number of frames that WoW does not have in Edit mode. These will be added to the table over time as users request. The scheme has changed to be more like 'move any/thing' which hooks the SetPoint of the frame. Titan still only allows vertical adjust - not move anywhere. -:DESC - ---]] +--]===] -- Globals -- Locals @@ -17,20 +17,12 @@ local _G = getfenv(0); local InCombatLockdown = _G.InCombatLockdown; local AceHook = LibStub("AceHook-3.0") - ---[[ API -NAME: TitanMovable_GetPanelYOffset -DESC: Get the Y axis offset Titan needs (1 or 2 bars) at the given position - top or bottom. -VAR: framePosition - TITAN_PANEL_PLACE_TOP or TITAN_PANEL_PLACE_BOTTOM -OUT: Y axis offset, in pixels -NOTE: -- As of DragonFlight this may not be as useful. Leaving to not break any addons. - -- The preferred method to determine the Y offset needed to use TitanUtils_GetBarAnchors() -which provides anchors (frames) for an addon to use. -:NOTE ---]] -function TitanMovable_GetPanelYOffset(framePosition) -- used by other addons +---API Classic : Get the Y axis offset Titan needs (1 or 2 bars) at the given position - top or bottom. +---The preferred method to determine the Y offset needed to use TitanUtils_GetBarAnchors() which provides anchors (frames) for an addon to use. +---@param framePosition number TITAN_PANEL_PLACE_TOP(1) / _BOTTOM(2) +---@return number offset In pixels * Titan scale +function TitanMovable_GetPanelYOffset(framePosition) + -- used by other addons -- Both top & bottom are figured out but only the -- requested position is returned local barnum_top = 0 @@ -49,7 +41,7 @@ function TitanMovable_GetPanelYOffset(framePosition) -- used by other addons -- if TitanPanelGetVar("AuxBar_Show") then barnum_bot = 1 end - + if TitanBarDataVars[TITAN_PANEL_DISPLAY_PREFIX.."AuxBar2"].show then -- if TitanPanelGetVar("AuxBar2_Show") then barnum_bot = 2 @@ -70,12 +62,10 @@ function TitanMovable_GetPanelYOffset(framePosition) -- used by other addons return 0 end ---[[ Titan -NAME: TitanPanel_AdjustFrameInit -DESC: Do all the setup needed when a user logs in / reload UI / enter or leave an instance or when user updates adjust flag. -VAR: frame_str : string of the frame name -OUT: None -NOTE: +---Titan Do all the setup needed when a user logs in / reload UI / enter or leave an instance or when user updates adjust flag. +--- See routine comments for more details. +function TitanPanel_AdjustFrameInit(frame_str) +--[[ - This is called once the profile (and settings) are known. - Keeping this simple for now until omplexity needs to be added. - hooksecurefunc from https://urbad.net/blue/us/34224257-Guide_to_Secure_Execution_and_Tainting @@ -90,9 +80,7 @@ The 'special' feature of this secure hook is that when your hook function is exe - hooksecurefunc from https://wowpedia.fandom.com/wiki/API_hooksecurefunc. - The hook will stay until a reload or logout. This means the TitanAdj MUST remain or the normal SetPoint will be broken. - Setting the hook is cumalitive so add ony once; controlled by titan_adj_hook on the frame. -:NOTE --]] -function TitanPanel_AdjustFrameInit(frame_str) -- local op = "" local frame = _G[frame_str] if frame then -- sanity check @@ -114,7 +102,7 @@ print("TitanAdj ~~" end end end - + if frame.titan_adj_hook == true then -- already hooked, do not want to add more... else @@ -130,11 +118,11 @@ print("TitanAdj ~~" frame.titan_adjusting = false end end) - + frame.titan_adj_hook = true op = "set secure hook" end - + TitanPanel_AdjustFrame(frame_str, "Init adjust") else op = "skip - frame invalid" @@ -142,17 +130,11 @@ print("TitanAdj ~~" end end ---[[ Titan -NAME: TitanPanel_AdjustFrame -DESC: Adjust frame as requested. -VAR: frame_str : string of the frame name -VAR: reason : string for debug -OUT: None -NOTE: -- This is called when usesrs has changed the adjust flag and on Titan init. -:NOTE ---]] -function TitanPanel_AdjustFrame(frame_str, reason) -- +---Titan Adjust frame as requested. +--- This is called when usesrs has changed the adjust flag and on Titan init. +---@param frame_str string Frame name +---@param reason string Debug to know where the call came from +function TitanPanel_AdjustFrame(frame_str, reason) local trace = false local op = "no action" local frame = _G[frame_str] @@ -177,7 +159,7 @@ function TitanPanel_AdjustFrame(frame_str, reason) -- frame:TitanAdj() op = "adjust - titan_adj to true" end - + if frame.titan_offset == TitanAdjustSettings[frame_str].offset then -- No need to update else @@ -234,7 +216,7 @@ if TITAN_ID == "TitanClassic" then local hooks_done = false; local move_count = 0 ---[[ Titan +--[[ Declare the Ace routines local AceTimer = LibStub("AceTimer-3.0") i.e. TitanPanelAce.ScheduleTimer("LDBToTitanSetText", TitanLDBRefreshButton, 2); @@ -243,6 +225,7 @@ Declare the Ace routines Be careful that the 'self' is proper to cancel timers!!! --]] + --local TitanPanelAce = LibStub("AceAddon-3.0"):NewAddon("TitanPanel", "AceHook-3.0", "AceTimer-3.0") --Determines the optimal magic number based on resolution @@ -278,7 +261,7 @@ local function DoAdjust(place, force) local res = false -- assume we will not adjust -- force is passed to cover cases where the user has just deselected both top or bottom bars -- When that happens we need to adjust - + -- We did it to ourselves - if (Aux)ScreenAdjust is true it means the user wants Titan to NOT adjust... if place == TITAN_PANEL_PLACE_TOP then if TitanPanelGetVar("ScreenAdjust") == 1 then @@ -304,34 +287,20 @@ local function DoAdjust(place, force) return res end ---[[ Titan -NAME: TitanMovable_MenuBar_Disable -DESC: Handle the main menu bar so Blizzard does not get upset. -VAR: None -OUT: None -NOTE: -- Reverted from 8.0 changes -:NOTE ---]] +---Titan Classic : Handle the main menu bar so Blizzard does not get upset. +--- Reverted from 8.0 changes function TitanMovable_MenuBar_Disable() if DoAdjust(TITAN_PANEL_PLACE_BOTTOM, false) then ---TitanPrint("TitanMovable_MenuBar_Disable - DoAdjust", "warning") MainMenuBar:SetMovable(true); -- MainMenuBar:SetUserPlaced(false); end end ---[[ Titan -NAME: TitanMovable_MenuBar_Enable -DESC: Handle the main menu bar so Blizzard does not get upset. -VAR: None -OUT: None -NOTE: -- Reverted from 8.0 changes -- This is called for the various events Titan handles that do / may hide the main menu bar -- IF TitanMovable_MenuBar_Disable was called, this must be called before having Titan adjust frames. The 'is user placed' is required to work around a Blizzard 'feature' that adjusts the main menu bar while in combat. -:NOTE ---]] +---Titan Classic : Handle the main menu bar so Blizzard does not get upset. +--- Reverted from 8.0 changes +--- This is called for the various events Titan handles that do / may hide the main menu bar +--- IF TitanMovable_MenuBar_Disable was called, this must be called before having Titan adjust frames. +--- The 'is user placed' is required to work around a Blizzard 'feature' that adjusts the main menu bar while in combat. function TitanMovable_MenuBar_Enable() if InCombatLockdown() then -- wait until out of combat... @@ -360,12 +329,12 @@ local function TitanMovableFrame_GetXOffset(frame, point) if point == "LEFT" and frame:GetLeft() and UIParent:GetLeft() then ret = frame:GetLeft() - UIParent:GetLeft(); elseif point == "RIGHT" and frame:GetRight() and UIParent:GetRight() then - ret = frame:GetRight() - UIParent:GetRight(); + ret = frame:GetRight() - UIParent:GetRight(); elseif point == "TOP" and frame:GetTop() and UIParent:GetTop() then ret = frame:GetTop() - UIParent:GetTop(); elseif point == "BOTTOM" and frame:GetBottom() and UIParent:GetBottom() then ret = frame:GetBottom() - UIParent:GetBottom(); - elseif point == "CENTER" and frame:GetLeft() and frame:GetRight() + elseif point == "CENTER" and frame:GetLeft() and frame:GetRight() and UIParent:GetLeft() and UIParent:GetRight() then local framescale = frame.GetScale and frame:GetScale() or 1; ret = (frame:GetLeft()* framescale + frame:GetRight() @@ -401,7 +370,7 @@ local function SetPosition(frame, ...) UIPARENT_MANAGED_FRAME_POSITIONS[name] = nil end -- Titan honors a user placed frame - frame:SetDontSavePosition(true) + frame:SetDontSavePosition(true) frame:SetAttribute('ignoreFramePositionManager', true) frame.ignoreFramePositionManager = true if ... then @@ -445,9 +414,11 @@ OUT: top_bottom - Frame is at top or bottom, expecting Titan constant for top or --]] local function MoveFrame(frame_ptr, start_y, top_bottom, force) local frame = _G[frame_ptr] - + local dbg = "Move" if frame then -- ensure a valid frame + dbg = dbg.." "..tostring(frame:GetName()) if frame:IsUserPlaced() then -- user (or another addon) may have placed this frame + dbg = dbg.." user placed set" else if DoAdjust(top_bottom, force) and frame:IsShown() then local y = TitanMovable_GetPanelYOffset(top_bottom) + (start_y or 0) -- includes scale adjustment @@ -455,22 +426,27 @@ local function MoveFrame(frame_ptr, start_y, top_bottom, force) -- check for nil which will cause an error if point and relativeTo and relativePoint and xOfs then -- do not care about yOfs SetPosition(frame, point, relativeTo:GetName(), relativePoint, xOfs, y) + dbg = dbg + .." "..tostring(relativeTo:GetName()).."" + .." "..tostring(xOfs).."" + .." "..tostring(y).."" else -- do not proceed + dbg = dbg.." GetPoint returns invalid" end else + dbg = dbg.." DoAdjust false" --[[ Some frames such as the ticket frame may not be visible or even created --]] - end + end end else -- Should note get here... ---[[ - TitanDebug ("MoveFrame nil found :" - .." "..tostring(frame_ptr) - ) ---]] + dbg = dbg.." No frame ??" + end + if Titan_Global.debug.movable then + TitanDebug(dbg) end end @@ -496,7 +472,7 @@ local function MoveMenuFrame(frame_ptr, start_y, top_bottom, force) end end ---[[ Titan +--[[ NAME: Titan_FCF_UpdateDockPosition DESC: Secure post hook to help adjust the chat / log frame. VAR: None @@ -509,12 +485,12 @@ NOTE: --]] local function Titan_FCF_UpdateDockPosition() if not Titan__InitializedPEW - or not TitanPanelGetVar("LogAdjust") - or TitanPanelGetVar("AuxScreenAdjust") then - return + or not TitanPanelGetVar("LogAdjust") + or TitanPanelGetVar("AuxScreenAdjust") then + return end - - if not InCombatLockdown() or (InCombatLockdown() + + if not InCombatLockdown() or (InCombatLockdown() and not _G["DEFAULT_CHAT_FRAME"]:IsProtected()) then local panelYOffset = TitanMovable_GetPanelYOffset(TITAN_PANEL_PLACE_BOTTOM); local scale = TitanPanelGetVar("Scale"); @@ -543,7 +519,7 @@ local function Titan_FCF_UpdateDockPosition() if ( DEFAULT_CHAT_FRAME:IsUserPlaced() ) then return; end - + local chatOffset = 85 + panelYOffset; -- Titan change to adjust Y offset if ( GetNumShapeshiftForms() > 0 or HasPetUI() or PetHasActionBar() ) then if ( MultiBarBottomLeft:IsShown() ) then @@ -554,17 +530,13 @@ local function Titan_FCF_UpdateDockPosition() elseif ( MultiBarBottomLeft:IsShown() ) then chatOffset = chatOffset + 15; end - DEFAULT_CHAT_FRAME:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", + DEFAULT_CHAT_FRAME:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 32, chatOffset); FCF_DockUpdate(); end end ---[[ Titan -NAME: Titan_ContainerFrames_Relocate -DESC: Secure post hook to help adjust the bag frames. -VAR: None -OUT: None +--[[ Secure post hook to help adjust the bag frames vertically only. NOTE: - The frame is adjusted in the Y axis only. - The Blizz routine "ContainerFrames_Relocate" should be examined for any conditions it checks and any changes to the SetPoint. @@ -575,8 +547,8 @@ This way the Blizz code does not need to be copied here. :NOTE --]] local function Titan_ContainerFrames_Relocate() - if not TitanPanelGetVar("BagAdjust") then - return + if not TitanPanelGetVar("BagAdjust") then + return end local panelYOffset = TitanMovable_GetPanelYOffset(TITAN_PANEL_PLACE_BOTTOM) @@ -590,8 +562,8 @@ local function Titan_ContainerFrames_Relocate() if ( bottom_y < off_y ) then -- Start a new column right_x = frame:GetRight() - frame:ClearAllPoints(); - frame:SetPoint("BOTTOMRIGHT", frame:GetParent(), + frame:ClearAllPoints(); + frame:SetPoint("BOTTOMRIGHT", frame:GetParent(), "BOTTOMLEFT", -- changed because we are taking the current x value right_x, -- x is not adjusted bottom_y + panelYOffset -- y @@ -603,10 +575,10 @@ end local function has_pet_bar() local hasPetBar = false - if ( ( PetActionBarFrame and PetActionBarFrame:IsShown() ) - or ( StanceBarFrame and StanceBarFrame:IsShown() ) - or ( MultiCastActionBarFrame and MultiCastActionBarFrame:IsShown() ) - or ( PossessBarFrame and PossessBarFrame:IsShown() ) + if ( ( PetActionBarFrame and PetActionBarFrame:IsShown() ) + or ( StanceBarFrame and StanceBarFrame:IsShown() ) + or ( MultiCastActionBarFrame and MultiCastActionBarFrame:IsShown() ) + or ( PossessBarFrame and PossessBarFrame:IsShown() ) or ( MainMenuBarVehicleLeaveButton and MainMenuBarVehicleLeaveButton:IsShown() ) ) then hasPetBar = true; end @@ -626,56 +598,56 @@ NOTE: :NOTE --]] local MData = { - [1] = {frameName = "PlayerFrame", - move = function (force) MoveFrame("PlayerFrame", 0, TITAN_PANEL_PLACE_TOP, force) end, + [1] = {frameName = "PlayerFrame", + move = function (force) MoveFrame("PlayerFrame", 0, TITAN_PANEL_PLACE_TOP, force) end, addonAdj = false, }, - [2] = {frameName = "TargetFrame", - move = function (force) MoveFrame("TargetFrame", 0, TITAN_PANEL_PLACE_TOP, force) end, + [2] = {frameName = "TargetFrame", + move = function (force) MoveFrame("TargetFrame", 0, TITAN_PANEL_PLACE_TOP, force) end, addonAdj = false, }, - [3] = {frameName = "PartyMemberFrame1", - move = function (force) MoveFrame("PartyMemberFrame1", 0, TITAN_PANEL_PLACE_TOP, force) end, + [3] = {frameName = "PartyMemberFrame1", + move = function (force) MoveFrame("PartyMemberFrame1", 0, TITAN_PANEL_PLACE_TOP, force) end, addonAdj = false, }, - [4] = {frameName = "TicketStatusFrame", - move = function (force) MoveFrame("TicketStatusFrame", 0, TITAN_PANEL_PLACE_TOP, force) end, + [4] = {frameName = "TicketStatusFrame", + move = function (force) MoveFrame("TicketStatusFrame", 0, TITAN_PANEL_PLACE_TOP, force) end, addonAdj = false, }, - [5] = {frameName = "BuffFrame", - move = function (force) + [5] = {frameName = "BuffFrame", + move = function (force) -- properly adjust buff frame(s) if GM Ticket is visible -- Use IsShown rather than IsVisible. In some cases (after closing -- full screen map) the ticket may not yet be visible. local yOffset = 0 if TicketStatusFrame:IsShown() - and TitanPanelGetVar("TicketAdjust") + and TitanPanelGetVar("TicketAdjust") then yOffset = (-TicketStatusFrame:GetHeight()) else yOffset = TitanPanelGetVar("BuffIconVerticalAdj") -- -13 end - MoveFrame("BuffFrame", yOffset, TITAN_PANEL_PLACE_TOP, force) end, + MoveFrame("BuffFrame", yOffset, TITAN_PANEL_PLACE_TOP, force) end, addonAdj = false, }, - [6] = {frameName = "MinimapCluster", - move = function (force) + [6] = {frameName = "MinimapCluster", + move = function (force) local yOffset = 0 - if MinimapBorderTop + if MinimapBorderTop and not MinimapBorderTop:IsShown() then yOffset = yOffset + (MinimapBorderTop:GetHeight() * 3/5) - 5 end - MoveFrame("MinimapCluster", yOffset, TITAN_PANEL_PLACE_TOP, force) end, + MoveFrame("MinimapCluster", yOffset, TITAN_PANEL_PLACE_TOP, force) end, addonAdj = false, }, - [7] = {frameName = "MultiBarRight", - move = function (force) - MoveFrame("MultiBarRight", 0, TITAN_PANEL_PLACE_BOTTOM, force) end, + [7] = {frameName = "MultiBarRight", + move = function (force) + MoveFrame("MultiBarRight", 0, TITAN_PANEL_PLACE_BOTTOM, force) end, addonAdj = false, }, - [8] = {frameName = "OverrideActionBar", - move = function (force) MoveFrame("OverrideActionBar", 0, TITAN_PANEL_PLACE_BOTTOM, force) end, + [8] = {frameName = "OverrideActionBar", + move = function (force) MoveFrame("OverrideActionBar", 0, TITAN_PANEL_PLACE_BOTTOM, force) end, addonAdj = false, }, - [9] = {frameName = "MicroButtonAndBagsBar", - move = function (force) MoveFrame("MicroButtonAndBagsBar", 0, TITAN_PANEL_PLACE_BOTTOM, force) end, + [9] = {frameName = "MicroButtonAndBagsBar", + move = function (force) MoveFrame("MicroButtonAndBagsBar", 0, TITAN_PANEL_PLACE_BOTTOM, force) end, addonAdj = false, }, [10] = {frameName = "MainMenuBar", -- MainMenuBar - move = function (force) - MoveMenuFrame("MainMenuBar", 0, TITAN_PANEL_PLACE_BOTTOM, force) end, + move = function (force) + MoveMenuFrame("MainMenuBar", 0, TITAN_PANEL_PLACE_BOTTOM, force) end, addonAdj = false, }, [11] = {frameName = "ExtraActionBarFrame", move = function (force) @@ -690,7 +662,7 @@ local MData = { local menuBarTop = 55; local overrideActionBarTop = 40; local petBattleTop = 60; - + local yOfs = 18 -- FramePositionDelegate:UIParentManageFramePositions if MainMenuBar and MainMenuBar:IsShown() then yOfs = yOfs + menuBarTop @@ -709,13 +681,13 @@ local MData = { end end, addonAdj = false, }, - [12] = {frameName = "UIWidgetTopCenterContainerFrame", - move = function (force) MoveFrame("UIWidgetTopCenterContainerFrame", 0, TITAN_PANEL_PLACE_TOP, force) end, + [12] = {frameName = "UIWidgetTopCenterContainerFrame", + move = function (force) MoveFrame("UIWidgetTopCenterContainerFrame", 0, TITAN_PANEL_PLACE_TOP, force) end, addonAdj = false, }, } --[==[ ---[[ Titan +--[[ Titan NAME: TitanMovable_AdjustTimer DESC: Cancel then add the given timer. The timer must be in TitanTimers. VAR: ttype - The timer type (string) as defined in TitanTimers @@ -730,13 +702,9 @@ function TitanMovable_AdjustTimer(ttype) end --]==] ---[[ Titan -NAME: TitanMovable_AddonAdjust -DESC: Set the given frame to be adjusted or not by another addon. This is called from TitanUtils for a developer API. -VAR: frame - frame name (string) -VAR: bool - true (addon will adjust) or false (Titan will use its settings) -OUT: None ---]] +---Titan Classic : Set the given frame to be adjusted or not by another addon. This is called from TitanUtils for a developer API. +---@param frame string Frame to look for +---@param bool boolean true (addon will adjust) or false (Titan will use its settings) function TitanMovable_AddonAdjust(frame, bool) for i = 1,#MData,1 do local fData = MData[i] @@ -758,8 +726,6 @@ Then update the chat and open bag frames. OUT: None --]] local function TitanMovableFrame_MoveFrames(force) - local move_count = 0 -- debug - local str = "" -- debug --[[ Setting the MainMenuBar as user placed is needed because in 8.0.0 Blizzard changed something in the way they controlled the frame. With Titan panel and bottom bars enabled the MainMenuBar @@ -770,16 +736,33 @@ local function TitanMovableFrame_MoveFrames(force) Later Titan checks rely on the user placed flag so it needs to be set early. --]] + if DoAdjust(TITAN_PANEL_PLACE_BOTTOM, force) then TitanMovable_MenuBar_Enable() end - if not InCombatLockdown() then + if InCombatLockdown() then + -- nothing to do + else + if Titan_Global.debug.movable then + TitanDebug("Start frame adjust...") + end for i = 1,#MData,1 do + local dbg = "Mv" + local ok = false if MData[i] then + dbg = dbg.." "..MData[i].frameName if MData[i].addonAdj then -- An addon has taken control of the frame so skip + dbg = dbg.." addonAdj true" else + dbg = dbg.." move" + ok = true + end + if Titan_Global.debug.movable then + TitanDebug(dbg) + end + if ok then -- Adjust the frame per MData MData[i].move(force) --[[ @@ -792,13 +775,16 @@ local function TitanMovableFrame_MoveFrames(force) .." "..msg, "error") end --]] + else + -- do nothing end end end Titan_FCF_UpdateDockPosition(); -- chat UpdateContainerFrameAnchors(); -- Move bags as needed - else - -- nothing to do + if Titan_Global.debug.movable then + TitanDebug("...End frame adjust") + end end end @@ -808,18 +794,13 @@ DESC: Adjust the scale of Titan bars and plugins to the user selected scaling. T VAR: None OUT: None --]] -local function Titan_AdjustUIScale() +local function Titan_AdjustUIScale() Titan_AdjustScale() end ---[[ Titan -NAME: TitanPanel_AdjustFrames -DESC: Adjust the frames for the Titan visible bars. -This is a shell for the actual Movable routine used by other Titan routines and secure hooks -OUT: None -NOTE: -:NOTE ---]] +---Titan Classic : Adjust the frames for the Titan visible bars. +---@param force boolean An adjust +---@param reason string Debug to know where the call came from function TitanPanel_AdjustFrames(force, reason) -- force is passed to cover cases where Titan should always adjust -- such as when the user has just de/selected top or bottom bars @@ -834,20 +815,13 @@ function TitanPanel_AdjustFrames(force, reason) end end ---[[ Titan -NAME: Titan_AdjustScale -DESC: Update the bars and plugins to the user selected scale. -VAR: None -OUT: None -NOTE: -- Ensure Titan has done its initialization before this is run. -:NOTE ---]] +---Titan Classic : Update the bars and plugins to the user selected scale. +--- Ensure Titan has done its initialization before this is run. function Titan_AdjustScale() -- Only adjust if Titan is fully initialized - if Titan__InitializedPEW then + if Titan__InitializedPEW then TitanPanel_SetScale(); - + -- TitanPanel_ClearAllBarTextures() -- TitanPanel_CreateBarTextures() --[[ @@ -862,23 +836,16 @@ function Titan_AdjustScale() end end ---[[ Titan -NAME: TitanMovable_SecureFrames -DESC: Once Titan is initialized create the post hooks we need to help adjust frames properly. -VAR: None -OUT: None -NOTE: -- The secure post hooks are required because Blizz adjusts frames Titan is interested in at times other than the events Titan registers for. -- This used to be inline code but was moved to a routine to avoid errors as Titan loaded. -:NOTE ---]] +---Titan Classic : Once Titan is initialized create the post hooks we need to help adjust frames properly. +--- The secure post hooks are required because Blizz adjusts frames Titan is interested in at times other than the events Titan registers for. +--- This used to be inline code but was moved to a routine to avoid errors as Titan loaded. function TitanMovable_SecureFrames() if not AceHook:IsHooked("FCF_UpdateDockPosition", Titan_FCF_UpdateDockPosition) then AceHook:SecureHook("FCF_UpdateDockPosition", Titan_FCF_UpdateDockPosition) -- FloatingChatFrame end if not AceHook:IsHooked("UIParent_ManageFramePositions", TitanPanel_AdjustFrames) then AceHook:SecureHook("UIParent_ManageFramePositions", TitanPanel_AdjustFrames) -- UIParent.lua - TitanPanel_AdjustFrames() + TitanPanel_AdjustFrames(false, " Hook UIParent_ManageFramePositions") end -- if not AceHook:IsHooked(TicketStatusFrame, "Show", TitanPanel_AdjustFrames) then @@ -894,7 +861,7 @@ function TitanMovable_SecureFrames() -- AceHook:SecureHook(WorldMapFrame.BorderFrame.MaximizeMinimizeFrame.MinimizeButton, "Show", TitanPanel_AdjustFrames) -- WorldMapFrame.lua -- AceHook:SecureHook("OrderHall_CheckCommandBar", TitanPanel_AdjustFrames) end - + if not AceHook:IsHooked("VideoOptionsFrameOkay_OnClick", Titan_AdjustUIScale) then -- Properly Adjust UI Scale if set -- Note: These are the least intrusive hooks we could think of, to properly adjust the Titan Bar(s) @@ -909,9 +876,11 @@ function TitanMovable_SecureFrames() -- Tell Titan to back off of the frames these addons could control -- Look in this routine for any special code or directions CheckConflicts() - + hooks_done = true end + +---Titan Classic : Unhook secure frames on error. function TitanMovable_Unhook_SecureFrames() --[[ This is a debug attempt to fix an issue when a player is dumped from a vehicle while still in combat. diff --git a/Titan/TitanPanelSetup-READ_ME_FIRST.txt b/Titan/TitanPanelSetup-READ_ME_FIRST.txt index d8409a5..1f38f45 100644 --- a/Titan/TitanPanelSetup-READ_ME_FIRST.txt +++ b/Titan/TitanPanelSetup-READ_ME_FIRST.txt @@ -2,18 +2,6 @@ TitanPanelSetup-READ_ME_FIRST File ================================== **************************************************************************************************** -ATTENTION! THE FOLLOWING PLUGINS HAVE BEEN REMOVED OR RENAMED. PLEASE REMOVE THESE FROM YOUR FOLDER! -- TitanCoords has been renamed TitanLocation to more accurately reflect the information it - provides. REMOVE THE TitanCoords FOLDER FROM YOUR ADDONS FOLDER. -- TitanGoldTracker has been renamed TitanGold. REMOVE THE TitanGoldTracker FOLDER FROM YOUR ADDONS - FOLDER. -- TitanAmmo has been removed from the package due to the elimination of ammo/arrows/bolts from the - game. REMOVE THE TitanAmmo FOLDER FROM YOUR ADDONS FOLDER. -- TitanRegen has been removed from the package due to lack of interest. Consequently, it may not - work with future versions of Titan Panel. You are free to maintain this plugin if you wish. - IF YOU HAVE NO INTEREST IN MAINTAINING IT, REMOVE THE TitanRegen FOLDER FROM YOUR ADDONS FOLDER. -- BonusScanner has been removed from Titan Panel as it is not part of the core functionality. -- BrokerBonusScanner has been removed from Titan Panel as it is not part of the core functionality. **************************************************************************************************** 1. Description diff --git a/Titan/TitanPluginDoc.lua b/Titan/TitanPluginDoc.lua deleted file mode 100644 index 606d6a5..0000000 --- a/Titan/TitanPluginDoc.lua +++ /dev/null @@ -1,61 +0,0 @@ ---[[ File -NAME: DocTitanPlugin.lua -DESC: This file contains documentation of Titan to assist a developer. -:DESC ---]] ---[[ API -NAME: Titan API overview for developers -DESC: Updated Feb 2024 - -This documentation is intended for addon developers that wish to create a Titan plugin. - -Terms: -Throughout the documentation and naming of routines and variables there are some terms that are used interchangably. -- Plugin / button which are frames using TitanTemplates.xml -- Character / player / toon -- Plugin ID / plugin name -Over time we desire to consolidate terms but it may take time. - -Plugin Types: -Titan allows two types of plugins: -- Titan native -- LDB enabled addons -Titan release has an example of each : TitanExamplePlugin and TitanExampleLDB. - -Titan Plugin Creation: -Titan native plugins must use one of the Titan templates found in TitanPanelTemplates.xml. -On the creation of a Titan plugin frame the Onload places the plugin in a holding table until the "Player Entering World" (PEW) event is fired. - -LDB Plugin Creation: -LDB enabled addons only need to adhere to the LDB (Lib Data Broker) 1.1 spec. -Titan uses the callback feature ("LibDataBroker_DataObjectCreated") to recognize LDB addons. -Titan creates a Titan plugin using the LDB plugin data. -At player_login Titan registers the call back. -It then loops through the LDB objects using :DataObjectIterator(). -When any LDB object is found Titan will attempt to create a Titan native plugin for display. - -Registration Steps: -On PLAYER_LOGIN event, Titan loops through the holding LDB plugins creating Titan plugins. It will sync the saved variables. -On PLAYER_ENTERING_WORLD (PEW) event, Titan loops through the holding table registering plugins. It will sync the saved variables. -Titan attempts to register each plugin ensuring: -- Each attempt is protected (pcall) so Titan does not crash (hopefully!) -- The .registry has required values and is reasonable. -- Sync of control and saved variables. -- All attempts are recorded. These can be seen in Titan Config > Attempts - -Registration Attempts: -Each attempt can be seen in Titan Config > Attempts with the results of the registration. The developer can see what happened and users can report issues using that data. - -Registry Table of Each Plugin: -Each plugin must contain a table called "registry". - self.registry = {} - -The registry table must have a unique id across all Titan plugins that are loaded. - self.registry = {id = "MyPlugin"} -This is all that is required for successful registration. It will register but will be a rather dull plugin. -It is strongly recommended that you utilize the Titan plugin example. The example is based on TitanBags so you can play with the code and compare it to a supported plugin. - -Titan API: -Within the Titan files you can recognize an API routine by the comment just before the function declaration. The comment block will have "API" as part of the starting block. -:DESC ---]] \ No newline at end of file diff --git a/Titan/TitanTemplate.lua b/Titan/TitanTemplate.lua index ca4751e..bedf8bd 100644 --- a/Titan/TitanTemplate.lua +++ b/Titan/TitanTemplate.lua @@ -1,24 +1,36 @@ ---[[ File -NAME: TitanPanelTemplate.lua -DESC: Contains the routines to handle a frame created as a Titan plugin. ---]] ---[[ API -NAME: TitanPanelTemplate overview -DESC: See TitanPanelButtonTemplate.xml also. +--[===[ File +Creates the following frames: +- TitanPanelBarButton : Main Titan frame handling events +- TitanPanelTooltip : Used? Inherits from GameTooltipTemplate + +Contains the routines to control a Titan template frame. +These could be: +- A Titan bar (full or short) +- A Titan plugin (built-in, thrid party, or LDB) + +The Titan templates are defined in .xml. +There appears to be no other way to make frame templates - virtual="true". +--]===] + +--[===[ Var API TitanPanelTemplate overview +See TitanPanelButtonTemplate.xml also for more detail. + +TitanTemplate (Lua and XML) contain the basics for Titan plugin frames. +Titan templates contain elements used by Titan. -A Titan plugin is a frame created using one of the button types in TitanPanelButtonTemplate.xml which inherits TitanPanelButtonTemplate. +A Titan plugin is a frame created using one of the button types in TitanPanelButtonTemplate.xml. The available plugin types are: -TitanPanelTextTemplate - A frame that only displays text ("$parentText") -TitanPanelIconTemplate - A frame that only displays an icon ("$parentIcon") -TitanPanelComboTemplate - A frame that displays an icon then text ("$parentIcon" "$parentText") +- TitanPanelTextTemplate - * A frame that only displays text ("$parentText") +- TitanPanelIconTemplate - * A frame that only displays an icon ("$parentIcon") +- TitanPanelComboTemplate - * A frame that displays an icon then text ("$parentIcon" "$parentText") +- TitanOptionsSliderTemplate - A frame that contains the basics for a vertical slider control. See TitanVolume for an example. +- TitanPanelChildButtonTemplate - A frame that allows a plugin within a plugin. !!! Not be used anymore!!! -Most plugins use the combo template. +* Templates inherit TitanPanelButtonTemplate for common elements. -TitanPanelButtonTemplate.xml contains other templates available to be used. -TitanOptionsSliderTemplate - A frame that contains the basics of a slider control. See TitanVolume for an example. -TitanPanelChildButtonTemplate - A frame that allows a plugin within a plugin. The older version of TitanGold was an example. This may not be used anymore. +Most plugins use the combo template. -Each template contains: +TitanPanelButtonTemplate contains: - a frame to handle a menu invoked by a right mouse click ("$parentRightClickMenu") - default event handlers for @@ -37,8 +49,13 @@ Each template contains: TitanPanelButton_OnLeave(self); If these events are overridden then the default routine needs to be included! -:DESC ---]] + + +NOTE: TitanPanelChildButtonTemplate - !!! Not be used anymore!!! +A much older version of TitanGold was an example. +No third party plugins we are aware of have used this over the years. This scheme may not work and will be slowly removed from the code. + +--]===] -- Globals @@ -50,15 +67,23 @@ local TITAN_PANEL_BUTTON_TYPE_ICON = 2; local TITAN_PANEL_BUTTON_TYPE_COMBO = 3; local TITAN_PANEL_BUTTON_TYPE_CUSTOM = 4; local pluginOnEnter = nil; -local TITAN_PANEL_MOVE_ADDON = nil; -local TITAN_PANEL_DROPOFF_ADDON = nil; +local TITAN_PANEL_MOVE_ADDON = ""; +local TITAN_PANEL_DROPOFF_ADDON = ""; -- Library instances local LibQTip = nil local _G = getfenv(0); -local InCombatLockdown = _G.InCombatLockdown; +local InCombatLockdown = _G.InCombatLockdown local media = LibStub("LibSharedMedia-3.0") +--[[ +print("B text" +.." "..tostring(id).."" +.." "..tostring(type(bFunction)).."" +.." '"..tostring(bFunction).."'" +.." '"..tostring(buttonTextFunction).."'" +) +--]] --========================== --[[ local @@ -82,16 +107,11 @@ function TitanPanel_SetScale() end end ---[[ local -NAME: TitanTooltip_AddTooltipText -DESC: Helper to add a line of tooltip text to the tooltip. -VAR: text - string -OUT: None -NOTE: -- Append a "\n" to the end if there is not one already there -:NOTE ---]] -local function TitanTooltip_AddTooltipText(text) +---local Helper to add a line of tooltip text to the tooltip. +---@param text string To add +---@param frame table Tooltip frame +--- Append a "\n" to the end if there is not one already there +local function TitanTooltip_AddTooltipText(text, frame) if (text) then -- Append a "\n" to the end if (string.sub(text, -1, -1) ~= "\n") then @@ -102,104 +122,73 @@ local function TitanTooltip_AddTooltipText(text) for text1, text2 in string.gmatch(text, "([^\t\n]*)\t?([^\t\n]*)\n") do if (text2 ~= "") then -- Add as double wide - GameTooltip:AddDoubleLine(text1, text2); + frame:AddDoubleLine(text1, text2); elseif (text1 ~= "") then -- Add single column line - GameTooltip:AddLine(text1); + frame:AddLine(text1); else -- Assume a blank line - GameTooltip:AddLine("\n"); + frame:AddLine("\n"); end end + else + -- No text to display end end ---[[ local -NAME: TitanTooltip_SetOwnerPosition -DESC: Set both the parent and the position of GameTooltip for the plugin tooltip. -VAR: parent - reference to the frame to attach the tooltip to -VAR: anchorPoint - tooltip anchor location (side or corner) to use -VAR: relativeToFrame - string name name of the frame, usually the plugin), to attach the tooltip to -VAR: relativePoint - parent anchor location (side or corner) to use -VAR: xOffset - X offset from the anchor point -VAR: yOffset - Y offset from the anchor point -VAR: frame - reference to the tooltip -OUT: None ---]] +---local Helper to set both the parent and the position of GameTooltip for the plugin tooltip. +---@param parent table Reference to the frame to attach the tooltip to +---@param anchorPoint string Tooltip anchor location (side or corner) to use +---@param relativeToFrame string name name of the frame, usually the plugin), to attach the tooltip to +---@param relativePoint string Parent anchor location (side or corner) to use +---@param xOffset number X offset +---@param yOffset number Y offset +---@param frame table Tooltip frame +--- Set Titan_Global.debug.tool_tips to output debug local function TitanTooltip_SetOwnerPosition(parent, anchorPoint, relativeToFrame, relativePoint, xOffset, yOffset, frame) - if not frame then - frame = _G["GameTooltip"] - end -- Changes for 9.1.5 Removed the background template from the GameTooltip -- Making changes to it difficult and possibly changing the tooltip globally. frame:SetOwner(parent, "ANCHOR_NONE"); - frame:SetPoint(anchorPoint, relativeToFrame, relativePoint, - xOffset, yOffset); + frame:SetPoint(anchorPoint, relativeToFrame, relativePoint, xOffset, yOffset); -- set font size for the Game Tooltip - if not TitanPanelGetVar("DisableTooltipFont") then + if TitanPanelGetVar("DisableTooltipFont") then + -- use UI scale + else if TitanTooltipScaleSet < 1 then TitanTooltipOrigScale = frame:GetScale(); TitanTooltipScaleSet = TitanTooltipScaleSet + 1; end frame:SetScale(TitanPanelGetVar("TooltipFont")); end -end ---[[ local -NAME: TitanTooltip_SetGameTooltip -DESC: Helper to set the tooltip of the given Titan plugin. -First check for a custom function. If no function then use the plugin tooltip title and text. -VAR: self - frame reference of the plugin -OUT: None -NOTE: -- If a custom function is given pcall (protected call) is used in case the function errors out. Currently the error is allowed to occur silently because it could generate a lot of text to chat. -:NOTE ---]] -local function TitanTooltip_SetGameTooltip(self) - if (self.tooltipCustomFunction) then - --[ - local tmp_txt = "" - local call_success - call_success, -- for pcall - tmp_txt = pcall(self.tooltipCustomFunction) - --]] - -- self.tooltipCustomFunction(); - elseif (self.tooltipTitle) then - GameTooltip:SetText(self.tooltipTitle, - HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b); - if (self.tooltipText) then - TitanTooltip_AddTooltipText(self.tooltipText); - end + if Titan_Global.debug.tool_tips then + local dbg_msg = "_pos" + .. " '" .. tostring(frame:GetName()) .. "'" + .. " " .. tostring(frame:IsShown()) .. "" + .. " @ '" .. tostring(relativeToFrame) .. "'" + .. " " .. tostring(_G[relativeToFrame]:IsShown()) .. "" + TitanDebug(dbg_msg, "normal") + dbg_msg = ">>_pos" + .. " " .. tostring(anchorPoint) .. "" + .. " " .. tostring(relativePoint) .. "" + .. " w" .. tostring(format("%0.1f", frame:GetWidth())) .. "" + .. " h" .. tostring(format("%0.1f", frame:GetHeight())) .. "" + TitanDebug(dbg_msg, "normal") end - - GameTooltip:Show(); end ---[[ local -NAME: TitanTooltip_SetPanelTooltip -DESC: Helper to set the screen position of the tooltip of the given Titan plugin. -VAR: self - frame reference of the plugin -VAR: id - string name of the plugin -VAR: frame - reference to the tooltip -OUT: None ---]] +---local Helper to set the screen position of the tooltip frame +---@param self table Tooltip frame +---@param id string Plugin id name +---@param frame table Tooltip frame - expected to be GameTooltip local function TitanTooltip_SetPanelTooltip(self, id, frame) - -- sanity checks - if not TitanPanelGetVar("ToolTipsShown") - or (TitanPanelGetVar("HideTipsInCombat") and InCombatLockdown()) then - return - end - - if not self.tooltipCustomFunction and not self.tooltipTitle then return end - - -- Set GameTooltip - local button = TitanUtils_GetButton(id); + local button = TitanUtils_GetButton(id) if button then -- Adjust the Y offset as needed - local rel_y = self:GetTop() - GameTooltip:GetHeight() + local rel_y = self:GetTop() - frame:GetHeight() local pt = "" local rel_pt = "" if rel_y > 0 then @@ -210,7 +199,7 @@ local function TitanTooltip_SetPanelTooltip(self, id, frame) pt = "BOTTOM"; rel_pt = "TOP"; end - local rel_x = self:GetLeft() + GameTooltip:GetHeight() + local rel_x = self:GetLeft() + frame:GetHeight() if (rel_x < GetScreenWidth()) then -- menu will fit pt = pt .. "LEFT"; @@ -220,157 +209,181 @@ local function TitanTooltip_SetPanelTooltip(self, id, frame) rel_pt = rel_pt .. "RIGHT"; end - --[[ -print("_tooltip" -.." "..tostring(self:GetName()).."" -.." "..tostring(pt).."" -.." "..tostring(rel_pt).."" -.." "..tostring(format("%0.1f", GameTooltip:GetWidth())).."" -.." "..tostring(format("%0.1f", GameTooltip:GetHeight())).."" -) ---]] TitanTooltip_SetOwnerPosition(button, pt, button:GetName(), rel_pt, 0, 0, frame) - TitanTooltip_SetGameTooltip(self) end end ---[[ local -NAME: TitanPanelButton_SetTooltip -DESC: Set the tooltip of the given Titan plugin. -VAR: self - frame reference of the plugin -VAR: id - string name of the plugin ---]] +---local Set the tooltip of the given Titan plugin. +---@param self table Tooltip frame +---@param id string Plugin id name +--- Set Titan_Global.debug.tool_tips to output debug of this routine local function TitanPanelButton_SetTooltip(self, id) - -- ensure that the 'self' passed is a valid frame reference - if not self:GetName() then return end - - local call_success = nil - local tmp_txt = "" - local use_mod = TitanAllGetVar("UseTooltipModifer") - local use_alt = TitanAllGetVar("TooltipModiferAlt") - local use_ctrl = TitanAllGetVar("TooltipModiferCtrl") - local use_shift = TitanAllGetVar("TooltipModiferShift") + local dbg_msg = "TT:" local ok = false + local frame = GameTooltip - if use_mod then - if (use_alt and IsAltKeyDown()) - or (use_ctrl and IsControlKeyDown()) - or (use_shift and IsShiftKeyDown()) - then - ok = true + -- ensure that the 'self' passed is a valid frame reference + if self:GetName() then + dbg_msg = dbg_msg .. "'" .. self:GetName() .. "'" + -- sanity checks + if (TitanPanelGetVar("HideTipsInCombat") and InCombatLockdown()) then + dbg_msg = dbg_msg .. " HideTipsInCombat" + else + if TitanPanelGetVar("ToolTipsShown") then + ok = true + else + dbg_msg = dbg_msg .. " ToolTipsShown false" + end end else - ok = true + dbg_msg = dbg_msg .. " No frame" + -- Cannot even start end - self.tooltipCustomFunction = nil; - if ok and (id and TitanUtils_IsPluginRegistered(id)) then - local plugin = TitanUtils_GetPlugin(id) - if plugin then - if (plugin.tooltipCustomFunction) then + if ok then + local call_success = nil + local tmp_txt = "" + local use_mod = TitanAllGetVar("UseTooltipModifer") + local use_alt = TitanAllGetVar("TooltipModiferAlt") + local use_ctrl = TitanAllGetVar("TooltipModiferCtrl") + local use_shift = TitanAllGetVar("TooltipModiferShift") + + if use_mod then + if (use_alt and IsAltKeyDown()) + or (use_ctrl and IsControlKeyDown()) + or (use_shift and IsShiftKeyDown()) + then + ok = true + end + else + ok = true + end + + self.tooltipCustomFunction = nil; + self.titan_tt_func = "" + self.titan_tt_err = "" + + if ok and (id and TitanUtils_IsPluginRegistered(id)) then + local plugin = TitanUtils_GetPlugin(id) + if (plugin and plugin.tooltipCustomFunction) then + -- Prep the tooltip frame + TitanTooltip_SetPanelTooltip(self, id, frame); + + -- Fill the tooltip self.tooltipCustomFunction = plugin.tooltipCustomFunction; - TitanTooltip_SetPanelTooltip(self, id); - elseif (plugin.tooltipTitle) then - -- local tooltipTextFunc = _G[plugin.tooltipTextFunction]; + dbg_msg = dbg_msg .. " | custom" + call_success, -- for pcall + tmp_txt = pcall(self.tooltipCustomFunction) + if call_success then + -- all is good + dbg_msg = dbg_msg .. " | ok" + else + dbg_msg = dbg_msg .. " | Err: " .. tmp_txt + end + + frame:Show(); -- now show it + elseif (plugin and plugin.tooltipTitle) then local tooltipTextFunc = {} ---@type function local tt_func = plugin.tooltipTextFunction if type(tt_func) == 'string' then -- Function MUST be in global namespace tooltipTextFunc = _G[tt_func] + dbg_msg = dbg_msg .. " | string" elseif type(tt_func) == 'function' then -- Can be global or local to the plugin tooltipTextFunc = tt_func + dbg_msg = dbg_msg .. " | function" else - return -- silently leave... + -- silently leave... + dbg_msg = dbg_msg .. " | none found" end if (tooltipTextFunc) then - if ok then -- display the tooltip - self.tooltipTitle = plugin.tooltipTitle; - call_success, -- for pcall - tmp_txt = pcall(tooltipTextFunc); - self.tooltipText = tmp_txt - -- self.tooltipText = tooltipTextFunc(); - TitanTooltip_SetPanelTooltip(self, id); + -- Prep the tooltip frame + TitanTooltip_SetPanelTooltip(self, id, frame); + self.tooltipTitle = plugin.tooltipTitle; + call_success, -- for pcall + tmp_txt = pcall(tooltipTextFunc) + + -- Fill the tooltip + self.tooltipText = tmp_txt + frame:SetText(self.tooltipTitle, + HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b); + if (self.tooltipText) then + TitanTooltip_AddTooltipText(self.tooltipText, frame) + dbg_msg = dbg_msg .. " | ok" + else + dbg_msg = dbg_msg .. " | No text" end + + frame:Show() -- now show it end + else + -- no recognized method to create tooltip + dbg_msg = "No recognized tooltip method [.tooltipCustomFunction then .tooltipTitle /.tooltipText]" end end + else + -- no need to waste cycles + end + + if Titan_Global.debug.tool_tips then + TitanDebug(dbg_msg, "normal") end end ---[[ local -NAME: TitanPanelButton_IsText -DESC: Is the given Titan plugin of type text? -VAR: id - string name of the plugin -OUT: boolean ---]] +---local Is the given Titan plugin template type text? +---@param id string Plugin id name +---@return boolean IsText local function TitanPanelButton_IsText(id) if (TitanPanelButton_GetType(id) == TITAN_PANEL_BUTTON_TYPE_TEXT) then - return 1; + return true + else + return false end end ---[[ local -NAME: TitanPanelButton_IsCombo -DESC: Is the given Titan plugin of type combo? -VAR: id - string name of the plugin -OUT: boolean ---]] +---local Is the given Titan plugin of type combo? +---@param id string Plugin id name +---@return boolean IsCombo local function TitanPanelButton_IsCombo(id) if (TitanPanelButton_GetType(id) == TITAN_PANEL_BUTTON_TYPE_COMBO) then - return 1; + return true + else + return false end end ---[[ Titan -NAME: TitanPanelButton_IsIcon -DESC: Is the given Titan plugin of type icon? -VAR: id - string name of the plugin -OUT: boolean ---]] +---Titan Is the given Titan plugin of type icon? +---@param id string Plugin id name +---@return boolean is_icon function TitanPanelButton_IsIcon(id) + local res = false if (TitanPanelButton_GetType(id) == TITAN_PANEL_BUTTON_TYPE_ICON) then - return 1; + res = true + else + res = false end -end ---[[ local -NAME: TitanPanelButton_IsCustom -DESC: Is the given Titan plugin of type custom? -VAR: id - string name of the plugin -OUT: boolean ---]] -local function TitanPanelButton_IsCustom(id) - if (TitanPanelButton_GetType(id) == TITAN_PANEL_BUTTON_TYPE_CUSTOM) then - return 1; - end + return res end ---[[ local -NAME: TitanPanelButton_OnDragStart -DESC: Handle the OnDragStart event of the given Titan plugin. -VAR: self - frame reference of the plugin -VAR: ChildButton - boolean -OUT: None -NOTE: -- Do nothing if the user has locked plugins or if in combat. -- Set the .isMoving of the plugin (frame) so other routine can check it. -- Set TITAN_PANEL_MOVING so any Titan routine will know a 'drag & drop' is in progress. -- Set TITAN_PANEL_MOVE_ADDON so sanity checks can be done on the 'drop'. -:NOTE ---]] -local function TitanPanelButton_OnDragStart(self, ChildButton) +---local Handle the OnDragStart event of the given Titan plugin. +---@param self table Plugin frame +--- Do nothing if the user has locked plugins or if in combat. +--- Set the .isMoving of the plugin (frame) so other routine can check it. +--- Set TITAN_PANEL_MOVING so any Titan routine will know a 'drag & drop' is in progress. +--- Set TITAN_PANEL_MOVE_ADDON so sanity checks can be done on the 'drop'. +local function TitanPanelButton_OnDragStart(self) if TitanPanelGetVar("LockButtons") or InCombatLockdown() then return end local frname = self; - if ChildButton then - frname = self:GetParent(); - end +-- if ChildButton then +-- frname = self:GetParent(); +-- end -- Clear button positions or we'll grab the button and all buttons 'after' - local i, j; for i, j in pairs(TitanPanelSettings.Buttons) do local pluginid = _G[TitanUtils_ButtonName(TitanPanelSettings.Buttons[i])]; if pluginid then @@ -410,10 +423,10 @@ local function TitanPanelButton_OnDragStart(self, ChildButton) -- Hold the plugin id so we can do checks on the drop TITAN_PANEL_MOVE_ADDON = TitanUtils_GetButtonID(self:GetName()); - if ChildButton then - TITAN_PANEL_MOVE_ADDON = - TitanUtils_GetButtonID(self:GetParent():GetName()); - end +-- if ChildButton then +-- TITAN_PANEL_MOVE_ADDON = +-- TitanUtils_GetButtonID(self:GetParent():GetName()); +-- end -- Tell Titan that a drag & drop is in process TITAN_PANEL_MOVING = 1; -- Store the OnEnter handler so the tooltip does not show - or other oddities @@ -421,19 +434,12 @@ local function TitanPanelButton_OnDragStart(self, ChildButton) self:SetScript("OnEnter", nil) end ---[[ local -NAME: TitanPanelButton_OnDragStop -DESC: Handle the OnDragStop event of the given Titan plugin. -VAR: self - frame reference of the plugin -VAR: ChildButton - boolean -OUT: None -NOTE: -- Clear the .isMoving of the plugin (frame). -- Clear TITAN_PANEL_MOVING. -- Clear TITAN_PANEL_MOVE_ADDON. -:NOTE ---]] -local function TitanPanelButton_OnDragStop(self, ChildButton) +---local Handle the OnDragStop event of the given Titan plugin. +---@param self table Plugin frame +--- Clear the .isMoving of the plugin (frame). +--- Clear TITAN_PANEL_MOVING. +--- Clear TITAN_PANEL_MOVE_ADDON. +local function TitanPanelButton_OnDragStop(self) if TitanPanelGetVar("LockButtons") then return end @@ -441,9 +447,9 @@ local function TitanPanelButton_OnDragStop(self, ChildButton) local nonmovableFrom = false; local nonmovableTo = false; local frname = self; - if ChildButton then - frname = self:GetParent(); - end +-- if ChildButton then +-- frname = self:GetParent(); +-- end if TITAN_PANEL_MOVING == 1 then frname:StopMovingOrSizing(); frname.isMoving = false; @@ -471,10 +477,10 @@ local function TitanPanelButton_OnDragStop(self, ChildButton) nonmovableFrom = TitanUtils_ToRight(TITAN_PANEL_MOVE_ADDON) nonmovableTo = TitanUtils_ToRight(TITAN_PANEL_DROPOFF_ADDON) if nonmovableTo ~= nonmovableFrom then - TITAN_PANEL_DROPOFF_ADDON = nil; + TITAN_PANEL_DROPOFF_ADDON = ""; end - if TITAN_PANEL_DROPOFF_ADDON == nil then + if TITAN_PANEL_DROPOFF_ADDON == "" then -- See if the plugin was dropped on a bar rather than -- another plugin. local bar @@ -515,132 +521,44 @@ local function TitanPanelButton_OnDragStop(self, ChildButton) -- This is important! The start drag cleared the button positions so -- the buttons need to be put back properly. TitanPanel_InitPanelButtons(); - TITAN_PANEL_MOVE_ADDON = nil; - TITAN_PANEL_DROPOFF_ADDON = nil; + TITAN_PANEL_MOVE_ADDON = ""; + TITAN_PANEL_DROPOFF_ADDON = ""; -- Restore the OnEnter script handler if pluginOnEnter then self:SetScript("OnEnter", pluginOnEnter) end pluginOnEnter = nil; end end ---[[ API -NAME: TitanOptionSlider_TooltipText -DESC: Set the color of the tooltip text to normal (white) with the value in green. -VAR: text - the label for value -VAR: value - the value -OUT: string - encoded color string of text and value ---]] +---API Set the color of the tooltip text to normal (white) with the value in green. +---@param text string Label to show +---@param value any Value to show; something tostring() can handle +---@return string str Formatted text and value +--- self.tooltipText = TitanOptionSlider_TooltipText("Addons", TitanGetVar(TITAN_PERFORMANCE_ID, "NumOfAddons")); function TitanOptionSlider_TooltipText(text, value) - return (text or "?") .. " " .. GREEN_FONT_COLOR_CODE .. value .. FONT_COLOR_CODE_CLOSE; + return tostring(text) .. " " .. GREEN_FONT_COLOR_CODE .. tostring(value) .. FONT_COLOR_CODE_CLOSE; end ---[[ API -NAME: TitanPanelButton_OnLoad -DESC: Handle the OnLoad event of the requested Titan plugin. Ensure the plugin is set to be registered. -VAR: isChildButton - boolean -NOTE: -- This is called from the Titan plugin frame in the OnLoad event - usually as the frame is created. -- This starts the plugin registration process. See TitanUtils for more details on plugin registration. -- The plugin registration is a two step process because not all addons create Titan plugins in the frame create. The Titan feature of converting LDB addons to Titan plugins is an example. -:NOTE +---API Handle the OnLoad event of the requested Titan plugin. Ensure the plugin is set to be registered. +---@param self table Plugin frame +---@param isChildButton boolean? If is child plugin !! NO LONGER USED !! +--- This is called from the Titan plugin frame in the OnLoad event - usually as the frame is created in the Titan template. +function TitanPanelButton_OnLoad(self, isChildButton) + -- Used by plugins +--[[ +--- This is called from the Titan plugin frame in the OnLoad event - usually as the frame is created in the Titan template. +--- This starts the plugin registration process. See TitanUtils for more details on plugin registration. +--- The plugin registration is a two step process because not all addons create Titan plugins in the frame create. +--- The Titan feature of converting LDB addons to Titan plugins is an example. +--- If the plugin needs an OnLoad process it should call this routine after its own. +--- TitanPanelLootTypeButton_OnLoad(self) +--- TitanPanelButton_OnLoad(self) --]] -function TitanPanelButton_OnLoad(self, isChildButton) -- Used by plugins - TitanUtils_PluginToRegister(self, isChildButton) +-- TitanUtils_PluginToRegister(self, isChildButton) + TitanUtils_PluginToRegister(self, false) end ---[[ API -- Used by plugins -NAME: TitanPanelPluginHandle_OnUpdate -DESC: A method to refresh the display of a Titan plugin. -VAR: table - the frame of the plugin -VAR: oldarg - nil or command -NOTE: -- This is used by some plugins. It is not used within Titan. -- The expected usage is either: -1) Table contains {, } -2) table = and oldarg = -- oldarg - nil or command -1 = refresh button -2 = refresh tooltip -3 = refresh button and tooltip -:NOTE ---]] -function TitanPanelPluginHandle_OnUpdate(table, oldarg) - local id, updateType = nil, nil - -- set the id and updateType - -- old method - if table and type(table) == "string" and oldarg then - id = table - updateType = oldarg - end - -- new method - if table and type(table) == "table" then - if table[1] then id = table[1] end - if table[2] then updateType = table[2] end - end - - -- id is required - if id then - if updateType == TITAN_PANEL_UPDATE_BUTTON - or updateType == TITAN_PANEL_UPDATE_ALL then - TitanPanelButton_UpdateButton(id) - end - - if (updateType == TITAN_PANEL_UPDATE_TOOLTIP - or updateType == TITAN_PANEL_UPDATE_ALL) - and MouseIsOver(_G[TitanUtils_ButtonName(id)]) then - if TitanPanelRightClickMenu_IsVisible() or TITAN_PANEL_MOVING == 1 then - return - end - - TitanPanelButton_SetTooltip(_G[TitanUtils_ButtonName(id)], id) - end - end -end - ---[[ API -NAME: TitanPanelDetectPluginMethod -DESC: Poorly named routine that sets the OnDragStart & OnDragStop scripts of a Titan plugin. -VAR: id - the string name of the plugin -VAR: isChildButton - boolean ---]] -function TitanPanelDetectPluginMethod(id, isChildButton) - -- Ensure the id is not nil - if not id then return end - local TitanPluginframe = _G[TitanUtils_ButtonName(id)]; - if isChildButton then - TitanPluginframe = _G[id]; - end - -- Ensure the frame is valid - if not TitanPluginframe and TitanPluginframe:GetName() then return end -- sanity check... - - -- Set the OnDragStart script - TitanPluginframe:SetScript("OnDragStart", function(self) - if not IsShiftKeyDown() - and not IsControlKeyDown() - and not IsAltKeyDown() then - if isChildButton then - TitanPanelButton_OnDragStart(self, true); - else - TitanPanelButton_OnDragStart(self); - end - end - end) - - -- Set the OnDragStop script - TitanPluginframe:SetScript("OnDragStop", function(self) - if isChildButton then - TitanPanelButton_OnDragStop(self, true) - else - TitanPanelButton_OnDragStop(self); - end - end) -end - ---[[ API -- Used by plugins -NAME: TitanPanelButton_OnShow -DESC: Handle the OnShow event of the requested Titan plugin. -VAR:self - frame reference of the plugin ---]] +---API Handle the OnShow event of the requested Titan plugin. +---@param self table Plugin frame function TitanPanelButton_OnShow(self) local id = nil; -- ensure that the 'self' passed is a valid frame reference @@ -653,36 +571,23 @@ function TitanPanelButton_OnShow(self) end end ---[[ API -- Used by plugins -NAME: TitanPanelButton_OnClick -DESC: Handle the OnClick mouse event of the requested Titan plugin. -VAR: self - frame reference of the plugin -VAR: button - mouse button that was clicked -VAR: isChildButton - boolean ! NO LONGER USED ! -NOTE: -- Only the left and right mouse buttons are handled by Titan. -:NOTE ---]] +---API Handle the OnClick mouse event of the requested Titan plugin. +---@param self table Plugin frame +---@param button string Mouse button clicked +---@param isChildButton boolean? If is child plugin ! NO LONGER USED ! +--- Only the left and right mouse buttons are handled by Titan. +--- Called from Titan templates unless overriden by plugin. If overridden the plugin should call this routine. function TitanPanelButton_OnClick(self, button, isChildButton) local id -- ensure that the 'self' passed is a valid frame reference if self and self:GetName() then - id = TitanUtils_Ternary(isChildButton, +--[[ id = TitanUtils_Ternary(isChildButton, TitanUtils_GetParentButtonID(self:GetName()), TitanUtils_GetButtonID(self:GetName())); +--]] + id = TitanUtils_GetButtonID(self:GetName()) end - --[[ -if self.TitanType == "macro" then -print("TPB OnClick" -.." "..tostring(self:GetName()).." " -.." "..tostring(button).." " -.." "..tostring(issecure()).." " -.." "..tostring(self:GetAttribute("type")).." " -.." "..tostring(self:GetAttribute("macrotext")).." " -) -end ---]] if id then local controlFrame = TitanUtils_GetControlFrame(id); @@ -699,7 +604,7 @@ end TitanUtils_CloseAllControlFrames(); TitanPanelRightClickMenu_Close(); --- local position = TitanUtils_GetWhichBar(id) + -- local position = TitanUtils_GetWhichBar(id) if (isControlFrameShown) then -- Note: This uses anchor points to place the control frame relative to the plugin on the screen. local parent = self:GetName() -- plugin with the control frame @@ -747,24 +652,20 @@ end end end ---[[ API -- Used by plugins -NAME: TitanPanelButton_OnEnter -DESC: Handle the OnEnter cursor event of the requested Titan plugin. -VAR: self - frame reference of the plugin -VAR: isChildButton - boolean -NOTE: -- The cursor has moved over the plugin so show the plugin tooltip. -- Save same hassle by doing nothing if the tooltip is already shown or if the cursor is moving. -- If the "is moving" is set the user is dragging this plugin around so do nothing here. -:NOTE ---]] +---API Handle the OnEnter event of the requested Titan plugin. +---@param self table Plugin frame +---@param isChildButton boolean? If is child plugin ! NO LONGER USED ! +--- 1. The cursor has moved over the plugin so show the plugin tooltip. +--- 2. Return if plugin "is moving" or if tooltip is already shown. function TitanPanelButton_OnEnter(self, isChildButton) local id = nil; -- ensure that the 'self' passed is a valid frame reference if self and self:GetName() then - id = TitanUtils_Ternary(isChildButton, +--[[ id = TitanUtils_Ternary(isChildButton, TitanUtils_GetParentButtonID(self:GetName()), TitanUtils_GetButtonID(self:GetName())); +--]] + id = TitanUtils_GetButtonID(self:GetName()) end if (id) then @@ -784,57 +685,57 @@ function TitanPanelButton_OnEnter(self, isChildButton) end end ---[[ API -NAME: TitanPanelButton_OnLeave -DESC: Handle the OnLeave cursor event of the requested Titan plugin. -VAR: self - frame reference of the plugin -VAR: isChildButton - boolean -NOTE: -- The cursor has moved off the plugin so hide the plugin tooltip. -:NOTE ---]] +---API Handle the OnLeave event of the requested Titan plugin. +---@param self table Plugin frame +---@param isChildButton boolean? If is child plugin ! NO LONGER USED ! +--- 1. The cursor has moved over the plugin so hide the plugin tooltip. function TitanPanelButton_OnLeave(self, isChildButton) local id = nil; -- ensure that the 'self' passed is a valid frame reference if self and self:GetName() then - id = TitanUtils_Ternary(isChildButton, - TitanUtils_GetParentButtonID(self:GetName()), - TitanUtils_GetButtonID(self:GetName())); +-- id = TitanUtils_Ternary(isChildButton, +-- TitanUtils_GetParentButtonID(self:GetName()), +-- TitanUtils_GetButtonID(self:GetName())); + id = TitanUtils_GetButtonID(self:GetName()) end if (id) then GameTooltip:Hide(); end - if not TitanPanelGetVar("DisableTooltipFont") then - -- reset original Tooltip Scale + if TitanPanelGetVar("DisableTooltipFont") then + -- use game font & scale + else + -- use Titan font & scale GameTooltip:SetScale(TitanTooltipOrigScale); TitanTooltipScaleSet = 0; end end -- local routines for Update Button ---[[ local -NAME: TitanPanelButton_SetButtonText -DESC: Set / update the text of the given Titan plugin. -VAR: id - string name of the plugin -NOTE: -- The plugin is expected to tell Titan what routine is to be called in .registry.buttonTextFunction. -- The text routine is called in protected mode (pcall) to ensure the Titan main routines still run. -- There are several places that return in this routine. Not best practice but more readable here. -:NOTE ---]] -local format_with_label = { [0] = "" } + + +local format_with_label = { [0] = "" } -- Set format string once for idx = 1, 4 do format_with_label[idx] = "%s%s" .. (TITAN_PANEL_LABEL_SEPARATOR .. "%s%s"):rep(idx - 1) end +---local Set the width of the given icon Titan plugin - icon only. +---@param id string Plugin id +--- The plugin is expected to tell Titan what routine is to be called in .registry.buttonTextFunction. +--- Note: Titan handles up to 4 label-value pairs. User may customize (override) the plugin labels. +--- The text routine is called in protected mode (pcall) to ensure the Titan main routines still run. local function TitanPanelButton_SetButtonText(id) + --- There are several places that return in this routine. Not best practice but more readable. + local dbg_msg = "ptxt : '" .. tostring(id) .. "'" + local ok = false + if (id and TitanUtils_IsPluginRegistered(id)) then -- seems valid, registered plugin + ok = true else -- return silently; The plugin is not registered! -- output here could be a lot and really annoy the user... - return + dbg_msg = dbg_msg .. " | unregistered plugin" end local pdata = TitanUtils_GetPlugin(id) -- get plugin data @@ -845,30 +746,27 @@ local function TitanPanelButton_SetButtonText(id) if type(bFunction) == 'string' then -- Function MUST be in global namespace buttonTextFunction = _G[bFunction] + ok = true elseif type(bFunction) == 'function' then -- Can be global or local to the plugin buttonTextFunction = bFunction + ok = true else - return -- silently leave... + dbg_msg = dbg_msg .. " | invalid function type" + -- silently leave... end - --[[ -print("B text" -.." "..tostring(id).."" -.." "..tostring(type(bFunction)).."" -.." '"..tostring(bFunction).."'" -.." '"..tostring(buttonTextFunction).."'" -) ---]] else - return -- silently leave... + -- silently leave... + dbg_msg = dbg_msg .. " | invalid plugin data" end - if buttonTextFunction then + if ok and buttonTextFunction then local label1, value1, label2, value2, label3, value3, label4, value4 local call_success = false local button = TitanUtils_GetButton(id) -- get plugin frame local buttonText = {} + local text = false if button then buttonText = _G[button:GetName() .. TITAN_PANEL_TEXT]; @@ -885,12 +783,13 @@ print("B text" if call_success then -- All is good + text = true else buttonText:SetText("") - return + dbg_msg = dbg_msg .. " | Err '"..tostring(label1).."'" end else - return + dbg_msg = dbg_msg .. " | invalid plugin id" end --===================================== @@ -901,94 +800,95 @@ print("B text" -- Plugin MUST have been shown at least once. -- In the case of first label only (no value), set the button and return. - if label1 and + if text and + label1 and not (label2 or label3 or label4 or value1 or value2 or value3 or value4) then buttonText:SetText(label1) TitanSetVar(id, "NumLabelsSeen", 1) - return - end - - - local show_label = TitanGetVar(id, "ShowLabelText") - local values = 0 - if label1 or value1 then - values = 1 - if show_label then - if TitanGetVar(id, "CustomLabelTextShow") then - -- override the label per the user - label1 = TitanGetVar(id, "CustomLabelText") - else - end - else - label1 = "" - end - if label2 or value2 then - values = 2 + dbg_msg = dbg_msg .. " | single label; no value | " + else + local show_label = TitanGetVar(id, "ShowLabelText") + local values = 0 + if label1 or value1 then + values = 1 if show_label then - if TitanGetVar(id, "CustomLabel2TextShow") then + if TitanGetVar(id, "CustomLabelTextShow") then -- override the label per the user - label2 = TitanGetVar(id, "CustomLabel2Text") + label1 = TitanGetVar(id, "CustomLabelText") else end else - label2 = "" + label1 = "" end - if label3 or value3 then + if label2 or value2 then + values = 2 if show_label then - if TitanGetVar(id, "CustomLabel3TextShow") then + if TitanGetVar(id, "CustomLabel2TextShow") then -- override the label per the user - label3 = TitanGetVar(id, "CustomLabel3Text") + label2 = TitanGetVar(id, "CustomLabel2Text") else end else - label3 = "" + label2 = "" end - values = 3 - if label4 or value4 then - values = 4 + if label3 or value3 then if show_label then - if TitanGetVar(id, "CustomLabel43TextShow") then + if TitanGetVar(id, "CustomLabel3TextShow") then -- override the label per the user - label4 = TitanGetVar(id, "CustomLabel4Text") + label3 = TitanGetVar(id, "CustomLabel3Text") else end else - label4 = "" + label3 = "" + end + values = 3 + if label4 or value4 then + values = 4 + if show_label then + if TitanGetVar(id, "CustomLabel43TextShow") then + -- override the label per the user + label4 = TitanGetVar(id, "CustomLabel4Text") + else + end + else + label4 = "" + end end end end + dbg_msg = dbg_msg .. " | ok | " .. tostring(values) + else + -- no label or value + -- Do nothing, it could be the right action for the plugin + dbg_msg = dbg_msg .. " | no label or value : " .. tostring(values) end - else - -- no label or value - -- Do nothing, it could be the right action for the plugin - end - TitanSetVar(id, "NumLabelsSeen", values) + TitanSetVar(id, "NumLabelsSeen", values) - -- values tells which format to use from the array - buttonText:SetFormattedText(format_with_label[values], - label1 or "", value1 or "", - label2 or "", value2 or "", - label3 or "", value3 or "", - label4 or "", value4 or "" - ) + -- values tells which format to use from the array + buttonText:SetFormattedText(format_with_label[values], + label1 or "", value1 or "", + label2 or "", value2 or "", + label3 or "", value3 or "", + label4 or "", value4 or "" + ) + end else -- no valid routine to update the plugin text + dbg_msg = dbg_msg .. " | no valid routine found" + end + if Titan_Global.debug.plugin_text then + TitanDebug(dbg_msg, "normal") end end ---[[ local -NAME: TitanPanelButton_SetTextButtonWidth -DESC: Set the text width of the given Titan plugin that is text only. -VAR: id - string name of the plugin -VAR: setButtonWidth - new width -NOTE: -- Titan uses a tolerance setting to prevent endless updating of the text width. -:NOTE ---]] +---local Set the width of the given Titan plugin - text only. +---@param id string Plugin id +---@param setButtonWidth? integer Width in pixels +--- Titan uses a tolerance setting to prevent endless updating of the text width. local function TitanPanelButton_SetTextButtonWidth(id, setButtonWidth) if (id) then local button = TitanUtils_GetButton(id) @@ -1009,14 +909,10 @@ local function TitanPanelButton_SetTextButtonWidth(id, setButtonWidth) end end ---[[ local -NAME: TitanPanelButton_SetIconButtonWidth -DESC: Set the icon width of the given Titan plugin that is icon only. -VAR: id - string name of the plugin -NOTE: -- The plugin is expected to tell Titan what the icon width is in .registry.iconButtonWidth. -:NOTE ---]] +---local Set the width of the given Titan plugin - icon only. +---@param id string Plugin id +--- Wrap up by (re)drawing the plugins on the Bar. +--- Titan uses a tolerance setting to prevent endless updating of the text width. local function TitanPanelButton_SetIconButtonWidth(id) if (id) then local button = TitanUtils_GetButton(id) @@ -1030,16 +926,14 @@ local function TitanPanelButton_SetIconButtonWidth(id) end end ---[[ local -NAME: TitanPanelButton_SetComboButtonWidth -DESC: Set the icon width of the given Titan plugin that is a combo - icon & text. -VAR: id - string name of the plugin -VAR: setButtonWidth - new width -NOTE: -- The plugin is expected to tell Titan what the icon width is in .registry.iconButtonWidth. -:NOTE ---]] +---local Set the width of the given Titan plugin - combo icon & text. +---@param id string Plugin id +---@param setButtonWidth? integer Width in pixels; default to .registry.iconWidth +--- Wrap up by (re)drawing the plugins on the Bar. +--- Titan uses a tolerance setting to prevent endless updating of the text width. local function TitanPanelButton_SetComboButtonWidth(id, setButtonWidth) +-- TODO - ensure this routine is proper - need this param? +-- icon width default to .registry.iconWidth before getting the actual width if (id) then local button = TitanUtils_GetButton(id) if not button then return end -- sanity check @@ -1081,14 +975,13 @@ local function TitanPanelButton_SetComboButtonWidth(id, setButtonWidth) end end ---[[ API -- Used by plugins -NAME: TitanPanelButton_UpdateButton -DESC: Update the display of the given Titan plugin. -VAR: id - string name of the plugin -VAR: setButtonWidth - new width ---]] +---API Update the display of the given Titan plugin. +---@param id string Plugin id +---@param setButtonWidth? integer Width in pixels +--- Use after any change to icon, label, or text (depending on Titan template used) +--- TitanPanelButton_UpdateButton(TITAN_CLOCK_ID) function TitanPanelButton_UpdateButton(id, setButtonWidth) - -- local button, id = TitanUtils_GetButton(id); + -- Used by plugins local plugin = TitanUtils_GetPlugin(id) -- safeguard to avoid errors if plugin and TitanUtils_IsPluginRegistered(id) then @@ -1115,11 +1008,8 @@ function TitanPanelButton_UpdateButton(id, setButtonWidth) end end ---[[ API -- Used by plugins -NAME: TitanPanelButton_UpdateTooltip -DESC: Update the tooltip of the given Titan plugin. -VAR: self - frame reference of the plugin ---]] +---API Update the tooltip of the given Titan plugin. +---@param self table Plugin frame function TitanPanelButton_UpdateTooltip(self) if not self then return end if (GameTooltip:IsOwned(self)) then @@ -1129,15 +1019,91 @@ function TitanPanelButton_UpdateTooltip(self) end end ---[[ API -NAME: TitanPanelButton_SetButtonIcon -DESC: Set the icon of the given Titan plugin. -VAR: id - string name of the plugin -VAR: iconCoords - if given, this is the placing of the icon within the plugin -VAR: iconR - if given, this is the Red (RBG) setting of the icon -VAR: iconG - if given, this is the Green (RBG) setting of the icon -VAR: iconB - if given, this is the Blue (RBG) setting of the icon ---]] +---API Refresh the display of the passed in Titan plugin. +---@param table table | string Either {plugin id, action} OR plugin id +---@param oldarg string? action OR nil +--- This is used by some plugins. It is not used within Titan. +--- Action : +--- 1 = refresh button +--- 2 = refresh tooltip +--- 3 = refresh button and tooltip +function TitanPanelPluginHandle_OnUpdate(table, oldarg) + --- This is used by some plugins. + local id, updateType = nil, nil + -- set the id and updateType + -- old method + if table and type(table) == "string" and oldarg then + id = table + updateType = oldarg + end + -- new method + if table and type(table) == "table" then + if table[1] then id = table[1] end + if table[2] then updateType = table[2] end + end + + -- id is required + if id then + if updateType == TITAN_PANEL_UPDATE_BUTTON + or updateType == TITAN_PANEL_UPDATE_ALL then + TitanPanelButton_UpdateButton(id) + end + + if (updateType == TITAN_PANEL_UPDATE_TOOLTIP + or updateType == TITAN_PANEL_UPDATE_ALL) + and MouseIsOver(_G[TitanUtils_ButtonName(id)]) then + if TitanPanelRightClickMenu_IsVisible() or TITAN_PANEL_MOVING == 1 then + return + end + + TitanPanelButton_SetTooltip(_G[TitanUtils_ButtonName(id)], id) + end + end +end + +---Titan Poorly named routine that sets the OnDragStart & OnDragStop scripts of a Titan plugin. +---@param id string Plugin id +---@param isChildButton boolean? If is child plugin +function TitanPanelDetectPluginMethod(id, isChildButton) + -- Ensure the id is not nil + if not id then return end + local TitanPluginframe = _G[TitanUtils_ButtonName(id)]; +-- if isChildButton then +-- TitanPluginframe = _G[id]; +-- end + -- Ensure the frame is valid + if not TitanPluginframe and TitanPluginframe:GetName() then return end -- sanity check... + + -- Set the OnDragStart script + TitanPluginframe:SetScript("OnDragStart", function(self) + if not IsShiftKeyDown() + and not IsControlKeyDown() + and not IsAltKeyDown() then +-- if isChildButton then +-- TitanPanelButton_OnDragStart(self, true); +-- else + TitanPanelButton_OnDragStart(self); +-- end + end + end) + + -- Set the OnDragStop script + TitanPluginframe:SetScript("OnDragStop", function(self) +-- if isChildButton then +-- TitanPanelButton_OnDragStop(self, true) +-- else + TitanPanelButton_OnDragStop(self); +-- end + end) +end + +---API Set the icon of the given Titan plugin. +---@param id string Plugin id +---@param iconCoords table? As {left, right, top, bottom} +---@param iconR number? Red (.0. - 1.0) +---@param iconG number? Green (.0. - 1.0) +---@param iconB number? Blue (.0. - 1.0) +--- Using TitanPanelButton_UpdateButton is preferred unless coords are needed function TitanPanelButton_SetButtonIcon(id, iconCoords, iconR, iconG, iconB) if (id and TitanUtils_IsPluginRegistered(id)) then local button = TitanUtils_GetButton(id) @@ -1166,16 +1132,12 @@ function TitanPanelButton_SetButtonIcon(id, iconCoords, iconR, iconG, iconB) end end ---[[ Titan -NAME: TitanPanelButton_GetType -DESC: Get the type of the given Titan plugin. -VAR: id - string name of the plugin -OUT: type - The type of the plugin (text, icon, combo (default)) -NOTE: -- This assumes that the developer is playing nice and is using the Titan templates as is... -:NOTE ---]] +---Titan Get the type of the given Titan plugin. +--- This assumes that the developer is playing nice and is using the Titan templates as is... +---@param id string Plugin id name +---@return integer type (text-1, icon-2, combo-3 (default)) function TitanPanelButton_GetType(id) + -- This assumes that the developer is playing nice and is using the Titan templates as is... -- id is required local type = 0 -- unknown if id then @@ -1203,16 +1165,11 @@ function TitanPanelButton_GetType(id) return type end ---[[ Titan -NAME: TitanPanelButton_ApplyBarPos -DESC: Apply saved Bar position to the Bar frame. -VAR: frame_str - string name of the Bar frame -OUT: None -NOTE: -- Bit of a sledge hammer; used when loading a profile over the current so the Bars are properly placed. -:NOTE ---]] +---Titan Apply saved Bar position to the Bar frame. +--- Bit of a sledge hammer; used when loading a profile over the current so the Bars are properly placed. +---@param frame_str string Bar frame name function TitanPanelButton_ApplyBarPos(frame_str) + -- local frame = _G[frame_str] local bdata = TitanBarData[frame_str] if frame then @@ -1226,11 +1183,8 @@ function TitanPanelButton_ApplyBarPos(frame_str) end end ---[[ Titan -NAME: TitanOptionsSliderTemplate_OnLoad -DESC: Loads the Backdrop for TitanOptionsSliderTemplate with new 9.0 API -VAR: self - The frame ---]] +---Titan Loads the Backdrop for TitanOptionsSliderTemplate with new 9.0 API +---@param self table Control frame function TitanOptionsSliderTemplate_OnLoad(self) self:SetBackdrop({ bgFile = "Interface\\Buttons\\UI-SliderBar-Background", diff --git a/Titan/TitanTemplate.xml b/Titan/TitanTemplate.xml index 8c0b2c3..5ebeb7a 100644 --- a/Titan/TitanTemplate.xml +++ b/Titan/TitanTemplate.xml @@ -90,6 +90,7 @@ + @@ -134,7 +135,7 @@ - + TitanOptionsSliderTemplate_OnLoad(self); @@ -144,6 +145,7 @@