From 6e582a02e31b0d51f5ab6bc130802e4861246554 Mon Sep 17 00:00:00 2001 From: urnati Date: Sun, 7 Jul 2024 16:04:48 -0400 Subject: [PATCH] Clock, Location, Performance, Repair, Volume, XP : Refactor code for IDE, mostly comments; some code. Changes for Titan color code Titan : - AutoHide : Fix tooltip error; shows Enabled / Disabled - Deprecated Titan Child template plugin code removed. - Refactor Titan code to move color codes to Titan globals. - Cleanup Titan tool tip code. - Add debug to Titan startup code. --- Titan/Titan.lua | 165 ++++----- Titan/TitanAutoHide.lua | 185 +++++----- Titan/TitanConfig.lua | 236 ++++++------ Titan/TitanGame.lua | 7 +- Titan/TitanGlobal.lua | 17 +- Titan/TitanHistory.lua | 26 +- Titan/TitanLDB.lua | 2 - Titan/TitanTemplate.lua | 101 ++--- Titan/TitanTemplate.xml | 16 - Titan/TitanUtils.lua | 306 ++++++---------- Titan/TitanVariables.lua | 36 +- Titan/_TitanIDE.lua | 5 +- TitanClassic/TitanGame.lua | 2 + TitanClock/TitanClock.lua | 186 ++++------ TitanGold/TitanGold.lua | 652 ++++++++++++++++----------------- TitanLocation/TitanLocation.lua | 467 +++++++++++------------ TitanPerformance/TitanPerformance.lua | 590 +++++++++++++++-------------- TitanRepair/TitanRepair.lua | 247 +++++-------- TitanVolume/TitanVolume.lua | 456 ++++++++--------------- TitanXP/TitanXP.lua | 313 +++++++--------- 20 files changed, 1737 insertions(+), 2278 deletions(-) diff --git a/Titan/Titan.lua b/Titan/Titan.lua index f06a111..f8354b0 100644 --- a/Titan/Titan.lua +++ b/Titan/Titan.lua @@ -1,6 +1,6 @@ ---@diagnostic disable: duplicate-set-field --[===[ File -Contains the basic routines of Titan. +Contains the basic routines of Titan. All the event handler routines, initialization routines, Titan menu routines, and select plugin handler routines. --]===] @@ -191,19 +191,6 @@ function TitanSetPanelFont(fontname, fontsize) if buttonText then buttonText:SetFont(newfont, fontsize); end - -- account for plugins with child buttons - local childbuttons = { button:GetChildren() }; - for _, child in ipairs(childbuttons) do - if child then - local bname = _G[child:GetName()] - if bname then - local childbuttonText = _G[child:GetName() .. TITAN_PANEL_TEXT]; - if childbuttonText then - childbuttonText:SetFont(newfont, fontsize); - end - end - end - end end end TitanPanel_RefreshPanelButtons(); @@ -252,6 +239,12 @@ print("PEW" if Titan__InitializedPEW then -- Currently no additional steps needed else + if Titan_Global.debug.titan_startup then + local dbg_msg = "PEW:" + .. " Init settings" + TitanDebug(dbg_msg, "normal") + end + -- Get Profile and Saved Vars TitanVariables_InitTitanSettings(); if TitanAllGetVar("Silenced") then @@ -269,13 +262,29 @@ print("PEW" -- Set the two anchors in their default positions -- until the Titan bars are drawn + if Titan_Global.debug.titan_startup then + local dbg_msg = "PEW:" + .. " Create anchors for other addons" + TitanDebug(dbg_msg, "normal") + end TitanPanelTopAnchor:ClearAllPoints(); TitanPanelTopAnchor:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", 0, 0); TitanPanelBottomAnchor:ClearAllPoints(); TitanPanelBottomAnchor:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", 0, 0); -- Ensure the bars are created before the plugins are registered. + if Titan_Global.debug.titan_startup then + local dbg_msg = "PEW:" + .. " Create frames for Titan bars" + TitanDebug(dbg_msg, "normal") + end for idx, v in pairs(TitanBarData) do + if Titan_Global.debug.titan_startup then + local dbg_msg = "..." + .. tostring(v.name) + TitanDebug(dbg_msg, "normal") + end + TitanPanelButton_CreateBar(idx) end -- Titan_AutoHide_Create_Frames() @@ -315,19 +324,40 @@ print("PEW" end --]] -- Should be safe to register for events that could show / hide Bars + if Titan_Global.debug.titan_startup then + local dbg_msg = "PEW:" + .. " Register for events Titan needs" + TitanDebug(dbg_msg, "normal") + end RegisterForEvents() end local _ = nil TitanSettings.Player, _, _ = TitanUtils_GetPlayer() + -- Some addons wait to create their LDB component or a Titan addon could -- create additional buttons as needed. -- So we need to sync their variables and set them up + if Titan_Global.debug.titan_startup then + local dbg_msg = "PEW:" + .. " Register any plugins found" + TitanDebug(dbg_msg, "normal") + end TitanUtils_RegisterPluginList() + if Titan_Global.debug.titan_startup then + local dbg_msg = "PEW:" + .. " Synch plugin saved vars" + TitanDebug(dbg_msg, "normal") + end TitanVariables_UseSettings(nil, TITAN_PROFILE_INIT) -- all addons are loaded so update the config (options) -- some could have registered late... + if Titan_Global.debug.titan_startup then + local dbg_msg = "PEW:" + .. " Init config data (right click menu)" + TitanDebug(dbg_msg, "normal") + end TitanUpdateConfig("init") -- Init panel font @@ -356,6 +386,11 @@ print("PEW" end -- Also sync LDB object text with their created Titan plugin + if Titan_Global.debug.titan_startup then + local dbg_msg = "PEW:" + .. " Register any LDB (Titan) plugins" + TitanDebug(dbg_msg, "normal") + end TitanLDBRefreshButton() end @@ -383,7 +418,11 @@ end function TitanPanelBarButton:ADDON_LOADED(addon) if addon == TITAN_ID then _G[TITAN_PANEL_CONTROL]:RegisterEvent("PLAYER_ENTERING_WORLD") - TitanVariables_InitTitanSettings() -- Min table setup to start. + + if Titan_Global.debug.titan_startup then + TitanDebug("Titan ADDON_LOADED") + end + -- TitanVariables_InitTitanSettings() -- Min table setup to start. -- Unregister event - saves a few event calls. self:UnregisterEvent("ADDON_LOADED"); self.ADDON_LOADED = nil @@ -401,6 +440,9 @@ print("PLAYER_ENTERING_WORLD" .." "..tostring(arg2).."" ) --]] + if Titan_Global.debug.titan_startup then + TitanDebug("Titan PLAYER_ENTERING_WORLD pcall setup routine") + end call_success, -- needed for pcall ret_val = -- actual return values pcall(TitanPanel_PlayerEnteringWorld, arg2) @@ -1254,7 +1296,7 @@ local function CheckBarBounds(self, width) end ---local Start the grap of a Short Titan bar if Shift and left mouse are held. ----@param self table +---@param self table local function OnMoveStart(self) if IsShiftKeyDown() then if self:IsMovable() then @@ -1268,7 +1310,7 @@ local function OnMoveStart(self) end ---local When a Short Titan bar drag is stopped. ----@param self table +---@param self table local function OnMovingStop(self) self:StopMovingOrSizing() self.isMoving = nil @@ -1313,7 +1355,7 @@ print("wheel" end end ----Titan Force all plugins created from LDB addons, visible or not, to be on the right side of the Titan bar. +---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 = {} @@ -1345,7 +1387,7 @@ function TitanPanelBarButton_ForceLDBLaunchersRight() end end ----local Helper to create the 'anchor' frames used by other addons that need to adjust so Titan can be visible. +---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. @@ -1356,9 +1398,9 @@ local function TitanAnchors() anchor_bot = anchor_bot >= TITAN_WOW_SCREEN_BOT and anchor_bot or TITAN_WOW_SCREEN_BOT local top_point, top_rel_to, top_rel_point, top_x, top_y = TitanPanelTopAnchor:GetPoint(TitanPanelTopAnchor - :GetNumPoints()) + :GetNumPoints()) local bot_point, bot_rel_to, bot_rel_point, bot_x, bot_y = TitanPanelBottomAnchor:GetPoint(TitanPanelBottomAnchor - :GetNumPoints()) + :GetNumPoints()) top_y = floor(tonumber(top_y) + 0.5) bot_y = floor(tonumber(bot_y) + 0.5) --[[ @@ -1697,8 +1739,8 @@ function TitanPanel_ReOrder(index) end ---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" +--- 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) @@ -1748,8 +1790,8 @@ function TitanPanel_RefreshPanelButtons() end end ----Titan Justify the plugins on each Titan bar. ---- Used when : +---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() @@ -1782,7 +1824,7 @@ function TitanPanelButton_Justify() y_offset = TitanBarData[idx].plugin_y_offset x_offset = TitanBarData[idx].plugin_x_offset firstLeftButton = TitanUtils_GetButton(TitanPanelSettings.Buttons - [TitanUtils_GetFirstButtonOnBar(bar, TITAN_LEFT)]) + [TitanUtils_GetFirstButtonOnBar(bar, TITAN_LEFT)]) align = TitanBarDataVars[idx].align --TitanPanelGetVar(bar.."_Align") leftWidth = 0; rightWidth = 0; @@ -1851,7 +1893,7 @@ local function BuildMainMenu(frame) ----------------- -- Plugin Categories -- Both arrays are in TitanGlobal ----@diagnostic disable-next-line: param-type-mismatch + ---@diagnostic disable-next-line: param-type-mismatch for index, id in pairs(L["TITAN_PANEL_MENU_CATEGORIES"]) do info = {}; info.notCheckable = true @@ -2237,11 +2279,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 - info.text = info.text .. TitanUtils_GetGoldText(" (" .. which_bar .. ")") --- end + -- 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 if plugin.controlVariables then @@ -2344,7 +2386,7 @@ print("_prep R click" end end ----Titan Determine if the given plugin is on any Titan bar. +---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) @@ -2355,7 +2397,7 @@ function TitanPanel_IsPluginShown(id) end end ----Titan Determine if the given plugin is / would be on right or left of a Titan bar. +---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) @@ -2366,17 +2408,6 @@ function TitanPanel_GetPluginSide(id) end end ---[[ -print("OnMoveStart" -.." "..tostring(self:GetName()).."" -.." "..tostring(IsShiftKeyDown()).."" -.." "..tostring(IsAltKeyDown()).."" -.."\n" -.." x "..tostring(format("%0.1f", self:GetLeft())).."" -.." y "..tostring(format("%0.1f", self:GetTop())).."" -) ---]] - ---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) @@ -2396,7 +2427,6 @@ end -- Routines to handle creation of Titan bars -- - ---Titan Create a Titan bar that can show plugins. ---@param frame_str string Unique ID of the plugin function TitanPanelButton_CreateBar(frame_str) @@ -2411,25 +2441,7 @@ function TitanPanelButton_CreateBar(frame_str) a_bar:SetScript("OnLeave", function(self) TitanPanelBarButton_OnLeave(self) end) a_bar:SetFrameStrata("DIALOG") - -- local x, y, w = TitanVariables_GetBarPos(frame_str) - -- local tscale = TitanPanelGetVar("Scale") - --[[ -print("_Create bar" -.." "..tostring(bar_data.name).."" -.."\n " -.." "..tostring(bar_data.name).."" -.." "..tostring(bar_data.show.pt).."" -.." "..tostring(bar_data.show.rel_fr).."" -.." "..tostring(bar_data.show.rel_pt).."" -.."\n " -.." "..tostring(bar_data.name).."" -.." "..tostring(format("%0.1f", x)).."" -.." "..tostring(format("%0.1f", y)).."" -.." "..tostring(format("%0.1f", w)).."" -) ---]] if bar_data.user_move then - -- a_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, x, y) a_bar:SetMovable(true) a_bar:SetResizable(true) a_bar:EnableMouse(true) @@ -2437,11 +2449,8 @@ print("_Create bar" a_bar:SetScript("OnDragStart", OnMoveStart) a_bar:SetScript("OnDragStop", OnMovingStop) a_bar:SetScript("OnMouseWheel", OnMouseWheel) - -- a_bar:SetSize(w / tscale, TITAN_PANEL_BAR_HEIGHT) else -- Static full width bar - -- a_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, x, y) - -- a_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, x, y - TITAN_PANEL_BAR_HEIGHT) end -- ====== @@ -2457,32 +2466,16 @@ print("_Create bar" -- ====== -- Frame for right clicks - -- Use one bar to rule them all - -- Use the plugin naming scheme + -- Use the plugin naming scheme for one frame to rule them all -- 2024 Feb : Change to match plugin right click menu scheme so one routine can be used. local f = CreateFrame("Frame", this_bar .. TITAN_PANEL_CLICK_MENU_SUFFIX, UIParent, "UIDropDownMenuTemplate") - --[[ - local tool_tip = Titan_Panel.plugin.PRE.."Bar"..Titan_Panel.plugin.POST - if _G[tool_tip] then - -- already created - else - f = CreateFrame("Frame", tool_tip, UIParent, "UIDropDownMenuTemplate") - end ---]] + -- ====== -- Hider for auto hide feature local hide_bar_name = TITAN_PANEL_HIDE_PREFIX .. bar_data.name if bar_data.hider then - --[[ -print("_Create hide bar" -.." "..tostring(bar_data.name).."" -.." "..tostring(hide_bar_name).."" -) ---]] - local hide_bar = CreateFrame("Button", hide_bar_name, UIParent, "TitanPanelBarButtonHiderTemplate") hide_bar:SetFrameStrata("DIALOG") - -- hide_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, x, -y) -- Set script handlers for display hide_bar:RegisterForClicks("LeftButtonUp", "RightButtonUp"); @@ -2493,7 +2486,7 @@ print("_Create hide bar" hide_bar:SetFrameStrata("BACKGROUND") hide_bar:SetSize(screen.x, TITAN_PANEL_BAR_HEIGHT) else - -- Not allowed for this bar + -- Hider not allowed for this bar end end diff --git a/Titan/TitanAutoHide.lua b/Titan/TitanAutoHide.lua index a02241b..afe6341 100644 --- a/Titan/TitanAutoHide.lua +++ b/Titan/TitanAutoHide.lua @@ -25,105 +25,31 @@ OUT: None --]] local function Titan_AutoHide_SetIcon(self) local frame_auto_hide = self:GetName() - local bar = self.bar_name - local frame_str = TitanVariables_GetFrameName(bar) + local icon = _G[frame_auto_hide.."Icon"] + local short = self.registry.short_name + local bar = TitanVariables_GetFrameName(short) -- Get the icon of the icon template - local icon = _G[frame_auto_hide.."Icon"] - if TitanBarDataVars[frame_str].auto_hide then + if TitanBarDataVars[bar].auto_hide then icon:SetTexture("Interface\\AddOns\\Titan\\Artwork\\TitanPanelPushpinOut") else icon:SetTexture("Interface\\AddOns\\Titan\\Artwork\\TitanPanelPushpinIn") end end --- Event handlers ---[[ -NAME: Titan_AutoHide_OnLoad -DESC: Setup the plugin on the given bar. -VAR: self - The bar -OUT: None ---]] -function Titan_AutoHide_OnLoad(self) - local frame = self:GetName() - local bar = self.bar_name - - self.registry = { - id = "AutoHide_"..bar, - category = "Built-ins", - version = TITAN_VERSION, - menuText = "AutoHide_"..bar, - tooltipTitle = L["TITAN_PANEL_AUTOHIDE_TOOLTIP"], - tooltipTextFunction = "TitanPanelClockButton_GetTooltipText", - savedVariables = { - DisplayOnRightSide = 1, - ForceBar = bar, - } - }; -end - -function TitanPanelClockButton_GetTooltipText(self) +local function GetTooltipText(self) local returnstring = "" ---[[ - local bar = self.bar_name - local frame_str = TitanVariables_GetFrameName(bar) - - if TitanBarDataVars[frame_str].auto_hide then - returnstring = L["TITAN_PANEL_MENU_DISABLED"] + if self.registry.titan_bar then + if TitanBarDataVars[self.registry.titan_bar].auto_hide then + returnstring = L["TITAN_PANEL_MENU_ENABLED"] + else + returnstring = L["TITAN_PANEL_MENU_DISABLED"] + end else - returnstring = L["TITAN_PANEL_MENU_ENABLED"] + -- do nothing end ---]] - return returnstring -end ---[[ -NAME: Titan_AutoHide_OnShow -DESC: Show the plugin on the given bar. -VAR: self - The bar -OUT: None ---]] -function Titan_AutoHide_OnShow(self) - Titan_AutoHide_SetIcon(self) -end - ---[[ -NAME: Titan_AutoHide_OnClick -DESC: Handle button clicks on the given bar. -VAR: self - The bar -VAR: button - The mouse button clicked -OUT: None ---]] -function Titan_AutoHide_OnClick(self, button) - if (button == "LeftButton") then - Titan_AutoHide_ToggleAutoHide(self.bar_name); - end -end - --- Auto hide routines ---[[ -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 -VAR: action - "Enter" | "Leave" -OUT: None ---]] -function Titan_AutoHide_Timers(frame, action) - if not frame or not action then - return - end - local bar = TitanBarData[frame].name --(frame.bar_name or nil) - local hide = TitanBarDataVars[frame].auto_hide -- (bar and TitanPanelGetVar(bar.."_Hide") or nil) - - if bar and hide then - if (action == "Enter") then - AceTimer.CancelAllTimers(frame) - end - if (action == "Leave") then - -- pass the bar as an arg so we can get it back - AceTimer.ScheduleRepeatingTimer(frame, Handle_OnUpdateAutoHide, 0.5, frame) - end - end + return returnstring end --[[ @@ -168,12 +94,62 @@ function Titan_AutoHide_ToggleAutoHide(bar) local frame_str = TitanVariables_GetFrameName(bar) -- toggle the correct auto hide variable - TitanBarDataVars[frame_str].auto_hide = - not TitanBarDataVars[frame_str].auto_hide --TitanPanelToggleVar(bar.."_Hide") + TitanBarDataVars[frame_str].auto_hide = not TitanBarDataVars[frame_str].auto_hide -- Hide / show the requested Titan bar Titan_AutoHide_Init(frame_str) end +-- Event handlers +--[[ +NAME: Titan_AutoHide_OnLoad +DESC: Setup the plugin on the given bar. +VAR: self - The bar +OUT: None +--]] +local function Titan_AutoHide_OnLoad(self) + local frame = self:GetName() + local bar = self.short_name + + self.registry = { + id = "AutoHide_"..bar, + category = "Built-ins", + version = TITAN_VERSION, + menuText = "AutoHide_"..bar, + tooltipTitle = L["TITAN_PANEL_AUTOHIDE_TOOLTIP"], + tooltipTextFunction = GetTooltipText, + savedVariables = { + DisplayOnRightSide = 1, + ForceBar = bar, + }, + -- Based on ForceBar, pass the Titan bar to the tooltip routine + short_name = bar, + titan_bar = TitanVariables_GetFrameName(bar) + }; +end + +--[[ +NAME: Titan_AutoHide_OnShow +DESC: Show the plugin on the given bar. +VAR: self - The bar +OUT: None +--]] +local function Titan_AutoHide_OnShow(self) + Titan_AutoHide_SetIcon(self) +end + +--[[ +NAME: Titan_AutoHide_OnClick +DESC: Handle button clicks on the given bar. +VAR: self - The bar +VAR: button - The mouse button clicked +OUT: None +--]] +local function Titan_AutoHide_OnClick(self, button) + if (button == "LeftButton") then + Titan_AutoHide_ToggleAutoHide(self.bar_name); + end +end + --[[ NAME: Handle_OnUpdateAutoHide DESC: Hide the bar if the user has auto hide after the cursor leaves the display bar. @@ -201,6 +177,32 @@ function Handle_OnUpdateAutoHide(frame) end end +-- Auto hide routines +--[[ +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 +VAR: action - "Enter" | "Leave" +OUT: None +--]] +function Titan_AutoHide_Timers(frame, action) + if not frame or not action then + return + end + local bar = TitanBarData[frame].name --(frame.bar_name or nil) + local hide = TitanBarDataVars[frame].auto_hide -- (bar and TitanPanelGetVar(bar.."_Hide") or nil) + + if bar and hide then + if (action == "Enter") then + AceTimer.CancelAllTimers(frame) + end + if (action == "Leave") then + -- pass the bar as an arg so we can get it back + AceTimer.ScheduleRepeatingTimer(frame, Handle_OnUpdateAutoHide, 0.5, frame) + end + end +end + -- --========================== -- Routines to handle moving and sizing of short bars @@ -210,7 +212,7 @@ local function Create_Hide_Button(bar, f) local plugin = CreateFrame("Button", name, f, "TitanPanelIconTemplate") plugin:SetFrameStrata("FULLSCREEN") - plugin.bar_name = bar -- set the bar name for the .registry + plugin.short_name = bar -- set the short bar name for the .registry -- Using SetScript("OnLoad", does not work Titan_AutoHide_OnLoad(plugin); @@ -226,7 +228,7 @@ local function Create_Hide_Button(bar, f) end --local function Create_Frames() -function Titan_AutoHide_Create_Frames() +local function Titan_AutoHide_Create_Frames() --====== Titan Auto hide plugin buttons ============================== -- general container frame local f = CreateFrame("Frame", nil, UIParent) @@ -238,5 +240,4 @@ function Titan_AutoHide_Create_Frames() end - Titan_AutoHide_Create_Frames() -- do the work diff --git a/Titan/TitanConfig.lua b/Titan/TitanConfig.lua index 30894f0..97bb610 100644 --- a/Titan/TitanConfig.lua +++ b/Titan/TitanConfig.lua @@ -252,7 +252,7 @@ local titan_entry = { confversiondesc = { order = 1, type = "description", - name = "".. Titan_Global.config_notes, + name = "" .. Titan_Global.config_notes, cmdHidden = true }, } @@ -285,52 +285,52 @@ local titan_entry = { confversiondesc = { order = 1, type = "description", - name = "|cffffd700" .. L["TITAN_PANEL_ABOUT_VERSION"] .. ": " - .. _G["GREEN_FONT_COLOR_CODE"] .. TitanPanel_GetVersion(), + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ABOUT_VERSION"] .. ": ") + .. TitanUtils_GetGreenText(TitanPanel_GetVersion()), cmdHidden = true }, confauthordesc = { order = 2, type = "description", - name = "|cffffd700" .. L["TITAN_PANEL_ABOUT_AUTHOR"] .. ": " - .. "|cffff8c00" .. TitanPanel_GetAuthor(), + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ABOUT_AUTHOR"] .. ": ") + .. TitanUtils_GetGreenText(TitanPanel_GetAuthor()), cmdHidden = true }, confcreditsdesc = { order = 3, type = "description", - name = "|cffffd700" .. L["TITAN_PANEL_ABOUT_CREDITS"] .. ": " - .. _G["HIGHLIGHT_FONT_COLOR_CODE"] .. TitanPanel_GetCredits(), + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ABOUT_CREDITS"] .. ": ") + .. TitanUtils_GetGreenText(TitanPanel_GetCredits()), cmdHidden = true }, confcatdesc = { order = 4, type = "description", - name = "|cffffd700" .. L["TITAN_PANEL_ABOUT_CATEGORY"] .. ": " - .. _G["HIGHLIGHT_FONT_COLOR_CODE"] .. TitanPanel_GetCategory(), + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ABOUT_CATEGORY"] .. ": ") + .. TitanUtils_GetGreenText(TitanPanel_GetCategory()), cmdHidden = true }, confemaildesc = { order = 5, type = "description", - name = "|cffffd700" .. L["TITAN_PANEL_ABOUT_EMAIL"] .. ": " - .. _G["HIGHLIGHT_FONT_COLOR_CODE"] .. TitanPanel_GetEmail(), + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ABOUT_EMAIL"] .. ": ") + .. TitanUtils_GetGreenText(TitanPanel_GetEmail()), cmdHidden = true }, --[[ has not been updated in quite a while... confwebsitedesc = { order = 6, type = "description", - name = "|cffffd700"..L["TITAN_PANEL_ABOUT_WEB"]..": " - .._G["HIGHLIGHT_FONT_COLOR_CODE"]..TitanPanel_GetWebsite(), + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ABOUT_WEB"]..": ") + ..TitanUtils_GetGreenText(TitanPanel_GetWebsite()), cmdHidden = true }, --]] conflicensedesc = { order = 7, type = "description", - name = "|cffffd700" .. L["TITAN_PANEL_ABOUT_LICENSE"] .. ": " - .. _G["HIGHLIGHT_FONT_COLOR_CODE"] .. TitanPanel_GetLicense(), + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ABOUT_LICENSE"] .. ": ") + .. TitanUtils_GetGreenText(TitanPanel_GetLicense()), cmdHidden = true }, } @@ -366,7 +366,7 @@ local function ColorAdjShown(frame_str) if TitanAdjustSettings[frame_str].adjust then res = frame_str -- leave as is else - res = "|cff808080" .. frame_str .. _G["FONT_COLOR_CODE_CLOSE"] + res = TitanUtils_GetGrayText(frame_str) end return res @@ -418,10 +418,10 @@ local function TitanUpdateAdj(t, pos) order = position, width = "full", } - position = position + 1 -- Show toggle + position = position + 1 -- Show toggle args[f_name].args.show = { type = "toggle", - width = .75, --"fill", + width = .75, --"fill", name = USE or "Use", --L["TITAN_PANEL_MENU_DISPLAY_BAR"], order = position, get = function(info) @@ -517,7 +517,7 @@ local function ColorShown(bar) if TitanBarDataVars[frame_str].show then -- leave as is else - res = "|cff808080" .. res .. _G["FONT_COLOR_CODE_CLOSE"] + res = TitanUtils_GetGrayText(res) end return res @@ -568,10 +568,10 @@ local function TitanUpdateConfigBars(t, pos) order = position, width = "full", } - position = position + 1 -- Show toggle + position = position + 1 -- Show toggle args[v.name].args.show = { type = "toggle", - width = .75, --"fill", + width = .75, --"fill", name = L["TITAN_PANEL_MENU_DISPLAY_BAR"], order = position, get = function(info) @@ -585,10 +585,10 @@ local function TitanUpdateConfigBars(t, pos) TitanUpdateConfigBars(optionsBars.args, 1000) end, } - position = position + 1 -- Auto hide toggle + position = position + 1 -- Auto hide toggle args[v.name].args.autohide = { type = "toggle", - width = .75, --"fill", + width = .75, --"fill", name = L["TITAN_PANEL_MENU_AUTOHIDE"], order = position, disabled = (v.hider == nil), @@ -600,10 +600,10 @@ local function TitanUpdateConfigBars(t, pos) Titan_AutoHide_ToggleAutoHide(info[1]) -- short bar name end, } - position = position + 1 -- Center toggle + position = position + 1 -- Center toggle args[v.name].args.center = { type = "toggle", - width = .75, --"fill", + width = .75, --"fill", name = L["TITAN_PANEL_MENU_CENTER_TEXT"], order = position, get = function(info) @@ -622,10 +622,10 @@ local function TitanUpdateConfigBars(t, pos) TitanPanelButton_Justify(); end, } - position = position + 1 -- Combat hide toggle + position = position + 1 -- Combat hide toggle args[v.name].args.hideincombat = { type = "toggle", - width = .75, --"fill", + width = .75, --"fill", name = L["TITAN_PANEL_MENU_HIDE_IN_COMBAT"], order = position, get = function(info) @@ -675,8 +675,8 @@ local function TitanUpdateConfigBars(t, pos) } position = position + 1 -- select background args[v.name].args.settextousebar = { - name = "", --L["TITAN_PANEL_MENU_GLOBAL_SKIN"], - desc = "", --L["TITAN_PANEL_MENU_GLOBAL_SKIN_TIP"], + name = "", --L["TITAN_PANEL_MENU_GLOBAL_SKIN"], + desc = "", --L["TITAN_PANEL_MENU_GLOBAL_SKIN_TIP"], order = position, type = "select", width = "full", @@ -726,9 +726,9 @@ local function TitanUpdateConfigBars(t, pos) for _, val in pairs(TitanSkins) do if val.path ~= TitanBarDataVars[frame_str].skin.path then -- if val.path ~= TitanPanelGetVar("Texture"..v.name) then - Skinlist[val.path] = "|cff19ff19" .. val.name .. "|r" + Skinlist[val.path] = TitanUtils_GetHexText(val.name, Titan_Global.colors.green) else - Skinlist[val.path] = "|cffffff9a" .. val.name .. "|r" + Skinlist[val.path] = TitanUtils_GetHexText(val.name, Titan_Global.colors.yellow) end end table.sort(Skinlist, function(a, b) @@ -761,9 +761,9 @@ local function TitanUpdateConfigBars(t, pos) imageWidth = 256, order = position, type = "description", - width = .5, --"60", + width = .5, --"60", } - position = position + 1 -- transparency + position = position + 1 -- transparency args[v.name].args.trans = { type = "range", width = "full", @@ -900,9 +900,9 @@ local optionsGlobals = { local v; for _, v in pairs(TitanSkins) do if v.path ~= TitanBarDataVars["Global"].skin.path then --TitanPanelGetVar("TexturePath") then - Skinlist[v.path] = "|cff19ff19" .. v.name .. "|r" + Skinlist[v.path] = TitanUtils_GetHexText(v.name, Titan_Global.colors.green) else - Skinlist[v.path] = "|cffffff9a" .. v.name .. "|r" + Skinlist[v.path] = TitanUtils_GetHexText(v.name, Titan_Global.colors.yellow) end end table.sort(Skinlist, function(a, b) @@ -1092,7 +1092,7 @@ local function ColorVisible(id, name) if TitanPanel_IsPluginShown(id) then res = (name or "") else - res = "|cff808080" .. name .. _G["FONT_COLOR_CODE_CLOSE"] + res = TitanUtils_GetGrayText(name) end return res @@ -1302,7 +1302,7 @@ local function TitanUpdateConfigAddons() order = 54, type = "description", name = TitanUtils_GetGoldText(L["TITAN_PANEL_MENU_BAR_ALWAYS"] .. - " " .. TitanGetVar(plug_in.id, "ForceBar")), + " " .. TitanGetVar(plug_in.id, "ForceBar")), cmdHidden = true, } end @@ -1339,10 +1339,10 @@ local function TitanUpdateConfigAddons() plug_ldb = "" end local str = "" - ..plug_version - ..plug_category + .. plug_version + .. plug_category .. _G["GREEN_FONT_COLOR_CODE"] .. plug_ldb .. "|r" - .."\n" + .. "\n" .. plug_notes if plug_in.notes then args[plug_in.id].args.notes = { @@ -1560,7 +1560,7 @@ local function TitanUpdateChars() type = "description", width = "full", name = L["TITAN_PANEL_GLOBAL_PROFILE"] .. - ": " .. TitanUtils_GetGoldText(TitanAllGetVar("GlobalProfileName") or "?"), + ": " .. TitanUtils_GetGoldText(TitanAllGetVar("GlobalProfileName") or "?"), } args["sp_20"] = { type = "description", @@ -2144,15 +2144,15 @@ local function Show_Skins(t, position) 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, + .. 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 + for idx, v in pairs(TitanSkins) do position = position + 1 -- spacer t[skin .. position] = { type = "header", @@ -2164,7 +2164,7 @@ local function Show_Skins(t, position) position = position + 1 -- Name of skin (col 1) t[skin .. position] = { type = "description", - name = "|cff19ff19" .. v.name .. "|r", + name = TitanUtils_GetHexText(v.name, Titan_Global.colors.green), order = position, width = "30", } @@ -2362,16 +2362,16 @@ local optionsSkinsCustom = { and v.path ~= "Interface\\AddOns\\Titan\\Artwork\\" and v.titan ~= true then - Skinlist[v.path] = "|cff19ff19" .. v.name .. "|r" + Skinlist[v.path] = TitanUtils_GetHexText(v.name, Titan_Global.colors.green) end if v.path == TitanSkinToRemove then - Skinlist[v.path] = "|cffffff9a" .. v.name .. "|r" + Skinlist[v.path] = TitanUtils_GetHexText(v.name, Titan_Global.colors.yellow) end end if TitanSkinToRemove ~= "None" then - Skinlist["None"] = "|cff19ff19" .. L["TITAN_PANEL_NONE"] .. "|r" + Skinlist["None"] = TitanUtils_GetHexText(L["TITAN_PANEL_NONE"], Titan_Global.colors.green) else - Skinlist["None"] = "|cffffff9a" .. L["TITAN_PANEL_NONE"] .. "|r" + Skinlist["None"] = TitanUtils_GetHexText(L["TITAN_PANEL_NONE"], Titan_Global.colors.yellow) end table.sort(Skinlist, function(a, b) return string.lower(TitanSkins[a].name) @@ -2524,7 +2524,7 @@ 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 plugins registered. -- Any plugins that attempted to register (no child frames though) are shown. See the Titan Utils section for more details on plugin registration. +- Any plugins that attempted to register are shown. See the Titan Utils section for more details on plugin registration. - This option page is for display only. The user can take not action. :NOTE --]] @@ -2553,80 +2553,72 @@ local function TitanUpdateAddonAttempts() local ptype = TitanPluginToBeRegistered[idx].plugin_type local btype = TitanPanelButton_GetType(idx) local title = TitanPluginToBeRegistered[idx].name - local isChild = TitanPluginToBeRegistered[idx].isChild and true or false if reason ~= TITAN_REGISTERED then title = TitanUtils_GetRedText(title) issue = TitanUtils_GetRedText(issue) end - if isChild then - -- Do not show. A child is part of (within) another plugin - -- showing it here would be confusing to the 'normal' user. - -- A plugin in author would know to look at the - -- TitanPluginToBeRegistered array directly. - else - args[num] = { - type = "group", - name = title, - order = idx, - args = { - name = { - type = "description", - name = TitanUtils_GetGoldText("") .. name, - cmdHidden = true, - order = 1, - }, - reason = { - type = "description", - name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_STATUS"] .. ": ") .. reason, - cmdHidden = true, - order = 2, - }, - issue = { - type = "description", - name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_ISSUE"] .. ": \n") .. issue, - cmdHidden = true, - order = 3, - }, - notes = { - type = "description", - name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_NOTES"] .. ": \n") .. notes, - cmdHidden = true, - order = 4, - }, - sp_1 = { - type = "description", - name = "", - cmdHidden = true, - order = 5, - }, - category = { - type = "description", - name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_CATEGORY"] .. ": ") .. category, - cmdHidden = true, - order = 10, - }, - ptype = { - type = "description", - name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_TYPE"] .. ": ") .. ptype, --.." "..btype, - cmdHidden = true, - order = 11, - }, - button = { - type = "description", - name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_BUTTON"] .. ": ") .. button, - cmdHidden = true, - order = 12, - }, - num_val = { - type = "description", - name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_TABLE"] .. ": ") .. num, - cmdHidden = true, - order = 13, - }, - } + args[num] = { + type = "group", + name = title, + order = idx, + args = { + name = { + type = "description", + name = TitanUtils_GetGoldText("") .. name, + cmdHidden = true, + order = 1, + }, + reason = { + type = "description", + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_STATUS"] .. ": ") .. reason, + cmdHidden = true, + order = 2, + }, + issue = { + type = "description", + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_ISSUE"] .. ": \n") .. issue, + cmdHidden = true, + order = 3, + }, + notes = { + type = "description", + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_NOTES"] .. ": \n") .. notes, + cmdHidden = true, + order = 4, + }, + sp_1 = { + type = "description", + name = "", + cmdHidden = true, + order = 5, + }, + category = { + type = "description", + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_CATEGORY"] .. ": ") .. category, + cmdHidden = true, + order = 10, + }, + ptype = { + type = "description", + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_TYPE"] .. ": ") .. ptype, --.." "..btype, + cmdHidden = true, + order = 11, + }, + button = { + type = "description", + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_BUTTON"] .. ": ") .. button, + cmdHidden = true, + order = 12, + }, + num_val = { + type = "description", + name = TitanUtils_GetGoldText(L["TITAN_PANEL_ATTEMPTS_TABLE"] .. ": ") .. num, + cmdHidden = true, + order = 13, + }, } - end + } end end diff --git a/Titan/TitanGame.lua b/Titan/TitanGame.lua index a5b5103..d83a66e 100644 --- a/Titan/TitanGame.lua +++ b/Titan/TitanGame.lua @@ -1,6 +1,9 @@ --[===[ File -This file contains the 'game version' - Titan or TitanClassic. -Used to set up libs, locale, ... per the WoW version the user is playing. +NAME: TitanGame.lua +DESC: This file contains the 'game version' Titan or TitanClassic. Used to set up libs, locale, ... +Different folders are required because Titan used TitanClassic as a name (& folder) for the Classic WoW versions. +The saved variables for Classic WoW are in TitanClassic.lua - not Titan.lua. +:DESC --]===] TITAN_ID = "Titan" diff --git a/Titan/TitanGlobal.lua b/Titan/TitanGlobal.lua index 6c5595e..c91023d 100644 --- a/Titan/TitanGlobal.lua +++ b/Titan/TitanGlobal.lua @@ -150,6 +150,7 @@ Titan_Global.debug.plugin_text = false Titan_Global.debug.plugin_register = false Titan_Global.debug.plugin_register_deep = false Titan_Global.debug.movable = false +Titan_Global.debug.titan_startup = false -- For WoW localized strings / literals we are using Titan_Global.literals = { @@ -162,6 +163,20 @@ Titan_Global.literals = { muted = MUTED, } +Titan_Global.colors = { + alliance = "00adf0", -- PLAYER_FACTION_COLOR_ALLIANCE + blue = "0000ff", -- PURE_BLUE_COLOR + gold = "f2e699", -- GOLD_FONT_COLOR + gray = "808080", -- GRAY_FONT_COLOR + green = "19ff19", -- GREEN_FONT_COLOR + horde = "ff2934", -- PLAYER_FACTION_COLOR_HORDE + orange = "ff8c00", + red = "ff2020", -- RED_FONT_COLOR + white = "ffffff", -- HIGHLIGHT_FONT_COLOR + yellow_gold = "ffd200", -- NORMAL_FONT_COLOR + yellow = "ffff00", -- YELLOW_FONT_COLOR +} + -- type for plugin registry ---@class PluginRegistryType ---@field id string The unique name of the plugin @@ -170,7 +185,7 @@ Titan_Global.literals = { ---@field menuText? string Localized string for the menu (right click) ---@field menuTextFunction? string | function Plugin function to call on right click ---@field buttonTextFunction? string | function Function to call when updating button display ----@field tooltipTitle? string Localized string for the menu +---@field tooltipTitle? string Localized string for the menu ---@field tooltipTextFunction? string | function Function to call for a simple tooltip (OnEnter) ---@field tooltipCustomFunction? function Function to call for a complex tooltip (OnEnter) ---@field icon? string Path to the plugin icon diff --git a/Titan/TitanHistory.lua b/Titan/TitanHistory.lua index 54ce662..22041f7 100644 --- a/Titan/TitanHistory.lua +++ b/Titan/TitanHistory.lua @@ -15,10 +15,26 @@ Green - 'header' - Titan or plugin Highlight - notes. tips. and details --]] Titan_Global.recent_changes = "" -.. TitanUtils_GetGoldText("8.0.13 : 2024/05/xx\n") +.. TitanUtils_GetGoldText("8.0.14 : 2024/07/xx\n") .. TitanUtils_GetGreenText("Titan : \n") .. TitanUtils_GetHighlightText("" -.. "- Update Retail version to 10.2.7.\n") +.. "- AutoHide : Fix tooltip error; shows Enabled / Disabled.\n" +.. "- Deprecated Titan Child template plugin code removed.\n" +.. "- Cleanup Titan tool tip code.\n" +.. "- Refactor Titan code to move color codes to Titan globals.\n" +.. "- Add debug to Titan startup code.\n" +) +.. TitanUtils_GetGreenText("Clock, Location, Performance, Repair, Volume, XP : \n") +.. TitanUtils_GetHighlightText("" +.. "- Refactor code for IDE, mostly comments; some code.\n" +.. "- Refactor code for Titan color code changes.\n" +) +.. "\n\n" +.. TitanUtils_GetGoldText("8.0.13 : 2024/06/18\n") +.. TitanUtils_GetGreenText("Titan : \n") +.. TitanUtils_GetHighlightText("" +.. "- Update Retail version to 10.2.7.\n" +.. "- Unknown LDB will not print error to Chat. Remains in Config > Attempted.\n") .. TitanUtils_GetGreenText("Repair : \n") .. TitanUtils_GetHighlightText("" .. "- Change to not error in Beta (The War Within).\n") @@ -74,12 +90,6 @@ Titan_Global.recent_changes = "" "- 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" --[[ Var Notes Use for important notes in the Titan Config About diff --git a/Titan/TitanLDB.lua b/Titan/TitanLDB.lua index 76159f6..c65cc0f 100644 --- a/Titan/TitanLDB.lua +++ b/Titan/TitanLDB.lua @@ -897,7 +897,6 @@ function LDBToTitan:TitanLDBCreateObject(sender, name, obj) { self = nil, button = nil, - isChild = nil, name = tostring(name), issue = ret_val, notes = "", @@ -944,7 +943,6 @@ LDBToTitan:SetScript("OnEvent", function(self, event, ...) { self = nil, button = nil, - isChild = nil, name = tostring(name), issue = ret_val, notes = "", diff --git a/Titan/TitanTemplate.lua b/Titan/TitanTemplate.lua index bedf8bd..ed825e9 100644 --- a/Titan/TitanTemplate.lua +++ b/Titan/TitanTemplate.lua @@ -24,7 +24,6 @@ The available plugin types are: - 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!!! * Templates inherit TitanPanelButtonTemplate for common elements. @@ -51,10 +50,7 @@ TitanPanelButtonTemplate contains: If these events are overridden then the default routine needs to be included! -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. - +NOTE: TitanPanelChildButtonTemplate - Removed 2024 Jun --]===] -- Globals @@ -213,14 +209,14 @@ local function TitanTooltip_SetPanelTooltip(self, id, frame) end end ----local Set the tooltip of the given Titan plugin. ----@param self table Tooltip frame ----@param id string Plugin id name +---local Set the tooltip (GameTooltip) of the given Titan plugin. +---@param self table Plugin frame --- Set Titan_Global.debug.tool_tips to output debug of this routine -local function TitanPanelButton_SetTooltip(self, id) +local function TitanPanelButton_SetTooltip(self) local dbg_msg = "TT:" local ok = false local frame = GameTooltip + local id = self.registry.id -- ensure that the 'self' passed is a valid frame reference if self:GetName() then @@ -265,6 +261,11 @@ local function TitanPanelButton_SetTooltip(self, id) if ok and (id and TitanUtils_IsPluginRegistered(id)) then local plugin = TitanUtils_GetPlugin(id) + -- 2024 Jun Add id and frame name to 'pass' to tooltip routine. + -- A compromise given that this mechanism is used by nearly all plugins. + -- Used by Titan auto hide to better determine which bar the 'pin' / icon is on. + self.plugin_id = id + self.plugin_frame = TitanUtils_ButtonName(id) if (plugin and plugin.tooltipCustomFunction) then -- Prep the tooltip frame TitanTooltip_SetPanelTooltip(self, id, frame); @@ -273,7 +274,7 @@ local function TitanPanelButton_SetTooltip(self, id) self.tooltipCustomFunction = plugin.tooltipCustomFunction; dbg_msg = dbg_msg .. " | custom" call_success, -- for pcall - tmp_txt = pcall(self.tooltipCustomFunction) + tmp_txt = pcall(self.tooltipCustomFunction, self) if call_success then -- all is good dbg_msg = dbg_msg .. " | ok" @@ -304,7 +305,7 @@ local function TitanPanelButton_SetTooltip(self, id) TitanTooltip_SetPanelTooltip(self, id, frame); self.tooltipTitle = plugin.tooltipTitle; call_success, -- for pcall - tmp_txt = pcall(tooltipTextFunc) + tmp_txt = pcall(tooltipTextFunc, self) -- Fill the tooltip self.tooltipText = tmp_txt @@ -379,9 +380,6 @@ local function TitanPanelButton_OnDragStart(self) if TitanPanelGetVar("LockButtons") or InCombatLockdown() then return end local frname = self; --- if ChildButton then --- frname = self:GetParent(); --- end -- Clear button positions or we'll grab the button and all buttons 'after' for i, j in pairs(TitanPanelSettings.Buttons) do @@ -423,10 +421,7 @@ local function TitanPanelButton_OnDragStart(self) -- 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 + -- 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 @@ -447,9 +442,7 @@ local function TitanPanelButton_OnDragStop(self) local nonmovableFrom = false; local nonmovableTo = false; local frname = self; --- if ChildButton then --- frname = self:GetParent(); --- end + if TITAN_PANEL_MOVING == 1 then frname:StopMovingOrSizing(); frname.isMoving = false; @@ -540,21 +533,19 @@ end ---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) +function TitanPanelButton_OnLoad(self) -- 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 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. +--- If the plugin needs an OnLoad process it should call this routine after its own. I.E. --- TitanPanelLootTypeButton_OnLoad(self) --- TitanPanelButton_OnLoad(self) --]] --- TitanUtils_PluginToRegister(self, isChildButton) - TitanUtils_PluginToRegister(self, false) + TitanUtils_PluginToRegister(self) end ---API Handle the OnShow event of the requested Titan plugin. @@ -574,17 +565,12 @@ end ---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) +function TitanPanelButton_OnClick(self, button) local id -- 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_GetButtonID(self:GetName()) end @@ -654,17 +640,12 @@ end ---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) +function TitanPanelButton_OnEnter(self) 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_GetButtonID(self:GetName()) end @@ -676,7 +657,7 @@ function TitanPanelButton_OnEnter(self, isChildButton) return; else if TITAN_PANEL_MOVING == 0 then - TitanPanelButton_SetTooltip(self, id); + TitanPanelButton_SetTooltip(self); end if self.isMoving then GameTooltip:Hide(); @@ -687,15 +668,11 @@ end ---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) +function TitanPanelButton_OnLeave(self) 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_GetButtonID(self:GetName()) end @@ -786,7 +763,7 @@ local function TitanPanelButton_SetButtonText(id) text = true else buttonText:SetText("") - dbg_msg = dbg_msg .. " | Err '"..tostring(label1).."'" + dbg_msg = dbg_msg .. " | Err '" .. tostring(label1) .. "'" end else dbg_msg = dbg_msg .. " | invalid plugin id" @@ -800,7 +777,7 @@ local function TitanPanelButton_SetButtonText(id) -- Plugin MUST have been shown at least once. -- In the case of first label only (no value), set the button and return. - if text and + if text and label1 and not (label2 or label3 or label4 or value1 or value2 or value3 or value4) then @@ -932,8 +909,8 @@ end --- 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 + -- 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 @@ -1015,7 +992,7 @@ function TitanPanelButton_UpdateTooltip(self) if (GameTooltip:IsOwned(self)) then local id = TitanUtils_GetButtonID(self:GetName()); - TitanPanelButton_SetTooltip(self, id); + TitanPanelButton_SetTooltip(self); end end @@ -1023,7 +1000,7 @@ end ---@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 : +--- Action : --- 1 = refresh button --- 2 = refresh tooltip --- 3 = refresh button and tooltip @@ -1056,21 +1033,17 @@ function TitanPanelPluginHandle_OnUpdate(table, oldarg) return end - TitanPanelButton_SetTooltip(_G[TitanUtils_ButtonName(id)], id) + TitanPanelButton_SetTooltip(_G[TitanUtils_ButtonName(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) +function TitanPanelDetectPluginMethod(id) -- 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... @@ -1079,21 +1052,13 @@ function TitanPanelDetectPluginMethod(id, isChildButton) if not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then --- if isChildButton then --- TitanPanelButton_OnDragStart(self, true); --- else - TitanPanelButton_OnDragStart(self); --- end + TitanPanelButton_OnDragStart(self); end end) -- Set the OnDragStop script TitanPluginframe:SetScript("OnDragStop", function(self) --- if isChildButton then --- TitanPanelButton_OnDragStop(self, true) --- else - TitanPanelButton_OnDragStop(self); --- end + TitanPanelButton_OnDragStop(self); end) end diff --git a/Titan/TitanTemplate.xml b/Titan/TitanTemplate.xml index 5ebeb7a..72133b9 100644 --- a/Titan/TitanTemplate.xml +++ b/Titan/TitanTemplate.xml @@ -19,22 +19,6 @@ -