Looped animations support

master
1987kostya 4 years ago
parent 8bcb0cd8a9
commit b93af88058

@ -650,10 +650,20 @@ namespace DotNetCTFDumper.GUI
} }
} }
} }
private bool breakAnim;
private bool isAnimRunning;
private void advancedPlayAnimation_Click(object sender, EventArgs e) private void advancedPlayAnimation_Click(object sender, EventArgs e)
{ {
if (((ChunkNode) advancedTreeView.SelectedNode).loader is Animation anim) if (((ChunkNode) advancedTreeView.SelectedNode).loader is Animation anim)
{ {
if (isAnimRunning)
{
breakAnim = true;
}
else
{
isAnimRunning = true;
var animThread = new Thread(PlayAnimation); var animThread = new Thread(PlayAnimation);
List<Bitmap> frames = new List<Bitmap>(); List<Bitmap> frames = new List<Bitmap>();
foreach (var dir in anim.DirectionDict) foreach (var dir in anim.DirectionDict)
@ -664,6 +674,9 @@ namespace DotNetCTFDumper.GUI
} }
animThread.Start(new Tuple<List<Bitmap>,AnimationDirection>(frames,dir.Value)); animThread.Start(new Tuple<List<Bitmap>,AnimationDirection>(frames,dir.Value));
} }
}
} }
@ -674,13 +687,43 @@ namespace DotNetCTFDumper.GUI
var (frames,anim) = (Tuple<List<Bitmap>,AnimationDirection>) o; var (frames,anim) = (Tuple<List<Bitmap>,AnimationDirection>) o;
var fps = (float)anim.MaxSpeed; var fps = (float)anim.MaxSpeed;
float delay = 1f/fps; float delay = 1f/fps;
Console.WriteLine((int) (delay*1200)); int i = 0;
if (anim.Repeat > 0)
{
foreach (Bitmap frame in frames) foreach (Bitmap frame in frames)
{ {
advancedPictureBox.Image = frame; advancedPictureBox.Image = frame;
advancedInfoLabel.Text = $"Current frame: {frames.IndexOf(frame)}\nAnimation Speed: {fps}"; advancedInfoLabel.Text = $"Current frame: {frames.IndexOf(frame)}\nAnimation Speed: {fps}";
Thread.Sleep((int) (delay*1500)); Thread.Sleep((int) (delay*1500));
} }
isAnimRunning = false;
Thread.CurrentThread.Abort();
}
else
{
while (true)
{
var frame = frames[i];
advancedPictureBox.Image = frame;
advancedInfoLabel.Text = $"Current frame: {i.ToString()}\nAnimation Speed: {fps}";
Thread.Sleep((int) (delay*1500));
i++;
if (i == frames.Count) i = 0;
if (breakAnim)
{
isAnimRunning = false;
breakAnim = false;
Thread.CurrentThread.Abort();
break;
}
}
}
//Limited
} }

@ -1,5 +1,4 @@
using System.IO; using System.IO;
using DotNetCTFDumper.Utils;
namespace DotNetCTFDumper namespace DotNetCTFDumper
{ {
@ -32,12 +31,6 @@ namespace DotNetCTFDumper
public static bool DoMFA; public static bool DoMFA;
public static bool UseGUI; public static bool UseGUI;
public static string DumperVersion = "CTFAN 0.1.1-c Debug"; public static string DumperVersion = "CTFAN 0.1.5-a Debug";
public static byte[] EncryptionKey=>Decryption.DecryptionKey;
} }
} }
Loading…
Cancel
Save