Skip to content

Commit

Permalink
Change log, version up, and plugins TOC bumps
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Aug 12, 2023
1 parent 6bfcc14 commit 0b32fe3
Show file tree
Hide file tree
Showing 15 changed files with 313 additions and 111 deletions.
21 changes: 11 additions & 10 deletions Libs/DF/addon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,22 @@ local addonLoaded = function(addonFrame, event, addonName)
local playerGUID = UnitGUID("player") --the guid points to a profile name

---@type table
local savedVariables = detailsFramework.SavedVars.GetSavedVariables(addonObject)
local tSavedVariables = detailsFramework.SavedVars.GetSavedVariables(addonObject)

--check if the player has a profileId saved
local playerProfileId = savedVariables.profile_ids[playerGUID]
if (not playerProfileId) then
--it doesn't, set it to use the default profile
playerProfileId = CONST_DEFAULT_PROFILE_NAME
savedVariables.profile_ids[playerGUID] = playerProfileId
local profileId = tSavedVariables.profile_ids[playerGUID]
if (not profileId) then
--if it doesn't, set it to use the default profile
profileId = CONST_DEFAULT_PROFILE_NAME
tSavedVariables.profile_ids[playerGUID] = profileId
end

local profileTable = detailsFramework.SavedVars.GetProfile(addonObject)
local bCreateIfNotFound = true
local profileTable = detailsFramework.SavedVars.GetProfile(addonObject, bCreateIfNotFound)
addonObject.profile = profileTable

if (addonObject.OnLoad) then
detailsFramework:Dispatch(addonObject.OnLoad, addonObject, profileTable)
detailsFramework:Dispatch(addonObject.OnLoad, addonObject, addonObject.profile)
end
end

Expand All @@ -56,8 +58,7 @@ local addonInit = function(addonFrame)
local addonObject = addonFrame.__addonObject

if (addonObject.OnInit) then
local profileTable = detailsFramework.SavedVars.GetProfile(addonObject)
detailsFramework:Dispatch(addonObject.OnInit, addonObject, profileTable)
detailsFramework:Dispatch(addonObject.OnInit, addonObject, addonObject.profile)
end
end

Expand Down
6 changes: 5 additions & 1 deletion Libs/DF/cooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ function DF:CreateCoolTip()
end
end

function gameCooltip:Msg(...)
print("|cFFFFFF00Cooltip|r:", ...)
end

function gameCooltip:SetDebug(bDebugState)
gameCooltip.debug = bDebugState
end
Expand Down Expand Up @@ -3459,7 +3463,7 @@ function DF:CreateCoolTip()

local okay, errortext = pcall(host.CoolTip.BuildFunc, host, host.CoolTip and host.CoolTip.FixedValue)
if (not okay) then
gameCooltip:PrintDebug("ExecFunc() injected function error:", errortext)
gameCooltip:Msg("ExecFunc() injected function error:", errortext)
end

gameCooltip:SetOwner(host, host.CoolTip.MyAnchor, host.CoolTip.HisAnchor, host.CoolTip.X, host.CoolTip.Y)
Expand Down
3 changes: 2 additions & 1 deletion Libs/DF/definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
---@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)
---@field SetButtonTexture fun(self:table, button:button|df_button, texture:atlasname|texturepath|textureid)
---@field CreateFadeAnimation fun(self:table, UIObject:uiobject, fadeInTime:number?, fadeOutTime:number?, fadeInAlpha:number?, fadeOutAlpha:number?)
129 changes: 106 additions & 23 deletions Libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


local dversion = 454
local dversion = 456
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary(major, minor)

