mirror of
https://github.com/LorisYounger/VPet.ModMaker.git
synced 2024-08-30 18:22:21 +00:00
AnimeEdit 实装 Shutdown StartUP Sleep
This commit is contained in:
parent
c94bafffe6
commit
82904d1321
@ -43,17 +43,6 @@ public class AnimeTypeModel
|
|||||||
IllAnimes.Add(anime.Copy());
|
IllAnimes.Add(anime.Copy());
|
||||||
}
|
}
|
||||||
|
|
||||||
public AnimeTypeModel(GraphInfo.GraphType graphType, string path)
|
|
||||||
{
|
|
||||||
GraphType.Value = graphType;
|
|
||||||
if (graphType is GraphInfo.GraphType.Default)
|
|
||||||
LoadDefault(path);
|
|
||||||
else if (graphType is GraphInfo.GraphType.Touch_Head or GraphInfo.GraphType.Touch_Body)
|
|
||||||
LoadMultiTypeAnime(path);
|
|
||||||
else
|
|
||||||
throw new Exception();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AnimeTypeModel? Create(GraphInfo.GraphType graphType, string path)
|
public static AnimeTypeModel? Create(GraphInfo.GraphType graphType, string path)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -67,31 +56,63 @@ public class AnimeTypeModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AnimeTypeModel(GraphInfo.GraphType graphType, string path)
|
||||||
|
{
|
||||||
|
GraphType.Value = graphType;
|
||||||
|
if (
|
||||||
|
graphType
|
||||||
|
is GraphInfo.GraphType.Default
|
||||||
|
or GraphInfo.GraphType.Shutdown
|
||||||
|
or GraphInfo.GraphType.StartUP
|
||||||
|
)
|
||||||
|
LoadDefault(path);
|
||||||
|
else if (
|
||||||
|
graphType
|
||||||
|
is GraphInfo.GraphType.Touch_Head
|
||||||
|
or GraphInfo.GraphType.Touch_Body
|
||||||
|
or GraphInfo.GraphType.Sleep
|
||||||
|
)
|
||||||
|
LoadMultiType(path);
|
||||||
|
else
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
//private void LoadSingle(string path)
|
||||||
|
//{
|
||||||
|
// foreach (var dir in Directory.EnumerateDirectories(path))
|
||||||
|
// {
|
||||||
|
// var dirName = Path.GetFileName(dir);
|
||||||
|
// var dirInfo = dirName.Split(Utils.Separator);
|
||||||
|
// var mode = Enum.Parse(typeof(GameSave.ModeType), dirInfo[0], true);
|
||||||
|
// if (dirInfo.Length == 2) { }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
private void LoadDefault(string path)
|
private void LoadDefault(string path)
|
||||||
{
|
{
|
||||||
foreach (var dir in Directory.EnumerateDirectories(path))
|
foreach (var dir in Directory.EnumerateDirectories(path))
|
||||||
{
|
{
|
||||||
var mode = Enum.Parse(typeof(GameSave.ModeType), Path.GetFileName(dir), true);
|
var dirName = Path.GetFileName(dir);
|
||||||
if (mode is GameSave.ModeType.Happy)
|
if (dirName.Contains(nameof(GameSave.ModeType.Happy)))
|
||||||
{
|
{
|
||||||
AddAnime(HappyAnimes, dir);
|
AddAnime(HappyAnimes, dir);
|
||||||
}
|
}
|
||||||
else if (mode is GameSave.ModeType.Nomal)
|
else if (dirName.Contains(nameof(GameSave.ModeType.Nomal)))
|
||||||
{
|
{
|
||||||
AddAnime(NomalAnimes, dir);
|
AddAnime(NomalAnimes, dir);
|
||||||
}
|
}
|
||||||
else if (mode is GameSave.ModeType.PoorCondition)
|
else if (dirName.Contains(nameof(GameSave.ModeType.PoorCondition)))
|
||||||
{
|
{
|
||||||
AddAnime(PoorConditionAnimes, dir);
|
AddAnime(PoorConditionAnimes, dir);
|
||||||
}
|
}
|
||||||
else if (mode is GameSave.ModeType.Ill)
|
else if (dirName.Contains(nameof(GameSave.ModeType.Ill)))
|
||||||
{
|
{
|
||||||
AddAnime(IllAnimes, dir);
|
AddAnime(IllAnimes, dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadMultiTypeAnime(string path)
|
private void LoadMultiType(string path)
|
||||||
{
|
{
|
||||||
foreach (var dir in Directory.EnumerateDirectories(path))
|
foreach (var dir in Directory.EnumerateDirectories(path))
|
||||||
{
|
{
|
||||||
@ -182,6 +203,136 @@ public class AnimeTypeModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Save(string path)
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
GraphType.Value
|
||||||
|
is GraphInfo.GraphType.Default
|
||||||
|
or GraphInfo.GraphType.Shutdown
|
||||||
|
or GraphInfo.GraphType.StartUP
|
||||||
|
)
|
||||||
|
SaveDefault(path, this);
|
||||||
|
else if (
|
||||||
|
GraphType.Value
|
||||||
|
is GraphInfo.GraphType.Touch_Head
|
||||||
|
or GraphInfo.GraphType.Touch_Body
|
||||||
|
or GraphInfo.GraphType.Sleep
|
||||||
|
)
|
||||||
|
SaveMultiType(path, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SaveMultiType(string path, AnimeTypeModel animeType)
|
||||||
|
{
|
||||||
|
var animePath = Path.Combine(path, animeType.GraphType.ToString());
|
||||||
|
Directory.CreateDirectory(animePath);
|
||||||
|
if (animeType.HappyAnimes.Count > 0)
|
||||||
|
{
|
||||||
|
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.Happy));
|
||||||
|
SaveAnimes(modePath, animeType.HappyAnimes);
|
||||||
|
}
|
||||||
|
if (animeType.NomalAnimes.Count > 0)
|
||||||
|
{
|
||||||
|
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.Nomal));
|
||||||
|
SaveAnimes(modePath, animeType.NomalAnimes);
|
||||||
|
}
|
||||||
|
if (animeType.PoorConditionAnimes.Count > 0)
|
||||||
|
{
|
||||||
|
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.PoorCondition));
|
||||||
|
SaveAnimes(modePath, animeType.PoorConditionAnimes);
|
||||||
|
}
|
||||||
|
if (animeType.IllAnimes.Count > 0)
|
||||||
|
{
|
||||||
|
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.Ill));
|
||||||
|
SaveAnimes(modePath, animeType.IllAnimes);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SaveAnimes(string animePath, ObservableCollection<AnimeModel> animes)
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(animePath);
|
||||||
|
var countA = 0;
|
||||||
|
var countB = 0;
|
||||||
|
var countC = 0;
|
||||||
|
foreach (var anime in animes)
|
||||||
|
{
|
||||||
|
if (anime.AnimeType.Value is GraphInfo.AnimatType.A_Start)
|
||||||
|
{
|
||||||
|
var animatTypePath = Path.Combine(animePath, "A");
|
||||||
|
Directory.CreateDirectory(animatTypePath);
|
||||||
|
SaveImages(Path.Combine(animatTypePath, countA.ToString()), anime);
|
||||||
|
countA++;
|
||||||
|
}
|
||||||
|
else if (anime.AnimeType.Value is GraphInfo.AnimatType.B_Loop)
|
||||||
|
{
|
||||||
|
var animatTypePath = Path.Combine(animePath, "B");
|
||||||
|
Directory.CreateDirectory(animatTypePath);
|
||||||
|
SaveImages(Path.Combine(animatTypePath, countB.ToString()), anime);
|
||||||
|
countB++;
|
||||||
|
}
|
||||||
|
else if (anime.AnimeType.Value is GraphInfo.AnimatType.C_End)
|
||||||
|
{
|
||||||
|
var animatTypePath = Path.Combine(animePath, "C");
|
||||||
|
Directory.CreateDirectory(animatTypePath);
|
||||||
|
SaveImages(Path.Combine(animatTypePath, countC.ToString()), anime);
|
||||||
|
countC++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SaveDefault(string path, AnimeTypeModel animeType)
|
||||||
|
{
|
||||||
|
var animePath = Path.Combine(path, animeType.GraphType.ToString());
|
||||||
|
Directory.CreateDirectory(animePath);
|
||||||
|
if (animeType.HappyAnimes.Count > 0)
|
||||||
|
{
|
||||||
|
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.Happy));
|
||||||
|
SaveAnimes(modePath, animeType.HappyAnimes);
|
||||||
|
}
|
||||||
|
if (animeType.NomalAnimes.Count > 0)
|
||||||
|
{
|
||||||
|
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.Nomal));
|
||||||
|
SaveAnimes(modePath, animeType.NomalAnimes);
|
||||||
|
}
|
||||||
|
if (animeType.PoorConditionAnimes.Count > 0)
|
||||||
|
{
|
||||||
|
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.PoorCondition));
|
||||||
|
SaveAnimes(modePath, animeType.PoorConditionAnimes);
|
||||||
|
}
|
||||||
|
if (animeType.IllAnimes.Count > 0)
|
||||||
|
{
|
||||||
|
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.Ill));
|
||||||
|
SaveAnimes(modePath, animeType.IllAnimes);
|
||||||
|
}
|
||||||
|
static void SaveAnimes(string animePath, ObservableCollection<AnimeModel> animes)
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(animePath);
|
||||||
|
var count = 0;
|
||||||
|
foreach (var anime in animes)
|
||||||
|
{
|
||||||
|
SaveImages(Path.Combine(animePath, count.ToString()), anime);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SaveImages(string imagesPath, AnimeModel model)
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(imagesPath);
|
||||||
|
var imageIndex = 0;
|
||||||
|
foreach (var image in model.Images)
|
||||||
|
{
|
||||||
|
File.Copy(
|
||||||
|
image.Image.Value.GetSourceFile(),
|
||||||
|
Path.Combine(
|
||||||
|
imagesPath,
|
||||||
|
$"{model.Id.Value}_{imageIndex:000}_{image.Duration.Value}.png"
|
||||||
|
),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
imageIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AnimeModel
|
public class AnimeModel
|
||||||
@ -190,8 +341,6 @@ public class AnimeModel
|
|||||||
|
|
||||||
public ObservableValue<GraphInfo.AnimatType> AnimeType { get; } = new();
|
public ObservableValue<GraphInfo.AnimatType> AnimeType { get; } = new();
|
||||||
|
|
||||||
//public ObservableValue<GameSave.ModeType> ModeType { get; } = new();
|
|
||||||
|
|
||||||
public ObservableCollection<ImageModel> Images { get; } = new();
|
public ObservableCollection<ImageModel> Images { get; } = new();
|
||||||
|
|
||||||
public AnimeModel() { }
|
public AnimeModel() { }
|
||||||
|
@ -248,149 +248,8 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
|
|||||||
File.WriteAllText(petFile, lps.ToString());
|
File.WriteAllText(petFile, lps.ToString());
|
||||||
|
|
||||||
var petAnimePath = Path.Combine(petPath, pet.Id.Value);
|
var petAnimePath = Path.Combine(petPath, pet.Id.Value);
|
||||||
Directory.CreateDirectory(petAnimePath);
|
foreach (var animeType in pet.Animes)
|
||||||
SaveAnime_Default(petAnimePath, pet);
|
animeType.Save(petAnimePath);
|
||||||
SaveAnime_MultiType(petAnimePath, pet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SaveAnime_MultiType(string path, PetModel pet)
|
|
||||||
{
|
|
||||||
if (
|
|
||||||
pet.Animes.FirstOrDefault(m => m.GraphType.Value is GraphInfo.GraphType.Touch_Head)
|
|
||||||
is AnimeTypeModel animeType1
|
|
||||||
)
|
|
||||||
{
|
|
||||||
SaveMultiTypeAnime(
|
|
||||||
Path.Combine(path, nameof(GraphInfo.GraphType.Touch_Head)),
|
|
||||||
animeType1
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
pet.Animes.FirstOrDefault(m => m.GraphType.Value is GraphInfo.GraphType.Touch_Body)
|
|
||||||
is AnimeTypeModel animeType2
|
|
||||||
)
|
|
||||||
{
|
|
||||||
SaveMultiTypeAnime(
|
|
||||||
Path.Combine(path, nameof(GraphInfo.GraphType.Touch_Body)),
|
|
||||||
animeType2
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SaveMultiTypeAnime(string animePath, AnimeTypeModel model)
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(animePath);
|
|
||||||
if (model.HappyAnimes.Count > 0)
|
|
||||||
{
|
|
||||||
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.Happy));
|
|
||||||
SaveAnimes(modePath, model.HappyAnimes);
|
|
||||||
}
|
|
||||||
if (model.NomalAnimes.Count > 0)
|
|
||||||
{
|
|
||||||
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.Nomal));
|
|
||||||
SaveAnimes(modePath, model.NomalAnimes);
|
|
||||||
}
|
|
||||||
if (model.PoorConditionAnimes.Count > 0)
|
|
||||||
{
|
|
||||||
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.PoorCondition));
|
|
||||||
SaveAnimes(modePath, model.PoorConditionAnimes);
|
|
||||||
}
|
|
||||||
if (model.IllAnimes.Count > 0)
|
|
||||||
{
|
|
||||||
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.Ill));
|
|
||||||
SaveAnimes(modePath, model.IllAnimes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SaveAnimes(string animePath, ObservableCollection<AnimeModel> animes)
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(animePath);
|
|
||||||
var countA = 0;
|
|
||||||
var countB = 0;
|
|
||||||
var countC = 0;
|
|
||||||
foreach (var anime in animes)
|
|
||||||
{
|
|
||||||
if (anime.AnimeType.Value is GraphInfo.AnimatType.A_Start)
|
|
||||||
{
|
|
||||||
var animatTypePath = Path.Combine(animePath, "A");
|
|
||||||
Directory.CreateDirectory(animatTypePath);
|
|
||||||
SaveImages(Path.Combine(animatTypePath, countA.ToString()), anime);
|
|
||||||
countA++;
|
|
||||||
}
|
|
||||||
else if (anime.AnimeType.Value is GraphInfo.AnimatType.B_Loop)
|
|
||||||
{
|
|
||||||
var animatTypePath = Path.Combine(animePath, "B");
|
|
||||||
Directory.CreateDirectory(animatTypePath);
|
|
||||||
SaveImages(Path.Combine(animatTypePath, countB.ToString()), anime);
|
|
||||||
countB++;
|
|
||||||
}
|
|
||||||
else if (anime.AnimeType.Value is GraphInfo.AnimatType.C_End)
|
|
||||||
{
|
|
||||||
var animatTypePath = Path.Combine(animePath, "C");
|
|
||||||
Directory.CreateDirectory(animatTypePath);
|
|
||||||
SaveImages(Path.Combine(animatTypePath, countC.ToString()), anime);
|
|
||||||
countC++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SaveAnime_Default(string path, PetModel pet)
|
|
||||||
{
|
|
||||||
if (
|
|
||||||
pet.Animes.FirstOrDefault(m => m.GraphType.Value == GraphInfo.GraphType.Default)
|
|
||||||
is not AnimeTypeModel animeType
|
|
||||||
)
|
|
||||||
return;
|
|
||||||
var animePath = Path.Combine(path, nameof(GraphInfo.GraphType.Default));
|
|
||||||
Directory.CreateDirectory(animePath);
|
|
||||||
if (animeType.HappyAnimes.Count > 0)
|
|
||||||
{
|
|
||||||
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.Happy));
|
|
||||||
SaveAnimes(modePath, animeType.HappyAnimes);
|
|
||||||
}
|
|
||||||
if (animeType.NomalAnimes.Count > 0)
|
|
||||||
{
|
|
||||||
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.Nomal));
|
|
||||||
SaveAnimes(modePath, animeType.NomalAnimes);
|
|
||||||
}
|
|
||||||
if (animeType.PoorConditionAnimes.Count > 0)
|
|
||||||
{
|
|
||||||
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.PoorCondition));
|
|
||||||
SaveAnimes(modePath, animeType.PoorConditionAnimes);
|
|
||||||
}
|
|
||||||
if (animeType.IllAnimes.Count > 0)
|
|
||||||
{
|
|
||||||
var modePath = Path.Combine(animePath, nameof(GameSave.ModeType.Ill));
|
|
||||||
SaveAnimes(modePath, animeType.IllAnimes);
|
|
||||||
}
|
|
||||||
static void SaveAnimes(string animePath, ObservableCollection<AnimeModel> animes)
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(animePath);
|
|
||||||
var count = 0;
|
|
||||||
foreach (var anime in animes)
|
|
||||||
{
|
|
||||||
SaveImages(Path.Combine(animePath, count.ToString()), anime);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SaveImages(string imagesPath, AnimeModel model)
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(imagesPath);
|
|
||||||
var imageIndex = 0;
|
|
||||||
foreach (var image in model.Images)
|
|
||||||
{
|
|
||||||
File.Copy(
|
|
||||||
image.Image.Value.GetSourceFile(),
|
|
||||||
Path.Combine(
|
|
||||||
imagesPath,
|
|
||||||
$"{model.Id.Value}_{imageIndex:000}_{image.Duration.Value}.png"
|
|
||||||
),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
imageIndex++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +65,7 @@ public class AnimeEditWindowVM
|
|||||||
model.GraphType.Value
|
model.GraphType.Value
|
||||||
is GraphInfo.GraphType.Touch_Body
|
is GraphInfo.GraphType.Touch_Body
|
||||||
or GraphInfo.GraphType.Touch_Head
|
or GraphInfo.GraphType.Touch_Head
|
||||||
|
or GraphInfo.GraphType.Sleep
|
||||||
)
|
)
|
||||||
HasMultiType.Value = true;
|
HasMultiType.Value = true;
|
||||||
}
|
}
|
||||||
@ -72,8 +73,10 @@ public class AnimeEditWindowVM
|
|||||||
private void CurrentAnimeModel_ValueChanged(AnimeModel oldValue, AnimeModel newValue)
|
private void CurrentAnimeModel_ValueChanged(AnimeModel oldValue, AnimeModel newValue)
|
||||||
{
|
{
|
||||||
StopCommand_ExecuteEvent();
|
StopCommand_ExecuteEvent();
|
||||||
oldValue.Images.CollectionChanged -= Images_CollectionChanged;
|
if (oldValue is not null)
|
||||||
newValue.Images.CollectionChanged += Images_CollectionChanged;
|
oldValue.Images.CollectionChanged -= Images_CollectionChanged;
|
||||||
|
if (newValue is not null)
|
||||||
|
newValue.Images.CollectionChanged += Images_CollectionChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Images_CollectionChanged(
|
private void Images_CollectionChanged(
|
||||||
|
@ -60,7 +60,10 @@ public partial class AnimeEditWindow : Window
|
|||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
if (Enum.TryParse<GameSave.ModeType>(str, true, out var mode))
|
if (Enum.TryParse<GameSave.ModeType>(str, true, out var mode))
|
||||||
|
{
|
||||||
ViewModel.CurrentMode = mode;
|
ViewModel.CurrentMode = mode;
|
||||||
|
ViewModel.CurrentAnimeModel.Value = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ListBox_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
private void ListBox_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
||||||
|
Loading…
Reference in New Issue
Block a user