Skip to content

Commit

Permalink
Improvements for the Ask to Erase Data and more development on End of…
Browse files Browse the repository at this point in the history
… M+ panel
  • Loading branch information
Tercioo committed Feb 18, 2024
1 parent cd8266f commit 2ca4c01
Show file tree
Hide file tree
Showing 10 changed files with 680 additions and 176 deletions.
31 changes: 31 additions & 0 deletions Definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,36 @@
---| "PLAYER_TARGET"
---| "DETAILS_PROFILE_APPLYED"

---@class mythicdungeoninfo
---@field StartedAt number
---@field EndedAt number
---@field WorldStateTimerStart number
---@field WorldStateTimerEnd number
---@field RunTime number
---@field TimeInCombat number
---@field SegmentID string
---@field RunID number
---@field OverallSegment boolean
---@field ZoneName string
---@field EJID number
---@field MapID number
---@field Level number
---@field OnTime boolean
---@field KeystoneUpgradeLevels number
---@field PracticeRun boolean
---@field OldDungeonScore number
---@field NewDungeonScore number
---@field IsAffixRecord boolean
---@field IsMapRecord boolean
---@field PrimaryAffix number
---@field IsEligibleForScore boolean
---@field UpgradeMembers table
---@field TimeLimit number
---@field DungeonName string
---@field DungeonID number
---@field DungeonTexture string
---@field DungeonBackgroundTexture string|number

---@alias containertype number this container type is the number used to identify the actorcontainer type when using combat:GetContainer(containertype), can be 1, 2, 3, or 4.

---@alias actorclass string this is the class of the actor, can be "WARRIOR", "PALADIN", "HUNTER", "ROGUE", "PRIEST", "DEATHKNIGHT", "SHAMAN", "MAGE", "WARLOCK", "MONK", "DRUID", "DEMONHUNTER"
Expand Down Expand Up @@ -86,6 +116,7 @@
---@field CreateEventListener fun(self: details) : table
---@field GetFullName fun(self: details, unitId: any, ambiguateString: any) : string create a CLEU compatible name of the unit passed, return string is in the format "playerName-realmName", the string will also be ambiguated using the ambiguateString passed
---@field GetTextColor fun(self:actor, instanceObject: instance, textSide: string) : number, number, number, number
---@field GetCombatSegments fun(self: details) : combat[] return a table with all the combat segments

---@class detailseventlistener : table
---@field RegisterEvent fun(self: detailseventlistener, event: detailsevent, callback: function)
Expand Down
7 changes: 5 additions & 2 deletions Libs/DF/definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,18 @@
---@field GetColorHue fun(self:table, r:number, g:number, b:number) : number return the hue of a color from red to blue to green to yellow and back to red
---@field IsHtmlColor fun(self:table, colorName:any) : unknown return true if DF.alias_text_colors has the colorName as a key
---@field CreateColorTable fun(self:table, r:number, g:number, b:number, a:number) : table return a table with {r, g, b, a}
---@field FormatColor fun(self:table, newFormat:string, r:number|string, g:number?, b:number?, a:number?, decimalsAmount:number?) : string|table|number|nil, number|nil, number|nil, number|nil takes in a color in one format and converts it to another specified format.
---@field FormatColor fun(self:table, newFormat:string, r:number|string|table, g:number?, b:number?, a:number?, decimalsAmount:number?) : string|table|number|nil, number|nil, number|nil, number|nil takes in a color in one format and converts it to another specified format.
---@field CreateEditor fun(self:table, parent:frame, name:string?, options:df_editor_defaultoptions?) : df_editor
---@field RandomBool fun(self:table, odds: number?) : boolean return a random boolean
---@field CreateHighlightTexture fun(self:table, parent:frame, parentKey:string?, alpha:number?, name:string?) : texture
---@field CreateIconRowGeneric fun(self:table, parent:frame, name:string?, options:table?)
---@field CreateColorPickButton fun(self:table, parent:frame, name:string?, member:string?, callback:function, alpha:number?, buttonTemplate:table?) : df_button
---@field CreateSlider fun(self:table, parent:frame, width:number?, height:number?, minValue:number?, maxValue:number?, step:number?, defaultv:number?, isDecemal:boolean?, member:string?, name:string?, label:string?, sliderTemplate:string|table?, labelTemplate:string|table?) : df_slider, df_label?
---@field CreateFrameContainer fun(self:table, parent:frame, options:table?, frameName:string?) : df_framecontainer create a frame container, which is a frame that envelops another frame, and can be moved, resized, etc.
---@field
---@field CreateAnimation fun(self:table, animationGroup:animationgroup, animationType:animationtype, order:number, duration:number, arg1:any, arg2:any, arg3:any, arg4:any, arg5:any, arg6:any, arg7:any, arg8:any) : animation
---@field CreateTexture fun(self:table, parent:frame, texture:atlasname|texturepath|textureid|nil, width:number?, height:number?, layer:drawlayer?, coords:table?, member:string?, name:string?) : df_image
---@field CreateFrameShake fun(self:table, parent:uiobject, duration:number?, amplitude:number?, frequency:number?, absoluteSineX:boolean?, absoluteSineY:boolean?, scaleX:number?, scaleY:number?, fadeInTime:number?, fadeOutTime:number?, anchorPoints:table?) : df_frameshake
---@field SetTexCoordFromAtlasInfo fun(self:table, texture:texture, atlasInfo:atlasinfo) : nil
---@field


