From 72d1b474655e9618240957dc0d685c55a7b4e20a Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Sat, 9 Nov 2019 19:26:55 -0300 Subject: [PATCH] Framework Update Framework updated to version .161 --- libs/DF/.gitignore | 9 ++ libs/DF/fw.lua | 6 +- libs/DF/panel.lua | 319 ++++++++++++++++++++++----------------------- 3 files changed, 172 insertions(+), 162 deletions(-) create mode 100644 libs/DF/.gitignore diff --git a/libs/DF/.gitignore b/libs/DF/.gitignore new file mode 100644 index 0000000..f380913 --- /dev/null +++ b/libs/DF/.gitignore @@ -0,0 +1,9 @@ + +background.blp +border_1.blp +border_2.blp +border_3.blp +cooltip_background.blp +feedback_sites.blp +icons.blp +mail.blp diff --git a/libs/DF/fw.lua b/libs/DF/fw.lua index ef83cb5..22ebb26 100644 --- a/libs/DF/fw.lua +++ b/libs/DF/fw.lua @@ -1,5 +1,6 @@ -local dversion = 153 +local dversion = 161 + local major, minor = "DetailsFramework-1.0", dversion local DF, oldminor = LibStub:NewLibrary (major, minor) @@ -21,7 +22,7 @@ SMALL_NUMBER = 0.000001 ALPHA_BLEND_AMOUNT = 0.8400251 DF.AuthorInfo = { - Name = "Tercioo", + Name = "Terciob", Discord = "https://discord.gg/AGSzAZX", } @@ -1654,6 +1655,7 @@ DF.GlobalWidgetControlNames = { slider = "DF_SliderMetaFunctions", split_bar = "DF_SplitBarMetaFunctions", aura_tracker = "DF_AuraTracker", + healthBar = "DF_healthBarMetaFunctions", } function DF:AddMemberForWidget (widgetName, memberType, memberName, func) diff --git a/libs/DF/panel.lua b/libs/DF/panel.lua index d4e4916..177e793 100644 --- a/libs/DF/panel.lua +++ b/libs/DF/panel.lua @@ -6682,7 +6682,7 @@ function DF:CreateDataScrollFrame (parent, name, options) end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ---> what's new window +--> "WHAT's NEW" window local default_newsframe_options = { width = 400, @@ -6771,9 +6771,18 @@ end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --> statusbar info -function DF:BuildStatusbarAuthorInfo (f) - - local authorName = DF:CreateLabel (f, "An addon by |cFFFFFFFFTercioo|r") +--[[ + authorTable = { + { + authorName = "author name 1", + link = "twitter.com/author1Handle", + } + } +]] + +function DF:BuildStatusbarAuthorInfo (f, addonBy, authorsNameString) + + local authorName = DF:CreateLabel (f, "" .. (addonBy or "An addon by") .. "|cFFFFFFFF" .. (authorsNameString or "Terciob") .. "|r") authorName.textcolor = "silver" local discordLabel = DF:CreateLabel (f, "Discord: ") discordLabel.textcolor = "silver" @@ -6796,6 +6805,7 @@ function DF:BuildStatusbarAuthorInfo (f) discordTextEntry:SetHook ("OnEditFocusGained", function() discordTextEntry:HighlightText() end) + end @@ -6851,67 +6861,83 @@ DF.StatusBarFunctions = { healthBar:SetTexture (texture) --]=] -local debugPerformance = { - eventCall = {}, - unitCall = {}, - functionCall = {}, - CPUUsageByFunction = {}, -} +--debug performance isn't placed anywhere +--how to use debug performance: I don't remember -local function CalcPerformance (type, data) - if (type == "event") then - debugPerformance.eventCall [data] = (debugPerformance.eventCall [data] or 0) + 1 - - elseif (type == "unit") then - debugPerformance.unitCall [data] = (debugPerformance.unitCall [data] or 0) + 1 - - elseif (type == "call") then - debugPerformance.functionCall [data] = (debugPerformance.functionCall [data] or 0) + 1 - - end -end + --Details:Dump (debugPerformance) -function DF_CalcCpuUsage (name) - local cpu = debugPerformance.CPUUsageByFunction [name] or {usage = 0, last = 0, active = false} - debugPerformance.CPUUsageByFunction [name] = cpu - - if (cpu.active) then - cpu.active = false - local diff = debugprofilestop() - cpu.last - cpu.usage = cpu.usage + diff - else - cpu.active = true - cpu.last = debugprofilestop() + local debugPerformance = { + eventCall = {}, + unitCall = {}, + functionCall = {}, + CPUUsageByFunction = {}, + } + + local function CalcPerformance (type, data) + if (type == "event") then + debugPerformance.eventCall [data] = (debugPerformance.eventCall [data] or 0) + 1 + + elseif (type == "unit") then + debugPerformance.unitCall [data] = (debugPerformance.unitCall [data] or 0) + 1 + + elseif (type == "call") then + debugPerformance.functionCall [data] = (debugPerformance.functionCall [data] or 0) + 1 + + end end -end -function UnitFrameStats() - for functionName, functionTable in pairs (debugPerformance.CPUUsageByFunction) do - debugPerformance.CPUUsageByFunction [functionName] = floor (functionTable.usage) + function DF_CalcCpuUsage (name) + local cpu = debugPerformance.CPUUsageByFunction [name] or {usage = 0, last = 0, active = false} + debugPerformance.CPUUsageByFunction [name] = cpu + + if (cpu.active) then + cpu.active = false + local diff = debugprofilestop() - cpu.last + cpu.usage = cpu.usage + diff + else + cpu.active = true + cpu.last = debugprofilestop() + end end - Details:Dump (debugPerformance) - - for functionName, functionTable in pairs (debugPerformance.CPUUsageByFunction) do - debugPerformance.CPUUsageByFunction [functionName] = {usage = 0, last = 0, active = false} + function UnitFrameStats() + for functionName, functionTable in pairs (debugPerformance.CPUUsageByFunction) do + debugPerformance.CPUUsageByFunction [functionName] = floor (functionTable.usage) + end + + for functionName, functionTable in pairs (debugPerformance.CPUUsageByFunction) do + debugPerformance.CPUUsageByFunction [functionName] = {usage = 0, last = 0, active = false} + end end -end +--end of performance calcs +--healthBar meta prototype + local healthBarMetaPrototype = { + WidgetType = "healthBar", + SetHook = DF.SetHook, + RunHooksForWidget = DF.RunHooksForWidget, + } + _G [DF.GlobalWidgetControlNames ["healthBar"]] = _G [DF.GlobalWidgetControlNames ["healthBar"]] or healthBarMetaPrototype ---CalcPerformance ("unit", data) + local healthBarMetaFunctions = _G [DF.GlobalWidgetControlNames ["healthBar"]] -DF.HealthFrameFunctions = { +--hook list + local defaultHooksForHealthBar = { + OnHide = {}, + OnShow = {}, + OnHealthChange = {}, + OnHealthMaxChange = {}, + } - WidgetType = "healthBar", - SetHook = DF.SetHook, - RunHooksForWidget = DF.RunHooksForWidget, + --use the hook already existing + healthBarMetaFunctions.HookList = healthBarMetaFunctions.HookList or defaultHooksForHealthBar + --copy the non existing values from a new version to the already existing hook table + DF.table.deploy (healthBarMetaFunctions.HookList, defaultHooksForHealthBar) - HookList = { - OnHide = {}, - OnShow = {}, - }, +--> Health Bar Meta Functions - Settings = { + --health bar settings + healthBarMetaFunctions.Settings = { CanTick = false, --> if true calls the method 'OnTick' every tick, the function needs to be overloaded, it receives self and deltaTime as parameters ShowHealingPrediction = true, --> when casting a healing pass, show the amount of health that spell will heal ShowShields = true, --> indicator of the amount of damage absortion the unit has @@ -6926,9 +6952,9 @@ DF.HealthFrameFunctions = { --default size Width = 100, Height = 20, - }, + } - HealthBarEvents = { + healthBarMetaFunctions.HealthBarEvents = { {"PLAYER_ENTERING_WORLD"}, --{"UNIT_HEALTH", true}, {"UNIT_MAXHEALTH", true}, @@ -6936,14 +6962,12 @@ DF.HealthFrameFunctions = { {"UNIT_HEAL_PREDICTION", true}, {"UNIT_ABSORB_AMOUNT_CHANGED", true}, {"UNIT_HEAL_ABSORB_AMOUNT_CHANGED", true}, - }, + } --> setup the castbar to be used by another unit - SetUnit = function (self, unit, displayedUnit) + healthBarMetaFunctions.SetUnit = function (self, unit, displayedUnit) if (self.unit ~= unit or self.displayedUnit ~= displayedUnit or unit == nil) then - CalcPerformance ("call", "SetUnit") - self.unit = unit self.displayedUnit = displayedUnit or unit @@ -6996,9 +7020,9 @@ DF.HealthFrameFunctions = { self:Hide() end end - end, + end - Initialize = function (self) + healthBarMetaFunctions.Initialize = function (self) PixelUtil.SetWidth (self, self.Settings.Width, 1) PixelUtil.SetHeight (self, self.Settings.Height, 1) @@ -7021,61 +7045,44 @@ DF.HealthFrameFunctions = { self.shieldAbsorbGlow:Hide() self:SetUnit (nil) - - CalcPerformance ("call", "HealthBar-Initialize") - end, + end - --> call every tick - OnTick = function (self, deltaTime) end, --if overrided, set 'CanTick' to true on the settings table + --call every tick + healthBarMetaFunctions.OnTick = function (self, deltaTime) end --if overrided, set 'CanTick' to true on the settings table - --> when an event happen for this unit, send it to the apropriate function - OnEvent = function (self, event, ...) - CalcPerformance ("unit", self.unit) - CalcPerformance ("event", event) - CalcPerformance ("call", "HealthBar-OnEvent") - - DF_CalcCpuUsage ("healthBar-OnEvent") + --when an event happen for this unit, send it to the apropriate function + healthBarMetaFunctions.OnEvent = function (self, event, ...) local eventFunc = self [event] if (eventFunc) then --the function doesn't receive which event was, only 'self' and the parameters eventFunc (self, ...) end - DF_CalcCpuUsage ("healthBar-OnEvent") - end, + end - --colocar mais coisas aqui, um member dizendo quanto de health e o health max da unit - UpdateMaxHealth = function (self) - DF_CalcCpuUsage ("HealthBar-UpdateMaxHealth") - local maxHealth = UnitHealthMax (self.displayedUnit) - self:SetMinMaxValues (0, maxHealth) - self.currentHealthMax = maxHealth - DF_CalcCpuUsage ("HealthBar-UpdateMaxHealth") + --when the unit max health is changed + healthBarMetaFunctions.UpdateMaxHealth = function (self) + local maxHealth = UnitHealthMax (self.displayedUnit) + self:SetMinMaxValues (0, maxHealth) + self.currentHealthMax = maxHealth - CalcPerformance ("call", "HealthBar-UpdateMaxHealth") - end, + self:RunHooksForWidget ("OnHealthMaxChange", self, self.displayedUnit) + end - UpdateHealth = function (self) - DF_CalcCpuUsage ("HealthBar-UpdateHealth") - local health = UnitHealth (self.displayedUnit) - self.currentHealth = health - PixelUtil.SetStatusBarValue (self, health) - DF_CalcCpuUsage ("HealthBar-UpdateHealth") - - CalcPerformance ("call", "HealthBar-UpdateHealth") - end, + healthBarMetaFunctions.UpdateHealth = function (self) + local health = UnitHealth (self.displayedUnit) + self.currentHealth = health + PixelUtil.SetStatusBarValue (self, health) + + self:RunHooksForWidget ("OnHealthChange", self, self.displayedUnit) + end - --isso aqui vai ser complicado! - UpdateHealPrediction = function (self) - CalcPerformance ("call", "HealthBar-UpdateHealPrediction") - - DF_CalcCpuUsage ("HealthBar-UpdateHealPrediction") - + --health and absorbs prediction + healthBarMetaFunctions.UpdateHealPrediction = function (self) local currentHealth = self.currentHealth local currentHealthMax = self.currentHealthMax local healthPercent = currentHealth / currentHealthMax if (not currentHealthMax or currentHealthMax <= 0) then - DF_CalcCpuUsage ("HealthBar-UpdateHealPrediction") return end @@ -7137,50 +7144,50 @@ DF.HealthFrameFunctions = { self.shieldAbsorbIndicator:Hide() self.shieldAbsorbGlow:Hide() end - - DF_CalcCpuUsage ("HealthBar-UpdateHealPrediction") - end, + end - PLAYER_ENTERING_WORLD = function (self, ...) - self:UpdateMaxHealth() - self:UpdateHealth() - self:UpdateHealPrediction() - end, - - --> health events - UNIT_HEALTH = function (self, ...) - self:UpdateHealth() - self:UpdateHealPrediction() - - local unitName = UnitName (self.unit) - CalcPerformance ("call", "HealthBar-UNIT_HEALTH-" .. unitName) - end, - UNIT_HEALTH_FREQUENT = function (self, ...) - self:UpdateHealth() - self:UpdateHealPrediction() - end, - UNIT_MAXHEALTH = function (self, ...) - self:UpdateMaxHealth() - self:UpdateHealth() - self:UpdateHealPrediction() - end, + --> Health Events + healthBarMetaFunctions.PLAYER_ENTERING_WORLD = function (self, ...) + self:UpdateMaxHealth() + self:UpdateHealth() + self:UpdateHealPrediction() + end + + healthBarMetaFunctions.UNIT_HEALTH = function (self, ...) + self:UpdateHealth() + self:UpdateHealPrediction() + end + + healthBarMetaFunctions.UNIT_HEALTH_FREQUENT = function (self, ...) + self:UpdateHealth() + self:UpdateHealPrediction() + end + + healthBarMetaFunctions.UNIT_MAXHEALTH = function (self, ...) + self:UpdateMaxHealth() + self:UpdateHealth() + self:UpdateHealPrediction() + end + + + healthBarMetaFunctions.UNIT_HEAL_PREDICTION = function (self, ...) + self:UpdateMaxHealth() + self:UpdateHealth() + self:UpdateHealPrediction() + end + + healthBarMetaFunctions.UNIT_ABSORB_AMOUNT_CHANGED = function (self, ...) + self:UpdateMaxHealth() + self:UpdateHealth() + self:UpdateHealPrediction() + end + + healthBarMetaFunctions.UNIT_HEAL_ABSORB_AMOUNT_CHANGED = function (self, ...) + self:UpdateMaxHealth() + self:UpdateHealth() + self:UpdateHealPrediction() + end - UNIT_HEAL_PREDICTION = function (self, ...) - self:UpdateMaxHealth() - self:UpdateHealth() - self:UpdateHealPrediction() - end, - UNIT_ABSORB_AMOUNT_CHANGED = function (self, ...) - self:UpdateMaxHealth() - self:UpdateHealth() - self:UpdateHealPrediction() - end, - UNIT_HEAL_ABSORB_AMOUNT_CHANGED = function (self, ...) - self:UpdateMaxHealth() - self:UpdateHealth() - self:UpdateHealPrediction() - end, -} -- ~healthbar function DF:CreateHealthBar (parent, name, settingsOverride) @@ -7212,18 +7219,18 @@ function DF:CreateHealthBar (parent, name, settingsOverride) end --> mixins - DF:Mixin (healthBar, DF.HealthFrameFunctions) + DF:Mixin (healthBar, healthBarMetaFunctions) DF:Mixin (healthBar, DF.StatusBarFunctions) --> settings and hooks - local settings = DF.table.copy ({}, DF.HealthFrameFunctions.Settings) + local settings = DF.table.copy ({}, healthBarMetaFunctions.Settings) if (settingsOverride) then DF.table.copy (settings, settingsOverride) end healthBar.Settings = settings - - local hookList = DF.table.copy ({}, DF.HealthFrameFunctions.HookList) - healthBar.HookList = hookList + + --> hook list + healthBar.HookList = DF.table.copy ({}, healthBarMetaFunctions.HookList) --> initialize the cast bar healthBar:Initialize() @@ -7350,13 +7357,11 @@ DF.PowerFrameFunctions = { --> when an event happen for this unit, send it to the apropriate function OnEvent = function (self, event, ...) - DF_CalcCpuUsage ("Powerbar-OnEvent") local eventFunc = self [event] if (eventFunc) then --the function doesn't receive which event was, only 'self' and the parameters eventFunc (self, ...) end - DF_CalcCpuUsage ("Powerbar-OnEvent") end, UpdatePowerBar = function (self) @@ -7376,32 +7381,27 @@ DF.PowerFrameFunctions = { end end, UpdatePower = function (self) - DF_CalcCpuUsage ("Powerbar-UpdatePower") self.currentPower = UnitPower (self.displayedUnit, self.powerType) PixelUtil.SetStatusBarValue (self, self.currentPower) if (self.Settings.ShowPercentText) then self.percentText:SetText (floor (self.currentPower / self.currentPowerMax * 100) .. "%") end - DF_CalcCpuUsage ("Powerbar-UpdatePower") end, --> when a event different from unit_power_update is triggered, update which type of power the unit should show UpdatePowerInfo = function (self) - DF_CalcCpuUsage ("Powerbar-UpdatePowerInfo") if (self.Settings.ShowAlternatePower) then local _, minPower, _, _, _, _, showOnRaid = UnitAlternatePowerInfo (self.displayedUnit) if (showOnRaid and IsInGroup()) then self.powerType = ALTERNATE_POWER_INDEX self.minPower = minPower - DF_CalcCpuUsage ("Powerbar-UpdatePowerInfo") return end end self.powerType = UnitPowerType (self.displayedUnit) self.minPower = 0 - DF_CalcCpuUsage ("Powerbar-UpdatePowerInfo") end, --> tint the bar with the color of the power, e.g. blue for a mana bar @@ -7683,7 +7683,7 @@ DF.CastFrameFunctions = { --> check max value if (not isFinished and not self.finished) then if (self.casting) then - if (self.value >= self.maxValue or self.value < 0) then + if (self.value >= self.maxValue) then isFinished = true end @@ -7937,10 +7937,8 @@ DF.CastFrameFunctions = { end, OnTick = function (self, deltaTime) - DF_CalcCpuUsage ("CastBar-OnTick") if (self.casting) then if (not self:OnTick_Casting (deltaTime)) then - DF_CalcCpuUsage ("CastBar-OnTick") return end @@ -7953,7 +7951,6 @@ DF.CastFrameFunctions = { elseif (self.channeling) then if (not self:OnTick_Channeling (deltaTime)) then - DF_CalcCpuUsage ("CastBar-OnTick") return end @@ -7964,7 +7961,6 @@ DF.CastFrameFunctions = { self.lazyUpdateCooldown = self.Settings.LazyUpdateCooldown end end - DF_CalcCpuUsage ("CastBar-OnTick") end, --> animation start script @@ -8302,6 +8298,11 @@ DF.CastFrameFunctions = { self.spellStartTime = startTime / 1000 self.spellEndTime = endTime / 1000 self.value = self.spellEndTime - GetTime() + + if (self.value < 0) then + self.value = 0 + end + self.maxValue = self.spellEndTime - self.spellStartTime self:SetMinMaxValues (0, self.maxValue) self:SetValue (self.value) @@ -8644,7 +8645,6 @@ end --> when an event happen for this unit, send it to the apropriate function OnEvent = function (self, event, ...) --> run the function for this event - DF_CalcCpuUsage ("unitFrame-OnEvent") local eventFunc = self [event] if (eventFunc) then --> is this event an unit event? @@ -8658,7 +8658,6 @@ end eventFunc (self, ...) end end - DF_CalcCpuUsage ("unitFrame-OnEvent") end, OnHide = function (self)