Expand Down Expand Up @@ -584,8 +584,11 @@ end
function DF.table.removeduplicate(table1, table2)
for key, value in pairs(table2) do
if (type(value) == "table") then
if (table1[key]) then
DF.table.removeduplicate(value, table1[key])
if (type(table1[key]) == "table") then
DF.table.removeduplicate(table1[key], value)
if (not next(table1[key])) then
table1[key] = nil
end
end
else
if (type(table1[key]) == "number" and type(value) == "number") then
Expand Down Expand Up @@ -619,10 +622,10 @@ end
function DF.table.deploy(t1, t2)
for key, value in pairs(t2) do
if (type(value) == "table") then
t1 [key] = t1 [key] or {}
DF.table.deploy(t1 [key], t2 [key])
elseif (t1 [key] == nil) then
t1 [key] = value
t1[key] = t1[key] or {}
DF.table.deploy(t1[key], t2[key])
elseif (t1[key] == nil) then
t1[key] = value
end
end
return t1
Expand Down Expand Up @@ -814,6 +817,7 @@ else
end

---format a number with commas
---@param self table
---@param value number
---@return string
function DF:CommaValue(value)
Expand All @@ -832,6 +836,7 @@ function DF:CommaValue(value)
end

---call the function 'callback' for each group member passing the unitID and the extra arguments
---@param self table
---@param callback function
---@vararg any
function DF:GroupIterator(callback, ...)
Expand All @@ -852,27 +857,31 @@ function DF:GroupIterator(callback, ...)
end

---get an integer an format it as string with the time format 16:45
---@param self table
---@param value number
---@return string
function DF:IntegerToTimer(value) --~formattime
return "" .. math.floor(value/60) .. ":" .. string.format("%02.f", value%60)
end

---remove the realm name from a name
---@param self table
---@param name string
---@return string, number
function DF:RemoveRealmName(name)
return name:gsub(("%-.*"), "")
end

---remove the owner name of the pet or guardian
---@param self table
---@param name string
---@return string, number
function DF:RemoveOwnerName(name)
return name:gsub((" <.*"), "")
end

---remove realm and owner names also remove brackets from spell actors
---@param self table
---@param name string
---@return string
function DF:CleanUpName(name)
Expand All @@ -883,13 +892,15 @@ function DF:CleanUpName(name)
end

---remove the realm name from a name
---@param self table
---@param name string
---@return string, number
function DF:RemoveRealName(name)
return name:gsub(("%-.*"), "")
end

---get the UIObject of type 'FontString' named fontString and set the font size to the maximum value of the arguments
---@param self table
---@param fontString fontstring
---@vararg number
function DF:SetFontSize(fontString, ...)
Expand All @@ -898,6 +909,7 @@ function DF:SetFontSize(fontString, ...)
end

---get the UIObject of type 'FontString' named fontString and set the font to the argument fontface
---@param self table
---@param fontString fontstring
---@param fontface string
function DF:SetFontFace(fontString, fontface)
Expand All @@ -911,24 +923,26 @@ function DF:SetFontFace(fontString, fontface)
end

---get the FontString passed and set the font color
---@param self table
---@param fontString fontstring
---@param r any
---@param g number|nil
---@param b number|nil
---@param a number|nil
---@param g number?
---@param b number?
---@param a number?
function DF:SetFontColor(fontString, r, g, b, a)
r, g, b, a = DF:ParseColors(r, g, b, a)
fontString:SetTextColor(r, g, b, a)
end

---get the FontString passed and set the font shadow color and offset
---@param self table
---@param fontString fontstring
---@param r number
---@param g number
---@param b number
---@param a number
---@param x number
---@param y number
---@param r any
---@param g number?
---@param b number?
---@param a number?
---@param x number?
---@param y number?
function DF:SetFontShadow(fontString, r, g, b, a, x, y)
r, g, b, a = DF:ParseColors(r, g, b, a)
fontString:SetShadowColor(r, g, b, a)
Expand All @@ -941,6 +955,7 @@ function DF:SetFontShadow(fontString, r, g, b, a, x, y)
end

