From 906faf69cf58ce2d6a9056a8eabe804e1c7fb4ec Mon Sep 17 00:00:00 2001 From: Hakoyu Date: Mon, 23 Oct 2023 20:14:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Models/ModModel/FoodAnimeTypeModel.cs | 42 +------- VPet.ModMaker/Models/ModModel/PetModel.cs | 8 ++ .../AnimeEdit/FoodAnimeEditWindowVM.cs | 4 +- .../AnimeEdit/FoodAnimeEditWindow.xaml | 101 +++++++++++++----- .../Views/ModEdit/ModEditWindow.xaml | 2 +- 5 files changed, 88 insertions(+), 69 deletions(-) diff --git a/VPet.ModMaker/Models/ModModel/FoodAnimeTypeModel.cs b/VPet.ModMaker/Models/ModModel/FoodAnimeTypeModel.cs index 6efc93f..27e0ffc 100644 --- a/VPet.ModMaker/Models/ModModel/FoodAnimeTypeModel.cs +++ b/VPet.ModMaker/Models/ModModel/FoodAnimeTypeModel.cs @@ -98,14 +98,6 @@ public class FoodAnimeTypeModel : this() { Name.Value = Path.GetFileName(path); - //var infoFile = Path.Combine(path, ModMakerInfo.InfoFile); - //if ( - // Directory.EnumerateFiles(path, ModMakerInfo.InfoFile, SearchOption.AllDirectories).Any() - // is false - //) - // throw new Exception("信息文件\n{0}\n不存在".Translate(infoFile)); - //if (File.Exists(infoFile)) - // ParseInfoFile(path, infoFile); var infoFiles = Directory.EnumerateFiles( path, ModMakerInfo.InfoFile, @@ -320,7 +312,7 @@ public class FoodAnimeTypeModel var frontLayName = $"{Name.Value.ToLower()}_{FrontLayName}_{anime.Index}"; var backLayName = $"{Name.Value.ToLower()}_{BackLayName}_{anime.Index}"; SaveInfoFile(infoFile, frontLayName, backLayName, anime.Value, mode); - SaveImages(anime.Value, indexPath, frontLayName, backLayName); + SaveImages(anime.Value, indexPath); } } @@ -331,15 +323,10 @@ public class FoodAnimeTypeModel /// 索引路径 /// 顶层名称 /// 底层名称 - private static void SaveImages( - FoodAnimeModel anime, - string indexPath, - string frontLayName, - string backLayName - ) + private static void SaveImages(FoodAnimeModel anime, string indexPath) { - var frontLayPath = Path.Combine(indexPath, frontLayName); - var backLayPath = Path.Combine(indexPath, backLayName); + var frontLayPath = Path.Combine(indexPath, FrontLayName); + var backLayPath = Path.Combine(indexPath, BackLayName); Directory.CreateDirectory(frontLayPath); Directory.CreateDirectory(backLayPath); foreach (var frontImage in anime.FrontImages.Enumerate()) @@ -401,27 +388,6 @@ public class FoodAnimeTypeModel lps.Add(line); File.WriteAllText(infoFile, lps.ToString()); } - - /// - /// 保存图片 - /// - /// - /// - static void SaveImages(string imagesPath, AnimeModel model) - { - Directory.CreateDirectory(imagesPath); - var imageIndex = 0; - foreach (var image in model.Images) - { - image.Image.Value.SaveToPng( - Path.Combine( - imagesPath, - $"{model.Id.Value}_{imageIndex:000}_{image.Duration.Value}.png" - ) - ); - imageIndex++; - } - } } public class PNGAnimeInfo diff --git a/VPet.ModMaker/Models/ModModel/PetModel.cs b/VPet.ModMaker/Models/ModModel/PetModel.cs index 5fbe69e..97e023e 100644 --- a/VPet.ModMaker/Models/ModModel/PetModel.cs +++ b/VPet.ModMaker/Models/ModModel/PetModel.cs @@ -75,6 +75,8 @@ public class PetModel : I18nModel /// public ObservableCollection FoodAnimes { get; } = new(); + public ObservableValue AnimeCount { get; } = new(); + public bool IsSimplePetModel { get; } = false; public PetModel() @@ -84,6 +86,12 @@ public class PetModel : I18nModel { DescriptionId.Value = $"{n}_{nameof(DescriptionId)}"; }; + AnimeCount.AddNotifyReceiver(Animes); + AnimeCount.AddNotifyReceiver(FoodAnimes); + AnimeCount.NotifyReceived += (ref int v) => + { + v = Animes.Count + FoodAnimes.Count; + }; } public PetModel(PetModel model) diff --git a/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/FoodAnimeEditWindowVM.cs b/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/FoodAnimeEditWindowVM.cs index bb619ec..ff22edd 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/FoodAnimeEditWindowVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/FoodAnimeEditWindowVM.cs @@ -158,7 +158,7 @@ public class FoodAnimeEditWindowVM /// /// 添加食物定位命令 /// - public ObservableCommand AddeFoodLocationCommand { get; } = new(); + public ObservableCommand AddFoodLocationCommand { get; } = new(); /// /// 删除食物定位命令 @@ -228,7 +228,7 @@ public class FoodAnimeEditWindowVM ClearBackImageCommand.ExecuteEvent += ClearBackImageCommand_ExecuteEvent; ChangeBackImageCommand.ExecuteEvent += ChangeBackImageCommand_ExecuteEvent; - AddeFoodLocationCommand.ExecuteEvent += AddeFoodLocationCommand_ExecuteEvent; + AddFoodLocationCommand.ExecuteEvent += AddeFoodLocationCommand_ExecuteEvent; RemoveFoodLocationCommand.ExecuteEvent += RemoveFoodLocationCommand_ExecuteEvent; ClearFoodLocationCommand.ExecuteEvent += ClearFoodLocationCommand_ExecuteEvent; } diff --git a/VPet.ModMaker/Views/ModEdit/AnimeEdit/FoodAnimeEditWindow.xaml b/VPet.ModMaker/Views/ModEdit/AnimeEdit/FoodAnimeEditWindow.xaml index c72fa10..8f38d13 100644 --- a/VPet.ModMaker/Views/ModEdit/AnimeEdit/FoodAnimeEditWindow.xaml +++ b/VPet.ModMaker/Views/ModEdit/AnimeEdit/FoodAnimeEditWindow.xaml @@ -26,32 +26,19 @@ - - - - - - - + d:DataContext=""> - + + + + + + @@ -80,7 +67,23 @@ - + + + + + + + - + + + + + + + - + + + + + + +