91 changes: 70 additions & 21 deletions Libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


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

Expand Down Expand Up @@ -522,6 +522,10 @@ function DF:RandomBool(odds)
end
end

function DF:SetTexCoordFromAtlasInfo(texture, atlasInfo)
texture:SetTexCoord(atlasInfo.leftTexCoord, atlasInfo.rightTexCoord, atlasInfo.topTexCoord, atlasInfo.bottomTexCoord)
end

------------------------------------------------------------------------------------------------------------
--table

Expand Down Expand Up @@ -2061,16 +2065,16 @@ end
IsColorTable = true,
}

--takes in a color in one format and converts it to another specified format.
--here are the parameters it accepts:
--newFormat (string): The format to convert the color to. It can be one of the following: "commastring", "tablestring", "table", "tablemembers", "numbers", "hex".
--r (number|string): The red component of the color or a string representing the color.
--g (number|nil): The green component of the color. This is optional if r is a string.
--b (number|nil): The blue component of the color. This is optional if r is a string.
--a (number|nil): The alpha component of the color. This is optional and defaults to 1 if not provided.
--decimalsAmount (number|nil): The number of decimal places to round the color components to. This is optional and defaults to 4 if not provided.
--The function returns the color in the new format. The return type depends on the newFormat parameter. It can be a string, a table, or four separate number values (for the "numbers" format).
--For the "hex" format, it returns a string representing the color in hexadecimal format.
---* takes in a color in one format and converts it to another specified format.
---* here are the parameters it accepts:
---* newFormat (string): The format to convert the color to. It can be one of the following: "commastring", "tablestring", "table", "tablemembers", "numbers", "hex".
---* r (number|string): The red component of the color or a string representing the color.
---* g (number|nil): The green component of the color. This is optional if r is a string.
---* b (number|nil): The blue component of the color. This is optional if r is a string.
---* a (number|nil): The alpha component of the color. This is optional and defaults to 1 if not provided.
---* decimalsAmount (number|nil): The number of decimal places to round the color components to. This is optional and defaults to 4 if not provided.
---* The function returns the color in the new format. The return type depends on the newFormat parameter. It can be a string, a table, or four separate number values (for the "numbers" format).
---* For the "hex" format, it returns a string representing the color in hexadecimal format.
---@param newFormat string
---@param r number|string
---@param g number|nil
Expand Down Expand Up @@ -2844,9 +2848,30 @@ function DF:CreateAnimationHub(parent, onPlay, onFinished)
return newAnimation
end

