From d7b8f23a63eba56947eb18295da772370d433063 Mon Sep 17 00:00:00 2001 From: Hakoyu Date: Sat, 30 Mar 2024 17:48:23 +0800 Subject: [PATCH] =?UTF-8?q?#=20=E6=9B=B4=E6=96=B0=20-=20=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?,=E7=A7=BB=E5=8A=A8,=E5=8A=A8=E7=94=BB=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=BB=98=E8=AE=A4=E9=80=89=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E5=AE=A0=E7=89=A9=20-=20=E5=BF=BD=E7=95=A5`Food.Name`=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E7=9A=84=E5=86=85=E5=AE=B9=20-=20=E5=BF=BD=E7=95=A5`C?= =?UTF-8?q?lickText.Text`=E4=B8=BA=E7=A9=BA=E7=9A=84=E5=86=85=E5=AE=B9=20-?= =?UTF-8?q?=20=E5=BF=BD=E7=95=A5`LowText.Text`=E4=B8=BA=E7=A9=BA=E7=9A=84?= =?UTF-8?q?=E5=86=85=E5=AE=B9=20-=20=E5=BF=BD=E7=95=A5`SelectText.Text`?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E7=9A=84=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet.ModMaker/Models/ModModel/ModInfoModel.cs | 18 ++++++++++++++---- .../Models/ModModel/ModUpdataHelper.cs | 10 +++++++--- .../ModEdit/AnimeEdit/AnimePageVM.cs | 7 ++++++- .../ViewModels/ModEdit/MoveEdit/MovePageVM.cs | 6 +++++- .../ViewModels/ModEdit/WorkEdit/WorkPageVM.cs | 6 +++++- .../Views/ModEdit/AnimeEdit/AnimePage.xaml | 1 + .../Views/ModEdit/MoveEdit/MovePage.xaml | 1 + .../Views/ModEdit/WorkEdit/WorkPage.xaml | 2 +- 8 files changed, 40 insertions(+), 11 deletions(-) diff --git a/VPet.ModMaker/Models/ModModel/ModInfoModel.cs b/VPet.ModMaker/Models/ModModel/ModInfoModel.cs index 7da2dfa..2b1c6f2 100644 --- a/VPet.ModMaker/Models/ModModel/ModInfoModel.cs +++ b/VPet.ModMaker/Models/ModModel/ModInfoModel.cs @@ -48,13 +48,23 @@ public class ModInfoModel : I18nModel var imagePath = Path.Combine(loader.ModPath.FullName, "icon.png"); if (File.Exists(imagePath)) Image = NativeUtils.LoadImageToMemoryStream(imagePath); - foreach (var food in loader.Foods) + foreach (var food in loader.Foods.Where(m => string.IsNullOrWhiteSpace(m.Name) is false)) Foods.Add(new(food)); - foreach (var clickText in loader.ClickTexts) + foreach ( + var clickText in loader.ClickTexts.Where(m => + string.IsNullOrWhiteSpace(m.Text) is false + ) + ) ClickTexts.Add(new(clickText)); - foreach (var lowText in loader.LowTexts) + foreach ( + var lowText in loader.LowTexts.Where(m => string.IsNullOrWhiteSpace(m.Text) is false) + ) LowTexts.Add(new(lowText)); - foreach (var selectText in loader.SelectTexts) + foreach ( + var selectText in loader.SelectTexts.Where(m => + string.IsNullOrWhiteSpace(m.Text) is false + ) + ) SelectTexts.Add(new(selectText)); // 载入模组宠物 diff --git a/VPet.ModMaker/Models/ModModel/ModUpdataHelper.cs b/VPet.ModMaker/Models/ModModel/ModUpdataHelper.cs index d54871c..c101fef 100644 --- a/VPet.ModMaker/Models/ModModel/ModUpdataHelper.cs +++ b/VPet.ModMaker/Models/ModModel/ModUpdataHelper.cs @@ -57,7 +57,11 @@ public static class ModUpdataHelper { MessageBox.Show( ModEditWindow.Current, - "模组更新失败\n当前版本: {0}\n目标版本: {1}\n{2}".Translate(mod.ModVersion, action.Key, ex) + "模组更新失败\n当前支持的游戏版本: {0}\n目标支持的游戏版本: {1}\n{2}".Translate( + mod.ModVersion, + action.Key, + ex + ) ); return false; } @@ -68,11 +72,11 @@ public static class ModUpdataHelper public static SortedDictionary> UpdataAction { get; } = new() { - [11000] = (ModInfoModel m) => + [11000] = (m) => { - // 修改宠物默认ID foreach (var pet in m.Pets) { + // 修改宠物默认ID if (pet.ID == "默认虚拟桌宠") pet.ID = "vup"; foreach (var work in pet.Works) diff --git a/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/AnimePageVM.cs b/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/AnimePageVM.cs index b35c070..f124e08 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/AnimePageVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/AnimePageVM.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; +using HKW.HKWUtils.Extensions; using HKW.HKWUtils.Observable; using LinePutScript.Localization.WPF; using Panuon.WPF.UI; @@ -37,8 +38,12 @@ public class AnimePageVM : ObservableObjectX }, FilteredList = new() }; - CurrentPet = Pets.First(); PropertyChangedX += AnimePageVM_PropertyChangedX; + if (Pets.HasValue()) + CurrentPet = Pets.FirstOrDefault( + m => m.FromMain is false && m.AnimeCount > 0, + Pets.First() + ); AddCommand.ExecuteCommand += AddCommand_ExecuteCommand; EditCommand.ExecuteCommand += EditCommand_ExecuteCommand; diff --git a/VPet.ModMaker/ViewModels/ModEdit/MoveEdit/MovePageVM.cs b/VPet.ModMaker/ViewModels/ModEdit/MoveEdit/MovePageVM.cs index fc025d8..a898984 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/MoveEdit/MovePageVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/MoveEdit/MovePageVM.cs @@ -24,8 +24,12 @@ public class MovePageVM : ObservableObjectX Filter = f => f.Graph.Contains(Search, StringComparison.OrdinalIgnoreCase), FilteredList = new() }; - CurrentPet = Pets.First(); PropertyChanged += MovePageVM_PropertyChanged; + if (Pets.HasValue()) + CurrentPet = Pets.FirstOrDefault( + m => m.FromMain is false && m.Moves.HasValue(), + Pets.First() + ); AddCommand.ExecuteCommand += AddCommand_ExecuteCommand; EditCommand.ExecuteCommand += EditCommand_ExecuteCommand; RemoveCommand.ExecuteCommand += RemoveCommand_ExecuteCommand; diff --git a/VPet.ModMaker/ViewModels/ModEdit/WorkEdit/WorkPageVM.cs b/VPet.ModMaker/ViewModels/ModEdit/WorkEdit/WorkPageVM.cs index 96f1f92..d1d27ff 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/WorkEdit/WorkPageVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/WorkEdit/WorkPageVM.cs @@ -24,8 +24,12 @@ public class WorkPageVM : ObservableObjectX Filter = f => f.ID.Contains(Search, StringComparison.OrdinalIgnoreCase), FilteredList = new() }; - CurrentPet = Pets.First(); PropertyChanged += WorkPageVM_PropertyChanged; + if (Pets.HasValue()) + CurrentPet = Pets.FirstOrDefault( + m => m.FromMain is false && m.Works.HasValue(), + Pets.First() + ); AddCommand.ExecuteCommand += AddCommand_ExecuteCommand; EditCommand.ExecuteCommand += EditCommand_ExecuteCommand; RemoveCommand.ExecuteCommand += RemoveCommand_ExecuteCommand; diff --git a/VPet.ModMaker/Views/ModEdit/AnimeEdit/AnimePage.xaml b/VPet.ModMaker/Views/ModEdit/AnimeEdit/AnimePage.xaml index 0e9dbd7..8dc8b8d 100644 --- a/VPet.ModMaker/Views/ModEdit/AnimeEdit/AnimePage.xaml +++ b/VPet.ModMaker/Views/ModEdit/AnimeEdit/AnimePage.xaml @@ -38,6 +38,7 @@