diff --git a/EasyScrShot/HelperLib/Info.cs b/EasyScrShot/HelperLib/Info.cs index bcbc093..a116cf3 100644 --- a/EasyScrShot/HelperLib/Info.cs +++ b/EasyScrShot/HelperLib/Info.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Linq; namespace EasyScrShot.HelperLib @@ -9,6 +10,11 @@ public abstract class Info : ICloneable public abstract bool IsSource(string filename); public abstract string GetIndex(string filename); public abstract bool IsRipped(string filename, string frameId); + + public virtual int GetTotalPairCount(int totalFileCount) + { + return totalFileCount / 2; + } public virtual object Clone() { var clonedCopy = this.MemberwiseClone() as Info; @@ -53,8 +59,6 @@ class VSInfo : Info { public readonly int N=2, s=0, r=1; - private VSInfo() { } - public VSInfo(int N, int s, int r) { from = From.vs; @@ -81,4 +85,32 @@ public override bool IsRipped(string filename, string frameId) return (_frameId / N == int.Parse(frameId)) && (_frameId % N == r); } } + + class ProcessedInfo : Info + { + public ProcessedInfo() + { + from = From.processed; + } + + public override bool IsSource(string filename) + { + return Path.GetFileNameWithoutExtension(filename).All(char.IsDigit); + } + + public override string GetIndex(string filename) + { + return Utility.GetIntStr(filename); + } + + public override bool IsRipped(string filename, string frameId) + { + return filename == frameId + "v.png"; + } + + public override int GetTotalPairCount(int totalFileCount) + { + return totalFileCount / 3; + } + } } diff --git a/EasyScrShot/HelperLib/Utility.cs b/EasyScrShot/HelperLib/Utility.cs index fc6f9bc..aa25bc4 100644 --- a/EasyScrShot/HelperLib/Utility.cs +++ b/EasyScrShot/HelperLib/Utility.cs @@ -3,7 +3,7 @@ namespace EasyScrShot.HelperLib { - public enum From {avs, vs}; + public enum From {avs, vs, processed}; public static class Utility { diff --git a/EasyScrShot/MainWindow.cs b/EasyScrShot/MainWindow.cs index 51b9732..96c7988 100644 --- a/EasyScrShot/MainWindow.cs +++ b/EasyScrShot/MainWindow.cs @@ -59,7 +59,7 @@ private void LoadFile() try { GetPNG(); - if (N > 0) + if (Result.Length > 0) { DecidingInfo(); MatchPNG(); @@ -79,37 +79,40 @@ private void GetPNG() { Result = Directory.GetFiles(Utility.CurrentDir, "*.png"); InfoBoard.Text += $"当前目录有 {Result.Length} 张 PNG 图片。\n"; - if (Result.Length%2 == 1) - { - InfoBoard.Text += $"奇数张图没法继续啊{Utility.GetHelplessEmotion()}\n"; - N = 0; - } - else - { - for (int i = 0; i < Result.Length; i++) - Result[i] = Result[i].Remove(0, Utility.CurrentDir.Length); - N = Result.Length/2; - } + for (int i = 0; i < Result.Length; i++) + Result[i] = Result[i].Remove(0, Utility.CurrentDir.Length); } private void DecidingInfo() { - bool isVpy = Result.Any(item => item.Contains(".vpy")); - if (isVpy) //from vpy + if (Result.Length % 2 == 0 && Result.Any(item => item.Contains(".vpy"))) //from vpy { var popup = new VSInfoWindow(Result); popup.ShowDialog(); - FromInfo = (Info) popup.result.Clone(); + FromInfo = (Info)popup.result.Clone(); popup.Dispose(); } - else + else if ((Result.Length % 2 == 0 && Result.Any(item => item.Contains("src") || item.Contains("source")))) //from avs { FromInfo = new AVSInfo(); + InfoBoard.Text += "看起来是AVS截取的图。\n"; + } + else if (Result.Length % 3 == 0) + { + FromInfo = new ProcessedInfo(); + InfoBoard.Text += "看起来是已经处理过的图。\n"; + InfoBoard.Text += $"如果之前上传失败了,记得去图床手动清理啊{Utility.GetHelplessEmotion()}\n"; + } + else + { + InfoBoard.Text += $"完全不明白你这些图怎么来的{Utility.GetHelplessEmotion()}\n"; + InfoBoard.Text += $"去群里求助下正确使用姿势?\n"; } } private void MatchPNG() { + N = FromInfo.GetTotalPairCount(Result.Length); FList = new List(); int k = 0; bool flag = true; @@ -141,6 +144,11 @@ private void MatchPNG() N = 0; goButton.Enabled = false; } + else if (FromInfo is ProcessedInfo) + { + goButton.Enabled = false; + uploadButton.Enabled = true; + } } private enum OutputType diff --git a/EasyScrShot/Properties/AssemblyInfo.cs b/EasyScrShot/Properties/AssemblyInfo.cs index b71bc18..aa13e8f 100644 --- a/EasyScrShot/Properties/AssemblyInfo.cs +++ b/EasyScrShot/Properties/AssemblyInfo.cs @@ -32,4 +32,4 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.8.*")] +[assembly: AssemblyVersion("2.9.*")]