function DF:CreateAnimation(animation, animationType, order, duration, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
local anim = animation:CreateAnimation(animationType)
anim:SetOrder(order or animation.NextAnimation)
---* Create a new animation for an animation hub or group.
---* Alpha: CreateAnimation(animGroup, "Alpha", order, duration, fromAlpha, toAlpha).
---* Scale: CreateAnimation(animGroup, "Scale", order, duration, fromScaleX, fromScaleY, toScaleX, toScaleY, originPoint, x, y).
---* Translation: CreateAnimation(animGroup, "Translation", order, duration, xOffset, yOffset).
---* Rotation: CreateAnimation(animGroup, "Rotation", order, duration, degrees, originPoint, x, y).
---* Path: CreateAnimation(animGroup, "Path", order, duration, xOffset, yOffset, curveType).
---* VertexColor: CreateAnimation(animGroup, "VertexColor", order, duration, r1, g1, b1, a1, r2, g2, b2, a2).
---@param animationGroup animationgroup
---@param animationType animationtype
---@param order number
---@param duration number
---@param arg1 any
---@param arg2 any
---@param arg3 any
---@param arg4 any
---@param arg5 any
---@param arg6 any
---@param arg7 any
---@param arg8 any
---@return animation
function DF:CreateAnimation(animationGroup, animationType, order, duration, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
---@type animation
local anim = animationGroup:CreateAnimation(animationType)
anim:SetOrder(order or animationGroup.NextAnimation)
anim:SetDuration(duration)

animationType = string.upper(animationType)
Expand All @@ -2871,9 +2896,33 @@ function DF:CreateAnimation(animation, animationType, order, duration, arg1, arg

elseif (animationType == "TRANSLATION") then
anim:SetOffset(arg1, arg2)

elseif (animationType == "PATH") then
local newControlPoint = anim:CreateControlPoint()
anim:SetCurveType(arg4 or "SMOOTH")
newControlPoint:SetOffset(arg2, arg3)
newControlPoint:SetOrder(#anim:GetControlPoints())

elseif (animationType == "VERTEXCOLOR" or animationType == "COLOR") then
local r1, g1, b1, a1 = arg1, arg2, arg3, arg4
local r2, g2, b2, a2 = arg5, arg6, arg7, arg8

if ((type(r1) == "table" or type(r1) == "string") and (type(g1) == "table" or type(g1) == "string")) then
r2, g2, b2, a2 = DF:ParseColors(g1)
r1, g1, b1, a1 = DF:ParseColors(r1)

elseif ((type(r1) == "table" or type(r1) == "string")) then
r1, g1, b1, a1 = DF:ParseColors(r1)

elseif ((type(r2) == "table" or type(r2) == "string")) then
r2, g2, b2, a2 = DF:ParseColors(r2)
end

anim:SetStartColor(CreateColor(r1, g1, b1, a1))
anim:SetEndColor(CreateColor(r2, g2, b2, a2))
end

animation.NextAnimation = animation.NextAnimation + 1
animationGroup.NextAnimation = animationGroup.NextAnimation + 1
return anim
end

Expand Down Expand Up @@ -3117,7 +3166,7 @@ local frameshake_play = function(parent, shakeObject, scaleDirection, scaleAmpli
--update the amount of shake running on this frame
parent.__frameshakes.enabled = parent.__frameshakes.enabled + 1

if (not parent:GetScript("OnUpdate")) then
if (parent:HasScript("OnUpdate")) then
parent:SetScript("OnUpdate", function()end)
end
end
Expand Down Expand Up @@ -3151,7 +3200,7 @@ local frameshake_SetConfig = function(parent, shakeObject, duration, amplitude,
shakeObject.OriginalDuration = shakeObject.Duration
end

---@class frameshake : table
---@class df_frameshake : table
---@field Amplitude number
---@field Frequency number
---@field Duration number
Expand All @@ -3168,9 +3217,9 @@ end
---@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?)
---@field PlayFrameShake fun(parent:uiobject, shakeObject:df_frameshake, scaleDirection:number?, scaleAmplitude:number?, scaleFrequency:number?, scaleDuration:number?)
---@field StopFrameShake fun(parent:uiobject, shakeObject:df_frameshake)
---@field SetFrameShakeSettings fun(parent:uiobject, shakeObject:df_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
Expand All @@ -3184,7 +3233,7 @@ end
---@param fadeInTime number?
---@param fadeOutTime number?
---@param anchorPoints table?
---@return frameshake
---@return df_frameshake
function DF:CreateFrameShake(parent, duration, amplitude, frequency, absoluteSineX, absoluteSineY, scaleX, scaleY, fadeInTime, fadeOutTime, anchorPoints)
--create the shake table
local frameShake = {
Expand Down
114 changes: 83 additions & 31 deletions Libs/DF/picture.lua
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,16 @@ detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.ScriptHookMixin)
end
end

function ImageMetaFunctions:SetGradient(gradientType, fromColor, toColor)
function ImageMetaFunctions:SetGradient(gradientType, fromColor, toColor, bInvert)
fromColor = detailsFramework:FormatColor("tablemembers", fromColor)
toColor = detailsFramework:FormatColor("tablemembers", toColor)

if (bInvert) then
local temp = fromColor
fromColor = toColor
toColor = temp
end

self.image:SetGradient(gradientType, fromColor, toColor)
end

Expand All @@ -238,34 +245,50 @@ detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.ScriptHookMixin)
---@class df_image : texture
---@field SetGradient fun(gradientType: "vertical"|"horizontal", fromColor: table, toColor: table)

---@class df_gradienttable : table
---@field gradient "vertical"|"horizontal"
---@field fromColor table|string
---@field toColor table|string
---@field invert boolean?

---create an object that encapsulates a texture and add additional methods to it
---@param parent frame
---@param texture texturepath|textureid
---@param width number
---@param height number
---@param layer drawlayer
---@param coords {key1: number, key2: number, key3: number, key4: number}
---@param member string
---@param name string
---@return table|nil
---@param texture texturepath|textureid|df_gradienttable|nil
---@param width number?
---@param height number?
---@param layer drawlayer?
---@param coords {key1: number, key2: number, key3: number, key4: number}?
---@param member string?
---@param name string?
---@return df_image
function detailsFramework:CreateTexture(parent, texture, width, height, layer, coords, member, name)
return detailsFramework:NewImage(parent, texture, width, height, layer, coords, member, name)
end

---create an object that encapsulates a texture and add additional methods to it
---@param parent frame
---@param texture texturepath|textureid
---@param width number
---@param height number
---@param layer drawlayer
---@param coords {key1: number, key2: number, key3: number, key4: number}
---@param member string
---@param name string
---@return table|nil
---@param texture texturepath|textureid|df_gradienttable|nil
---@param width number?
---@param height number?
---@param layer drawlayer?
---@param coords {key1: number, key2: number, key3: number, key4: number}?
---@param member string?
---@param name string?
---@return df_image
function detailsFramework:CreateImage(parent, texture, width, height, layer, coords, member, name)
return detailsFramework:NewImage(parent, texture, width, height, layer, coords, member, name)
end

---create an object that encapsulates a texture and add additional methods to it
---@param parent frame
---@param texture texturepath|textureid|df_gradienttable|nil
---@param width number?
---@param height number?
---@param layer drawlayer?
---@param texCoord {key1: number, key2: number, key3: number, key4: number}?
---@param member string?
---@param name string?
---@return df_image
function detailsFramework:NewImage(parent, texture, width, height, layer, texCoord, member, name)
if (not parent) then
return error("DetailsFrameWork: NewImage() parent not found.", 2)
Expand Down Expand Up @@ -313,26 +336,45 @@ detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.ScriptHookMixin)

ImageObject.image.MyObject = ImageObject

if (width) then
ImageObject.image:SetWidth(width)
end
if (height) then
ImageObject.image:SetHeight(height)
end

if (texture) then
if (type(texture) == "table") then
if (texture.gradient) then
---@type df_gradienttable
local gradientTable = texture

if (detailsFramework.IsDragonflight() or detailsFramework.IsNonRetailWowWithRetailAPI()) then
ImageObject.image:SetColorTexture(1, 1, 1, 1)
local fromColor = detailsFramework:FormatColor("tablemembers", texture.fromColor)
local toColor = detailsFramework:FormatColor("tablemembers", texture.toColor)
ImageObject.image:SetGradient(texture.gradient, fromColor, toColor)
local fromColor = detailsFramework:FormatColor("tablemembers", gradientTable.fromColor)
local toColor = detailsFramework:FormatColor("tablemembers", gradientTable.toColor)

if (gradientTable.invert) then
local temp = fromColor
fromColor = toColor
toColor = temp
end

ImageObject.image:SetGradient(gradientTable.gradient, fromColor, toColor)
else
local fromR, fromG, fromB, fromA = detailsFramework:ParseColors(texture.fromColor)
local toR, toG, toB, toA = detailsFramework:ParseColors(texture.toColor)
local fromR, fromG, fromB, fromA = detailsFramework:ParseColors(gradientTable.fromColor)
local toR, toG, toB, toA = detailsFramework:ParseColors(gradientTable.toColor)

if (gradientTable.invert) then
local temp = fromR
fromR = toR
toR = temp
temp = fromG
fromG = toG
toG = temp
temp = fromB
fromB = toB
toB = temp
temp = fromA
fromA = toA
toA = temp
end

ImageObject.image:SetColorTexture(1, 1, 1, 1)
ImageObject.image:SetGradientAlpha(texture.gradient, fromR, fromG, fromB, fromA, toR, toG, toB, toA)
ImageObject.image:SetGradientAlpha(gradientTable.gradient, fromR, fromG, fromB, fromA, toR, toG, toB, toA)
end
else
local r, g, b, a = detailsFramework:ParseColors(texture)
Expand All @@ -352,14 +394,24 @@ detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.ScriptHookMixin)
end
end
else
ImageObject.image:SetTexture(texture)
local textureType = type(texture)
if (textureType == "string" or textureType == "number") then
ImageObject.image:SetTexture(texture)
end
end
end

if (texCoord and type(texCoord) == "table" and texCoord[4]) then
ImageObject.image:SetTexCoord(unpack(texCoord))
end

if (width) then
ImageObject.image:SetWidth(width)
end
if (height) then
ImageObject.image:SetHeight(height)
end

ImageObject.HookList = {
}

Expand Down
Loading

0 comments on commit 2ca4c01

Please sign in to comment.