From 9546fb604aa965495f15358cf8aa3e8dc9c6a49d Mon Sep 17 00:00:00 2001 From: Hakoyu Date: Mon, 11 Dec 2023 01:29:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0:=20-=20=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E5=AE=A0=E7=89=A9=E6=97=B6,=20=E8=8B=A5=E6=9C=AC=E4=BD=93?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E5=90=8C=E5=90=8D=E5=AE=A0=E7=89=A9,=20?= =?UTF-8?q?=E5=88=99=E5=8F=AA=E4=BC=9A=E4=BF=9D=E5=AD=98=E5=B7=AE=E5=BC=82?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=20=E4=BF=AE=E5=A4=8D:=20-=20=E6=A8=A1?= =?UTF-8?q?=E7=BB=84=E5=AE=A0=E7=89=A9=E5=92=8C=E6=9C=AC=E4=BD=93=E5=AE=A0?= =?UTF-8?q?=E7=89=A9=E5=90=8C=E6=97=B6=E5=87=BA=E7=8E=B0=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet.ModMaker/Converters.xaml | 1 + VPet.ModMaker/Models/ModLoader.cs | 3 +- VPet.ModMaker/Models/ModMakeHistory.cs | 3 +- VPet.ModMaker/Models/ModMaker.cs | 8 +- VPet.ModMaker/Models/ModMakerInfo.cs | 16 +- VPet.ModMaker/Models/ModModel/AnimeModel.cs | 2 +- .../Models/ModModel/AnimeTypeModel.cs | 2 +- .../Models/ModModel/ClickTextModel.cs | 53 +-- .../Models/ModModel/FoodAnimeModel.cs | 2 +- .../Models/ModModel/FoodAnimeTypeModel.cs | 2 +- .../Models/ModModel/FoodLocationModel.cs | 10 +- VPet.ModMaker/Models/ModModel/FoodModel.cs | 2 +- VPet.ModMaker/Models/ModModel/ImageModel.cs | 5 +- VPet.ModMaker/Models/ModModel/ModInfoModel.cs | 15 +- VPet.ModMaker/Models/ModModel/PetModel.cs | 431 ++++++++++++------ .../Models/ModModel/SelectTextModel.cs | 50 +- VPet.ModMaker/Models/ObservablePoint.cs | 50 +- VPet.ModMaker/Models/ObservableRange.cs | 106 ++--- VPet.ModMaker/Models/ObservableRect.cs | 68 +-- .../INotifyPropertyChangedX.cs | 12 + .../INotifyPropertyChangingX.cs | 12 + .../ObservableClass/ObservableClass.cs | 112 +++++ .../PropertyChangedXEventArgs.cs | 33 ++ .../PropertyChangedXEventHandler.cs | 17 + .../PropertyChangingXEventArgs.cs | 35 ++ .../PropertyChangingXEventHandler.cs | 17 + ...Handler.cs => ExecuteAsyncEventHandler.cs} | 4 +- .../ObservableCommand/ObservableCommand.cs | 122 ++--- .../ObservableCommand/ObservableCommandT.cs | 130 +++--- .../ObservableValue/ObservableValue.cs | 46 +- VPet.ModMaker/Usings.cs | 9 + VPet.ModMaker/{Models => Utils}/Expansions.cs | 20 +- VPet.ModMaker/Utils/HashCode.cs | 72 +++ VPet.ModMaker/Utils/ObservableEnumFlags.cs | 81 ++++ VPet.ModMaker/Utils/ObservablePoint.cs | 79 ++++ VPet.ModMaker/Utils/ObservableRange.cs | 82 ++++ VPet.ModMaker/Utils/ObservableRect.cs | 91 ++++ VPet.ModMaker/{Models => Utils}/Utils.cs | 3 +- VPet.ModMaker/VPet.ModMaker.csproj | 41 +- .../ViewModels/ModEdit/AddCultureWindowVM.cs | 2 +- .../ModEdit/AnimeEdit/AnimeEditWindowVM.cs | 4 +- .../ModEdit/AnimeEdit/AnimePageVM.cs | 2 +- .../AnimeEdit/FoodAnimeEditWindowVM.cs | 5 +- .../ModEdit/ClickTextEdit/ClickTextPageVM.cs | 2 +- .../ModEdit/FoodEdit/FoodEditWindowVM.cs | 2 +- .../ViewModels/ModEdit/FoodEdit/FoodPageVM.cs | 2 +- .../ModEdit/I18nEdit/I18nEditWindowVM.cs | 4 +- .../ModEdit/LowTextEdit/LowTextPageVM.cs | 2 +- .../ViewModels/ModEdit/ModEditWindowVM.cs | 1 - .../ModEdit/MoveEdit/MoveEditWindowVM.cs | 2 +- .../ViewModels/ModEdit/MoveEdit/MovePageVM.cs | 2 +- .../ModEdit/PetEdit/PetEditWindowVM.cs | 2 +- .../ViewModels/ModEdit/PetEdit/PetPageVM.cs | 13 +- .../SelectTextEdit/SelectTextPageVM.cs | 2 +- .../ModEdit/WorkEdit/WorkEditWindowVM.cs | 2 +- .../ViewModels/ModEdit/WorkEdit/WorkPageVM.cs | 2 +- .../ModEdit/AnimeEdit/AnimeEditWindow.xaml.cs | 3 +- .../Views/ModEdit/AnimeEdit/AnimePage.xaml | 9 +- .../AnimeEdit/FoodAnimeEditWindow.xaml | 19 +- .../AnimeEdit/FoodAnimeEditWindow.xaml.cs | 3 +- .../AnimeEdit/SelectGraphTypeWindow.xaml.cs | 2 +- .../Views/ModEdit/MoveEdit/MovePage.xaml | 9 +- .../Views/ModEdit/PetEdit/PetEditWindow.xaml | 128 +++--- .../Views/ModEdit/WorkEdit/WorkPage.xaml | 9 +- 64 files changed, 1434 insertions(+), 646 deletions(-) create mode 100644 VPet.ModMaker/SimpleObservable/ObservableClass/INotifyPropertyChangedX.cs create mode 100644 VPet.ModMaker/SimpleObservable/ObservableClass/INotifyPropertyChangingX.cs create mode 100644 VPet.ModMaker/SimpleObservable/ObservableClass/ObservableClass.cs create mode 100644 VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangedXEventArgs.cs create mode 100644 VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangedXEventHandler.cs create mode 100644 VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangingXEventArgs.cs create mode 100644 VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangingXEventHandler.cs rename VPet.ModMaker/SimpleObservable/ObservableCommand/{AsyncExecuteEventHandler.cs => ExecuteAsyncEventHandler.cs} (70%) create mode 100644 VPet.ModMaker/Usings.cs rename VPet.ModMaker/{Models => Utils}/Expansions.cs (95%) create mode 100644 VPet.ModMaker/Utils/HashCode.cs create mode 100644 VPet.ModMaker/Utils/ObservableEnumFlags.cs create mode 100644 VPet.ModMaker/Utils/ObservablePoint.cs create mode 100644 VPet.ModMaker/Utils/ObservableRange.cs create mode 100644 VPet.ModMaker/Utils/ObservableRect.cs rename VPet.ModMaker/{Models => Utils}/Utils.cs (98%) diff --git a/VPet.ModMaker/Converters.xaml b/VPet.ModMaker/Converters.xaml index f528ee7..7656ef2 100644 --- a/VPet.ModMaker/Converters.xaml +++ b/VPet.ModMaker/Converters.xaml @@ -9,6 +9,7 @@ + diff --git a/VPet.ModMaker/Models/ModLoader.cs b/VPet.ModMaker/Models/ModLoader.cs index c29f366..289371f 100644 --- a/VPet.ModMaker/Models/ModLoader.cs +++ b/VPet.ModMaker/Models/ModLoader.cs @@ -1,5 +1,4 @@ -using HKW.Models; -using LinePutScript; +using LinePutScript; using LinePutScript.Converter; using LinePutScript.Dictionary; using System; diff --git a/VPet.ModMaker/Models/ModMakeHistory.cs b/VPet.ModMaker/Models/ModMakeHistory.cs index 16d986f..1e06102 100644 --- a/VPet.ModMaker/Models/ModMakeHistory.cs +++ b/VPet.ModMaker/Models/ModMakeHistory.cs @@ -1,5 +1,4 @@ -using HKW.Models; -using LinePutScript.Converter; +using LinePutScript.Converter; using System; using System.Collections.Generic; using System.IO; diff --git a/VPet.ModMaker/Models/ModMaker.cs b/VPet.ModMaker/Models/ModMaker.cs index f6b9f02..e34639d 100644 --- a/VPet.ModMaker/Models/ModMaker.cs +++ b/VPet.ModMaker/Models/ModMaker.cs @@ -9,7 +9,6 @@ using System.Windows.Controls; using System.Windows; using VPet_Simulator.Windows.Interface; using VPet.ModMaker.Views; -using HKW.Models; namespace VPet.ModMaker.Models; @@ -51,12 +50,7 @@ public class ModMaker : MainPlugin ModMakerInfo.GameVersion = MW.version; // 载入本体宠物 foreach (var pet in MW.Pets) - { - var petModel = new PetModel(); - petModel.SourceId = pet.Name; - petModel.Id.Value = pet.Name + " (来自本体)".Translate(); - ModMakerInfo.Pets.Add(petModel); - } + ModMakerInfo.MainPets.Add(pet.Name, new(pet, true)); //Maker.ModMaker = this; Maker.Show(); Maker.Closed += Maker_Closed; diff --git a/VPet.ModMaker/Models/ModMakerInfo.cs b/VPet.ModMaker/Models/ModMakerInfo.cs index 856b7a6..de234fa 100644 --- a/VPet.ModMaker/Models/ModMakerInfo.cs +++ b/VPet.ModMaker/Models/ModMakerInfo.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using VPet.ModMaker.Models.ModModel; +using VPet_Simulator.Core; namespace VPet.ModMaker.Models; @@ -34,11 +35,24 @@ public static class ModMakerInfo /// /// 本体的宠物 + /// + /// (PetId, PetModel) + /// /// - public static List Pets { get; } = new(); + public static Dictionary MainPets { get; } = new(); /// /// 本地风格 /// public static NativeStyles NativeStyles { get; } = new(); + + /// + /// 是含有名称的动画 + /// + /// + /// + public static bool IsHasNameAnime(this GraphInfo.GraphType graphType) + { + return AnimeTypeModel.HasNameAnimes.Contains(graphType); + } } diff --git a/VPet.ModMaker/Models/ModModel/AnimeModel.cs b/VPet.ModMaker/Models/ModModel/AnimeModel.cs index e8ffbd7..b40082d 100644 --- a/VPet.ModMaker/Models/ModModel/AnimeModel.cs +++ b/VPet.ModMaker/Models/ModModel/AnimeModel.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using System.Collections.ObjectModel; using System.IO; using System.Linq; diff --git a/VPet.ModMaker/Models/ModModel/AnimeTypeModel.cs b/VPet.ModMaker/Models/ModModel/AnimeTypeModel.cs index e5e662f..c26d86e 100644 --- a/VPet.ModMaker/Models/ModModel/AnimeTypeModel.cs +++ b/VPet.ModMaker/Models/ModModel/AnimeTypeModel.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using System; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/VPet.ModMaker/Models/ModModel/ClickTextModel.cs b/VPet.ModMaker/Models/ModModel/ClickTextModel.cs index 6689956..bd5db27 100644 --- a/VPet.ModMaker/Models/ModModel/ClickTextModel.cs +++ b/VPet.ModMaker/Models/ModModel/ClickTextModel.cs @@ -1,5 +1,6 @@ -using HKW.HKWUtils.Observable; -using HKW.Models; +using HKW.HKWUtils; +using HKW.HKWUtils.Observable; + using LinePutScript.Converter; using System; using System.Collections.Generic; @@ -145,14 +146,14 @@ public class ClickTextModel : I18nModel Working.Value = clickText.Working; WorkingState.Value = clickText.State; DayTime.EnumValue.Value = clickText.DaiTime; - Like.SetValue(clickText.LikeMin, clickText.LikeMax); - Health.SetValue(clickText.HealthMin, clickText.HealthMax); - Level.SetValue(clickText.LevelMin, clickText.LevelMax); - Money.SetValue(clickText.MoneyMin, clickText.MoneyMax); - Food.SetValue(clickText.FoodMin, clickText.FoodMax); - Drink.SetValue(clickText.DrinkMin, clickText.DrinkMax); - Feel.SetValue(clickText.FeelMin, clickText.FeelMax); - Strength.SetValue(clickText.StrengthMin, clickText.StrengthMax); + Like = new(clickText.LikeMin, clickText.LikeMax); + Health = new(clickText.HealthMin, clickText.HealthMax); + Level = new(clickText.LevelMin, clickText.LevelMax); + Money = new(clickText.MoneyMin, clickText.MoneyMax); + Food = new(clickText.FoodMin, clickText.FoodMax); + Drink = new(clickText.DrinkMin, clickText.DrinkMax); + Feel = new(clickText.FeelMin, clickText.FeelMax); + Strength = new(clickText.StrengthMin, clickText.StrengthMax); } public ClickText ToClickText() @@ -164,22 +165,22 @@ public class ClickTextModel : I18nModel Working = Working.Value, State = WorkingState.Value, DaiTime = DayTime.EnumValue.Value, - LikeMax = Like.Max.Value, - LikeMin = Like.Min.Value, - HealthMin = Health.Min.Value, - HealthMax = Health.Max.Value, - LevelMin = Level.Min.Value, - LevelMax = Level.Max.Value, - MoneyMin = Money.Min.Value, - MoneyMax = Money.Max.Value, - FoodMin = Food.Min.Value, - FoodMax = Food.Max.Value, - DrinkMin = Drink.Min.Value, - DrinkMax = Drink.Max.Value, - FeelMin = Feel.Min.Value, - FeelMax = Feel.Max.Value, - StrengthMin = Strength.Min.Value, - StrengthMax = Strength.Max.Value, + LikeMax = Like.Max, + LikeMin = Like.Min, + HealthMin = Health.Min, + HealthMax = Health.Max, + LevelMin = Level.Min, + LevelMax = Level.Max, + MoneyMin = Money.Min, + MoneyMax = Money.Max, + FoodMin = Food.Min, + FoodMax = Food.Max, + DrinkMin = Drink.Min, + DrinkMax = Drink.Max, + FeelMin = Feel.Min, + FeelMax = Feel.Max, + StrengthMin = Strength.Min, + StrengthMax = Strength.Max, }; } } diff --git a/VPet.ModMaker/Models/ModModel/FoodAnimeModel.cs b/VPet.ModMaker/Models/ModModel/FoodAnimeModel.cs index 655f394..859891c 100644 --- a/VPet.ModMaker/Models/ModModel/FoodAnimeModel.cs +++ b/VPet.ModMaker/Models/ModModel/FoodAnimeModel.cs @@ -48,7 +48,7 @@ public class FoodAnimeModel foodLocationInfo.Duration.Value = int.Parse(infos[0]); if (infos.Length > 1) { - foodLocationInfo.Rect.SetValue( + foodLocationInfo.Rect = new( double.Parse(infos[1]), double.Parse(infos[2]), double.Parse(infos[3]), diff --git a/VPet.ModMaker/Models/ModModel/FoodAnimeTypeModel.cs b/VPet.ModMaker/Models/ModModel/FoodAnimeTypeModel.cs index 5335189..4bebb47 100644 --- a/VPet.ModMaker/Models/ModModel/FoodAnimeTypeModel.cs +++ b/VPet.ModMaker/Models/ModModel/FoodAnimeTypeModel.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using LinePutScript; using LinePutScript.Localization.WPF; using System; diff --git a/VPet.ModMaker/Models/ModModel/FoodLocationModel.cs b/VPet.ModMaker/Models/ModModel/FoodLocationModel.cs index 42f18f0..80fc338 100644 --- a/VPet.ModMaker/Models/ModModel/FoodLocationModel.cs +++ b/VPet.ModMaker/Models/ModModel/FoodLocationModel.cs @@ -20,7 +20,7 @@ public class FoodLocationModel /// /// 范围 /// - public ObservableRect Rect { get; } = new(); + public ObservableRect Rect { get; set; } = new(); /// /// 旋转角度 @@ -34,9 +34,9 @@ public class FoodLocationModel public FoodLocationModel() { - Rect.Width.ValueChanged += (s, e) => + Rect.PropertyChangedX += (s, e) => { - Rect.Height.Value = e.NewValue; + Rect.Height = (int)e.NewValue; }; } @@ -44,7 +44,7 @@ public class FoodLocationModel { var model = new FoodLocationModel(); model.Duration.Value = Duration.Value; - model.Rect.SetValue(Rect.X.Value, Rect.Y.Value, Rect.Width.Value, Rect.Height.Value); + model.Rect = new(Rect.X, Rect.Y, Rect.Width, Rect.Height); model.Rotate.Value = Rotate.Value; model.Opacity.Value = Opacity.Value; return model; @@ -52,6 +52,6 @@ public class FoodLocationModel public override string ToString() { - return $"{Duration.Value},{Rect.X.Value},{Rect.Y.Value},{Rect.Width.Value},{Rotate.Value},{Opacity.Value}"; + return $"{Duration.Value}, {Rect.X}, {Rect.Y}, {Rect.Width}, {Rotate.Value}, {Opacity.Value}"; } } diff --git a/VPet.ModMaker/Models/ModModel/FoodModel.cs b/VPet.ModMaker/Models/ModModel/FoodModel.cs index 47216de..407eb6f 100644 --- a/VPet.ModMaker/Models/ModModel/FoodModel.cs +++ b/VPet.ModMaker/Models/ModModel/FoodModel.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using LinePutScript; using LinePutScript.Converter; using System; diff --git a/VPet.ModMaker/Models/ModModel/ImageModel.cs b/VPet.ModMaker/Models/ModModel/ImageModel.cs index dcf572b..bc7c5b9 100644 --- a/VPet.ModMaker/Models/ModModel/ImageModel.cs +++ b/VPet.ModMaker/Models/ModModel/ImageModel.cs @@ -1,5 +1,6 @@ -using HKW.HKWUtils.Observable; -using HKW.Models; +using HKW.HKWUtils; +using HKW.HKWUtils.Observable; + using System; using System.Collections.Generic; using System.Linq; diff --git a/VPet.ModMaker/Models/ModModel/ModInfoModel.cs b/VPet.ModMaker/Models/ModModel/ModInfoModel.cs index 2f214f8..8b98542 100644 --- a/VPet.ModMaker/Models/ModModel/ModInfoModel.cs +++ b/VPet.ModMaker/Models/ModModel/ModInfoModel.cs @@ -1,5 +1,6 @@ -using HKW.HKWUtils.Observable; -using HKW.Models; +using HKW.HKWUtils; +using HKW.HKWUtils.Observable; + using LinePutScript; using LinePutScript.Converter; using LinePutScript.Localization.WPF; @@ -20,6 +21,7 @@ using VPet_Simulator.Windows.Interface; namespace VPet.ModMaker.Models; +// TODO: 本体模组显示开关 /// /// 模组信息模型 /// @@ -142,6 +144,7 @@ public class ModInfoModel : I18nModel foreach (var selectText in loader.SelectTexts) SelectTexts.Add(new(selectText)); + // 载入模组宠物 foreach (var pet in loader.Pets) { var petModel = new PetModel(pet); @@ -149,14 +152,16 @@ public class ModInfoModel : I18nModel foreach (var p in pet.path) LoadAnime(petModel, p); } + // 插入本体宠物 - foreach (var pet in ModMakerInfo.Pets) + foreach (var pet in ModMakerInfo.MainPets) { // 确保Id不重复 - if (Pets.All(i => i.Id.Value != pet.SourceId)) - Pets.Insert(0, pet); + if (Pets.All(i => i.Id.Value != pet.Key)) + Pets.Insert(0, pet.Value); } + // 载入本地化 foreach (var lang in loader.I18nDatas) I18nDatas.Add(lang.Key, lang.Value); OtherI18nDatas = loader.OtherI18nDatas; diff --git a/VPet.ModMaker/Models/ModModel/PetModel.cs b/VPet.ModMaker/Models/ModModel/PetModel.cs index 0182cf2..70e3674 100644 --- a/VPet.ModMaker/Models/ModModel/PetModel.cs +++ b/VPet.ModMaker/Models/ModModel/PetModel.cs @@ -1,5 +1,5 @@ -using HKW.HKWUtils.Observable; -using HKW.Models; +using HKW.HKWUtils; +using HKW.HKWUtils.Observable; using LinePutScript; using LinePutScript.Converter; using LinePutScript.Localization.WPF; @@ -23,9 +23,9 @@ namespace VPet.ModMaker.Models; public class PetModel : I18nModel { /// - /// 显示的Id 若不为空则判断为来自本体的宠物 + /// 来自本体 /// - public string? SourceId { get; set; } = null; + public ObservableValue FromMain { get; set; } = new(false); /// /// Id @@ -95,8 +95,6 @@ public class PetModel : I18nModel public ObservableValue AnimeCount { get; } = new(); - public bool IsSimplePetModel { get; } = false; - public PetModel() { PetNameId.Value = $"{Id.Value}_{nameof(PetNameId)}"; @@ -131,68 +129,62 @@ public class PetModel : I18nModel CurrentI18nData.Value = I18nDatas[I18nHelper.Current.CultureName.Value]; } - public PetModel(PetLoader loader) + public PetModel(PetLoader loader, bool fromMain = false) : this() { Id.Value = loader.Name; PetNameId.Value = loader.PetName; DescriptionId.Value = loader.Intor; - TouchHeadRect.Value.SetValue( + TouchHeadRect.Value = new( loader.Config.TouchHeadLocate.X, loader.Config.TouchHeadLocate.Y, loader.Config.TouchHeadSize.Width, loader.Config.TouchHeadSize.Height ); - TouchBodyRect.Value.SetValue( + TouchBodyRect.Value = new( loader.Config.TouchBodyLocate.X, loader.Config.TouchBodyLocate.Y, loader.Config.TouchBodySize.Width, loader.Config.TouchBodySize.Height ); - TouchRaisedRect.Value.Happy.Value.SetValue( + TouchRaisedRect.Value.Happy = new( loader.Config.TouchRaisedLocate[0].X, loader.Config.TouchRaisedLocate[0].Y, loader.Config.TouchRaisedSize[0].Width, loader.Config.TouchRaisedSize[0].Height ); - TouchRaisedRect.Value.Nomal.Value.SetValue( + TouchRaisedRect.Value.Nomal = new( loader.Config.TouchRaisedLocate[1].X, loader.Config.TouchRaisedLocate[1].Y, loader.Config.TouchRaisedSize[1].Width, loader.Config.TouchRaisedSize[1].Height ); - TouchRaisedRect.Value.PoorCondition.Value.SetValue( + TouchRaisedRect.Value.PoorCondition = new( loader.Config.TouchRaisedLocate[2].X, loader.Config.TouchRaisedLocate[2].Y, loader.Config.TouchRaisedSize[2].Width, loader.Config.TouchRaisedSize[2].Height ); - TouchRaisedRect.Value.Ill.Value.SetValue( + TouchRaisedRect.Value.Ill = new( loader.Config.TouchRaisedLocate[3].X, loader.Config.TouchRaisedLocate[3].Y, loader.Config.TouchRaisedSize[3].Width, loader.Config.TouchRaisedSize[3].Height ); - RaisePoint.Value.Happy.Value.SetValue( - loader.Config.RaisePoint[0].X, - loader.Config.RaisePoint[0].Y - ); - RaisePoint.Value.Nomal.Value.SetValue( - loader.Config.RaisePoint[1].X, - loader.Config.RaisePoint[1].Y - ); - RaisePoint.Value.PoorCondition.Value.SetValue( + RaisePoint.Value.Happy = new(loader.Config.RaisePoint[0].X, loader.Config.RaisePoint[0].Y); + RaisePoint.Value.Nomal = new(loader.Config.RaisePoint[1].X, loader.Config.RaisePoint[1].Y); + RaisePoint.Value.PoorCondition = new( loader.Config.RaisePoint[2].X, loader.Config.RaisePoint[2].Y ); - RaisePoint.Value.Ill.Value.SetValue( - loader.Config.RaisePoint[3].X, - loader.Config.RaisePoint[3].Y - ); + RaisePoint.Value.Ill = new(loader.Config.RaisePoint[3].X, loader.Config.RaisePoint[3].Y); + // 如果这个宠物数据来自本体, 则不载入 Work 和 Move + if (FromMain.Value = fromMain) + return; foreach (var work in loader.Config.Works) Works.Add(new(work)); @@ -200,13 +192,6 @@ public class PetModel : I18nModel Moves.Add(new(move)); } - public PetModel(PetLoader loader, bool isSimplePet) - : this() - { - Id.Value = loader.Name; - IsSimplePetModel = isSimplePet; - } - public void Close() { foreach (var anime in Animes) @@ -222,13 +207,6 @@ public class PetModel : I18nModel /// 路径 public void Save(string path) { - if (IsSimplePetModel) - { - Id.Value = SourceId; - SaveSimplePetInfo(path); - Id.Value = SourceId + " (来自本体)".Translate(); - return; - } foreach (var cultureName in I18nHelper.Current.CultureNames) { ModInfoModel.SaveI18nDatas[cultureName].TryAdd( @@ -248,7 +226,11 @@ public class PetModel : I18nModel if (File.Exists(petFile) is false) File.Create(petFile).Close(); var lps = new LPS(); - SavePetInfo(lps); + // 如果本体中存在相同的宠物, 则只保存差异信息 + if (ModMakerInfo.MainPets.TryGetValue(Id.Value, out var mainPet)) + SaveDifferentPetInfo(lps, mainPet); + else + SavePetInfo(lps); SaveWorksInfo(lps); SaveMoveInfo(lps); File.WriteAllText(petFile, lps.ToString()); @@ -257,18 +239,6 @@ public class PetModel : I18nModel SaveAnime(path); } - private void SaveSimplePetInfo(string path) - { - if (Works.Count == 0 && Moves.Count == 0 && Animes.Count == 0) - return; - var petFile = Path.Combine(path, $"{Id.Value}.lps"); - var lps = new LPS { new Line("pet", Id.Value) { new Sub("path", Id.Value), } }; - SaveWorksInfo(lps); - SaveMoveInfo(lps); - File.WriteAllText(petFile, lps.ToString()); - SaveAnime(path); - } - private void SaveAnime(string path) { var petAnimePath = Path.Combine(path, Id.Value); @@ -311,12 +281,42 @@ public class PetModel : I18nModel } } + #region SavePetInfo /// /// 保存宠物信息 /// /// - /// private void SavePetInfo(LPS lps) + { + SavePetBasicInfo(lps); + SavePetTouchHeadInfo(lps); + SavePetTouchBodyInfo(lps); + SavePetTouchRaisedInfo(lps); + SavePetRaisePointInfo(lps); + } + + /// + /// 保存差异宠物信息 + /// + /// 用于本体存在同名宠物的情况下 + /// + /// + /// + /// 本体宠物 + private void SaveDifferentPetInfo(LPS lps, PetModel mainPet) + { + SavePetBasicInfo(lps); + if (TouchHeadRect != mainPet.TouchHeadRect) + SavePetTouchHeadInfo(lps); + if (TouchBodyRect != mainPet.TouchBodyRect) + SavePetTouchBodyInfo(lps); + if (TouchRaisedRect != mainPet.TouchRaisedRect) + SavePetTouchRaisedInfo(lps); + if (RaisePoint != mainPet.RaisePoint) + SavePetRaisePointInfo(lps); + } + + private void SavePetBasicInfo(LPS lps) { lps.Add( new Line("pet", Id.Value) @@ -326,65 +326,82 @@ public class PetModel : I18nModel new Sub("petname", PetNameId.Value) } ); + } + + private void SavePetTouchHeadInfo(LPS lps) + { lps.Add( new Line("touchhead") { - new Sub("px", TouchHeadRect.Value.X.Value), - new Sub("py", TouchHeadRect.Value.Y.Value), - new Sub("sw", TouchHeadRect.Value.Width.Value), - new Sub("sh", TouchHeadRect.Value.Height.Value), - } - ); - lps.Add( - new Line("touchbody") - { - new Sub("px", TouchBodyRect.Value.X.Value), - new Sub("py", TouchBodyRect.Value.Y.Value), - new Sub("sw", TouchBodyRect.Value.Width.Value), - new Sub("sh", TouchBodyRect.Value.Height.Value), - } - ); - lps.Add( - new Line("touchraised") - { - new Sub("happy_px", TouchRaisedRect.Value.Happy.Value.X.Value), - new Sub("happy_py", TouchRaisedRect.Value.Happy.Value.Y.Value), - new Sub("happy_sw", TouchRaisedRect.Value.Happy.Value.Width.Value), - new Sub("happy_sh", TouchRaisedRect.Value.Happy.Value.Height.Value), - // - new Sub("nomal_px", TouchRaisedRect.Value.Nomal.Value.X.Value), - new Sub("nomal_py", TouchRaisedRect.Value.Nomal.Value.Y.Value), - new Sub("nomal_sw", TouchRaisedRect.Value.Nomal.Value.Width.Value), - new Sub("nomal_sh", TouchRaisedRect.Value.Nomal.Value.Height.Value), - // - new Sub("poorcondition_px", TouchRaisedRect.Value.PoorCondition.Value.X.Value), - new Sub("poorcondition_py", TouchRaisedRect.Value.PoorCondition.Value.Y.Value), - new Sub("poorcondition_sw", TouchRaisedRect.Value.PoorCondition.Value.Width.Value), - new Sub("poorcondition_sh", TouchRaisedRect.Value.PoorCondition.Value.Height.Value), - // - new Sub("ill_px", TouchRaisedRect.Value.Ill.Value.X.Value), - new Sub("ill_py", TouchRaisedRect.Value.Ill.Value.Y.Value), - new Sub("ill_sw", TouchRaisedRect.Value.Ill.Value.Width.Value), - new Sub("ill_sh", TouchRaisedRect.Value.Ill.Value.Height.Value), - } - ); - lps.Add( - new Line("raisepoint") - { - new Sub("happy_x", RaisePoint.Value.Happy.Value.X.Value), - new Sub("happy_y", RaisePoint.Value.Happy.Value.Y.Value), - // - new Sub("nomal_x", RaisePoint.Value.Nomal.Value.X.Value), - new Sub("nomal_y", RaisePoint.Value.Nomal.Value.Y.Value), - // - new Sub("poorcondition_x", RaisePoint.Value.PoorCondition.Value.X.Value), - new Sub("poorcondition_y", RaisePoint.Value.PoorCondition.Value.Y.Value), - // - new Sub("ill_x", RaisePoint.Value.Ill.Value.X.Value), - new Sub("ill_y", RaisePoint.Value.Ill.Value.Y.Value), + new Sub("px", TouchHeadRect.Value.X), + new Sub("py", TouchHeadRect.Value.Y), + new Sub("sw", TouchHeadRect.Value.Width), + new Sub("sh", TouchHeadRect.Value.Height), } ); } + + private void SavePetTouchBodyInfo(LPS lps) + { + lps.Add( + new Line("touchbody") + { + new Sub("px", TouchBodyRect.Value.X), + new Sub("py", TouchBodyRect.Value.Y), + new Sub("sw", TouchBodyRect.Value.Width), + new Sub("sh", TouchBodyRect.Value.Height), + } + ); + } + + private void SavePetTouchRaisedInfo(LPS lps) + { + lps.Add( + new Line("touchraised") + { + new Sub("happy_px", TouchRaisedRect.Value.Happy.X), + new Sub("happy_py", TouchRaisedRect.Value.Happy.Y), + new Sub("happy_sw", TouchRaisedRect.Value.Happy.Width), + new Sub("happy_sh", TouchRaisedRect.Value.Happy.Height), + // + new Sub("nomal_px", TouchRaisedRect.Value.Nomal.X), + new Sub("nomal_py", TouchRaisedRect.Value.Nomal.Y), + new Sub("nomal_sw", TouchRaisedRect.Value.Nomal.Width), + new Sub("nomal_sh", TouchRaisedRect.Value.Nomal.Height), + // + new Sub("poorcondition_px", TouchRaisedRect.Value.PoorCondition.X), + new Sub("poorcondition_py", TouchRaisedRect.Value.PoorCondition.Y), + new Sub("poorcondition_sw", TouchRaisedRect.Value.PoorCondition.Width), + new Sub("poorcondition_sh", TouchRaisedRect.Value.PoorCondition.Height), + // + new Sub("ill_px", TouchRaisedRect.Value.Ill.X), + new Sub("ill_py", TouchRaisedRect.Value.Ill.Y), + new Sub("ill_sw", TouchRaisedRect.Value.Ill.Width), + new Sub("ill_sh", TouchRaisedRect.Value.Ill.Height), + } + ); + } + + private void SavePetRaisePointInfo(LPS lps) + { + lps.Add( + new Line("raisepoint") + { + new Sub("happy_x", RaisePoint.Value.Happy.X), + new Sub("happy_y", RaisePoint.Value.Happy.Y), + // + new Sub("nomal_x", RaisePoint.Value.Nomal.X), + new Sub("nomal_y", RaisePoint.Value.Nomal.Y), + // + new Sub("poorcondition_x", RaisePoint.Value.PoorCondition.X), + new Sub("poorcondition_y", RaisePoint.Value.PoorCondition.Y), + // + new Sub("ill_x", RaisePoint.Value.Ill.X), + new Sub("ill_y", RaisePoint.Value.Ill.Y), + } + ); + } + #endregion #endregion } @@ -405,13 +422,41 @@ public class I18nPetInfoModel } public class ObservableMultiStateRect + : ObservableClass, + IEquatable { - public ObservableValue> Happy { get; } = new(new()); - public ObservableValue> Nomal { get; } = new(new()); - public ObservableValue> PoorCondition { get; } = new(new()); - public ObservableValue> Ill { get; } = new(new()); + private ObservableRect _happy; + public ObservableRect Happy + { + get => _happy; + set => SetProperty(ref _happy, value); + } + private ObservableRect _nomal; + public ObservableRect Nomal + { + get => _nomal; + set => SetProperty(ref _nomal, value); + } + private ObservableRect _poorCondition; + public ObservableRect PoorCondition + { + get => _poorCondition; + set => SetProperty(ref _poorCondition, value); + } + private ObservableRect _ill; + public ObservableRect Ill + { + get => _ill; + set => SetProperty(ref _ill, value); + } - public ObservableMultiStateRect() { } + public ObservableMultiStateRect() + { + Happy = new(); + Nomal = new(); + PoorCondition = new(); + Ill = new(); + } public ObservableMultiStateRect( ObservableRect happy, @@ -420,31 +465,101 @@ public class ObservableMultiStateRect ObservableRect ill ) { - Happy.Value = happy; - Nomal.Value = nomal; - PoorCondition.Value = poorCondition; - Ill.Value = ill; + Happy = happy; + Nomal = nomal; + PoorCondition = poorCondition; + Ill = ill; } public ObservableMultiStateRect Copy() { - var result = new ObservableMultiStateRect(); - result.Happy.Value = Happy.Value.Copy(); - result.Nomal.Value = Nomal.Value.Copy(); - result.PoorCondition.Value = PoorCondition.Value.Copy(); - result.Ill.Value = Ill.Value.Copy(); - return result; + return new() + { + Happy = Happy.Copy(), + Nomal = Nomal.Copy(), + PoorCondition = PoorCondition.Copy(), + Ill = Ill.Copy(), + }; } + + #region Other + + /// + public override int GetHashCode() + { + return HashCode.Combine(Happy, Nomal, PoorCondition, Ill); + } + + /// + public override bool Equals(object? obj) + { + return obj is ObservableMultiStateRect temp + && EqualityComparer>.Default.Equals(Happy, temp.Happy) + && EqualityComparer>.Default.Equals(Nomal, temp.Nomal) + && EqualityComparer>.Default.Equals( + PoorCondition, + temp.PoorCondition + ) + && EqualityComparer>.Default.Equals(Ill, temp.Ill); + } + + /// + public bool Equals(ObservableMultiStateRect? other) + { + return Equals(obj: other); + } + + /// + public static bool operator ==(ObservableMultiStateRect a, ObservableMultiStateRect b) + { + return Equals(a, b); + } + + /// + public static bool operator !=(ObservableMultiStateRect a, ObservableMultiStateRect b) + { + return Equals(a, b) is not true; + } + + #endregion } public class ObservableMultiStatePoint + : ObservableClass, + IEquatable { - public ObservableValue> Happy { get; } = new(new()); - public ObservableValue> Nomal { get; } = new(new()); - public ObservableValue> PoorCondition { get; } = new(new()); - public ObservableValue> Ill { get; } = new(new()); + private ObservablePoint _happy; + public ObservablePoint Happy + { + get => _happy; + set => SetProperty(ref _happy, value); + } + private ObservablePoint _nomal; + public ObservablePoint Nomal + { + get => _nomal; + set => SetProperty(ref _nomal, value); + } + private ObservablePoint _poorCondition; + public ObservablePoint PoorCondition + { + get => _poorCondition; + set => SetProperty(ref _poorCondition, value); + } + private ObservablePoint _ill; + public ObservablePoint Ill + { + get => _ill; + set => SetProperty(ref _ill, value); + } - public ObservableMultiStatePoint() { } + public ObservableMultiStatePoint() + { + Happy = new(); + Nomal = new(); + PoorCondition = new(); + Ill = new(); + } public ObservableMultiStatePoint( ObservablePoint happy, @@ -453,19 +568,61 @@ public class ObservableMultiStatePoint ObservablePoint ill ) { - Happy.Value = happy; - Nomal.Value = nomal; - PoorCondition.Value = poorCondition; - Ill.Value = ill; + Happy = happy; + Nomal = nomal; + PoorCondition = poorCondition; + Ill = ill; } public ObservableMultiStatePoint Copy() { - var result = new ObservableMultiStatePoint(); - result.Happy.Value = Happy.Value.Copy(); - result.Nomal.Value = Nomal.Value.Copy(); - result.PoorCondition.Value = PoorCondition.Value.Copy(); - result.Ill.Value = Ill.Value.Copy(); - return result; + return new() + { + Happy = Happy.Copy(), + Nomal = Nomal.Copy(), + PoorCondition = PoorCondition.Copy(), + Ill = Ill.Copy(), + }; } + + #region Other + + /// + public override int GetHashCode() + { + return HashCode.Combine(Happy, Nomal, PoorCondition, Ill); + } + + /// + public override bool Equals(object? obj) + { + return obj is ObservableMultiStatePoint temp + && EqualityComparer>.Default.Equals(Happy, temp.Happy) + && EqualityComparer>.Default.Equals(Nomal, temp.Nomal) + && EqualityComparer>.Default.Equals( + PoorCondition, + temp.PoorCondition + ) + && EqualityComparer>.Default.Equals(Ill, temp.Ill); + } + + /// + public bool Equals(ObservableMultiStatePoint? other) + { + return Equals(obj: other); + } + + /// + public static bool operator ==(ObservableMultiStatePoint a, ObservableMultiStatePoint b) + { + return Equals(a, b); + } + + /// + public static bool operator !=(ObservableMultiStatePoint a, ObservableMultiStatePoint b) + { + return Equals(a, b) is not true; + } + + #endregion } diff --git a/VPet.ModMaker/Models/ModModel/SelectTextModel.cs b/VPet.ModMaker/Models/ModModel/SelectTextModel.cs index 96ba63f..3fb1a80 100644 --- a/VPet.ModMaker/Models/ModModel/SelectTextModel.cs +++ b/VPet.ModMaker/Models/ModModel/SelectTextModel.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -130,14 +130,14 @@ public class SelectTextModel : I18nModel Mode.EnumValue.Value = text.Mode; Tags.Value = text.Tags is null ? string.Empty : string.Join(", ", text.Tags); ToTags.Value = text.ToTags is null ? string.Empty : string.Join(", ", text.ToTags); - Like.SetValue(text.LikeMin, text.LikeMax); - Health.SetValue(text.HealthMin, text.HealthMax); - Level.SetValue(text.LevelMin, text.LevelMax); - Money.SetValue(text.MoneyMin, text.MoneyMax); - Food.SetValue(text.FoodMin, text.FoodMax); - Drink.SetValue(text.DrinkMin, text.DrinkMax); - Feel.SetValue(text.FeelMin, text.FeelMax); - Strength.SetValue(text.StrengthMin, text.StrengthMax); + Like = new(text.LikeMin, text.LikeMax); + Health = new(text.HealthMin, text.HealthMax); + Level = new(text.LevelMin, text.LevelMax); + Money = new(text.MoneyMin, text.MoneyMax); + Food = new(text.FoodMin, text.FoodMax); + Drink = new(text.DrinkMin, text.DrinkMax); + Feel = new(text.FeelMin, text.FeelMax); + Strength = new(text.StrengthMin, text.StrengthMax); } private readonly static char[] rs_splitChar = { ',', ' ' }; @@ -151,22 +151,22 @@ public class SelectTextModel : I18nModel Mode = Mode.EnumValue.Value, Tags = new(Tags.Value.Split(rs_splitChar, StringSplitOptions.RemoveEmptyEntries)), ToTags = new(ToTags.Value.Split(rs_splitChar, StringSplitOptions.RemoveEmptyEntries)), - LikeMax = Like.Max.Value, - LikeMin = Like.Min.Value, - HealthMin = Health.Min.Value, - HealthMax = Health.Max.Value, - LevelMin = Level.Min.Value, - LevelMax = Level.Max.Value, - MoneyMin = Money.Min.Value, - MoneyMax = Money.Max.Value, - FoodMin = Food.Min.Value, - FoodMax = Food.Max.Value, - DrinkMin = Drink.Min.Value, - DrinkMax = Drink.Max.Value, - FeelMin = Feel.Min.Value, - FeelMax = Feel.Max.Value, - StrengthMin = Strength.Min.Value, - StrengthMax = Strength.Max.Value, + LikeMax = Like.Max, + LikeMin = Like.Min, + HealthMin = Health.Min, + HealthMax = Health.Max, + LevelMin = Level.Min, + LevelMax = Level.Max, + MoneyMin = Money.Min, + MoneyMax = Money.Max, + FoodMin = Food.Min, + FoodMax = Food.Max, + DrinkMin = Drink.Min, + DrinkMax = Drink.Max, + FeelMin = Feel.Min, + FeelMax = Feel.Max, + StrengthMin = Strength.Min, + StrengthMax = Strength.Max, }; } } diff --git a/VPet.ModMaker/Models/ObservablePoint.cs b/VPet.ModMaker/Models/ObservablePoint.cs index c454003..0806d48 100644 --- a/VPet.ModMaker/Models/ObservablePoint.cs +++ b/VPet.ModMaker/Models/ObservablePoint.cs @@ -1,31 +1,31 @@ -using HKW.HKWUtils.Observable; +//using HKW.HKWUtils.Observable; -namespace VPet.ModMaker.Models; +//namespace VPet.ModMaker.Models; -public class ObservablePoint -{ - public ObservableValue X { get; } = new(); - public ObservableValue Y { get; } = new(); +//public class ObservablePoint +//{ +// public ObservableValue X { get; } = new(); +// public ObservableValue Y { get; } = new(); - public ObservablePoint() { } +// public ObservablePoint() { } - public ObservablePoint(T x, T y) - { - X.Value = x; - Y.Value = y; - } +// public ObservablePoint(T x, T y) +// { +// X.Value = x; +// Y.Value = y; +// } - public void SetValue(T x, T y) - { - X.Value = x; - Y.Value = y; - } +// public void SetValue(T x, T y) +// { +// X.Value = x; +// Y.Value = y; +// } - public ObservablePoint Copy() - { - var result = new ObservablePoint(); - result.X.Value = X.Value; - result.Y.Value = Y.Value; - return result; - } -} +// public ObservablePoint Copy() +// { +// var result = new ObservablePoint(); +// result.X.Value = X.Value; +// result.Y.Value = Y.Value; +// return result; +// } +//} diff --git a/VPet.ModMaker/Models/ObservableRange.cs b/VPet.ModMaker/Models/ObservableRange.cs index 62d9f18..222b334 100644 --- a/VPet.ModMaker/Models/ObservableRange.cs +++ b/VPet.ModMaker/Models/ObservableRange.cs @@ -1,62 +1,62 @@ -using HKW.HKWUtils.Observable; +//using HKW.HKWUtils.Observable; -namespace HKW.Models; +//namespace HKW.Models; -/// -/// 可观察的范围 -/// -/// 类型 -public class ObservableRange -{ - /// - /// 最小值 - /// - public ObservableValue Min { get; } = new(); +///// +///// 可观察的范围 +///// +///// 类型 +//public class ObservableRange +//{ +// /// +// /// 最小值 +// /// +// public ObservableValue Min { get; } = new(); - /// - /// 最大值 - /// - public ObservableValue Max { get; } = new(); +// /// +// /// 最大值 +// /// +// public ObservableValue Max { get; } = new(); - /// - /// 信息 - /// - public ObservableValue Info { get; } = new(); +// /// +// /// 信息 +// /// +// public ObservableValue Info { get; } = new(); - public ObservableRange() - { - Min.ValueChanged += ValueChanged; - Max.ValueChanged += ValueChanged; - } +// public ObservableRange() +// { +// Min.ValueChanged += ValueChanged; +// Max.ValueChanged += ValueChanged; +// } - public ObservableRange(T min, T max) - : this() - { - SetValue(min, max); - } +// public ObservableRange(T min, T max) +// : this() +// { +// SetValue(min, max); +// } - private void ValueChanged(ObservableValue sender, ValueChangedEventArgs e) - { - Info.Value = $"({Min.Value}, {Max.Value})"; - } +// private void ValueChanged(ObservableValue sender, ValueChangedEventArgs e) +// { +// Info.Value = $"({Min.Value}, {Max.Value})"; +// } - /// - /// 设置值 - /// - /// 最小值 - /// 最大值 - public void SetValue(T min, T max) - { - Min.Value = min; - Max.Value = max; - } +// /// +// /// 设置值 +// /// +// /// 最小值 +// /// 最大值 +// public void SetValue(T min, T max) +// { +// Min.Value = min; +// Max.Value = max; +// } - /// - /// 复制 - /// - /// - public ObservableRange Copy() - { - return new(Min.Value, Max.Value); - } -} +// /// +// /// 复制 +// /// +// /// +// public ObservableRange Copy() +// { +// return new(Min.Value, Max.Value); +// } +//} diff --git a/VPet.ModMaker/Models/ObservableRect.cs b/VPet.ModMaker/Models/ObservableRect.cs index 2ffd0fa..5c8767e 100644 --- a/VPet.ModMaker/Models/ObservableRect.cs +++ b/VPet.ModMaker/Models/ObservableRect.cs @@ -1,39 +1,41 @@ -using HKW.HKWUtils.Observable; +//using HKW.HKWUtils.Observable; -namespace VPet.ModMaker.Models; +//namespace VPet.ModMaker.Models; -public class ObservableRect -{ - public ObservableValue X { get; } = new(); - public ObservableValue Y { get; } = new(); - public ObservableValue Width { get; } = new(); - public ObservableValue Height { get; } = new(); +//public class ObservableRect +//{ +// public ObservableValue X { get; } = new(); +// public ObservableValue Y { get; } = new(); +// public ObservableValue Width { get; } = new(); +// public ObservableValue Height { get; } = new(); - public ObservableRect() { } +// public bool Changed { get; set; } = true; - public ObservableRect(T x, T y, T width, T hetght) - { - X.Value = x; - Y.Value = y; - Width.Value = width; - Height.Value = hetght; - } +// public ObservableRect() { } - public void SetValue(T x, T y, T width, T hetght) - { - X.Value = x; - Y.Value = y; - Width.Value = width; - Height.Value = hetght; - } +// public ObservableRect(T x, T y, T width, T hetght) +// { +// X.Value = x; +// Y.Value = y; +// Width.Value = width; +// Height.Value = hetght; +// } - public ObservableRect Copy() - { - var result = new ObservableRect(); - result.X.Value = X.Value; - result.Y.Value = Y.Value; - result.Width.Value = Width.Value; - result.Height.Value = Height.Value; - return result; - } -} +// public void SetValue(T x, T y, T width, T hetght) +// { +// X.Value = x; +// Y.Value = y; +// Width.Value = width; +// Height.Value = hetght; +// } + +// public ObservableRect Copy() +// { +// var result = new ObservableRect(); +// result.X.Value = X.Value; +// result.Y.Value = Y.Value; +// result.Width.Value = Width.Value; +// result.Height.Value = Height.Value; +// return result; +// } +//} diff --git a/VPet.ModMaker/SimpleObservable/ObservableClass/INotifyPropertyChangedX.cs b/VPet.ModMaker/SimpleObservable/ObservableClass/INotifyPropertyChangedX.cs new file mode 100644 index 0000000..141f509 --- /dev/null +++ b/VPet.ModMaker/SimpleObservable/ObservableClass/INotifyPropertyChangedX.cs @@ -0,0 +1,12 @@ +namespace HKW.HKWUtils.Observable; + +/// +/// 通知属性改变后接口 +/// +public interface INotifyPropertyChangedX +{ + /// + /// 通知属性改变后事件 + /// + public event PropertyChangedXEventHandler? PropertyChangedX; +} diff --git a/VPet.ModMaker/SimpleObservable/ObservableClass/INotifyPropertyChangingX.cs b/VPet.ModMaker/SimpleObservable/ObservableClass/INotifyPropertyChangingX.cs new file mode 100644 index 0000000..8b47081 --- /dev/null +++ b/VPet.ModMaker/SimpleObservable/ObservableClass/INotifyPropertyChangingX.cs @@ -0,0 +1,12 @@ +namespace HKW.HKWUtils.Observable; + +/// +/// 通知属性改变前接口 +/// +public interface INotifyPropertyChangingX +{ + /// + /// 属性改变前事件 + /// + public event PropertyChangingXEventHandler? PropertyChangingX; +} diff --git a/VPet.ModMaker/SimpleObservable/ObservableClass/ObservableClass.cs b/VPet.ModMaker/SimpleObservable/ObservableClass/ObservableClass.cs new file mode 100644 index 0000000..18a0100 --- /dev/null +++ b/VPet.ModMaker/SimpleObservable/ObservableClass/ObservableClass.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + +namespace HKW.HKWUtils.Observable; + +/// +/// 可观察对象 +/// 示例: +/// { +/// int _value = 0; +/// public int Value +/// { +/// get => _value; +/// set => SetProperty(ref _value, value); +/// } +/// }]]> +/// +public abstract class ObservableClass + : INotifyPropertyChanging, + INotifyPropertyChanged, + INotifyPropertyChangingX, + INotifyPropertyChangedX + where TObject : ObservableClass +{ + #region OnPropertyChange + /// + /// 设置属性值 + /// + /// 值 + /// 新值 + /// 属性名称 + /// 成功为 失败为 + [MethodImpl(MethodImplOptions.AggressiveInlining)] + protected virtual bool SetProperty( + ref TValue value, + TValue newValue, + [CallerMemberName] string propertyName = null! + ) + { + if (EqualityComparer.Default.Equals(value, newValue) is true) + return false; + var oldValue = value; + if (OnPropertyChanging(oldValue, newValue, propertyName)) + return false; + value = newValue; + OnPropertyChanged(oldValue, newValue, propertyName); + return true; + } + + /// + /// 属性改变前 + /// + /// 旧值 + /// 新值 + /// 属性名称 + /// 取消为 否则为 + [MethodImpl(MethodImplOptions.AggressiveInlining)] + protected virtual bool OnPropertyChanging( + object? oldValue, + object? newValue, + [CallerMemberName] string propertyName = null! + ) + { + PropertyChanging?.Invoke(this, new(propertyName)); + if (PropertyChangingX is null) + return false; + var e = new PropertyChangingXEventArgs(propertyName, oldValue, newValue); + PropertyChangingX?.Invoke((TObject)this, e); + if (e.Cancel) + PropertyChanged?.Invoke(this, new(propertyName)); + return e.Cancel; + } + + /// + /// 属性改变后 + /// + /// 旧值 + /// 新值 + /// 属性名称 + [MethodImpl(MethodImplOptions.AggressiveInlining)] + protected virtual void OnPropertyChanged( + object? oldValue, + object? newValue, + [CallerMemberName] string propertyName = null! + ) + { + PropertyChanged?.Invoke(this, new(propertyName)); + PropertyChangedX?.Invoke((TObject)this, new(propertyName, oldValue, newValue)); + } + #endregion + + #region Event + /// + public event PropertyChangingEventHandler? PropertyChanging; + + /// + public event PropertyChangedEventHandler? PropertyChanged; + + /// + public event PropertyChangingXEventHandler? PropertyChangingX; + + /// + public event PropertyChangedXEventHandler? PropertyChangedX; + #endregion +} diff --git a/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangedXEventArgs.cs b/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangedXEventArgs.cs new file mode 100644 index 0000000..d9f80c2 --- /dev/null +++ b/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangedXEventArgs.cs @@ -0,0 +1,33 @@ +namespace HKW.HKWUtils.Observable; + +/// +/// 属性改变后事件参数 +/// +public class PropertyChangedXEventArgs : EventArgs +{ + /// + /// 属性名 + /// + public string PropertyName { get; } + + /// + /// 旧值 + /// + public object? OldValue { get; } + + /// + /// 新值 + /// + public object? NewValue { get; } + + /// + /// 属性名 + /// 旧值 + /// 新值 + public PropertyChangedXEventArgs(string propertyName, object? oldValue, object? newValue) + { + PropertyName = propertyName; + OldValue = oldValue; + NewValue = newValue; + } +} diff --git a/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangedXEventHandler.cs b/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangedXEventHandler.cs new file mode 100644 index 0000000..0303a37 --- /dev/null +++ b/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangedXEventHandler.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HKW.HKWUtils.Observable; + +/// +/// 属性改变后事件 +/// +/// 发送者 +/// 参数 +public delegate void PropertyChangedXEventHandler( + TSender sender, + PropertyChangedXEventArgs e +); diff --git a/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangingXEventArgs.cs b/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangingXEventArgs.cs new file mode 100644 index 0000000..bbd6eed --- /dev/null +++ b/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangingXEventArgs.cs @@ -0,0 +1,35 @@ +using System.ComponentModel; + +namespace HKW.HKWUtils.Observable; + +/// +/// 属性改变前事件参数 +/// +public class PropertyChangingXEventArgs : CancelEventArgs +{ + /// + /// 属性名 + /// + public string PropertyName { get; } + + /// + /// 旧值 + /// + public object? OldValue { get; } + + /// + /// 新值 + /// + public object? NewValue { get; } + + /// + /// 属性名 + /// 旧值 + /// 新值 + public PropertyChangingXEventArgs(string propertyName, object? oldValue, object? newValue) + { + PropertyName = propertyName; + OldValue = oldValue; + NewValue = newValue; + } +} diff --git a/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangingXEventHandler.cs b/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangingXEventHandler.cs new file mode 100644 index 0000000..2a28cc5 --- /dev/null +++ b/VPet.ModMaker/SimpleObservable/ObservableClass/PropertyChangingXEventHandler.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HKW.HKWUtils.Observable; + +/// +/// 属性改变前事件 +/// +/// 发送者 +/// 参数 +public delegate void PropertyChangingXEventHandler( + TSender sender, + PropertyChangingXEventArgs e +); diff --git a/VPet.ModMaker/SimpleObservable/ObservableCommand/AsyncExecuteEventHandler.cs b/VPet.ModMaker/SimpleObservable/ObservableCommand/ExecuteAsyncEventHandler.cs similarity index 70% rename from VPet.ModMaker/SimpleObservable/ObservableCommand/AsyncExecuteEventHandler.cs rename to VPet.ModMaker/SimpleObservable/ObservableCommand/ExecuteAsyncEventHandler.cs index cf0818a..2577fb4 100644 --- a/VPet.ModMaker/SimpleObservable/ObservableCommand/AsyncExecuteEventHandler.cs +++ b/VPet.ModMaker/SimpleObservable/ObservableCommand/ExecuteAsyncEventHandler.cs @@ -7,10 +7,10 @@ namespace HKW.HKWUtils.Observable; /// /// 异步执行命令事件 /// -public delegate Task AsyncExecuteEventHandler(); +public delegate Task ExecuteAsyncEventHandler(); /// /// 异步执行命令事件 /// /// 值 -public delegate Task AsyncExecuteEventHandler(T parameter); +public delegate Task ExecuteAsyncEventHandler(T parameter); diff --git a/VPet.ModMaker/SimpleObservable/ObservableCommand/ObservableCommand.cs b/VPet.ModMaker/SimpleObservable/ObservableCommand/ObservableCommand.cs index 3899e1f..4e70cc7 100644 --- a/VPet.ModMaker/SimpleObservable/ObservableCommand/ObservableCommand.cs +++ b/VPet.ModMaker/SimpleObservable/ObservableCommand/ObservableCommand.cs @@ -10,41 +10,43 @@ namespace HKW.HKWUtils.Observable; /// /// 可观察命令 /// -[DebuggerDisplay("\\{ObservableCommand, CanExecute = {CanExecuteProperty.Value}\\}")] -public class ObservableCommand : ICommand +[DebuggerDisplay("\\{ObservableCommand, CanExecute = {IsCanExecute.Value}\\}")] +public class ObservableCommand : ObservableClass, ICommand { + bool _isCanExecute = true; + /// /// 能执行的属性 /// - public ObservableValue CanExecuteProperty { get; } = new(true); + public bool IsCanExecute + { + get => _isCanExecute; + set => SetProperty(ref _isCanExecute, value); + } + + bool _currentCanExecute = true; /// /// 当前可执行状态 + /// + /// 在执行异步事件时会强制为 , 但异步结束后会恢复为 的值 + /// /// - public ObservableValue CurrentCanExecute { get; } = new(true); + public bool CurrentCanExecute + { + get => _currentCanExecute; + private set => SetProperty(ref _currentCanExecute, value); + } /// public ObservableCommand() { - CanExecuteProperty.PropertyChanged += InvokeCanExecuteChanged; - CurrentCanExecute.PropertyChanged += InvokeCanExecuteChanged; - CurrentCanExecute.ValueChanging += CurrentCanExecute_ValueChanging; + PropertyChanged += OnCanExecuteChanged; } - private void CurrentCanExecute_ValueChanging( - ObservableValue sender, - ValueChangingEventArgs e - ) + private void OnCanExecuteChanged(object? sender, PropertyChangedEventArgs e) { - if (e.NewValue is true && CanExecuteProperty.Value is false) - e.Cancel = true; - else - e.Cancel = false; - } - - private void InvokeCanExecuteChanged(object? sender, PropertyChangedEventArgs e) - { - CanExecuteChanged?.Invoke(sender, e); + CanExecuteChanged?.Invoke(this, new()); } #region ICommand @@ -55,7 +57,7 @@ public class ObservableCommand : ICommand /// 能被执行为 否则为 public bool CanExecute(object? parameter) { - return CurrentCanExecute.Value && CanExecuteProperty.Value; + return CurrentCanExecute && IsCanExecute; } /// @@ -64,71 +66,36 @@ public class ObservableCommand : ICommand /// 参数 public async void Execute(object? parameter) { + if (IsCanExecute is not true) + return; ExecuteCommand?.Invoke(); await ExecuteAsync(); } /// - /// 执行异步方法, 会在等待中关闭按钮的可执行性, 完成后恢复 + /// 执行异步方法, 会在等待中修改 , 完成后恢复 + /// + /// 若要在执行此方法时触发 事件, 请将 设置为 + /// /// - /// 等待 - private async Task ExecuteAsync() + /// 设置为 时触发 事件 + /// 任务 + public async Task ExecuteAsync(bool runAlone = false) { - if (AsyncExecuteCommand is null) + if (IsCanExecute is not true) return; - CurrentCanExecute.Value = false; + if (runAlone) + ExecuteCommand?.Invoke(); + if (ExecuteAsyncCommand is null) + return; + CurrentCanExecute = false; foreach ( - var asyncEvent in AsyncExecuteCommand + var asyncEvent in ExecuteAsyncCommand .GetInvocationList() - .Cast() + .Cast() ) await asyncEvent.Invoke(); - CurrentCanExecute.Value = true; - } - #endregion - - #region NotifyReceiver - /// - /// 添加通知属性改变后接收器 - /// - /// 添加的接口触发后会执行 - /// - /// 示例: - /// value = new(); - /// ObservableCommand command = new(); - /// command.AddNotifyReceiver(value); - /// command.NotifyCanExecuteReceived += (ref bool canExecute) => - /// { - /// canExecute = false; // trigger this - /// }; - /// value.EnumValue = "A"; // execute this - /// // result: value.EnumValue == "A" , command.CanExecuteProperty == false - /// ]]> - /// - /// - /// 通知属性改变后接口 - public void AddNotifyReceiver(params INotifyPropertyChanged[] notifies) - { - foreach (var notify in notifies) - notify.PropertyChanged += Notify_PropertyChanged; - } - - /// - /// 删除通知属性改变后接收器 - /// - /// 通知属性改变后接口 - public void RemoveNotifyReceiver(params INotifyPropertyChanged[] notifies) - { - foreach (var notify in notifies) - notify.PropertyChanged -= Notify_PropertyChanged; - } - - private void Notify_PropertyChanged(object? sender, PropertyChangedEventArgs e) - { - var args = new CancelEventArgs(); - NotifyCanExecuteReceived?.Invoke(this, args); - CanExecuteProperty.Value = args.Cancel; + CurrentCanExecute = true; } #endregion @@ -146,11 +113,6 @@ public class ObservableCommand : ICommand /// /// 异步执行事件 /// - public event AsyncExecuteEventHandler? AsyncExecuteCommand; - - /// - /// 可执行通知接收器事件 - /// - public event NotifyReceivedEventHandler? NotifyCanExecuteReceived; + public event ExecuteAsyncEventHandler? ExecuteAsyncCommand; #endregion } diff --git a/VPet.ModMaker/SimpleObservable/ObservableCommand/ObservableCommandT.cs b/VPet.ModMaker/SimpleObservable/ObservableCommand/ObservableCommandT.cs index 759f6d1..9fe11f7 100644 --- a/VPet.ModMaker/SimpleObservable/ObservableCommand/ObservableCommandT.cs +++ b/VPet.ModMaker/SimpleObservable/ObservableCommand/ObservableCommandT.cs @@ -8,110 +8,112 @@ using System.Windows.Input; namespace HKW.HKWUtils.Observable; /// -/// 带参数的可观察命令 +/// 具有参数的可观察命令 /// -/// 参数类型 -[DebuggerDisplay("\\{ObservableCommand, CanExecute = {CanExecuteProperty.Value}\\}")] -public class ObservableCommand : ICommand - where T : notnull +[DebuggerDisplay("\\{ObservableCommand, CanExecute = {IsCanExecute.Value}\\}")] +public class ObservableCommand : ObservableClass, ICommand { - /// - public ObservableValue CanExecuteProperty { get; } = new(true); + bool _isCanExecute = true; + + /// + /// 能执行的属性 + /// + public bool IsCanExecute + { + get => _isCanExecute; + set => SetProperty(ref _isCanExecute, value); + } + + bool _currentCanExecute = true; /// /// 当前可执行状态 + /// + /// 在执行异步事件时会强制为 , 但异步结束后会恢复为 的值 + /// /// - public ObservableValue CurrentCanExecute { get; } = new(true); + public bool CurrentCanExecute + { + get => _currentCanExecute; + private set => SetProperty(ref _currentCanExecute, value); + } /// public ObservableCommand() { - CanExecuteProperty.PropertyChanged += InvokeCanExecuteChanged; - CurrentCanExecute.PropertyChanged += InvokeCanExecuteChanged; - CurrentCanExecute.ValueChanging += CurrentCanExecute_ValueChanging; + PropertyChanged += OnCanExecuteChanged; } - private void CurrentCanExecute_ValueChanging( - ObservableValue sender, - ValueChangingEventArgs e - ) + private void OnCanExecuteChanged(object? sender, PropertyChangedEventArgs e) { - if (e.NewValue is true && CanExecuteProperty.Value is false) - e.Cancel = true; - else - e.Cancel = false; - } - - private void InvokeCanExecuteChanged(object? sender, PropertyChangedEventArgs e) - { - CanExecuteChanged?.Invoke(sender, e); + CanExecuteChanged?.Invoke(this, new()); } #region ICommand - /// + /// + /// 能否被执行 + /// + /// 参数 + /// 能被执行为 否则为 public bool CanExecute(object? parameter) { - return CurrentCanExecute.Value && CanExecuteProperty.Value; + return CurrentCanExecute && IsCanExecute; } - /// + /// + /// 执行方法 + /// + /// 参数 public async void Execute(object? parameter) { + if (IsCanExecute is not true) + return; ExecuteCommand?.Invoke((T)parameter!); await ExecuteAsync((T)parameter!); } - /// + /// + /// 执行异步方法, 会在等待中修改 , 完成后恢复 + /// + /// 若要在执行此方法时触发 事件, 请将 设置为 + /// + /// /// 参数 - private async Task ExecuteAsync(T parameter) + /// 设置为 时触发 事件 + /// 任务 + public async Task ExecuteAsync(T parameter, bool runAlone = false) { - if (AsyncExecuteCommand is null) + if (IsCanExecute is not true) return; - CurrentCanExecute.Value = false; + if (runAlone) + ExecuteCommand?.Invoke(parameter); + if (ExecuteAsyncCommand is null) + return; + CurrentCanExecute = false; foreach ( - var asyncEvent in AsyncExecuteCommand + var asyncEvent in ExecuteAsyncCommand .GetInvocationList() - .Cast>() + .Cast>() ) await asyncEvent.Invoke(parameter); - CurrentCanExecute.Value = true; - } - #endregion - - #region NotifyReceiver - /// - public void AddNotifyReceiver(params INotifyPropertyChanged[] notifies) - { - foreach (var notify in notifies) - notify.PropertyChanged += Notify_PropertyChanged; - } - - /// - public void RemoveNotifyReceiver(params INotifyPropertyChanged[] notifies) - { - foreach (var notify in notifies) - notify.PropertyChanged -= Notify_PropertyChanged; - } - - private void Notify_PropertyChanged(object? sender, PropertyChangedEventArgs e) - { - var args = new CancelEventArgs(); - NotifyCanExecuteReceived?.Invoke(this, args); - CanExecuteProperty.Value = args.Cancel; + CurrentCanExecute = true; } #endregion #region Event - /// + /// + /// 能否执行属性改变后事件 + /// public event EventHandler? CanExecuteChanged; - /// + /// + /// 执行事件 + /// public event ExecuteEventHandler? ExecuteCommand; - /// - public event AsyncExecuteEventHandler? AsyncExecuteCommand; - - /// - public event NotifyReceivedEventHandler? NotifyCanExecuteReceived; + /// + /// 异步执行事件 + /// + public event ExecuteAsyncEventHandler? ExecuteAsyncCommand; #endregion } diff --git a/VPet.ModMaker/SimpleObservable/ObservableValue/ObservableValue.cs b/VPet.ModMaker/SimpleObservable/ObservableValue/ObservableValue.cs index f3a3a3f..ef6ef79 100644 --- a/VPet.ModMaker/SimpleObservable/ObservableValue/ObservableValue.cs +++ b/VPet.ModMaker/SimpleObservable/ObservableValue/ObservableValue.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; +using System.Runtime.CompilerServices; namespace HKW.HKWUtils.Observable; @@ -169,55 +170,36 @@ public class ObservableValue } /// - public override bool Equals(object? obj) + public override int GetHashCode() { - return Equals(obj as ObservableValue); + return Value?.GetHashCode() ?? 0; } /// - public override int GetHashCode() + public override bool Equals(object? obj) { - return Guid.GetHashCode(); + return obj is ObservableValue value + && EqualityComparer.Default.Equals(Value, value.Value); } /// public bool Equals(ObservableValue? other) { - return Guid.Equals(other?.Guid) is true; + return other is ObservableValue value + && EqualityComparer.Default.Equals(Value, value.Value); } - /// - /// 值相等 - /// - /// 其它可观察值 - /// 相等为 否则为 - public bool ValueEquals(ObservableValue other) + /// + public static bool operator ==(ObservableValue a, ObservableValue b) { - return Value?.Equals(other.Value) is true; + return EqualityComparer.Default.Equals(a.Value, b.Value); } - /// - /// 判断 相等 - /// - /// 左值 - /// 右值 - /// 相等为 否则为 - public static bool operator ==(ObservableValue value1, ObservableValue value2) + /// + public static bool operator !=(ObservableValue a, ObservableValue b) { - return value1.Value?.Equals(value2.Value) is true; + return (a == b) is not true; } - - /// - /// 判断 不相等 - /// - /// 左值 - /// 右值 - /// 不相等为 否则为 - public static bool operator !=(ObservableValue value1, ObservableValue value2) - { - return value1.Value?.Equals(value2.Value) is not true; - } - #endregion #region Event diff --git a/VPet.ModMaker/Usings.cs b/VPet.ModMaker/Usings.cs new file mode 100644 index 0000000..2d09127 --- /dev/null +++ b/VPet.ModMaker/Usings.cs @@ -0,0 +1,9 @@ +global using global::System; +global using global::System.Collections.Generic; +global using global::System.IO; +global using global::System.Linq; +global using global::System.Net.Http; +global using global::System.Threading; +global using global::System.Threading.Tasks; +global using global::HKW.HKWUtils; +global using global::HKW.HKWUtils.Observable; diff --git a/VPet.ModMaker/Models/Expansions.cs b/VPet.ModMaker/Utils/Expansions.cs similarity index 95% rename from VPet.ModMaker/Models/Expansions.cs rename to VPet.ModMaker/Utils/Expansions.cs index 7a27670..8519668 100644 --- a/VPet.ModMaker/Models/Expansions.cs +++ b/VPet.ModMaker/Utils/Expansions.cs @@ -12,10 +12,9 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Media; using System.Windows.Media.Imaging; -using VPet.ModMaker.Models.ModModel; using VPet_Simulator.Core; -namespace HKW.Models; +namespace HKW.HKWUtils; /// /// 拓展 @@ -45,10 +44,9 @@ public static class Extensions /// 图像资源 public static void CloseStream(this ImageSource source) { - if (source is BitmapImage image) - { - image.StreamSource?.Close(); - } + if (source is not BitmapImage image) + return; + image.StreamSource?.Close(); } /// @@ -140,16 +138,6 @@ public static class Extensions return true; } - /// - /// 是含有名称的动画 - /// - /// - /// - public static bool IsHasNameAnime(this GraphInfo.GraphType graphType) - { - return AnimeTypeModel.HasNameAnimes.Contains(graphType); - } - /// /// 流内容对比 /// diff --git a/VPet.ModMaker/Utils/HashCode.cs b/VPet.ModMaker/Utils/HashCode.cs new file mode 100644 index 0000000..2af45ae --- /dev/null +++ b/VPet.ModMaker/Utils/HashCode.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HKW.HKWUtils; + +/// +/// 哈希值 +/// +public class HashCode +{ + /// + /// 默认种子 + /// + public const int DefaultSeed = 114514; + + /// + /// 默认系数 + /// + public const int DefaultFactor = 1919810; + + /// + /// 组合哈希值 + /// + /// 值 + /// 组合的哈希值 + public static int Combine(params object[] values) + { + return CustomHash(DefaultSeed, DefaultFactor, values.Select(v => v.GetHashCode())); + } + + /// + /// 组合哈希值 + /// + /// 种子 + /// 系数 + /// 值 + /// 组合的哈希值 + public static int Combine(int seed, int factor, params object[] values) + { + return CustomHash(seed, factor, values.Select(v => v.GetHashCode())); + } + + /// + /// 自定义组合哈希 + /// + /// 种子 + /// 系数 + /// 哈希集合 + /// 组合的哈希 + public static int CustomHash(int seed, int factor, IEnumerable collection) + { + int hash = seed; + foreach (int i in collection) + hash = unchecked((hash * factor) + i); + return hash; + } + + /// + /// 自定义组合哈希 + /// + /// 种子 + /// 系数 + /// 哈希集合 + /// 组合的哈希 + public static int CustomHash(int seed, int factor, params int[] values) + { + return CustomHash(seed, factor, collection: values); + } +} diff --git a/VPet.ModMaker/Utils/ObservableEnumFlags.cs b/VPet.ModMaker/Utils/ObservableEnumFlags.cs new file mode 100644 index 0000000..9712a7c --- /dev/null +++ b/VPet.ModMaker/Utils/ObservableEnumFlags.cs @@ -0,0 +1,81 @@ +using HKW.HKWUtils.Observable; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; + +namespace HKW.HKWUtils; + +/// +/// 可观察的枚举标签模型 +/// +/// 枚举类型 +public class ObservableEnumFlags : ObservableClass> + where T : Enum +{ + private T _EnumValue; + public T EnumValue + { + get => _EnumValue; + set => SetProperty(ref _EnumValue, value); + } + + /// + /// 添加枚举命令 + /// + public ObservableCommand AddCommand { get; } = new(); + + /// + /// 删除枚举命令 + /// + public ObservableCommand RemoveCommand { get; } = new(); + + /// + /// 枚举类型 + /// + public Type EnumType = typeof(T); + + /// + /// 枚举基类 + /// + public Type UnderlyingType { get; } = Enum.GetUnderlyingType(typeof(T)); + + public ObservableEnumFlags() + { + if (Attribute.IsDefined(EnumType, typeof(FlagsAttribute)) is false) + throw new Exception($"此枚举类型未使用特性 [{nameof(FlagsAttribute)}]"); + AddCommand.ExecuteCommand += AddCommand_Execute; + RemoveCommand.ExecuteCommand += RemoveCommand_Execute; + } + + public ObservableEnumFlags(T value) + : this() + { + EnumValue = value; + } + + private void AddCommand_Execute(T v) + { + if (UnderlyingType == typeof(int)) + { + EnumValue = (T) + Enum.Parse(EnumType, (Convert.ToInt32(EnumValue) | Convert.ToInt32(v)).ToString()); + } + else + throw new NotImplementedException($"Value type: {UnderlyingType}"); + } + + private void RemoveCommand_Execute(T v) + { + if (UnderlyingType == typeof(int)) + { + EnumValue = (T) + Enum.Parse(EnumType, (Convert.ToInt32(EnumValue) & ~Convert.ToInt32(v)).ToString()); + } + else + throw new NotImplementedException($"Value type: {UnderlyingType}"); + } +} diff --git a/VPet.ModMaker/Utils/ObservablePoint.cs b/VPet.ModMaker/Utils/ObservablePoint.cs new file mode 100644 index 0000000..a72bb86 --- /dev/null +++ b/VPet.ModMaker/Utils/ObservablePoint.cs @@ -0,0 +1,79 @@ +using HKW.HKWUtils.Observable; + +namespace HKW.HKWUtils; + +/// +/// 可观察地点 +/// +/// 类型 +public class ObservablePoint + : ObservableClass>, + IEquatable> +{ + private T _x; + public T X + { + get => _x; + set => SetProperty(ref _x, value); + } + + private T _y; + public T Y + { + get => _y; + set => SetProperty(ref _y, value); + } + + public ObservablePoint() { } + + public ObservablePoint(T x, T y) + { + X = x; + Y = y; + } + + /// + /// 复制一个新的对象 + /// + /// 新对象 + public ObservablePoint Copy() + { + return new(X, Y); + } + + #region Other + + /// + public override int GetHashCode() + { + return HashCode.Combine(X, Y); + } + + /// + public override bool Equals(object? obj) + { + return obj is ObservablePoint temp + && EqualityComparer.Default.Equals(X, temp.X) + && EqualityComparer.Default.Equals(Y, temp.Y); + } + + /// + public bool Equals(ObservablePoint? other) + { + return Equals(obj: other); + } + + /// + public static bool operator ==(ObservablePoint a, ObservablePoint b) + { + return Equals(a, b); + } + + /// + public static bool operator !=(ObservablePoint a, ObservablePoint b) + { + return Equals(a, b) is not true; + } + + #endregion +} diff --git a/VPet.ModMaker/Utils/ObservableRange.cs b/VPet.ModMaker/Utils/ObservableRange.cs new file mode 100644 index 0000000..afe2141 --- /dev/null +++ b/VPet.ModMaker/Utils/ObservableRange.cs @@ -0,0 +1,82 @@ +using HKW.HKWUtils; +using HKW.HKWUtils.Observable; +using System.ComponentModel; +using System.Runtime.CompilerServices; + +namespace HKW.HKWUtils; + +/// +/// 可观察的范围 +/// +/// 类型 +public class ObservableRange + : ObservableClass>, + IEquatable> +{ + private T _min; + public T Min + { + get => _min; + set => SetProperty(ref _min, value); + } + + private T _max; + public T Max + { + get => _max; + set => SetProperty(ref _max, value); + } + + public ObservableRange() { } + + public ObservableRange(T min, T max) + { + _min = min; + _max = max; + } + + /// + /// 复制一个新的对象 + /// + /// 新对象 + public ObservableRange Copy() + { + return new(Min, Max); + } + + #region Other + + /// + public override int GetHashCode() + { + return HashCode.Combine(Min, Max); + } + + /// + public override bool Equals(object? obj) + { + return obj is ObservableRange temp + && EqualityComparer.Default.Equals(Min, temp.Min) + && EqualityComparer.Default.Equals(Max, temp.Max); + } + + /// + public bool Equals(ObservableRange? other) + { + return Equals(obj: other); + } + + /// + public static bool operator ==(ObservableRange a, ObservableRange b) + { + return Equals(a, b); + } + + /// + public static bool operator !=(ObservableRange a, ObservableRange b) + { + return Equals(a, b) is not true; + } + + #endregion +} diff --git a/VPet.ModMaker/Utils/ObservableRect.cs b/VPet.ModMaker/Utils/ObservableRect.cs new file mode 100644 index 0000000..6221bc9 --- /dev/null +++ b/VPet.ModMaker/Utils/ObservableRect.cs @@ -0,0 +1,91 @@ +using HKW.HKWUtils.Observable; + +namespace HKW.HKWUtils; + +public class ObservableRect : ObservableClass>, IEquatable> +{ + private T _x; + public T X + { + get => _x; + set => SetProperty(ref _x, value); + } + + private T _y; + public T Y + { + get => _y; + set => SetProperty(ref _y, value); + } + + private T _width; + public T Width + { + get => _width; + set => SetProperty(ref _width, value); + } + + private T _heigth; + public T Height + { + get => _heigth; + set => SetProperty(ref _heigth, value); + } + + public ObservableRect() { } + + public ObservableRect(T x, T y, T width, T hetght) + { + X = x; + Y = y; + Width = width; + Height = hetght; + } + + /// + /// 复制一个新的对象 + /// + /// 新对象 + public ObservableRect Copy() + { + return new(X, Y, Width, Height); + } + + #region Other + + /// + public override int GetHashCode() + { + return HashCode.Combine(X, Y, Width, Height); + } + + /// + public override bool Equals(object? obj) + { + return obj is ObservableRect temp + && EqualityComparer.Default.Equals(X, temp.X) + && EqualityComparer.Default.Equals(Y, temp.Y) + && EqualityComparer.Default.Equals(Width, temp.Width) + && EqualityComparer.Default.Equals(Height, temp.Height); + } + + /// + public bool Equals(ObservableRect? other) + { + return Equals(obj: other); + } + + /// + public static bool operator ==(ObservableRect a, ObservableRect b) + { + return Equals(a, b); + } + + /// + public static bool operator !=(ObservableRect a, ObservableRect b) + { + return Equals(a, b) is not true; + } + + #endregion +} diff --git a/VPet.ModMaker/Models/Utils.cs b/VPet.ModMaker/Utils/Utils.cs similarity index 98% rename from VPet.ModMaker/Models/Utils.cs rename to VPet.ModMaker/Utils/Utils.cs index 1d348a2..d8763ec 100644 --- a/VPet.ModMaker/Models/Utils.cs +++ b/VPet.ModMaker/Utils/Utils.cs @@ -5,9 +5,8 @@ using System.IO; using System.Linq; using System.Text; using System.Windows.Media.Imaging; -using VPet.ModMaker; -namespace HKW.Models; +namespace HKW.HKWUtils; /// /// 工具 diff --git a/VPet.ModMaker/VPet.ModMaker.csproj b/VPet.ModMaker/VPet.ModMaker.csproj index 86d81bb..3ffcaea 100644 --- a/VPet.ModMaker/VPet.ModMaker.csproj +++ b/VPet.ModMaker/VPet.ModMaker.csproj @@ -98,6 +98,7 @@ App.xaml + @@ -110,12 +111,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + - @@ -136,18 +162,6 @@ - - - - - - - - - - - - @@ -217,7 +231,6 @@ Settings.settings True - FoodEditWindow.xaml diff --git a/VPet.ModMaker/ViewModels/ModEdit/AddCultureWindowVM.cs b/VPet.ModMaker/ViewModels/ModEdit/AddCultureWindowVM.cs index 6728e05..d6cb6c9 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/AddCultureWindowVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/AddCultureWindowVM.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using LinePutScript.Localization.WPF; using System; using System.Collections.Generic; diff --git a/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/AnimeEditWindowVM.cs b/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/AnimeEditWindowVM.cs index 155d4e6..8ed0d6e 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/AnimeEditWindowVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/AnimeEditWindowVM.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using LinePutScript.Localization.WPF; using Microsoft.Win32; using System; @@ -123,7 +123,7 @@ public class AnimeEditWindowVM CurrentAnimeModel.ValueChanged += CurrentAnimeModel_ValueChanged; - PlayCommand.AsyncExecuteCommand += PlayCommand_AsyncExecuteEvent; + PlayCommand.ExecuteAsyncCommand += PlayCommand_AsyncExecuteEvent; StopCommand.ExecuteCommand += StopCommand_ExecuteEvent; AddAnimeCommand.ExecuteCommand += AddAnimeCommand_ExecuteEvent; RemoveAnimeCommand.ExecuteCommand += RemoveAnimeCommand_ExecuteEvent; diff --git a/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/AnimePageVM.cs b/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/AnimePageVM.cs index 8978e2b..9fa6fd0 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/AnimePageVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/AnimePageVM.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using LinePutScript.Localization.WPF; using Panuon.WPF.UI; using System; diff --git a/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/FoodAnimeEditWindowVM.cs b/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/FoodAnimeEditWindowVM.cs index 5dc58d4..b51a355 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/FoodAnimeEditWindowVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/FoodAnimeEditWindowVM.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using LinePutScript.Localization.WPF; using Microsoft.Win32; using System; @@ -24,7 +24,6 @@ public class FoodAnimeEditWindowVM /// public PetModel CurrentPet { get; set; } - // TODO: 使用内部资源 /// /// 默认食物图片 /// @@ -211,7 +210,7 @@ public class FoodAnimeEditWindowVM CurrentAnimeModel.ValueChanged += CurrentAnimeModel_ValueChanged; - PlayCommand.AsyncExecuteCommand += PlayCommand_AsyncExecuteEvent; + PlayCommand.ExecuteAsyncCommand += PlayCommand_AsyncExecuteEvent; StopCommand.ExecuteCommand += StopCommand_ExecuteEvent; ReplaceFoodImageCommand.ExecuteCommand += ChangeFoodImageCommand_ExecuteEvent; ResetFoodImageCommand.ExecuteCommand += ResetFoodImageCommand_ExecuteEvent; diff --git a/VPet.ModMaker/ViewModels/ModEdit/ClickTextEdit/ClickTextPageVM.cs b/VPet.ModMaker/ViewModels/ModEdit/ClickTextEdit/ClickTextPageVM.cs index dc64171..15d881a 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/ClickTextEdit/ClickTextPageVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/ClickTextEdit/ClickTextPageVM.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using LinePutScript.Localization.WPF; using System; using System.Collections.Generic; diff --git a/VPet.ModMaker/ViewModels/ModEdit/FoodEdit/FoodEditWindowVM.cs b/VPet.ModMaker/ViewModels/ModEdit/FoodEdit/FoodEditWindowVM.cs index 2bcbe21..98b0111 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/FoodEdit/FoodEditWindowVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/FoodEdit/FoodEditWindowVM.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using LinePutScript.Localization.WPF; using Microsoft.Win32; using System; diff --git a/VPet.ModMaker/ViewModels/ModEdit/FoodEdit/FoodPageVM.cs b/VPet.ModMaker/ViewModels/ModEdit/FoodEdit/FoodPageVM.cs index 2edd0d1..40eb8ce 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/FoodEdit/FoodPageVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/FoodEdit/FoodPageVM.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using LinePutScript.Localization.WPF; using System; using System.Collections.Generic; diff --git a/VPet.ModMaker/ViewModels/ModEdit/I18nEdit/I18nEditWindowVM.cs b/VPet.ModMaker/ViewModels/ModEdit/I18nEdit/I18nEditWindowVM.cs index 92870a0..02834a5 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/I18nEdit/I18nEditWindowVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/I18nEdit/I18nEditWindowVM.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -296,7 +296,7 @@ public class I18nEditWindowVM { foreach (var pet in model.Pets) { - if (pet.IsSimplePetModel) + if (pet.FromMain.Value) continue; AddData(pet.Id, pet, (m) => m.Name); AddData(pet.PetNameId, pet, (m) => m.PetName); diff --git a/VPet.ModMaker/ViewModels/ModEdit/LowTextEdit/LowTextPageVM.cs b/VPet.ModMaker/ViewModels/ModEdit/LowTextEdit/LowTextPageVM.cs index ee52062..bd4b8ea 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/LowTextEdit/LowTextPageVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/LowTextEdit/LowTextPageVM.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using LinePutScript.Localization.WPF; using System; using System.Collections.Generic; diff --git a/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs b/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs index 2df879a..1547225 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs @@ -18,7 +18,6 @@ using Panuon.WPF.UI; using VPet.ModMaker.Views.ModEdit.I18nEdit; using System.Globalization; using Ookii.Dialogs.Wpf; -using HKW.Models; namespace VPet.ModMaker.ViewModels.ModEdit; diff --git a/VPet.ModMaker/ViewModels/ModEdit/MoveEdit/MoveEditWindowVM.cs b/VPet.ModMaker/ViewModels/ModEdit/MoveEdit/MoveEditWindowVM.cs index d0cf992..556d46b 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/MoveEdit/MoveEditWindowVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/MoveEdit/MoveEditWindowVM.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using LinePutScript.Localization.WPF; using Microsoft.Win32; using System; diff --git a/VPet.ModMaker/ViewModels/ModEdit/MoveEdit/MovePageVM.cs b/VPet.ModMaker/ViewModels/ModEdit/MoveEdit/MovePageVM.cs index 6a22e35..0cef5c4 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/MoveEdit/MovePageVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/MoveEdit/MovePageVM.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using LinePutScript.Localization.WPF; using System; using System.Collections.Generic; diff --git a/VPet.ModMaker/ViewModels/ModEdit/PetEdit/PetEditWindowVM.cs b/VPet.ModMaker/ViewModels/ModEdit/PetEdit/PetEditWindowVM.cs index d206850..7ec660f 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/PetEdit/PetEditWindowVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/PetEdit/PetEditWindowVM.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using LinePutScript.Localization.WPF; using Microsoft.Win32; using System; diff --git a/VPet.ModMaker/ViewModels/ModEdit/PetEdit/PetPageVM.cs b/VPet.ModMaker/ViewModels/ModEdit/PetEdit/PetPageVM.cs index 808fd08..6b5c3a3 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/PetEdit/PetPageVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/PetEdit/PetPageVM.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using LinePutScript.Localization.WPF; using System; using System.Collections.Generic; @@ -66,11 +66,12 @@ public class PetPageVM public void Edit(PetModel model) { - if (model.IsSimplePetModel) - { - MessageBox.Show("这是本体自带的宠物, 无法编辑".Translate()); + if ( + model.FromMain.Value + && MessageBox.Show("这是本体自带的宠物, 确定要编辑吗".Translate(), "", MessageBoxButton.YesNo) + is not MessageBoxResult.Yes + ) return; - } var window = new PetEditWindow(); var vm = window.ViewModel; vm.OldPet = model; @@ -86,7 +87,7 @@ public class PetPageVM private void Remove(PetModel model) { - if (model.IsSimplePetModel) + if (model.FromMain.Value) { MessageBox.Show("这是本体自带的宠物, 无法删除".Translate()); return; diff --git a/VPet.ModMaker/ViewModels/ModEdit/SelectTextEdit/SelectTextPageVM.cs b/VPet.ModMaker/ViewModels/ModEdit/SelectTextEdit/SelectTextPageVM.cs index 2a78a9f..b4d9964 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/SelectTextEdit/SelectTextPageVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/SelectTextEdit/SelectTextPageVM.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using LinePutScript.Localization.WPF; using System; using System.Collections.Generic; diff --git a/VPet.ModMaker/ViewModels/ModEdit/WorkEdit/WorkEditWindowVM.cs b/VPet.ModMaker/ViewModels/ModEdit/WorkEdit/WorkEditWindowVM.cs index 6870d70..33be058 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/WorkEdit/WorkEditWindowVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/WorkEdit/WorkEditWindowVM.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using LinePutScript.Localization.WPF; using Microsoft.Win32; using System; diff --git a/VPet.ModMaker/ViewModels/ModEdit/WorkEdit/WorkPageVM.cs b/VPet.ModMaker/ViewModels/ModEdit/WorkEdit/WorkPageVM.cs index 56af9c7..84859e6 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/WorkEdit/WorkPageVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/WorkEdit/WorkPageVM.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using LinePutScript.Localization.WPF; using System; using System.Collections.Generic; diff --git a/VPet.ModMaker/Views/ModEdit/AnimeEdit/AnimeEditWindow.xaml.cs b/VPet.ModMaker/Views/ModEdit/AnimeEdit/AnimeEditWindow.xaml.cs index 8d3a987..3202721 100644 --- a/VPet.ModMaker/Views/ModEdit/AnimeEdit/AnimeEditWindow.xaml.cs +++ b/VPet.ModMaker/Views/ModEdit/AnimeEdit/AnimeEditWindow.xaml.cs @@ -1,5 +1,4 @@ -using HKW.Models; -using LinePutScript.Localization.WPF; +using LinePutScript.Localization.WPF; using System; using System.Collections.Generic; using System.Linq; diff --git a/VPet.ModMaker/Views/ModEdit/AnimeEdit/AnimePage.xaml b/VPet.ModMaker/Views/ModEdit/AnimeEdit/AnimePage.xaml index 50b67f7..4a22cea 100644 --- a/VPet.ModMaker/Views/ModEdit/AnimeEdit/AnimePage.xaml +++ b/VPet.ModMaker/Views/ModEdit/AnimeEdit/AnimePage.xaml @@ -39,7 +39,6 @@ x:Name="ComboBox_Pet" Grid.Column="1" pu:ComboBoxHelper.Watermark="{ll:Str 选择宠物}" - DisplayMemberPath="Id.Value" ItemsSource="{Binding Pets}" SelectedItem="{Binding CurrentPet.Value}" Style="{DynamicResource StandardComboBoxStyle}"> @@ -48,6 +47,14 @@ + + + + + + + + diff --git a/VPet.ModMaker/Views/ModEdit/AnimeEdit/FoodAnimeEditWindow.xaml b/VPet.ModMaker/Views/ModEdit/AnimeEdit/FoodAnimeEditWindow.xaml index b9c58bd..b8530f4 100644 --- a/VPet.ModMaker/Views/ModEdit/AnimeEdit/FoodAnimeEditWindow.xaml +++ b/VPet.ModMaker/Views/ModEdit/AnimeEdit/FoodAnimeEditWindow.xaml @@ -348,7 +348,7 @@ + Value="{Binding Rect.Width}" /> @@ -360,7 +360,7 @@ @@ -368,7 +368,7 @@ @@ -380,7 +380,6 @@ - @@ -433,7 +432,7 @@ - + @@ -442,8 +441,8 @@ - - + + @@ -481,7 +480,7 @@ - + @@ -490,8 +489,8 @@ - - + + diff --git a/VPet.ModMaker/Views/ModEdit/AnimeEdit/FoodAnimeEditWindow.xaml.cs b/VPet.ModMaker/Views/ModEdit/AnimeEdit/FoodAnimeEditWindow.xaml.cs index c9dfeea..e17b3c7 100644 --- a/VPet.ModMaker/Views/ModEdit/AnimeEdit/FoodAnimeEditWindow.xaml.cs +++ b/VPet.ModMaker/Views/ModEdit/AnimeEdit/FoodAnimeEditWindow.xaml.cs @@ -1,5 +1,4 @@ -using HKW.Models; -using LinePutScript.Localization.WPF; +using LinePutScript.Localization.WPF; using System; using System.Collections; using System.Collections.Generic; diff --git a/VPet.ModMaker/Views/ModEdit/AnimeEdit/SelectGraphTypeWindow.xaml.cs b/VPet.ModMaker/Views/ModEdit/AnimeEdit/SelectGraphTypeWindow.xaml.cs index 8cd5a26..42c3553 100644 --- a/VPet.ModMaker/Views/ModEdit/AnimeEdit/SelectGraphTypeWindow.xaml.cs +++ b/VPet.ModMaker/Views/ModEdit/AnimeEdit/SelectGraphTypeWindow.xaml.cs @@ -1,5 +1,5 @@ using HKW.HKWUtils.Observable; -using HKW.Models; + using System; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/VPet.ModMaker/Views/ModEdit/MoveEdit/MovePage.xaml b/VPet.ModMaker/Views/ModEdit/MoveEdit/MovePage.xaml index dffda9d..790eca5 100644 --- a/VPet.ModMaker/Views/ModEdit/MoveEdit/MovePage.xaml +++ b/VPet.ModMaker/Views/ModEdit/MoveEdit/MovePage.xaml @@ -39,7 +39,6 @@ x:Name="ComboBox_Pet" Grid.Column="1" pu:ComboBoxHelper.Watermark="{ll:Str 选择宠物}" - DisplayMemberPath="Id.Value" ItemsSource="{Binding Pets}" SelectedItem="{Binding CurrentPet.Value}" Style="{DynamicResource StandardComboBoxStyle}"> @@ -48,6 +47,14 @@ + + + + + + + + diff --git a/VPet.ModMaker/Views/ModEdit/PetEdit/PetEditWindow.xaml b/VPet.ModMaker/Views/ModEdit/PetEdit/PetEditWindow.xaml index 87ec154..9410003 100644 --- a/VPet.ModMaker/Views/ModEdit/PetEdit/PetEditWindow.xaml +++ b/VPet.ModMaker/Views/ModEdit/PetEdit/PetEditWindow.xaml @@ -72,7 +72,7 @@ - + @@ -80,7 +80,7 @@ - + @@ -89,8 +89,8 @@ - - + + @@ -103,7 +103,7 @@ - + @@ -111,7 +111,7 @@ - + @@ -120,8 +120,8 @@ - - + + @@ -134,7 +134,7 @@ - + @@ -142,7 +142,7 @@ - + @@ -151,8 +151,8 @@ - - + + @@ -165,7 +165,7 @@ - + @@ -173,7 +173,7 @@ - + @@ -182,8 +182,8 @@ - - + + @@ -196,7 +196,7 @@ - + @@ -204,7 +204,7 @@ - + @@ -213,8 +213,8 @@ - - + + @@ -227,7 +227,7 @@ - + @@ -235,7 +235,7 @@ - + @@ -244,8 +244,8 @@ - - + + @@ -264,8 +264,8 @@ - - + + @@ -284,8 +284,8 @@ - - + + @@ -304,8 +304,8 @@ - - + + @@ -324,8 +324,8 @@ - - + + @@ -414,12 +414,12 @@ @@ -461,12 +461,12 @@ @@ -516,12 +516,12 @@ @@ -709,12 +709,12 @@