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/<server or custom> from the Titan right click menu. -VAR: None -OUT: None ---]] +---local Show alphabetical list of toons submenu off Profiles/Manage/<server or custom> 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/<server or custom>/<profile> from the Titan (right click) menu. -VAR: None -OUT: None ---]] +---local Show save / load submenu off Profiles/Manage/<server or custom>/<profile> 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 <Titan bar name>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 <Titan bar name>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 = "<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 <version> <category - Titan menu> <if LDB>.\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 ---@<tag> 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 <OnLoad> @@ -37,8 +49,13 @@ Each template contains: TitanPanelButton_OnLeave(self); </OnLeave> 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 {<plugin id>, <update command>} -2) table = <plugin id> and oldarg = <update command> -- 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 <self>.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 <self>.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 <self>.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 <self>.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 @@ <AbsDimension x="0" y="0"/> </PushedTextOffset> </Button> + <Slider name="TitanOptionsSliderTemplate" orientation="VERTICAL" inherits="BackdropTemplate" virtual="true" enableMouse="true" > <Size> <AbsDimension x="10" y="100"/> @@ -134,7 +135,7 @@ </Size> </ThumbTexture> <Scripts> - <!-- DF Appears Blizz moved EnableMouseWheel from declaration to code --> + <!-- Draagonflight (DF) Appears Blizz moved EnableMouseWheel from declaration to code --> <OnLoad> TitanOptionsSliderTemplate_OnLoad(self); @@ -144,6 +145,7 @@ </Slider> <GameTooltip name="TitanPanelTooltip" inherits="GameTooltipTemplate" parent="UIParent" hidden="true"/> + <Button name="TitanPanelBarButtonHiderTemplate" frameStrata="BACKGROUND" toplevel="true" movable="true" parent="UIParent" virtual="true"> <Scripts> <OnLoad> diff --git a/Titan/TitanUtils.lua b/Titan/TitanUtils.lua index b7c09e7..96a345a 100644 --- a/Titan/TitanUtils.lua +++ b/Titan/TitanUtils.lua @@ -1,8 +1,11 @@ ---[[ File -NAME: TitanUtils.lua -DESC: This file contains various utility routines used by Titan and routines available to plugin developers. -Nov 2023 : merge Retail and Classic to min versions and maintainence and, hopefully, allow a consistent feature set. ---]] +--[===[ File +This large file contains various utility routines used by +- Titan +- Plugin developers for strings; create menus; and more +- Addon developers that want to know which Titan full bars is on the UI + +Nov 2023 : Merge Retail and Classic to minimize versions and maintainence and, hopefully, allow a consistent feature set. +--]===] local _G = getfenv(0); local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) @@ -10,253 +13,310 @@ local media = LibStub("LibSharedMedia-3.0") local drop_down_1 = "" -- changes if using Blizz drop down (retail) or lib (Classic) ---====== Set the default drop down menu per retail or Classic +--====== Set the default drop down menu routines per retail or Classic if TITAN_ID == "TitanClassic" then - drop_down_1 = "L_DropDownList1" -- The LibUIDropDownMenu lib is used over the Blizzard frame + drop_down_1 = "L_DropDownList1" -- The LibUIDropDownMenu lib is used over the Blizzard frame else -- The LibUIDropDownMenu lib is used over the Blizzard frame drop_down_1 = "DropDownList1" -- Boo!! Per hard-coded Blizz UIDropDownMenu.lua end ---====== Classic routines for a drop down menu lib +--[===[ Var API Dropdown Menu wrappers +Right click menu routines for plugins +The expected frame name of the plugin is: +"TitanPanelRightClickMenu_Prepare"..<registry.id>.."Menu" + +local drop_down_1 = "" -- changes if using Blizz drop down (retail) or lib (Classic) +Blizzard hard-codes the value... + +The Titan routines abstract the menu creation built into WoW. + +Whenever there is a change to the menu routines, the abstractions : +- Insulate 3rd party Titan plugin authors from Blizz or lib changes. +- Allow better maintainance by updating Utils rather than updating Titan using search & replace. + +Titan uses TITAN_ID to determine which version of the abstracted routines to use! + +The Ace lib was replaced with the Blizzard drop down routines in Dec 2018. +Then in 8.0.0 (Dec 2023) Titan combined its three versions into a single release. +With the inclusion of Retail and Classic (Wrath) and Classic Era, the Ace drop down wrappers were added back. + +Classic: +The L_* routines wrap the drop down menu API from Ace for Titan Classic plugins. +The individual routines are not annotated for the API doc. See TitanUtils for the full list. + +Titn handles Retail vs Classic using the TITAN_ID. Only declaring the L_* if Classic. +--]===] --[[ ====== Classic routines for a drop down menu lib Messy but declare the lib routines used in the Classic versions --]] if TITAN_ID == "TitanClassic" then + local DDM = LibStub:GetLibrary("LibUIDropDownMenu-4.0") -local DDM = LibStub:GetLibrary("LibUIDropDownMenu-4.0") + -- + -- Wrap the drop down lib 4.0 to look like 2.0 to keep current plugins the same + -- These need to be global to act like the older version + -- + -- L_UIDropDownMenuDelegate_OnAttributeChanged -- Different in 4.0 + function L_UIDropDownMenu_InitializeHelper(frame) + DDM:UIDropDownMenu_InitializeHelper(frame) + end --- --- Wrap the drop down lib 4.0 to look like 2.0 to keep current plugins the same --- These need to be global to act like the older version --- --- L_UIDropDownMenuDelegate_OnAttributeChanged -- Different in 4.0 -function L_UIDropDownMenu_InitializeHelper (frame) - DDM:UIDropDownMenu_InitializeHelper (frame) -end -function L_Create_UIDropDownMenu(name, parent) - local str = "" - if type(name) == "table" then - str = name:GetName() - else - str = name + function L_Create_UIDropDownMenu(name, parent) + local str = "" + if type(name) == "table" then + str = name:GetName() + else + str = name + end + return DDM:Create_UIDropDownMenu(name, parent) end - return DDM:Create_UIDropDownMenu(name, parent) -end -function L_UIDropDownMenu_Initialize(frame, initFunction, displayMode, level, menuList) - DDM:UIDropDownMenu_Initialize(frame, initFunction, displayMode, level, menuList) -end -function L_UIDropDownMenu_SetInitializeFunction(frame, initFunction) - DDM:UIDropDownMenu_SetInitializeFunction(frame, initFunction) -end -function L_UIDropDownMenu_SetDisplayMode(frame, displayMode) - DDM:UIDropDownMenu_SetDisplayMode(frame, displayMode) -end -function L_UIDropDownMenu_RefreshDropDownSize(self) - DDM:UIDropDownMenu_RefreshDropDownSize(self) -end ---function L_UIDropDownMenu_OnUpdate(self, elapsed) -- Different in 4.0 -function L_UIDropDownMenu_StartCounting(frame) - DDM:UIDropDownMenu_StartCounting(frame) -end -function L_UIDropDownMenu_StopCounting(frame) - DDM:UIDropDownMenu_StopCounting(frame) -end ---function L_UIDropDownMenuButtonInvisibleButton_OnEnter(self)) -- Different in 4.0 ---function L_UIDropDownMenuButtonInvisibleButton_OnLeave(self)) -- Different in 4.0 ---function L_UIDropDownMenuButton_OnEnter(self) -- Different in 4.0 ---function L_UIDropDownMenuButton_OnLeave(self) -- Different in 4.0 -function L_UIDropDownMenu_CreateInfo() - return DDM:UIDropDownMenu_CreateInfo() -end -function L_UIDropDownMenu_CreateFrames(level, index) - DDM:UIDropDownMenu_CreateFrames(level, index) -end -function L_UIDropDownMenu_AddSeparator(level) - DDM:UIDropDownMenu_AddSeparator(level) -end -function L_UIDropDownMenu_AddSpace(level) -- new in 4.0 - DDM:UIDropDownMenu_AddSpace(level) -end -function L_UIDropDownMenu_AddButton(info, level) - DDM:UIDropDownMenu_AddButton(info, level) -end -function L_UIDropDownMenu_CheckAddCustomFrame(self, button, info) - DDM:UIDropDownMenu_CheckAddCustomFrame(self, button, info) -end -function L_UIDropDownMenu_RegisterCustomFrame(self, customFrame) - DDM:UIDropDownMenu_RegisterCustomFrame(self, customFrame) -end -function L_UIDropDownMenu_GetMaxButtonWidth(self) - return DDM:UIDropDownMenu_GetMaxButtonWidth(self) -end -function L_UIDropDownMenu_GetButtonWidth(button) - return DDM:UIDropDownMenu_GetButtonWidth(button) -end -function L_UIDropDownMenu_Refresh(frame, useValue, dropdownLevel) - DDM:UIDropDownMenu_Refresh(frame, useValue, dropdownLevel) -end -function L_UIDropDownMenu_RefreshAll(frame, useValue) - DDM:UIDropDownMenu_RefreshAll(frame, useValue) -end -function L_UIDropDownMenu_SetIconImage(icon, texture, info) - DDM:UIDropDownMenu_SetIconImage(icon, texture, info) -end -function L_UIDropDownMenu_SetSelectedName(frame, name, useValue) - DDM:UIDropDownMenu_SetSelectedName(frame, name, useValue) -end -function L_UIDropDownMenu_SetSelectedValue(frame, value, useValue) - DDM:UIDropDownMenu_SetSelectedValue(frame, value, useValue) -end -function L_UIDropDownMenu_SetSelectedID(frame, id, useValue) - DDM:UIDropDownMenu_SetSelectedID(frame, id, useValue) -end -function L_UIDropDownMenu_GetSelectedName(frame) - return DDM:UIDropDownMenu_GetSelectedName(frame) -end -function L_UIDropDownMenu_GetSelectedID(frame) - return DDM:UIDropDownMenu_GetSelectedID(frame) -end -function L_UIDropDownMenu_GetSelectedValue(frame) - return DDM:UIDropDownMenu_GetSelectedValue(frame) -end ---function L_UIDropDownMenuButton_OnClick(self) -- Different in 4.0 -function L_HideDropDownMenu(level) - DDM:HideDropDownMenu(level) -end -function L_ToggleDropDownMenu(level, value, dropDownFrame, anchorName, xOffset, yOffset, menuList, button, autoHideDelay) - DDM:ToggleDropDownMenu(level, value, dropDownFrame, anchorName, xOffset, yOffset, menuList, button, autoHideDelay) -end -function L_CloseDropDownMenus(level) - DDM:CloseDropDownMenus(level) -end ---function L_UIDropDownMenu_OnHide(self) -- Different in 4.0 --- 4.0 has 'contains mouse' routines for retail only -function L_UIDropDownMenu_SetWidth(frame, width, padding) - DDM:UIDropDownMenu_SetWidth(frame, width, padding) -end -function L_UIDropDownMenu_SetButtonWidth(frame, width) - DDM:UIDropDownMenu_SetButtonWidth(frame, width) -end -function L_UIDropDownMenu_SetText(frame, text) - DDM:UIDropDownMenu_SetText(frame, text) -end -function L_UIDropDownMenu_GetText(frame) - return DDM:UIDropDownMenu_GetText(frame) -end -function L_UIDropDownMenu_ClearAll(frame) - DDM:UIDropDownMenu_ClearAll(frame) -end -function L_UIDropDownMenu_JustifyText(frame, justification) - DDM:UIDropDownMenu_JustifyText(frame, justification) -end -function L_UIDropDownMenu_SetAnchor(dropdown, xOffset, yOffset, point, relativeTo, relativePoint) - DDM:UIDropDownMenu_SetAnchor(dropdown, xOffset, yOffset, point, relativeTo, relativePoint) -end -function L_UIDropDownMenu_GetCurrentDropDown() - return DDM:UIDropDownMenu_GetCurrentDropDown() -end -function L_UIDropDownMenuButton_GetChecked(self) - return DDM:UIDropDownMenuButton_GetChecked(self) -end -function L_UIDropDownMenuButton_GetName(self) - return DDM:UIDropDownMenuButton_GetName(self) -end -function L_UIDropDownMenuButton_OpenColorPicker(self, button) - DDM:UIDropDownMenuButton_OpenColorPicker(self, button) -end -function L_UIDropDownMenu_DisableButton(level, id) - DDM:UIDropDownMenu_DisableButton(level, id) -end -function L_UIDropDownMenu_EnableButton(level, id) - DDM:UIDropDownMenu_EnableButton(level, id) -end -function L_UIDropDownMenu_SetButtonText(level, id, text, colorCode) - DDM:UIDropDownMenu_SetButtonText(level, id, text, colorCode) -end -function L_UIDropDownMenu_SetButtonNotClickable(level, id) - DDM:UIDropDownMenu_SetButtonNotClickable(level, id) -end -function L_UIDropDownMenu_SetButtonClickable(level, id) - DDM:UIDropDownMenu_SetButtonClickable(level, id) -end -function L_UIDropDownMenu_DisableDropDown(dropDown) - DDM:UIDropDownMenu_DisableDropDown(dropDown) -end -function L_UIDropDownMenu_EnableDropDown(dropDown) - DDM:UIDropDownMenu_EnableDropDown(dropDown) -end -function L_UIDropDownMenu_IsEnabled(dropDown) - return DDM:UIDropDownMenu_IsEnabled(dropDown) -end -function L_UIDropDownMenu_GetValue(id) - return DDM:UIDropDownMenu_GetValue(id) -end -function L_OpenColorPicker(info) - DDM:OpenColorPicker(info) -end -function L_ColorPicker_GetPreviousValues() - return DDM:ColorPicker_GetPreviousValues() -end -else -- only retail (may change as Blizz expands API to Classic versions) - ---[[ API -NAME: TitanUtils_GetMinimapAdjust -DESC: Return the current setting of the Titan MinimapAdjust option. -VAR: None -OUT: The value of the MinimapAdjust option ---]] -function TitanUtils_GetMinimapAdjust() -- Used by addons - return not TitanPanelGetVar("MinimapAdjust") -end ---[[ API -NAME: TitanUtils_SetMinimapAdjust -DESC: Set the current setting of the Titan MinimapAdjust option. -VAR: bool - true (off) or false (on) -OUT: None ---]] -function TitanUtils_SetMinimapAdjust(bool) -- Used by addons - -- This routine allows an addon to turn on or off - -- the Titan minimap adjust. - TitanPanelSetVar("MinimapAdjust", not bool) -end + function L_UIDropDownMenu_Initialize(frame, initFunction, displayMode, level, menuList) + DDM:UIDropDownMenu_Initialize(frame, initFunction, displayMode, level, menuList) + end ---[[ API -NAME: TitanUtils_AddonAdjust -DESC: Tell Titan to adjust (or not) a frame. -VAR: frame - is the name (string) of the frame -VAR: bool - true if the addon will adjust the frame or false if Titan will adjust -OUT: None -Note: -- Titan will NOT store the adjust value across a log out / exit. -- This is a generic way for an addon to tell Titan to not adjust a frame. The addon will take responsibility for adjusting that frame. This is useful for UI style addons so the user can run Titan and a modifed UI. -- The list of frames Titan adjusts is specified in TitanMovableData within TitanMovable.lua. -- If the frame name is not in TitanMovableData then Titan does not adjust that frame. -:NOTE ---]] -function TitanUtils_AddonAdjust(frame, bool) -- Used by addons - TitanMovable_AddonAdjust(frame, bool) -end + function L_UIDropDownMenu_SetInitializeFunction(frame, initFunction) + DDM:UIDropDownMenu_SetInitializeFunction(frame, initFunction) + end + + function L_UIDropDownMenu_SetDisplayMode(frame, displayMode) + DDM:UIDropDownMenu_SetDisplayMode(frame, displayMode) + end + + function L_UIDropDownMenu_RefreshDropDownSize(self) + DDM:UIDropDownMenu_RefreshDropDownSize(self) + end + + --function L_UIDropDownMenu_OnUpdate(self, elapsed) -- Different in 4.0 + function L_UIDropDownMenu_StartCounting(frame) + DDM:UIDropDownMenu_StartCounting(frame) + end + + function L_UIDropDownMenu_StopCounting(frame) + DDM:UIDropDownMenu_StopCounting(frame) + end + + --function L_UIDropDownMenuButtonInvisibleButton_OnEnter(self)) -- Different in 4.0 + --function L_UIDropDownMenuButtonInvisibleButton_OnLeave(self)) -- Different in 4.0 + --function L_UIDropDownMenuButton_OnEnter(self) -- Different in 4.0 + --function L_UIDropDownMenuButton_OnLeave(self) -- Different in 4.0 + function L_UIDropDownMenu_CreateInfo() + return DDM:UIDropDownMenu_CreateInfo() + end + + function L_UIDropDownMenu_CreateFrames(level, index) + DDM:UIDropDownMenu_CreateFrames(level, index) + end + + function L_UIDropDownMenu_AddSeparator(level) + DDM:UIDropDownMenu_AddSeparator(level) + end + + function L_UIDropDownMenu_AddSpace(level) -- new in 4.0 + DDM:UIDropDownMenu_AddSpace(level) + end + + function L_UIDropDownMenu_AddButton(info, level) + DDM:UIDropDownMenu_AddButton(info, level) + end + + function L_UIDropDownMenu_CheckAddCustomFrame(self, button, info) + DDM:UIDropDownMenu_CheckAddCustomFrame(self, button, info) + end + + function L_UIDropDownMenu_RegisterCustomFrame(self, customFrame) + DDM:UIDropDownMenu_RegisterCustomFrame(self, customFrame) + end + + function L_UIDropDownMenu_GetMaxButtonWidth(self) + return DDM:UIDropDownMenu_GetMaxButtonWidth(self) + end + + function L_UIDropDownMenu_GetButtonWidth(button) + return DDM:UIDropDownMenu_GetButtonWidth(button) + end + + function L_UIDropDownMenu_Refresh(frame, useValue, dropdownLevel) + DDM:UIDropDownMenu_Refresh(frame, useValue, dropdownLevel) + end + + function L_UIDropDownMenu_RefreshAll(frame, useValue) + DDM:UIDropDownMenu_RefreshAll(frame, useValue) + end + + function L_UIDropDownMenu_SetIconImage(icon, texture, info) + DDM:UIDropDownMenu_SetIconImage(icon, texture, info) + end + + function L_UIDropDownMenu_SetSelectedName(frame, name, useValue) + DDM:UIDropDownMenu_SetSelectedName(frame, name, useValue) + end + + function L_UIDropDownMenu_SetSelectedValue(frame, value, useValue) + DDM:UIDropDownMenu_SetSelectedValue(frame, value, useValue) + end + + function L_UIDropDownMenu_SetSelectedID(frame, id, useValue) + DDM:UIDropDownMenu_SetSelectedID(frame, id, useValue) + end + + function L_UIDropDownMenu_GetSelectedName(frame) + return DDM:UIDropDownMenu_GetSelectedName(frame) + end + + function L_UIDropDownMenu_GetSelectedID(frame) + return DDM:UIDropDownMenu_GetSelectedID(frame) + end + + function L_UIDropDownMenu_GetSelectedValue(frame) + return DDM:UIDropDownMenu_GetSelectedValue(frame) + end + + --function L_UIDropDownMenuButton_OnClick(self) -- Different in 4.0 + function L_HideDropDownMenu(level) + DDM:HideDropDownMenu(level) + end + + function L_ToggleDropDownMenu(level, value, dropDownFrame, anchorName, xOffset, yOffset, menuList, button, + autoHideDelay) + DDM:ToggleDropDownMenu(level, value, dropDownFrame, anchorName, xOffset, yOffset, menuList, button, autoHideDelay) + end + + function L_CloseDropDownMenus(level) + DDM:CloseDropDownMenus(level) + end + + --function L_UIDropDownMenu_OnHide(self) -- Different in 4.0 + -- 4.0 has 'contains mouse' routines for retail only + function L_UIDropDownMenu_SetWidth(frame, width, padding) + DDM:UIDropDownMenu_SetWidth(frame, width, padding) + end + + function L_UIDropDownMenu_SetButtonWidth(frame, width) + DDM:UIDropDownMenu_SetButtonWidth(frame, width) + end + + function L_UIDropDownMenu_SetText(frame, text) + DDM:UIDropDownMenu_SetText(frame, text) + end + + function L_UIDropDownMenu_GetText(frame) + return DDM:UIDropDownMenu_GetText(frame) + end + + function L_UIDropDownMenu_ClearAll(frame) + DDM:UIDropDownMenu_ClearAll(frame) + end + + function L_UIDropDownMenu_JustifyText(frame, justification) + DDM:UIDropDownMenu_JustifyText(frame, justification) + end + + function L_UIDropDownMenu_SetAnchor(dropdown, xOffset, yOffset, point, relativeTo, relativePoint) + DDM:UIDropDownMenu_SetAnchor(dropdown, xOffset, yOffset, point, relativeTo, relativePoint) + end + + function L_UIDropDownMenu_GetCurrentDropDown() + return DDM:UIDropDownMenu_GetCurrentDropDown() + end + + function L_UIDropDownMenuButton_GetChecked(self) + return DDM:UIDropDownMenuButton_GetChecked(self) + end + + function L_UIDropDownMenuButton_GetName(self) + return DDM:UIDropDownMenuButton_GetName(self) + end + + function L_UIDropDownMenuButton_OpenColorPicker(self, button) + DDM:UIDropDownMenuButton_OpenColorPicker(self, button) + end + + function L_UIDropDownMenu_DisableButton(level, id) + DDM:UIDropDownMenu_DisableButton(level, id) + end + + function L_UIDropDownMenu_EnableButton(level, id) + DDM:UIDropDownMenu_EnableButton(level, id) + end + + function L_UIDropDownMenu_SetButtonText(level, id, text, colorCode) + DDM:UIDropDownMenu_SetButtonText(level, id, text, colorCode) + end + + function L_UIDropDownMenu_SetButtonNotClickable(level, id) + DDM:UIDropDownMenu_SetButtonNotClickable(level, id) + end + + function L_UIDropDownMenu_SetButtonClickable(level, id) + DDM:UIDropDownMenu_SetButtonClickable(level, id) + end + + function L_UIDropDownMenu_DisableDropDown(dropDown) + DDM:UIDropDownMenu_DisableDropDown(dropDown) + end + + function L_UIDropDownMenu_EnableDropDown(dropDown) + DDM:UIDropDownMenu_EnableDropDown(dropDown) + end + + function L_UIDropDownMenu_IsEnabled(dropDown) + return DDM:UIDropDownMenu_IsEnabled(dropDown) + end + + function L_UIDropDownMenu_GetValue(id) + return DDM:UIDropDownMenu_GetValue(id) + end + + function L_OpenColorPicker(info) + DDM:OpenColorPicker(info) + end + function L_ColorPicker_GetPreviousValues() + return DDM:ColorPicker_GetPreviousValues() + end +else -- only retail (may change as Blizz expands API to Classic versions) + ---API Return the current setting of the Titan MinimapAdjust option. + ---@return boolean boolean Adjust + function TitanUtils_GetMinimapAdjust() + -- Used by addons + return not TitanPanelGetVar("MinimapAdjust") + end + + ---API Allows an addon to turn on or off whether Titan adjusts mini map (MinimapAdjust). + ---@param bool boolean Adjust + function TitanUtils_SetMinimapAdjust(bool) + -- Used by addons + TitanPanelSetVar("MinimapAdjust", not bool) + end + + ---API Tell Titan to adjust (or not) a frame. Allows an addon to tell Titan it will control adjustment of that frame. + ---@param frame string Frame Titan adjusts + ---@param bool boolean Adjust + ---- Titan will NOT store the adjust value across a log out / exit. + ---- This is a generic way for an addon to tell Titan to not adjust a frame. + ---The addon will take responsibility for adjusting that frame. + ---This is useful for UI style addons so the user can run Titan and a modifed UI. + ---- The list of frames Titan adjusts is specified in TitanMovableData within TitanMovable.lua. + ---- If the frame name is not in TitanMovableData then Titan does not adjust that frame. + ---- The frame list is different across the WoW versions. + --- TitanMovable_AddonAdjust("MicroButtonAndBagsBar", true) + function TitanUtils_AddonAdjust(frame, bool) + -- Used by addons + TitanMovable_AddonAdjust(frame, bool) + end end -- Retail versus retail routines --====== The routines labeled API are useable by addon developers ---[[ API -- Used by addons -NAME: TitanUtils_GetBarAnchors -DESC: Get the anchors of the bottom most top bar and the top most bottom bar. - Intended for addons that modify the UI so they can adjust for Titan. - The anchors adjust depending on what Titan bars the user displays. -:DESC -VAR: None -OUT: frame - TitanPanelTopAnchor frame reference - Titan uses the space ABOVE this -OUT: frame - TitanPanelBottomAnchor frame reference - Titan uses the space BELOW this -NOTE: -- The two anchors are implemented as 2 frames that are moved by Titan depending on which bars are shown. -:NOTE ---]] +---API Get the anchors of the bottom most top bar and the top most bottom bar. +---@return table Top +---@return table Bottom +---Intended for addons that modify the UI so they can adjust for Titan full bars. +---The two anchors are implemented as 2 frames that are moved by Titan depending on which full bars are shown. function TitanUtils_GetBarAnchors() + -- Used by addons return TitanPanelTopAnchor, TitanPanelBottomAnchor end @@ -264,44 +324,35 @@ end -- -- Plugin button search & manipulation routines -- ---[[ API -NAME: TitanUtils_ButtonName -DESC: Create the button name from plugin id. -VAR: id - is the id of the plugin -OUT: string - The button / frame name ---]] + + +---API Create the button name from plugin id. +---@param id string Unique ID of the plugin +---@return string? FrameName function TitanUtils_ButtonName(id) if (id) then - return Titan_Global.plugin.PRE..id..Titan_Global.plugin.POST + return Titan_Global.plugin.PRE .. id .. Titan_Global.plugin.POST else return nil end end ---[[ API : Used by plugins -NAME: TitanUtils_GetButton -DESC: Return the actual button frame and the plugin id. ---]] +---API Return the actual button frame and the plugin id. ---@param id string Unique ID of the plugin ---@return table? frame Frame of the plugin ---@return string? id Unique ID of the plugin function TitanUtils_GetButton(id) + -- API : Used by plugins if (id) then - return _G[Titan_Global.plugin.PRE..id..Titan_Global.plugin.POST], id; + return _G[Titan_Global.plugin.PRE .. id .. Titan_Global.plugin.POST], id; else return nil, nil; end end ---[[ API -- Used by plugins -NAME: TitanUtils_GetRealPosition -DESC: Return whether the plugin is on the top or bottom bar. -VAR: id - is the id of the plugin -OUT: bottom(2) or top(1)-default -NOTE: -- This returns top or bottom NOT which bar (1-4) the plugin is on. -:NOTE ---]] +---API Return whether the plugin is on top (1) or bottom (2) full bar - NOT which bar. +---@param id string Plugin name +---@return number? PluginId function TitanUtils_GetRealPosition(id) -- This will return top / bottom but it is a compromise. -- With the introduction of independent bars there is @@ -310,7 +361,7 @@ function TitanUtils_GetRealPosition(id) -- would overlap the double bar. local bar = TitanUtils_GetWhichBar(id) local bar_pos = nil - for idx,v in pairs (TitanBarData) do + for idx, v in pairs(TitanBarData) do if bar == TitanBarData[idx].name then bar_pos = TitanBarData[idx].vert end @@ -318,44 +369,33 @@ function TitanUtils_GetRealPosition(id) return (bar_pos == TITAN_BOTTOM and TITAN_PANEL_PLACE_BOTTOM or TITAN_PANEL_PLACE_TOP) end ---[[ API -NAME: TitanUtils_GetButtonID -DESC: Return the plugin id of the given name. This can be used to see if a plugin exists. -VAR: name - is the id of the plugin -OUT: string - plugin id or nil ---]] +---API Return the plugin id from the frame name +---@param name string Plugin frame name +---@return string? PluginId function TitanUtils_GetButtonID(name) if name then - local s, e, id = string.find(name, Titan_Global.plugin.PRE.."(.*)"..Titan_Global.plugin.POST); + local s, e, id = string.find(name, Titan_Global.plugin.PRE .. "(.*)" .. Titan_Global.plugin.POST); return id; else return nil; end end ---[[ API -NAME: TitanUtils_GetParentButtonID -DESC: Return the plugin id of the parent of the given name, if it exists. -VAR: name - is the id of the plugin -OUT: string - plugin id or nil ---]] +---Titan Return the plugin id of the parent of the given name, if it exists. +---@param name string Plugin frame name +---@return string? PluginId +---Used for Titan child templates which may not work... function TitanUtils_GetParentButtonID(name) local frame = TitanUtils_Ternary(name, _G[name], nil); - if ( frame and frame:GetParent() ) then + if (frame and frame:GetParent()) then return TitanUtils_GetButtonID(frame:GetParent():GetName()); end end ---[[ API -NAME: TitanUtils_GetButtonIDFromMenu -DESC: Return the plugin id of whatever the mouse is over. Used in the right click menu on load. -VAR: self - is the id of the frame -OUT: string - plugin id or nil -NOTE: -- The plugin id returned could be the Titan bar or a plugin or nil. -:NOTE ---]] +---Titan Return the plugin id of whatever the mouse is over. Used in the right click menu on load. +---@param self table Plugin frame +---@return string? PluginId could be the Titan ("Bar") or a plugin or nil. function TitanUtils_GetButtonIDFromMenu(self) local ret = nil local temp @@ -384,22 +424,19 @@ function TitanUtils_GetButtonIDFromMenu(self) ret = temp else TitanDebug("Could not determine Titan ID for '" - ..(self:GetParent():GetParent() or "?").."'. " - ,"error") + .. (self:GetParent():GetParent() or "?") .. "'. " + , "error") end end else TitanDebug("Could not determine Titan ID from menu. " - ,"error") + , "error") end return ret end ---[[ API -NAME: TitanUtils_GetPlugin -DESC: Return the plugin itself (table and all). ---]] +---Titan Return the plugin itself (table and all). ---@param id string Unique ID of the plugin ---@return table? table plugin data function TitanUtils_GetPlugin(id) @@ -410,13 +447,10 @@ function TitanUtils_GetPlugin(id) end end ---[[ API -NAME: TitanUtils_GetWhichBar -DESC: Return the bar the plugin is shown on. -VAR: id - is the id of the plugin -OUT: string - internal bar name or nil -OUT: string - locale bar name or nil ---]] +---Titan Return the bar the plugin is shown on. +---@param id string? +---@return string? ShortName +---@return string? LocaleName function TitanUtils_GetWhichBar(id) local i = TitanPanel_GetButtonNumber(id); if TitanPanelSettings.Location[i] == nil then @@ -424,7 +458,7 @@ function TitanUtils_GetWhichBar(id) else local internal = TitanPanelSettings.Location[i] local locale = "" - for _,v in pairs (TitanBarData) do + for _, v in pairs(TitanBarData) do if v.name == internal then locale = v.locale_name else @@ -435,18 +469,14 @@ function TitanUtils_GetWhichBar(id) end end ---[[ API -NAME: TitanUtils_PickBar -DESC: Return the first bar that is shown. -VAR: None -OUT: string - bar name or nil ---]] +---Titan Return the first bar that is shown. +---@return string? Bar function TitanUtils_PickBar() -- Pick the 'first' bar shown per the Titan defined order. -- This is used for defaulting where plugins are put -- if using the Titan options screen. local bar_list = {} - for _,v in pairs (TitanBarData) do + for _, v in pairs(TitanBarData) do bar_list[v.order] = v end table.sort(bar_list, function(a, b) @@ -463,21 +493,18 @@ function TitanUtils_PickBar() return nil end ---[[ API -NAME: TitanUtils_ToRight -DESC: See if the plugin is to be on the right. - These are the methods to place a plugin on the right: +---Titan See if the plugin is to be on the right. +---@param id string? +---@return boolean Found +function TitanUtils_ToRight(id) + --[[ +These are the methods to place a plugin on the right: 1) DisplayOnRightSide saved variable logic (preferred) 2) Place a plugin in TITAN_PANEL_NONMOVABLE_PLUGINS (NOT preferred) -:DESC -VAR: None -OUT: bool - true or nil. true if the plugin is to be placed on the right side of a bar. -NOTE: -- Using the Titan template TitanPanelIconTemplate used to enforce right side only but was removed during DragonFlight to give users more flexibility. -:NOTE +Using the Titan template TitanPanelIconTemplate used to enforce right side only +but was removed during DragonFlight to give users more flexibility. --]] -function TitanUtils_ToRight(id) - local found = nil + local found = false for index, _ in ipairs(TITAN_PANEL_NONMOVABLE_PLUGINS) do if id == TITAN_PANEL_NONMOVABLE_PLUGINS[index] then found = true; @@ -493,14 +520,12 @@ end --====== General util routines ---[[ API -- Used by plugins -NAME: TitanUtils_Ternary -DESC: Return b or c if true or false respectively -VAR: a - value to determine true or false -VAR: b - value to use if true -VAR: c - value to use if false or nil -OUT: value - b (true) or c (false) ---]] +---API Return b (a = true) or c (a = false) +---@param a any +---@param b any +---@param c any +---@return any Tern +--- Typically used for saved variables check. Takes 'any' so relies on Lua T/F determination. function TitanUtils_Ternary(a, b, c) if (a) then return b; @@ -509,13 +534,11 @@ function TitanUtils_Ternary(a, b, c) end end ---[[ API -- Used by plugins -NAME: TitanUtils_Toggle -DESC: Flip the value assuming it is true or false -VAR: value - value to start with -OUT: bool - true or false ---]] -function TitanUtils_Toggle(value) +---API Toggle value : (true or 1) return nil else return 1 +---@param value boolean | number +---@return number? 1 or nil +--- Making this true / false would probably break Titan and a bunch of addons... +function TitanUtils_Toggle(value) if (value == 1 or value == true) then return nil; else @@ -523,42 +546,31 @@ function TitanUtils_Toggle(value) end end ---[[ API -NAME: TitanUtils_Min -DESC: Return the min of a or b -VAR: a - a value -VAR: b - a value -OUT: -- value of min (a, b) ---]] +---API Return min of a or b +---@param a any +---@param b any +---@return any Min function TitanUtils_Min(a, b) if (a and b) then --- return ( a < b ) and a or b + -- return ( a < b ) and a or b return TitanUtils_Ternary((a < b), a, b); end end ---[[ API -NAME: TitanUtils_Max -DESC: Return the max of a or b -VAR: a - a value -VAR: b - a value -OUT: value - value of max (a, b) ---]] +---API Return max of a or b +---@param a any +---@param b any +---@return any Max function TitanUtils_Max(a, b) if (a and b) then return TitanUtils_Ternary((a > b), a, b); ---- return ( a > b ) and a or b + --- return ( a > b ) and a or b end end ---[[ API -NAME: TitanUtils_Round -DESC: Return the nearest integer -VAR: v - a value -OUT: -- value of nearest integer ---]] +---API Return the rounded up number +---@param v number +---@return number Rounded_value function TitanUtils_Round(v) local f = math.floor(v) if v == f then @@ -568,16 +580,14 @@ function TitanUtils_Round(v) end end ---[[ local -NAME: GetTimeParts -DESC: Use the seconds (s) to return its parts. -VAR: s - a time value in seconds -OUT: int - days -OUT: int - hours -OUT: int - minutes -OUT: int - seconds ---]] -local function GetTimeParts(s) +---local return elapsed time from seconds given - spaces and leaving off the rest +---@param seconds_value number +---@return number days +---@return number hours +---@return number minutes +---@return number seconds +local function GetTimeParts(seconds_value) + local s = seconds_value local days = 0 local hours = 0 local minutes = 0 @@ -585,109 +595,95 @@ local function GetTimeParts(s) if not s or (s < 0) then seconds = -1 else - days = floor(s/24/60/60); s = mod(s, 24*60*60); - hours = floor(s/60/60); s = mod(s, 60*60); - minutes = floor(s/60); s = mod(s, 60); + days = floor(s / 24 / 60 / 60); s = mod(s, 24 * 60 * 60); + hours = floor(s / 60 / 60); s = mod(s, 60 * 60); + minutes = floor(s / 60); s = mod(s, 60); seconds = s; end return days, hours, minutes, seconds end ---[[ API -NAME: TitanUtils_GetEstTimeText -DESC: Use the seconds (s) to return an estimated time. -VAR: s - a time value in seconds -OUT: string - string with localized, estimated elapsed time using spaces and leaving off the rest ---]] -function TitanUtils_GetEstTimeText(s) +---API return a elapsed time from seconds given - spaces and leaving off the rest +---@param seconds_value number +---@return string Time that is readable +function TitanUtils_GetEstTimeText(seconds_value) local timeText = ""; - local days, hours, minutes, seconds = GetTimeParts(s) - local fracdays = days + (hours/24); - local frachours = hours + (minutes/60); + local days, hours, minutes, seconds = GetTimeParts(seconds_value) + local fracdays = days + (hours / 24); + local frachours = hours + (minutes / 60); if seconds == -1 then timeText = L["TITAN_PANEL_NA"]; else if (days ~= 0) then - timeText = timeText..format("%4.1f"..L["TITAN_PANEL_DAYS_ABBR"].." ", fracdays); + timeText = timeText .. format("%4.1f" .. L["TITAN_PANEL_DAYS_ABBR"] .. " ", fracdays); elseif (days ~= 0 or hours ~= 0) then - timeText = timeText..format("%4.1f"..L["TITAN_PANEL_HOURS_ABBR"].." ", frachours); + timeText = timeText .. format("%4.1f" .. L["TITAN_PANEL_HOURS_ABBR"] .. " ", frachours); elseif (days ~= 0 or hours ~= 0 or minutes ~= 0) then - timeText = timeText..format("%d"..L["TITAN_PANEL_MINUTES_ABBR"].." ", minutes); + timeText = timeText .. format("%d" .. L["TITAN_PANEL_MINUTES_ABBR"] .. " ", minutes); else - timeText = timeText..format("%d"..L["TITAN_PANEL_SECONDS_ABBR"], seconds); + timeText = timeText .. format("%d" .. L["TITAN_PANEL_SECONDS_ABBR"], seconds); end end return timeText; end ---[[ API -NAME: TitanUtils_GetFullTimeText -DESC: break the seconds (s) into days, hours, minutes, and seconds -VAR: s - a time value in seconds -OUT: string - string with localized days, hours, minutes, and seconds using commas and including zeroes ---]] -function TitanUtils_GetFullTimeText(s) - local days, hours, minutes, seconds = GetTimeParts(s) +---API return a localized time from seconds given - days, hours, minutes, and seconds using commas and including zeroe +---@param seconds_value number +---@return string Time that is readable +function TitanUtils_GetFullTimeText(seconds_value) + local days, hours, minutes, seconds = GetTimeParts(seconds_value) if seconds == L["TITAN_PANEL_NA"] then return L["TITAN_PANEL_NA"]; else - return format("%d"..L["TITAN_PANEL_DAYS_ABBR"] - ..", %2d"..L["TITAN_PANEL_HOURS_ABBR"] - ..", %2d"..L["TITAN_PANEL_MINUTES_ABBR"] - ..", %2d"..L["TITAN_PANEL_SECONDS_ABBR"], - days, hours, minutes, seconds); + return format("%d" .. L["TITAN_PANEL_DAYS_ABBR"] + .. ", %2d" .. L["TITAN_PANEL_HOURS_ABBR"] + .. ", %2d" .. L["TITAN_PANEL_MINUTES_ABBR"] + .. ", %2d" .. L["TITAN_PANEL_SECONDS_ABBR"], + days, hours, minutes, seconds); end end ---[[ API -- Used by plugins -NAME: TitanUtils_GetAbbrTimeText -DESC: break the seconds (s) into days, hours, minutes, and seconds -VAR: s - a time value in seconds -OUT: string - string with localized days, hours, minutes, and seconds using spaces and including zeroes ---]] -function TitanUtils_GetAbbrTimeText(s) +---API return a terse localized time from seconds given. +---@param seconds_value number +---@return string Time that is readable +function TitanUtils_GetAbbrTimeText(seconds_value) local timeText = ""; - local days, hours, minutes, seconds = GetTimeParts(s) + local days, hours, minutes, seconds = GetTimeParts(seconds_value) if seconds == L["TITAN_PANEL_NA"] then timeText = L["TITAN_PANEL_NA"]; else if (days ~= 0) then - timeText = timeText..format("%d"..L["TITAN_PANEL_DAYS_ABBR"].." ", days); + timeText = timeText .. format("%d" .. L["TITAN_PANEL_DAYS_ABBR"] .. " ", days); end if (days ~= 0 or hours ~= 0) then - timeText = timeText..format("%d"..L["TITAN_PANEL_HOURS_ABBR"].." ", hours); + timeText = timeText .. format("%d" .. L["TITAN_PANEL_HOURS_ABBR"] .. " ", hours); end if (days ~= 0 or hours ~= 0 or minutes ~= 0) then - timeText = timeText..format("%d"..L["TITAN_PANEL_MINUTES_ABBR"].." ", minutes); + timeText = timeText .. format("%d" .. L["TITAN_PANEL_MINUTES_ABBR"] .. " ", minutes); end - timeText = timeText..format("%d"..L["TITAN_PANEL_SECONDS_ABBR"], seconds); + timeText = timeText .. format("%d" .. L["TITAN_PANEL_SECONDS_ABBR"], seconds); end return timeText; end ---[[ API -NAME: TitanUtils_GetControlFrame -DESC: return the control frame, if one was created. ---]] +---API Get the control frame of the plugin given. ---@param id string Unique ID of the plugin ---@return table? frame Frame of the menu (right click) function TitanUtils_GetControlFrame(id) if (id) then - return _G["TitanPanel"..id.."ControlFrame"]; + return _G["TitanPanel" .. id .. "ControlFrame"]; else return nil; end end ---[[ API -NAME: TitanUtils_TableContainsValue -DESC: Determine if the table contains the value. -VAR: table - table to search -VAR: value - value to find -OUT: int - nil or the index to value ---]] +---API Routine that index of the value given. +---@param table table Array to check +---@param value any Value to look for +---@return any index if value found; nil if not function TitanUtils_TableContainsValue(table, value) + local res = nil if (table and value) then for i, v in pairs(table) do if (v == value) then @@ -695,47 +691,33 @@ function TitanUtils_TableContainsValue(table, value) end end end + + return res -- not found end ---[[ API -NAME: TitanUtils_TableContainsIndex -DESC: Determine if the table contains the index. -VAR: table - table to search -VAR: index - index to find -OUT: int - nil or the index ---]] +---API Routine that index if found. +---@param table table Array to check +---@param index any Index to look for +---@return any index if found; nil if not function TitanUtils_TableContainsIndex(table, index) + local res = nil if (table and index and table[index] ~= nil) then return index end ---[[ - if (table and index) then - for i, v in pairs(table) do - if (i == index) then - return i; - end - end - end ---]] + + return res -- not found end ---[[ API -NAME: TitanUtils_GetCurrentIndex -DESC: Determine if the table contains the value. -VAR: table - table to search -VAR: value - value to find -OUT: int - nil or the index to value ---]] +---API Routine that index of the value given. +---@param table table Array to check +---@param value any Value to look for +---@return any index if value found; nil if not function TitanUtils_GetCurrentIndex(table, value) return TitanUtils_TableContainsValue(table, value); end ---[[ API -NAME: TitanUtils_PrintArray -DESC: Debug tool that will attempt to output the index and value of the array passed in. -VAR: array - array to output -OUT: table - Array output to the chat window ---]] +---API Debug tool that will attempt to output to Chat the top level index and value of the array. +---@param array table Simple array function TitanUtils_PrintArray(array) if (not array) then TitanDebug("array is nil"); @@ -746,146 +728,164 @@ function TitanUtils_PrintArray(array) end TitanDebug("}"); end - end ---[[ API -- Used by plugins -NAME: TitanUtils_GetRedText -DESC: Make the given text red. -VAR: text - text to color -OUT: string - Red string with proper start and end font encoding ---]] +---API Routine that returns red string with proper start and end font encoding. +---@param text string Text to wrap +---@return string text Red color encoded string function TitanUtils_GetRedText(text) + local res = "" if (text) then - return _G["RED_FONT_COLOR_CODE"]..text.._G["FONT_COLOR_CODE_CLOSE"]; + res = _G["RED_FONT_COLOR_CODE"] .. text .. _G["FONT_COLOR_CODE_CLOSE"]; + else + res = _G["GRAY_FONT_COLOR"] .. tostring(text) .. _G["FONT_COLOR_CODE_CLOSE"] end + + return res end ---[[ API -NAME: TitanUtils_GetGoldText -DESC: Make the given text gold. -VAR: text - text to color -OUT: string - Gold string with proper start and end font encoding ---]] +---API Routine that returns gold string with proper start and end font encoding. +---@param text string Text to wrap +---@return string text Gold color encoded string function TitanUtils_GetGoldText(text) + local res = "" if (text) then - return "|cffffd700"..text.._G["FONT_COLOR_CODE_CLOSE"]; + res = "|cffffd700" .. text .. _G["FONT_COLOR_CODE_CLOSE"]; + else + res = _G["GRAY_FONT_COLOR"] .. tostring(text) .. _G["FONT_COLOR_CODE_CLOSE"] end + + return res end ---[[ API -- Used by plugins -NAME: TitanUtils_GetGreenText -DESC: Make the given text green. -VAR: text - text to color -OUT: string - Green string with proper start and end font encoding ---]] +---API Routine that returns green string with proper start and end font encoding. +---@param text string Text to wrap +---@return string text Green color encoded string function TitanUtils_GetGreenText(text) + local res = "" if (text) then - return _G["GREEN_FONT_COLOR_CODE"]..text.._G["FONT_COLOR_CODE_CLOSE"]; + res = _G["GREEN_FONT_COLOR_CODE"] .. text .. _G["FONT_COLOR_CODE_CLOSE"]; + else + res = _G["GRAY_FONT_COLOR"] .. tostring(text) .. _G["FONT_COLOR_CODE_CLOSE"] end + + return res end ---[[ API -NAME: TitanUtils_GetBlueText -DESC: Make the given text blue. -VAR: text - text to color -OUT: string - Blue string with proper start and end font encoding ---]] +---API Routine that returns blue string with proper start and end font encoding. +---@param text string Text to wrap +---@return string text Blue color encoded string function TitanUtils_GetBlueText(text) + local res = "" if (text) then - return "|cff0000ff"..text.._G["FONT_COLOR_CODE_CLOSE"]; + res = "|cff0000ff" .. text .. _G["FONT_COLOR_CODE_CLOSE"]; + else + res = _G["GRAY_FONT_COLOR"] .. tostring(text) .. _G["FONT_COLOR_CODE_CLOSE"] end + + return res end ---[[ API -- Used by plugins -NAME: TitanUtils_GetNormalText -DESC: Make the given text normal (gray-white). -VAR: text - text to color -OUT: string - Normal string with proper start and end font encoding ---]] +---API Routine that returns normal color (gray-white) string with proper start and end font encoding. +---@param text string Text to wrap +---@return string text Normal color encoded string function TitanUtils_GetNormalText(text) + local res = "" if (text) then - return _G["NORMAL_FONT_COLOR_CODE"]..text.._G["FONT_COLOR_CODE_CLOSE"]; + res = _G["NORMAL_FONT_COLOR_CODE"] .. text .. _G["FONT_COLOR_CODE_CLOSE"]; + else + res = _G["GRAY_FONT_COLOR"] .. tostring(text) .. _G["FONT_COLOR_CODE_CLOSE"] end + + return res end ---[[ API -- Used by plugins -NAME: TitanUtils_GetHighlightText -DESC: Make the given text highlight (brighter white). -VAR: text - text to color -OUT: string - Highlight string with proper start and end font encoding ---]] +---API Routine that returns highlight color (brighter white) string with proper start and end font encoding. +---@param text string Text to wrap +---@return string text Highlight color encoded string function TitanUtils_GetHighlightText(text) + local res = "" if (text) then - return _G["HIGHLIGHT_FONT_COLOR_CODE"]..text.._G["FONT_COLOR_CODE_CLOSE"]; + res = _G["HIGHLIGHT_FONT_COLOR_CODE"] .. text .. _G["FONT_COLOR_CODE_CLOSE"]; + else + res = _G["GRAY_FONT_COLOR"] .. tostring(text) .. _G["FONT_COLOR_CODE_CLOSE"] end + + return res end ---[[ API -- Used by plugins -NAME: TitanUtils_GetColoredText -DESC: Make the given text a custom color. -VAR: text - text to color -VAR: color - color is the color table with r, b, g values set. -OUT: string - Custom color string with proper start and end font encoding ---]] +---API Routine that returns custom color (rbg) string with proper start and end font encoding. +---@param text string Text to wrap +---@param color any See color:GetRGB() / color:GetRGBA() +---@return string text Custom color encoded string +--- TitanUtils_GetColoredText(GOLD_PERHOUR_STATUS, TITAN_GOLD_GREEN) function TitanUtils_GetColoredText(text, color) + local res = "" if (text and color) then local redColorCode = format("%02x", color.r * 255); local greenColorCode = format("%02x", color.g * 255); local blueColorCode = format("%02x", color.b * 255); - local colorCode = "|cff"..redColorCode..greenColorCode..blueColorCode; - return colorCode..text.._G["FONT_COLOR_CODE_CLOSE"]; + local colorCode = "|cff" .. redColorCode .. greenColorCode .. blueColorCode; + res = colorCode .. text .. _G["FONT_COLOR_CODE_CLOSE"]; + else + res = _G["GRAY_FONT_COLOR"] .. tostring(text) .. _G["FONT_COLOR_CODE_CLOSE"] end + + return res end ---[[ API -- Used by plugins -NAME: TitanUtils_GetHexText -DESC: Make the given text a custom color. -VAR: text - text to color -VAR: hex - color as a 6 char hex code -OUT: string - Custom color string with proper start and end font encoding ---]] +---API Routine that returns custom color (hex) string with proper start and end font encoding. +---@param text string Text to wrap +---@param hex string +---@return string text Custom color encoded string +---TitanUtils_GetHexText(player.faction, "d42447") -- Horde function TitanUtils_GetHexText(text, hex) + local res = "" if (text and hex) then - return "|cff"..tostring(hex)..text.._G["FONT_COLOR_CODE_CLOSE"]; + res = "|cff" .. tostring(hex) .. text .. _G["FONT_COLOR_CODE_CLOSE"] + else + res = _G["GRAY_FONT_COLOR"] .. tostring(text) .. _G["FONT_COLOR_CODE_CLOSE"] end + + return res end ---[[ API -NAME: TitanUtils_GetThresholdColor -DESC: Flexable routine that returns the threshold color for a given value using a table as input. -VAR: ThresholdTable - table holding the list of colors and values -VAR: value - -OUT: string - The color value from the treshhold table ---]] +---@param ThresholdTable table holding the list of colors and values +---@param value number to check against table ranges (assumes assending values) +---@return string color in table or "GRAY_FONT_COLOR" function TitanUtils_GetThresholdColor(ThresholdTable, value) - if ( not tonumber(value) or type(ThresholdTable) ~= "table" - or ThresholdTable.Values == nil or ThresholdTable.Colors == nil - or table.getn(ThresholdTable.Values) >= table.getn(ThresholdTable.Colors) - ) then + --[[ example + local TITAN_FPS_THRESHOLD_TABLE = { + Values = { 20, 30 }, + Colors = { RED_FONT_COLOR, NORMAL_FONT_COLOR, GREEN_FONT_COLOR }, + } + + TitanUtils_GetThresholdColor(TITAN_FPS_THRESHOLD_TABLE, button.fps) + --]] + if (not tonumber(value) or type(ThresholdTable) ~= "table" + or ThresholdTable.Values == nil or ThresholdTable.Colors == nil + or table.getn(ThresholdTable.Values) >= table.getn(ThresholdTable.Colors) + ) then return _G["GRAY_FONT_COLOR"]; end local n = table.getn(ThresholdTable.Values) + 1; for i = 1, n do - local low = TitanUtils_Ternary(i == 1, nil, ThresholdTable.Values[i-1]); -- lowest - local high = TitanUtils_Ternary(i == n, nil, ThresholdTable.Values[i]); -- highest + local low = TitanUtils_Ternary(i == 1, nil, ThresholdTable.Values[i - 1]); -- lowest + local high = TitanUtils_Ternary(i == n, nil, ThresholdTable.Values[i]); -- highest - if ( not low and not high ) then + if (not low and not high) then -- No threshold values return ThresholdTable.Colors[i]; - - elseif ( not low and high ) then + elseif (not low and high) then -- Value is smaller than the first threshold - if ( value < high ) then return ThresholdTable.Colors[i] end - - elseif ( low and not high ) then + if (value < high) then return ThresholdTable.Colors[i] end + elseif (low and not high) then -- Value is larger than the last threshold - if ( low <= value ) then return ThresholdTable.Colors[i] end - + if (low <= value) then return ThresholdTable.Colors[i] end else -- Value is in between 2 adjacent thresholds - if ( low <= value and value < high ) then + if (low <= value and value < high) then return ThresholdTable.Colors[i] end end @@ -895,16 +895,18 @@ function TitanUtils_GetThresholdColor(ThresholdTable, value) return _G["GRAY_FONT_COLOR"]; end ---[[ API -NAME: TitanUtils_ToString -DESC: Routine that returns the text or an empty string. -VAR: text - text to check -OUT: string - string of text or "" ---]] +---API Routine that returns the text or an empty string. +---@param text string Text to check +---@return string text or "" function TitanUtils_ToString(text) return TitanUtils_Ternary(text, text, ""); end +--====== Right click menu routines - Retail dropdown menu + +---local Add menu button at the given level. +---@param info table Filled in button to add +---@param level number menu level local function Add_button(info, level) if TITAN_ID == "TitanClassic" then L_UIDropDownMenu_AddButton(info, level); @@ -913,27 +915,13 @@ local function Add_button(info, level) end end ---====== Right click menu routines - Retail dropdown menu ---[[ -Right click menu routines for plugins -The expected global function name in the plugin is: -"TitanPanelRightClickMenu_Prepare"..<registry.id>.."Menu" - -This section abstracts the menu routines built into WoW. -Over time Titan used the menu routines written by Blizzard then a lib under Ace3. Currently back to the Blizzard routines. -Whenever there is a change to the menu routines, the abstractions allows us to update Utils rather than updating Titan using search & replace. It also helps insulate 3rd party Titan plugin authors from Blizz or lib changes. ---]] - ---[[ API -NAME: TitanPanelRightClickMenu_GetDropdownFrameBase -DESC: Menu - Get the current dropdown w/o a level -OUT: str - dropdown w/o a level ---]] +---API Menu - Get the base frame name of the user selected menu (without level). +---@return string frame_name function TitanPanelRightClickMenu_GetDropdownFrameBase() local res = "" if TITAN_ID == "TitanClassic" then - res = "L_DropDownList" -- The LibUIDropDownMenu lib is used over the Blizzard frame + res = "L_DropDownList" -- The LibUIDropDownMenu lib is used over the Blizzard frame else -- The LibUIDropDownMenu lib is used over the Blizzard frame res = "DropDownList" -- Boo!! Per hard-coded Blizz UIDropDownMenu.lua @@ -942,33 +930,26 @@ function TitanPanelRightClickMenu_GetDropdownFrameBase() return res end ---[[ API -NAME: TitanPanelRightClickMenu_GetDropdownMenu -DESC: Menu - Get the current level in the menus. -VAR: None -OUT: int - dropdown menu level ---]] +---API Menu - Get the frame name of the user selected menu. +---@return string frame_name function TitanPanelRightClickMenu_GetDropdownFrame() local res = "" if TITAN_ID == "TitanClassic" then - res = "L_DropDownList"..tostring(L_UIDROPDOWNMENU_MENU_LEVEL) + res = "L_DropDownList" .. tostring(L_UIDROPDOWNMENU_MENU_LEVEL) else -- The LibUIDropDownMenu lib is used over the Blizzard frame - res = "DropDownList"..tostring(UIDROPDOWNMENU_MENU_LEVEL) + res = "DropDownList" .. tostring(UIDROPDOWNMENU_MENU_LEVEL) end return res end ---[[ API -NAME: TitanPanelRightClickMenu_GetDropdownMenu -DESC: Menu - Get the current level in the menus. -VAR: None -OUT: int - dropdown menu level ---]] +---API Menu - Get the current level of the user selected menu. +---@return number level function TitanPanelRightClickMenu_GetDropdownLevel() - local res = _G[drop_down_1] + -- local res = _G[drop_down_1] + local res = 1 -- proper typing if TITAN_ID == "TitanClassic" then res = L_UIDROPDOWNMENU_MENU_LEVEL @@ -980,12 +961,8 @@ function TitanPanelRightClickMenu_GetDropdownLevel() return res end ---[[ API -NAME: TitanPanelRightClickMenu_GetDropdMenuValue -DESC: Menu - Get the current value in the selected menu. -VAR: None -OUT: int - dropdown menu value ---]] +---API Menu - Get the current value of the user selected menu. +---@return any Value <button>.value usually a string; could be table to hold needed info function TitanPanelRightClickMenu_GetDropdMenuValue() local res = nil if TITAN_ID == "TitanClassic" then @@ -996,36 +973,30 @@ function TitanPanelRightClickMenu_GetDropdMenuValue() return res end ---[[ API -NAME: TitanPanelRightClickMenu_AddButton -DESC: Menu - add given info (button) at the given level in the form of a button. -VAR: info - text / button / command to show -VAR: level - level to put text -OUT: None ---]] +---API Menu - add given info (button) at the given menu level. +---@param info table Filled in button to add +---@param level? number menu level or 1 function TitanPanelRightClickMenu_AddButton(info, level) - if (info) then + level = level or 1 + if (info) then Add_button(info, level) - end + end end ---[[ API -NAME: TitanPanelRightClickMenu_AddToggleRightSide -DESC: Menu - add a toggle Right Side (localized) command at the given level in the form of a button. Titan will properly control the "DisplayOnRightSide" -VAR: id - id of the plugin -VAR: level - level to put the line -OUT: None ---]] +---API Menu - add a toggle Right Side (localized) command at the given level in the form of a button. Titan will properly control the "DisplayOnRightSide" +---@param id string Plugin id +---@param level? number menu level or 1 function TitanPanelRightClickMenu_AddToggleRightSide(id, level) + level = level or 1 local plugin = TitanUtils_GetPlugin(id) if plugin and plugin.controlVariables and plugin.controlVariables.DisplayOnRightSide then -- copy of TitanPanelRightClickMenu_AddToggleVar adding a remove button local info = {}; info.text = L["TITAN_CLOCK_MENU_DISPLAY_ON_RIGHT_SIDE"]; - info.value = {id, "DisplayOnRightSide"}; + info.value = { id, "DisplayOnRightSide" }; info.func = function() local bar = TitanUtils_GetWhichBar(id) - TitanPanelRightClickMenu_ToggleVar({id, "DisplayOnRightSide"}) + TitanPanelRightClickMenu_ToggleVar({ id, "DisplayOnRightSide" }) TitanPanel_RemoveButton(id); TitanUtils_AddButtonOnBar(bar, id) end @@ -1035,14 +1006,11 @@ function TitanPanelRightClickMenu_AddToggleRightSide(id, level) end end ---[[ API -NAME: TitanPanelRightClickMenu_AddTitle -DESC: Menu - add a title at the given level in the form of a button. -VAR: title - text to show -VAR: level - level to put text -OUT: None ---]] +---API Menu - add a localized title at the given level in the form of a button. +---@param title string localized title +---@param level? number menu level or 1 function TitanPanelRightClickMenu_AddTitle(title, level) + level = level or 1 if (title) then local info = {}; info.text = title; @@ -1053,16 +1021,13 @@ function TitanPanelRightClickMenu_AddTitle(title, level) end end ---[[ API -NAME: TitanPanelRightClickMenu_AddCommand -DESC: Menu - add a command at the given level in the form of a button. -VAR: title - text to show -VAR: value - value of the command -VAR: functionName - routine to run when clicked -VAR: level - level to put command -OUT: None ---]] +---API Menu - add a toggle variable command at the given level in the form of a button. +---@param text string Localized text to show +---@param value string Internal button name +---@param functionName function | string Function to call on click +---@param level? number menu level function TitanPanelRightClickMenu_AddCommand(text, value, functionName, level) + level = level or 1 local info = {}; info.notCheckable = true; info.text = text; @@ -1080,26 +1045,23 @@ function TitanPanelRightClickMenu_AddCommand(text, value, functionName, level) -- silently leave... end -- Redundant but the given string may not be a function - if type(callback)== "function" then + if type(callback) == "function" then -- No return expected... callback(value) else -- Must be a function - spank developer end else - -- Leave, no function given + -- Leave, creates an inactive button end end Add_button(info, level); end ---[[ API -NAME: TitanPanelRightClickMenu_AddSeparator -DESC: Menu - add a line at the given level in the form of an inactive button. -VAR: level - level to put the line -OUT: None ---]] +---API Menu - add a line at the given level in the form of an inactive button. +---@param level? number menu level or 1 function TitanPanelRightClickMenu_AddSeparator(level) + level = level or 1 if TITAN_ID == "TitanClassic" then L_UIDropDownMenu_AddSeparator(level) else @@ -1107,13 +1069,10 @@ function TitanPanelRightClickMenu_AddSeparator(level) end end ---[[ API -NAME: TitanPanelRightClickMenu_AddSpacer -DESC: Menu - add a blank line at the given level in the form of an inactive button. -VAR: level - level to put the line -OUT: None ---]] +---API Menu - add a blank line at the given level in the form of an inactive button. +---@param level? number menu level or 1 function TitanPanelRightClickMenu_AddSpacer(level) + level = level or 1 if TITAN_ID == "TitanClassic" then L_UIDropDownMenu_AddSpace(level) else @@ -1121,88 +1080,68 @@ function TitanPanelRightClickMenu_AddSpacer(level) end end ---[[ API -NAME: TitanPanelRightClickMenu_Hide -DESC: This will remove the plugin from the Titan bar. -VAR: value - id of the plugin -OUT: None ---]] -function TitanPanelRightClickMenu_Hide(value) - TitanPanel_RemoveButton(value); +---API This will remove the plugin from whichever Titan bar it is on. +---@param id string Plugin id +function TitanPanelRightClickMenu_Hide(id) + TitanPanel_RemoveButton(id); end ---[[ API -NAME: TitanPanelRightClickMenu_AddToggleVar -DESC: Menu - add a toggle variable command at the given level in the form of a button. -VAR: text - text to show -VAR: id - id of the plugin -VAR: var - the saved variable of the plugin to toggle -VAR: toggleTable - control table (called with other than nil??) -VAR: level - level to put the line -OUT: None ---]] +---API Menu - add a toggle variable command at the given level in the form of a button. +---@param text string Localized text to show +---@param id string Plugin id +---@param var string the saved variable of the plugin to toggle +---@param toggleTable nil ! NOT USED ! +---@param level number menu level function TitanPanelRightClickMenu_AddToggleVar(text, id, var, toggleTable, level) local info = {}; info.text = text; - info.value = {id, var, toggleTable}; + info.value = { id, var, toggleTable }; info.func = function() - TitanPanelRightClickMenu_ToggleVar({id, var, toggleTable}) + TitanPanelRightClickMenu_ToggleVar({ id, var, toggleTable }) end info.checked = TitanGetVar(id, var); info.keepShownOnClick = 1; Add_button(info, level); end ---[[ API -NAME: TitanPanelRightClickMenu_AddToggleIcon -DESC: Menu - add a toggle Icon (localized) command at the given level in the form of a button. Titan will properly control the "ShowIcon" -VAR: id - id of the plugin -VAR: level - level to put the line -OUT: None ---]] +---API Menu - add a toggle Label (localized) command at the given level in the form of a button. Titan will properly control "ShowIcon" +---@param id string Plugin id +---@param level? number menu level or 1 function TitanPanelRightClickMenu_AddToggleIcon(id, level) + level = level or 1 local plugin = TitanUtils_GetPlugin(id) if plugin and plugin.controlVariables and plugin.controlVariables.ShowIcon then TitanPanelRightClickMenu_AddToggleVar(L["TITAN_PANEL_MENU_SHOW_ICON"], id, "ShowIcon", nil, level); end end ---[[ API -NAME: TitanPanelRightClickMenu_AddToggleLabelText -DESC: Menu - add a toggle Label (localized) command at the given level in the form of a button. Titan will properly control the "ShowLabelText" -VAR: id - id of the plugin -VAR: level - level to put the line -OUT: None ---]] +---API Menu - add a toggle Label (localized) command at the given level in the form of a button. Titan will properly control "ShowLabelText" +---@param id string Plugin id +---@param level? number menu level or 1 function TitanPanelRightClickMenu_AddToggleLabelText(id, level) + level = level or 1 local plugin = TitanUtils_GetPlugin(id) if plugin and plugin.controlVariables and plugin.controlVariables.ShowLabelText then TitanPanelRightClickMenu_AddToggleVar(L["TITAN_PANEL_MENU_SHOW_LABEL_TEXT"], id, "ShowLabelText", nil, level); end end ---[[ API -NAME: TitanPanelRightClickMenu_AddToggleColoredText -DESC: Menu - add a toggle Colored Text (localized) command at the given level in the form of a button. Titan will properly control the "ShowColoredText" -VAR: id - id of the plugin -VAR: level - level to put the line -OUT: None ---]] +---API Menu - add a toggle Colored Text (localized) command at the given level in the form of a button. Titan will properly control "ShowColoredText" +---@param id string Plugin id +---@param level? number menu level or 1 function TitanPanelRightClickMenu_AddToggleColoredText(id, level) + level = level or 1 local plugin = TitanUtils_GetPlugin(id) if plugin and plugin.controlVariables and plugin.controlVariables.ShowColoredText then TitanPanelRightClickMenu_AddToggleVar(L["TITAN_PANEL_MENU_SHOW_COLORED_TEXT"], id, "ShowColoredText", nil, level); end end ---[[ API -NAME: TitanPanelRightClickMenu_AddHide -DESC: Menu - add a Hide (localized) command at the given level in the form of a button. When clicked this will remove the plugin from the Titan bar. -VAR: id - id of the plugin -VAR: level - level to put the line -OUT: None ---]] +---API Menu - add a Hide (localized) command at the given level in the form of a button. When clicked this will remove the plugin from the Titan bar. +---@param id string Plugin id +---@param level? number menu level or 1 function TitanPanelRightClickMenu_AddHide(id, level) + level = level or 1 local info = {}; info.notCheckable = true; info.text = L["TITAN_PANEL_MENU_HIDE"]; @@ -1213,25 +1152,26 @@ function TitanPanelRightClickMenu_AddHide(id, level) Add_button(info, level); end ---[[ API -NAME: TitanPanelRightClickMenu_ToggleVar -DESC: This will toggle the Titan variable and the update the button. -VAR: value - table of (id of the plugin, saved var to be updated, control table) -OUT: None ---]] +---API This will toggle the Titan variable and the update the button. +---@param value table Plugin id and var to toggle +--- Example: {TITAN_XP_ID, "ShowSimpleToLevel"} function TitanPanelRightClickMenu_ToggleVar(value) - local id, var, toggleTable = nil, nil, nil; + -- Update 2024 Mar - Removed the 'reverse' check. + -- Not sure it was ever used or even worked. + -- local id, var, toggleTable = "", nil, {} + local id, var = "", "" -- table expected else do nothing - if type(value)~="table" then return end + if type(value) ~= "table" then return end if value and value[1] then id = value[1] end if value and value[2] then var = value[2] end - if value and value[3] then toggleTable = value[3] end + -- if value and value[3] then toggleTable = value[3] end -- Toggle var TitanToggleVar(id, var); - + TitanPanelButton_UpdateButton(id); + --[=[]] if ( TitanPanelRightClickMenu_AllVarNil(id, toggleTable) ) then -- Undo if all vars in toggle table nil TitanToggleVar(id, var); @@ -1239,48 +1179,15 @@ function TitanPanelRightClickMenu_ToggleVar(value) -- Otherwise continue and update the button TitanPanelButton_UpdateButton(id, 1); end +--]=] end ---[[ API -NAME: TitanPanelRightClickMenu_AllVarNil -DESC: Check if all the variables in the table are nil/false. -VAR: id - id of the plugin -VAR: toggleTable - table of saved var to be checked -OUT: bool - true (1) or nil ---]] -function TitanPanelRightClickMenu_AllVarNil(id, toggleTable) - if ( toggleTable ) and type(toggleTable)== "table" then - for i, v in toggleTable do - if ( TitanGetVar(id, v) ) then - return nil; - end - end - return 1; - end -end - ---[[ API -NAME: TitanPanelRightClickMenu_AddToggleColoredText -DESC: This will toggle the "ShowColoredText" Titan variable then update the button -VAR: id - id of the plugin -VAR: level - level to put the line -OUT: None ---]] -function TitanPanelRightClickMenu_ToggleColoredText(value) - TitanToggleVar(value, "ShowColoredText"); - TitanPanelButton_UpdateButton(value, 1); -end - ---[[ API -NAME: TitanPanelRightClickMenu_SetCustomBackdrop -DESC: This will set the backdrop of the given button. This is used for custom created controls such as Clock offset or Volume sliders to give a consistent look. -VAR: frame - the control frame of the plugin -OUT: None ---]] +---API Set backdrop of the plugin. Used for custom created controls (Clock / Volume) to give a consistent look. +---@param frame table Plugin control frame function TitanPanelRightClickMenu_SetCustomBackdrop(frame) frame:SetBackdrop({ - bgFile="Interface\\Tooltips\\UI-Tooltip-Background", - edgeFile="Interface\\Tooltips\\UI-Tooltip-Border", + bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", + edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", tile = true, tileEdge = true, insets = { left = 1, right = 1, top = 1, bottom = 1 }, @@ -1299,17 +1206,13 @@ function TitanPanelRightClickMenu_SetCustomBackdrop(frame) , 1); end ---[[ API -NAME: TitanPanelRightClickMenu_AddControlVars -DESC: Menu - add the set of options that are in the plugin registry control variables . -VAR: id - id of the plugin -OUT: None -NOTE: Assume top level only ---]] +---API Menu - add the set of options per the plugin registry control variables. +---@param id string Plugin id +---@param level? number If not present, default to 1 (top) function TitanPanelRightClickMenu_AddControlVars(id, level) - local level = 1 -- assume top menu - TitanPanelRightClickMenu_AddSeparator(level) - + level = level or 1 -- assume top menu + TitanPanelRightClickMenu_AddSeparator(level) + TitanPanelRightClickMenu_AddToggleIcon(id, level) TitanPanelRightClickMenu_AddToggleLabelText(id, level) TitanPanelRightClickMenu_AddToggleColoredText(id, level) @@ -1319,18 +1222,16 @@ function TitanPanelRightClickMenu_AddControlVars(id, level) TitanPanelRightClickMenu_AddCommand(L["TITAN_PANEL_MENU_HIDE"], id, TITAN_PANEL_MENU_FUNC_HIDE); end - -------------------------------------------------------------- -- -- Plugin manipulation routines -- ---[[ local -NAME: TitanUtils_SwapButtonOnBar -DESC: This will swap two buttons on the Titan bars. Once swapped then 'reinit' the buttons to show properly. This is currently used as part of the shift left / right. -VAR: from_id - id of the plugin -VAR: to_id - id of the plugin -OUT: None ---]] + + +---local This will swap two buttons on the Titan bars. Once swapped then 'reinit' the buttons to show properly. +--- This is currently used as part of the shift left / right on same bar. +---@param from_id integer Plugin id +---@param to_id integer Plugin id local function TitanUtils_SwapButtonOnBar(from_id, to_id) -- Used as part of the shift L / R to swap the buttons local button = TitanPanelSettings.Buttons[from_id] @@ -1343,17 +1244,12 @@ local function TitanUtils_SwapButtonOnBar(from_id, to_id) TitanPanel_InitPanelButtons(); end ---[[ local -NAME: TitanUtils_GetNextButtonOnBar -DESC: Find the next button that is on the same bar and is on the same side. -VAR: bar - The Titan bar to search -VAR: id - id of the plugin to see if there is a plugin next to it -VAR: side - right or left -OUT: int - index of the next button or nil if none found -NOTE: --- buttons on Left are placed L to R; buttons on Right are placed R to L. Next and prev depend on which side we need to check. -:NOTE ---]] +---local Find the next button index that is on the same bar and is on the same side. +---@param bar string Short bar name to look through +---@param id string Plugin id to look for +---@param side string TITAN_RIGHT("Right") or TITAN_Left("Left") +---@return integer? NextIndex nil means id is last +-- Buttons on Left are placed L to R; buttons on Right are placed R to L. Next and prev depend on which side we need to check. local function TitanUtils_GetNextButtonOnBar(bar, id, side) -- find the next button that is on the same bar and is on the same side -- return nil if not found @@ -1361,25 +1257,20 @@ local function TitanUtils_GetNextButtonOnBar(bar, id, side) for i, id in pairs(TitanPanelSettings.Buttons) do if TitanUtils_GetWhichBar(id) == bar - and i > index - and TitanPanel_GetPluginSide(id) == side - and TitanUtils_IsPluginRegistered(id) then + and i > index + and TitanPanel_GetPluginSide(id) == side + and TitanUtils_IsPluginRegistered(id) then return i; end end end ---[[ local -NAME: TitanUtils_GetPrevButtonOnBar -DESC: Find the previous button that is on the same bar and is on the same side. -VAR: bar - The Titan bar to search -VAR: id - id of the plugin to see if there is a plugin previous to it -VAR: side - right or left -OUT: int - index of the previous button or nil if none found -NOTE: --- buttons on Left are placed L to R; buttons on Right are placed R to L. Next and prev depend on which side we need to check. -:NOTE ---]] +---local Find the previous button index that is on the same bar and is on the same side. +---@param bar string Short bar name to look through +---@param id string Plugin id to look for +---@param side string TITAN_RIGHT("Right") or TITAN_Left("Left") +---@return integer? PrevIndex nil means id is first +-- Buttons on Left are placed L to R; buttons on Right are placed R to L. Next and prev depend on which side we need to check. local function TitanUtils_GetPrevButtonOnBar(bar, id, side) -- find the prev button that is on the same bar and is on the same side -- return nil if not found @@ -1388,9 +1279,9 @@ local function TitanUtils_GetPrevButtonOnBar(bar, id, side) for i, id in pairs(TitanPanelSettings.Buttons) do if TitanUtils_GetWhichBar(id) == bar - and i < index - and TitanPanel_GetPluginSide(id) == side - and TitanUtils_IsPluginRegistered(id) then + and i < index + and TitanPanel_GetPluginSide(id) == side + and TitanUtils_IsPluginRegistered(id) then prev_idx = i; -- this might be the previous button end if i == index then @@ -1399,20 +1290,16 @@ local function TitanUtils_GetPrevButtonOnBar(bar, id, side) end end ---[[ Titan -NAME: TitanUtils_AddButtonOnBar -DESC: Add the given plugin to the given bar. Then reinit the plugins to show it properly. -VAR: bar - The Titan bar to add the plugin -VAR: id - id of the plugin to add -OUT: None. ---]] +---Titan Add the given plugin to the given bar. Then reinit the plugins to show it properly. +---@param bar string Bar name to use +---@param id string Plugin to add function TitanUtils_AddButtonOnBar(bar, id) - local frame_str = TitanVariables_GetFrameName(bar) + local frame_str = TitanVariables_GetFrameName(bar) -- Add the button to the requested bar, if shown if (not bar) - or (not id) - or (not TitanPanelSettings) - or (not TitanBarDataVars[frame_str].show) + or (not id) + or (not TitanPanelSettings) + or (not TitanBarDataVars[frame_str].show) then return; end @@ -1425,17 +1312,11 @@ function TitanUtils_AddButtonOnBar(bar, id) TitanPanel_InitPanelButtons(); end ---[[ Titan -NAME: TitanUtils_GetFirstButtonOnBar -DESC: Find the first button that is on the given bar and is on the given side. -VAR: bar - The Titan bar to search -VAR: side - right or left -OUT: int - index of the first button or nil if none found -NOTE: --- buttons on Left are placed L to R; buttons on Right are placed R to L. Next and prev depend on which side we need to check. --- buttons on Right are placed R to L -:NOTE ---]] +---Titan Find the first button that is on the given bar and is on the given side. +--- buttons on Left are placed L to R; buttons on Right are placed R to L. Next and prev depend on which side we need to check. +--- buttons on Right are placed R to L +---@param bar string Bar name to search +---@param side string TITAN_RIGHT("Right") or TITAN_Left("Left") function TitanUtils_GetFirstButtonOnBar(bar, side) -- find the first button that is on the same bar and is on the same side -- return nil if not found @@ -1443,24 +1324,19 @@ function TitanUtils_GetFirstButtonOnBar(bar, side) for i, id in pairs(TitanPanelSettings.Buttons) do if TitanUtils_GetWhichBar(id) == bar - and i > index - and TitanPanel_GetPluginSide(id) == side - and TitanUtils_IsPluginRegistered(id) then + and i > index + and TitanPanel_GetPluginSide(id) == side + and TitanUtils_IsPluginRegistered(id) then return i; end end end ---[[ Titan -NAME: TitanUtils_ShiftButtonOnBarLeft -DESC: Find the button that is on the bar and is on the side and left of the given button -VAR: -- name - id of the plugin -OUT: None ---]] +---Titan Find the button that is on the bar and is on the side and left of the given button +---@param name string Plugin id name function TitanUtils_ShiftButtonOnBarLeft(name) -- Find the button to the left. If there is one, swap it in the array - local from_idx = TitanUtils_GetCurrentIndex(TitanPanelSettings.Buttons,name) + local from_idx = TitanUtils_GetCurrentIndex(TitanPanelSettings.Buttons, name) local side = TitanPanel_GetPluginSide(name) local bar = TitanUtils_GetWhichBar(name) local to_idx = nil @@ -1468,9 +1344,9 @@ function TitanUtils_ShiftButtonOnBarLeft(name) -- buttons on Left are placed L to R; -- buttons on Right are placed R to L if side and side == TITAN_LEFT then - to_idx = TitanUtils_GetPrevButtonOnBar (TitanUtils_GetWhichBar(name), name, side) + to_idx = TitanUtils_GetPrevButtonOnBar(TitanUtils_GetWhichBar(name), name, side) elseif side and side == TITAN_RIGHT then - to_idx = TitanUtils_GetNextButtonOnBar (TitanUtils_GetWhichBar(name), name, side) + to_idx = TitanUtils_GetNextButtonOnBar(TitanUtils_GetWhichBar(name), name, side) end if to_idx then @@ -1480,16 +1356,11 @@ function TitanUtils_ShiftButtonOnBarLeft(name) end end ---[[ Titan -NAME: TitanUtils_ShiftButtonOnBarRight -DESC: Find the button that is on the bar and is on the side and right of the given button -VAR: -- name - id of the plugin -OUT: None ---]] +--Titan Find the button that is on the bar and is on the side and right of the given button +---@param name string Plugin id name function TitanUtils_ShiftButtonOnBarRight(name) -- Find the button to the right. If there is one, swap it in the array - local from_idx = TitanUtils_GetCurrentIndex(TitanPanelSettings.Buttons,name) + local from_idx = TitanUtils_GetCurrentIndex(TitanPanelSettings.Buttons, name) local to_idx = nil local side = TitanPanel_GetPluginSide(name) local bar = TitanUtils_GetWhichBar(name) @@ -1497,9 +1368,9 @@ function TitanUtils_ShiftButtonOnBarRight(name) -- buttons on Left are placed L to R; -- buttons on Right are placed R to L if side and side == TITAN_LEFT then - to_idx = TitanUtils_GetNextButtonOnBar (bar, name, side) + to_idx = TitanUtils_GetNextButtonOnBar(bar, name, side) elseif side and side == TITAN_RIGHT then - to_idx = TitanUtils_GetPrevButtonOnBar (bar, name, side) + to_idx = TitanUtils_GetPrevButtonOnBar(bar, name, side) end if to_idx then @@ -1513,19 +1384,15 @@ end -- -- Control Frame check & manipulation routines -- ---[[ Titan Plugins -NAME: TitanUtils_CheckFrameCounting -DESC: Check the frame - expected to be a control / menu frame. Close if timer has expired. Used in plugin OnUpdate -VAR: -- frame - control / menu frame -- elapsed - portion of second since last OnUpdate -OUT: None ---]] + +---Titan: Check the frame - expected to be a control / menu frame. Close if timer has expired. Used in plugin OnUpdate +---@param frame table control / menu frame +---@param elapsed number portion of second since last OnUpdate function TitanUtils_CheckFrameCounting(frame, elapsed) if (frame:IsVisible()) then if (not frame.frameTimer or not frame.isCounting) then return; - elseif ( frame.frameTimer < 0 ) then + elseif (frame.frameTimer < 0) then frame:Hide(); frame.frameTimer = nil; frame.isCounting = nil; @@ -1535,85 +1402,71 @@ function TitanUtils_CheckFrameCounting(frame, elapsed) end end ---[[ Titan Plugins -NAME: TitanUtils_StartFrameCounting -DESC: Set the max time the control frame could be open once cursor has left frame. Used in plugin OnLeave -VAR: -- frame - control / menu frame -- frameShowTime - max time -OUT: None ---]] +---Titan Set the max time the control frame could be open once cursor has left frame. Used in plugin OnLeave +---@param frame table control / menu frame +---@param frameShowTime number time to wait function TitanUtils_StartFrameCounting(frame, frameShowTime) frame.frameTimer = frameShowTime; frame.isCounting = 1; end ---[[ Titan Plugins -NAME: TitanUtils_StopFrameCounting -DESC: Remove timer flag once cursor has entered frame. Used in plugin OnEnter -VAR: -- frame - control / menu frame -OUT: None ---]] +---Titan Remove timer flag once cursor has entered frame. Used in plugin OnEnter +---@param frame table control / menu frame function TitanUtils_StopFrameCounting(frame) frame.isCounting = nil; end ---[[ Titan Plugins AND Bars -NAME: TitanUtils_CloseAllControlFrames -DESC: Remove all timer flags on plugin control frames. Used for plugin Shift+Left and within Titan -VAR: None -OUT: None ---]] +---Titan Remove all timer flags on plugin control frames. Used for plugin Shift+Left and within Titan +--- Used for Plugins AND Titan function TitanUtils_CloseAllControlFrames() for index, value in pairs(TitanPlugins) do - local frame = _G["TitanPanel"..index.."ControlFrame"]; + local frame = _G["TitanPanel" .. index .. "ControlFrame"]; if (frame and frame:IsVisible()) then frame:Hide(); end end end +--[[ 2024 Mar commented out - not used by Titan function TitanUtils_IsAnyControlFrameVisible() -- need? for index, value in TitanPlugins do - local frame = _G["TitanPanel"..index.."ControlFrame"]; + local frame = _G["TitanPanel" .. index .. "ControlFrame"]; if (frame:IsVisible()) then return true; end end return false; end - ---[[ Titan Plugins AND Titan -NAME: TitanUtils_GetOffscreen -DESC: Check where the control frame should be on screen; return x and y -VAR: None -OUT: float - x where frame should be -OUT: float - y where frame should be --]] + +---Titan Check if the control frame is on screen. +--- Used for Plugins AND Titan +---@param frame table Frame name likely tooltip +---@return number off_X -1 off left; 0 = ok; 1 off right +---@return number off_Y -1 off top; 0 = ok; 1 off bottom function TitanUtils_GetOffscreen(frame) local offscreenX, offscreenY; local ui_scale = UIParent:GetEffectiveScale() if not frame then - return + return 0, 0 -- ?? end local fr_scale = frame:GetEffectiveScale() - if ( frame and frame:GetLeft() - and frame:GetLeft() * fr_scale < UIParent:GetLeft() * ui_scale ) then + if (frame and frame:GetLeft() + and frame:GetLeft() * fr_scale < UIParent:GetLeft() * ui_scale) then offscreenX = -1; - elseif ( frame and frame:GetRight() - and frame:GetRight() * fr_scale > UIParent:GetRight() * ui_scale ) then + elseif (frame and frame:GetRight() + and frame:GetRight() * fr_scale > UIParent:GetRight() * ui_scale) then offscreenX = 1; else offscreenX = 0; end - if ( frame and frame:GetTop() - and frame:GetTop() * fr_scale > UIParent:GetTop() * ui_scale ) then + if (frame and frame:GetTop() + and frame:GetTop() * fr_scale > UIParent:GetTop() * ui_scale) then offscreenY = -1; - elseif ( frame and frame:GetBottom() - and frame:GetBottom() * fr_scale < UIParent:GetBottom() * ui_scale ) then + elseif (frame and frame:GetBottom() + and frame:GetBottom() * fr_scale < UIParent:GetBottom() * ui_scale) then offscreenY = 1; else offscreenY = 0; @@ -1626,18 +1479,13 @@ end -- -- Plugin registration routines -- ---[[ Titan -NAME: TitanUtils_GetAddOnMetadata -DESC: Attempt to get meta data from the addon -VAR: -- name - string of addon name -- field - string of addon field to get -OUT: None -NOTE: -- As of May 2023 (10.1) the routine moved and no longer dies silently so it is wrapped here... ---]] + +---Titan Wrapper to get meta data from the addon +---@param name string Addon name +---@param field string Attribute to get function TitanUtils_GetAddOnMetadata(name, field) ----@diagnostic disable-next-line: deprecated + -- As of May 2023 (10.1) the routine moved and no longer dies silently so it is wrapped here... + ---@diagnostic disable-next-line: deprecated local GetMeta = C_AddOns and C_AddOns.GetAddOnMetadata or GetAddOnMetadata local call_success, ret_val @@ -1645,9 +1493,9 @@ function TitanUtils_GetAddOnMetadata(name, field) -- Just in case, catch any errors call_success, -- needed for pcall ret_val = -- actual return values - pcall (GetMeta, name, field) + pcall(GetMeta, name, field) if call_success then - -- all is good + -- all is good return ret_val else -- Some error.. for our use return nil @@ -1655,14 +1503,13 @@ function TitanUtils_GetAddOnMetadata(name, field) end end ---[[ Titan -NAME: TitanUtils_PluginToRegister -DESC: Place the plugin to be registered later by Titan -VAR: -- self - frame of the plugin (must be a Titan template) -- isChildButton - true if the frame is a child of a Titan frame -OUT: None -NOTE: +---Titan Store the plugin to be registered later by Titan +--- See comments in the routine for more details. +---@param self table Plugin frame +---@param isChildButton boolean? !! Not Used !! +function TitanUtils_PluginToRegister(self, isChildButton) + -- 2024 Mar -- removed isChildButton since it has not been used in years to my knowledge :) + --[[ - .registry is part of 'self' (the Titan plugin frame) which works great for Titan specific plugins. Titan plugins create the registry as part of the frame _OnLoad. But this does not work for LDB buttons. The frame is created THEN the registry is added to the frame. @@ -1671,8 +1518,7 @@ NOTE: Sometimes plugin frames are created after this process. Right now only LDB plugins are handled. If someone where to start creating Titan frames after the registration process were complete then it would fail to be registered... -!For LDB plugins the 'registry' is attached to the frame AFTER the frame is created... - The fields put into "Attempted" are defaulted here in preperation of being registered. ---]] -function TitanUtils_PluginToRegister(self, isChildButton) + --]] TitanPluginToBeRegisteredNum = TitanPluginToBeRegisteredNum + 1 local cat = "" local notes = "" @@ -1687,8 +1533,8 @@ function TitanUtils_PluginToRegister(self, isChildButton) TitanPluginToBeRegistered[TitanPluginToBeRegisteredNum] = { self = self, button = ((self and self:GetName() - or "Nyl".."_"..TitanPluginToBeRegisteredNum)), - isChild = (isChildButton and true or false), + or "Nyl" .. "_" .. TitanPluginToBeRegisteredNum)), + isChild = false, -- (isChildButton and true or false), -- fields below are updated when registered name = "?", issue = "", @@ -1701,30 +1547,28 @@ function TitanUtils_PluginToRegister(self, isChildButton) -- Debug if Titan_Global.debug.plugin_register then TitanDebug("Queue Plugin" --- .." '"..tostring(self:GetName()).."'" - .." '"..tostring(TitanUtils_GetButtonID(self:GetName())).."'" - .." "..tostring(TITAN_NOT_REGISTERED).."" - ) + -- .." '"..tostring(self:GetName()).."'" + .. " '" .. tostring(TitanUtils_GetButtonID(self:GetName())) .. "'" + .. " " .. tostring(TITAN_NOT_REGISTERED) .. "" + ) end end ---[[ Titan -NAME: TitanUtils_PluginFail -DESC: Place the plugin to be registered later by Titan -VAR: -- plugin - frame of the plugin (must be a Titan template) -OUT: None -NOTE: -- This is called when a plugin is unsupported. Cuurently this is used if a LDB data object is not supported. See SupportedDOTypes in LDBToTitan.lua for more detail. - It is intended mainly for developers. It is a place to put relevant info for debug and so users can supply troubleshooting info. - The key is set the status to 'fail' so there is no further attempt to register the plugin. -- The results will show in "Attempted" so the developer has a shot at figuring out what was wrong. -- plugin is expected to hold as much relevant info as possible... ---]] +---local Handle a Titan plugin that could not be registered. +--- See comments in the routine for more details. +---@param plugin table Plugin frame - Titan template function TitanUtils_PluginFail(plugin) + --[[ +--- This is called when a plugin is unsupported. Curently this is used if a LDB data object is not supported. +--- See SupportedDOTypes in LDBToTitan.lua for more detail. +--- It is intended mainly for developers. It is a place to put relevant info for debug and so users can supply troubleshooting info. +--- The key is set the status to 'fail' so there is no further attempt to register the plugin. +--- The results will show in "Attempted" so the developer has a shot at figuring out what was wrong. +--- plugin is expected to hold as much relevant info as possible... +--]] TitanPluginToBeRegisteredNum = TitanPluginToBeRegisteredNum + 1 TitanPluginToBeRegistered[TitanPluginToBeRegisteredNum] = - { + { self = plugin.self, button = (plugin.button and plugin.button:GetName() or ""), isChild = (plugin.isChild and true or false), @@ -1733,33 +1577,36 @@ function TitanUtils_PluginFail(plugin) status = (plugin.status or "?"), category = (plugin.category or ""), plugin_type = (plugin.plugin_type or ""), - } + } local message = "" - .." '"..tostring(TitanPluginToBeRegistered[TitanPluginToBeRegisteredNum].status).."'" - .." '"..tostring(TitanPluginToBeRegistered[TitanPluginToBeRegisteredNum].name).."'" - .." '"..tostring(TitanPluginToBeRegistered[TitanPluginToBeRegisteredNum].category).."'" - .." '"..tostring(TitanPluginToBeRegistered[TitanPluginToBeRegisteredNum].issue).."'" + .. " '" .. tostring(TitanPluginToBeRegistered[TitanPluginToBeRegisteredNum].status) .. "'" + .. " '" .. tostring(TitanPluginToBeRegistered[TitanPluginToBeRegisteredNum].name) .. "'" + .. " '" .. tostring(TitanPluginToBeRegistered[TitanPluginToBeRegisteredNum].category) .. "'" + .. " '" .. tostring(TitanPluginToBeRegistered[TitanPluginToBeRegisteredNum].issue) .. "'" TitanPrint(message, "error") end +---local Strip the WoW color string(s) from the given string +---@param name string +---@return string NoColor local function NoColor(name) local no_color = name - + -- Remove any color formatting from the name in the list no_color = string.gsub(no_color, "|c........", "") no_color = string.gsub(no_color, "|r", "") - + return no_color end ---[[ local -NAME: TitanUtils_RegisterPluginProtected -DESC: This routine is intended to be called in a protected manner (pcall) by Titan when it attempts to register a plugin. -VAR: -- plugin - frame of the plugin (must be a Titan template) +---local This routine is a protected manner (pcall) by Titan when it attempts to register a plugin. +---@param plugin table Plugin frame - Titan template +---@return table Results of the registration - pass (TitanPlugins) or fail +--- See routine for output table values +local function TitanUtils_RegisterPluginProtected(plugin) +--[[ OUT: -- table .issue : Show the user what prevented the plugin from registering .result : Used so we know which plugins were processed .id : The name used to lookup the plugin @@ -1771,8 +1618,7 @@ NOTE: And attempt to tell the user / developer what went wrong. - If successful the plugin will be in TitanPlugins as a registered plugin and will be available for display on the Titan bars. --]] -local function TitanUtils_RegisterPluginProtected(plugin) - local result = "" +local result = "" local issue = "" local id = "" local cat = "" @@ -1781,107 +1627,106 @@ local function TitanUtils_RegisterPluginProtected(plugin) local str = "" local self = plugin.self - local isChildButton = (plugin.isChild and true or false) + -- local isChildButton = (plugin.isChild and true or false) if self and self:GetName() then - if (isChildButton) then - -- This is a button within a button - self:RegisterForClicks("LeftButtonUp", "RightButtonUp", "MiddleButtonUp"); - self:RegisterForDrag("LeftButton") - TitanPanelDetectPluginMethod(self:GetName(), true); - result = TITAN_REGISTERED - -- give some indication that this is valid... - id = (self:GetName() or "").."<child>" - else - -- Check for the .registry where all the Titan plugin info is expected - if (self.registry and self.registry.id) then - id = self.registry.id - if TitanUtils_IsPluginRegistered(id) then - -- We have already registered this plugin! - issue = "Plugin '"..tostring(id).."' already loaded. " - .."Please see if another plugin (Titan or LDB) is also loading " - .."with the same name.\n" - .."<Titan>.registry.id or <LDB>.label" + -- if (isChildButton) then + -- -- This is a button within a button + -- self:RegisterForClicks("LeftButtonUp", "RightButtonUp", "MiddleButtonUp"); + -- self:RegisterForDrag("LeftButton") + -- TitanPanelDetectPluginMethod(self:GetName(), true); + -- result = TITAN_REGISTERED + -- give some indication that this is valid... + -- id = (self:GetName() or "") .. "<child>" + -- else + -- Check for the .registry where all the Titan plugin info is expected + if (self.registry and self.registry.id) then + id = self.registry.id + if TitanUtils_IsPluginRegistered(id) then + -- We have already registered this plugin! + issue = "Plugin '" .. tostring(id) .. "' already loaded. " + .. "Please see if another plugin (Titan or LDB) is also loading " + .. "with the same name.\n" + .. "<Titan>.registry.id or <LDB>.label" + else + -- A sanity check just in case it was already in the list + if TitanUtils_TableContainsValue(TitanPluginsIndex, id) then + str = "In List ??" else - -- A sanity check just in case it was already in the list - if TitanUtils_TableContainsValue(TitanPluginsIndex, id) then - str = "In List ??" - else - str = "Save .registry" - -- Herein lies any special per plugin variables Titan wishes to control - -- These will be overwritten from saved vars, if any - -- - -- Sanity check - if self.registry.savedVariables then - -- Custom labels - self.registry.savedVariables.CustomLabelTextShow = false - self.registry.savedVariables.CustomLabelText = "" - self.registry.savedVariables.CustomLabel2TextShow = false - self.registry.savedVariables.CustomLabel2Text = "" - self.registry.savedVariables.CustomLabel3TextShow = false - self.registry.savedVariables.CustomLabel3Text = "" - self.registry.savedVariables.CustomLabel4TextShow = false - self.registry.savedVariables.CustomLabel4Text = "" - end + str = "Save .registry" + -- Herein lies any special per plugin variables Titan wishes to control + -- These will be overwritten from saved vars, if any + -- + -- Sanity check + if self.registry.savedVariables then + -- Custom labels + self.registry.savedVariables.CustomLabelTextShow = false + self.registry.savedVariables.CustomLabelText = "" + self.registry.savedVariables.CustomLabel2TextShow = false + self.registry.savedVariables.CustomLabel2Text = "" + self.registry.savedVariables.CustomLabel3TextShow = false + self.registry.savedVariables.CustomLabel3Text = "" + self.registry.savedVariables.CustomLabel4TextShow = false + self.registry.savedVariables.CustomLabel4Text = "" + end - -- Assign and Sort the list of plugins - TitanPlugins[id] = self.registry; - -- Set the name used for menus - if TitanPlugins[id].menuText == nil then - TitanPlugins[id].menuText = TitanPlugins[id].id; - end - TitanPlugins[id].menuText = NoColor(TitanPlugins[id].menuText) - - table.insert(TitanPluginsIndex, self.registry.id); - table.sort(TitanPluginsIndex, - function(a, b) - return string.lower(TitanPlugins[a].menuText) - < string.lower(TitanPlugins[b].menuText); - end - ); + -- Assign and Sort the list of plugins + TitanPlugins[id] = self.registry; + -- Set the name used for menus + if TitanPlugins[id].menuText == nil then + TitanPlugins[id].menuText = TitanPlugins[id].id; end - end - if issue ~= "" then - result = TITAN_REGISTER_FAILED - else - -- We are almost done- - -- Allow mouse clicks on the plugin - local pluginID = TitanUtils_GetButtonID(self:GetName()); - local plugin_id = TitanUtils_GetPlugin(pluginID); - if (plugin_id) then - self:RegisterForClicks("LeftButtonUp", "RightButtonUp", "MiddleButtonUp"); - self:RegisterForDrag("LeftButton") - if (plugin_id.id) then - TitanPanelDetectPluginMethod(plugin_id.id); + TitanPlugins[id].menuText = NoColor(TitanPlugins[id].menuText) + + table.insert(TitanPluginsIndex, self.registry.id); + table.sort(TitanPluginsIndex, + function(a, b) + return string.lower(TitanPlugins[a].menuText) + < string.lower(TitanPlugins[b].menuText); end - end - result = TITAN_REGISTERED - -- determine the plugin category - cat = (self.registry.category or "General") - ptype = TITAN_ID -- Assume it is created for Titan - if self.registry.ldb then - -- Override the type with the LDB type - ptype = "LDB: '"..self.registry.ldb.."'" - end - -- === Right click menu - local f = CreateFrame("Frame", - self:GetName()..TITAN_PANEL_CLICK_MENU_SUFFIX, - self or nil, - "UIDropDownMenuTemplate") + ); end - notes = (self.registry.notes or "") - - else - -- There could be a couple reasons the .registry was not found + end + if issue ~= "" then result = TITAN_REGISTER_FAILED - if (not self.registry) then - issue = "Can not find registry for plugin (self.registry)" + else + -- We are almost done- + -- Allow mouse clicks on the plugin + local pluginID = TitanUtils_GetButtonID(self:GetName()); + local plugin_id = TitanUtils_GetPlugin(pluginID); + if (plugin_id) then + self:RegisterForClicks("LeftButtonUp", "RightButtonUp", "MiddleButtonUp"); + self:RegisterForDrag("LeftButton") + if (plugin_id.id) then + TitanPanelDetectPluginMethod(plugin_id.id); + end end - if (self.registry and not self.registry.id) then - issue = "Can not determine plugin name (self.registry.id)" + result = TITAN_REGISTERED + -- determine the plugin category + cat = (self.registry.category or "General") + ptype = TITAN_ID -- Assume it is created for Titan + if self.registry.ldb then + -- Override the type with the LDB type + ptype = "LDB: '" .. self.registry.ldb .. "'" end + -- === Right click menu + local f = CreateFrame("Frame", + self:GetName() .. TITAN_PANEL_CLICK_MENU_SUFFIX, + self or nil, + "UIDropDownMenuTemplate") + end + notes = (self.registry.notes or "") + else + -- There could be a couple reasons the .registry was not found + result = TITAN_REGISTER_FAILED + if (not self.registry) then + issue = "Can not find registry for plugin (self.registry)" + end + if (self.registry and not self.registry.id) then + issue = "Can not determine plugin name (self.registry.id)" end end + -- end else -- The button could not be determined - the plugin is hopeless result = TITAN_REGISTER_FAILED @@ -1891,12 +1736,12 @@ local function TitanUtils_RegisterPluginProtected(plugin) -- Debug if Titan_Global.debug.plugin_register then TitanDebug("Plugin RegProt" --- .." '"..tostring(self:GetName()).."'" - .." '"..tostring(id).."'" - .." '"..tostring(result).."'" - .." '"..tostring(str).."'" - .." '"..tostring(TitanPlugins[id].id).."'" - ) + -- .." '"..tostring(self:GetName()).."'" + .. " '" .. tostring(id) .. "'" + .. " '" .. tostring(result) .. "'" + .. " '" .. tostring(str) .. "'" + .. " '" .. tostring(TitanPlugins[id].id) .. "'" + ) end -- create and return the results local ret_val = {} @@ -1909,15 +1754,9 @@ local function TitanUtils_RegisterPluginProtected(plugin) return ret_val end ---[[ Titan -NAME: TitanUtils_RegisterPlugin -DESC: Attempt to register a plugin that has requested to be registered -VAR: -- plugin - frame of the plugin (must be a Titan template) -OUT: None -NOTE: -- Lets be extremely paranoid here because registering plugins that do not play nice can cause real headaches... ---]] +---Titan Attempt to register a plugin that has requested to be registered +--- Lets be extremely paranoid here because registering plugins that do not play nice can cause real headaches... +---@param plugin table Plugin frame - Titan template function TitanUtils_RegisterPlugin(plugin) local call_success, ret_val -- Ensure we have a glimmer of a plugin and that the plugin has not @@ -1927,8 +1766,8 @@ function TitanUtils_RegisterPlugin(plugin) if plugin.self then -- Just in case, catch any errors call_success, -- needed for pcall - ret_val = -- actual return values - pcall (TitanUtils_RegisterPluginProtected, plugin) + ret_val = -- actual return values + pcall(TitanUtils_RegisterPluginProtected, plugin) -- pcall does not allow errors to propagate out. Any error -- is returned as text with the success / fail. -- Think of it as a try - catch block @@ -1957,15 +1796,15 @@ function TitanUtils_RegisterPlugin(plugin) -- If there was an error tell the user. if not plugin.issue == "" - or plugin.status ~= TITAN_REGISTERED then + or plugin.status ~= TITAN_REGISTERED then TitanPrint(TitanUtils_GetRedText("Error Registering Plugin") - ..TitanUtils_GetGreenText( + .. TitanUtils_GetGreenText( ": " - .."name: '"..(plugin.name or "?_").."' " - .."issue: '"..(plugin.issue or "?_").."' " - .."button: '"..plugin.button.."' " - ) + .. "name: '" .. (plugin.name or "?_") .. "' " + .. "issue: '" .. (plugin.issue or "?_") .. "' " + .. "button: '" .. plugin.button .. "' " ) + , "error") end -- Debug @@ -1977,22 +1816,16 @@ function TitanUtils_RegisterPlugin(plugin) status = TitanUtils_GetGreenText(status) end TitanDebug("Registering Plugin" - .." "..tostring(plugin.name).."" - .." "..tostring(status).."" - ) + .. " " .. tostring(plugin.name) .. "" + .. " " .. tostring(status) .. "" + ) end end end ---[[ Titan -NAME: TitanUtils_RegisterPluginList -DESC: Attempt to register the list of plugins that have requested to be registered -VAR: None -OUT: None -NOTE: -- Tell the user when this starts and ends only on the first time. - This could be called if a plugin requests to be registered after the first loop through. ---]] +---Titan Attempt to register the list of plugins that have requested to be registered +--- Tell the user when this starts and ends only on the first time. +--- This could be called if a plugin requests to be registered after the first loop through. function TitanUtils_RegisterPluginList() -- Loop through the plugins that have requested to be loaded into Titan. local result = "" @@ -2010,19 +1843,14 @@ function TitanUtils_RegisterPluginList() cnt = cnt + 1 end if not Titan__InitializedPEW and TitanAllGetVar("Registered") then - TitanDebug((L["TITAN_PANEL_REGISTER_END"].." "..cnt), "normal") + TitanDebug((L["TITAN_PANEL_REGISTER_END"] .. " " .. cnt), "normal") end end end ---[[ API -NAME: TitanUtils_IsPluginRegistered -DESC: See if the given plugin was registered successfully. -VAR: -- id - id of the plugin -OUT: None -- true (successful) or false ---]] +---API See if the given plugin was registered successfully. +---@param id string Plugin id +---@return boolean registered True if registered; False if not function TitanUtils_IsPluginRegistered(id) if (id and TitanPlugins[id]) then return true; @@ -2033,58 +1861,42 @@ end --====== Right click menu routines for Titan Panel bars and plugins ---[[ Titan -NAME: TitanUtils_CloseRightClickMenu -DESC: Close the right click menu of any plugin if it was open. Only one can be open at a time. -VAR: None -OUT: None ---]] +---Titan Close the right click menu of any plugin, if it was open. Only one can be open at a time. function TitanUtils_CloseRightClickMenu() if (_G["DropDownList1"]:IsVisible()) then _G["DropDownList1"]:Hide(); end end ---[[ local -NAME: TitanRightClickMenu_OnLoad -DESC: Prepare the plugin right click menu using the function given by the plugin or Titan bar. -VAR: -- self - menu frame of the plugin as created when the plugin was successfully registered. -OUT: None -NOTE: -- This routine handles Titan plugins and the Titan bars. -- UIDropDownMenu_Initialize appears to be 'safe'. Any error is returned rather than propagated. +---local Prepare the plugin right click menu using the function given by the plugin OR Titan bar. +---@param self table Titan Bar or Plugin frame +--- See the routine for details on determining the menu function. +--- UIDropDownMenu_Initialize will place (part of) the error in the menu - it is not progagated out. +--- Set Titan_Global.debug.menu to output the error to Chat. +local function TitanRightClickMenu_OnLoad(self) +--[[ - The function to create the menu is either -1. set in registry in .menuTextFunction -: New in 2024 Feb to make the routine explicit +1. set in registry in .menuTextFunction +: New in 2024 Feb to make the routine explicit (UIDropDownMenu_Initialize appears to be 'safe') : If a function then the routine can be local or in the global namespace : If a string then the routine MUST be in the global namespace. 2. assumed to be "TitanPanelRightClickMenu_Prepare"..plugin_id.."Menu" : This is the way Titan was written -- TitanUtils_GetButtonIDFromMenu returns a generic "Bar" when the user clicks on a Titan bar. +- TitanUtils_GetButtonIDFromMenu returns a generic "Bar" when the user clicks on a Titan bar. This works because every Titan bar uses the same menu allowing one routine to be reused. --]] -local function TitanRightClickMenu_OnLoad(self) local id = TitanUtils_GetButtonIDFromMenu(self) -- "Bar" if self is any Titan bar local err = "" if id then local frame = TitanUtils_GetPlugin(id) -- get plugin frame ---[[ -print("RC* _OnLoad" -.." "..tostring(id).."" -.." "..tostring(self:GetName()).."" -.." "..tostring(frame).."" ---.." "..tostring(frame.menuTextFunction).."" -) ---]] local prepareFunction -- function to call - + if frame and frame.menuTextFunction then prepareFunction = frame.menuTextFunction -- Newer method 2024 Feb else -- If 'bar' then routine for ALL Titan bars - prepareFunction = "TitanPanelRightClickMenu_Prepare"..id.."Menu" + prepareFunction = "TitanPanelRightClickMenu_Prepare" .. id .. "Menu" end - + if type(prepareFunction) == 'string' then -- Function MUST be in global namespace -- Becomes nil if not found @@ -2095,23 +1907,23 @@ print("RC* _OnLoad" -- Invalid type, do not even try... prepareFunction = nil end - + if prepareFunction then UIDropDownMenu_Initialize(self, prepareFunction, "MENU") else err = "Could not display tooltip. " - .."No function for '"..tostring(id).."' " - .."["..tostring(type(prepareFunction)).."] " - .."["..tostring(prepareFunction).."] " - ..". " + .. "No function for '" .. tostring(id) .. "' " + .. "[" .. tostring(type(prepareFunction)) .. "] " + .. "[" .. tostring(prepareFunction) .. "] " + .. ". " end else err = "Could not display tooltip. " - .."Unknown Titan ID for " - .."'"..(self:GetName() or "?").."'. " + .. "Unknown Titan ID for " + .. "'" .. (self:GetName() or "?") .. "'. " end - - if Titan_Global.debug.tool_tips then + + if Titan_Global.debug.menu then if err == "" then -- all is good else @@ -2122,24 +1934,17 @@ print("RC* _OnLoad" return DropDownList1, DropDownList1:GetHeight(), DropDownList1:GetWidth() end ---[[ Titan -NAME: TitanPanelRightClickMenu_Toggle -DESC: Call the routine to build the plugin menu then place it properly. -VAR: -- self - frame of the plugin (must be a Titan template) -- isChildButton - function to create the menu -OUT: None -NOTE: -- This routine is for Titan plugins. There is a similar routine for the Titan bar. ---]] +---Titan Call the routine to build the plugin menu then place it properly. +--- This routine is for Titan plugins. There is a similar routine for the Titan bar. +---@param self table Plugin frame function TitanPanelRightClickMenu_Toggle(self) -- Mar 2023 : Rewritten to place menu relative to the passed in frame (button) -- There are two places for the menu creation routine -- 1) Titan bar - creates same menu -- 2) Plugin creation via the .registry - local frame = self:GetName() - local menu = _G[self:GetName()..TITAN_PANEL_CLICK_MENU_SUFFIX] ---[[ + local frame = self:GetName() + local menu = _G[self:GetName() .. TITAN_PANEL_CLICK_MENU_SUFFIX] + --[[ print("_ toggle R menu" .." "..tostring(frame).."" ) @@ -2149,7 +1954,7 @@ print("_ toggle R menu" -- Adjust the Y offset as needed local rel_y = _G[frame]:GetTop() - menu_height - if rel_y > 0 then + if rel_y > 0 then menu.point = "TOP"; menu.relativePoint = "BOTTOM"; else @@ -2172,10 +1977,10 @@ print("_ toggle R menu" left = _G[frame]:GetLeft() end local rel_x = left + menu_width - if ( rel_x < GetScreenWidth() ) then + if (rel_x < GetScreenWidth()) then -- menu will fit - menu.point = menu.point.."LEFT"; - menu.relativePoint = menu.relativePoint.."LEFT"; + menu.point = menu.point .. "LEFT"; + menu.relativePoint = menu.relativePoint .. "LEFT"; if TitanBarData[frame] then x_offset = left @@ -2184,10 +1989,10 @@ print("_ toggle R menu" x_offset = 0 end else - -- Menu would go off right side of the screen - menu.point = menu.point.."RIGHT"; - menu.relativePoint = menu.relativePoint.."RIGHT"; - + -- Menu would go off right side of the screen + menu.point = menu.point .. "RIGHT"; + menu.relativePoint = menu.relativePoint .. "RIGHT"; + if TitanBarData[frame] then -- correct is on Titan bar (bottom, far right) -- flip calc since we flipped the anchor to right @@ -2197,7 +2002,7 @@ print("_ toggle R menu" x_offset = 0 end end ---[[ + --[[ print("RCM" .." "..tostring(frame).."" .." "..tostring(format("%0.1f", menu_height)).."" @@ -2215,13 +2020,8 @@ print("RCM" end end ---[[ Titan -NAME: TitanPanelRightClickMenu_IsVisible -DESC: Determine if a right click menu is shown. There can only be one. -VAR: None -OUT: -- true (IsVisible) or false ---]] +---Titan Determine if a right click menu is shown. There can only be one. +---@return boolean IsVisible function TitanPanelRightClickMenu_IsVisible() local res = false if _G[drop_down_1] and _G[drop_down_1]:IsVisible() then @@ -2232,12 +2032,7 @@ function TitanPanelRightClickMenu_IsVisible() return res end ---[[ Titan -NAME: TitanPanelRightClickMenu_Close -DESC: Close the right click menu if shown. There can only be one. -VAR: None -OUT: None ---]] +---Titan Close the right click menu if shown. There can only be one. function TitanPanelRightClickMenu_Close() if _G[drop_down_1] and _G[drop_down_1]:IsVisible() then _G[drop_down_1]:Hide() @@ -2246,80 +2041,60 @@ end --====== Titan utility routines ---[[ Titan -NAME: TitanUtils_ParseName -DESC: Parse the player name and return the parts. -VAR: -- name - the name to break up -OUT: -- string player name only -- string realm name only ---]] +---Titan Parse the Titan player / profile name and return the parts. +---@param name string Titan player / profile name +---@return string player_name or "" +---@return string server_name or "" function TitanUtils_ParseName(name) local server = "" local player = "" if name and name ~= TITAN_PROFILE_NONE then local s, e, ident = string.find(name, TITAN_AT); if s ~= nil then - server = string.sub(name, s+1); - player = string.sub(name, 1, s-1); + server = string.sub(name, s + 1); + player = string.sub(name, 1, s - 1); end else end return player, server end ---[[ Titan -NAME: TitanUtils_CreateName -DESC: Given the player name and server and return the Titan name. -VAR: -- player - 1st part -- realm - 2nd part. Could be realm or 'custom' -OUT: -- string - Titan name ---]] +---Titan Given the player name and server and return the Titan player name; also used as profile name. +---@param player string +---@param realm string realm name or default +---@return string toon <player>@<realm> function TitanUtils_CreateName(player, realm) local p1 = player or "?" local p2 = realm or "?" - return p1..TITAN_AT..p2 + return p1 .. TITAN_AT .. p2 end ---[[ Titan -NAME: TitanUtils_GetPlayer -DESC: Create the player name (toon being played) and return the parts. -VAR: None -OUT: -- string Titan player name or nil -- string player name only -- string realm name only ---]] +---Titan Create the character name / toon being played and return the parts. +---@return string toon name or "<>" +---@return string player_name or "" +---@return string server_name or "" function TitanUtils_GetPlayer() local playerName = UnitName("player"); local serverName = GetRealmName(); - local toon = nil + local toon = "<>" if (playerName == nil - or serverName == nil - or playerName == UKNOWNBEING) then + or serverName == nil + or playerName == UKNOWNBEING) then -- Do nothing if player name is not available else - toon = playerName..TITAN_AT..serverName + toon = playerName .. TITAN_AT .. serverName end return toon, playerName, serverName end ---[[ Titan -NAME: TitanUtils_GetGlobalProfile -DESC: Return the global profile setting and the global profile name, if any. -VAR: None -OUT: -- bool Global profile value -- string Global profile name or default -- string player name only or blank -- string realm name only or blank ---]] +---Titan Return the global profile setting and the global profile name, if any. +---@return boolean global_in_use +---@return string profile name or "<>" +---@return string player_name or "" +---@return string server_name or "" function TitanUtils_GetGlobalProfile() local playerName = "" local serverName = "" @@ -2341,14 +2116,9 @@ function TitanUtils_GetGlobalProfile() return glob, toon, playerName, serverName end ---[[ Titan -NAME: TitanUtils_SetGlobalProfile -DESC: Return the global profile setting and the global profile name, if any. -VAR: -- bool Global profile value -- string Global profile name or default -OUT: None ---]] +---Titan Return the global profile setting and the global profile name, if any. +---@param glob boolean Use global profile +---@param toon string? Global profile name or default function TitanUtils_SetGlobalProfile(glob, toon) TitanAllSetVar("GlobalProfileUse", glob) if glob then @@ -2361,43 +2131,38 @@ function TitanUtils_SetGlobalProfile(glob, toon) TitanAllSetVar("GlobalProfileName", toon or TITAN_PROFILE_NONE) end ---[[ Titan -NAME: TitanUtils_ScreenSize -DESC: Return the screen size after scaling -VAR: -- output - boolean if true dump a lot of UI size info to chat -OUT: -- number - scaled X / width -- number - scaled Y / height ---]] -function TitanUtils_ScreenSize(output) +---Titan Return the screen size after scaling +---@return table screenXY { x | y | scaled_x | scaled_y } all numbers +function TitanUtils_ScreenSize() local screen = {} - screen.x = UIParent:GetRight() - screen.y = UIParent:GetTop() + screen.x = UIParent:GetRight() + screen.y = UIParent:GetTop() screen.scaled_x = UIParent:GetRight() * UIParent:GetEffectiveScale() screen.scaled_y = UIParent:GetTop() * UIParent:GetEffectiveScale() + --[[ if output then local x = UIParent:GetRight() local y = UIParent:GetTop() local s = UIParent:GetEffectiveScale() local px, py = GetPhysicalScreenSize() print("_ScreenSize" - .."\n" - .." UI - x:"..tostring(format("%0.1f", x)).."" - .." X y:"..tostring(format("%0.1f", y)).."" - .."\n" - .." UI scaled - x:"..tostring(format("%0.1f", screen.x * UIParent:GetEffectiveScale())).."" - .." X y:"..tostring(format("%0.1f", screen.y * UIParent:GetEffectiveScale())).."" - .."\n" - .." Scale: UI"..tostring(format("%0.6f", s)).."" - .." Titan "..tostring(format("%0.1f", TitanPanelGetVar("Scale"))).."" - .."\n" - .." screen - x:"..tostring(format("%0.1f", px)).."" - .." X y:"..tostring(format("%0.1f", py)).."" + .. "\n" + .. " UI - x:" .. tostring(format("%0.1f", x)) .. "" + .. " X y:" .. tostring(format("%0.1f", y)) .. "" + .. "\n" + .. " UI scaled - x:" .. tostring(format("%0.1f", screen.x * UIParent:GetEffectiveScale())) .. "" + .. " X y:" .. tostring(format("%0.1f", screen.y * UIParent:GetEffectiveScale())) .. "" + .. "\n" + .. " Scale: UI" .. tostring(format("%0.6f", s)) .. "" + .. " Titan " .. tostring(format("%0.1f", TitanPanelGetVar("Scale"))) .. "" + .. "\n" + .. " screen - x:" .. tostring(format("%0.1f", px)) .. "" + .. " X y:" .. tostring(format("%0.1f", py)) .. "" ) end - +--]] + return screen end @@ -2410,49 +2175,42 @@ local idx = TitanDebugArray.index TitanDebugArray.lines[TitanDebugArray.index] = (date("%m/%d/%y %H:%M:%S".." : ")..message) end --]] ---[[ Titan -NAME: TitanPanel_GetVersion -DESC: Get the Titan version into a string. -VAR: None -OUT: -- string containing the version ---]] + +---Titan Get the Titan version as a string. +---@return string version function TitanPanel_GetVersion() return tostring(TitanUtils_GetAddOnMetadata(TITAN_ID, "Version")) or L["TITAN_PANEL_NA"]; end ---[[ Titan -NAME: TitanPrint -DESC: Output a message to the user in a consistent format. -VAR: -- message - string to output -- msg_type - "info" | "warning" | "error" | "plain" -OUT: -- string - message to chat window ---]] +---Titan: Output a message safely to the user in a consistent format. +---@param message string Message to output ot Chat +---@param msg_type string? "info" | "warning" | "error" | "plain" | nil function TitanPrint(message, msg_type) local dtype = "" - local pre = TitanUtils_GetGoldText(L["TITAN_PANEL_PRINT"]..": ") + local pre = TitanUtils_GetGoldText(L["TITAN_PANEL_PRINT"] .. ": ") local msg = "" if msg_type == "error" then dtype = TitanUtils_GetRedText("Error: ") elseif msg_type == "warning" then - dtype = "|cFFFFFF00".."Warning: ".._G["FONT_COLOR_CODE_CLOSE"] + dtype = "|cFFFFFF00" .. "Warning: " .. _G["FONT_COLOR_CODE_CLOSE"] elseif msg_type == "plain" then pre = "" elseif msg_type == "header" then local ver = TitanPanel_GetVersion() pre = TitanUtils_GetGoldText(L["TITAN_PANEL"]) - ..TitanUtils_GetGreenText(" "..ver) - ..TitanUtils_GetGoldText(L["TITAN_PANEL_VERSION_INFO"] + .. TitanUtils_GetGreenText(" " .. ver) + .. TitanUtils_GetGoldText(L["TITAN_PANEL_VERSION_INFO"] ) end - msg = pre..dtype..TitanUtils_GetGreenText(message) + msg = pre .. dtype .. TitanUtils_GetGreenText(tostring(message)) DEFAULT_CHAT_FRAME:AddMessage(msg) --- Debug_array(msg) + -- Debug_array(msg) end +---Titan: Output a debug message safely in a consistent format. +---@param debug_message string Message to output to Chat +---@param debug_type string? "warning" | "error" | "normal" | nil function TitanDebug(debug_message, debug_type) local dtype = "" local time_stamp = "" @@ -2465,7 +2223,7 @@ function TitanDebug(debug_message, debug_type) if debug_type == "normal" then time_stamp = "" else - time_stamp = TitanUtils_GetGoldText(date("%H:%M:%S")..": ") + time_stamp = TitanUtils_GetGoldText(date("%H:%M:%S") .. ": ") end if debug_message == true then debug_message = "<true>"; @@ -2478,27 +2236,31 @@ function TitanDebug(debug_message, debug_type) end msg = - TitanUtils_GetGoldText(L["TITAN_PANEL_DEBUG"].." ") - ..time_stamp - ..dtype --- ..TitanUtils_GetBlueText(debug_message) - ..TitanUtils_GetHexText(debug_message, "1DA6C5") + TitanUtils_GetGoldText(L["TITAN_PANEL_DEBUG"] .. " ") + .. tostring(time_stamp) + .. tostring(dtype) + -- ..TitanUtils_GetBlueText(debug_message) + .. TitanUtils_GetHexText(tostring(debug_message), "1DA6C5") if not TitanAllGetVar("Silenced") then _G["DEFAULT_CHAT_FRAME"]:AddMessage(msg) end --- Debug_array(msg) + -- Debug_array(msg) --date("%m/%d/%y %H:%M:%S") end +---API: Output a debug message in a consistent format. +---@param id string Plugin id +---@param debug_message string Message to output to Chat function TitanPluginDebug(id, debug_message) local msg = - TitanUtils_GetGoldText("<"..tostring(id).."> "..date("%H:%M:%S")) - .." "..TitanUtils_GetHexText(tostring(debug_message), "1DA6C5") - + TitanUtils_GetGoldText("<" .. tostring(id) .. "> " .. date("%H:%M:%S")) + .. " " .. TitanUtils_GetHexText(tostring(debug_message), "1DA6C5") + _G["DEFAULT_CHAT_FRAME"]:AddMessage(msg) end +---Titan: Output the current list of registered plugins. function TitanDumpPluginList() -- Just dump the current list of plugins local plug_in = {} @@ -2506,32 +2268,34 @@ function TitanDumpPluginList() plug_in = TitanUtils_GetPlugin(TitanPluginsIndex[idx]) if plug_in then TitanDebug("TitanDumpPluginList " - .."'"..idx.."'" - ..": '"..(plug_in.id or "?").."'" - ..": '"..(plug_in.version or "?").."'" + .. "'" .. tostring(idx) .. "'" + .. ": '" .. tostring(plug_in.id) .. "'" + .. ": '" .. tostring(plug_in.version) .. "'" ) end end end +---Titan: Output the current list of known characters / toons. function TitanDumpPlayerList() - -- Just dump the current list of toons in Titan config local cnt = 0 TitanDebug("TitanDumpPlayerList ==== start") if TitanSettings.Players then for idx, value in pairs(TitanSettings.Players) do TitanDebug("-- " - .."'"..(idx or "?").."'" + .. "'" .. tostring(idx) .. "'" ) cnt = cnt + 1 end else TitanDebug("No player list found!!! " - ) + ) end - TitanDebug("TitanDumpPlayerList ==== done "..cnt) + TitanDebug("TitanDumpPlayerList ==== done " .. cnt) end +---Titan: Output the frame name, if known,and its parent name. +---@param self table Any frame function TitanDumpFrameName(self) local frame local parent @@ -2545,62 +2309,99 @@ function TitanDumpFrameName(self) else parent = self:GetParent():GetName() end ---[ -TitanDebug("_GetFrameName " -..(self and "T" or "F").." " -..(frame or "?").." " -..(parent or "?").." " -) ---]] + --[ + TitanDebug("_GetFrameName " + .. tostring(self and "T" or "F") .. " " + .. tostring(frame) .. " " + .. tostring(parent) .. " " + ) + --]] end +---Titan: Output the value of Titan timer saved variables.TODO : (Needs Classic update!!) function TitanDumpTimers() local str = "Titan-timers: " - .."'"..(TitanAllGetVar("TimerLDB") or "?").."' " + .. "'" .. tostring(TitanAllGetVar("TimerLDB")) .. "' " TitanPrint(str, "plain") end -function TitanArgConvert (event, a1, a2, a3, a4, a4, a5, a6) +---Titan: Output an event and args 1 - 6. +---@param event string +---@param a1 any Argument 1 +---@param a2 any Argument 2 +---@param a3 any Argument 3 +---@param a4 any Argument 4 +---@param a5 any Argument 5 +---@param a6 any Argument 6 +function TitanArgConvert(event, a1, a2, a3, a4, a5, a6) local t1 = type(a1) local t2 = type(a2) local t3 = type(a3) local t4 = type(a4) local t5 = type(a5) local t6 = type(a6) - if type(a1) == "boolean" then a1 = (a1 and "T" or "F") end - if type(a2) == "boolean" then a2 = (a2 and "T" or "F") end - if type(a3) == "boolean" then a3 = (a3 and "T" or "F") end - if type(a4) == "boolean" then a4 = (a4 and "T" or "F") end - if type(a5) == "boolean" then a5 = (a5 and "T" or "F") end - if type(a6) == "boolean" then a6 = (a6 and "T" or "F") end - TitanDebug(event.." " - .."1: "..(a1 or "?").."("..t1..") " - .."2: "..(a2 or "?").."("..t2..") " - .."3: "..(a3 or "?").."("..t3..") " - .."4: "..(a4 or "?").."("..t4..") " - .."5: "..(a5 or "?").."("..t5..") " - .."6: "..(a6 or "?").."("..t6..") " + TitanDebug(tostring(event) .. " " + .. "1: " .. tostring(a1) .. "(" .. tostring(t1) .. ") " + .. "2: " .. tostring(a2) .. "(" .. tostring(t2) .. ") " + .. "3: " .. tostring(a3) .. "(" .. tostring(t3) .. ") " + .. "4: " .. tostring(a4) .. "(" .. tostring(t4) .. ") " + .. "5: " .. tostring(a5) .. "(" .. tostring(t5) .. ") " + .. "6: " .. tostring(a6) .. "(" .. tostring(t6) .. ") " ) end +---Titan: Output a given table; up to a depth of 8 levels. +---@param tb table +---@param level integer? 1 or defaults to 1 function TitanDumpTable(tb, level) - level = level or 1 - local spaces = string.rep(' ', level*2) - for k,v in pairs(tb) do - if type(v) ~= "table" then - print("["..level.."]v'"..spaces.."["..tostring(k).."]='"..tostring(v).."'") - else - print("["..level.."]t'"..spaces.."["..tostring(k).."]") - level = level + 1 - if level <= 8 then - TitanDumpTable(v, level) - end - end - end + level = level or 1 + local spaces = string.rep(' ', level * 2) + for k, v in pairs(tb) do + if type(v) ~= "table" then + print("[" .. level .. "]v'" .. spaces .. "[" .. tostring(k) .. "]='" .. tostring(v) .. "'") + else + print("[" .. level .. "]t'" .. spaces .. "[" .. tostring(k) .. "]") + level = level + 1 + if level <= 8 then + TitanDumpTable(v, level) + end + end + end end --====== Deprecated routines -- These routines will be commented out for a couple releases then deleted. -- --[===[ + +Below 2024 Mar + +This routine is really broken... unlikely it worked. +--[[ API +NAME: TitanPanelRightClickMenu_AddToggleColoredText +DESC: This will toggle the "ShowColoredText" Titan variable then update the button +VAR: id - id of the plugin +VAR: level - level to put the line +OUT: None +--]] +function TitanPanelRightClickMenu_ToggleColoredText(value) + TitanToggleVar(value, "ShowColoredText"); + TitanPanelButton_UpdateButton(value, 1); +end + +---API Check if all the variables in the table are nil/false. +---@param id string Plugin id +---@param toggleTable table {} +---@return boolean all_nil true (1) or nil +function TitanPanelRightClickMenu_AllVarNil(id, toggleTable) + if ( toggleTable ) and type(toggleTable)== "table" then + for i, v in toggleTable do + if ( TitanGetVar(id, v) ) then + return nil; + end + end + return 1; + end +end + --]===] diff --git a/Titan/TitanVariables.lua b/Titan/TitanVariables.lua index 103364a..44009b7 100644 --- a/Titan/TitanVariables.lua +++ b/Titan/TitanVariables.lua @@ -1,8 +1,8 @@ ---[[ File -NAME: TitanVariables.lua -DESC: This file contains the routines to initialize, get, and set the basic data structures used by Titan. -It also sets the global variables and constants used by Titan. +--[===[ File +This file contains the routines to initialize, get, and set the basic data structures used by Titan. +--]===] +--[===[ Var TitanBarData ^^: Titan static bar reference and placement info TitanAll is used for settings used for Titan itself such as use global profile, tootip modifier, etc. TitanSettings, TitanSkins, ServerTimeOffsets, ServerHourFormat are the structures saved to disk (listed in toc). @@ -18,7 +18,7 @@ TitanPluginSettings = TitanSettings.Players[toon].Plugins : Successful registe TitanPanelSettings = TitanSettings.Players[toon].Panel : ** TitanPanelRegister = TitanSettings.Players[toon].Register : .registry of all plugins (Titan and LDB) to be registered with Titan TitanBarDataVars ^^= TitanSettings.Players[toon].BarVars : Titan user selected placement info -TitanAdjustSettings = TitanSettings.Players[toon].Adjust : List of frames Titan can adjust, vertically only +TitanAdjustSettings = TitanSettings.Players[toon].Adjust : List of frames Titan can adjust, vertically only ** : - Has Plugin placement data under Location and Buttons @@ -26,9 +26,9 @@ TitanAdjustSettings = TitanSettings.Players[toon].Adjust : List of frames Tit - Per character Titan settings plugin spacing, global skin, etc ^^ : -- The index is the string name of the Titan Bar to coordinate staic and user selected bar data -:DESC ---]] +- The index is the string name of the Titan Bar. +Having the same index helps coordinate static and user selected bar data +--]===] local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) local _G = getfenv(0); @@ -40,7 +40,7 @@ if (GetLocale() == "ruRU") then end local TPC = TITAN_PANEL_CONSTANTS -- shortcut ---[[ Titan +--[===[ Titan NAME: Titan bar overview DESC: -- 3 button frames are used to create a Titan bar: @@ -48,11 +48,10 @@ DESC: -- the 'hider' which is a blank 1/2 height bar to capture the cursor moving to the bar, -- and the 'auto hide' plugin displaying the 'push pin' button. :DESC ---]] +--]===] ---[[ Titan -NAME: TitanBarData table. -DESC: +--[===[ Var +TitanBarData table. The table holds: - the name of each Titan bar (as the index) - the short name of the bar @@ -63,22 +62,41 @@ The table holds: The short name is used to build names of the various saved variables, frames, and buttons used by Titan. -:DESC --]] +--]===] local SHORT_WIDTH = 200 local y_top = GetScreenHeight() -- * UIParent:GetEffectiveScale() local x_max = GetScreenWidth() local x_mid = (GetScreenWidth() / 2) - (SHORT_WIDTH / 2) +---local Calc screen Y +---@return number local function Calc_Y(n) return (GetScreenHeight() - (TITAN_PANEL_BAR_HEIGHT * n)) end + +---local Calc screen X +---@return number local function Calc_X() return (GetScreenWidth() / 2) - (SHORT_WIDTH / 2) end --[[ --]] +---@class TitanBarData Titan Bar description +---@field frame_name string Full bar frame name, same as index +---@field locale_name string Localized short name +---@field name string Internal short name +---@field vert string TITAN_TOP | TITAN_BOTTOM | TITAN_SHORT +---@field tex_name string Full frame name for texture - Titan skin +---@field hider string Full frame name of hider - TITAN_TOP / TITAN_BOTTOM only +---@field hide_y integer Offset to move if hidden (offscreen) +---@field plugin_y_offset integer Plugin offset within bar +---@field plugin_x_offset integer Min width, short bars only +---@field show table Used for SetPoint to display the bar +---@field bott? table Used for SetPoint to display full bar only (sized using two points) +---@field user_move boolean false - full bar; true - short bar +---This holds the static data used to set up and control Titan bars. + TitanBarData = { [TITAN_PANEL_DISPLAY_PREFIX .. "Bar"] = { frame_name = TITAN_PANEL_DISPLAY_PREFIX .. "Bar", @@ -136,7 +154,6 @@ TitanBarData = { hide_y = -(TITAN_PANEL_BAR_HEIGHT * 3), plugin_y_offset = 1, plugin_x_offset = 5, - position = { eff_x = 0, eff_y = 0, eff_width = 0 }, show = { pt = "TOPLEFT", rel_fr = "UIParent", rel_pt = "BOTTOMLEFT", }, bott = { pt = "BOTTOMRIGHT", rel_fr = "UIParent", rel_pt = "BOTTOMRIGHT", }, user_move = false, @@ -283,9 +300,7 @@ TitanBarData = { }, } ---[[ Titan -NAME: TitanBarPositions table. -DESC: +--[===[ Var TitanBarPositions table The table holds: - the name of each Titan bar (as the index) - the X and Y position of the bar @@ -296,14 +311,27 @@ This table wil be saved under "Players" to rember the placement of Short bars. The cooresponding Defaults table holds the starting values. The original Titan (full width) bars values are used for default X and Y -:DESC --]] +--]===] TitanBarDataVars = {} TitanSkinsDefaultPath = "Interface\\AddOns\\Titan\\Artwork\\" TitanSkinsCustomPath = TitanSkinsDefaultPath .. "Custom\\" TitanSkinsPathEnd = "\\" +---@class TitanBarVars Titan Bar variables selectable by user +---@field off_x integer Offset for SetPoint +---@field off_y integer Offset for SetPoint +---@field off_w integer Bar width +---@field skin table Path and alpha / transparency +---@field color table r,b,g,alpha as number 1.0 - 0.0 +---@field texure string Titan_Global.NONE | Titan_Global.SKIN | Titan_Global.COLOR +---@field show boolean Whether user wants this Bar shown or not +---@field auto_hide boolean Whether user wants this Bar on auto hide or not +---@field align integer TITAN_PANEL_BUTTONS_ALIGN_LEFT | TITAN_PANEL_BUTTONS_ALIGN_CENTER +---@field hide_in_combat boolean Whether user wants this Bar hidden during combat or not +---Index is the Full bar frame name, same as TitanBarData. +---Global is an additional index used if the user wants all Bars to be the same skin or color. + TitanBarVarsDefaults = { ["Global"] = -- holds 'global' user settings; NOT for use in the frame loop! { @@ -486,32 +514,26 @@ local TitanAdjDefaults = { adjust = false, offset = 0, } -Titan_Global.AdjList = { -- TODO : localize - ["UIWidgetTopCenterContainerFrame"] = { - frame_name = "UIWidgetTopCenterContainerFrame", - purpose = "Status for BG / Dungeon", - }, -} TitanAdjustSettings = {} -- holds frames that Titan allows user to adjust -- Timers used within Titan TitanTimers = {} ---[[ Titan +--[===[ Var TitanPluginToBeRegistered table holds each plugin that is requesting to be a plugin. TitanPluginToBeRegisteredNum is the number of plugins that have requested. Each plugin in the table will be updated with the status of the registration and will be available in the Titan Attempted option. ---]] +--]===] TitanPluginToBeRegistered = {} TitanPluginToBeRegisteredNum = 0 TitanPluginRegisteredNum = 0 ---[[ Titan +--[===[ Var TitanPluginExtras table holds the plugin data for plugins that are in saved variables but not loaded on the current character. Saved as TitanPlayerSettings.Extra TitanPluginExtrasNum is the number of plugins not loaded. ---]] +--]===] TitanPluginExtras = {} TitanPluginExtrasNum = 0 @@ -528,9 +550,9 @@ local Default_Plugins = { { id = "Bag", loc = "Bar" }, { id = "Repair", loc = "Bar" }, } ---[[ Titan +--[===[ Var TITAN_PANEL_SAVED_VARIABLES table holds the Titan Panel Default SavedVars. ---]] +--]===] TITAN_PANEL_SAVED_VARIABLES = { Buttons = {}, Location = {}, @@ -584,9 +606,9 @@ TITAN_PANEL_SAVED_VARIABLES = { AuxBar2_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, }; ---[[ Titan +--[===[ Var TITAN_ALL_SAVED_VARIABLES table holds the Titan Panel Global SavedVars. ---]] +--]===] TITAN_ALL_SAVED_VARIABLES = { -- for timers in seconds TimerLDB = 2, @@ -635,6 +657,8 @@ TitanSkinsDefault = { }; TitanSkins = {} +TITAN_VERSION = TitanUtils_GetAddOnMetadata(TITAN_ID, "Version") +--[[ -- trim version if it exists local fullversion = TitanUtils_GetAddOnMetadata(TITAN_ID, "Version") if fullversion then @@ -643,13 +667,13 @@ if fullversion then TITAN_VERSION = string.sub(fullversion, 1, pos - 1); end end +--]] ---[[ local Classic +--[=[ local Classic NAME: TitanRegisterExtra -DESC: Add the saved variable data of an unloaded plugin to the 'extra' list in case the user wants to delete the data via Tian Extras option. +DESC: Add the saved variable data of an unloaded plugin to the 'extra' list in case the user wants to delete the data via Titan Extras option. VAR: id - the name of the plugin (string) OUT: None ---]] local function TitanRegisterExtra(id) TitanPluginExtrasNum = TitanPluginExtrasNum + 1 TitanPluginExtras[TitanPluginExtrasNum] = @@ -658,8 +682,11 @@ local function TitanRegisterExtra(id) id = (id or "?"), } end +--]=] -- routines to sync toon data + +---local Hide the current set of plugins to prevent overlap (creates a very messy bar!) local function CleanupProfile() if TitanPanelSettings and TitanPanelSettings["Buttons"] then -- Hide the current set of plugins to prevent overlap (creates a very messy bar!) @@ -675,13 +702,10 @@ local function CleanupProfile() TitanPanelRightClickMenu_Close(); end ---[[ local -NAME: TitanVariables_SyncRegisterSavedVariables -DESC: Helper routine to sync two sets of toon data - Titan settings and loaded plugins. -VAR: registeredVariables - current loaded data (destination) -VAR: savedVariables - data to compare with (source) -OUT: None --]] +---local Helper routine to sync two sets of toon data - Titan settings and loaded plugins. +---@param registeredVariables table current loaded data (destination) +---@param savedVariables table data to compare with (source) local function TitanVariables_SyncRegisterSavedVariables(registeredVariables, savedVariables) if (registeredVariables and savedVariables) then -- Init registeredVariables @@ -706,18 +730,16 @@ print("_sync" end end ---[[ local -NAME: Plugin_settings -DESC: Give the curent profile the default plugins - if they are registered. -VAR: reset - boolean -OUT: None -NOTE: +---local Set the plugins (if registered) +---@param reset boolean +--- - true : Use Titan default +--- - false : Use current profile +local function Plugin_settings(reset) + --[[ - It is assumed this is a plugin wipe of the given profile. - Use the default Titan plugin list to display on the given bar. - These will be saved on exit or reload in the given profile. -:NOTE --]] -local function Plugin_settings(reset) local plugin_list = {} if reset then -- use the default install list plugin_list = Default_Plugins @@ -748,19 +770,15 @@ print("plugins init" end end ---[[ local -NAME: TitanVariables_PluginSettingsInit -DESC: Give the curent profile the default plugins - if they are registered. -VAR: None -OUT: None -NOTE: +---local Set the plugins (if registered) per the curent profile. +local function TitanVariables_PluginSettingsInit() + --[[ - The saved variables of the given profile will be used. - These will be saved on exit or reload in the given profile. - The saved display list will be used but only the registered plugins will be displayed. -- The plugins that are not registered will NOT be removed from the saved list. This allows different a single saved display list to be used for toons that have different plugins enabled. -:NOTE ---]] -local function TitanVariables_PluginSettingsInit() +- The plugins that are not registered will NOT be removed from the saved list. +This allows a single saved display list to be used for toons that have different plugins enabled. + --]] -- Loop through the user's displayed plugins and see what is -- actually registered for idx, display_plugin in pairs(TitanPanelSettings.Buttons) do @@ -780,18 +798,13 @@ local function TitanVariables_PluginSettingsInit() end end ---[[ local -NAME: TitanVariables_SyncSkins -DESC: Routine to sync two sets of skins data - Titan defaults and Titan saved vars. -VAR: None -OUT: None -NOTE: -- It is assumed that the list in Titan defaults or as input from the user are in the Titan skins folder. Blizz does not allow LUA to read the hard drive directly. -:NOTE ---]] +---local Routine to sync two sets of skins data - Titan defaults and Titan saved vars. +---@return table +--- Safety in case Titan changes the default list. +--- Blizz does not allow LUA to read the hard drive directly. local function TitanVariables_SyncSkins() + local skins = {} if (TitanSkinsDefault and TitanSkins) then - local skins = {} -- insert all the Titan defaults for idx, v in pairs(TitanSkinsDefault) do table.insert(skins, TitanSkinsDefault[idx]) @@ -826,16 +839,12 @@ local function TitanVariables_SyncSkins() end end end - return skins end + return skins end ---[[ local -NAME: Set_Timers -DESC: Routine to reset / sync Titan settings. -VAR: None -OUT: None ---]] +---local Helper to reset / sync Titan settings. +---@param reset boolean local function Set_Timers(reset) -- Titan is loaded so set the timers we want to use TitanTimers = { @@ -864,12 +873,8 @@ local function Set_Timers(reset) end end ---[[ Titan -NAME: TitanVariables_SyncSinglePluginSettings -DESC: Routine to sync one plugin - current loaded (lua file) to its plugin saved vars (last save to disk). -VAR: id : plugin name -OUT: None ---]] +---Titan Routine to sync one plugin - current loaded (lua file) to its plugin saved vars (last save to disk). +---@param id string Plugin id name function TitanVariables_SyncSinglePluginSettings(id) -- Init this plugin local plugin = TitanPlugins[id] @@ -892,12 +897,8 @@ function TitanVariables_SyncSinglePluginSettings(id) end end ---[[ Titan -- one plugin uses this -NAME: TitanVariables_SyncPluginSettings -DESC: Routine to sync plugin datas - current loaded (lua file) to any plugin saved vars (last save to disk). -VAR: None -OUT: None ---]] +---Titan Routine to sync plugin datas - current loaded (lua file) to any plugin saved vars (last save to disk). +--- one plugin uses this function TitanVariables_SyncPluginSettings() -- Init / sync every plugin for id, plugin in pairs(TitanPlugins) do @@ -912,6 +913,7 @@ function TitanVariables_SyncPluginSettings() end end +---local Set the adjustable frames for TitanMovable & Config local function Titan_SyncAdjList() -- Using Titan list, walk saved vars to add adjustable frames for frame, v in pairs(Titan_Global.AdjList) do @@ -934,15 +936,8 @@ local function Titan_SyncAdjList() end end ---[[ Titan -NAME: TitanVariables_InitTitanSettings -DESC: Ensure TitanSettings (one of the saved vars in the toc) exists and set the Titan version. -VAR: None -OUT: None -NOTE: -- Called when Titan is loaded (ADDON_LOADED event) -:NOTE ---]] +---Titan Ensure TitanSettings (one of the saved vars in the toc) exists and set the Titan version. +--- Called when Titan is loaded (ADDON_LOADED event) function TitanVariables_InitTitanSettings() local trace = false local player = TitanUtils_GetPlayer() @@ -999,23 +994,17 @@ end TitanSettings.Version = TITAN_VERSION; end ---[[ Titan -NAME: TitanVariables_SetBarPos -DESC: Update local and saved vars to new bar position per user -VAR: self - frame to save position -OUT: None -NOTE: -- Called when Titan is loaded (ADDON_LOADED event) -- Called when user moves or changes width of bar -- :GetPoint(1) results in incorrect values based on point used -:NOTE ---]] +---Titan Update local and saved vars to new bar position per user or reset to default +--- Called when Titan is loaded (ADDON_LOADED event) +---@param self table Bar frame +---@param reset boolean Set to default position +---@param x_off? number Set to X +---@param y_off? number Set to Y +---@param w_off? number Set to width function TitanVariables_SetBarPos(self, reset, x_off, y_off, w_off) -- Collect bar x & y and save so bar stays put. local bar_frame = self:GetName() - local force_reset = reset or false - if TitanBarDataVars[bar_frame] then if reset then -- Initial defaults calc to screen size and scaling at that time - it could have changed! @@ -1029,54 +1018,32 @@ function TitanVariables_SetBarPos(self, reset, x_off, y_off, w_off) TitanBarDataVars[bar_frame].off_w = w_off end end - --[[ -print("_SetBarPos" -.." "..tostring(self:GetName()).."" -.." "..tostring(reset).."" -.." x: "..tostring(format("%0.1f", (TitanBarDataVars[bar_frame].off_x or -1.0))).."" -.." y: "..tostring(format("%0.1f", (TitanBarDataVars[bar_frame].off_y or -1.0))).."" -.." w: "..tostring(format("%0.1f", (TitanBarDataVars[bar_frame].off_w or -1.0))).."" -) ---]] + -- :GetPoint(1) results in incorrect values based on point used end ---[[ Titan -NAME: TitanVariables_GetBarPos -DESC: Retrieve saved vars of bar position -VAR: frame_str - frame name to retrieve positions from -OUT: X, Y, Width ---]] +---Titan Retrieve saved vars of bar position +---@param frame_str string Short bar name +---@return number off_x +---@return number off_y +---@return number off_width function TitanVariables_GetBarPos(frame_str) - local tscale = TitanPanelGetVar("Scale") - --[[ -print("_GetBarPos f" -.." '"..tostring(frame_str).."'" -.." '"..tostring(TitanBarData[frame_str].name).."'" -) -print("_GetBarPos" -.." '"..tostring(TitanBarData[frame_str].name).."'" -.." '"..tostring(format("%0.1f", TitanBarDataVars[frame_str].off_x)).."'" -.." '"..tostring(format("%0.1f", TitanBarDataVars[frame_str].off_y)).."'" -.." '"..tostring(format("%0.1f", TitanBarDataVars[frame_str].off_w)).."'" -) ---]] + -- local tscale = TitanPanelGetVar("Scale") return TitanBarDataVars[frame_str].off_x, --/ tscale, -- / tscale, TitanBarDataVars[frame_str].off_y, --/ tscale, -- / tscale, TitanBarDataVars[frame_str].off_w -- / tscale end ---[[ Titan -NAME: TitanVariables_GetFrameName -DESC: Build the frame name from the bar name -VAR: bar_str - frame name to retrieve positions from -OUT: frame string ---]] +---Titan Build the frame name from the bar name +---@param bar_str string Short bar name +---@return string is_icon Bar frame name function TitanVariables_GetFrameName(bar_str) return TITAN_PANEL_DISPLAY_PREFIX .. bar_str end --- lua-users.org/wiki/CopyTable +---local Original : lua-users.org/wiki/CopyTable +---@param orig any +---@return any local function deepcopy(orig) local orig_type = type(orig) local copy @@ -1092,6 +1059,10 @@ local function deepcopy(orig) return copy end +---local Set the Titan bar settings of the given profile from saved variables +---@param to_profile string +---@param trace boolean? +--- If no profile found, use Titan defaults local function Set_bar_vars(to_profile, trace) local tracer = (trace or false) if TitanSettings.Players[to_profile].BarVars then @@ -1134,13 +1105,14 @@ local function Set_bar_vars(to_profile, trace) end end ---[[ local -NAME: Init_player_settings -DESC: Use the Titan settings, the plugin settings, the 'extras' data of the given profile. Create the "to" profile if it does not exist. -VAR: from_profile - nil or profile to switch from (string) -VAR: to_profile - the toon to use (string) -OUT: None -NOTE: +---local Use the Titan settings, the plugin settings, the 'extras' data of the given profile. +---@param from_profile string? +---@param to_profile string +---@param action string TITAN_PROFILE_USE | TITAN_PROFILE_RESET | TITAN_PROFILE_INIT +--- In form "toon"@"server" +--- Create the "to" profile if it does not exist. +local function Init_player_settings(from_profile, to_profile, action) + --[[ - Called at PLAYER_ENTERING_WORLD event after we know Titan has registered plugins. - There are 3 actions: USE, RESET, and INIT - USE: @@ -1152,9 +1124,7 @@ NOTE: - INIT: From: saved variables of that profile To: Player or Global profile -:NOTE ---]] -local function Init_player_settings(from_profile, to_profile, action) + --]] local trace = false local old_player = {} @@ -1292,16 +1262,10 @@ local function Init_player_settings(from_profile, to_profile, action) TitanSettings.Profile = to_profile end ---[[ API -NAME: TitanGetVar -DESC: Get the value of the requested plugin variable. -VAR: id - the plugin name (string) -VAR: var - the name (string) of the variable -OUT: None -NOTE: -- 'var' is from the plugin <button>.registry.savedVariables table as created in the plugin lua. -:NOTE ---]] +---API Get the value of the requested plugin variable. +---@param id string Plugin name +---@param var string Variable name +---From the plugin <button>.registry.savedVariables table as created in the plugin Lua. function TitanGetVar(id, var) if (id and var and TitanPluginSettings and TitanPluginSettings[id]) then -- compatibility check @@ -1313,17 +1277,10 @@ function TitanGetVar(id, var) end end ---[[ API -NAME: TitanVarExists -DESC: Determine if requested plugin variable exists. -VAR: id - the plugin name (string) -VAR: var - the name (string) of the variable -OUT: None -NOTE: -- 'var' is from the plugin <button>.registry.savedVariables table as created in the plugin lua. -- This checks existence NOT false! -:NOTE ---]] +---API Determine if requested plugin variable exists. +---@param id string Plugin name +---@param var string Variable name +---From the plugin <button>.registry.savedVariables table as created in the plugin Lua. function TitanVarExists(id, var) -- We need to check for existance not true! -- If the value is nil then it will not exist... @@ -1337,48 +1294,30 @@ function TitanVarExists(id, var) end end ---[[ API -NAME: TitanSetVar -DESC: Get the value of the requested plugin variable to the given value. -VAR: id - the plugin name (string) -VAR: var - the name (string) of the variable -VAR: value - new value of var -OUT: None -NOTE: -- 'var' is from the plugin <button>.registry.savedVariables table as created in the plugin lua. -:NOTE ---]] +---API Set the value of the requested plugin variable. +---@param id string Plugin name +---@param var string Variable name +---@param value any Value +---From the plugin <button>.registry.savedVariables table as created in the plugin Lua. function TitanSetVar(id, var, value) if (id and var and TitanPluginSettings and TitanPluginSettings[id]) then TitanPluginSettings[id][var] = TitanUtils_Ternary(value, value, false); end end ---[[ API -NAME: TitanToggleVar -DESC: Toggle the value of the requested plugin variable. This assumes var value represents a boolean -VAR: id - the plugin name (string) -VAR: var - the name (string) of the variable -OUT: None -NOTE: -- Boolean in this case could be true / false or non zero / zero or nil. -:NOTE ---]] +---API Toggle the value of the requested plugin variable. This assumes var value represents a boolean. +---@param id string Plugin name +---@param var string Variable name function TitanToggleVar(id, var) + -- Boolean in this case could be true / false or non zero / zero or nil. if (id and var and TitanPluginSettings and TitanPluginSettings[id]) then TitanSetVar(id, var, TitanUtils_Toggle(TitanGetVar(id, var))); end end ---[[ API -NAME: TitanPanelGetVar -DESC: Get the value of the requested Titan variable. -VAR: var - the name (string) of the variable -OUT: value of the requested Titan variable -NOTE: -- 'var' is from the TitanPanelSettings[var]. -:NOTE ---]] +---API Get the value of the requested Titan global variable. +---@param var string Titan saved variable name +---@return any? Value function TitanPanelGetVar(var) if (var and TitanPanelSettings) then if TitanPanelSettings[var] == "Titan Nil" then @@ -1388,46 +1327,27 @@ function TitanPanelGetVar(var) end end ---[[ API -NAME: TitanPanelSetVar -DESC: Set the value of the requested Titan variable. -VAR: var - the name (string) of the variable -VAR: value - new value of var -OUT: None -NOTE: -- 'var' is from the TitanPanelSettings[var]. -:NOTE ---]] +---API Set the value of the requested Titan global variable. +---@param var string Titan saved variable name +---@param value any? function TitanPanelSetVar(var, value) if (var and TitanPanelSettings) then TitanPanelSettings[var] = TitanUtils_Ternary(value, value, false); end end ---[[ API -NAME: TitanPanelToggleVar -DESC: Toggle the value of the requested Titan variable. This assumes var value represents a boolean -VAR: var - the name (string) of the variable -OUT: None -NOTE: -- Boolean in this case could be true / false or non zero / zero or nil. -:NOTE ---]] +---API Toggle the value of the requested Titan variable. This assumes var value represents a boolean. +---@param var string Titan saved variable name function TitanPanelToggleVar(var) + -- Boolean in this case could be true / false or non zero / zero or nil. if (var and TitanPanelSettings) then TitanPanelSetVar(var, TitanUtils_Toggle(TitanPanelGetVar(var))); end end ---[[ API -NAME: TitanAllGetVar -DESC: Get the value of the requested Titan global variable. -VAR: var - the name (string) of the variable -OUT: None -NOTE: -- 'var' is from the TitanAll[var]. -:NOTE ---]] +---API Set the value of the requested Titan global variable. +---@param var string Titan saved variable name +---@return any? Value function TitanAllGetVar(var) if (var and TitanAll) then if TitanAll[var] == "Titan Nil" then @@ -1437,44 +1357,27 @@ function TitanAllGetVar(var) end end ---[[ API -NAME: TitanAllSetVar -DESC: Set the value of the requested Titan global variable. -VAR: var - the name (string) of the variable -VAR: value - new value of var -OUT: None -NOTE: -- 'var' is from the TitanPanelSettings[var]. -:NOTE ---]] +---API Set the value of the requested Titan global variable. +---@param var string Titan saved variable name +---@param value any? function TitanAllSetVar(var, value) if (var and TitanAll) then TitanAll[var] = TitanUtils_Ternary(value, value, false); end end ---[[ API -NAME: TitanAllToggleVar -DESC: Toggle the value of the requested Titan global variable. This assumes var value represents a boolean -VAR: var - the name (string) of the variable -OUT: None -NOTE: -- Boolean in this case could be true / false or non zero / zero or nil. -:NOTE ---]] +---API Toggle the value of the requested Titan global variable. This assumes var value represents a boolean. +---@param var string Titan saved variable name function TitanAllToggleVar(var) if (var and TitanAll) then TitanAllSetVar(var, TitanUtils_Toggle(TitanAllGetVar(var))); end end ---[[ API -NAME: TitanVariables_GetPanelStrata -DESC: Return the strata and the next highest strata of the given value -VAR: value - the name (string) of the strata to look up -OUT: string - Next highest strata -OUT: string - passed in strata ---]] +---API Return the strata and the next highest strata of the given value +---@param value string Strata +---@return string Next +---@return string Passed function TitanVariables_GetPanelStrata(value) -- obligatory check if not value then value = "DIALOG" end @@ -1494,12 +1397,8 @@ function TitanVariables_GetPanelStrata(value) return StrataTypes[indexpos + 1], StrataTypes[indexpos] end ---[[ API -NAME: TitanVariables_SetPanelStrata -DESC: Set the Titan bars to the given strata and the plugins to the next highest strata. -VAR: value - strata name (string) -OUT: None ---]] +---API Set the Titan bars to the given strata and the plugins to the next highest strata. +---@param value string WoW strata name function TitanVariables_SetPanelStrata(value) local plugins, bars = TitanVariables_GetPanelStrata(value) -- Set all the Titan bars @@ -1515,24 +1414,12 @@ function TitanVariables_SetPanelStrata(value) end end ---[[ Titan -NAME: TitanVariables_UseSettings -DESC: Set the Titan variables and plugin variables to the passed in profile. -VAR: profile - profile to use for this toon : <name>@<server> -OUT: None -NOTE: -- Called from the Titan right click menu -- profile is compared as 'lower' so the case of profile does not matter -:NOTE ---]] +---Titan Set the Titan variables and plugin variables to the passed in profile. +--- Called from the Titan right click menu +--- profile is compared as 'lower' so the case of profile does not matter +---@param profile? string name +---@param action string Use | Reset function TitanVariables_UseSettings(profile, action) - --[[ -print("_UseSettings " -.."profile: "..(profile or "?").." " -.."action: "..action.." " -) ---]] - local from_profile = nil if action == TITAN_PROFILE_USE then -- Grab the old profile currently in use diff --git a/Titan/Titan_Mainline.toc b/Titan/Titan_Mainline.toc index 510e90c..97223a8 100644 --- a/Titan/Titan_Mainline.toc +++ b/Titan/Titan_Mainline.toc @@ -1,6 +1,7 @@ ## Interface: 100206 -## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa008.0.10|r +## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa008.0.11|r ## Author: Titan Panel Dev Team +## Version: 8.0.11 ## IconTexture: Interface\Icons\Achievement_Dungeon_UlduarRaid_Titan_01 ## SavedVariables: TitanAll, TitanSettings, TitanSkins, ServerTimeOffsets, ServerHourFormat ## Notes: Adds display bars to show and control information/launcher plugins. @@ -42,6 +43,7 @@ locale\Localization.TW.lua TitanGlobal.lua TitanUtils.lua +TitanHistory.lua TitanVariables.lua TitanTemplate.xml TitanTemplate.lua diff --git a/Titan/_ATitanDoc.lua b/Titan/_ATitanDoc.lua new file mode 100644 index 0000000..be34202 --- /dev/null +++ b/Titan/_ATitanDoc.lua @@ -0,0 +1,338 @@ +--[===[ File +Starts the Titan developer documention. +--]===] + +--[===[ Titan Documentation Beginning + +This document will introduce Titan essentials for a Titan developer. +The intent is simplify what may appear to be a daunting experience. + +We suggest you grab your favorite beverage, read this doc, and relax! +Many of Titan mysteries will be explained. 🙂 + +The Titan team and its users are available to answer questions. +The two most used ways are : +The Titan Discord community - https://discord.gg/e93sxuSPwC +Curse comments under Titan Panel addon + +=== IDE 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 + +And a tiny Python parser to pull these comments. + +Note: The WoW API is geared to Retail. +There was no option to automatically include 'Classic' deprecated routines. +There are diagnostic annotations used to ignore some warnings. +Ignore warning annotations were limited as much as practical to 'this line' to point out usage of Classic routines. + +=== Documentation blocks +Within the document are Titan routines available to a plugin developer. + +There are three files contributing to Titan documentation. +- Titan_API_<time>.lua - for Titan plugin developers +- Titan_Dev_<time>.lua - for Titan developers +- Titan_File_<time>.lua - for Titan developers + +These are created from annotations in the Lua files. +API : +These are routines Titan will keep stable. +Changes to these varaibles and routines will be broadcast to developers via Discord at a minimum. + +Dev : +These are global routines Tian uses. These may change at any time per Titan needs and design. + +File : +Each file has a terse description of its contents. + +--]===] + +--[===[ Titan Start editing + +Before you start changing this example, it is HIGHLY recommended to install the following WoW addons: +- BugGrabber : Grabs errors and stores them +- BugSack : The visual part of BugGrabber +- WowLua : This allows you to try Lua code directly in WoW. + +Small changes are recommended; then test your coding. +When testing, just start or reload WoW. All versions now check and load new files on reload. + +Reload is /reload in game chat. +Using a text editor with code folding features will make this file easier to read and find information. + +For simple changes, install a code / text editor. NotepadPlusPlus is a very popular editor. + +For more in delpth changes consider using an IDE (Integrated Development Environment). +The file TitanIDE contains details on tools and ammotation. + +Regardless of tools used, please update any annotations and comments as changes are made!!! + +=== Additional Help For You +A good Lua resource is https://www.lua.org/docs.html +NOTE: WoW uses Lua version 5.1 as its base. +NOTE: WoW does restrict, add, or even remove some Lua features. For example the file routines and many OS routines are not available to an addon. + +There are sites that have deeper explanations about addon development, such as +- Wowhead.com +- Wiki wow wiki (Warcraft.Wiki.gg). +Please use these or other sites for more detailed addon and API information. +The API information changes as Blizzard adds features, changes API methods, or any other reason. + +=== Folder Structure +Inside the Titan folder you will notice : +- Artwork folder : Contains skins used by Titan +- libs : Library routines Titan uses +- A .toc file +- Many .lua files including this file +- An XML file : Containing Titan templates mainly for plugins +- This file + + +=== .toc + +The folder and the .toc files MUST have the same name! +Sort of... the name prior to the underscore(_) must be the same as the folder name. +The part after (postfix) has meaning to the WoW addon loader. +WoW has three versions represented by the three postfix values. +_Mainline : current retail version +_Wrath : Wrath of the Lich King version. +_Vanilla : Classic Era version + +These values may change as the versions evolve, say Cata is added. +Or they may not :). Years from now we may wonder why Wrath represents Dragonflight! + +Titan uses this TOC method. Notice the Titan folder has no 'wrath' or 'vanilla' .toc. +TitanClassic folder has both 'wrath' and 'vanilla' .toc but no 'mainline' .toc. +This allows Titan to load differently so plugins (built-in or 3rd party) intended for Classic versions can run without change. +Titan has no dependencies but Titan plugins need to list Titan or TitanClassic. + +=== .toc internals +NOTE: The ## Interface value should match the current interface value of the corresponding WoW version. +In BattleNet this is typically shown below the 'Play' button. +DragonFlight 10.02.05 is represented without dots - 100206 - in the .toc. + +If the interface value is higher or lower, WoW will complain that you are running 'out of date' addons. + +See one of the referrenced sites for more detail. +- https://warcraft.wiki.gg/wiki/TOC_format contains more info than you will ever need on TOC format. + +After the TOC directives, Titan lists the files in the order they are to be parsed. +This is important for Titan (or any addon) to load properly. + +TitanGame.Lua specifies TITAN_ID which is the addon ID and is determines whether to use Retail or Classic versions of some routines. + +Then the Ace libraries. Note Titan does not use all the Ace libraries. +_Titan_Lib_Notes shows a running change history of the libraries. + +Then all the localization files. + +Then the Titan code files. + +=== Artwork + +WoW tends to use .tga image files. +Lookup TextureBase:SetTexture for current accepted image types. +NOTE: All versions of WoW may not accept all image types. + +Most graphic art software can save to these formats. We don’t recommend using an online source to convert options. +They have a tendency to add additional code or info to the artwork. +--]===] + +--[===[ Titan Addon code flow + +First step: ==== Starting WoW +Wow will load load Titan along with other addons installed. There is no guarantee of order the addons are installed! + +The files will be loaded / run per the order in the TOC. +TitanTemplate.xml : Creates the Titan frame - TitanPanelBarButton - along with Titan Templates. This is used to receive events. + +Any code outside the Lua functions will be run per the order in the TOC. +Examples: +- TitanGlobal.lua sets up constants and variables used by Titan +- Titan.lua local variables and registering for some events such as ADDON_LOADED +- Creation of functions +- TitanLDB.lua creates LDBToTitan frome to handle LDB objects + +When ADDON_LOADED event is received, +- Titan registers for event PLAYER_ENTERING_WORLD +- Titan ensures its saved variables are whole and known player profiles are read. + +Next: ==== Waiting for WoW +WoW fires a bunch of events as this and other addons are loaded. +Eventually the game and all addons are loaded and PLAYER_ENTERING_WORLD event is sent + +Next: ==== Entering world +When event PLAYER_ENTERING_WORLD is received via OnEvent, the real work begins. + +The local routine - TitanPanel_PlayerEnteringWorld - is called using pcall. +This ensures Titan reacts to errors rather than forcing an error to the user. +TitanPanel_PlayerEnteringWorld does all the variable and profile setup for the character entering the world. + +On first PLAYER_ENTERING_WORLD (not reload) Titan +- Sets character profiles - TitanVariables_InitTitanSettings +- Sets TitanPanel*Anchor for other addons to adjust for Titan +- Creates all Titan bars - TitanPanelButton_CreateBar - including right click menu and auto hide frames +- Registers for events Titan uses - RegisterForEvents + +On login and reload Titan +- Register plugins in case the user installed / enabled / disabled addons then reloaded - TitanUtils_RegisterPluginList +- Set THIS character profile () - TitanVariables_UseSettings - + See TitanVariables (File) for more details on saved variables; this is a simple concept but touchy to implement + Here Titan uses + - TitanPanel_InitPanelBarButton to set the bars the user wants + - TitanPanel_InitPanelButtons to set the plugins the user wants on the user selected bars +- Update the Titan config tables - TitanUpdateConfig +- Set Titan font and strata +- Update any LDB plugins - TitanLDBRefreshButton +If the above was successful then all is good +If the above failed with an error then +- tell user some bad happened with error they can pass to dev team +- attempt to hide all bars as cleanup +- nuke the Titan config tables as cleanup +--]===] + +--[[ Frame Scripts + +The frame scripts are how WoW and Titan interact with this addon. + +==== OnEnter and OnLeave +Titan sets these scripts on a Bar for future use . Currently Titan does no work. + +For Titan Hider Bars these are used to show / hide the Titan Bar. +Note: Hider Bars are only for the full width bars - NOT Short Bars. + +==== OnClick script : +Right click is to open the Titan menu. +Left click closes any tooltip and any menu. + +On Short Bars Titan registers for +- OnDragStart and OnDragStop (left mouse button) for moving Short Bars +- OnMouseWheel to size a Short Bar + +==== OnShow script : +Not used by Titan bars. + +==== OnHide script : +Not used by Titan bars. + +==== OnEvent script : +Titan.lua sets the OnEvent stript for TitanPanelBarButton to redirect events to TitanPanelBarButton:<registered event> +See local function RegisterForEvents for the list of eventsand their usage. +--]] + +--[[ Plugin registry + +=== Titan plugins +The routine - TitanUtils_RegisterPluginList - starts the plugin registry process. + +=== LDB objects See LDBTitan.lua for many more details. + +The OnEvent script of LDBToTitan frame processes the PLAYER_LOGIN event. +This starts the process to convert all known LDB objects into Titan plugins. +Note: PLAYER_LOGIN occurs same time or very close to PLAYER_ENTERING_WORLD. +This event was chosen by the orignal developer. + +Each object found calls TitanLDBCreateObject using pcall to protect Titan. + +Before Titan is initialized (first PLAYER_ENTERING_WORLD) the LDB object will be added to the plugin list. +After, TitanUtils_RegisterPluginList will be used iteratively to register each found LDB object. +Most LDB objects are created on loading by addons. There should only an issue for addons that create +many LDB objects on demand. + +The Titan plugin example has a lot more detail from the plugin view that would be helpful to a Titan dev. +--]] + +--[[ Saved Variables + +See TitanVariables.lua (File) for additional detail. + +Much of the info below is included in the Titan plugin example. + +NOTE: Titan routines have used 1 as true since inception so be careful on 'true checks'. +As an example +if ShowUsedSlots then +*should* work fine if ShowUsedSlots is true or 1 + +=== Where are these saved variables????? +The saved variables are specified in the Titan toc : +## SavedVariables: TitanAll, TitanSettings, TitanSkins, ServerTimeOffsets, ServerHourFormat + +TitanSettings contains all the plugin saved variables. +Titan uses the single table structure to store the saved variables across a user account. +This makes the setup code rather cumbersome and not straight forward - just warning... + +The saved variables can be found here: .../World of Warcraft/_retail_/WTF/Account/(account name>/SavedVariables/Titan.lua +There is a Titan.lua.bak which is the prior save (logout / exit / reload). + +It is HIGHLY recommended opening the saved variables file in an editor with code folding features! +This file could be quite large with many lines. +I have 20+ characters on one server. Even though I do not use many addons, I do test with addons on some characters. +A plugin such as Titan Panel [Reputation] can create 100+ plugins. My file is nearly 90,000 lines long! + +Say we want to find a character named Embic on Staghelm which you are using for testing. +This would under +TitanSettings = { + ["Players"] = { + ["Embic@Staghelm"] = { + ["Panel"] = { + -- Holds all the Titan settings for this character + } + ["BarVars"] = { + -- Holds all the Titan bar settings for this character + } + ["Plugins"] = { + -- Each registered plugin will be here + ["Starter"] = { + ["notes"] = "Adds bag and free slot information to Titan Panel.\n", + ["menuTextFunction"] = nil, + ["id"] = "Starter", + ["menuText"] = "Bag", + ["iconWidth"] = 16, + ["savedVariables"] = { + ["ShowColoredText"] = 1, + ["CustomLabel3Text"] = "", + ["ShowIcon"] = 1, + ["OpenBags"] = false, + ["CustomLabel3TextShow"] = false, + ["CustomLabelTextShow"] = false, + ["CustomLabel4Text"] = "", + ["CustomLabel2Text"] = "", + ["OpenBagsClassic"] = "new_install", + ["ShowLabelText"] = 1, + ["CustomLabel4TextShow"] = false, + ["CountProfBagSlots"] = false, + ["ShowUsedSlots"] = 1, + ["DisplayOnRightSide"] = false, + ["ShowDetailedInfo"] = false, + ["CustomLabel2TextShow"] = false, + ["CustomLabelText"] = "", + }, + ["controlVariables"] = { + ["DisplayOnRightSide"] = true, + ["ShowColoredText"] = true, + ["ShowIcon"] = true, + ["ShowLabelText"] = true, + }, + ["version"] = "1.0.0", + ["category"] = "Information", + ["buttonTextFunction"] = nil , + ["tooltipTextFunction"] = nil , + ["icon"] = "Interface\\AddOns\\TitanPlugin\\Artwork\\TitanStarter", + ["tooltipTitle"] = "Bags Info", + }, + } + ["Adjust"] = { + -- Holds offsets for frames the user may adjust - Retail and Classic have different list of frames + } + ["Register"] = { + -- Holds data as each plugin and LDB is attempted to be registered. + -- There may be helpful debug data here under your plugin name if the plugin is not shown as expected. + -- Titan > Configuration > Attempts shows some of this data, including errors. + } + +--]] diff --git a/Titan/_TitanIDE.lua b/Titan/_TitanIDE.lua new file mode 100644 index 0000000..e6606a6 --- /dev/null +++ b/Titan/_TitanIDE.lua @@ -0,0 +1,201 @@ +--[===[ File + This file is NOT to be included in the TOC file! + This is intended to be used for IDE Intellisense. +--]===] + +--[[ 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 ---@<tag> 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 +-- Should be handled by the WoW extension + +--====== 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. + +---@class Frame Plugin frame from a Titan template +---@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 Only LDB ATM +---@field TitanType string Not used ATM +---@field TitanName string Used for LDB name / id +---@field TitanAction string Not used ATM +---@field bar_name string Used by auto hide built-in +---@field registry table Any Titan plugin (built-in; third party; or LDB) + + +---@class Button Plugin frame +---@field RequestTimePlayed table Override default - XP +---@field TIME_PLAYED_MSG table Override default - XP + + +--====== 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 + + +--====== API routines diff --git a/Titan/locale/Localization.BR.lua b/Titan/locale/Localization.BR.lua index b864441..936c180 100644 --- a/Titan/locale/Localization.BR.lua +++ b/Titan/locale/Localization.BR.lua @@ -241,7 +241,7 @@ L["TITAN_PANEL_MENU_CATEGORIES_04"] = "Informação" L["TITAN_PANEL_MENU_CATEGORIES_05"] = "Interface" L["TITAN_PANEL_MENU_CATEGORIES_06"] = "Profissão" L["TITAN_PANEL_MENU_CENTER_TEXT"] = "Centralizar Texto"; -L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent".." "..(CHANGE or "Change").." "..(HISTORY or "History") +L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent Change History" L["TITAN_PANEL_MENU_COMMAND"] = (COMMAND or "Command") L["TITAN_PANEL_MENU_CONFIGURATION"] = "Configuração"; L["TITAN_PANEL_MENU_DELETE_SETTINGS"] = "Apagar"; @@ -299,6 +299,7 @@ L["TITAN_PANEL_MENU_SHOW_ICON"] = "Exibir Ícone"; L["TITAN_PANEL_MENU_SHOW_LABEL_TEXT"] = "Exibir Texto de Rótulo"; L["TITAN_PANEL_MENU_SHOW_PLUGIN_TEXT"] = "Exibir Texto do Plugin"; L["TITAN_PANEL_MENU_SHOW"] = "Exibir Plugin"; +L["TITAN_PANEL_MENU_SKIN_CHANGE"] = "Change skins using Bar options :"; L["TITAN_PANEL_MENU_SILENT_LOAD"] = "Carregament Silencioso"; L["TITAN_PANEL_MENU_SLASH_COMMAND"] = ("/").." "..(COMMAND or "Command") L["TITAN_PANEL_MENU_TEXTURE_SETTINGS"] = "Peles"; @@ -489,8 +490,8 @@ L["TITAN_VOLUME_SOUND_CONTROL_TITLE"] = "Efeitos"; L["TITAN_VOLUME_SOUND_TOOLTIP_VALUE"] = "Effects Sound Volume: "; L["TITAN_VOLUME_SPEAKER_CONTROL_TITLE"] = "Auto-falante"; L["TITAN_VOLUME_SPEAKER_TOOLTIP_VALUE"] = "Speaker Sound Volume: "; -L["TITAN_VOLUME_TOOLTIP_HINT1"] = "Hint: Clique para ajustar o"; -L["TITAN_VOLUME_TOOLTIP_HINT2"] = "volume do som."; +L["TITAN_VOLUME_TOOLTIP_HINT1"] = "Hint: Clique para ajustar o volume do som."; +L["TITAN_VOLUME_TOOLTIP_HINT2"] = "Hint: Double-click to toggle mute"; L["TITAN_VOLUME_TOOLTIP"] = "Informação de Volume"; L["TITAN_XP_BUTTON_LABEL_SESSION_TIME"] = "Session Time: "; L["TITAN_XP_BUTTON_LABEL_TOLEVEL_TIME_LEVEL"] = "Time To Level: "; diff --git a/Titan/locale/Localization.CN.lua b/Titan/locale/Localization.CN.lua index ba3d759..2d17b91 100644 --- a/Titan/locale/Localization.CN.lua +++ b/Titan/locale/Localization.CN.lua @@ -241,7 +241,7 @@ L["TITAN_PANEL_MENU_CATEGORIES_04"] = "信息" L["TITAN_PANEL_MENU_CATEGORIES_05"] = "用户界面" L["TITAN_PANEL_MENU_CATEGORIES_06"] = "专业技能" L["TITAN_PANEL_MENU_CENTER_TEXT"] = "文字居中"; -L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent".." "..(CHANGE or "Change").." "..(HISTORY or "History") +L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent Change History" L["TITAN_PANEL_MENU_COMMAND"] = (COMMAND or "Command") L["TITAN_PANEL_MENU_CONFIGURATION"] = "配置设置"; L["TITAN_PANEL_MENU_DELETE_SETTINGS"] = "删除"; @@ -299,6 +299,7 @@ L["TITAN_PANEL_MENU_SHOW_ICON"] = "显示图标"; L["TITAN_PANEL_MENU_SHOW_LABEL_TEXT"] = "显示名称"; L["TITAN_PANEL_MENU_SHOW_PLUGIN_TEXT"] = "显示扩展组件文本"; L["TITAN_PANEL_MENU_SHOW"] = "显示扩展组件"; +L["TITAN_PANEL_MENU_SKIN_CHANGE"] = "Change skins using Bar options :"; L["TITAN_PANEL_MENU_SILENT_LOAD"] = "Silent Load"; L["TITAN_PANEL_MENU_SLASH_COMMAND"] = ("/").." "..(COMMAND or "Command") L["TITAN_PANEL_MENU_TEXTURE_SETTINGS"] = "皮肤"; @@ -489,8 +490,8 @@ L["TITAN_VOLUME_SOUND_CONTROL_TITLE"] = "音效音量"; L["TITAN_VOLUME_SOUND_TOOLTIP_VALUE"] = "音效音量: "; L["TITAN_VOLUME_SPEAKER_CONTROL_TITLE"] = "扬声器"; L["TITAN_VOLUME_SPEAKER_TOOLTIP_VALUE"] = "扬声器音量: "; -L["TITAN_VOLUME_TOOLTIP_HINT1"] = "提示: 用鼠标左键来调节"; -L["TITAN_VOLUME_TOOLTIP_HINT2"] = "音量."; +L["TITAN_VOLUME_TOOLTIP_HINT1"] = "提示: 用鼠标左键来调节音量."; +L["TITAN_VOLUME_TOOLTIP_HINT2"] = "Hint: Double-click to toggle mute"; L["TITAN_VOLUME_TOOLTIP"] = "音量信息"; L["TITAN_XP_BUTTON_LABEL_SESSION_TIME"] = "连接时间: "; L["TITAN_XP_BUTTON_LABEL_TOLEVEL_TIME_LEVEL"] = "升级所需时间: "; diff --git a/Titan/locale/Localization.DE.lua b/Titan/locale/Localization.DE.lua index ac47eaf..b67b21c 100644 --- a/Titan/locale/Localization.DE.lua +++ b/Titan/locale/Localization.DE.lua @@ -241,7 +241,7 @@ L["TITAN_PANEL_MENU_CATEGORIES_04"] = "Informationen" L["TITAN_PANEL_MENU_CATEGORIES_05"] = "Interface" L["TITAN_PANEL_MENU_CATEGORIES_06"] = "Beruf" L["TITAN_PANEL_MENU_CENTER_TEXT"] = "Text zentrieren"; -L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent".." "..(CHANGE or "Change").." "..(HISTORY or "History") +L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent Change History" L["TITAN_PANEL_MENU_COMMAND"] = (COMMAND or "Command") L["TITAN_PANEL_MENU_CONFIGURATION"] = "Konfiguration"; L["TITAN_PANEL_MENU_DELETE_SETTINGS"] = "L\195\182schen"; @@ -299,6 +299,7 @@ L["TITAN_PANEL_MENU_SHOW_ICON"] = "Icon anzeigen"; L["TITAN_PANEL_MENU_SHOW_LABEL_TEXT"] = "Beschriftungstext anzeigen"; L["TITAN_PANEL_MENU_SHOW_PLUGIN_TEXT"] = "Zeige Plugintext"; L["TITAN_PANEL_MENU_SHOW"] = "Zeige Plugin"; +L["TITAN_PANEL_MENU_SKIN_CHANGE"] = "Change skins using Bar options :"; L["TITAN_PANEL_MENU_SILENT_LOAD"] = "Stilles Laden"; L["TITAN_PANEL_MENU_SLASH_COMMAND"] = ("/").." "..(COMMAND or "Command") L["TITAN_PANEL_MENU_TEXTURE_SETTINGS"] = "Skins"; @@ -489,8 +490,8 @@ L["TITAN_VOLUME_SOUND_CONTROL_TITLE"] = "Effekte"; L["TITAN_VOLUME_SOUND_TOOLTIP_VALUE"] = "Momentane Effektlautst\195\164rke: "; L["TITAN_VOLUME_SPEAKER_CONTROL_TITLE"] = "Lautsprecher"; L["TITAN_VOLUME_SPEAKER_TOOLTIP_VALUE"] = "Momentane Lautsprecherlaust\195\164rke: "; -L["TITAN_VOLUME_TOOLTIP_HINT1"] = "Hinweis: Links-Klick um die"; -L["TITAN_VOLUME_TOOLTIP_HINT2"] = "Lautst\195\164rken anzupassen."; +L["TITAN_VOLUME_TOOLTIP_HINT1"] = "Hinweis: Links-Klick um die Lautst\195\164rken anzupassen."; +L["TITAN_VOLUME_TOOLTIP_HINT2"] = "Hint: Double-click to toggle mute"; L["TITAN_VOLUME_TOOLTIP"] = "Lautst\195\164rke einstellen"; L["TITAN_XP_BUTTON_LABEL_SESSION_TIME"] = "Sitzungszeit: "; L["TITAN_XP_BUTTON_LABEL_TOLEVEL_TIME_LEVEL"] = "Zeit bis Aufstieg: "; diff --git a/Titan/locale/Localization.ES.lua b/Titan/locale/Localization.ES.lua index 5e04fc1..9c7cfc1 100644 --- a/Titan/locale/Localization.ES.lua +++ b/Titan/locale/Localization.ES.lua @@ -242,7 +242,7 @@ L["TITAN_PANEL_MENU_CATEGORIES_04"] = "Información" L["TITAN_PANEL_MENU_CATEGORIES_05"] = "Interfaz" L["TITAN_PANEL_MENU_CATEGORIES_06"] = "Profesión" L["TITAN_PANEL_MENU_CENTER_TEXT"] = "Centrar texto"; -L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent".." "..(CHANGE or "Change").." "..(HISTORY or "History") +L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent Change History" L["TITAN_PANEL_MENU_COMMAND"] = (COMMAND or "Command") L["TITAN_PANEL_MENU_CONFIGURATION"] = "Configuración"; L["TITAN_PANEL_MENU_DELETE_SETTINGS"] = "Borrar"; @@ -300,6 +300,7 @@ L["TITAN_PANEL_MENU_SHOW_ICON"] = "Mostrar icono"; L["TITAN_PANEL_MENU_SHOW_LABEL_TEXT"] = "Mostrar etiqueta de texto"; L["TITAN_PANEL_MENU_SHOW_PLUGIN_TEXT"] = "Mostrar texto del plugin"; L["TITAN_PANEL_MENU_SHOW"] = "Mostrar plugin"; +L["TITAN_PANEL_MENU_SKIN_CHANGE"] = "Change skins using Bar options :"; L["TITAN_PANEL_MENU_SILENT_LOAD"] = "Carga silenciosa"; L["TITAN_PANEL_MENU_SLASH_COMMAND"] = ("/").." "..(COMMAND or "Command") L["TITAN_PANEL_MENU_TEXTURE_SETTINGS"] = "Skins"; @@ -490,8 +491,8 @@ L["TITAN_VOLUME_SOUND_CONTROL_TITLE"] = "Efectos"; L["TITAN_VOLUME_SOUND_TOOLTIP_VALUE"] = "Volumen de los efectos: "; L["TITAN_VOLUME_SPEAKER_CONTROL_TITLE"] = "Altavoz"; L["TITAN_VOLUME_SPEAKER_TOOLTIP_VALUE"] = "Volumen de los altavoces: "; -L["TITAN_VOLUME_TOOLTIP_HINT1"] = "Consejo: Click-Izq. para ajustar"; -L["TITAN_VOLUME_TOOLTIP_HINT2"] = "el volumen."; +L["TITAN_VOLUME_TOOLTIP_HINT1"] = "Consejo: Click-Izq. para ajustar el volumen."; +L["TITAN_VOLUME_TOOLTIP_HINT2"] = "Hint: Double-click to toggle mute"; L["TITAN_VOLUME_TOOLTIP"] = "Control de Volumen"; L["TITAN_XP_BUTTON_LABEL_SESSION_TIME"] = "Tiempo en esta sesión: "; L["TITAN_XP_BUTTON_LABEL_TOLEVEL_TIME_LEVEL"] = "Tiempo para subir: "; diff --git a/Titan/locale/Localization.FR.lua b/Titan/locale/Localization.FR.lua index ec35513..c4d1b07 100644 --- a/Titan/locale/Localization.FR.lua +++ b/Titan/locale/Localization.FR.lua @@ -241,7 +241,7 @@ L["TITAN_PANEL_MENU_CATEGORIES_04"] = "Informations" L["TITAN_PANEL_MENU_CATEGORIES_05"] = "Interface" L["TITAN_PANEL_MENU_CATEGORIES_06"] = "Métiers" L["TITAN_PANEL_MENU_CENTER_TEXT"] = "Centrer le texte"; -L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent".." "..(CHANGE or "Change").." "..(HISTORY or "History") +L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent Change History" L["TITAN_PANEL_MENU_COMMAND"] = (COMMAND or "Command") L["TITAN_PANEL_MENU_CONFIGURATION"] = "Configuration"; L["TITAN_PANEL_MENU_DELETE_SETTINGS"] = "Suppression"; @@ -299,6 +299,7 @@ L["TITAN_PANEL_MENU_SHOW_ICON"] = "Montrer l'icône"; L["TITAN_PANEL_MENU_SHOW_LABEL_TEXT"] = "Montrer le titre"; L["TITAN_PANEL_MENU_SHOW_PLUGIN_TEXT"] = "Afficher le texte"; L["TITAN_PANEL_MENU_SHOW"] = "Afficher le plugin"; +L["TITAN_PANEL_MENU_SKIN_CHANGE"] = "Change skins using Bar options :"; L["TITAN_PANEL_MENU_SILENT_LOAD"] = "Chargement silencieux"; L["TITAN_PANEL_MENU_SLASH_COMMAND"] = ("/").." "..(COMMAND or "Command") L["TITAN_PANEL_MENU_TEXTURE_SETTINGS"] = "Paramètres du skin"; @@ -489,8 +490,8 @@ L["TITAN_VOLUME_SOUND_CONTROL_TITLE"] = "Effets"; L["TITAN_VOLUME_SOUND_TOOLTIP_VALUE"] = "Volume des effets : "; L["TITAN_VOLUME_SPEAKER_CONTROL_TITLE"] = "Voix"; L["TITAN_VOLUME_SPEAKER_TOOLTIP_VALUE"] = "Volume des voix : "; -L["TITAN_VOLUME_TOOLTIP_HINT1"] = "Info : clic-gauche pour ajuster"; -L["TITAN_VOLUME_TOOLTIP_HINT2"] = "le volume sonore."; +L["TITAN_VOLUME_TOOLTIP_HINT1"] = "Info : clic-gauche pour ajuster le volume sonore."; +L["TITAN_VOLUME_TOOLTIP_HINT2"] = "Hint: Double-click to toggle mute"; L["TITAN_VOLUME_TOOLTIP"] = "Contrôle du volume"; L["TITAN_XP_BUTTON_LABEL_SESSION_TIME"] = "Temps joué pour cette session : "; L["TITAN_XP_BUTTON_LABEL_TOLEVEL_TIME_LEVEL"] = "Temps avant niveau : "; diff --git a/Titan/locale/Localization.IT.lua b/Titan/locale/Localization.IT.lua index 9ed6812..73b1683 100644 --- a/Titan/locale/Localization.IT.lua +++ b/Titan/locale/Localization.IT.lua @@ -241,7 +241,7 @@ L["TITAN_PANEL_MENU_CATEGORIES_04"] = "Informazione" L["TITAN_PANEL_MENU_CATEGORIES_05"] = "Interfaccia" L["TITAN_PANEL_MENU_CATEGORIES_06"] = "Professioni" L["TITAN_PANEL_MENU_CENTER_TEXT"] = "Testo Centrale"; -L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent".." "..(CHANGE or "Change").." "..(HISTORY or "History") +L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent Change History" L["TITAN_PANEL_MENU_COMMAND"] = (COMMAND or "Command") L["TITAN_PANEL_MENU_CONFIGURATION"] = "Configurazione"; L["TITAN_PANEL_MENU_DELETE_SETTINGS"] = "Elimina"; @@ -299,6 +299,7 @@ L["TITAN_PANEL_MENU_SHOW_ICON"] = "Mostra icona"; L["TITAN_PANEL_MENU_SHOW_LABEL_TEXT"] = "Mostra testo"; L["TITAN_PANEL_MENU_SHOW_PLUGIN_TEXT"] = "Mostra testo plugin"; L["TITAN_PANEL_MENU_SHOW"] = "Mostra Plugin"; +L["TITAN_PANEL_MENU_SKIN_CHANGE"] = "Change skins using Bar options :"; L["TITAN_PANEL_MENU_SILENT_LOAD"] = "Silent Load"; L["TITAN_PANEL_MENU_SLASH_COMMAND"] = ("/").." "..(COMMAND or "Command") L["TITAN_PANEL_MENU_TEXTURE_SETTINGS"] = "Skin"; @@ -489,8 +490,8 @@ L["TITAN_VOLUME_SOUND_CONTROL_TITLE"] = "Effetti"; L["TITAN_VOLUME_SOUND_TOOLTIP_VALUE"] = "Volume effetti: "; L["TITAN_VOLUME_SPEAKER_CONTROL_TITLE"] = "Casse"; L["TITAN_VOLUME_SPEAKER_TOOLTIP_VALUE"] = "Volume casse: "; -L["TITAN_VOLUME_TOOLTIP_HINT1"] = "Suggerimento: Click Sinistro per impostare il"; -L["TITAN_VOLUME_TOOLTIP_HINT2"] = "volume."; +L["TITAN_VOLUME_TOOLTIP_HINT1"] = "Suggerimento: Click Sinistro per impostare il volume."; +L["TITAN_VOLUME_TOOLTIP_HINT2"] = "Hint: Double-click to toggle mute"; L["TITAN_VOLUME_TOOLTIP"] = "Info Volume"; L["TITAN_XP_BUTTON_LABEL_SESSION_TIME"] = "Tempo sessione: "; L["TITAN_XP_BUTTON_LABEL_TOLEVEL_TIME_LEVEL"] = "Tempo per salire di lv: "; diff --git a/Titan/locale/Localization.KR.lua b/Titan/locale/Localization.KR.lua index cabaaea..24315f0 100644 --- a/Titan/locale/Localization.KR.lua +++ b/Titan/locale/Localization.KR.lua @@ -242,7 +242,7 @@ L["TITAN_PANEL_MENU_CATEGORIES_04"] = "정보" L["TITAN_PANEL_MENU_CATEGORIES_05"] = "기능강화" L["TITAN_PANEL_MENU_CATEGORIES_06"] = "전문기술" L["TITAN_PANEL_MENU_CENTER_TEXT"] = "중앙 글자"; -L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent".." "..(CHANGE or "Change").." "..(HISTORY or "History") +L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent Change History" L["TITAN_PANEL_MENU_COMMAND"] = (COMMAND or "Command") L["TITAN_PANEL_MENU_CONFIGURATION"] = "설정"; L["TITAN_PANEL_MENU_DELETE_SETTINGS"] = "삭제"; @@ -300,6 +300,7 @@ L["TITAN_PANEL_MENU_SHOW_ICON"] = "아이콘 표시"; L["TITAN_PANEL_MENU_SHOW_LABEL_TEXT"] = "라벨 글자 표시"; L["TITAN_PANEL_MENU_SHOW_PLUGIN_TEXT"] = "플러그인 글자 표시"; L["TITAN_PANEL_MENU_SHOW"] = "플러그인 표시"; +L["TITAN_PANEL_MENU_SKIN_CHANGE"] = "Change skins using Bar options :"; L["TITAN_PANEL_MENU_SILENT_LOAD"] = "Silent Load"; L["TITAN_PANEL_MENU_SLASH_COMMAND"] = ("/").." "..(COMMAND or "Command") L["TITAN_PANEL_MENU_TEXTURE_SETTINGS"] = "스킨"; @@ -490,8 +491,8 @@ L["TITAN_VOLUME_SOUND_CONTROL_TITLE"] = "효과음"; L["TITAN_VOLUME_SOUND_TOOLTIP_VALUE"] = "효과음: "; L["TITAN_VOLUME_SPEAKER_CONTROL_TITLE"] = "스피커"; L["TITAN_VOLUME_SPEAKER_TOOLTIP_VALUE"] = "스피커: "; -L["TITAN_VOLUME_TOOLTIP_HINT1"] = "힌트: 왼쪽 클릭하면 "; -L["TITAN_VOLUME_TOOLTIP_HINT2"] = "음량 조절 메뉴를 엽니다."; +L["TITAN_VOLUME_TOOLTIP_HINT1"] = "힌트: 왼쪽 클릭하면 음량 조절 메뉴를 엽니다."; +L["TITAN_VOLUME_TOOLTIP_HINT2"] = "Hint: Double-click to toggle mute"; L["TITAN_VOLUME_TOOLTIP"] = "음량 정보"; L["TITAN_XP_BUTTON_LABEL_SESSION_TIME"] = "접속 시간: "; L["TITAN_XP_BUTTON_LABEL_TOLEVEL_TIME_LEVEL"] = "레벨당 시간: "; diff --git a/Titan/locale/Localization.MX.lua b/Titan/locale/Localization.MX.lua index 232c3e1..78e5f90 100644 --- a/Titan/locale/Localization.MX.lua +++ b/Titan/locale/Localization.MX.lua @@ -242,7 +242,7 @@ L["TITAN_PANEL_MENU_CATEGORIES_04"] = "Información" L["TITAN_PANEL_MENU_CATEGORIES_05"] = "Interfaz" L["TITAN_PANEL_MENU_CATEGORIES_06"] = "Profesión" L["TITAN_PANEL_MENU_CENTER_TEXT"] = "Centrar texto"; -L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent".." "..(CHANGE or "Change").." "..(HISTORY or "History") +L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent Change History" L["TITAN_PANEL_MENU_COMMAND"] = (COMMAND or "Command") L["TITAN_PANEL_MENU_CONFIGURATION"] = "Configuración"; L["TITAN_PANEL_MENU_DELETE_SETTINGS"] = "Borrar"; @@ -300,6 +300,7 @@ L["TITAN_PANEL_MENU_SHOW_ICON"] = "Mostrar icono"; L["TITAN_PANEL_MENU_SHOW_LABEL_TEXT"] = "Mostrar etiqueta de texto"; L["TITAN_PANEL_MENU_SHOW_PLUGIN_TEXT"] = "Mostrar texto del plugin"; L["TITAN_PANEL_MENU_SHOW"] = "Mostrar plugin"; +L["TITAN_PANEL_MENU_SKIN_CHANGE"] = "Change skins using Bar options :"; L["TITAN_PANEL_MENU_SILENT_LOAD"] = "Carga silenciosa"; L["TITAN_PANEL_MENU_SLASH_COMMAND"] = ("/").." "..(COMMAND or "Command") L["TITAN_PANEL_MENU_TEXTURE_SETTINGS"] = "Skins"; @@ -490,8 +491,8 @@ L["TITAN_VOLUME_SOUND_CONTROL_TITLE"] = "Efectos"; L["TITAN_VOLUME_SOUND_TOOLTIP_VALUE"] = "Volumen de los efectos: "; L["TITAN_VOLUME_SPEAKER_CONTROL_TITLE"] = "Altavoz"; L["TITAN_VOLUME_SPEAKER_TOOLTIP_VALUE"] = "Volumen de los altavoces: "; -L["TITAN_VOLUME_TOOLTIP_HINT1"] = "Consejo: Click-Izq. para ajustar"; -L["TITAN_VOLUME_TOOLTIP_HINT2"] = "el volumen."; +L["TITAN_VOLUME_TOOLTIP_HINT1"] = "Consejo: Click-Izq. para ajustar el volumen."; +L["TITAN_VOLUME_TOOLTIP_HINT2"] = "Hint: Double-click to toggle mute"; L["TITAN_VOLUME_TOOLTIP"] = "Control de Volumen"; L["TITAN_XP_BUTTON_LABEL_SESSION_TIME"] = "Tiempo en esta sesión: "; L["TITAN_XP_BUTTON_LABEL_TOLEVEL_TIME_LEVEL"] = "Tiempo para subir: "; diff --git a/Titan/locale/Localization.RU.lua b/Titan/locale/Localization.RU.lua index 3df66a2..0844a7a 100644 --- a/Titan/locale/Localization.RU.lua +++ b/Titan/locale/Localization.RU.lua @@ -241,7 +241,7 @@ L["TITAN_PANEL_MENU_CATEGORIES_04"] = "Информация" L["TITAN_PANEL_MENU_CATEGORIES_05"] = "Интерфейс" L["TITAN_PANEL_MENU_CATEGORIES_06"] = "Профессия" L["TITAN_PANEL_MENU_CENTER_TEXT"] = "Текст в центре"; -L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent".." "..(CHANGE or "Change").." "..(HISTORY or "History") +L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent Change History" L["TITAN_PANEL_MENU_COMMAND"] = (COMMAND or "Command") L["TITAN_PANEL_MENU_CONFIGURATION"] = "Конфигурация"; L["TITAN_PANEL_MENU_DELETE_SETTINGS"] = "Удалить"; @@ -299,6 +299,7 @@ L["TITAN_PANEL_MENU_SHOW_ICON"] = "Показывать иконку"; L["TITAN_PANEL_MENU_SHOW_LABEL_TEXT"] = "Текст ярлыка"; L["TITAN_PANEL_MENU_SHOW_PLUGIN_TEXT"] = "Показать текст плагина"; L["TITAN_PANEL_MENU_SHOW"] = "Показать плагин"; +L["TITAN_PANEL_MENU_SKIN_CHANGE"] = "Change skins using Bar options :"; L["TITAN_PANEL_MENU_SILENT_LOAD"] = "Silent Load"; L["TITAN_PANEL_MENU_SLASH_COMMAND"] = ("/").." "..(COMMAND or "Command") L["TITAN_PANEL_MENU_TEXTURE_SETTINGS"] = "Настройки шкурки"; @@ -489,8 +490,8 @@ L["TITAN_VOLUME_SOUND_CONTROL_TITLE"] = "Звуки"; L["TITAN_VOLUME_SOUND_TOOLTIP_VALUE"] = "Громкость звуковых эффектов: "; L["TITAN_VOLUME_SPEAKER_CONTROL_TITLE"] = "Динамик"; L["TITAN_VOLUME_SPEAKER_TOOLTIP_VALUE"] = "Громкость динамиков: "; -L["TITAN_VOLUME_TOOLTIP_HINT1"] = "ЛКМ чтобы настроить"; -L["TITAN_VOLUME_TOOLTIP_HINT2"] = "Громкость звука"; +L["TITAN_VOLUME_TOOLTIP_HINT1"] = "ЛКМ чтобы настроить Громкость звука"; +L["TITAN_VOLUME_TOOLTIP_HINT2"] = "Hint: Double-click to toggle mute"; L["TITAN_VOLUME_TOOLTIP"] = "Контроль звука"; L["TITAN_XP_BUTTON_LABEL_SESSION_TIME"] = "Время сеанса: "; L["TITAN_XP_BUTTON_LABEL_TOLEVEL_TIME_LEVEL"] = "Время до уровня: "; diff --git a/Titan/locale/Localization.TW.lua b/Titan/locale/Localization.TW.lua index 3832854..bae0873 100644 --- a/Titan/locale/Localization.TW.lua +++ b/Titan/locale/Localization.TW.lua @@ -241,7 +241,7 @@ L["TITAN_PANEL_MENU_CATEGORIES_04"] = "資訊" L["TITAN_PANEL_MENU_CATEGORIES_05"] = "介面" L["TITAN_PANEL_MENU_CATEGORIES_06"] = "專業" L["TITAN_PANEL_MENU_CENTER_TEXT"] = "文字置中"; -L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent".." "..(CHANGE or "Change").." "..(HISTORY or "History") +L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent Change History" L["TITAN_PANEL_MENU_COMMAND"] = (COMMAND or "Command") L["TITAN_PANEL_MENU_CONFIGURATION"] = "配置設定"; L["TITAN_PANEL_MENU_DELETE_SETTINGS"] = "刪除"; @@ -299,6 +299,7 @@ L["TITAN_PANEL_MENU_SHOW_ICON"] = "顯示圖示"; L["TITAN_PANEL_MENU_SHOW_LABEL_TEXT"] = "顯示標籤文字"; L["TITAN_PANEL_MENU_SHOW_PLUGIN_TEXT"] = "Show plugin text"; L["TITAN_PANEL_MENU_SHOW"] = "Show plugin"; +L["TITAN_PANEL_MENU_SKIN_CHANGE"] = "Change skins using Bar options :"; L["TITAN_PANEL_MENU_SILENT_LOAD"] = "Silent Load"; L["TITAN_PANEL_MENU_SLASH_COMMAND"] = ("/").." "..(COMMAND or "Command") L["TITAN_PANEL_MENU_TEXTURE_SETTINGS"] = "面板設定"; @@ -489,8 +490,8 @@ L["TITAN_VOLUME_SOUND_CONTROL_TITLE"] = "音效"; L["TITAN_VOLUME_SOUND_TOOLTIP_VALUE"] = "音效音量大小: "; L["TITAN_VOLUME_SPEAKER_CONTROL_TITLE"] = "喇叭"; L["TITAN_VOLUME_SPEAKER_TOOLTIP_VALUE"] = "喇叭音量大小: "; -L["TITAN_VOLUME_TOOLTIP_HINT1"] = "提示: 滑鼠左鍵調整"; -L["TITAN_VOLUME_TOOLTIP_HINT2"] = "主音量大小"; +L["TITAN_VOLUME_TOOLTIP_HINT1"] = "提示: 滑鼠左鍵調整主音量大小"; +L["TITAN_VOLUME_TOOLTIP_HINT2"] = "Hint: Double-click to toggle mute"; L["TITAN_VOLUME_TOOLTIP"] = "音量控制"; L["TITAN_XP_BUTTON_LABEL_SESSION_TIME"] = "連接: "; L["TITAN_XP_BUTTON_LABEL_TOLEVEL_TIME_LEVEL"] = "升級所需的時間: "; diff --git a/Titan/locale/Localization.lua b/Titan/locale/Localization.lua index 216f16b..aa5039d 100644 --- a/Titan/locale/Localization.lua +++ b/Titan/locale/Localization.lua @@ -240,7 +240,7 @@ L["TITAN_PANEL_MENU_CATEGORIES_04"] = "Information" L["TITAN_PANEL_MENU_CATEGORIES_05"] = "Interface" L["TITAN_PANEL_MENU_CATEGORIES_06"] = "Profession" L["TITAN_PANEL_MENU_CENTER_TEXT"] = "Center Text"; -L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent".." "..(CHANGE or "Change").." "..(HISTORY or "History") +L["TITAN_PANEL_MENU_CHANGE_HISTORY"] = "Recent Change History"; L["TITAN_PANEL_MENU_COMMAND"] = (COMMAND or "Command") L["TITAN_PANEL_MENU_CONFIGURATION"] = "Configuration"; L["TITAN_PANEL_MENU_DELETE_SETTINGS"] = "Delete"; @@ -298,6 +298,7 @@ L["TITAN_PANEL_MENU_SHOW_ICON"] = "Show Icon"; L["TITAN_PANEL_MENU_SHOW_LABEL_TEXT"] = "Show Label Text"; L["TITAN_PANEL_MENU_SHOW_PLUGIN_TEXT"] = "Show Plugin Text"; L["TITAN_PANEL_MENU_SHOW"] = "Show Plugin"; +L["TITAN_PANEL_MENU_SKIN_CHANGE"] = "Change skins using Bar options :"; L["TITAN_PANEL_MENU_SILENT_LOAD"] = "Silent Load"; L["TITAN_PANEL_MENU_SLASH_COMMAND"] = ("/").." "..(COMMAND or "Command") L["TITAN_PANEL_MENU_TEXTURE_SETTINGS"] = "Skins"; @@ -488,8 +489,8 @@ L["TITAN_VOLUME_SOUND_CONTROL_TITLE"] = "Effects"; L["TITAN_VOLUME_SOUND_TOOLTIP_VALUE"] = "Effects Sound Volume: "; L["TITAN_VOLUME_SPEAKER_CONTROL_TITLE"] = "Speaker"; L["TITAN_VOLUME_SPEAKER_TOOLTIP_VALUE"] = "Speaker Sound Volume: "; -L["TITAN_VOLUME_TOOLTIP_HINT1"] = "Hint: Left-click to adjust the"; -L["TITAN_VOLUME_TOOLTIP_HINT2"] = "sound volume."; +L["TITAN_VOLUME_TOOLTIP_HINT1"] = "Hint: Left-click to adjust the sound volume."; +L["TITAN_VOLUME_TOOLTIP_HINT2"] = "Hint: Double-click to toggle mute"; L["TITAN_VOLUME_TOOLTIP"] = "Volume Info"; L["TITAN_XP_BUTTON_LABEL_SESSION_TIME"] = "Session Time: "; L["TITAN_XP_BUTTON_LABEL_TOLEVEL_TIME_LEVEL"] = "Time To Level: "; diff --git a/TitanAmmo/TitanAmmo_Vanilla.toc b/TitanAmmo/TitanAmmo_Vanilla.toc index 6dbfafb..1b79a76 100644 --- a/TitanAmmo/TitanAmmo_Vanilla.toc +++ b/TitanAmmo/TitanAmmo_Vanilla.toc @@ -1,6 +1,6 @@ ## Interface: 11502 -## Title: Titan Panel [|cffeda55fAmmo|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fAmmo|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Adds an ammo monitor to Titan Panel - Classic versions only ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanAmmo/TitanAmmo_Wrath.toc b/TitanAmmo/TitanAmmo_Wrath.toc index bbfa7a0..ce7bdb8 100644 --- a/TitanAmmo/TitanAmmo_Wrath.toc +++ b/TitanAmmo/TitanAmmo_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fAmmo|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fAmmo|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Adds an ammo monitor to Titan Panel - Classic versions only ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanAmmo/TitanClassicAmmo.lua b/TitanAmmo/TitanClassicAmmo.lua index ea9869c..3386b41 100644 --- a/TitanAmmo/TitanClassicAmmo.lua +++ b/TitanAmmo/TitanClassicAmmo.lua @@ -64,6 +64,9 @@ local L = LibStub("AceLocale-3.0"):GetLocale("TitanClassic", true) local debug_flow = false +---@diagnostic disable-next-line: deprecated +local GetItem = C_Item.GetItemInfo or GetItemInfo -- For Classic versions + -- ******************************** Functions ******************************* --[[ local -- ************************************************************************** @@ -137,7 +140,7 @@ local function GetAmmoCount() -- get weapon info (thrown) or ammo info (guns & bows) itemName, itemLink, itemQuality, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, sellPrice, classID, subclassID, bindType, expacID, setID, isCraftingReagent - = GetItemInfo(weap) + = GetItem(weap) ammo = itemEquipLoc -- set ammo name and count @@ -152,7 +155,7 @@ local function GetAmmoCount() label = L["TITAN_AMMO_BUTTON_LABEL_THROWN"] - ammo_name = select(1, GetItemInfo(GetInventoryItemID("player", rangedSlotID))) or _G["UNKNOWN"] + ammo_name = select(1, GetItem(GetInventoryItemID("player", rangedSlotID))) or _G["UNKNOWN"] if ammo_name == _G["UNKNOWN"] then ammo_count = 0 else @@ -176,7 +179,7 @@ local function GetAmmoCount() then ammoName, ammoLink, ammoQuality, ammoLevel, ammoMinLevel, ammoType, ammoSubType, ammoStackCount, ammoEquipLoc, ammoTexture, _, ammoID, subammoID, _, _, _, _ - = GetItemInfo(GetInventoryItemID("player", ammoSlotID)) + = GetItem(GetInventoryItemID("player", ammoSlotID)) -- ammo_name = select(1, GetItemInfo(GetInventoryItemID("player", ammoSlotID))) or UNKNOWN ammo_name = ammoName or "" if ammoName == nil then diff --git a/TitanBag/TitanBag_Mainline.toc b/TitanBag/TitanBag_Mainline.toc index 09bb0b9..5171a4a 100644 --- a/TitanBag/TitanBag_Mainline.toc +++ b/TitanBag/TitanBag_Mainline.toc @@ -1,6 +1,6 @@ ## Interface: 100206 -## Title: Titan Panel [|cffeda55fBag|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fBag|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## IconTexture: Interface\AddOns\TitanBag\TitanBag ## Notes: Adds bag and free slot information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) diff --git a/TitanBag/TitanBag_Vanilla.toc b/TitanBag/TitanBag_Vanilla.toc index 0748f91..3713007 100644 --- a/TitanBag/TitanBag_Vanilla.toc +++ b/TitanBag/TitanBag_Vanilla.toc @@ -1,6 +1,6 @@ ## Interface: 11502 -## Title: Titan Panel [|cffeda55fBag|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fBag|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Adds bag and free slot information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanBag/TitanBag_Wrath.toc b/TitanBag/TitanBag_Wrath.toc index 966237f..57ee2d7 100644 --- a/TitanBag/TitanBag_Wrath.toc +++ b/TitanBag/TitanBag_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fBag|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fBag|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Adds bag and free slot information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanClassic/TitanClassic_Vanilla.toc b/TitanClassic/TitanClassic_Vanilla.toc index 85ea2eb..4f4b0af 100644 --- a/TitanClassic/TitanClassic_Vanilla.toc +++ b/TitanClassic/TitanClassic_Vanilla.toc @@ -1,7 +1,7 @@ ## Interface: 11502 -## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa008.0.10|r +## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa008.0.11|r ## Author: Titan Panel Dev Team -## Version: 8.0.10 +## Version: 8.0.11 ## SavedVariables: TitanAll, TitanSettings, TitanSkins, ServerTimeOffsets, ServerHourFormat ## OptionalDeps: Ace3, AceGUI-3.0-SharedMediaWidgets, LibSharedMedia-3.0, LibQTip-1.0, !LibUIDropDownMenu ## Notes: Adds display bars to show and control information/launcher plugins. @@ -46,6 +46,7 @@ TitanGame.lua ..\Titan\TitanGlobal.lua ..\Titan\TitanUtils.lua +..\Titan\TitanHistory.lua ..\Titan\TitanVariables.lua ..\Titan\TitanTemplate.xml ..\Titan\TitanTemplate.lua diff --git a/TitanClassic/TitanClassic_Wrath.toc b/TitanClassic/TitanClassic_Wrath.toc index f2d343f..cff1b52 100644 --- a/TitanClassic/TitanClassic_Wrath.toc +++ b/TitanClassic/TitanClassic_Wrath.toc @@ -1,7 +1,7 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa008.0.10|r +## Title: Titan Panel [|cffeda55f_Core_|r] |cff00aa008.0.11|r ## Author: Titan Panel Dev Team -## Version: 8.0.10 +## Version: 8.0.11 ## SavedVariables: TitanAll, TitanSettings, TitanSkins, ServerTimeOffsets, ServerHourFormat ## OptionalDeps: Ace3, AceGUI-3.0-SharedMediaWidgets, LibSharedMedia-3.0, LibQTip-1.0, !LibUIDropDownMenu ## Notes: Adds display bars to show and control information/launcher plugins. @@ -46,6 +46,7 @@ TitanGame.lua ..\Titan\TitanGlobal.lua ..\Titan\TitanUtils.lua +..\Titan\TitanHistory.lua ..\Titan\TitanVariables.lua ..\Titan\TitanTemplate.xml ..\Titan\TitanTemplate.lua diff --git a/TitanClassic/TitanGame.lua b/TitanClassic/TitanGame.lua index 792ad94..e33e8d0 100644 --- a/TitanClassic/TitanGame.lua +++ b/TitanClassic/TitanGame.lua @@ -1,8 +1,8 @@ ---[[ File +--[===[ File NAME: TitanGame.lua DESC: This file contains the 'game version' Titan or TitanClassic. Used to set up libs, locale, ... :DESC ---]] +--]===] TITAN_ID = "TitanClassic" diff --git a/TitanClock/TitanClock_Mainline.toc b/TitanClock/TitanClock_Mainline.toc index b9ca98d..53390e2 100644 --- a/TitanClock/TitanClock_Mainline.toc +++ b/TitanClock/TitanClock_Mainline.toc @@ -1,6 +1,6 @@ ## Interface: 100206 -## Title: Titan Panel [|cffeda55fClock|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fClock|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## IconTexture: Interface\Icons\Spell_Nature_TimeStop ## Notes: Adds a clock to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) diff --git a/TitanClock/TitanClock_Vanilla.toc b/TitanClock/TitanClock_Vanilla.toc index bcd30a7..abe2a4c 100644 --- a/TitanClock/TitanClock_Vanilla.toc +++ b/TitanClock/TitanClock_Vanilla.toc @@ -1,6 +1,6 @@ ## Interface: 11502 -## Title: Titan Panel [|cffeda55fClock|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fClock|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Adds a clock to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanClock/TitanClock_Wrath.toc b/TitanClock/TitanClock_Wrath.toc index fd852fe..6c70d1c 100644 --- a/TitanClock/TitanClock_Wrath.toc +++ b/TitanClock/TitanClock_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fClock|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fClock|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Adds a clock to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanGold/TitanGold_Mainline.toc b/TitanGold/TitanGold_Mainline.toc index 6bee6a3..7e8ccc2 100644 --- a/TitanGold/TitanGold_Mainline.toc +++ b/TitanGold/TitanGold_Mainline.toc @@ -1,6 +1,6 @@ ## Interface: 100206 -## Title: Titan Panel [|cffeda55fGold|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fGold|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## IconTexture: Interface\AddOns\TitanGold\Artwork\TitanGold ## Notes: Keeps track of all gold held by a player's toons on a per server/faction basis. ## Author: Titan Panel Development Team (http://www.titanpanel.org) diff --git a/TitanGold/TitanGold_Vanilla.toc b/TitanGold/TitanGold_Vanilla.toc index 46ca7da..e6071ec 100644 --- a/TitanGold/TitanGold_Vanilla.toc +++ b/TitanGold/TitanGold_Vanilla.toc @@ -1,6 +1,6 @@ ## Interface: 11502 -## Title: Titan Panel [|cffeda55fGold|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fGold|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Keeps track of all gold held by a player's toons on a per server/faction basis. ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: GoldSave diff --git a/TitanGold/TitanGold_Wrath.toc b/TitanGold/TitanGold_Wrath.toc index 25af16d..34d8f9c 100644 --- a/TitanGold/TitanGold_Wrath.toc +++ b/TitanGold/TitanGold_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fGold|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fGold|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Keeps track of all gold held by a player's toons on a per server/faction basis. ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: GoldSave diff --git a/TitanLocation/TitanLocation.lua b/TitanLocation/TitanLocation.lua index d1f33a4..be1e848 100755 --- a/TitanLocation/TitanLocation.lua +++ b/TitanLocation/TitanLocation.lua @@ -15,6 +15,7 @@ local _G = getfenv(0); local TITAN_LOCATION_ID = "Location"; local TITAN_BUTTON = "TitanPanel"..TITAN_LOCATION_ID.."Button" local TITAN_MAP_FRAME = "TitanMapFrame" +local TITAN_LOCATION_VERSION = TITAN_VERSION; local addon_conflict = false -- used for addon conflicts local cachedX = 0; @@ -28,6 +29,9 @@ local LocationTimerRunning = false local debug_flow = false +---@diagnostic disable-next-line: deprecated +local GetZonePVP = C_PvP.GetZonePVPInfo or GetZonePVPInfo -- For Classic versions + -- ******************************** Functions ******************************* --[[ local -- ************************************************************************** @@ -141,7 +145,7 @@ print("TLoc ZoneUpdate" local _ = nil self.zoneText = GetZoneText(); self.subZoneText = GetSubZoneText(); - self.pvpType, _, self.factionName = GetZonePVPInfo(); + self.pvpType, _, self.factionName = GetZonePVP(); TitanPanelPluginHandle_OnUpdate(updateTable); end @@ -200,7 +204,7 @@ local function LocOnMiniMap(reason) -- adjust MiniMap frame if needed if reason == "config" then - TitanPanel_AdjustFrames(false); + TitanPanel_AdjustFrames(false, "Location"); else -- 2024 Jan - Do not adjust; allow Titan to handle on PEW end @@ -722,7 +726,7 @@ local function OnLoad(self) self.registry = { id = TITAN_LOCATION_ID, category = "Built-ins", - version = (TitanUtils_GetAddOnMetadata(TITAN_LOCATION_ID, "Version")) or "", + version = TITAN_LOCATION_VERSION, menuText = L["TITAN_LOCATION_MENU_TEXT"], menuTextFunction = CreateMenu, buttonTextFunction = GetButtonText, diff --git a/TitanLocation/TitanLocation_Mainline.toc b/TitanLocation/TitanLocation_Mainline.toc index 3665c60..416e8c3 100644 --- a/TitanLocation/TitanLocation_Mainline.toc +++ b/TitanLocation/TitanLocation_Mainline.toc @@ -1,6 +1,6 @@ ## Interface: 100206 -## Title: Titan Panel [|cffeda55fLocation|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fLocation|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## IconTexture: Interface\AddOns\TitanLocation\TitanLocation ## Notes: Adds coordinates and location information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) diff --git a/TitanLocation/TitanLocation_Vanilla.toc b/TitanLocation/TitanLocation_Vanilla.toc index 2a24e3a..0c15e95 100644 --- a/TitanLocation/TitanLocation_Vanilla.toc +++ b/TitanLocation/TitanLocation_Vanilla.toc @@ -1,6 +1,6 @@ ## Interface: 11502 -## Title: Titan Panel [|cffeda55fLocation|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fLocation|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Adds coordinates and location information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanLocation/TitanLocation_Wrath.toc b/TitanLocation/TitanLocation_Wrath.toc index 5d853fd..586547d 100644 --- a/TitanLocation/TitanLocation_Wrath.toc +++ b/TitanLocation/TitanLocation_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fLocation|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fLocation|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Adds coordinates and location information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanLootType/TitanClassicLootType.lua b/TitanLootType/TitanClassicLootType.lua index 63feee5..d8b423d 100644 --- a/TitanLootType/TitanClassicLootType.lua +++ b/TitanLootType/TitanClassicLootType.lua @@ -1,4 +1,4 @@ ---[[ File +--[===[ File NAME: TitanLootType.lua DESC: This Titan plugin will show group type and loot type in the button text. @@ -15,7 +15,7 @@ The left-click it will depend whether the user is group leader or loot master : Once a leader initiates a roll, the tracker will pop for other Titan users who are using LootType. :DESC ---]] +--]===] TitanPanelLootType = {} -- declare name space local LT = TitanPanelLootType -- save some typing... diff --git a/TitanLootType/TitanLootType_Mainline.toc b/TitanLootType/TitanLootType_Mainline.toc index 26cad9c..47b648c 100644 --- a/TitanLootType/TitanLootType_Mainline.toc +++ b/TitanLootType/TitanLootType_Mainline.toc @@ -1,6 +1,6 @@ ## Interface: 100206 -## Title: Titan Panel [|cffeda55fLootType|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fLootType|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## IconTexture: Interface\AddOns\TitanLootType\TitanLootType ## Notes: Adds group loot and instance difficulty information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) diff --git a/TitanLootType/TitanLootType_Vanilla.toc b/TitanLootType/TitanLootType_Vanilla.toc index 9c14fd5..e70a0d2 100644 --- a/TitanLootType/TitanLootType_Vanilla.toc +++ b/TitanLootType/TitanLootType_Vanilla.toc @@ -1,6 +1,6 @@ ## Interface: 11502 -## Title: Titan Panel [|cffeda55fLootType|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fLootType|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Adds group loot and instance difficulty information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: TitanClassicLootTypeSaved diff --git a/TitanLootType/TitanLootType_Wrath.toc b/TitanLootType/TitanLootType_Wrath.toc index 9e46bc1..8ab7cc9 100644 --- a/TitanLootType/TitanLootType_Wrath.toc +++ b/TitanLootType/TitanLootType_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fLootType|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fLootType|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Adds group loot and instance difficulty information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: TitanClassicLootTypeSaved diff --git a/TitanPerformance/TitanPerformance.lua b/TitanPerformance/TitanPerformance.lua index 5761baf..4fa3e8f 100644 --- a/TitanPerformance/TitanPerformance.lua +++ b/TitanPerformance/TitanPerformance.lua @@ -236,7 +236,7 @@ local function SetTooltip() else rate = (button.memory - button.initialMemory) / sessionTime; color = TitanUtils_GetThresholdColor(TITAN_MEMORY_RATE_THRESHOLD_TABLE, rate); - rateRichText = TitanUtils_GetColoredText(format(L["TITAN_PANEL_PERFORMANCE_MEMORY_RATE_FORMAT"], rate), color); + rateRichText = TitanUtils_GetColoredText(format(L["TITAN_PANEL_PERFORMANCE_MEMORY_RATE_FORMAT"], rate), color) end if ( button.memory == button.initialMemory ) then timeToGCRichText = TitanUtils_GetHighlightText("N/A"); @@ -848,7 +848,7 @@ local function Slider_OnValueChanged(self, a1) -- Update GameTooltip if (self.tooltipText) then - self.tooltipText = TitanOptionSlider_TooltipText(L["TITAN_PERFORMANCE_CONTROL_TOOLTIP"], val); + self.tooltipText = TitanOptionSlider_TooltipText(L["TITAN_PERFORMANCE_CONTROL_TOOLTIP"], tostring(val)) GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1); end end diff --git a/TitanPerformance/TitanPerformance_Mainline.toc b/TitanPerformance/TitanPerformance_Mainline.toc index 928626e..01cf001 100644 --- a/TitanPerformance/TitanPerformance_Mainline.toc +++ b/TitanPerformance/TitanPerformance_Mainline.toc @@ -1,6 +1,6 @@ ## Interface: 100206 -## Title: Titan Panel [|cffeda55fPerformance|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fPerformance|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## IconTexture: Interface\AddOns\TitanPerformance\TitanPerformance ## Notes: Adds FPS and Garbage collection information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) diff --git a/TitanPerformance/TitanPerformance_Vanilla.toc b/TitanPerformance/TitanPerformance_Vanilla.toc index 4562df3..d20b5fd 100644 --- a/TitanPerformance/TitanPerformance_Vanilla.toc +++ b/TitanPerformance/TitanPerformance_Vanilla.toc @@ -1,6 +1,6 @@ ## Interface: 11502 -## Title: Titan Panel [|cffeda55fPerformance|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fPerformance|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Adds FPS and Garbage collection information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanPerformance/TitanPerformance_Wrath.toc b/TitanPerformance/TitanPerformance_Wrath.toc index 0fe471d..31a10a4 100644 --- a/TitanPerformance/TitanPerformance_Wrath.toc +++ b/TitanPerformance/TitanPerformance_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fPerformance|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fPerformance|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Adds FPS and Garbage collection information to Titan Panel ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanRegen/TitanRegen.lua b/TitanRegen/TitanRegen.lua index d5ba770..848cd9c 100644 --- a/TitanRegen/TitanRegen.lua +++ b/TitanRegen/TitanRegen.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field -- ************************************************************************** -- * TitanClassicRegen.lua -- * diff --git a/TitanRegen/TitanRegen_Vanilla.toc b/TitanRegen/TitanRegen_Vanilla.toc index c854f72..11cc21e 100644 --- a/TitanRegen/TitanRegen_Vanilla.toc +++ b/TitanRegen/TitanRegen_Vanilla.toc @@ -1,6 +1,6 @@ ## Interface: 11502 -## Title: Titan Panel [|cffeda55fRegen|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fRegen|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Adds a regen monitor to Titan Panel to show HP/MANA regen - Classic versions only ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanRegen/TitanRegen_Wrath.toc b/TitanRegen/TitanRegen_Wrath.toc index 30710ee..a797469 100644 --- a/TitanRegen/TitanRegen_Wrath.toc +++ b/TitanRegen/TitanRegen_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fRegen|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fRegen|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Adds a regen monitor to Titan Panel to show HP/MANA regen - Classic versions only ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanRepair/TitanRepair.lua b/TitanRepair/TitanRepair.lua index 04ce15a..58e09ae 100644 --- a/TitanRepair/TitanRepair.lua +++ b/TitanRepair/TitanRepair.lua @@ -25,6 +25,11 @@ local TR_Timer_active = false local parse_item = "|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?" +---@diagnostic disable-next-line: deprecated +local GetItem = C_Item.GetItemInfo or GetItemInfo -- For Classic versions +---@diagnostic disable-next-line: deprecated +local GetQ = C_Item.GetItemQualityColor or GetItemQualityColor -- For Classic versions + -- locals TR.repair_total = 0 TR.dur_total = 0 @@ -269,6 +274,7 @@ print local dmsg = "" local msg = "Scan " + if (TR.show_debug or TR.show_debug_scan) then msg = msg .." '"..tostring(reason).."'" @@ -322,10 +328,10 @@ print scan_slots = scan_slots .." item: Empty" else - _, _, Color, Ltype, Id, Enchant, + _, _, Color, Ltype, Id, Enchant, Gem1, Gem2, Gem3, Gem4, Suffix, Unique, LinkLvl, reforging, Name = string.find(itemLink, parse_item) - itemName, _, itemQuality = GetItemInfo(Id) + itemName, _, itemQuality = GetItem(Id) scan_slots = scan_slots .." id:"..tostring(Id).."" @@ -350,7 +356,7 @@ print local minimum, maximum = GetInventoryItemDurability(slotID) if minimum and maximum then -- Only calc when item has durability local hasItem, repairCost = GetRepairCostEquip(slotName, slotID) - local r, g, b, hex = GetItemQualityColor(itemQuality or 1) + local r, g, b, hex = GetQ(itemQuality or 1) scan_slots = scan_slots .." item:"..tostring(hasItem).."" @@ -461,7 +467,7 @@ print local info = C_Container.GetContainerItemInfo(bag, slot) if info and info.quality == 0 then -- gray / Poor quality - TR.grays.total = TR.grays.total + (info.stackCount * select(11, GetItemInfo(info.itemID))) + TR.grays.total = TR.grays.total + (info.stackCount * select(11, GetItem(info.itemID))) else -- ignore - not gray end @@ -770,7 +776,7 @@ local function TitanRepair_SellGrayItems() _, -- xpac id _, -- set id _ -- is crafting reagent - = GetItemInfo(info.itemID) + = GetItem(info.itemID) local msg = "Selling" .." "..tostring(info.stackCount).."" .." "..tostring(name).."" @@ -818,7 +824,7 @@ local function AutoHighlight (item_frac, valueText) return valueText; end ---[[ Titan +--[[ -- ************************************************************************** -- NAME : OnEvent(self, event, a1, ...) -- DESC : This section will grab the events registered to the add on and act on them @@ -943,7 +949,7 @@ local function GetDiscountCost(sum) return costStr, discountlabel end ---[[ Titan +--[[ -- ************************************************************************** -- NAME : GetButtonText(id) -- DESC : Determine the plugin button text based on last scan values and user preferences @@ -1043,7 +1049,7 @@ local function GetButtonText(id) end end ---[[ Titan +--[[ -- ************************************************************************** -- NAME : GetTooltipText() -- DESC : Create the Repair tool tip based on last scan and user preferences @@ -1204,7 +1210,7 @@ local function GetTooltipText() return out end ---[[ Titan +--[[ -- ************************************************************************** -- NAME : CreateMenu() -- DESC : Create the Repair right click menu @@ -1474,7 +1480,7 @@ local function CreateMenu() TitanPanelRightClickMenu_AddControlVars(TITAN_REPAIR_ID) end ---[[ Titan +--[[ -- ************************************************************************** -- NAME : OnLoad(self) -- DESC : Registers the plugin upon loading; OnShow to start; OnHide to stop diff --git a/TitanRepair/TitanRepair_Mainline.toc b/TitanRepair/TitanRepair_Mainline.toc index d217e41..dc3f46b 100644 --- a/TitanRepair/TitanRepair_Mainline.toc +++ b/TitanRepair/TitanRepair_Mainline.toc @@ -1,6 +1,6 @@ ## Interface: 100206 -## Title: Titan Panel [|cffeda55fRepair|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fRepair|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## IconTexture: Interface\AddOns\TitanRepair\TitanRepair ## Notes: Provides a configurable durability display. Also adds the ability to auto repair items and inventory at vendors. Adds selling of grey items. ## Author: Titan Panel Development Team (http://www.titanpanel.org) diff --git a/TitanRepair/TitanRepair_Vanilla.toc b/TitanRepair/TitanRepair_Vanilla.toc index b82f414..fa7a9a1 100644 --- a/TitanRepair/TitanRepair_Vanilla.toc +++ b/TitanRepair/TitanRepair_Vanilla.toc @@ -1,6 +1,6 @@ ## Interface: 11502 -## Title: Titan Panel [|cffeda55fRepair|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fRepair|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Provides a configurable durability display. Also adds the ability to auto repair items and inventory at vendors. Adds selling of grey items. ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanRepair/TitanRepair_Wrath.toc b/TitanRepair/TitanRepair_Wrath.toc index df9d7b3..2654fe7 100644 --- a/TitanRepair/TitanRepair_Wrath.toc +++ b/TitanRepair/TitanRepair_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fRepair|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fRepair|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Provides a configurable durability display. Also adds the ability to auto repair items and inventory at vendors. Adds selling of grey items. ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanVolume/TitanVolume.lua b/TitanVolume/TitanVolume.lua index 0808a29..b0e4c63 100644 --- a/TitanVolume/TitanVolume.lua +++ b/TitanVolume/TitanVolume.lua @@ -10,6 +10,8 @@ local TITAN_VOLUME_ID = "Volume"; local TITAN_VOLUME_BUTTON = "TitanPanel" .. TITAN_VOLUME_ID .. "Button" +local cname = "TitanPanelVolumeControlFrame" + local TITAN_VOLUME_FRAME_SHOW_TIME = 0.5; local TITAN_VOLUME_ARTWORK_PATH = "Interface\\AddOns\\TitanVolume\\Artwork\\"; local _G = getfenv(0); @@ -19,7 +21,24 @@ local function GetVolumeText(volume) return tostring(floor(100 * volume + 0.5)) .. "%"; end +local function IsMuted() + local mute = false + local setting = "Sound_EnableAllSound" + local value = C_CVar.GetCVar(setting) + if value == nil then + -- value is invalid - Blizz change?? + elseif value == "0" then + mute = true + elseif value == "1" then + -- not muted + else + -- value is invalid - Blizz change?? + end + return mute +end + local function SetVolumeIcon() +--[[ local icon = _G["TitanPanelVolumeButtonIcon"]; local masterVolume = tonumber(GetCVar("Sound_MasterVolume")); if (masterVolume <= 0) then @@ -31,6 +50,23 @@ local function SetVolumeIcon() else icon:SetTexture(TITAN_VOLUME_ARTWORK_PATH .. "TitanVolumeHigh"); end +--]] + local plugin = TitanUtils_GetPlugin(TITAN_VOLUME_ID) + + if IsMuted() then + plugin.icon = TITAN_VOLUME_ARTWORK_PATH .. "TitanVolumeMute" + else + local masterVolume = tonumber(GetCVar("Sound_MasterVolume")); + if (masterVolume <= 0) then + plugin.icon = TITAN_VOLUME_ARTWORK_PATH .. "TitanVolumeMute" + elseif (masterVolume < 0.33) then + plugin.icon = TITAN_VOLUME_ARTWORK_PATH .. "TitanVolumeLow" + elseif (masterVolume < 0.66) then + plugin.icon = TITAN_VOLUME_ARTWORK_PATH .. "TitanVolumeMedium" + else + plugin.icon = TITAN_VOLUME_ARTWORK_PATH .. "TitanVolumeHigh" + end + end end local function OnEvent(self, event, a1, ...) @@ -50,11 +86,13 @@ local function OnEvent(self, event, a1, ...) TitanGetVar(TITAN_VOLUME_ID, "VolumeMusic")) end -- if TitanGetVar(TITAN_VOLUME_ID, "VolumeOutboundChat") then SetCVar("OutboundChatVolume", TitanGetVar(TITAN_VOLUME_ID, "VolumeOutboundChat")) end -- if TitanGetVar(TITAN_VOLUME_ID, "VolumeInboundChat") then SetCVar("InboundChatVolume", TitanGetVar(TITAN_VOLUME_ID, "VolumeInboundChat")) end + TitanPanelButton_UpdateButton(TITAN_VOLUME_ID); end end local function OnShow() SetVolumeIcon(); + TitanPanelButton_UpdateButton(TITAN_VOLUME_ID); end local function OnEnter() @@ -66,7 +104,7 @@ local function OnEnter() TitanPanelMusicVolumeControlSlider:SetValue(1 - GetCVar("Sound_MusicVolume")); -- TitanPanelMicrophoneVolumeControlSlider:SetValue(1 - GetCVar("OutboundChatVolume")); -- TitanPanelSpeakerVolumeControlSlider:SetValue(1 - GetCVar("InboundChatVolume")); - SetVolumeIcon(); +-- SetVolumeIcon(); end -- 'Master' @@ -276,6 +314,13 @@ local function DialogSlider_OnValueChanged(self, a1) end +--[[ WoW 9.5 +Blizzard decided to remove direct Backdrop API in 9.0 (Shadowlands) +so inherit the template (XML) +and set the values in the code (Lua) + +9.5 The tooltip template was removed from the GameTooltip. +--]] local function ControlFrame_OnLoad(self) _G[self:GetName() .. "Title"]:SetText(L["TITAN_VOLUME_CONTROL_TITLE"]); -- VOLUME _G[self:GetName() .. "MasterTitle"]:SetText(L["TITAN_VOLUME_MASTER_CONTROL_TITLE"]); --MASTER_VOLUME @@ -285,17 +330,19 @@ local function ControlFrame_OnLoad(self) _G[self:GetName() .. "DialogTitle"]:SetText(L["TITAN_VOLUME_DIALOG_CONTROL_TITLE"]); -- _G[self:GetName().."MicrophoneTitle"]:SetText(L["TITAN_VOLUME_MICROPHONE_CONTROL_TITLE"]); -- _G[self:GetName().."SpeakerTitle"]:SetText(L["TITAN_VOLUME_SPEAKER_CONTROL_TITLE"]); - --[[ -Blizzard decided to remove direct Backdrop API in 9.0 (Shadowlands) -so inherit the template (XML) -and set the values in the code (Lua) - -9.5 The tooltip template was removed from the GameTooltip. ---]] TitanPanelRightClickMenu_SetCustomBackdrop(self) end local function GetTooltipText() + local mute = Titan_Global.literals.muted + + if IsMuted() then + mute = mute .. "\t" .. TitanUtils_GetRedText(Titan_Global.literals.yes) .. "\n\n" + else + mute = mute .. "\t" .. TitanUtils_GetGreenText(Titan_Global.literals.no) .. "\n\n" + end + local text = "" + local volumeMasterText = GetVolumeText(GetCVar("Sound_MasterVolume")); local volumeSoundText = GetVolumeText(GetCVar("Sound_SFXVolume")); local volumeMusicText = GetVolumeText(GetCVar("Sound_MusicVolume")); @@ -303,16 +350,21 @@ local function GetTooltipText() local volumeDialogText = GetVolumeText(GetCVar("Sound_DialogVolume")); -- local volumeMicrophoneText = GetVolumeText(GetCVar("OutboundChatVolume")); -- local volumeSpeakerText = GetVolumeText(GetCVar("InboundChatVolume")); - return "" .. - L["TITAN_VOLUME_MASTER_TOOLTIP_VALUE"] .. "\t" .. TitanUtils_GetHighlightText(volumeMasterText) .. "\n" .. - L["TITAN_VOLUME_SOUND_TOOLTIP_VALUE"] .. "\t" .. TitanUtils_GetHighlightText(volumeSoundText) .. "\n" .. - L["TITAN_VOLUME_MUSIC_TOOLTIP_VALUE"] .. "\t" .. TitanUtils_GetHighlightText(volumeMusicText) .. "\n" .. - L["TITAN_VOLUME_AMBIENCE_TOOLTIP_VALUE"] .. "\t" .. TitanUtils_GetHighlightText(volumeAmbienceText) .. "\n" .. - L["TITAN_VOLUME_DIALOG_TOOLTIP_VALUE"] .. "\t" .. TitanUtils_GetHighlightText(volumeDialogText) .. "\n" .. - -- L["TITAN_VOLUME_MICROPHONE_TOOLTIP_VALUE"].."\t"..TitanUtils_GetHighlightText(volumeMicrophoneText).."\n".. - -- L["TITAN_VOLUME_SPEAKER_TOOLTIP_VALUE"].."\t"..TitanUtils_GetHighlightText(volumeSpeakerText).."\n".. - TitanUtils_GetGreenText(L["TITAN_VOLUME_TOOLTIP_HINT1"]) .. "\n" .. - TitanUtils_GetGreenText(L["TITAN_VOLUME_TOOLTIP_HINT2"]); + + text = "".. + mute .. + L["TITAN_VOLUME_MASTER_TOOLTIP_VALUE"] .. "\t" .. TitanUtils_GetHighlightText(volumeMasterText) .. "\n" .. + L["TITAN_VOLUME_SOUND_TOOLTIP_VALUE"] .. "\t" .. TitanUtils_GetHighlightText(volumeSoundText) .. "\n" .. + L["TITAN_VOLUME_MUSIC_TOOLTIP_VALUE"] .. "\t" .. TitanUtils_GetHighlightText(volumeMusicText) .. "\n" .. + L["TITAN_VOLUME_AMBIENCE_TOOLTIP_VALUE"] .. "\t" .. TitanUtils_GetHighlightText(volumeAmbienceText) .. "\n" .. + L["TITAN_VOLUME_DIALOG_TOOLTIP_VALUE"] .. "\t" .. TitanUtils_GetHighlightText(volumeDialogText) .. "\n" .. + -- L["TITAN_VOLUME_MICROPHONE_TOOLTIP_VALUE"].."\t"..TitanUtils_GetHighlightText(volumeMicrophoneText).."\n".. + -- L["TITAN_VOLUME_SPEAKER_TOOLTIP_VALUE"].."\t"..TitanUtils_GetHighlightText(volumeSpeakerText).."\n".. + TitanUtils_GetGreenText(L["TITAN_VOLUME_TOOLTIP_HINT1"]) .. "\n" .. + TitanUtils_GetGreenText(L["TITAN_VOLUME_TOOLTIP_HINT2"]) .. "\n" .. + "" + + return text end function CreateMenu() @@ -337,9 +389,27 @@ function CreateMenu() TitanPanelRightClickMenu_AddControlVars(TITAN_VOLUME_ID) end +local function OnDoubleClick(self, button) + if button == "LeftButton" then + -- Toggle mute value + if IsMuted() then + SetCVar("Sound_EnableAllSound","1") + else + SetCVar("Sound_EnableAllSound","0") + end + SetVolumeIcon() + _G[cname]:Hide() + TitanPanelButton_UpdateButton(TITAN_VOLUME_ID); + else + -- No action + end +end + local function OnLoad(self) local notes = "" - .. "Adds a volume control icon on your Titan Bar.\n" + .. "Adds a volume control icon on your Titan Bar.\n" + .. L["TITAN_VOLUME_TOOLTIP_HINT1"] .. "\n" + .. L["TITAN_VOLUME_TOOLTIP_HINT2"] .. "\n" -- .."- xxx.\n" self.registry = { id = TITAN_VOLUME_ID, @@ -407,7 +477,6 @@ local function Create_Frames() ---[===[ -- Config screen - local cname = "TitanPanelVolumeControlFrame" local config = CreateFrame("Frame", cname, f, BackdropTemplateMixin and "BackdropTemplate") config:SetFrameStrata("FULLSCREEN") -- config:Hide() @@ -423,6 +492,10 @@ local function Create_Frames() config:SetScript("OnUpdate", function(self, elapsed) TitanUtils_CheckFrameCounting(self, elapsed) end) + window:SetScript("OnDoubleClick", function(self, button) + OnDoubleClick(self, button) +-- TitanPanelButton_OnClick(self, button) + end) -- Config font sections local str = nil diff --git a/TitanVolume/TitanVolume_Mainline.toc b/TitanVolume/TitanVolume_Mainline.toc index 5176553..e262b88 100644 --- a/TitanVolume/TitanVolume_Mainline.toc +++ b/TitanVolume/TitanVolume_Mainline.toc @@ -1,6 +1,6 @@ ## Interface: 100206 -## Title: Titan Panel [|cffeda55fVolume|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fVolume|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## IconTexture: Interface\AddOns\TitanVolume\Artwork\TitanVolumeHigh ## Notes: Adds a volume control icon on your Titan Bar ## Author: Titan Panel Development Team (http://www.titanpanel.org) diff --git a/TitanVolume/TitanVolume_Vanilla.toc b/TitanVolume/TitanVolume_Vanilla.toc index 317f2a6..f5ba2f0 100644 --- a/TitanVolume/TitanVolume_Vanilla.toc +++ b/TitanVolume/TitanVolume_Vanilla.toc @@ -1,6 +1,6 @@ ## Interface: 11502 -## Title: Titan Panel [|cffeda55fVolume|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fVolume|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Adds a volume control icon on your Titan Bar ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanVolume/TitanVolume_Wrath.toc b/TitanVolume/TitanVolume_Wrath.toc index 01217b2..69bd883 100644 --- a/TitanVolume/TitanVolume_Wrath.toc +++ b/TitanVolume/TitanVolume_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fVolume|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fVolume|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Adds a volume control icon on your Titan Bar ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanXP/TitanXP.lua b/TitanXP/TitanXP.lua index cf0c98a..8fdeba7 100644 --- a/TitanXP/TitanXP.lua +++ b/TitanXP/TitanXP.lua @@ -9,10 +9,10 @@ -- ******************************** Constants ******************************* local TITAN_XP_ID = "XP"; -local TITAN_XP_BUTTON = "TitanPanel"..TITAN_XP_ID.."Button" +local TITAN_XP_BUTTON = "TitanPanel" .. TITAN_XP_ID .. "Button" local _G = getfenv(0); local TITAN_XP_FREQUENCY = 1; -local updateTable = {TITAN_XP_ID, TITAN_PANEL_UPDATE_ALL}; +local updateTable = { TITAN_XP_ID, TITAN_PANEL_UPDATE_ALL }; -- ******************************** Variables ******************************* local lastMobXP, lastXP, XPGain = 0, 0, 0 local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) @@ -20,6 +20,24 @@ local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true) local trace = false local trace_update = false +--****** overload the 'time played' text to Chat - if XP requested the API call + +local requesting +local xp_frame = {} + +-- Save orignal output to Chat +local orig_ChatFrame_DisplayTimePlayed = ChatFrame_DisplayTimePlayed +-- Override the output to Chat +ChatFrame_DisplayTimePlayed = function(...) + if requesting then + -- XP requested time played, do not spam Chat + requesting = false + else + -- XP did not request time played so output + orig_ChatFrame_DisplayTimePlayed(...) + end +end + -- ******************************** Functions ******************************* --[[ -- ************************************************************************** @@ -53,7 +71,7 @@ local function comma_value(amount) while true do if sep == "UseComma" then formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') end if sep == "UsePeriod" then formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1.%2') end - if (k==0) then + if (k == 0) then break end end @@ -62,16 +80,29 @@ end --[[ -- ************************************************************************** +-- NAME : RefreshPlayed() +-- DESC : Get total time played +-- Do not send RequestTimePlayed output to Chat if XP requested the info. +-- This is done by overriding the routine RequestTimePlayed() uses +-- ChatFrame_DisplayTimePlayed. +-- ************************************************************************** +--]] +local function RefreshPlayed() + xp_frame:RequestTimePlayed() +end + +--[[ +-- ************************************************************************** -- NAME : OnShow() -- DESC : Display the icon in the bar -- ************************************************************************** --]] local function OnShow(self) local txt = "" - + if (not self.sessionTime) then -- initial login / PEW self.sessionTime = time(); - txt = txt.."Sess reset" + txt = txt .. "Sess reset" end if (not self.initXP) then -- initial login / PEW self.initXP = UnitXP("player"); @@ -79,23 +110,21 @@ local function OnShow(self) self.sessionXP = 0; self.startSessionTime = time(); lastXP = self.initXP; - txt = txt.." | Init" + txt = txt .. " | Init" end self:RegisterEvent("TIME_PLAYED_MSG"); self:RegisterEvent("PLAYER_XP_UPDATE"); self:RegisterEvent("PLAYER_LEVEL_UP"); self:RegisterEvent("CHAT_MSG_COMBAT_XP_GAIN"); - SetIcon(); - txt = txt.." | Events" + RefreshPlayed() - -- Time played received attached to an event - RequestTimePlayed(); - txt = txt.." | Time played" + SetIcon(); + txt = txt .. " | Events" if trace then local dbg = "XP _OnShow" - .." "..tostring(txt).."" + .. " " .. tostring(txt) .. "" TitanPluginDebug(TITAN_XP_ID, dbg) end end @@ -118,13 +147,14 @@ local function OnEvent(self, event, a1, a2, ...) local txt = "" if trace then txt = "_OnEvent" - .." "..tostring(event).."" --- .." "..tostring(a1).."" --- .." "..tostring(a2).."" + .. " " .. tostring(event) .. "" + -- .." "..tostring(a1).."" + -- .." "..tostring(a2).."" TitanPluginDebug(TITAN_XP_ID, txt) end if (event == "PLAYER_ENTERING_WORLD") then + -- Do nothing elseif (event == "TIME_PLAYED_MSG") then -- Remember play time self.totalTime = a1; @@ -145,9 +175,9 @@ local function OnEvent(self, event, a1, a2, ...) self.sessionXP = UnitXP("player") - self.initXP + self.accumXP; if trace then txt = "XP Ev " - .." unit "..tostring(format("%0.1f", UnitXP("player"))).."" - .." init "..tostring(format("%0.1f", self.initXP)).."" - .." acc "..tostring(format("%0.1f", self.accumXP)).."" + .. " unit " .. tostring(format("%0.1f", UnitXP("player"))) .. "" + .. " init " .. tostring(format("%0.1f", self.initXP)) .. "" + .. " acc " .. tostring(format("%0.1f", self.accumXP)) .. "" TitanPluginDebug(TITAN_XP_ID, txt) end elseif (event == "PLAYER_LEVEL_UP") then @@ -155,7 +185,7 @@ local function OnEvent(self, event, a1, a2, ...) self.accumXP = self.accumXP + UnitXPMax("player") - self.initXP; self.initXP = 0; elseif (event == "CHAT_MSG_COMBAT_XP_GAIN") then - local _,_,_,killXP = string.find(a1, "^"..L["TITAN_XP_GAIN_PATTERN"]) + local _, _, _, killXP = string.find(a1, "^" .. L["TITAN_XP_GAIN_PATTERN"]) if killXP then lastMobXP = tonumber(killXP) end if lastMobXP < 0 then lastMobXP = 0 end end @@ -170,7 +200,7 @@ end --]] local function OnUpdate(self, elapsed) TITAN_XP_FREQUENCY = TITAN_XP_FREQUENCY - elapsed; - if (TITAN_XP_FREQUENCY <=0) then + if (TITAN_XP_FREQUENCY <= 0) then TITAN_XP_FREQUENCY = 1; TitanPanelPluginHandle_OnUpdate(updateTable) end @@ -209,7 +239,7 @@ local function GetButtonText(id) if (TitanPanelXPButton.startSessionTime == nil) then if trace then txt = "XP " - .." "..tostring("start not set - too early").."" + .. " " .. tostring("start not set - too early") .. "" TitanPluginDebug(TITAN_XP_ID, txt) end return @@ -227,82 +257,87 @@ local function GetButtonText(id) if XPGain ~= 0 then numofgains = math.ceil(toLevelXP / XPGain) else numofgains = _G["UNKNOWN"] end if trace_update then txt = "XP / Hr" - .." sxp"..tostring(format("%0.1f", sessionXP)).."" - .." st"..tostring(format("%0.1f", TitanPanelXPButton.startSessionTime)).."" + .. " sxp" .. tostring(format("%0.1f", sessionXP)) .. "" + .. " st" .. tostring(format("%0.1f", TitanPanelXPButton.startSessionTime)) .. "" TitanPluginDebug(TITAN_XP_ID, txt) end if (levelTime) then if (TitanGetVar(TITAN_XP_ID, "DisplayType") == "ShowXPPerHourSession") then xpPerHour = sessionXP / sessionTime * 3600; - -- timeToLevel = TitanUtils_Ternary((sessionXP == 0), -1, toLevelXP / sessionXP * sessionTime); + -- timeToLevel = TitanUtils_Ternary((sessionXP == 0), -1, toLevelXP / sessionXP * sessionTime); timeToLevel = (sessionXP == 0) and -1 or toLevelXP / sessionXP * sessionTime; - xpPerHourText = comma_value(math.floor(xpPerHour+0.5)); + xpPerHourText = comma_value(math.floor(xpPerHour + 0.5)); timeToLevelText = TitanUtils_GetEstTimeText(timeToLevel); if trace_update then txt = "XP / Hr" - .." hr: "..tostring(format("%0.1f", xpPerHour)).."" - .." '"..tostring(xpPerHourText).."'" - .." lvl: "..tostring(format("%0.1f", timeToLevel)).."" - .." '"..tostring(timeToLevelText).."'" + .. " hr: " .. tostring(format("%0.1f", xpPerHour)) .. "" + .. " '" .. tostring(xpPerHourText) .. "'" + .. " lvl: " .. tostring(format("%0.1f", timeToLevel)) .. "" + .. " '" .. tostring(timeToLevelText) .. "'" TitanPluginDebug(TITAN_XP_ID, txt) end return L["TITAN_XP_BUTTON_LABEL_XPHR_SESSION"], TitanUtils_GetHighlightText(xpPerHourText), L["TITAN_XP_BUTTON_LABEL_TOLEVEL_TIME_LEVEL"], TitanUtils_GetHighlightText(timeToLevelText); - elseif (TitanGetVar(TITAN_XP_ID,"DisplayType") == "ShowXPPerHourLevel") then + elseif (TitanGetVar(TITAN_XP_ID, "DisplayType") == "ShowXPPerHourLevel") then xpPerHour = currentXP / levelTime * 3600; - -- timeToLevel = TitanUtils_Ternary((currentXP == 0), -1, toLevelXP / currentXP * levelTime); + -- timeToLevel = TitanUtils_Ternary((currentXP == 0), -1, toLevelXP / currentXP * levelTime); timeToLevel = (currentXP == 0) and -1 or toLevelXP / currentXP * levelTime; - xpPerHourText = comma_value(math.floor(xpPerHour+0.5)); + xpPerHourText = comma_value(math.floor(xpPerHour + 0.5)); timeToLevelText = TitanUtils_GetEstTimeText(timeToLevel); return L["TITAN_XP_BUTTON_LABEL_XPHR_LEVEL"], TitanUtils_GetHighlightText(xpPerHourText), L["TITAN_XP_BUTTON_LABEL_TOLEVEL_TIME_LEVEL"], TitanUtils_GetHighlightText(timeToLevelText); - elseif (TitanGetVar(TITAN_XP_ID,"DisplayType") == "ShowSessionTime") then - return L["TITAN_XP_BUTTON_LABEL_SESSION_TIME"], TitanUtils_GetHighlightText(TitanUtils_GetAbbrTimeText(sessionTime)); - elseif (TitanGetVar(TITAN_XP_ID,"DisplayType") == "ShowXPSimple") then + elseif (TitanGetVar(TITAN_XP_ID, "DisplayType") == "ShowSessionTime") then + return L["TITAN_XP_BUTTON_LABEL_SESSION_TIME"], + TitanUtils_GetHighlightText(TitanUtils_GetAbbrTimeText(sessionTime)); + elseif (TitanGetVar(TITAN_XP_ID, "DisplayType") == "ShowXPSimple") then local toLevelXPText = ""; local rest = ""; local labelrested = ""; local labeltolevel = ""; local labelnumofkills = ""; local labelnumofgains = ""; - local percent = floor(10000*(currentXP/totalXP)+0.5)/100; - if TitanGetVar(TITAN_XP_ID,"ShowSimpleToLevel") then - toLevelXPText = TitanUtils_GetColoredText(format(L["TITAN_XP_FORMAT"], comma_value(math.floor(toLevelXP+0.5))), _G["GREEN_FONT_COLOR"]); + local percent = floor(10000 * (currentXP / totalXP) + 0.5) / 100; + if TitanGetVar(TITAN_XP_ID, "ShowSimpleToLevel") then + toLevelXPText = TitanUtils_GetColoredText( + format(L["TITAN_XP_FORMAT"], comma_value(math.floor(toLevelXP + 0.5))), _G["GREEN_FONT_COLOR"]); labeltolevel = L["TITAN_XP_XPTOLEVELUP"]; end - if TitanGetVar(TITAN_XP_ID,"ShowSimpleRested") then - rest = TitanUtils_GetColoredText(comma_value(GetXPExhaustion()==nil and "0" or GetXPExhaustion()),{r=0.44, g=0.69, b=0.94}); + if TitanGetVar(TITAN_XP_ID, "ShowSimpleRested") then + rest = TitanUtils_GetColoredText(comma_value(GetXPExhaustion() == nil and "0" or GetXPExhaustion()), + { r = 0.44, g = 0.69, b = 0.94 }); labelrested = L["TITAN_XP_TOTAL_RESTED"]; end - if TitanGetVar(TITAN_XP_ID,"ShowSimpleNumOfKills") then - numofkills = TitanUtils_GetColoredText(comma_value(numofkills), {r=0.24, g=0.7, b=0.44}) + if TitanGetVar(TITAN_XP_ID, "ShowSimpleNumOfKills") then + numofkills = TitanUtils_GetColoredText(comma_value(numofkills), { r = 0.24, g = 0.7, b = 0.44 }) labelnumofkills = L["TITAN_XP_KILLS_LABEL_SHORT"]; else numofkills = "" end - if TitanGetVar(TITAN_XP_ID,"ShowSimpleNumOfGains") then - numofgains = TitanUtils_GetColoredText(comma_value(numofgains), {r=1, g=0.49, b=0.04}) + if TitanGetVar(TITAN_XP_ID, "ShowSimpleNumOfGains") then + numofgains = TitanUtils_GetColoredText(comma_value(numofgains), { r = 1, g = 0.49, b = 0.04 }) labelnumofgains = L["TITAN_XP_XPGAINS_LABEL_SHORT"]; else numofgains = "" end - if TitanGetVar(TITAN_XP_ID,"ShowSimpleNumOfGains") then - return L["TITAN_XP_LEVEL_COMPLETE"], TitanUtils_GetHighlightText(percent .. "%"), labelrested, rest , labeltolevel, toLevelXPText, labelnumofgains, numofgains + if TitanGetVar(TITAN_XP_ID, "ShowSimpleNumOfGains") then + return L["TITAN_XP_LEVEL_COMPLETE"], TitanUtils_GetHighlightText(percent .. "%"), labelrested, rest, + labeltolevel, toLevelXPText, labelnumofgains, numofgains else - return L["TITAN_XP_LEVEL_COMPLETE"], TitanUtils_GetHighlightText(percent .. "%"), labelrested, rest , labeltolevel, toLevelXPText, labelnumofkills, numofkills + return L["TITAN_XP_LEVEL_COMPLETE"], TitanUtils_GetHighlightText(percent .. "%"), labelrested, rest, + labeltolevel, toLevelXPText, labelnumofkills, numofkills end end else if trace_update then TitanPluginDebug(TITAN_XP_ID, "pending") end - return "("..L["TITAN_XP_UPDATE_PENDING"]..")"; + return "(" .. L["TITAN_XP_UPDATE_PENDING"] .. ")"; end end end @@ -326,31 +361,53 @@ local function GetTooltipText() local toLevelXPPercent = toLevelXP / totalXP * 100; local xpPerHourThisLevel = currentXP / levelTime * 3600; local xpPerHourThisSession = TitanPanelXPButton.sessionXP / sessionTime * 3600; - local estTimeToLevelThisLevel = TitanUtils_Ternary((currentXP == 0), -1, toLevelXP / (max(currentXP,1)) * levelTime); + local estTimeToLevelThisLevel = TitanUtils_Ternary((currentXP == 0), -1, toLevelXP / (max(currentXP, 1)) * levelTime); local estTimeToLevelThisSession = 0; if TitanPanelXPButton.sessionXP > 0 then - estTimeToLevelThisSession = TitanUtils_Ternary((TitanPanelXPButton.sessionXP == 0), -1, toLevelXP / TitanPanelXPButton.sessionXP * sessionTime); + estTimeToLevelThisSession = TitanUtils_Ternary((TitanPanelXPButton.sessionXP == 0), -1, + toLevelXP / TitanPanelXPButton.sessionXP * sessionTime); end local numofkills, numofgains; if lastMobXP ~= 0 then numofkills = math.ceil(toLevelXP / lastMobXP) else numofkills = _G["UNKNOWN"] end if XPGain ~= 0 then numofgains = math.ceil(toLevelXP / XPGain) else numofgains = _G["UNKNOWN"] end - return "".. - L["TITAN_XP_TOOLTIP_TOTAL_TIME"].."\t"..TitanUtils_GetHighlightText(TitanUtils_GetAbbrTimeText(totalTime)).."\n".. - L["TITAN_XP_TOOLTIP_LEVEL_TIME"].."\t"..TitanUtils_GetHighlightText(TitanUtils_GetAbbrTimeText(levelTime)).."\n".. - L["TITAN_XP_TOOLTIP_SESSION_TIME"].."\t"..TitanUtils_GetHighlightText(TitanUtils_GetAbbrTimeText(sessionTime)).."\n".. - "\n".. - L["TITAN_XP_TOOLTIP_TOTAL_XP"].."\t"..TitanUtils_GetHighlightText(comma_value(totalXP)).."\n".. - L["TITAN_XP_TOTAL_RESTED"].."\t"..TitanUtils_GetHighlightText(comma_value(GetXPExhaustion()==nil and "0" or GetXPExhaustion())).."\n".. - L["TITAN_XP_TOOLTIP_LEVEL_XP"].."\t"..TitanUtils_GetHighlightText(comma_value(currentXP).." "..format(L["TITAN_XP_PERCENT_FORMAT"], currentXPPercent)).."\n".. - L["TITAN_XP_TOOLTIP_TOLEVEL_XP"].."\t"..TitanUtils_GetHighlightText(comma_value(toLevelXP).." "..format(L["TITAN_XP_PERCENT_FORMAT"], toLevelXPPercent)).."\n".. - L["TITAN_XP_TOOLTIP_SESSION_XP"].."\t"..TitanUtils_GetHighlightText(comma_value(TitanPanelXPButton.sessionXP)).."\n".. - format(L["TITAN_XP_KILLS_LABEL"], comma_value(lastMobXP)).."\t"..TitanUtils_GetHighlightText(comma_value(numofkills)).."\n".. - format(L["TITAN_XP_XPGAINS_LABEL"], comma_value(XPGain)).."\t"..TitanUtils_GetHighlightText(comma_value(numofgains)).."\n".. - "\n".. - L["TITAN_XP_TOOLTIP_XPHR_LEVEL"].."\t"..TitanUtils_GetHighlightText(format(L["TITAN_XP_FORMAT"], comma_value(math.floor(xpPerHourThisLevel+0.5)))).."\n".. - L["TITAN_XP_TOOLTIP_XPHR_SESSION"].."\t"..TitanUtils_GetHighlightText(format(L["TITAN_XP_FORMAT"], comma_value(math.floor(xpPerHourThisSession+0.5)))).."\n".. - L["TITAN_XP_TOOLTIP_TOLEVEL_LEVEL"].."\t"..TitanUtils_GetHighlightText(TitanUtils_GetAbbrTimeText(estTimeToLevelThisLevel)).."\n".. - L["TITAN_XP_TOOLTIP_TOLEVEL_SESSION"].."\t"..TitanUtils_GetHighlightText(TitanUtils_GetAbbrTimeText(estTimeToLevelThisSession)); + return "" .. + L["TITAN_XP_TOOLTIP_TOTAL_TIME"] .. + "\t" .. TitanUtils_GetHighlightText(TitanUtils_GetAbbrTimeText(totalTime)) .. "\n" .. + L["TITAN_XP_TOOLTIP_LEVEL_TIME"] .. + "\t" .. TitanUtils_GetHighlightText(TitanUtils_GetAbbrTimeText(levelTime)) .. "\n" .. + L["TITAN_XP_TOOLTIP_SESSION_TIME"] .. + "\t" .. TitanUtils_GetHighlightText(TitanUtils_GetAbbrTimeText(sessionTime)) .. "\n" .. + "\n" .. + L["TITAN_XP_TOOLTIP_TOTAL_XP"] .. "\t" .. TitanUtils_GetHighlightText(comma_value(totalXP)) .. "\n" .. + L["TITAN_XP_TOTAL_RESTED"] .. + "\t" .. TitanUtils_GetHighlightText(comma_value(GetXPExhaustion() == nil and "0" or GetXPExhaustion())) .. "\n" .. + L["TITAN_XP_TOOLTIP_LEVEL_XP"] .. + "\t" .. + TitanUtils_GetHighlightText(comma_value(currentXP) .. " " .. + format(L["TITAN_XP_PERCENT_FORMAT"], currentXPPercent)) .. "\n" .. + L["TITAN_XP_TOOLTIP_TOLEVEL_XP"] .. + "\t" .. + TitanUtils_GetHighlightText(comma_value(toLevelXP) .. " " .. + format(L["TITAN_XP_PERCENT_FORMAT"], toLevelXPPercent)) .. "\n" .. + L["TITAN_XP_TOOLTIP_SESSION_XP"] .. + "\t" .. TitanUtils_GetHighlightText(comma_value(TitanPanelXPButton.sessionXP)) .. "\n" .. + format(L["TITAN_XP_KILLS_LABEL"], comma_value(lastMobXP)) .. + "\t" .. TitanUtils_GetHighlightText(comma_value(numofkills)) .. "\n" .. + format(L["TITAN_XP_XPGAINS_LABEL"], comma_value(XPGain)) .. + "\t" .. TitanUtils_GetHighlightText(comma_value(numofgains)) .. "\n" .. + "\n" .. + L["TITAN_XP_TOOLTIP_XPHR_LEVEL"] .. + "\t" .. + TitanUtils_GetHighlightText(format(L["TITAN_XP_FORMAT"], comma_value(math.floor(xpPerHourThisLevel + 0.5)))) .. + "\n" .. + L["TITAN_XP_TOOLTIP_XPHR_SESSION"] .. + "\t" .. + TitanUtils_GetHighlightText(format(L["TITAN_XP_FORMAT"], comma_value(math.floor(xpPerHourThisSession + 0.5)))) .. + "\n" .. + L["TITAN_XP_TOOLTIP_TOLEVEL_LEVEL"] .. + "\t" .. TitanUtils_GetHighlightText(TitanUtils_GetAbbrTimeText(estTimeToLevelThisLevel)) .. "\n" .. + L["TITAN_XP_TOOLTIP_TOLEVEL_SESSION"] .. + "\t" .. TitanUtils_GetHighlightText(TitanUtils_GetAbbrTimeText(estTimeToLevelThisSession)); end local function Seperator(chosen) @@ -404,7 +461,7 @@ end local function ShowXPSimple() TitanSetVar(TITAN_XP_ID, "DisplayType", "ShowXPSimple"); TitanPanelButton_UpdateButton(TITAN_XP_ID); - end +end --[[ -- ************************************************************************** @@ -422,49 +479,44 @@ end --[[ -- ************************************************************************** --- NAME : RefreshPlayed() --- DESC : Get total time played --- ************************************************************************** ---]] -local function RefreshPlayed() - RequestTimePlayed(); -end - ---[[ --- ************************************************************************** -- NAME : TitanPanelRightClickMenu_PrepareXPMenu() -- DESC : Display rightclick menu options -- ************************************************************************** --]] local function CreateMenu() - local info = {}; if TitanPanelRightClickMenu_GetDropdownLevel() == 2 then TitanPanelRightClickMenu_AddTitle(L["TITAN_XP_MENU_SIMPLE_BUTTON_TITLE"], 2); info = {}; info.text = L["TITAN_XP_MENU_SIMPLE_BUTTON_RESTED"]; - info.func = function() TitanPanelRightClickMenu_ToggleVar({TITAN_XP_ID, "ShowSimpleRested"}) end + info.func = function() TitanPanelRightClickMenu_ToggleVar({ TITAN_XP_ID, "ShowSimpleRested" }) end info.checked = TitanUtils_Ternary(TitanGetVar(TITAN_XP_ID, "ShowSimpleRested"), 1, nil); info.keepShownOnClick = 1; TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); info = {}; info.text = L["TITAN_XP_MENU_SIMPLE_BUTTON_TOLEVELUP"]; - info.func = function() TitanPanelRightClickMenu_ToggleVar({TITAN_XP_ID, "ShowSimpleToLevel"}) end + info.func = function() TitanPanelRightClickMenu_ToggleVar({ TITAN_XP_ID, "ShowSimpleToLevel" }) end info.checked = TitanUtils_Ternary(TitanGetVar(TITAN_XP_ID, "ShowSimpleToLevel"), 1, nil); info.keepShownOnClick = 1; TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); info = {}; info.text = L["TITAN_XP_MENU_SIMPLE_BUTTON_KILLS"]; - info.func = function() TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfKills", true) TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfGains", false) end + info.func = function() + TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfKills", true) + TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfGains", false) + end info.checked = TitanUtils_Ternary(TitanGetVar(TITAN_XP_ID, "ShowSimpleNumOfKills"), 1, nil); TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); info = {}; info.text = L["TITAN_XP_MENU_SIMPLE_BUTTON_XPGAIN"]; - info.func = function() TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfGains", true) TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfKills", false) end + info.func = function() + TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfGains", true) + TitanSetVar(TITAN_XP_ID, "ShowSimpleNumOfKills", false) + end info.checked = TitanUtils_Ternary(TitanGetVar(TITAN_XP_ID, "ShowSimpleNumOfGains"), 1, nil); TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); return @@ -502,14 +554,15 @@ local function CreateMenu() TitanPanelRightClickMenu_AddSpacer(); - local info = {}; + info = {}; info.text = L["TITAN_PANEL_USE_COMMA"]; info.checked = TitanGetVar(TITAN_XP_ID, "UseSeperatorComma"); info.func = function() Seperator("UseSeperatorComma") end TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel()); - local info = {}; + + info = {}; info.text = L["TITAN_PANEL_USE_PERIOD"]; info.checked = TitanGetVar(TITAN_XP_ID, "UseSeperatorPeriod"); info.func = function() @@ -528,8 +581,8 @@ end --]] local function OnLoad(self) local notes = "" - .."Adds information to Titan Panel about XP earned and time to level.\n" --- .."- xxx.\n" + .. "Adds information to Titan Panel about XP earned and time to level.\n" + -- .."- xxx.\n" self.registry = { id = TITAN_XP_ID, category = "Built-ins", @@ -560,39 +613,46 @@ local function OnLoad(self) DisplayOnRightSide = false, } }; --- self:RegisterEvent("PLAYER_ENTERING_WORLD"); + -- self:RegisterEvent("PLAYER_ENTERING_WORLD"); end -- ====== Create needed frames local function Create_Frames() if _G[TITAN_XP_BUTTON] then - return -- if already created + -- if already created + else + -- general container frame + local f = CreateFrame("Frame", nil, UIParent) + -- f:Hide() + + -- Titan plugin button + local window = CreateFrame("Button", TITAN_XP_BUTTON, f, "TitanPanelComboTemplate") + xp_frame = window + window:SetFrameStrata("FULLSCREEN") + -- Using SetScript("OnLoad", does not work + OnLoad(window); + -- TitanPanelButton_OnLoad(window); -- Titan XML template calls this... + + window:SetScript("OnShow", function(self) + OnShow(self) + TitanPanelButton_OnShow(self) + end) + window:SetScript("OnHide", function(self) + OnHide(self) + end) + window:SetScript("OnEvent", function(self, event, ...) + OnEvent(self, event, ...) + end) + window:SetScript("OnUpdate", function(self, elapsed) + OnUpdate(self, elapsed) + end) + + -- Do not output Chat messages when using RequestTimePlayed + function window:RequestTimePlayed() + requesting = true + RequestTimePlayed() + end end - - -- general container frame - local f = CreateFrame("Frame", nil, UIParent) --- f:Hide() - - -- Titan plugin button - local window = CreateFrame("Button", TITAN_XP_BUTTON, f, "TitanPanelComboTemplate") - window:SetFrameStrata("FULLSCREEN") - -- Using SetScript("OnLoad", does not work - OnLoad(window); --- TitanPanelButton_OnLoad(window); -- Titan XML template calls this... - - window:SetScript("OnShow", function(self) - OnShow(self) - TitanPanelButton_OnShow(self) - end) - window:SetScript("OnHide", function(self) - OnHide(self) - end) - window:SetScript("OnEvent", function(self, event, ...) - OnEvent(self, event, ...) - end) - window:SetScript("OnUpdate", function(self, elapsed) - OnUpdate(self, elapsed) - end) end diff --git a/TitanXP/TitanXP_Mainline.toc b/TitanXP/TitanXP_Mainline.toc index bd7e8e4..20a6ea9 100644 --- a/TitanXP/TitanXP_Mainline.toc +++ b/TitanXP/TitanXP_Mainline.toc @@ -1,6 +1,6 @@ ## Interface: 100206 -## Title: Titan Panel [|cffeda55fXP|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fXP|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## IconTexture: Interface\Icons\xp_icon ## Notes: Adds information to Titan Panel about XP earned and time to level ## Author: Titan Panel Development Team (http://www.titanpanel.org) diff --git a/TitanXP/TitanXP_Vanilla.toc b/TitanXP/TitanXP_Vanilla.toc index 13cc99a..19d51b4 100644 --- a/TitanXP/TitanXP_Vanilla.toc +++ b/TitanXP/TitanXP_Vanilla.toc @@ -1,6 +1,6 @@ ## Interface: 11502 -## Title: Titan Panel [|cffeda55fXP|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fXP|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Adds information to Titan Panel about XP earned and time to level ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: diff --git a/TitanXP/TitanXP_Wrath.toc b/TitanXP/TitanXP_Wrath.toc index a593560..31cc97c 100644 --- a/TitanXP/TitanXP_Wrath.toc +++ b/TitanXP/TitanXP_Wrath.toc @@ -1,6 +1,6 @@ ## Interface: 30403 -## Title: Titan Panel [|cffeda55fXP|r] |cff00aa008.0.10|r -## Version: 8.0.10 +## Title: Titan Panel [|cffeda55fXP|r] |cff00aa008.0.11|r +## Version: 8.0.11 ## Notes: Adds information to Titan Panel about XP earned and time to level ## Author: Titan Panel Development Team (http://www.titanpanel.org) ## SavedVariables: