Skip to content

Commit

Permalink
Inherit from a regular ScaledTexture
Browse files Browse the repository at this point in the history
To prevent further issues down the line
  • Loading branch information
justalemon committed Dec 19, 2023
1 parent 328fbff commit a18842e
Showing 1 changed file with 5 additions and 47 deletions.
52 changes: 5 additions & 47 deletions LemonUI/Elements/ScaledAnim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ namespace LemonUI.Elements
/// <summary>
/// A scaled animation using YTD files with all of the frames.
/// </summary>
public class ScaledAnim : BaseElement
public class ScaledAnim : ScaledTexture
{
#region Fields

private readonly ScaledTexture texture = new ScaledTexture(string.Empty, string.Empty);
private float frameRate;
private int start = 0;
private int duration;
Expand All @@ -30,46 +29,6 @@ public class ScaledAnim : BaseElement

#region Properties

/// <summary>
/// The position of this animation.
/// </summary>
public override PointF Position
{
get => texture.Position;
set => texture.Position = value;
}
/// <summary>
/// The size of this animation.
/// </summary>
public override SizeF Size
{
get => texture.Size;
set => texture.Size = value;
}
/// <summary>
/// The color of this animation.
/// </summary>
public override Color Color
{
get => texture.Color;
set => texture.Color = value;
}
/// <summary>
/// The rotation of this animation.
/// </summary>
public override float Heading
{
get => texture.Heading;
set => texture.Heading = value;
}
/// <summary>
/// The dictionary that contains the textures.
/// </summary>
public string Dictionary
{
get => texture.Dictionary;
set => texture.Dictionary = value ?? throw new ArgumentNullException(nameof(value));
}
/// <summary>
/// The total number of frames per second.
/// </summary>
Expand Down Expand Up @@ -121,17 +80,16 @@ public ScaledAnim(string dict) : this(dict, PointF.Empty, SizeF.Empty)
/// <param name="size">The size of the animation.</param>
public ScaledAnim(string dict, SizeF size) : this(dict, PointF.Empty, size)
{
texture.Dictionary = dict ?? throw new ArgumentNullException(nameof(dict));
}
/// <summary>
/// Creates a new dictionary based animation.
/// </summary>
/// <param name="dict">The texture dictionary (YTD) to use.</param>
/// <param name="pos">The position of the animation.</param>
/// <param name="size">The size of the animation.</param>
public ScaledAnim(string dict, PointF pos, SizeF size) : base(pos, size)
public ScaledAnim(string dict, PointF pos, SizeF size) : base(pos, size, dict, string.Empty)
{
texture.Dictionary = dict ?? throw new ArgumentNullException(nameof(dict));
Dictionary = dict ?? throw new ArgumentNullException(nameof(dict));
}

#endregion
Expand Down Expand Up @@ -168,9 +126,9 @@ public override void Draw()
float progress = (time - (float)start) / Duration;
int totalFrames = (int)((duration / 1000.0f) * frameRate);
int currentFrame = (int)(totalFrames * progress);
texture.Texture = currentFrame.ToString();
Texture = currentFrame.ToString();

texture.Draw();
base.Draw();
}

#endregion
Expand Down

0 comments on commit a18842e

Please sign in to comment.