Skip to content

Commit

Permalink
Added support for already-processed images.
Browse files Browse the repository at this point in the history
  • Loading branch information
LittlePox committed Feb 25, 2020
1 parent 36065c1 commit c8a0a00
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 20 deletions.
36 changes: 34 additions & 2 deletions EasyScrShot/HelperLib/Info.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Linq;

namespace EasyScrShot.HelperLib
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
}
}
2 changes: 1 addition & 1 deletion EasyScrShot/HelperLib/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace EasyScrShot.HelperLib
{
public enum From {avs, vs};
public enum From {avs, vs, processed};

public static class Utility
{
Expand Down
40 changes: 24 additions & 16 deletions EasyScrShot/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void LoadFile()
try
{
GetPNG();
if (N > 0)
if (Result.Length > 0)
{
DecidingInfo();
MatchPNG();
Expand All @@ -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<Frame>();
int k = 0;
bool flag = true;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion EasyScrShot/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.*")]

0 comments on commit c8a0a00

Please sign in to comment.