From da670af17151f4475c9446a93c6419c05f62bb40 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Thu, 2 Nov 2023 02:39:14 -0700 Subject: [PATCH] Fix not restoring images of restored states --- SpaceWizards.RsiLib/RSI/Rsi.cs | 2 +- SpaceWizards.RsiLib/RSI/RsiState.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/SpaceWizards.RsiLib/RSI/Rsi.cs b/SpaceWizards.RsiLib/RSI/Rsi.cs index 45e3d48..0844459 100644 --- a/SpaceWizards.RsiLib/RSI/Rsi.cs +++ b/SpaceWizards.RsiLib/RSI/Rsi.cs @@ -115,7 +115,7 @@ public void SaveImagesToFolder(string rsiFolder) var image = state.GetFullImage(Size); var path = Path.Combine(rsiFolder, $"{state.Name}.png"); - if (state.ImagePath == null) + if (state.ImagePath == null || !File.Exists(state.ImagePath)) { image.SaveAsPng(path); } diff --git a/SpaceWizards.RsiLib/RSI/RsiState.cs b/SpaceWizards.RsiLib/RSI/RsiState.cs index a2960c1..118fda6 100644 --- a/SpaceWizards.RsiLib/RSI/RsiState.cs +++ b/SpaceWizards.RsiLib/RSI/RsiState.cs @@ -63,7 +63,7 @@ public RsiState() : this("", DirectionType.None, null, null, null) public List>? Delays { get; set; } public Dictionary? Flags { get; set; } - + /// /// The path of the image to be copied when saving this state. /// @@ -175,7 +175,7 @@ public void LoadGif(Image image) DelayLength = image.Frames.Count; Delays = new List> { new() }; Frames = new Image[8, DelayLength]; - + for (var frame = 0; frame < DelayLength; frame++) { var frameImage = image.Frames.CloneFrame(frame); @@ -186,7 +186,7 @@ public void LoadGif(Image image) Frames[0, frame] = frameImage; } } - + public void LoadImage(Image image, RsiSize size) { var currentX = 0; @@ -221,4 +221,4 @@ public void Dispose() Array.Clear(Frames, 0, Frames.Length); } -} \ No newline at end of file +}