|
5 | 5 |
|
6 | 6 | namespace ProjectStarlight.Interchange |
7 | 7 | { |
8 | | - // TODO: GIF looping |
| 8 | + /// <summary> |
| 9 | + /// Simple class containing GIF data for drawing and updating. |
| 10 | + /// </summary> |
9 | 11 | public class TextureGIF |
10 | 12 | { |
| 13 | + /// <summary> |
| 14 | + /// The width of the GIF. |
| 15 | + /// </summary> |
11 | 16 | public int Width { get; private set; } |
12 | 17 |
|
| 18 | + /// <summary> |
| 19 | + /// The height of the GIF. |
| 20 | + /// </summary> |
13 | 21 | public int Height { get; private set; } |
14 | 22 |
|
| 23 | + /// <summary> |
| 24 | + /// Whether the GIF is paused. |
| 25 | + /// </summary> |
15 | 26 | public bool IsPaused { get; private set; } |
16 | 27 |
|
| 28 | + /// <summary> |
| 29 | + /// Whether the GIF has ended. Never true of the GIF loops (<seealso cref="ShouldLoop"/>). |
| 30 | + /// </summary> |
17 | 31 | public bool HasEnded => FrameIndex >= Frames.Length && FrameTick >= TicksPerFrame && !ShouldLoop; |
18 | 32 |
|
| 33 | + /// <summary> |
| 34 | + /// Whether the GIF loops. Prevents the GIF from ending unless <seealso cref="Stop"/> is called. |
| 35 | + /// </summary> |
19 | 36 | public bool ShouldLoop { get; set; } |
20 | 37 |
|
| 38 | + /// <summary> |
| 39 | + /// The amount of ticks per frame. Once the tick threshold is reached, goes to a new frame. |
| 40 | + /// </summary> |
21 | 41 | public int TicksPerFrame { get; set; } |
22 | 42 |
|
| 43 | + /// <summary> |
| 44 | + /// The current tick the frame is on. |
| 45 | + /// </summary> |
23 | 46 | public int FrameTick { get; private set; } |
24 | 47 |
|
| 48 | + /// <summary> |
| 49 | + /// The index of <seealso cref="Frames"/> that should be drawn. |
| 50 | + /// </summary> |
25 | 51 | public int FrameIndex { get; private set; } |
26 | 52 |
|
27 | | - public Texture2D[] Frames { get; set; } |
| 53 | + /// <summary> |
| 54 | + /// An array of <seealso cref="Texture2D"/>s representing the frames of a GIF. |
| 55 | + /// </summary> |
| 56 | + public Texture2D[] Frames { get; private set; } |
28 | 57 |
|
| 58 | + /// <summary> |
| 59 | + /// Gets the current frame in accordance to <seealso cref="Frames"/>, using <seealso cref="FrameIndex"/> as the index. |
| 60 | + /// </summary> |
29 | 61 | public Texture2D CurrentFrame => HasEnded ? Frames.Last() : Frames[FrameIndex]; |
30 | 62 |
|
31 | 63 | /// <summary> |
@@ -123,12 +155,18 @@ public void Draw(SpriteBatch spriteBatch, Rectangle destinationRectangle, Rectan |
123 | 155 | spriteBatch.Draw(CurrentFrame, destinationRectangle, sourceRectangle, color, rotation, origin, effects, |
124 | 156 | layerDepth); |
125 | 157 |
|
| 158 | + /// <summary> |
| 159 | + /// Increment ticks by one if the GIF is not paused and has not ended. |
| 160 | + /// </summary> |
126 | 161 | public void UpdateGIF() |
127 | 162 | { |
128 | 163 | if (!IsPaused && !HasEnded) |
129 | 164 | ForwardTicks(1); |
130 | 165 | } |
131 | 166 |
|
| 167 | + /// <summary> |
| 168 | + /// Increments the specified amount of ticks. You can use this to skip frames as well. |
| 169 | + /// </summary> |
132 | 170 | public void ForwardTicks(int tickAmount) |
133 | 171 | { |
134 | 172 | for (int i = 0; i < tickAmount; i++) |
|
0 commit comments