diff --git a/WorldQuestTracker.toc b/WorldQuestTracker.toc index b6fc57b0..600c3569 100644 --- a/WorldQuestTracker.toc +++ b/WorldQuestTracker.toc @@ -1,5 +1,5 @@ -## Interface: 110000 -## Interface-Mainline: 110000 +## Interface: 110002 +## Interface-Mainline: 110002 ## Interface-Wrath: 30402 ## Title: World Quest Tracker diff --git a/WorldQuestTracker_Core.lua b/WorldQuestTracker_Core.lua index 974600a2..324d5e2a 100644 --- a/WorldQuestTracker_Core.lua +++ b/WorldQuestTracker_Core.lua @@ -1340,7 +1340,7 @@ WorldQuestTracker.OnToggleWorldMap = function(self) elseif (option == "untrack_quests") then WorldQuestTracker.RemoveAllQuestsFromTracker() - if (TomTom and IsAddOnLoaded("TomTom")) then + if (TomTom and C_AddOns.IsAddOnLoaded("TomTom")) then for questID, t in pairs(WorldQuestTracker.TomTomUIDs) do TomTom:RemoveWaypoint(t) end @@ -4022,7 +4022,7 @@ WorldQuestTracker.OnToggleWorldMap = function(self) --]=] -- - if (TomTom and IsAddOnLoaded("TomTom")) then + if (TomTom and C_AddOns.IsAddOnLoaded("TomTom")) then GameCooltip:AddLine("$div") GameCooltip:AddLine("TomTom") diff --git a/WorldQuestTracker_IDs.lua b/WorldQuestTracker_IDs.lua index 705aec9e..2d361073 100644 --- a/WorldQuestTracker_IDs.lua +++ b/WorldQuestTracker_IDs.lua @@ -194,6 +194,15 @@ WorldQuestTracker.MapData.ExpMaps = { [zoneIDs.BROKENISLES] = 7, } +WorldQuestTracker.MapData.HubMapIconsScale = { + [zoneIDs.DRAGONISLES] = 1, + [zoneIDs.THESHADOWLANDS] = 1, + [zoneIDs.ZANDALAR] = 1, + [zoneIDs.KULTIRAS] = 1, + [zoneIDs.AZEROTH] = 1, + [zoneIDs.BROKENISLES] = 0.8, +} + --list of map ids for world quest hubs WorldQuestTracker.MapData.QuestHubs = { [zoneIDs.DRAGONISLES] = true, --dragon isles hub diff --git a/WorldQuestTracker_Tracker.lua b/WorldQuestTracker_Tracker.lua index 7dc2d71d..54b1cf8a 100644 --- a/WorldQuestTracker_Tracker.lua +++ b/WorldQuestTracker_Tracker.lua @@ -112,7 +112,7 @@ function WorldQuestTracker.AddQuestToTracker(self, questID, mapID) return end - if (WorldQuestTracker.db.profile.tomtom.enabled and TomTom and IsAddOnLoaded ("TomTom")) then + if (WorldQuestTracker.db.profile.tomtom.enabled and TomTom and C_AddOns.IsAddOnLoaded("TomTom")) then WorldQuestTracker.AddQuestTomTom (self.questID, self.mapID or mapID) --return true end diff --git a/WorldQuestTracker_WorldMap.lua b/WorldQuestTracker_WorldMap.lua index 09c600bf..fb985e9a 100644 --- a/WorldQuestTracker_WorldMap.lua +++ b/WorldQuestTracker_WorldMap.lua @@ -1441,7 +1441,7 @@ local mapRangeValues = { [WorldQuestTracker.MapData.ZoneIDs.AZEROTH] = {0.18, .38, 5.2, 3.3}, [WorldQuestTracker.MapData.ZoneIDs.ZANDALAR] = {0.18, .38, 5.2, 3.3}, [WorldQuestTracker.MapData.ZoneIDs.KULTIRAS] = {0.18, .38, 5.2, 3.3}, - [WorldQuestTracker.MapData.ZoneIDs.BROKENISLES] = {0.18/3.0, .38/3.0, 5.2/3.0, 3.3/3.0}, + [WorldQuestTracker.MapData.ZoneIDs.BROKENISLES] = {0.18/3.0, .38/3.0, 5.2/3.0, 3.3/3.0}, --0.06, 0.126, 1.733, 1.1 [WorldQuestTracker.MapData.ZoneIDs.ARGUS] = {0.18/2.5, .38/2.5, 5.2/2.5, 3.3/2.5}, ["default"] = {0.18, .38, 5.2, 3.3}, } @@ -1557,6 +1557,10 @@ local scheduledIconUpdate = function(questTable) end local pinScale = DF:MapRangeClamped(rangeValues[1], rangeValues[2], rangeValues[3], rangeValues[4], mapScale) + + local finalScaleScalar = WorldQuestTracker.MapData.HubMapIconsScale[WorldMapFrame.mapID] or 1 + pinScale = pinScale * finalScaleScalar + if (WorldMapFrame.mapID == WorldQuestTracker.MapData.ZoneIDs.THESHADOWLANDS) then pinScale = pinScale - 1 local conduitType = WorldQuestTracker.GetConduitQuestData(questID) diff --git a/WorldQuestTracker_ZoneMap.lua b/WorldQuestTracker_ZoneMap.lua index 28f0b4f5..37bc3380 100644 --- a/WorldQuestTracker_ZoneMap.lua +++ b/WorldQuestTracker_ZoneMap.lua @@ -1569,19 +1569,26 @@ ZoneSumaryFrame.Header.BlackBackground:SetSize(150, ZoneSumaryFrame.Header.Backg ZoneSumaryFrame.Header.BlackBackground:SetPoint("topleft", ZoneSumaryFrame.Header.Background, "topleft", 8, -14) ZoneSumaryFrame.Header.BlackBackground:SetPoint("bottomright", ZoneSumaryFrame.Header.Background, "bottomright", 0, 0) -local GetOrCreateZoneSummaryWidget = function(index) +function WorldQuestTracker.GetOrCreateZoneSummaryWidget(index, parent, pool) + if (not pool) then + pool = WorldQuestTracker.ZoneSumaryWidgets + end - local widget = WorldQuestTracker.ZoneSumaryWidgets [index] + local widget = pool[index] if (widget) then return widget end - local button = CreateFrame("button", "WorldQuestTrackerZoneSummaryFrame_Widget" .. index, ZoneSumaryFrame, "BackdropTemplate") + parent = parent or ZoneSumaryFrame + + local button = CreateFrame("button", "WorldQuestTrackerZoneSummaryFrame_Widget" .. index, parent, "BackdropTemplate") button:SetAlpha(WorldQuestTracker.db.profile.world_summary_alpha) + pool[index] = button + --button:SetPoint("bottomleft", ZoneSumaryFrame, "bottomleft", 0,((index-1)*(ZoneSumaryFrame.WidgetHeight + 1)) -2) --grow bottom to top - button:SetPoint("topleft", ZoneSumaryFrame, "topleft", 0,(((index-1) *(ZoneSumaryFrame.WidgetHeight + 1)) -2) * -1) --grow top to bottom - button:SetSize(ZoneSumaryFrame.WidgetWidth, ZoneSumaryFrame.WidgetHeight) + button:SetPoint("topleft", parent, "topleft", 0,(((index-1) *(parent.WidgetHeight + 1)) -2) * -1) --grow top to bottom + button:SetSize(parent.WidgetWidth, parent.WidgetHeight) button:SetFrameLevel(WorldQuestTracker.DefaultFrameLevel + 1) --create a square icon @@ -1590,7 +1597,7 @@ local GetOrCreateZoneSummaryWidget = function(index) --squareIcon.isWorldMapWidget = false --required when updating borders squareIcon.IsZoneSummaryQuestButton = true squareIcon:SetPoint("left", button, "left", 2, 0) - squareIcon:SetSize(ZoneSumaryFrame.IconSize, ZoneSumaryFrame.IconSize) + squareIcon:SetSize(parent.IconSize, parent.IconSize) squareIcon:SetFrameLevel(WorldQuestTracker.DefaultFrameLevel + 2) squareIcon.IsZoneSummaryButton = true button.Icon = squareIcon @@ -1700,13 +1707,13 @@ local GetOrCreateZoneSummaryWidget = function(index) --mouseoverHighlight:Hide() end) - WorldQuestTracker.ZoneSumaryWidgets [index] = button - --disable mouse click button:SetMouseClickEnabled(false) return button end + + function WorldQuestTracker.ClearZoneSummaryButtons() for _, button in ipairs(WorldQuestTracker.ZoneSumaryWidgets) do button:Hide() @@ -1902,7 +1909,7 @@ function WorldQuestTracker.UpdateZoneSummaryFrame() if (not isSummaryMinimized) then for i = 1, #WorldQuestTracker.Cache_ShownWidgetsOnZoneMap do local zoneWidget = WorldQuestTracker.Cache_ShownWidgetsOnZoneMap [i] - local summaryWidget = GetOrCreateZoneSummaryWidget(index) + local summaryWidget = WorldQuestTracker.GetOrCreateZoneSummaryWidget(index) summaryWidget._Twin = zoneWidget WorldQuestTracker.SetupZoneSummaryButton(summaryWidget, zoneWidget) diff --git a/libs/DF/LibDFramework-1.0.toc b/libs/DF/LibDFramework-1.0.toc index c61998f8..48ecdae3 100644 --- a/libs/DF/LibDFramework-1.0.toc +++ b/libs/DF/LibDFramework-1.0.toc @@ -1,4 +1,4 @@ -## Interface: 110000 +## Interface: 110002 ## Title: Lib: LibDFramework-1.0 ## Notes: Base Framework for many Addons diff --git a/libs/DF/auras.lua b/libs/DF/auras.lua index 33942382..0745833f 100644 --- a/libs/DF/auras.lua +++ b/libs/DF/auras.lua @@ -12,7 +12,7 @@ local tinsert = table.insert local GetSpellInfo = GetSpellInfo or function(spellID) if not spellID then return nil end local si = C_Spell.GetSpellInfo(spellID) if si then return si.name, nil, si.iconID, si.castTime, si.minRange, si.maxRange, si.spellID, si.originalIconID end end local lower = string.lower local SpellBookItemTypeMap = Enum.SpellBookItemType and {[Enum.SpellBookItemType.Spell] = "SPELL", [Enum.SpellBookItemType.None] = "NONE", [Enum.SpellBookItemType.Flyout] = "FLYOUT", [Enum.SpellBookItemType.FutureSpell] = "FUTURESPELL", [Enum.SpellBookItemType.PetAction] = "PETACTION" } or {} -local GetSpellBookItemInfo = GetSpellBookItemInfo or function(...) local si = C_SpellBook.GetSpellBookItemInfo(...) if si then return SpellBookItemTypeMap[si.itemType] or "NONE", si.spellID end end +local GetSpellBookItemInfo = GetSpellBookItemInfo or function(...) local si = C_SpellBook.GetSpellBookItemInfo(...) if si then return SpellBookItemTypeMap[si.itemType] or "NONE", (si.itemType == Enum.SpellBookItemType.Flyout or si.itemType == Enum.SpellBookItemType.PetAction) and si.actionID or si.spellID or si.actionID, si end end local SPELLBOOK_BANK_PLAYER = Enum.SpellBookSpellBank and Enum.SpellBookSpellBank.Player or "player" local GetNumSpellTabs = GetNumSpellTabs or C_SpellBook.GetNumSpellBookSkillLines local GetSpellTabInfo = GetSpellTabInfo or function(tabLine) local skillLine = C_SpellBook.GetSpellBookSkillLineInfo(tabLine) if skillLine then return skillLine.name, skillLine.iconID, skillLine.itemIndexOffset, skillLine.numSpellBookItems, skillLine.isGuild, skillLine.offSpecID end end diff --git a/libs/DF/button.lua b/libs/DF/button.lua index bd56b5bc..47fcfa49 100644 --- a/libs/DF/button.lua +++ b/libs/DF/button.lua @@ -892,7 +892,7 @@ end ---@field IsEnabled fun(self: df_button) : boolean returns true if the button is enabled ---@field SetIcon fun(self: df_button,texture: string|number, width: number|nil, height: number|nil, layout: string|nil, texcoord: table|nil, overlay: table|nil, textDistance: number|nil, leftPadding: number|nil, textHeight: number|nil, shortMethod: any|nil) ---@field GetIconTexture fun(self: df_button) : string returns the texture path of the button icon - ---@field SetTexture fun(self: df_button, normalTexture: string, highlightTexture: string, pressedTexture: string, disabledTexture: string) set the regular button textures + ---@field SetTexture fun(self: df_button, normalTexture: any, highlightTexture: any, pressedTexture: any, disabledTexture: any) set the regular button textures ---@field SetFontFace fun(self: df_button, font: string) set the button font ---@field SetFontSize fun(self: df_button, size: number) set the button font size ---@field SetTextColor fun(self: df_button, color: any) set the button text color diff --git a/libs/DF/charts.examples.lua b/libs/DF/charts.examples.lua index 589dcf09..87bf1e3b 100644 --- a/libs/DF/charts.examples.lua +++ b/libs/DF/charts.examples.lua @@ -2,53 +2,58 @@ --documentation: see the header of the file charts.lua ---1º example: making a simple chart, just copy and paste this code into a lua file and run it +--1º example: making a simple chart with two lines, just copy and paste this code into a lua file and run it do - local ChartFrameTest = ChartFrameExample1 or DetailsFramework:CreateGraphicLineFrame(UIParent, "ChartFrameExample1") + local ChartFrameTest = ChartFrameExample1 or DetailsFramework:CreateGraphicMultiLineFrame(UIParent, "ChartFrameExample1") ChartFrameTest:SetPoint("left", UIParent, "left", 10, 0) --set the position of the chart ChartFrameTest:SetSize(800, 600) --set the size of the chart DetailsFramework:ApplyStandardBackdrop(ChartFrameTest) --apply a backdrop to this example hence see the frame size - --set the data (required) + --add a line: local data = {1, 2, 30, 25, 6, 5, 4, 8, 7, 4, 1, 12, 15, 24, 18, 17, 14, 15, 8, 4, 14, 42, 22, 25, 30, 35, 39, 8, 7, 4, 1, 2, 5, 4, 8, 7, 4, 12, 12, 4} - local smoothnessLevel = 1 --(optional, default: 1) - ChartFrameTest:SetData(data, smoothnessLevel) + local smoothingMethod = "sma" --(optional, default: "sma") + local smoothnessLevel = 3 --(optional, default: 1) + local name = "Line 1" --(optional, default: none) + local red, green, blue, alpha = 1, 1, 1, 1 --(optional, default: 1, 1, 1, 1) + + ChartFrameTest:AddData(data, smoothingMethod, smoothnessLevel, name, red, green, blue, alpha) + + --add another line: + data = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} + smoothingMethod = "loess" --using a different smoothing method + smoothnessLevel = 50 + name = "Line 2" + local color = "red" --using a string with the color name + ChartFrameTest:AddData(data, smoothingMethod, smoothnessLevel, name, color) + --draw the chart ChartFrameTest:Plot() end ---2º example: setting the color, thickness and scale of the line: +--2º example: thickness and scale of the line: do - local ChartFrameTest = ChartFrameExample2 or DetailsFramework:CreateGraphicLineFrame(UIParent, "ChartFrameExample2") + local ChartFrameTest = ChartFrameExample2 or DetailsFramework:CreateGraphicMultiLineFrame(UIParent, "ChartFrameExample2") ChartFrameTest:SetPoint("left", UIParent, "left", 10, 0) --set the position of the chart ChartFrameTest:SetSize(800, 600) --set the size of the chart DetailsFramework:ApplyStandardBackdrop(ChartFrameTest) --apply a backdrop to this example hence see the frame size + --add the data (required) + local data = {1, 2, 30, 25, 6, 5, 4, 8, 7, 4, 1, 12, 15, 24 ,18, 17 ,14, 15, 8 , 4, 14, 42, 22, 25, 30, 35, 39, 8, 7, 4, 1, 2, 5, 4 ,8, 7 ,4, 12, 12 , 4} + ChartFrameTest:AddData(data) + --set the line thickness (optional, default: 2) local lineThickness = 3 ChartFrameTest:SetLineThickness(lineThickness) - --set the chart color (optional, default: "white") - local lineColor = {r = 1, g = 1, b = 0} --set it to "yellow" - ChartFrameTest:SetColor(lineColor) --using {r = 1, g = 1, b = 0} - ChartFrameTest:SetColor("yellow") --using the color name - ChartFrameTest:SetColor(1, 1, 0) --passing the rgb directly - ChartFrameTest:SetColor({1, 1, 0}) --using an index table - - --set the data (required) - local data = {1, 2, 30, 25, 6, 5, 4, 8, 7, 4, 1, 12, 15, 24 ,18, 17 ,14, 15, 8 , 4, 14, 42, 22, 25, 30, 35, 39, 8, 7, 4, 1, 2, 5, 4 ,8, 7 ,4, 12, 12 , 4} - local smoothnessLevel = 1 --(optional, default: 1) - ChartFrameTest:SetData(data, smoothnessLevel) - --height modifier, if for some reason need to scale the chart height - local heightScale = 1 --(optional, default: 1) + local heightScale = 1.2 --(optional, default: 1) --draw the chart ChartFrameTest:Plot(heightScale) end --3º example: setting the axes lines and labels do - local ChartFrameTest = ChartFrameExample3 or DetailsFramework:CreateGraphicLineFrame(UIParent, "ChartFrameExample3") + local ChartFrameTest = ChartFrameExample3 or DetailsFramework:CreateGraphicMultiLineFrame(UIParent, "ChartFrameExample3") ChartFrameTest:SetPoint("left", UIParent, "left", 10, 0) ChartFrameTest:SetSize(800, 600) DetailsFramework:ApplyStandardBackdrop(ChartFrameTest) @@ -76,7 +81,7 @@ do --setting the data, doesn't matter if it is set at the top or right before Plot() local data = {1, 2, 30, 25, 6, 5, 4, 8, 7, 4, 1, 12, 15, 24 ,18, 17 ,14, 15, 8 , 4, 14, 42, 22, 25, 30, 35, 39, 8, 7, 4, 1, 2, 5, 4 ,8, 7 ,4, 12, 12 , 4} - ChartFrameTest:SetData(data) --smoothnessLevel is absent here, it'll use 1 as default + ChartFrameTest:AddData(data) ChartFrameTest:Plot() end diff --git a/libs/DF/charts.lua b/libs/DF/charts.lua index ba3bc517..8acfa1fa 100644 --- a/libs/DF/charts.lua +++ b/libs/DF/charts.lua @@ -33,7 +33,16 @@ local _ ---| "number" same as timer, but the number is not comverted to time ---| "value" a fixed table with values is passed by the SetXAxisData() function +---@class df_chartline : line +---@field thickness number + ---@class df_chartshared: table +---@field fillOrder table the order of the lines to be filled, this table is shared by all charts +---@field bFillChart boolean if the chart lines should be filled or not +---@field fillChartLineThickness number the thickness of the fill line +---@field bRunningInBackground boolean true if there is a proccess happening asynchronously +---@field waitForBackgroundProcessTicker timer a ticker to check if all background process finished +---@field amountOfBackgroundProcess number the amount of background processes happening ---@field yAxisLine line the vertical line which can be anchored in the left or right side of the frame, if the chart is a multi chart, this line is shared by all charts ---@field xAxisLine line the horizontal line which can be anchored in the top or bottom side of the frame, if the chart is a multi chart, this line is shared by all charts ---@field xAxisDataNumber any if the data type of the x axis is "number" or "time" @@ -49,12 +58,17 @@ local _ ---@field smoothnessLevel number default: 0, the smoothness level of the chart lines, 0 is no smoothness ---@field backdropIndicators chart_backdropindicator[] ---@field nextBackdropIndicator number tell which is the next backdrop indicator to be used +---@field SetFillChart fun(self: df_chartshared, bFill: boolean, lineThickness:number?) set if the chart lines should be filled or not +---@field GetFillState fun(self: df_chartshared) : boolean, number return if the chart lines should be filled or not +---@field ShrinkData fun(self: df_chartmulti|df_chart, data: table, skrinkBy: number, bJustDrop: boolean?) : table +---@field HasBackgroundProcess fun(self: df_chartmulti|df_chart) : boolean return true if there is a proccess happening asynchronously +---@field SetBackgroundProcessState fun(self: df_chartmulti|df_chart, bRunning: boolean) set if there is a proccess happening asynchronously ---@field CreateBackdropIndicator fun(self: df_chartmulti|df_chart, index: number) : chart_backdropindicator create a new backdrop indicator ---@field GetBackdropIndicator fun(self: df_chartmulti|df_chart) : chart_backdropindicator get a backdrop indicator by index ---@field ResetBackdropIndicators fun(self: df_chartmulti|df_chart) reset all backdrop indicators ---@field SetAxesColor fun(self: df_chartmulti, red: number|string|table|nil, green: number|nil, blue: number|nil, alpha: number|nil) : boolean set the color of both axis lines ---@field SetAxesThickness fun(self: df_chartmulti, thickness: number) : boolean set the thickness of both axis lines ----@field CreateAxesLines fun(self: df_chartmulti|df_chart, xOffset: number, yOffset: number, whichSide: "left"|"right", thickness: number, amountYLabels: number, amountXLabels: number, red: any, green: number|nil, blue: number|nil, alpha: number|nil) +---@field CreateAxesLines fun(self: df_chartmulti|df_chart, xOffset: number, yOffset: number, whichSide: "left"|"right", thickness: number, amountYLabels: number, amountXLabels: number, red: any, green: number|nil, blue: number|nil, alpha: number|nil) create the x and y axis lines with their labels, offsets are the distance from left and bottom ---@field SetXAxisDataType fun(self: df_chartmulti|df_chart, dataType: x_axisdatatype) : boolean set the data type of the x axis, if time, the x axis will be a time axis, if value, the x axis will be a value axis ---@field SetXAxisData fun(self: df_chartmulti|df_chart, data: any) set the data of the x axis, if time, the x axis will be a time axis, if value, the x axis will be a value axis ---@field SharedContrustor fun(self: df_chartmulti|df_chart) set default values for fields used on both chart types @@ -78,13 +92,15 @@ end ---@class df_chart: frame, df_data, df_value, df_chartshared ---@field _dataInfo df_data +---@field average number +---@field depth number ---@field color number[] red green blue alpha ---@field height number ---@field nextLine number ---@field minValue number ---@field maxValue number ---@field data number[] ----@field lines line[] +---@field lines df_chartline[] ---@field fixedLineWidth number ---@field chartName string ---@field dataPoint_OnEnterFunc fun(self: df_chart, onEnterFunc: function, ...) set the function to be called when the mouse hover over a data point in the chart @@ -93,8 +109,8 @@ end ---@field dataPoint_OnLeavePayload any[] set the payload to be passed to the function set by DataPoint_OnLeaveFunc ---@field GetOnEnterLeaveFunctions fun(self: df_chart) : function, any[], function, any[] return the functions and payloads set by DataPoint_OnEnterFunc and DataPoint_OnLeaveFunc ---@field ChartFrameConstructor fun(self: df_chart) set the default values for the chart frame ----@field GetLine fun(self: df_chart) : line return a line and also internally handle next line ----@field GetLines fun(self: df_chart) : line[] return a table with all lines already created +---@field GetLine fun(self: df_chart) : df_chartline return a line and also internally handle next line +---@field GetLines fun(self: df_chart) : df_chartline[] return a table with all lines already created ---@field GetLineWidth fun(self: df_chart) : number calculate the width of each drawn line ---@field SetLineWidth fun(self: df_chart, width: number) set the line width to a fixed value ---@field GetAmountLines fun(self: df_chart) : number return the amount of lines in use @@ -106,7 +122,7 @@ end ---@field SetLineThickness fun(self: df_chart, thickness: number) set the line thickness ---@field CalcYAxisPointForValue fun(self: df_chart, value: number, plotFrameHeightScaled: number) : number ---@field UpdateFrameSizeCache fun(self: df_chart) ----@field Plot fun(self: df_chart, yPointScale: number|nil, bUpdateLabels: boolean|nil) draw the graphic using lines and following the data set by SetData() or AddData() in multi chart +---@field Plot fun(self: df_chart, yPointScale: number|nil, bUpdateLabels: boolean|nil, lineId:number?) draw the graphic using lines and following the data set by SetData() or AddData() in multi chart ---@class df_chartmulti : df_chart, df_chartshared ---@field chartFrames df_chart[] @@ -117,7 +133,7 @@ end ---@field MultiChartFrameConstructor fun(self: df_chartmulti) ---@field GetCharts fun(self: df_chartmulti) : df_chart[] ---@field GetChart fun(self: df_chartmulti) : df_chart ----@field AddData fun(self: df_chartmulti, data: table, name: string, red: any, green: number|nil, blue: number|nil, alpha: number|nil) +---@field AddData fun(self: df_chartmulti, data: table, smoothingMethod: string|nil, smoothnessLevel:number, name: string, red: any, green: number|nil, blue: number|nil, alpha: number|nil) ---@field GetAmountCharts fun(self: df_chartmulti): number ---@field HideCharts fun(self: df_chartmulti) ---@field Reset fun(self: df_chartmulti) @@ -190,7 +206,6 @@ local createHorizontalAxisLabels = function(parent, amountLabels, labelsTable, r end end ----create the x and y axis lines with their labels ---@param self df_chart|df_chartmulti ---@param xOffset number ---@param yOffset number @@ -342,8 +357,84 @@ local updateLabelValues = function(self) end detailsFramework.ChartFrameSharedMixin = { - ---set the color of both axis lines + ---set if the chart lines should be filled or not, when filled, an extra line is drawn at the bottom of the chart to close the fill + ---@param self df_chartshared + ---@param bFill boolean + ---@param lineThickness number? + SetFillChart = function(self, bFill, lineThickness) + lineThickness = lineThickness or 1 + self.bFillChart = bFill + self.fillChartLineThickness = lineThickness + end, + + ---return if the chart lines should be filled or not + ---@param self df_chartshared + ---@return boolean + ---@return number + GetFillState = function(self) + return self.bFillChart, self.fillChartLineThickness + end, + + ---receives a table containing the data to be plotted in the chart, returns a new table with the data reduced by the skrinkBy value + ---if bJustDrop is true, the data will be reduced by dropping values, if false, the data will be reduced by averaging the values ---@param self df_chart|df_chartmulti + ---@param data table + ---@param skrinkBy number + ---@param bJustDrop boolean + ---@return table + ShrinkData = function(self, data, skrinkBy, bJustDrop) + local newData = {} + local dataSize = #data + + local tinsert = table.insert + + if (bJustDrop) then + if (true) then + --make a for loop to drop the values by random, for example, is shrink is 3 and index is 9, it will drop at random two values of: 9 10 or 11 + else + --it will shrink the data by dropping values each skrinkBy indexes + for i = 1, dataSize, skrinkBy do + tinsert(newData, data[i]) + end + end + else + --it will shrink the data by making an average of the values and add to newTable, shrinkBy controls how many values will be averaged + for i = 1, dataSize, skrinkBy do + local sum = 0 + for o = 0, skrinkBy - 1 do + sum = sum + (data[i + o] or 0) --attempt to perform arithmetic on field '?' (a nil value) + end + tinsert(newData, sum / skrinkBy) + end + end + + return newData + end, + + ---return if there is a proccess happening asynchronously + ---@param self df_chartmulti + ---@return boolean + HasBackgroundProcess = function(self) + return self.bRunningInBackground + end, + + ---set if there is a proccess happening asynchronously + ---@param self df_chartmulti + ---@param bRunning boolean + SetBackgroundProcessState = function(self, bRunning) + if (bRunning) then + self.amountOfBackgroundProcess = self.amountOfBackgroundProcess + 1 + self.bRunningInBackground = bRunning + else + self.amountOfBackgroundProcess = self.amountOfBackgroundProcess - 1 + if (self.amountOfBackgroundProcess == 0) then + self.bRunningInBackground = false + end + end + end, + + ---set the color of both axis lines + ---@param self df_chartmulti ---@param red any ---@param green number|nil ---@param blue number|nil @@ -372,7 +463,7 @@ detailsFramework.ChartFrameSharedMixin = { end, ---set the thickness of both axis lines - ---@param self df_chart|df_chartmulti + ---@param self df_chartmulti ---@param thickness number ---@return boolean bThicknessChanged return true if the thickness was set, false if the axis lines are not created yet SetAxesThickness = function(self, thickness) @@ -385,7 +476,7 @@ detailsFramework.ChartFrameSharedMixin = { end, ---create the x and y axis lines with their labels - ---@param self df_chart|df_chartmulti + ---@param self df_chartmulti ---@param xOffset number ---@param yOffset number ---@param whichSide "left"|"right" @@ -401,20 +492,20 @@ detailsFramework.ChartFrameSharedMixin = { return createAxesLines(self, xOffset, yOffset, whichSide, thickness, amountYLabels, amountXLabels, red, green, blue, alpha) end, - ---@param self df_chartmulti|df_chart + ---@param self df_chartmulti ---@param ... any SetXAxisData = function(self, ...) setXAxisData(self, ...) end, - ---@param self df_chartmulti|df_chart + ---@param self df_chartmulti ---@param dataType x_axisdatatype SetXAxisDataType = function(self, dataType) setXAxisDataType(self, dataType) end, ---create a new backdrop indicator, this is called from the function GetBackdropIndicator - ---@param self df_chartmulti|df_chart + ---@param self df_chartmulti ---@return chart_backdropindicator CreateBackdropIndicator = function(self, nextIndicatorIndex) ---@type chart_backdropindicator @@ -444,7 +535,7 @@ detailsFramework.ChartFrameSharedMixin = { end, ---reset the backdrop indicators by hidding all of them - ---@param self df_chartmulti|df_chart + ---@param self df_chartmulti ResetBackdropIndicators = function(self) for i = 1, #self.backdropIndicators do local thisBackdropIndicator = self.backdropIndicators[i] @@ -455,7 +546,7 @@ detailsFramework.ChartFrameSharedMixin = { end, ---get a backdrop indicator, if it doesn't exist, create a new one - ---@param self df_chartmulti|df_chart + ---@param self df_chartmulti ---@return chart_backdropindicator GetBackdropIndicator = function(self) local nextIndicator = self.nextBackdropIndicator @@ -469,7 +560,7 @@ detailsFramework.ChartFrameSharedMixin = { end, ---add a backdrop indicator to the chart - ---@param self df_chartmulti|df_chart + ---@param self df_chartmulti ---@param label string this is a text to be displayed on the left side of the indicator and on the top right corner of the chart panel ---@param timeStart number the start time of the indicator ---@param timeEnd number the end time of the indicator @@ -497,7 +588,7 @@ detailsFramework.ChartFrameSharedMixin = { ---when Plot() is called, this function will be called to show the backdrop indicators ---it gets the x_axisdatatype or if not existant defaults to "time", calculate the area in pixels using the plot area width and the plot area 'time' ---then set the texture color, label texts and show the small squere indicators in the top right of the plot area - ---@param self df_chartmulti|df_chart + ---@param self df_chartmulti ShowBackdropIndicators = function(self) --get the x axis data type local xDataType = self.xAxisDataType or "time" @@ -546,6 +637,119 @@ detailsFramework.ChartFrameSharedMixin = { end, } +local fillerLines_InAvailable = {} +local fillerLines_InUse = {} + +---@class df_chartlazypayload : table +---@field self df_chartmulti +---@field currentDataIndex number +---@field executionsPerFrame number +---@field dataSize number +---@field currentXPoint number +---@field currentYPoint number +---@field eachLineWidth number +---@field plotFrameHeightScaled number +---@field r number +---@field g number +---@field b number +---@field lineId number +---@field bUpdateLabels boolean +---@field bFillChart boolean +---@field fillLineThickness number + +--this is the function which is called by the schedules lazy execution system +local lazyChartUpdate = function(payload, iterationCount, maxIterations) + ---@cast payload df_chartlazypayload + + local self = payload.self + ---@cast self df_chart + + local currentDataIndex = payload.currentDataIndex + local dataSize = payload.dataSize + local currentXPoint = payload.currentXPoint + local currentYPoint = payload.currentYPoint + local eachLineWidth = payload.eachLineWidth + local plotFrameHeightScaled = payload.plotFrameHeightScaled + local r = payload.r + local g = payload.g + local b = payload.b + local lineId = payload.lineId + local bUpdateLabels = payload.bUpdateLabels + local bFillChart = payload.bFillChart + local fillLineThickness = payload.fillLineThickness + + local executionsPerFrame = payload.executionsPerFrame + currentDataIndex = currentDataIndex + executionsPerFrame + + for i = 1, payload.executionsPerFrame do + local value, dataIndex = self:GetDataNextValue() + if (not value) then + --the data stream has ended + return true + end + + local line = self:GetLine() + line:SetColorTexture(r, g, b) + + if (line.thickness ~= self.lineThickness) then + line:SetThickness(self.lineThickness) + line.thickness = self.lineThickness + end + + --get the start points + local startX = currentXPoint + local startY = currentYPoint + currentXPoint = currentXPoint + eachLineWidth + --end point + local endX = currentXPoint + currentYPoint = self:CalcYAxisPointForValue(value, plotFrameHeightScaled) + local endY = currentYPoint + + local length = detailsFramework:GetVectorLength(endX - startX, endY - startY) + --make sure the magnitude of the difference between previous point to current point is at least 1.5 + if (length < 1.5) then + local diffX = endX - startX + local diffY = endY - startY + + local diffLength = detailsFramework:GetVectorLength(diffX, diffY) + local scaleFactor = 1.5 / diffLength + + diffX = diffX * scaleFactor + diffY = diffY * scaleFactor + + endX = endX + diffX + endY = endY + diffY + end + + --the start point starts where the latest point finished + line:SetStartPoint("bottomleft", startX, startY) + line:SetEndPoint("bottomleft", endX, endY) + + if (bFillChart) then + if (lineId) then + local fillLine = table.remove(fillerLines_InAvailable) + if (not fillLine) then + fillLine = self.plotFrame:CreateLine(nil, "overlay") + fillLine:SetThickness(fillLineThickness) + fillerLines_InUse[#fillerLines_InUse+1] = fillLine + else + fillerLines_InUse[#fillerLines_InUse+1] = fillLine + end + + fillLine:SetStartPoint("bottomleft", endX, endY) + fillLine:SetEndPoint("bottomleft", endX, 0) + fillLine:SetDrawLayer("overlay", self.depth) + fillLine:SetColorTexture(r, g, b, 0.15 + (self.depth/10)) + + fillLine:Show() + end + end + end + + payload.currentXPoint = currentXPoint + payload.currentYPoint = currentYPoint +end + detailsFramework.ChartFrameMixin = { ---set the default values for the chart frame ---@param self df_chart @@ -557,6 +761,8 @@ detailsFramework.ChartFrameMixin = { self.data = {} self.lines = {} self.color = {1, 1, 1, 1} + self.amountOfBackgroundProcess = 0 + --OnSizeChanged self:SetScript("OnSizeChanged", self.OnSizeChanged) @@ -593,14 +799,17 @@ detailsFramework.ChartFrameMixin = { ---internally handle next line ---@param self df_chart + ---@return df_chartline GetLine = function(self) - ---@type line + ---@type df_chartline local line = self.lines[self.nextLine] if (not line) then ---@type line - line = self.plotFrame:CreateLine(nil, "overlay", nil, 5) - self.lines[self.nextLine] = line + local newLine = self.plotFrame:CreateLine(nil, "overlay", nil, 5) + ---@cast newLine df_chartline + self.lines[self.nextLine] = newLine + line = newLine end self.nextLine = self.nextLine + 1 @@ -610,7 +819,7 @@ detailsFramework.ChartFrameMixin = { ---return all lines created for this chart ---@param self df_chart - ---@return line[] + ---@return df_chartline[] GetLines = function(self) return self.lines end, @@ -717,14 +926,12 @@ detailsFramework.ChartFrameMixin = { ---@param self df_chart ---@param yPointScale number|nil ---@param bUpdateLabels boolean|nil - Plot = function(self, yPointScale, bUpdateLabels) - --debug - --self:SetData({38, 26, 12, 63, 100, 96, 42, 94, 25, 75, 61, 54, 71, 40, 34, 100, 66, 90, 39, 13, 99, 18, 72, 18, 83, 45, 56, 24, 33, 85, 95, 71, 15, 66, 19, 58, 52, 9, 83, 99, 100, 4, 3, 56, 6, 80, 94, 7, 40, 55, 98, 92, 20, 9, 35, 89, 72, 7, 13, 81, 29, 78, 55, 70, 12, 33, 39, 3, 84, 31, 10, 53, 51, 69, 66, 58, 71, 60, 31, 71, 27, 76, 21, 75, 15, 89, 2, 81, 72, 78, 74, 80, 97, 10, 59, 0, 31, 5, 1, 82, 71, 89, 78, 94, 74, 20, 65, 72, 56, 40, 92, 91, 40, 79, 4, 56, 18, 88, 88, 20, 20, 10, 47, 26, 80, 26, 75, 21, 57, 10, 67, 66, 84, 83, 14, 47, 83, 9, 7, 73, 63, 32, 64, 20, 40, 3, 46, 54, 17, 37, 82, 66, 65, 22, 12, 1, 100, 41, 1, 72, 38, 41, 71, 69, 88, 34, 10, 50, 9, 25, 19, 27, 3, 13, 40, 75, 3, 11, 93, 58, 81, 80, 93, 25, 74, 68, 91, 87, 79, 48, 66, 53, 64, 18, 51, 19, 32, 4, 21, 43}) - + Plot = function(self, yPointScale, bUpdateLabels, lineId) + lineId = lineId or 1 self:UpdateFrameSizeCache() --max amount of data is the max amount of point the chart will have - local maxLines = self:GetDataSize() + local dataSize = self:GetDataSize() --calculate where the first point height will be local firstValue = self:GetDataFirstValue() @@ -739,37 +946,235 @@ detailsFramework.ChartFrameMixin = { self:ResetDataIndex() - print(maxLines) + local r, g, b = unpack(self.color) + + local bFillChart, fillLineThickness = self:GetFillState() + + local payload = { + executionsPerFrame = 50, + self = self, + currentDataIndex = 1, + dataSize = dataSize, + currentXPoint = currentXPoint, + currentYPoint = currentYPoint, + eachLineWidth = eachLineWidth, + plotFrameHeightScaled = plotFrameHeightScaled, + r = r, + g = g, + b = b, + lineId = lineId, + bUpdateLabels = bUpdateLabels, + bFillChart = bFillChart, + fillLineThickness = fillLineThickness, + } + + for i = #fillerLines_InUse, 1, -1 do + local line = table.remove(fillerLines_InUse, i) + fillerLines_InAvailable[#fillerLines_InAvailable+1] = line + line:Hide() + end + + detailsFramework.Schedules.LazyExecute(lazyChartUpdate, payload) + + self:ShowBackdropIndicators() + + if (bUpdateLabels or bUpdateLabels == nil) then + updateLabelValues(self) + end + end, +} + +--https://en.wikipedia.org/wiki/Local_regression +local calcLOESS = function(data, span, mainFrame, chartFrame) + local lazyLOESSUpdate = function(payload, iterationCount, maxIterations) + local data = payload.data + local span = payload.span + local lastDataIndex = payload.lastDataIndex + local result = payload.result + local halfSpan = payload.halfSpan + local sumTotal = payload.sumTotal + + local currentDataIndex = payload.currentDataIndex + payload.currentDataIndex = currentDataIndex + payload.executionsPerFrame + + local max = math.max + local min = math.min + local abs = math.abs + local tinsert = table.insert + + for i = currentDataIndex, currentDataIndex + payload.executionsPerFrame do + --define the local neighborhood + local neighborhood = {} + for o = max(1, i - halfSpan), min(lastDataIndex, i + halfSpan) do + tinsert(neighborhood, {x = o, y = data[o]}) + end - for i = 1, maxLines do - local line = self:GetLine() + sumTotal = sumTotal + data[i] - line:SetColorTexture(unpack(self.color)) + --calculate weights based on distance from target point + local weights = {} + for _, point in ipairs(neighborhood) do + local distance = abs(i - point.x) + local weight = (1 - (distance / (halfSpan + 1)) ^ 3) ^ 3 + weights[point.x] = weight + end - if (line.thickness ~= self.lineThickness) then - line:SetThickness(self.lineThickness) - line.thickness = self.lineThickness + --fit a weighted linear regression to the neighborhood + local sum_w = 0 + local sum_wx = 0 + local sum_wy = 0 + local sum_wxx = 0 + local sum_wxy = 0 + + for _, point in ipairs(neighborhood) do + local w = weights[point.x] + sum_w = sum_w + w + sum_wx = sum_wx + w * point.x + sum_wy = sum_wy + w * point.y + sum_wxx = sum_wxx + w * point.x * point.x + sum_wxy = sum_wxy + w * point.x * point.y end - --the start point starts where the latest point finished - line:SetStartPoint("bottomleft", currentXPoint, currentYPoint) + local denominator = sum_w * sum_wxx - sum_wx * sum_wx + local intercept = (sum_wy * sum_wxx - sum_wx * sum_wxy) / denominator + local slope = (sum_w * sum_wxy - sum_wx * sum_wy) / denominator - --move x - currentXPoint = currentXPoint + eachLineWidth + --predict the smoothed value at the target point + result[i] = max(0, intercept + slope * i) - --end point - local value = self:GetDataNextValue() - currentYPoint = self:CalcYAxisPointForValue(value, plotFrameHeightScaled) - line:SetEndPoint("bottomleft", currentXPoint, currentYPoint) + --check if can finishe the execution + if (i == lastDataIndex) then + return true + end end - self:ShowBackdropIndicators() + payload.sumTotal = sumTotal + end - if (bUpdateLabels or bUpdateLabels == nil) then - updateLabelValues(self) + local result = {} + local dataSize = #data + local halfSpan = math.floor(span / 2) + + local payload = { + currentDataIndex = 1, + sumTotal = 0, + lastDataIndex = dataSize, + executionsPerFrame = 100, + data = data, + span = span, + result = result, + halfSpan = halfSpan, + } + + ---@type df_schedule + local schedules = detailsFramework.Schedules + + local onEndLazyExecution = function(payload) + chartFrame:SetDataRaw(payload.result) + + chartFrame.average = payload.sumTotal / dataSize + + local minValue, maxValue = chartFrame:GetDataMinMaxValues() + chartFrame:SetMinMaxValues(minValue, maxValue) + --clear the lines + chartFrame:HideLines() + mainFrame:SetBackgroundProcessState(false) + end + + mainFrame:SetBackgroundProcessState(true) + schedules.LazyExecute(lazyLOESSUpdate, payload, 999, onEndLazyExecution) +end + +--simple moving average +---@param data table +---@param averageSize number +---@param mainFrame df_chartmulti +---@param chartFrame df_chart +---@param bAddZeroPadding boolean? +local calcSMA = function(data, averageSize, mainFrame, chartFrame, bAddZeroPadding) + if (bAddZeroPadding) then + --fill the start of the data with zeros + for i = 1, averageSize - 1 do + --insert at index 1 a zero + table.insert(data, 1, 0) end - end, -} + end + + local lazySMAUpdate = function(payload, iterationCount, maxIterations) + local averageSize = payload.averageSize + local result = payload.result + local data = payload.data + local lastDataIndex = payload.lastDataIndex + local sum = payload.sum + local sumTotal = payload.sumTotal + local bAddZeroPadding = payload.bAddZeroPadding + + local currentDataIndex = payload.currentDataIndex + payload.currentDataIndex = currentDataIndex + payload.executionsPerFrame + + local tinsert = table.insert + + for i = currentDataIndex, currentDataIndex + payload.executionsPerFrame do + sum = sum + data[i] + sumTotal = sumTotal + data[i] + if (i >= averageSize) then + if (i > averageSize) then + sum = sum - data[i - averageSize] + end + tinsert(result, max(0, sum / averageSize)) + end + + --check if can finishe the execution + if (i == lastDataIndex) then + if (bAddZeroPadding) then + --remove from the data the zeros added at the start + for o = 1, averageSize - 1 do + --remove from the data the zero added at the first index + table.remove(data, 1) + end + end + return true + end + end + + payload.sumTotal = sumTotal + payload.sum = sum + end + + --return result + local result = {} + local dataSize = #data + + local payload = { + sum = 0, + sumTotal = 0, + currentDataIndex = 1, + lastDataIndex = dataSize, + executionsPerFrame = 300, + data = data, + result = result, + averageSize = averageSize, + bAddZeroPadding = bAddZeroPadding, + } + + ---@type df_schedule + local schedules = detailsFramework.Schedules + + local onEndLazyExecution = function(payload) + chartFrame:SetDataRaw(payload.result) + + chartFrame.average = payload.sumTotal / dataSize + + local minValue, maxValue = chartFrame:GetDataMinMaxValues() + chartFrame:SetMinMaxValues(minValue, maxValue) + --clear the lines + chartFrame:HideLines() + mainFrame:SetBackgroundProcessState(false) + end + + mainFrame:SetBackgroundProcessState(true) + schedules.LazyExecute(lazySMAUpdate, payload, 999, onEndLazyExecution) +end ---create a chart frame object ---@param parent frame @@ -788,41 +1193,31 @@ local createChartFrame = function(parent, name) chartFrame:ValueConstructor() chartFrame:ChartFrameConstructor() - --when a new data is set, update the min and max values - local onSetDataCallback = function(data, smoothnessLevel) - local newData = {} + --when a new data is set, starting an background process to smooth the data + local onSetDataCallback = function(data, payload) + local smoothnessMethod = payload.smoothnessMethod or "" + local smoothnessLevel = payload.smoothnessLevel + local mainFrame = payload.mainFrame smoothnessLevel = smoothnessLevel or 0 + smoothnessMethod = string.lower(smoothnessMethod) - if (smoothnessLevel > 0) then - smoothnessLevel = smoothnessLevel + 2 - - for i = 1, #data do - local thisValue = 0 - local amountDataAdded = 0 + if (smoothnessMethod == "loess") then + calcLOESS(data, smoothnessLevel, mainFrame, chartFrame) - --calculate the sum within the window - for o = i - math.floor(smoothnessLevel / 2), i + math.floor(smoothnessLevel / 2) do - if o >= 1 and o <= #data then - thisValue = thisValue + data[o] - amountDataAdded = amountDataAdded + 1 - end - end + elseif (smoothnessMethod == "sma") then + calcSMA(data, smoothnessLevel, mainFrame, chartFrame) - --calculate the average and store in the smoothedData value - local average = thisValue / amountDataAdded - table.insert(newData, average) - end + elseif (smoothnessMethod == "smaz") then + local bAddZeroPadding = true + calcSMA(data, smoothnessLevel, mainFrame, chartFrame, bAddZeroPadding) else - newData = data + chartFrame:SetDataRaw(data) + local minValue, maxValue = chartFrame:GetDataMinMaxValues() + chartFrame:SetMinMaxValues(minValue, maxValue) + --clear the lines + chartFrame:HideLines() end - - chartFrame:SetDataRaw(newData) - - local minValue, maxValue = chartFrame:GetDataMinMaxValues() - chartFrame:SetMinMaxValues(minValue, maxValue) - --clear the lines - chartFrame:HideLines() end chartFrame:AddDataChangeCallback(onSetDataCallback) @@ -831,13 +1226,6 @@ local createChartFrame = function(parent, name) end - -function detailsFramework:CreateGraphicLineFrame(parent, name) - ---@type df_chart - local newGraphicFrame = createChartFrame(parent, name) - return newGraphicFrame -end - detailsFramework.MultiChartFrameMixin = { MultiChartFrameConstructor = function(self) self.nextChartselframe = 1 @@ -846,6 +1234,7 @@ detailsFramework.MultiChartFrameMixin = { self.nextChartFrame = 1 self.chartFrames = {} self.lineNameIndicators = {} + self.amountOfBackgroundProcess = 0 chartFrameSharedConstructor(self) end, @@ -857,27 +1246,29 @@ detailsFramework.MultiChartFrameMixin = { ---add a new chart data and create a new chart frame if necessary to the multi chart ---@param self df_chartmulti ---@param data table + ---@param smoothingMethod string|nil ---@param smoothnessLevel number|nil ---@param name string|nil ---@param red any ---@param green number|nil ---@param blue number|nil ---@param alpha number|nil - AddData = function(self, data, smoothnessLevel, name, red, green, blue, alpha) + AddData = function(self, data, smoothingMethod, smoothnessLevel, name, red, green, blue, alpha) assert(type(data) == "table", "MultiChartFrame:AddData() usage: AddData(table)") local chartFrame = self:GetChart() red, green, blue, alpha = detailsFramework:ParseColors(red, green, blue, alpha) chartFrame:SetColor(red, green, blue, alpha) - chartFrame:SetData(data, smoothnessLevel) - chartFrame.chartName = name or "" - self:SetMaxValueIfBigger(chartFrame:GetMaxValue()) - self:SetMinValueIfLower(chartFrame:GetMinValue()) + local payload = { + smoothnessMethod = smoothingMethod or "sma", + smoothnessLevel = smoothnessLevel or 3, + mainFrame = self, + } - local dataAmount = chartFrame:GetDataSize() - self:SetMaxDataSize(dataAmount) + --setting the data will start a background process to smooth the data + chartFrame:SetData(data, payload) end, ---internally handle next line @@ -1023,14 +1414,58 @@ detailsFramework.MultiChartFrameMixin = { end end, + ---@param self df_chartmulti + WaitForBackgroundProcess = function(self) + --start a ticker to check if the background process is done + if (not self.waitForBackgroundProcessTicker) then + self.waitForBackgroundProcessTicker = C_Timer.NewTicker(0.1, function() + if (not self:HasBackgroundProcess()) then + self.waitForBackgroundProcessTicker:Cancel() + self.waitForBackgroundProcessTicker = nil + self:Plot() + end + end) + end + end, + ---draw all the charts added to the multi chart frame ---@param multiChartFrame df_chartmulti Plot = function(multiChartFrame) + --check if there is a background process ongoing + if (multiChartFrame:HasBackgroundProcess()) then + multiChartFrame:WaitForBackgroundProcess() + return + end + + local allCharts = multiChartFrame:GetCharts() + local bFillChart, fillLineThickness = multiChartFrame:GetFillState() + ---@type table + local biggestAverage = {} + + --set the min/max values of the multi chart frame + for i = 1, multiChartFrame:GetAmountCharts() do + local chartFrame = allCharts[i] + multiChartFrame:SetMaxValueIfBigger(chartFrame:GetMaxValue()) + multiChartFrame:SetMinValueIfLower(chartFrame:GetMinValue()) + + local dataAmount = chartFrame:GetDataSize() + multiChartFrame:SetMaxDataSize(dataAmount) + + if (bFillChart) then + chartFrame:SetFillChart(true, fillLineThickness) + end + + --get the average of this chart + biggestAverage[i] = {average = chartFrame.average, chartIndex = i} + end + + --sort the averages by the biggest average placing the biggest average in the first position + table.sort(biggestAverage, function(a, b) return a.average > b.average end) + local minValue, multiChartMaxValue = multiChartFrame:GetMinMaxValues() local plotAreaWidth = multiChartFrame.plotFrame:GetWidth() --if there's no axis, the plotFrame has no width local maxDataSize = multiChartFrame:GetMaxDataSize() --it's not clearing when a new boss is selected local eachLineWidth = plotAreaWidth / maxDataSize - local allCharts = multiChartFrame:GetCharts() for i = 1, multiChartFrame:GetAmountCharts() do local chartFrame = allCharts[i] @@ -1043,11 +1478,19 @@ detailsFramework.MultiChartFrameMixin = { chartFrame:SetLineThickness(multiChartFrame.lineThickness) chartFrame:SetLineWidth(eachLineWidth) + for o = 1, #biggestAverage do + local thisAverageTable = biggestAverage[o] + if (thisAverageTable.chartIndex == i) then + chartFrame.depth = o + break + end + end + --get the percentage of how small this data is compared to the biggest data --this percentage is then used to scale down the to fit correctly the fontStrings showing the value metrics local yPointScale = chartFrame.maxValue / multiChartMaxValue local bUpdateLabels = false - chartFrame:Plot(yPointScale, bUpdateLabels) + chartFrame:Plot(yPointScale, bUpdateLabels, i) end multiChartFrame:ShowBackdropIndicators() diff --git a/libs/DF/cooltip.lua b/libs/DF/cooltip.lua index 3913fee4..54e5253d 100644 --- a/libs/DF/cooltip.lua +++ b/libs/DF/cooltip.lua @@ -28,7 +28,7 @@ end --api locals local PixelUtil = PixelUtil or DFPixelUtil -local version = 26 +local version = 28 local CONST_MENU_TYPE_MAINMENU = "main" local CONST_MENU_TYPE_SUBMENU = "sub" @@ -45,7 +45,7 @@ function DF:CreateCoolTip() local defaultBackdrop = {bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}} - local defaultBackdropColor = {0.1215, 0.1176, 0.1294, 0.8000} + local defaultBackdropColor = {0.1215, 0.1176, 0.1294, 0.9500} local defaultBackdropBorderColor = {0.05, 0.05, 0.05, 1} local defaultTexCoord = {0, 1, 0, 1} @@ -144,7 +144,8 @@ function DF:CreateCoolTip() ["TextFont"] = true, ["TextColor"] = true, ["TextColorRight"] = true, - ["TextShadow"] = true, + ["TextShadow"] = true, --text shadow is doing the text outline + ["TextActuallyShadow"] = true, --text shadow which is the actually text shadow ["LeftTextWidth"] = true, ["RightTextWidth"] = true, ["LeftTextHeight"] = true, @@ -157,8 +158,11 @@ function DF:CreateCoolTip() ["SubMenuIsTooltip"] = true, ["LeftBorderSize"] = true, --offset between the left border and the left icon, default: 10 + offset ["RightBorderSize"] = true, --offset between the right border and the right icon, default: -10 + offset + ["TopBorderSize"] = true, --offset between the top border and the top of the first line, default: -6 + offset ["HeighMod"] = true, ["HeighModSub"] = true, + ["TooltipFrameHeightOffset"] = true, + ["TooltipFrameHeightOffsetSub"] = true, ["IconBlendMode"] = true, ["IconBlendModeHover"] = true, ["SubFollowButton"] = true, @@ -189,6 +193,10 @@ function DF:CreateCoolTip() ["FrameHeightSizeOffset"] = "HeighMod", ["FrameHeightSizeOffsetSub"] = "HeighModSub", + ["TextOutline"] = "TextShadow", + ["TextSilhouette"] = "TextActuallyShadow", + ["TextContour"] = "TextActuallyShadow", + --space between the tooltip's left side and the start of the line ["LeftPadding"] = "LeftBorderSize", @@ -1094,6 +1102,17 @@ function DF:CreateCoolTip() menuButton.leftText:SetFont(gameCooltip.defaultFont, leftTextSettings[6] or gameCooltip.OptionsTable.TextSize or 10, leftTextSettings[8] or gameCooltip.OptionsTable.TextShadow) end + --text shadow color + if (leftTextSettings[11]) then + local shadow_r, shadow_g, shadow_b, shadow_a = DF:ParseColors(leftTextSettings[11]) + menuButton.leftText:SetShadowColor(shadow_r, shadow_g, shadow_b, shadow_a) + elseif (gameCooltip.OptionsTable.TextActuallyShadow) then + local shadow_r, shadow_g, shadow_b, shadow_a = DF:ParseColors(gameCooltip.OptionsTable.TextActuallyShadow) + menuButton.leftText:SetShadowColor(shadow_r, shadow_g, shadow_b, shadow_a) + else + menuButton.leftText:SetShadowColor(0, 0, 0, 1) + end + local heightMod = gameCooltip.OptionsTable.TextHeightMod or 0 menuButton.leftText:SetPoint("center", menuButton.leftIcon, "center", 0, 0 + heightMod) menuButton.leftText:SetPoint("left", menuButton.leftIcon, "right", 3, 0 + heightMod) @@ -1179,6 +1198,17 @@ function DF:CreateCoolTip() else menuButton.rightText:SetFont(gameCooltip.defaultFont, rightTextSettings[6] or gameCooltip.OptionsTable.TextSize or 10, rightTextSettings[8] or gameCooltip.OptionsTable.TextShadow) end + + --text shadow color + if (rightTextSettings[11]) then + local shadow_r, shadow_g, shadow_b, shadow_a = DF:ParseColors(rightTextSettings[11]) + menuButton.rightText:SetShadowColor(shadow_r, shadow_g, shadow_b, shadow_a) + elseif (gameCooltip.OptionsTable.TextActuallyShadow) then + local shadow_r, shadow_g, shadow_b, shadow_a = DF:ParseColors(gameCooltip.OptionsTable.TextActuallyShadow) + menuButton.rightText:SetShadowColor(shadow_r, shadow_g, shadow_b, shadow_a) + else + menuButton.rightText:SetShadowColor(0, 0, 0, 1) + end else menuButton.rightText:SetText("") end @@ -1840,7 +1870,8 @@ function DF:CreateCoolTip() end --normalize height of all rows - local heightValue = -6 + spacing + (gameCooltip.OptionsTable.ButtonsYMod or 0) + local heightValue = (gameCooltip.OptionsTable.TopBorderSize or -6) + spacing + (gameCooltip.OptionsTable.ButtonsYMod or 0) + for i = 1, #LeftTextTableSub do local menuButton = frame2.Lines[i] @@ -1869,7 +1900,7 @@ function DF:CreateCoolTip() else menuButton:SetHeight(frame2.hHeight + (gameCooltip.OptionsTable.ButtonHeightMod or 0)) - menuButton:SetPoint("top", frame2, "top", 0, (((i-1) * frame2.hHeight) * -1) - 6 + (gameCooltip.OptionsTable.ButtonsYMod or 0) + spacing) + menuButton:SetPoint("top", frame2, "top", 0, (((i-1) * frame2.hHeight) * -1) + (gameCooltip.OptionsTable.TopBorderSize or -6) + (gameCooltip.OptionsTable.ButtonsYMod or 0) + spacing) end if (gameCooltip.OptionsTable.YSpacingMod and not gameCooltip.OptionsTable.IgnoreButtonAutoHeight) then @@ -1904,17 +1935,22 @@ function DF:CreateCoolTip() end end + local heightMod = gameCooltip.OptionsTable.TooltipFrameHeightOffsetSub or 0 + if (gameCooltip.OptionsTable.FixedHeight) then PixelUtil.SetHeight(frame2, gameCooltip.OptionsTable.FixedHeight) else if (gameCooltip.OptionsTable.AlignAsBlizzTooltip) then - PixelUtil.SetHeight(frame2, ((heightValue - 10) * -1) + (gameCooltip.OptionsTable.AlignAsBlizzTooltipFrameHeightOffset or 0)) + local newHeight = ((heightValue - 10) * -1) + (gameCooltip.OptionsTable.AlignAsBlizzTooltipFrameHeightOffset or 0) + PixelUtil.SetHeight(frame2, newHeight) elseif (gameCooltip.OptionsTable.IgnoreButtonAutoHeight) then - PixelUtil.SetHeight(frame2, (heightValue + spacing) * -1) + local newHeight = (heightValue + spacing) * -1 + PixelUtil.SetHeight(frame2, newHeight + heightMod) else - PixelUtil.SetHeight(frame2, max((frame2.hHeight * gameCooltip.Indexes) + 8 + ((gameCooltip.OptionsTable.ButtonsYMod or 0) * -1), 22)) + local newHeight = (frame2.hHeight * gameCooltip.Indexes) + 8 + ((gameCooltip.OptionsTable.ButtonsYMod or 0) * -1) + PixelUtil.SetHeight(frame2, max(newHeight + heightMod, 22)) end end @@ -2027,7 +2063,7 @@ function DF:CreateCoolTip() --mana range --instant cooldown - gameCooltip:ShowRoundedCorner() + --gameCooltip:ShowRoundedCorner() end end end @@ -2082,7 +2118,8 @@ function DF:CreateCoolTip() end --normalize height of all rows - local heightValue = -6 + spacing + (gameCooltip.OptionsTable.ButtonsYMod or 0) + local heightValue = (gameCooltip.OptionsTable.TopBorderSize or -6) + spacing + (gameCooltip.OptionsTable.ButtonsYMod or 0) + for i = 1, gameCooltip.Indexes do local menuButton = frame1.Lines[i] @@ -2108,10 +2145,9 @@ function DF:CreateCoolTip() menuButton:SetHeight(height) menuButton:SetPoint("top", frame1, "top", 0, heightValue) heightValue = heightValue + (height * -1) + spacing + (gameCooltip.OptionsTable.ButtonsYMod or 0) - else menuButton:SetHeight(frame1.hHeight + (gameCooltip.OptionsTable.ButtonHeightMod or 0)) - menuButton:SetPoint("top", frame1, "top", 0, (((i-1) * frame1.hHeight) * -1) - 6 + (gameCooltip.OptionsTable.ButtonsYMod or 0) + spacing) + menuButton:SetPoint("top", frame1, "top", 0, (((i-1) * frame1.hHeight) * -1) + (gameCooltip.OptionsTable.TopBorderSize or -6) + (gameCooltip.OptionsTable.ButtonsYMod or 0) + spacing) end if (gameCooltip.OptionsTable.YSpacingMod and not gameCooltip.OptionsTable.IgnoreButtonAutoHeight) then @@ -2146,6 +2182,8 @@ function DF:CreateCoolTip() end end + local heightMod = gameCooltip.OptionsTable.TooltipFrameHeightOffset or 0 + if (gameCooltip.OptionsTable.FixedHeight) then PixelUtil.SetHeight(frame1, gameCooltip.OptionsTable.FixedHeight) else @@ -2153,10 +2191,11 @@ function DF:CreateCoolTip() PixelUtil.SetHeight(frame1, ((heightValue - 10) * -1) + (gameCooltip.OptionsTable.AlignAsBlizzTooltipFrameHeightOffset or 0)) elseif (gameCooltip.OptionsTable.IgnoreButtonAutoHeight) then - PixelUtil.SetHeight(frame1, (heightValue + spacing) * -1) - + local newHeight = (heightValue + spacing) * -1 + PixelUtil.SetHeight(frame1, newHeight + heightMod) else - PixelUtil.SetHeight(frame1, max((frame1.hHeight * gameCooltip.Indexes) + 8 + ((gameCooltip.OptionsTable.ButtonsYMod or 0) * -1), 22)) + local newHeight = (frame1.hHeight * gameCooltip.Indexes) + 8 + ((gameCooltip.OptionsTable.ButtonsYMod or 0) * -1) + PixelUtil.SetHeight(frame1, max(newHeight + heightMod, 22)) end end @@ -3365,13 +3404,13 @@ function DF:CreateCoolTip() --adds a line. --only works with cooltip type1 and 2 (tooltip and tooltip with bars) --parameters: left text, right text[, L color R, L color G, L color B, L color A[, R color R, R color G, R color B, R color A[, wrap]]] - function gameCooltip:AddDoubleLine (leftText, rightText, menuType, ColorR1, ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag, textWidth, textHeight) --ãddline ~addline - return gameCooltip:AddLine(leftText, rightText, menuType, ColorR1, ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag, textWidth, textHeight) + function gameCooltip:AddDoubleLine (leftText, rightText, menuType, ColorR1, ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag, textWidth, textHeight, textContour) --ãddline ~addline + return gameCooltip:AddLine(leftText, rightText, menuType, ColorR1, ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag, textWidth, textHeight, textContour) end --adds a line for tooltips --AddLine creates a new line on the tooltip - function gameCooltip:AddLine(leftText, rightText, menuType, ColorR1, ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag, textWidth, textHeight) + function gameCooltip:AddLine(leftText, rightText, menuType, ColorR1, ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag, textWidth, textHeight, textContour) --check data integrity local leftTextType = type(leftText) if (leftTextType ~= "string") then @@ -3392,7 +3431,7 @@ function DF:CreateCoolTip() end if (type(ColorR1) ~= "number") then - ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag, textWidth, textHeight = ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace + ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag, textWidth, textHeight, textContour = ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag if (type(ColorR1) == "boolean" or not ColorR1) then ColorR1, ColorG1, ColorB1, ColorA1 = 0, 0, 0, 0 else @@ -3401,7 +3440,7 @@ function DF:CreateCoolTip() end if (type(ColorR2) ~= "number") then - fontSize, fontFace, fontFlag, textWidth, textHeight = ColorG2, ColorB2, ColorA2, fontSize, fontFace + fontSize, fontFace, fontFlag, textWidth, textHeight, textContour = ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag if (type(ColorR2) == "boolean" or not ColorR2) then ColorR2, ColorG2, ColorB2, ColorA2 = 0, 0, 0, 0 else @@ -3502,6 +3541,7 @@ function DF:CreateCoolTip() lineTable_Left[8] = fontFlag lineTable_Left[9] = textWidth lineTable_Left[10] = textHeight + lineTable_Left[11] = textContour lineTable_Right[1] = rightText lineTable_Right[2] = ColorR2 @@ -3513,6 +3553,7 @@ function DF:CreateCoolTip() lineTable_Right[8] = fontFlag lineTable_Right[9] = textWidth lineTable_Right[10] = textHeight + lineTable_Right[11] = textContour end function gameCooltip:AddSpecial(widgetType, index, subIndex, ...) diff --git a/libs/DF/definitions.lua b/libs/DF/definitions.lua index 07128d27..32bcffde 100644 --- a/libs/DF/definitions.lua +++ b/libs/DF/definitions.lua @@ -332,7 +332,11 @@ ---@field CreateHeader fun(self:table, parent:frame, headerTable:df_headercolumndata[], options:table?, frameName:string?) : df_headerframe ---@field CreateGraphicMultiLineFrame fun(self:table, parent:frame, name:string) : df_chartmulti ---@field CreateGraphicLineFrame fun(self:table, parent:frame, name:string) : df_chart ----@field +---@field CreateFlashAnimation fun(self:table, frame:uiobject, onFinishFunc:function?, onLoopFunc:function?) : animationgroup +---@field CreateTimeBar fun(self:table, parent:frame, texture:texturepath|textureid, width:number?, height:number?, value:number?, member:string?, name:string?) : df_timebar +---@field CreatePool fun(self:table, func:function, ...) : table +---@field CreateObjectPool fun(self:table, func:function, ...) : table alias of CreatePool + --[=[ Wrapped objects: when using the following functions, the object will be wrapped in a table, e.g. detailsFramework:CreateButton() will return a table with the button, the button will be accessible through the "button" key. diff --git a/libs/DF/fw.lua b/libs/DF/fw.lua index 07964f4d..3cf03adc 100644 --- a/libs/DF/fw.lua +++ b/libs/DF/fw.lua @@ -1,6 +1,6 @@ -local dversion = 556 +local dversion = 563 local major, minor = "DetailsFramework-1.0", dversion local DF, oldminor = LibStub:NewLibrary(major, minor) @@ -34,7 +34,7 @@ local GetSpellBookItemName = GetSpellBookItemName or C_SpellBook.GetSpellBookIte local GetNumSpellTabs = GetNumSpellTabs or C_SpellBook.GetNumSpellBookSkillLines local GetSpellTabInfo = GetSpellTabInfo or function(tabLine) local skillLine = C_SpellBook.GetSpellBookSkillLineInfo(tabLine) if skillLine then return skillLine.name, skillLine.iconID, skillLine.itemIndexOffset, skillLine.numSpellBookItems, skillLine.isGuild, skillLine.offSpecID end end local SpellBookItemTypeMap = Enum.SpellBookItemType and {[Enum.SpellBookItemType.Spell] = "SPELL", [Enum.SpellBookItemType.None] = "NONE", [Enum.SpellBookItemType.Flyout] = "FLYOUT", [Enum.SpellBookItemType.FutureSpell] = "FUTURESPELL", [Enum.SpellBookItemType.PetAction] = "PETACTION" } or {} -local GetSpellBookItemInfo = GetSpellBookItemInfo or function(...) local si = C_SpellBook.GetSpellBookItemInfo(...) if si then return SpellBookItemTypeMap[si.itemType] or "NONE", si.spellID end end +local GetSpellBookItemInfo = GetSpellBookItemInfo or function(...) local si = C_SpellBook.GetSpellBookItemInfo(...) if si then return SpellBookItemTypeMap[si.itemType] or "NONE", (si.itemType == Enum.SpellBookItemType.Flyout or si.itemType == Enum.SpellBookItemType.PetAction) and si.actionID or si.spellID or si.actionID, si end end local SPELLBOOK_BANK_PLAYER = Enum.SpellBookSpellBank and Enum.SpellBookSpellBank.Player or "player" local SPELLBOOK_BANK_PET = Enum.SpellBookSpellBank and Enum.SpellBookSpellBank.Pet or "pet" local IsPassiveSpell = IsPassiveSpell or C_Spell.IsSpellPassive @@ -2017,6 +2017,10 @@ local startFlash_Method = function(self, fadeInTime, fadeOutTime, flashDuration, flashAnimation:Play() end +---create a flash animation for a frame +---@param frame table +---@param onFinishFunc function? +---@param onLoopFunc function? function DF:CreateFlashAnimation(frame, onFinishFunc, onLoopFunc) local flashAnimation = frame:CreateAnimationGroup() @@ -2915,7 +2919,7 @@ end --DF.font_templates ["ORANGE_FONT_TEMPLATE"] = {color = "orange", size = 11, font = "Accidental Presidency"} --DF.font_templates ["OPTIONS_FONT_TEMPLATE"] = {color = "yellow", size = 12, font = "Accidental Presidency"} --DF.font_templates["ORANGE_FONT_TEMPLATE"] = {color = "orange", size = 10, font = DF:GetBestFontForLanguage()} -DF.font_templates["ORANGE_FONT_TEMPLATE"] = {color = {1, 0.8235, 0, 1}, size = 12, font = DF:GetBestFontForLanguage()} +DF.font_templates["ORANGE_FONT_TEMPLATE"] = {color = {1, 0.8235, 0, 1}, size = 11, font = DF:GetBestFontForLanguage()} --DF.font_templates["OPTIONS_FONT_TEMPLATE"] = {color = "yellow", size = 9.6, font = DF:GetBestFontForLanguage()} DF.font_templates["OPTIONS_FONT_TEMPLATE"] = {color = {1, 1, 1, 0.9}, size = 9.6, font = DF:GetBestFontForLanguage()} DF.font_templates["SMALL_SILVER"] = {color = "silver", size = 9, font = DF:GetBestFontForLanguage()} @@ -3050,7 +3054,13 @@ DF.button_templates["STANDARD_GRAY"] = { backdropcolor = {0.2, 0.2, 0.2, 0.502}, backdropbordercolor = {0, 0, 0, 0.5}, onentercolor = {0.4, 0.4, 0.4, 0.502}, +} +DF.button_templates["OPAQUE_DARK"] = { + backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Buttons\WHITE8X8]], tileSize = 8, tile = true}, + backdropcolor = {0.2, 0.2, 0.2, 1}, + backdropbordercolor = {0, 0, 0, 1}, + onentercolor = {0.4, 0.4, 0.4, 1}, } --sliders diff --git a/libs/DF/load.xml b/libs/DF/load.xml index c0505fa8..797e8d78 100644 --- a/libs/DF/load.xml +++ b/libs/DF/load.xml @@ -45,4 +45,5 @@