From cb4c8a64076688d82344e792703d34d6cf8c0261 Mon Sep 17 00:00:00 2001 From: urnati Date: Sun, 21 Nov 2021 09:35:27 -0500 Subject: [PATCH] - Fix errors due to API backdrop changes in Seasons of Mastery; upgraded dropdown to 4.0 - Update allowed R side built-in plugins (except Vol and auto-hide) --- TitanClassic/LDBToTitanClassic.lua | 18 +- TitanClassic/TitanClassicUtils.lua | 251 ++++- TitanClassic/TitanPanelClassic.lua | 2 +- TitanClassic/TitanPanelClassicTemplate.lua | 87 +- TitanClassic/TitanPanelClassicTemplate.xml | 15 +- .../LibUIDropDownMenu/LibEasyMenu.lua | 37 +- .../LibUIDropDownMenu/LibUIDropDownMenu.lua | 1014 +++++++++++++------- .../LibUIDropDownMenu/LibUIDropDownMenu.xml | 7 +- .../LibUIDropDownMenuTemplates.lua | 71 +- .../LibUIDropDownMenuTemplates.xml | 45 +- TitanClassicAmmo/TitanClassicAmmo.lua | 32 +- TitanClassicBag/TitanClassicBag.lua | 4 +- TitanClassicClock/TitanClassicClock.lua | 47 +- TitanClassicClock/TitanClassicClock.xml | 10 +- TitanClassicLocation/TitanClassicLocation.lua | 4 +- TitanClassicLootType/TitanClassicLootType.xml | 8 +- .../TitanClassicPerformance.lua | 5 +- .../TitanClassicPerformance.xml | 6 +- TitanClassicVolume/TitanClassicVolume.lua | 3 +- TitanClassicVolume/TitanClassicVolume.xml | 6 +- TitanClassicXP/TitanClassicXP.lua | 14 +- 21 files changed, 1175 insertions(+), 511 deletions(-) diff --git a/TitanClassic/LDBToTitanClassic.lua b/TitanClassic/LDBToTitanClassic.lua index 2219327..d7a3134 100644 --- a/TitanClassic/LDBToTitanClassic.lua +++ b/TitanClassic/LDBToTitanClassic.lua @@ -115,30 +115,14 @@ VAR: frame --]] function LDBToTitan:TitanLDBSetOwnerPosition(parent, anchorPoint, relativeToFrame, relativePoint, xOffset, yOffset, frame) if frame:GetName() == "GameTooltip" then - -- Changes for 9.1.5. The background template was removed from the GameTooltip - local tip_name = frame:GetName() - - local tip_back_name = tip_name.."Backdrop" - local tip_back_frame = _G[tip_back_name] or CreateFrame("Frame", tip_back_name, frame, BackdropTemplateMixin and "BackdropTemplate" or nil) - tip_back_frame:SetFrameLevel(frame:GetFrameLevel() - 1) -- By creating this after the parent, need to set it behind the parent - - tip_back_frame:SetAllPoints() - tip_back_frame:SetBackdrop(back_drop_info) - -- set alpha (transparency) for the Game Tooltip - local tool_trans = TitanPanelGetVar("TooltipTrans") - tip_back_frame:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b, tool_trans) - tip_back_frame:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b, tool_trans) - frame.MenuBackdrop = tip_back_frame - frame:SetOwner(parent, "ANCHOR_NONE"); ---[[ -- set alpha (transparency) for the Game Tooltip local red, green, blue = GameTooltip:GetBackdropColor(); local red2, green2, blue2 = GameTooltip:GetBackdropBorderColor(); frame:SetBackdropColor(red,green,blue,TitanPanelGetVar("TooltipTrans")); frame:SetBackdropBorderColor(red2,green2,blue2, TitanPanelGetVar("TooltipTrans")); ---]] + -- set font size for the Game Tooltip if not TitanPanelGetVar("DisableTooltipFont") then if TitanTooltipScaleSet < 1 then diff --git a/TitanClassic/TitanClassicUtils.lua b/TitanClassic/TitanClassicUtils.lua index 06ff9c6..f34582a 100644 --- a/TitanClassic/TitanClassicUtils.lua +++ b/TitanClassic/TitanClassicUtils.lua @@ -16,6 +16,183 @@ TITAN_NOT_REGISTERED = _G["RED_FONT_COLOR_CODE"].."Not_Registered_Yet".._G["FONT 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"] +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 +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 +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) + DDMUIDropDownMenu_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 + +--============= + -- -- The routines labeled API are useable by addon developers -- @@ -811,29 +988,6 @@ function TitanPanelRightClickMenu_AddToggleColoredText(id, level) 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 ---]] -function TitanPanelRightClickMenu_AddToggleRightSide(id, level) - -- 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.func = function() - local bar = TitanUtils_GetWhichBar(id) - TitanPanelRightClickMenu_ToggleVar({id, "DisplayOnRightSide"}) - TitanPanel_RemoveButton(id); - TitanUtils_AddButtonOnBar(bar, id) - end - info.checked = TitanGetVar(id, "DisplayOnRightSide"); - info.keepShownOnClick = 1; - L_UIDropDownMenu_AddButton(info, level); -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 @@ -909,6 +1063,57 @@ function TitanPanelRightClickMenu_ToggleColoredText(value) TitanPanelButton_UpdateButton(value, 1); 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 +--]] +function TitanPanelRightClickMenu_AddToggleRightSide(id, level) + -- 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.func = function() + local bar = TitanUtils_GetWhichBar(id) + TitanPanelRightClickMenu_ToggleVar({id, "DisplayOnRightSide"}) + TitanPanel_RemoveButton(id); + TitanUtils_AddButtonOnBar(bar, id) + end + info.checked = TitanGetVar(id, "DisplayOnRightSide"); + info.keepShownOnClick = 1; + L_UIDropDownMenu_AddButton(info, level); +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 +--]] +function TitanPanelRightClickMenu_SetCustomBackdrop(frame) + frame:SetBackdrop({ + 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 }, + tileSize = 8, + edgeSize = 8, + }) + + frame:SetBackdropBorderColor( + TOOLTIP_DEFAULT_COLOR.r, + TOOLTIP_DEFAULT_COLOR.g, + TOOLTIP_DEFAULT_COLOR.b); + frame:SetBackdropColor( + TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, + TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, + TOOLTIP_DEFAULT_BACKGROUND_COLOR.b + , 1); +end + -------------------------------------------------------------- -- -- Plugin manipulation routines diff --git a/TitanClassic/TitanPanelClassic.lua b/TitanClassic/TitanPanelClassic.lua index 67b8ff4..43999a7 100644 --- a/TitanClassic/TitanPanelClassic.lua +++ b/TitanClassic/TitanPanelClassic.lua @@ -326,7 +326,7 @@ NOTE: --]] function TitanPanel_PlayerEnteringWorld() if Titan__InitializedPEW then - -- Also sync the LDB object with the Tian plugin + -- Also sync the LDB object with the Titan plugin TitanLDBRefreshButton() else -- Get Profile and Saved Vars diff --git a/TitanClassic/TitanPanelClassicTemplate.lua b/TitanClassic/TitanPanelClassicTemplate.lua index b8e5f56..528ab24 100644 --- a/TitanClassic/TitanPanelClassicTemplate.lua +++ b/TitanClassic/TitanPanelClassicTemplate.lua @@ -91,21 +91,6 @@ local function TitanTooltip_AddTooltipText(text) end end -local back_drop_info = - { - bgFile="Interface\\Tooltips\\UI-Tooltip-Background", - edgeFile="Interface\\Tooltips\\UI-Tooltip-Border", - tile = true, - insets = { - left = 6, - right = 6, - top = 3, - bottom = 3, - }, - tileSize = 8, - edgeSize = 8, - } - --[[ local NAME: TitanTooltip_SetOwnerPosition DESC: Set both the parent and the position of GameTooltip for the plugin tooltip. @@ -122,32 +107,15 @@ local function TitanTooltip_SetOwnerPosition(parent, anchorPoint, relativeToFram if not frame then frame = _G["GameTooltip"] end - -- Changes for 9.1.5. The background template was removed from the GameTooltip - local tip_name = frame:GetName() - - local tip_back_name = tip_name.."Backdrop" - local tip_back_frame = _G[tip_back_name] or CreateFrame("Frame", tip_back_name, frame, BackdropTemplateMixin and "BackdropTemplate" or nil) - tip_back_frame:SetFrameLevel(frame:GetFrameLevel() - 1) -- By creating this after the parent, need to set it behind the parent - - tip_back_frame:SetAllPoints() - tip_back_frame:SetBackdrop(back_drop_info) - -- set alpha (transparency) for the Game Tooltip - local tool_trans = TitanPanelGetVar("TooltipTrans") - tip_back_frame:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b, tool_trans) - tip_back_frame:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b, tool_trans) - frame.MenuBackdrop = tip_back_frame - frame:SetOwner(parent, "ANCHOR_NONE"); frame:SetPoint(anchorPoint, relativeToFrame, relativePoint, xOffset, yOffset); ---[[ -- set alpha (transparency) for the Game Tooltip local red, green, blue = frame:GetBackdropColor(); local red2, green2, blue2 = frame:GetBackdropBorderColor(); local tool_trans = TitanPanelGetVar("TooltipTrans") frame:SetBackdropColor(red,green,blue,tool_trans); frame:SetBackdropBorderColor(red2,green2,blue2,tool_trans); ---]] -- set font size for the Game Tooltip if not TitanPanelGetVar("DisableTooltipFont") then if TitanTooltipScaleSet < 1 then @@ -495,6 +463,41 @@ local function TitanPanelButton_OnDragStop(self, ChildButton) 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 function TitanTooltip_SetOwnerPosition(parent, anchorPoint, relativeToFrame, relativePoint, xOffset, yOffset, frame) + if not frame then + frame = _G["GameTooltip"] + end + frame:SetOwner(parent, "ANCHOR_NONE"); + frame:SetPoint(anchorPoint, relativeToFrame, relativePoint, + xOffset, yOffset); + -- set alpha (transparency) for the Game Tooltip + local red, green, blue = frame:GetBackdropColor(); + local red2, green2, blue2 = frame:GetBackdropBorderColor(); + local tool_trans = TitanPanelGetVar("TooltipTrans") + frame:SetBackdropColor(red,green,blue,tool_trans); + frame:SetBackdropBorderColor(red2,green2,blue2,tool_trans); + -- set font size for the Game Tooltip + if not TitanPanelGetVar("DisableTooltipFont") then + if TitanTooltipScaleSet < 1 then + TitanTooltipOrigScale = frame:GetScale(); + TitanTooltipScaleSet = TitanTooltipScaleSet + 1; + end + frame:SetScale(TitanPanelGetVar("TooltipFont")); + end +end + --[[ API NAME: TitanOptionSlider_TooltipText DESC: Set the color of the tooltip text to normal (white) with the value in green. @@ -1048,3 +1051,23 @@ function TitanPanelButton_GetType(id) return type; end +--[[ Titan +NAME: TitanOptionsSliderTemplate_OnLoad +DESC: Loads the Backdrop for TitanOptionsSliderTemplate with new 9.0 API +VAR: self - The frame +--]] +function TitanOptionsSliderTemplate_OnLoad(self) + self:SetBackdrop({ + bgFile="Interface\\Buttons\\UI-SliderBar-Background", + edgeFile="Interface\\Buttons\\UI-SliderBar-Border", + tile = true, + insets = { + left = 6, + right = 6, + top = 3, + bottom = 3, + }, + tileSize = 8, + edgeSize = 8, + }) +end diff --git a/TitanClassic/TitanPanelClassicTemplate.xml b/TitanClassic/TitanPanelClassicTemplate.xml index d063544..9fb1d55 100644 --- a/TitanClassic/TitanPanelClassicTemplate.xml +++ b/TitanClassic/TitanPanelClassicTemplate.xml @@ -2,6 +2,9 @@ ..\FrameXML\UI.xsd">