---get the FontString object passed and set the rotation of the text shown
---@param self table
---@param fontString fontstring
---@param degrees number
function DF:SetFontRotation(fontString, degrees)
Expand All @@ -958,6 +973,7 @@ function DF:SetFontRotation(fontString, degrees)
end

---receives a string and a color and return the string wrapped with the color using |c and |r scape codes
---@param self table
---@param text string
---@param color any
---@return string
Expand All @@ -975,6 +991,7 @@ function DF:AddColorToText(text, color) --wrap text with a color
end

---receives a string 'text' and a class name and return the string wrapped with the class color using |c and |r scape codes
---@param self table
---@param text string
---@param className string
---@return string
Expand All @@ -997,6 +1014,7 @@ function DF:AddClassColorToText(text, className)
end

---create a string with the spell icon and the spell name using |T|t scape codes to add the icon inside the string
---@param self table
---@param spellId any
---@return string
function DF:MakeStringFromSpellId(spellId)
Expand Down Expand Up @@ -3401,6 +3419,11 @@ end
-----------------------------
--animations

---create an animation 'hub' which is an animationGroup but with some extra functions
---@param parent uiobject
---@param onPlay function?
---@param onFinished function?
---@return animationgroup
function DF:CreateAnimationHub(parent, onPlay, onFinished)
local newAnimation = parent:CreateAnimationGroup()
newAnimation:SetScript("OnPlay", onPlay)
Expand Down Expand Up @@ -3443,6 +3466,38 @@ function DF:CreateAnimation(animation, animationType, order, duration, arg1, arg
return anim
end

---receives an uiobject, when its parent get hover overed, starts the fade in animation
---start the fade out animation when the mouse leaves the parent
---@param UIObject uiobject
---@param fadeInTime number
---@param fadeOutTime number
---@param fadeInAlpha number
---@param fadeOutAlpha number
function DF:CreateFadeAnimation(UIObject, fadeInTime, fadeOutTime, fadeInAlpha, fadeOutAlpha)
fadeInTime = fadeInTime or 0.1
fadeOutTime = fadeOutTime or 0.1
fadeInAlpha = fadeInAlpha or 1
fadeOutAlpha = fadeOutAlpha or 0

local fadeInAnimationHub = DF:CreateAnimationHub(UIObject, function() UIObject:Show(); UIObject:SetAlpha(fadeOutAlpha) end, function() UIObject:SetAlpha(fadeInAlpha) end)
local fadeIn = DF:CreateAnimation(fadeInAnimationHub, "Alpha", 1, fadeInTime, fadeOutAlpha, fadeInAlpha)

local fadeOutAnimationHub = DF:CreateAnimationHub(UIObject, nil, function() UIObject:Hide(); UIObject:SetAlpha(0) end)
local fadeOut = DF:CreateAnimation(fadeOutAnimationHub, "Alpha", 2, fadeOutTime, fadeInAlpha, fadeOutAlpha)

local scriptFrame
--hook the parent OnEnter and OnLeave
if (UIObject:IsObjectType("FontString") or UIObject:IsObjectType("Texture")) then
scriptFrame = UIObject:GetParent()
else
scriptFrame = UIObject
end

---@cast scriptFrame frame
scriptFrame:HookScript("OnEnter", function() fadeOutAnimationHub:Stop(); fadeInAnimationHub:Play() end)
scriptFrame:HookScript("OnLeave", function() fadeInAnimationHub:Stop(); fadeOutAnimationHub:Play() end)
end

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--frame shakes

Expand Down Expand Up @@ -3475,7 +3530,6 @@ FrameshakeUpdateFrame:SetScript("OnUpdate", function(self, deltaTime)
end
end)


local frameshake_ShakeFinished = function(parent, shakeObject)
if (shakeObject.IsPlaying) then
shakeObject.IsPlaying = false
Expand Down Expand Up @@ -3545,7 +3599,6 @@ frameshake_DoUpdate = function(parent, shakeObject, deltaTime)
local scaleShake = min(shakeObject.IsFadingIn and (shakeObject.IsFadingInTime / shakeObject.FadeInTime) or 1, shakeObject.IsFadingOut and (1 - shakeObject.IsFadingOutTime / shakeObject.FadeOutTime) or 1)

if (scaleShake > 0) then

--delate the time by the frequency on both X and Y offsets
shakeObject.XSineOffset = shakeObject.XSineOffset + (deltaTime * shakeObject.Frequency)
shakeObject.YSineOffset = shakeObject.YSineOffset + (deltaTime * shakeObject.Frequency)
Expand Down Expand Up @@ -3577,12 +3630,9 @@ frameshake_DoUpdate = function(parent, shakeObject, deltaTime)

elseif (#anchor == 5) then
local anchorName1, anchorTo, anchorName2, point1, point2 = unpack(anchor)
--parent:ClearAllPoints()

parent:SetPoint(anchorName1, anchorTo, anchorName2, point1 + newX, point2 + newY)
end
end

end
else
frameshake_ShakeFinished(parent, shakeObject)
Expand Down Expand Up @@ -3666,7 +3716,7 @@ local frameshake_play = function(parent, shakeObject, scaleDirection, scaleAmpli
frameshake_DoUpdate(parent, shakeObject)
end

local frameshake_SetConfig = function(parent, shakeObject, duration, amplitude, frequency, absoluteSineX, absoluteSineY, scaleX, scaleY, fadeInTime, fadeOutTime, anchorPoints)
local frameshake_SetConfig = function(parent, shakeObject, duration, amplitude, frequency, absoluteSineX, absoluteSineY, scaleX, scaleY, fadeInTime, fadeOutTime)
shakeObject.Amplitude = amplitude or shakeObject.Amplitude
shakeObject.Frequency = frequency or shakeObject.Frequency
shakeObject.Duration = duration or shakeObject.Duration
Expand All @@ -3690,8 +3740,41 @@ local frameshake_SetConfig = function(parent, shakeObject, duration, amplitude,
shakeObject.OriginalDuration = shakeObject.Duration
end

---@class frameshake : table
---@field Amplitude number
---@field Frequency number
---@field Duration number
---@field FadeInTime number
---@field FadeOutTime number
---@field ScaleX number
---@field ScaleY number
---@field AbsoluteSineX boolean
---@field AbsoluteSineY boolean
---@field IsPlaying boolean
---@field TimeLeft number
---@field OriginalScaleX number
---@field OriginalScaleY number
---@field OriginalFrequency number
---@field OriginalAmplitude number
---@field OriginalDuration number
---@field PlayFrameShake fun(parent:uiobject, shakeObject:frameshake, scaleDirection:number?, scaleAmplitude:number?, scaleFrequency:number?, scaleDuration:number?)
---@field StopFrameShake fun(parent:uiobject, shakeObject:frameshake)
---@field SetFrameShakeSettings fun(parent:uiobject, shakeObject:frameshake, duration:number?, amplitude:number?, frequency:number?, absoluteSineX:boolean?, absoluteSineY:boolean?, scaleX:number?, scaleY:number?, fadeInTime:number?, fadeOutTime:number?)

---create a frame shake object
---@param parent uiobject
---@param duration number?
---@param amplitude number?
---@param frequency number?
---@param absoluteSineX boolean?
---@param absoluteSineY boolean?
---@param scaleX number?
---@param scaleY number?
---@param fadeInTime number?
---@param fadeOutTime number?
---@param anchorPoints table?
---@return frameshake
function DF:CreateFrameShake(parent, duration, amplitude, frequency, absoluteSineX, absoluteSineY, scaleX, scaleY, fadeInTime, fadeOutTime, anchorPoints)

--create the shake table
local frameShake = {
Amplitude = amplitude or 2,
Expand Down
Loading

0 comments on commit 0b32fe3

Please sign in to comment.