Rewrite on Faders: Details.FadeHandler.Fader(frame, animationType, speed, hideType)

This commit is contained in:
Tercio Jose
2021-04-24 18:17:59 -03:00
parent 4a28c63b4e
commit 2379884746
35 changed files with 722 additions and 337 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
local dversion = 241
local dversion = 243
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary (major, minor)
+13 -13
View File
@@ -6006,13 +6006,13 @@ local default_load_conditions_frame_options = {
function DF:CreateLoadFilterParser (callback)
local f = CreateFrame ("frame")
f:RegisterEvent ("PLAYER_ENTERING_WORLD")
if WOW_PROJECT_ID ~= WOW_PROJECT_CLASSIC then
if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
f:RegisterEvent ("PLAYER_SPECIALIZATION_CHANGED")
f:RegisterEvent ("PLAYER_TALENT_UPDATE")
end
f:RegisterEvent ("PLAYER_ROLES_ASSIGNED")
f:RegisterEvent ("ZONE_CHANGED_NEW_AREA")
if WOW_PROJECT_ID ~= WOW_PROJECT_CLASSIC then
if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
f:RegisterEvent ("CHALLENGE_MODE_START")
end
f:RegisterEvent ("ENCOUNTER_START")
@@ -7201,9 +7201,9 @@ DF.StatusBarFunctions = {
{"UNIT_HEALTH", true},
{"UNIT_MAXHEALTH", true},
--{"UNIT_HEALTH_FREQUENT", true},
{(WOW_PROJECT_ID ~= WOW_PROJECT_CLASSIC) and "UNIT_HEAL_PREDICTION", true},
{(WOW_PROJECT_ID ~= WOW_PROJECT_CLASSIC) and "UNIT_ABSORB_AMOUNT_CHANGED", true},
{(WOW_PROJECT_ID ~= WOW_PROJECT_CLASSIC) and "UNIT_HEAL_ABSORB_AMOUNT_CHANGED", true},
{(WOW_PROJECT_ID == WOW_PROJECT_MAINLINE) and "UNIT_HEAL_PREDICTION", true},
{(WOW_PROJECT_ID == WOW_PROJECT_MAINLINE) and "UNIT_ABSORB_AMOUNT_CHANGED", true},
{(WOW_PROJECT_ID == WOW_PROJECT_MAINLINE) and "UNIT_HEAL_ABSORB_AMOUNT_CHANGED", true},
}
--> setup the castbar to be used by another unit
@@ -7232,7 +7232,7 @@ DF.StatusBarFunctions = {
--> check for settings and update some events
if (not self.Settings.ShowHealingPrediction) then
if WOW_PROJECT_ID ~= WOW_PROJECT_CLASSIC then
if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
self:UnregisterEvent ("UNIT_HEAL_PREDICTION")
self:UnregisterEvent ("UNIT_HEAL_ABSORB_AMOUNT_CHANGED")
end
@@ -7240,7 +7240,7 @@ DF.StatusBarFunctions = {
self.healAbsorbIndicator:Hide()
end
if (not self.Settings.ShowShields) then
if WOW_PROJECT_ID ~= WOW_PROJECT_CLASSIC then
if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
self:UnregisterEvent ("UNIT_ABSORB_AMOUNT_CHANGED")
end
self.shieldAbsorbIndicator:Hide()
@@ -7333,7 +7333,7 @@ DF.StatusBarFunctions = {
--health and absorbs prediction
healthBarMetaFunctions.UpdateHealPrediction = function (self)
if WOW_PROJECT_ID == WOW_PROJECT_CLASSIC then return end
if WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE then return end
local currentHealth = self.currentHealth
local currentHealthMax = self.currentHealthMax
local healthPercent = currentHealth / currentHealthMax
@@ -7789,8 +7789,8 @@ DF.CastFrameFunctions = {
{"UNIT_SPELLCAST_CHANNEL_START"},
{"UNIT_SPELLCAST_CHANNEL_UPDATE"},
{"UNIT_SPELLCAST_CHANNEL_STOP"},
{(WOW_PROJECT_ID ~= WOW_PROJECT_CLASSIC) and "UNIT_SPELLCAST_INTERRUPTIBLE"},
{(WOW_PROJECT_ID ~= WOW_PROJECT_CLASSIC) and "UNIT_SPELLCAST_NOT_INTERRUPTIBLE"},
{(WOW_PROJECT_ID == WOW_PROJECT_MAINLINE) and "UNIT_SPELLCAST_INTERRUPTIBLE"},
{(WOW_PROJECT_ID == WOW_PROJECT_MAINLINE) and "UNIT_SPELLCAST_NOT_INTERRUPTIBLE"},
{"PLAYER_ENTERING_WORLD"},
{"UNIT_SPELLCAST_START", true},
{"UNIT_SPELLCAST_STOP", true},
@@ -8321,7 +8321,7 @@ DF.CastFrameFunctions = {
UNIT_SPELLCAST_START = function (self, unit)
local name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, spellID = UnitCastingInfo (unit)
if WOW_PROJECT_ID ~= WOW_PROJECT_CLASSIC then
if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, spellID = UnitCastingInfo (unit)
else
name, text, texture, startTime, endTime, isTradeSkill, castID, spellID = UnitCastingInfo (unit)
@@ -8382,7 +8382,7 @@ DF.CastFrameFunctions = {
UNIT_SPELLCAST_CHANNEL_START = function (self, unit, ...)
local name, text, texture, startTime, endTime, isTradeSkill, notInterruptible, spellID
if WOW_PROJECT_ID ~= WOW_PROJECT_CLASSIC then
if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
name, text, texture, startTime, endTime, isTradeSkill, notInterruptible, spellID = UnitChannelInfo (unit)
else
name, text, texture, startTime, endTime, isTradeSkill, spellID = UnitChannelInfo (unit)
@@ -8993,7 +8993,7 @@ end
--> todo: see what 'UnitTargetsVehicleInRaidUI' is, there's a call for this in the CompactUnitFrame.lua but zero documentation
CheckVehiclePossession = function (self)
--> this unit is possessing a vehicle?
local unitPossessVehicle = (WOW_PROJECT_ID ~= WOW_PROJECT_CLASSIC) and UnitHasVehicleUI (self.unit) or false
local unitPossessVehicle = (WOW_PROJECT_ID == WOW_PROJECT_MAINLINE) and UnitHasVehicleUI (self.unit) or false
if (unitPossessVehicle) then
if (not self.unitInVehicle) then
if (UnitIsUnit ("player", self.unit)) then
+91 -2
View File
@@ -451,8 +451,97 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
end
end
-- animation
local timeDilatation = 2.615321
--> animation with acceleration ~animation ~healthbaranimation
local animateLeftWithAccel = function(self, deltaTime)
local distance = (self.AnimationStart - self.AnimationEnd) / self.CurrentMaxValue * 100 --scale 1 - 100
local minTravel = min (distance / 10, 3) -- 10 = trigger distance to max speed 3 = speed scale on max travel
local maxTravel = max (minTravel, 0.45) -- 0.45 = min scale speed on low travel speed
local animationSpeed = (self.CurrentMaxValue * (deltaTime * timeDilatation)) * maxTravel --re-scale back to unit health, scale with delta time and scale with the travel speed
self.AnimationStart = self.AnimationStart - (animationSpeed)
self:SetValue(self.AnimationStart)
self.currentValue = self.AnimationStart
if (self.Spark) then
self.Spark:SetPoint("center", self, "left", self.AnimationStart / self.CurrentMaxValue * self:GetWidth(), 0)
self.Spark:Show()
end
if (self.AnimationStart - 0.01 <= self.AnimationEnd) then
self:SetValue (self.AnimationEnd)
self.currentValue = self.AnimationEnd
self.IsAnimating = false
if (self.Spark) then
self.Spark:Hide()
end
end
end
local animateRightWithAccel = function(self, deltaTime)
local distance = (self.AnimationEnd - self.AnimationStart) / self.CurrentMaxValue * 100 --scale 1 - 100 basis
local minTravel = math.min (distance / 10, 3) -- 10 = trigger distance to max speed 3 = speed scale on max travel
local maxTravel = math.max (minTravel, 0.45) -- 0.45 = min scale speed on low travel speed
local animationSpeed = (self.CurrentMaxValue * (deltaTime * timeDilatation)) * maxTravel --re-scale back to unit health, scale with delta time and scale with the travel speed
self.AnimationStart = self.AnimationStart + (animationSpeed)
self:SetValue(self.AnimationStart)
self.currentValue = self.AnimationStart
if (self.AnimationStart + 0.01 >= self.AnimationEnd) then
self:SetValue (self.AnimationEnd)
self.currentValue = self.AnimationEnd
self.IsAnimating = false
if (self.Spark) then
self.Spark:Hide()
end
end
end
local onUpdate = function(self, deltaTime)
return self.MyObject:DoAnimation(deltaTime)
end
function SplitBarMetaFunctions:EnableAnimations()
self.widget:SetScript("OnUpdate", onUpdate)
self.widget:SetMinMaxValues(0, 1.0)
self.widget:SetValue(0, 0.5)
self.UsingAnimation = true
self.oldValue = self:GetValue()
self.currentValue = self:GetValue()
self.CurrentMaxValue = 100.0
end
function SplitBarMetaFunctions:DisableAnimations()
self.widget:SetScript("OnUpdate", nil)
self.UsingAnimation = nil
self.oldValue = nil
self.currentValue = nil
end
function SplitBarMetaFunctions:DoAnimation(deltaTime)
local oldValue = self.oldValue
self.AnimationStart = oldValue
self.AnimationEnd = self.currentValue
self:SetValue(oldValue)
self.IsAnimating = true
if (self.AnimationEnd > self.AnimationStart) then
self.AnimateFunc = animateRightWithAccel
else
self.AnimateFunc = animateLeftWithAccel
end
end
------------------------------------------------------------------------------------------------------------
--> scripts
local OnEnter = function (frame)
local capsule = frame.MyObject
local kill = capsule:RunHooksForWidget ("OnEnter", frame, capsule)
@@ -539,8 +628,8 @@ function DetailsFrameworkSplitlBar_OnCreate (self)
return true
end
function DF:CreateSplitBar (parent, parent, w, h, member, name)
return DF:NewSplitBar (parent, container, name, member, w, h)
function DF:CreateSplitBar(parent, width, height, member, name)
return DF:NewSplitBar(parent, nil, name, member, width, height)
end
local build_statusbar = function (self)