From 6bfcc14309b3e554800f110e80d812cd11b64892 Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Sun, 6 Aug 2023 16:20:47 -0300 Subject: [PATCH] Fixes for the latest alpha version --- Libs/DF/definitions.lua | 13 ++++--- Libs/DF/frames.lua | 61 +++++++++++++++++++++++++++++- Libs/DF/fw.lua | 4 +- Libs/DF/panel.lua | 48 +++++++++++++++-------- Libs/LibLuaServer/LibLuaServer.lua | 2 + boot.lua | 42 ++++++++++++++++++++ classes/class_damage.lua | 6 ++- classes/class_utility.lua | 7 +++- 8 files changed, 154 insertions(+), 29 deletions(-) diff --git a/Libs/DF/definitions.lua b/Libs/DF/definitions.lua index caa43a01..60332429 100644 --- a/Libs/DF/definitions.lua +++ b/Libs/DF/definitions.lua @@ -5,10 +5,11 @@ ---@field GetDefaultBackdropColor fun(self:table) : red, green, blue, alpha return a standard backdrop color ---@field Msg fun(self:table, message:string, ...) show a message in the chat frame ---@field MsgWarning fun(self:table, message:string, ...) show a warning message in the chat frame ----@field CreateCloseButton fun(self:table, parent:frame, frameName:string|nil) : df_closebutton ----@field CreateTabButton fun(self:table, parent:frame, frameName:string|nil) : df_tabbutton ----@field CreateRoundedPanel fun(self:table, parent:frame, frameName:string|nil, optionsTable:df_roundedpanel_options|nil) : df_roundedpanel +---@field CreateCloseButton fun(self:table, parent:frame, frameName:string?) : df_closebutton +---@field CreateTabButton fun(self:table, parent:frame, frameName:string?) : df_tabbutton +---@field CreateRoundedPanel fun(self:table, parent:frame, frameName:string?, optionsTable:df_roundedpanel_options?) : df_roundedpanel ---@field CreateScaleBar fun(self:table, parent:frame, config:table) : df_scalebar ----@field AddRoundedCornersToFrame fun(self:table, frame:frame, optionsTable:df_roundedpanel_preset|nil) ----@field ParseColors fun(self:table, red:any, green:number|nil, blue:number|nil, alpha:number|nil) : red, green, blue, alpha ----@field Mixin fun(self:table, target:table, ...) : table \ No newline at end of file +---@field AddRoundedCornersToFrame fun(self:table, frame:frame, optionsTable:df_roundedpanel_preset?) +---@field ParseColors fun(self:table, red:any, green:number?, blue:number?, alpha:number?) : red, green, blue, alpha +---@field Mixin fun(self:table, target:table, ...) : table +---@field SetButtonTexture fun(self:table, button:button|df_button, texture:atlasname|texturepath|textureid) \ No newline at end of file diff --git a/Libs/DF/frames.lua b/Libs/DF/frames.lua index a4072d8c..fc3d128d 100644 --- a/Libs/DF/frames.lua +++ b/Libs/DF/frames.lua @@ -64,6 +64,7 @@ local cornerNames = {"TopLeft", "TopRight", "BottomLeft", "BottomRight"} ---@field CreateBorder fun(self:df_roundedpanel) --called from SetBorderCornerColor if the border is not created yet ---@field CalculateBorderEdgeSize fun(self:df_roundedpanel, alignment: "vertical"|"horizontal"): number --calculate the size of the border edge texture ---@field SetTitleBarColor fun(self:df_roundedpanel, red: any, green: number|nil, blue: number|nil, alpha: number|nil) +---@field GetMaxFrameLevel fun(self:df_roundedpanel) : number --return the max frame level of the frame and its children ---@class df_roundedpanel : frame, df_roundedcornermixin, df_optionsmixin, df_titlebar ---@field bHasBorder boolean @@ -75,6 +76,7 @@ local cornerNames = {"TopLeft", "TopRight", "BottomLeft", "BottomRight"} ---@field BorderCornerTextures cornertextures ---@field BorderEdgeTextures edgetextures ---@field TitleBar df_roundedpanel +---@field bIsTitleBar boolean ---@field TopLeft texture corner texture ---@field TopRight texture corner texture ---@field BottomLeft texture corner texture @@ -211,6 +213,54 @@ detailsFramework.RoundedCornerPanelMixin = { setCornerPoints(self, self.CornerTextures) end, + ---get the highest frame level of the rounded panel and its children + ---@param self df_roundedpanel + ---@return framelevel + GetMaxFrameLevel = function(self) + ---@type framelevel + local maxFrameLevel = 0 + local children = {self:GetChildren()} + + for i = 1, #children do + local thisChild = children[i] + ---@cast thisChild frame + if (thisChild:GetFrameLevel() > maxFrameLevel) then + maxFrameLevel = thisChild:GetFrameLevel() + end + end + + return maxFrameLevel + end, + + ---create a frame placed at the top side of the rounded panel, this frame has a member called 'Text' which is a fontstring for the title + ---@param self df_roundedpanel + ---@return df_roundedpanel + CreateTitleBar = function(self) + ---@type df_roundedpanel + local titleBar = detailsFramework:CreateRoundedPanel(self, "$parentTitleBar", {width = self.options.width - 6, height = 16}) + titleBar:SetPoint("top", self, "top", 0, -4) + titleBar:SetRoundness(5) + titleBar:SetFrameLevel(9500) + titleBar.bIsTitleBar = true + self.TitleBar = titleBar + self.bHasTitleBar = true + + local textFontString = titleBar:CreateFontString("$parentText", "overlay", "GameFontNormal") + textFontString:SetPoint("center", titleBar, "center", 0, 0) + titleBar.Text = textFontString + + local closeButton = detailsFramework:CreateCloseButton(titleBar, "$parentCloseButton") + closeButton:SetPoint("right", titleBar, "right", -3, 0) + closeButton:SetSize(10, 10) + closeButton:SetAlpha(0.3) + closeButton:SetScript("OnClick", function(self) + self:GetParent():GetParent():Hide() + end) + detailsFramework:SetButtonTexture(closeButton, "common-search-clearbutton") + + return titleBar + end, + ---return the width and height of the corner textures ---@param self df_roundedpanel ---@return number, number @@ -518,11 +568,15 @@ local applyPreset = function(frame, preset) else frame:SetRoundness(1) end + + if (preset.use_titlebar) then + frame:CreateTitleBar() + end end ---set a frame to have rounded corners following the settings passed by the preset table ---@param frame frame ----@param preset df_roundedpanel_preset|nil +---@param preset df_roundedpanel_preset? function detailsFramework:AddRoundedCornersToFrame(frame, preset) frame = frame and frame.widget or frame assert(frame and frame.GetObjectType and frame.SetPoint, "AddRoundedCornersToFrame(frame): frame must be a frame object.") @@ -566,7 +620,10 @@ function detailsFramework:AddRoundedCornersToFrame(frame, preset) end ---test case: -C_Timer.After(1, function() if true then return end +C_Timer.After(1, function() + + if true then return end + local DF = DetailsFramework local parent = UIParent diff --git a/Libs/DF/fw.lua b/Libs/DF/fw.lua index 5f9c86fc..e4d0385a 100644 --- a/Libs/DF/fw.lua +++ b/Libs/DF/fw.lua @@ -1,6 +1,6 @@ -local dversion = 453 +local dversion = 454 local major, minor = "DetailsFramework-1.0", dversion local DF, oldminor = LibStub:NewLibrary(major, minor) @@ -585,7 +585,7 @@ function DF.table.removeduplicate(table1, table2) for key, value in pairs(table2) do if (type(value) == "table") then if (table1[key]) then - DF.SavedVars.removeduplicate(value, table1[key]) + DF.table.removeduplicate(value, table1[key]) end else if (type(table1[key]) == "number" and type(value) == "number") then diff --git a/Libs/DF/panel.lua b/Libs/DF/panel.lua index df476c8e..e377a5ab 100644 --- a/Libs/DF/panel.lua +++ b/Libs/DF/panel.lua @@ -627,6 +627,7 @@ function detailsFramework:NewPanel(parent, container, name, member, w, h, backdr PanelObject.frame:SetBackdrop({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", edgeSize = 10, tileSize = 64, tile = true}) PanelObject.widget = PanelObject.frame + PanelObject.frame.MyObject = PanelObject if (not APIFrameFunctions) then APIFrameFunctions = {} @@ -644,8 +645,6 @@ function detailsFramework:NewPanel(parent, container, name, member, w, h, backdr PanelObject.frame:SetWidth(w or 100) PanelObject.frame:SetHeight(h or 100) - PanelObject.frame.MyObject = PanelObject - PanelObject.HookList = { OnEnter = {}, OnLeave = {}, @@ -1980,6 +1979,7 @@ local no_options = {} ---UseStatusBar = false, --if true, creates a status bar at the bottom of the frame (frame.StatusBar) ---NoCloseButton = false, --if true, won't show the close button ---NoTitleBar = false, --if true, don't create the title bar +---RoundedCorners = false, --use rounded corners if true ---@class simplepanel ---@field TitleBar frame ---@field Title fontstring @@ -2024,9 +2024,19 @@ function detailsFramework:CreateSimplePanel(parent, width, height, title, frameN simplePanel:SetMovable(true) --set the backdrop - simplePanel:SetBackdrop(SimplePanel_frame_backdrop) - simplePanel:SetBackdropColor(unpack(SimplePanel_frame_backdrop_color)) - simplePanel:SetBackdropBorderColor(unpack(SimplePanel_frame_backdrop_border_color)) + if (panelOptions.RoundedCorners) then + local tRoundedCornerPreset = { + roundness = 6, + color = {.1, .1, .1, 0.98}, + border_color = {.05, .05, .05, 0.834}, + use_titlebar = true, + } + detailsFramework:AddRoundedCornersToFrame(simplePanel, tRoundedCornerPreset) + else + simplePanel:SetBackdrop(SimplePanel_frame_backdrop) + simplePanel:SetBackdropColor(unpack(SimplePanel_frame_backdrop_color)) + simplePanel:SetBackdropBorderColor(unpack(SimplePanel_frame_backdrop_border_color)) + end simplePanel.DontRightClickClose = panelOptions.DontRightClickClose @@ -2034,19 +2044,27 @@ function detailsFramework:CreateSimplePanel(parent, width, height, title, frameN tinsert(UISpecialFrames, frameName) end - if (panelOptions.UseStatusBar) then + if (panelOptions.UseStatusBar and not panelOptions.RoundedCorners) then local statusBar = detailsFramework:CreateStatusBar(simplePanel) simplePanel.StatusBar = statusBar end - local titleBar = CreateFrame("frame", frameName .. "TitleBar", simplePanel,"BackdropTemplate") - titleBar:SetPoint("topleft", simplePanel, "topleft", 2, -3) - titleBar:SetPoint("topright", simplePanel, "topright", -2, -3) - titleBar:SetHeight(20) - titleBar:SetBackdrop(SimplePanel_frame_backdrop) - titleBar:SetBackdropColor(.2, .2, .2, 1) - titleBar:SetBackdropBorderColor(0, 0, 0, 1) - simplePanel.TitleBar = titleBar + local titleBar = CreateFrame("frame", frameName .. "TitleBar", simplePanel, "BackdropTemplate") + + if (panelOptions.RoundedCorners) then + simplePanel.TitleBar:SetColor(.2, .2, .2, 0.4) + simplePanel.TitleBar:SetBorderCornerColor(0, 0, 0, 0) + + else + simplePanel.TitleBar = titleBar + titleBar:SetPoint("topleft", simplePanel, "topleft", 2, -3) + titleBar:SetPoint("topright", simplePanel, "topright", -2, -3) + titleBar:SetHeight(20) + titleBar:SetBackdrop(SimplePanel_frame_backdrop) + titleBar:SetBackdropColor(.2, .2, .2, 1) + titleBar:SetBackdropBorderColor(0, 0, 0, 1) + simplePanel.TitleBar = titleBar + end local close = CreateFrame("button", frameName and frameName .. "CloseButton", titleBar) close:SetFrameLevel(detailsFramework.FRAMELEVEL_OVERLAY) @@ -2077,7 +2095,7 @@ function detailsFramework:CreateSimplePanel(parent, width, height, title, frameN simplePanel.Title:SetPoint("center", titleBar, "center") simplePanel.Close:SetPoint("right", titleBar, "right", -2, 0) - if (panelOptions.NoCloseButton) then + if (panelOptions.NoCloseButton or panelOptions.RoundedCorners) then simplePanel.Close:Hide() end diff --git a/Libs/LibLuaServer/LibLuaServer.lua b/Libs/LibLuaServer/LibLuaServer.lua index 198d10dd..f87bb337 100644 --- a/Libs/LibLuaServer/LibLuaServer.lua +++ b/Libs/LibLuaServer/LibLuaServer.lua @@ -183,6 +183,7 @@ ---@alias width number property that represents the horizontal size of a UI element, such as a frame or a texture. Gotten from the first result of GetWidth() or from the first result of GetSize(). It is expected a GetWidth() or GetSize() when the type 'height' is used. ---@alias height number property that represents the vertical size of a UI element, such as a frame or a texture. Gotten from the first result of GetHeight() or from the second result of GetSize(). It is expected a GetHeight() or GetSize() when the type 'height' is used. +---@alias framelevel number represent how high a frame is placed within its strata. The higher the frame level, the more likely it is to appear in front of other frames. The frame level is a number between 0 and 65535. The default frame level is 0. The frame level is set with the SetFrameLevel() function. ---@alias red number color value representing the red component of a color, the value must be between 0 and 1. To retrieve a color from a string or table use: local red, green, blue, alpha = DetailsFramework:ParseColors(color) ---@alias green number color value representing the green component of a color, the value must be between 0 and 1. To retrieve a color from a string or table use: local red, green, blue, alpha = DetailsFramework:ParseColors(color) ---@alias blue number color value representing the blue component of a color, the value must be between 0 and 1. To retrieve a color from a string or table use: local red, green, blue, alpha = DetailsFramework:ParseColors(color) @@ -211,6 +212,7 @@ ---@alias npcid number a number that identifies a specific npc in the game. ---@alias textureid number each texture from the game client has an id. ---@alias texturepath string access textures from addons. +---@alias atlasname string a name of an atlas, an atlas name is used with the SetAtlas() function to display a texture from the game client. ---@alias valueamount number used to represent a value, such as a damage amount, a healing amount, or a resource amount. ---@alias unixtime number a number that represents the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970, not counting leap seconds. ---@alias timestring string refers to a string showing a time value, such as "1:23" or "1:23:45". diff --git a/boot.lua b/boot.lua index 0d50c156..78818b25 100644 --- a/boot.lua +++ b/boot.lua @@ -1026,6 +1026,48 @@ do return Details:Dump(spellInfo) end end + + --check if is an atlas texture + local atlas + if (type(value) == "string") then + atlas = C_Texture.GetAtlasInfo(value) + if (atlas) then + return Details:Dump(atlas) + end + end + + --[=[ + for key, tooltip in pairs(_G) do + if (type(tooltip) == "table" and tooltip.GetName) then + if (tooltip.IsShown and tooltip.HookScript and not tooltip.widget and not tooltip.MyObject) then + if (tooltip.GetObjectType and not getmetatable(tooltip)) then + print(tooltip:GetObjectType()) + if (tooltip:GetObjectType() == "GameTooltip") then + if (tooltip:IsShown()) then + print(tooltip:GetName()) + end + end + end + end + end + end + --]=] + + if (value == nil) then + local allTooltips = {"GameTooltip", "EventTraceTooltip", "FrameStackTooltip", "GarrisonMissionMechanicTooltip", "GarrisonMissionMechanicFollowerCounterTooltip", "ItemSocketingDescription", "NamePlateTooltip", "PrivateAurasTooltip", "RuneforgeFrameResultTooltip", "ItemRefTooltip", "QuickKeybindTooltip", "SettingsTooltip"} + for i = 1, #allTooltips do + local tooltipName = allTooltips[i] + local tooltip = _G[tooltipName] + + if (tooltip and tooltip.GetTooltipData) then + local tooltipData = tooltip:GetTooltipData() + if (tooltipData)then + return Details:Dump(tooltipData) + end + end + end + end + return Details:Dump(value) end diff --git a/classes/class_damage.lua b/classes/class_damage.lua index fce33ea7..46a3d9d9 100644 --- a/classes/class_damage.lua +++ b/classes/class_damage.lua @@ -2991,8 +2991,8 @@ end ---@param totalAmount valueamount ---@param topAmount valueamount ---@param instanceObject instance ----@param onEnterFunc function|nil ----@param onLeaveFunc function|nil +---@param onEnterFunc function? +---@param onLeaveFunc function? function Details:ShowExtraStatusbar(thisLine, amount, extraAmount, totalAmount, topAmount, instanceObject, onEnterFunc, onLeaveFunc) if (extraAmount and extraAmount > 0 and Details.combat_log.evoker_calc_damage) then local extraStatusbar = thisLine.extraStatusbar @@ -6705,6 +6705,8 @@ end if (actorObject.augmentedSpellsContainer) then local overallAugmentedSpellsContainer = overallActor.augmentedSpellsContainer or spellContainerClass:CreateSpellContainer(Details.container_type.CONTAINER_DAMAGE_CLASS) + overallActor.augmentedSpellsContainer = overallAugmentedSpellsContainer + for spellId, spellTable in pairs(actorObject.augmentedSpellsContainer._ActorTable) do --same as actorObject.augmentedSpellsContainer:GetRawSpellTable() local overallSpellTable = overallAugmentedSpellsContainer:GetOrCreateSpell(spellId, true) overallSpellTable.total = overallSpellTable.total + spellTable.total diff --git a/classes/class_utility.lua b/classes/class_utility.lua index d88448b2..f1d5510b 100644 --- a/classes/class_utility.lua +++ b/classes/class_utility.lua @@ -2366,8 +2366,8 @@ local refresh_alvos = function(container1, container2) end local refresh_habilidades = function(container1, container2) for spellid, habilidade in pairs(container2._ActorTable) do - local habilidade_shadow = container1:PegaHabilidade (spellid, true, nil, true) - refresh_alvos (habilidade_shadow.targets , habilidade.targets) + local habilidade_shadow = container1:PegaHabilidade(spellid, true, nil, true) + refresh_alvos(habilidade_shadow.targets , habilidade.targets) end end @@ -2414,6 +2414,9 @@ function atributo_misc:r_onlyrefresh_shadow (actor) refresh_habilidades (shadow.buff_uptime_spells, actor.buff_uptime_spells) if (actor.received_buffs_spells) then + if (not shadow.received_buffs_spells) then + shadow.received_buffs_spells = container_habilidades:NovoContainer(_detalhes.container_type.CONTAINER_MISC_CLASS) + end refresh_habilidades(shadow.received_buffs_spells, actor.received_buffs_spells) end end