diff --git a/VPet.ModMaker/Models/I18nData.cs b/VPet.ModMaker/Models/I18nData.cs index d2cd1a7..3db9357 100644 --- a/VPet.ModMaker/Models/I18nData.cs +++ b/VPet.ModMaker/Models/I18nData.cs @@ -15,14 +15,14 @@ namespace VPet.ModMaker.Models; [DebuggerDisplay("{ID}, Count = {Datas.Count}")] public class I18nData : ObservableObjectX { - /// - /// Id - /// - #region Id + #region ID [DebuggerBrowsable(DebuggerBrowsableState.Never)] private string _id = string.Empty; - public string Id + /// + /// ID + /// + public string ID { get => _id; set => SetProperty(ref _id, value); @@ -32,5 +32,5 @@ public class I18nData : ObservableObjectX /// /// 基于 的索引的数据列表 /// - public ObservableList> Datas { get; } = new(); + //public ObservableList>> Datas { get; } = new(); } diff --git a/VPet.ModMaker/Models/I18nModel.cs b/VPet.ModMaker/Models/I18nModel.cs index ead4139..18d64e2 100644 --- a/VPet.ModMaker/Models/I18nModel.cs +++ b/VPet.ModMaker/Models/I18nModel.cs @@ -15,7 +15,7 @@ namespace VPet.ModMaker.Models; /// /// 类型 public class I18nModel : ObservableObjectX> - where T : class, new() + where T : ObservableObjectX, new() { /// /// 当前I18n数据 diff --git a/VPet.ModMaker/Models/ModModel/ModInfoModel.cs b/VPet.ModMaker/Models/ModModel/ModInfoModel.cs index d5d794a..7da2dfa 100644 --- a/VPet.ModMaker/Models/ModModel/ModInfoModel.cs +++ b/VPet.ModMaker/Models/ModModel/ModInfoModel.cs @@ -11,6 +11,7 @@ using System.Threading; using System.Threading.Tasks; using System.Windows.Media.Imaging; using HKW.HKWUtils; +using HKW.HKWUtils.Extensions; using HKW.HKWUtils.Observable; using LinePutScript; using LinePutScript.Converter; @@ -33,6 +34,88 @@ public class ModInfoModel : I18nModel Pets.CollectionChanged += Pets_CollectionChanged; } + public ModInfoModel(ModLoader loader) + : this() + { + SourcePath = loader.ModPath.FullName; + ID = loader.Name; + DescriptionID = loader.Intro; + Author = loader.Author; + GameVersion = loader.GameVer; + ModVersion = loader.Ver; + ItemID = loader.ItemID; + AuthorID = loader.AuthorID; + var imagePath = Path.Combine(loader.ModPath.FullName, "icon.png"); + if (File.Exists(imagePath)) + Image = NativeUtils.LoadImageToMemoryStream(imagePath); + foreach (var food in loader.Foods) + Foods.Add(new(food)); + foreach (var clickText in loader.ClickTexts) + ClickTexts.Add(new(clickText)); + foreach (var lowText in loader.LowTexts) + LowTexts.Add(new(lowText)); + foreach (var selectText in loader.SelectTexts) + SelectTexts.Add(new(selectText)); + + // 载入模组宠物 + foreach (var pet in loader.Pets) + { + var petModel = new PetModel(pet); + // 如果检测到本体存在同名宠物 + if (ModMakerInfo.MainPets.TryGetValue(petModel.ID, out var mainPet)) + { + // 若宠物的值为默认值并且本体同名宠物不为默认值, 则把本体宠物的值作为模组宠物的默认值 + if ( + petModel.TouchHeadRectangleLocation + == PetModel.Current.TouchHeadRectangleLocation + && petModel.TouchHeadRectangleLocation != mainPet.TouchHeadRectangleLocation + ) + petModel.TouchHeadRectangleLocation = mainPet.TouchHeadRectangleLocation; + if ( + petModel.TouchBodyRectangleLocation + == PetModel.Current.TouchBodyRectangleLocation + && petModel.TouchBodyRectangleLocation != mainPet.TouchBodyRectangleLocation + ) + petModel.TouchBodyRectangleLocation = mainPet.TouchBodyRectangleLocation; + if ( + petModel.TouchRaisedRectangleLocation + == PetModel.Current.TouchRaisedRectangleLocation + && petModel.TouchRaisedRectangleLocation != mainPet.TouchRaisedRectangleLocation + ) + petModel.TouchRaisedRectangleLocation = mainPet.TouchRaisedRectangleLocation; + if ( + petModel.RaisePoint == PetModel.Current.RaisePoint + && petModel.RaisePoint != mainPet.RaisePoint + ) + petModel.RaisePoint = mainPet.RaisePoint; + } + Pets.Add(petModel); + foreach (var p in pet.path) + LoadAnime(petModel, p); + } + + //loader.Pets.First().Name = "TestMainPet"; + //Pets.Insert(0, new(loader.Pets.First(), true)); + + // 插入本体宠物 + foreach (var pet in ModMakerInfo.MainPets) + { + // 确保Id不重复 + if (Pets.All(i => i.ID != pet.Key)) + Pets.Insert(0, pet.Value); + } + + // 载入本地化 + foreach (var lang in loader.I18nDatas) + I18nDatas.Add(lang.Key, lang.Value); + OtherI18nDatas = loader.OtherI18nDatas; + + LoadI18nDatas(); + RefreshAllId(); + if (I18nHelper.Current.CultureNames.HasValue()) + RefreshID(); + } + private void ModInfoModel_PropertyChanged(object? sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(ID)) @@ -248,88 +331,7 @@ public class ModInfoModel : I18nModel PetDisplayedCount = Pets.Count - Pets.Count(m => m.FromMain); } - public ModInfoModel(ModLoader loader) - : this() - { - SourcePath = loader.ModPath.FullName; - ID = loader.Name; - DescriptionID = loader.Intro; - Author = loader.Author; - GameVersion = loader.GameVer; - ModVersion = loader.Ver; - ItemID = loader.ItemID; - AuthorID = loader.AuthorID; - var imagePath = Path.Combine(loader.ModPath.FullName, "icon.png"); - if (File.Exists(imagePath)) - Image = NativeUtils.LoadImageToMemoryStream(imagePath); - foreach (var food in loader.Foods) - Foods.Add(new(food)); - foreach (var clickText in loader.ClickTexts) - ClickTexts.Add(new(clickText)); - foreach (var lowText in loader.LowTexts) - LowTexts.Add(new(lowText)); - foreach (var selectText in loader.SelectTexts) - SelectTexts.Add(new(selectText)); - - // 载入模组宠物 - foreach (var pet in loader.Pets) - { - var petModel = new PetModel(pet); - // 如果检测到本体存在同名宠物 - if (ModMakerInfo.MainPets.TryGetValue(petModel.ID, out var mainPet)) - { - // 若宠物的值为默认值并且本体同名宠物不为默认值, 则把本体宠物的值作为模组宠物的默认值 - if ( - petModel.TouchHeadRectangleLocation - == PetModel.Current.TouchHeadRectangleLocation - && petModel.TouchHeadRectangleLocation != mainPet.TouchHeadRectangleLocation - ) - petModel.TouchHeadRectangleLocation = mainPet.TouchHeadRectangleLocation; - if ( - petModel.TouchBodyRectangleLocation - == PetModel.Current.TouchBodyRectangleLocation - && petModel.TouchBodyRectangleLocation != mainPet.TouchBodyRectangleLocation - ) - petModel.TouchBodyRectangleLocation = mainPet.TouchBodyRectangleLocation; - if ( - petModel.TouchRaisedRectangleLocation - == PetModel.Current.TouchRaisedRectangleLocation - && petModel.TouchRaisedRectangleLocation != mainPet.TouchRaisedRectangleLocation - ) - petModel.TouchRaisedRectangleLocation = mainPet.TouchRaisedRectangleLocation; - if ( - petModel.RaisePoint == PetModel.Current.RaisePoint - && petModel.RaisePoint != mainPet.RaisePoint - ) - petModel.RaisePoint = mainPet.RaisePoint; - } - Pets.Add(petModel); - foreach (var p in pet.path) - LoadAnime(petModel, p); - } - - //loader.Pets.First().Name = "TestMainPet"; - //Pets.Insert(0, new(loader.Pets.First(), true)); - - // 插入本体宠物 - foreach (var pet in ModMakerInfo.MainPets) - { - // 确保Id不重复 - if (Pets.All(i => i.ID != pet.Key)) - Pets.Insert(0, pet.Value); - } - - // 载入本地化 - foreach (var lang in loader.I18nDatas) - I18nDatas.Add(lang.Key, lang.Value); - OtherI18nDatas = loader.OtherI18nDatas; - - LoadI18nDatas(); - RefreshAllId(); - RefreshId(); - } - - public void RefreshId() + public void RefreshID() { DescriptionID = $"{ID}_{nameof(DescriptionID)}"; } diff --git a/VPet.ModMaker/Models/ModModel/WorkModel.cs b/VPet.ModMaker/Models/ModModel/WorkModel.cs index 04573ce..696ff9d 100644 --- a/VPet.ModMaker/Models/ModModel/WorkModel.cs +++ b/VPet.ModMaker/Models/ModModel/WorkModel.cs @@ -301,7 +301,7 @@ public class WorkModel : I18nModel /// /// 边框颜色 /// - + [AdaptIgnore] public SolidColorBrush BorderBrush { get => _borderBrush; @@ -316,6 +316,7 @@ public class WorkModel : I18nModel /// /// 背景色 /// + [AdaptIgnore] public SolidColorBrush Background { get => _background; @@ -330,6 +331,7 @@ public class WorkModel : I18nModel /// /// 前景色 /// + [AdaptIgnore] public SolidColorBrush Foreground { get => _foreground; @@ -345,6 +347,7 @@ public class WorkModel : I18nModel /// /// 按钮背景色 /// + [AdaptIgnore] public SolidColorBrush ButtonBackground { get => _buttonBackground; @@ -360,6 +363,7 @@ public class WorkModel : I18nModel /// /// 按钮前景色 /// + [AdaptIgnore] public SolidColorBrush ButtonForeground { get => _buttonForeground; diff --git a/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/AnimePageVM.cs b/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/AnimePageVM.cs index 051cdca..b35c070 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/AnimePageVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/AnimeEdit/AnimePageVM.cs @@ -37,6 +37,7 @@ public class AnimePageVM : ObservableObjectX }, FilteredList = new() }; + CurrentPet = Pets.First(); PropertyChangedX += AnimePageVM_PropertyChangedX; AddCommand.ExecuteCommand += AddCommand_ExecuteCommand; diff --git a/VPet.ModMaker/ViewModels/ModEdit/I18nEdit/I18nEditWindowVM.cs b/VPet.ModMaker/ViewModels/ModEdit/I18nEdit/I18nEditWindowVM.cs index 6b63dd4..259159a 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/I18nEdit/I18nEditWindowVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/I18nEdit/I18nEditWindowVM.cs @@ -13,9 +13,48 @@ namespace VPet.ModMaker.ViewModels.ModEdit.I18nEdit; public class I18nEditWindowVM : ObservableObjectX { } //{ +// public I18nEditWindowVM() +// { +// I18nDatas = new() +// { +// Filter = (d) => +// { +// if (SearchTarget == nameof(ModInfoModel.ID)) +// { +// return d.ID.Contains(Search, StringComparison.OrdinalIgnoreCase); +// } +// else +// { +// var cultureIndex = I18nHelper.Current.CultureNames.IndexOf(SearchTarget); + +// return d.Datas[cultureIndex] +// .Value.Contains(Search, StringComparison.OrdinalIgnoreCase); +// } +// }, +// FilteredList = new() +// }; +// SearchTarget = nameof(ModInfoModel.ID); +// PropertyChanged += I18nEditWindowVM_PropertyChanged; +// } + +// private void I18nEditWindowVM_PropertyChanged( +// object? sender, +// System.ComponentModel.PropertyChangedEventArgs e +// ) +// { +// if (e.PropertyName == nameof(Search)) +// { +// I18nDatas.Refresh(); +// } +// else if (e.PropertyName == nameof(SearchTarget)) +// { +// I18nDatas.Refresh(); +// } +// } + // #region Search // [DebuggerBrowsable(DebuggerBrowsableState.Never)] -// private string _search; +// private string _search = string.Empty; // /// // /// 搜索 @@ -28,33 +67,28 @@ public class I18nEditWindowVM : ObservableObjectX { } // #endregion // /// -// /// 全部I18n数据 (Id, I18nData) +// /// 全部I18n数据 (ID, I18nData) // /// // public Dictionary AllI18nDatas { get; } = new(); // /// -// /// 全部I18n数据 -// /// -// public ObservableList I18nDatas { get; } = new(); - -// /// -// /// 显示的I18n数据 +// /// 全部的I18n数据 // /// // #region ShowI18nDatas // [DebuggerBrowsable(DebuggerBrowsableState.Never)] -// private ObservableList _showI18nDatas; +// private ObservableFilterList> _i18nDatas; -// public ObservableList ShowI18nDatas +// public ObservableFilterList> I18nDatas // { -// get => _showI18nDatas; -// set => SetProperty(ref _showI18nDatas, value); +// get => _i18nDatas; +// set => SetProperty(ref _i18nDatas, value); // } // #endregion // /// // /// 搜索目标列表 // /// -// public ObservableList SearchTargets { get; } = new() { nameof(ModInfoModel.Id) }; +// public ObservableList SearchTargets { get; } = new() { nameof(ModInfoModel.ID) }; // /// // /// 搜索目标 @@ -70,48 +104,6 @@ public class I18nEditWindowVM : ObservableObjectX { } // } // #endregion -// public I18nEditWindowVM() -// { -// //Search.ValueChanged += Search_ValueChanged;// TODO -// ShowI18nDatas = I18nDatas; -// SearchTarget = nameof(ModInfoModel.Id); -// } - -// /// -// /// 搜索改变事件 -// /// -// /// -// /// -// private void Search_ValueChanged( -// ObservableValue sender, -// ValueChangedEventArgs e -// ) -// { -// if (string.IsNullOrWhiteSpace(e.NewValue)) -// { -// ShowI18nDatas = I18nDatas; -// } -// else if (SearchTarget == nameof(ModInfoModel.Id)) -// { -// ShowI18nDatas = new( -// I18nDatas.Where(m => -// m.Id?.Contains(e.NewValue, StringComparison.OrdinalIgnoreCase) is true -// ) -// ); -// } -// else -// { -// var cultureIndex = I18nHelper.Current.CultureNames.IndexOf(SearchTarget); -// ShowI18nDatas = new( -// I18nDatas.Where(m => -// m.Datas[cultureIndex] -// .Value?.Contains(e.NewValue, StringComparison.OrdinalIgnoreCase) -// is true -// ) -// ); -// } -// } - // /// // /// 文化列表改变事件 // /// @@ -139,7 +131,7 @@ public class I18nEditWindowVM : ObservableObjectX { } // data.Value.Datas.RemoveAt(e.OldStartingIndex); // } // if (SearchTarget is null) -// SearchTarget = nameof(ModInfoModel.Id); +// SearchTarget = nameof(ModInfoModel.ID); // } // else if (e.Action is NotifyCollectionChangedAction.Replace) // { @@ -187,29 +179,29 @@ public class I18nEditWindowVM : ObservableObjectX { } // { // foreach (var food in model.Foods) // { -// AddData(food.Id, food, (m) => m.Name); -// AddData(food.DescriptionId, food, (m) => m.Description); +// AddData(food.ID, food, (m) => m.Name); +// AddData(food.DescriptionID, food, (m) => m.Description); // } // model.Foods.CollectionChanged += (s, e) => // { // if (e.Action is NotifyCollectionChangedAction.Add) // { // var newModel = (FoodModel)e.NewItems[0]; -// AddData(newModel.Id, newModel, (m) => m.Name); -// AddData(newModel.DescriptionId, newModel, (m) => m.Description); +// AddData(newModel.ID, newModel, (m) => m.Name); +// AddData(newModel.DescriptionID, newModel, (m) => m.Description); // } // else if (e.Action is NotifyCollectionChangedAction.Remove) // { // var oldModel = (FoodModel)e.OldItems[0]; -// RemoveData(oldModel.Id, oldModel, (m) => m.Name); -// RemoveData(oldModel.DescriptionId, oldModel, (m) => m.Description); +// RemoveData(oldModel.ID, oldModel, (m) => m.Name); +// RemoveData(oldModel.DescriptionID, oldModel, (m) => m.Description); // } // else if (e.Action is NotifyCollectionChangedAction.Replace) // { // var newModel = (FoodModel)e.NewItems[0]; // var oldModel = (FoodModel)e.OldItems[0]; -// ReplaceData(newModel.Id, newModel, (m) => m.Name); -// ReplaceData(newModel.DescriptionId, newModel, (m) => m.Description); +// ReplaceData(newModel.ID, newModel, (m) => m.Name); +// ReplaceData(newModel.DescriptionID, newModel, (m) => m.Description); // } // }; // } @@ -222,25 +214,25 @@ public class I18nEditWindowVM : ObservableObjectX { } // { // foreach (var text in model.ClickTexts) // { -// AddData(text.Id, text, (m) => m.Text); +// AddData(text.ID, text, (m) => m.Text); // } // model.ClickTexts.CollectionChanged += (s, e) => // { // if (e.Action is NotifyCollectionChangedAction.Add) // { // var newModel = (ClickTextModel)e.NewItems[0]; -// AddData(newModel.Id, newModel, (m) => m.Text); +// AddData(newModel.ID, newModel, (m) => m.Text); // } // else if (e.Action is NotifyCollectionChangedAction.Remove) // { // var oldModel = (ClickTextModel)e.OldItems[0]; -// RemoveData(oldModel.Id, oldModel, (m) => m.Text); +// RemoveData(oldModel.ID, oldModel, (m) => m.Text); // } // else if (e.Action is NotifyCollectionChangedAction.Replace) // { // var newModel = (ClickTextModel)e.NewItems[0]; // var oldModel = (ClickTextModel)e.OldItems[0]; -// ReplaceData(newModel.Id, newModel, (m) => m.Text); +// ReplaceData(newModel.ID, newModel, (m) => m.Text); // } // }; // } @@ -253,25 +245,25 @@ public class I18nEditWindowVM : ObservableObjectX { } // { // foreach (var text in model.LowTexts) // { -// AddData(text.Id, text, (m) => m.Text); +// AddData(text.ID, text, (m) => m.Text); // } // model.LowTexts.CollectionChanged += (s, e) => // { // if (e.Action is NotifyCollectionChangedAction.Add) // { // var newModel = (LowTextModel)e.NewItems[0]; -// AddData(newModel.Id, newModel, (m) => m.Text); +// AddData(newModel.ID, newModel, (m) => m.Text); // } // else if (e.Action is NotifyCollectionChangedAction.Remove) // { // var oldModel = (LowTextModel)e.OldItems[0]; -// RemoveData(oldModel.Id, oldModel, (m) => m.Text); +// RemoveData(oldModel.ID, oldModel, (m) => m.Text); // } // else if (e.Action is NotifyCollectionChangedAction.Replace) // { // var newModel = (LowTextModel)e.NewItems[0]; // var oldModel = (LowTextModel)e.OldItems[0]; -// ReplaceData(newModel.Id, newModel, (m) => m.Text); +// ReplaceData(newModel.ID, newModel, (m) => m.Text); // } // }; // } @@ -284,7 +276,7 @@ public class I18nEditWindowVM : ObservableObjectX { } // { // foreach (var text in model.SelectTexts) // { -// AddData(text.Id, text, (m) => m.Text); +// AddData(text.ID, text, (m) => m.Text); // AddData(text.ChooseId, text, (m) => m.Choose); // } // model.SelectTexts.CollectionChanged += (s, e) => @@ -292,20 +284,20 @@ public class I18nEditWindowVM : ObservableObjectX { } // if (e.Action is NotifyCollectionChangedAction.Add) // { // var newModel = (SelectTextModel)e.NewItems[0]; -// AddData(newModel.Id, newModel, (m) => m.Text); +// AddData(newModel.ID, newModel, (m) => m.Text); // AddData(newModel.ChooseId, newModel, (m) => m.Choose); // } // else if (e.Action is NotifyCollectionChangedAction.Remove) // { // var oldModel = (SelectTextModel)e.OldItems[0]; -// RemoveData(oldModel.Id, oldModel, (m) => m.Text); +// RemoveData(oldModel.ID, oldModel, (m) => m.Text); // RemoveData(oldModel.ChooseId, oldModel, (m) => m.Choose); // } // else if (e.Action is NotifyCollectionChangedAction.Replace) // { // var newModel = (SelectTextModel)e.NewItems[0]; // var oldModel = (SelectTextModel)e.OldItems[0]; -// ReplaceData(newModel.Id, newModel, (m) => m.Text); +// ReplaceData(newModel.ID, newModel, (m) => m.Text); // ReplaceData(newModel.ChooseId, newModel, (m) => m.Choose); // } // }; @@ -323,9 +315,9 @@ public class I18nEditWindowVM : ObservableObjectX { } // continue; // AddData(pet.ID, pet, (m) => m.Name); // AddData(pet.PetNameId, pet, (m) => m.PetName); -// AddData(pet.DescriptionId, pet, (m) => m.Description); +// AddData(pet.DescriptionID, pet, (m) => m.Description); // foreach (var work in pet.Works) -// AddData(work.Id, work, (m) => m.Name); +// AddData(work.ID, work, (m) => m.Name); // } // model.Pets.CollectionChanged += (s, e) => // { @@ -333,9 +325,9 @@ public class I18nEditWindowVM : ObservableObjectX { } // { // var newModel = (PetModel)e.NewItems[0]; // AddData(newModel.ID, newModel, (m) => m.Name); -// AddData(newModel.DescriptionId, newModel, (m) => m.Description); +// AddData(newModel.DescriptionID, newModel, (m) => m.Description); // foreach (var work in newModel.Works) -// AddData(work.Id, work, (m) => m.Name); +// AddData(work.ID, work, (m) => m.Name); // } // else if (e.Action is NotifyCollectionChangedAction.Remove) // { @@ -343,18 +335,18 @@ public class I18nEditWindowVM : ObservableObjectX { } // if (oldModel.FromMain.Value) // return; // RemoveData(oldModel.ID, oldModel, (m) => m.Name); -// RemoveData(oldModel.DescriptionId, oldModel, (m) => m.Description); +// RemoveData(oldModel.DescriptionID, oldModel, (m) => m.Description); // foreach (var work in oldModel.Works) -// RemoveData(work.Id, work, (m) => m.Name); +// RemoveData(work.ID, work, (m) => m.Name); // } // else if (e.Action is NotifyCollectionChangedAction.Replace) // { // var newModel = (PetModel)e.NewItems[0]; // var oldModel = (PetModel)e.OldItems[0]; // ReplaceData(newModel.ID, newModel, (m) => m.Name); -// ReplaceData(newModel.DescriptionId, newModel, (m) => m.Description); +// ReplaceData(newModel.DescriptionID, newModel, (m) => m.Description); // foreach (var work in newModel.Works) -// ReplaceData(work.Id, work, (m) => m.Name); +// ReplaceData(work.ID, work, (m) => m.Name); // } // }; // } @@ -368,14 +360,10 @@ public class I18nEditWindowVM : ObservableObjectX { } // /// // /// // /// -// private void AddData( -// ObservableValue id, -// I18nModel i18nModel, -// Func> i18nValue -// ) -// where T : class, new() +// private void AddData(I18nModel i18nModel, string id) +// where T : I18nModel, new() // { -// if (AllI18nDatas.TryGetValue(id.Value, out var outData)) +// if (AllI18nDatas.TryGetValue(id, out var outData)) // { // foreach (var culture in I18nHelper.Current.CultureNames.EnumerateIndex()) // { @@ -391,7 +379,7 @@ public class I18nEditWindowVM : ObservableObjectX { } // else // { // var data = new I18nData(); -// data.Id = id.Value; +// data.ID = id.Value; // foreach (var culture in I18nHelper.Current.CultureNames) // data.Datas.Add(i18nValue(i18nModel.I18nDatas[culture])); // I18nDatas.Add(data); @@ -408,7 +396,7 @@ public class I18nEditWindowVM : ObservableObjectX { } // private void IdChange(ObservableValue sender, ValueChangedEventArgs e) // { // var sourceData = AllI18nDatas[e.OldValue]; -// //sourceData.Id.Group?.Remove(sourceData.Id); //TODO +// //sourceData.ID.Group?.Remove(sourceData.ID); //TODO // if (AllI18nDatas.TryGetValue(e.OldValue, out var outData)) // { // foreach (var culture in I18nHelper.Current.CultureNames.EnumerateIndex()) @@ -422,7 +410,7 @@ public class I18nEditWindowVM : ObservableObjectX { } // } // else // { -// sourceData.Id = e.NewValue; +// sourceData.ID = e.NewValue; // AllI18nDatas.Remove(e.OldValue); // AllI18nDatas.Add(e.NewValue, sourceData); // } diff --git a/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs b/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs index 9916454..c4226a1 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs @@ -204,7 +204,8 @@ public class ModEditWindowVM : ObservableObjectX { if ( MessageBox.Show( - "!!!注意!!!\n此操作会将所有Id设为当前文化的翻译内容,仅适用于初次设置多文化的模组\n确定要继续吗?".Translate(), + ModEditWindow, + "!!!注意!!!\n此操作会将所有ID设为当前文化的翻译内容,仅适用于初次设置多文化的模组\n确定要继续吗?".Translate(), "", MessageBoxButton.YesNo ) @@ -305,6 +306,7 @@ public class ModEditWindowVM : ObservableObjectX if (I18nHelper.Current.CultureNames.Count == 0) { MessageBox.Show( + ModEditWindow, "未添加任何语言".Translate(), "", MessageBoxButton.OK, @@ -314,12 +316,24 @@ public class ModEditWindowVM : ObservableObjectX } if (string.IsNullOrWhiteSpace(model.ID)) { - MessageBox.Show("Id不可为空".Translate(), "", MessageBoxButton.OK, MessageBoxImage.Warning); + MessageBox.Show( + ModEditWindow, + "ID不可为空".Translate(), + "", + MessageBoxButton.OK, + MessageBoxImage.Warning + ); return false; } if (string.IsNullOrWhiteSpace(model.Author)) { - MessageBox.Show("作者不可为空".Translate(), "", MessageBoxButton.OK, MessageBoxImage.Warning); + MessageBox.Show( + ModEditWindow, + "作者不可为空".Translate(), + "", + MessageBoxButton.OK, + MessageBoxImage.Warning + ); return false; } return true; diff --git a/VPet.ModMaker/ViewModels/ModEdit/MoveEdit/MovePageVM.cs b/VPet.ModMaker/ViewModels/ModEdit/MoveEdit/MovePageVM.cs index e9be950..fc025d8 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/MoveEdit/MovePageVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/MoveEdit/MovePageVM.cs @@ -24,8 +24,8 @@ public class MovePageVM : ObservableObjectX Filter = f => f.Graph.Contains(Search, StringComparison.OrdinalIgnoreCase), FilteredList = new() }; + CurrentPet = Pets.First(); PropertyChanged += MovePageVM_PropertyChanged; - 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 39343a7..96f1f92 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/WorkEdit/WorkPageVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/WorkEdit/WorkPageVM.cs @@ -24,6 +24,7 @@ public class WorkPageVM : ObservableObjectX Filter = f => f.ID.Contains(Search, StringComparison.OrdinalIgnoreCase), FilteredList = new() }; + CurrentPet = Pets.First(); PropertyChanged += WorkPageVM_PropertyChanged; AddCommand.ExecuteCommand += AddCommand_ExecuteCommand; EditCommand.ExecuteCommand += EditCommand_ExecuteCommand; diff --git a/VPet.ModMaker/ViewModels/ModMakerWindowVM.cs b/VPet.ModMaker/ViewModels/ModMakerWindowVM.cs index 836f25c..4d868fc 100644 --- a/VPet.ModMaker/ViewModels/ModMakerWindowVM.cs +++ b/VPet.ModMaker/ViewModels/ModMakerWindowVM.cs @@ -133,7 +133,7 @@ public class ModMakerWindowVM : ObservableObjectX /// /// 保存历史 /// - private void SaveHistories() + public void SaveHistories() { Directory.CreateDirectory(nameof(ModMaker)); if (File.Exists(ModMakerInfo.HistoryFile) is false) @@ -260,7 +260,7 @@ public class ModMakerWindowVM : ObservableObjectX public void LoadMod(string path) { ModLoader? loader = null; - var pendingHandler = PendingBox.Show("载入中".Translate()); + var pendingHandler = PendingBox.Show(ModMakerWindow, "载入中".Translate()); try { loader = new ModLoader(new(path)); @@ -275,11 +275,11 @@ public class ModMakerWindowVM : ObservableObjectX try { var modInfo = new ModInfoModel(loader); + pendingHandler.Hide(); EditMod(modInfo); // 更新模组 if (ModUpdataHelper.CanUpdata(modInfo)) { - pendingHandler.Hide(); if ( MessageBox.Show( ModEditWindow.Current, @@ -293,7 +293,7 @@ public class ModMakerWindowVM : ObservableObjectX ) { if (ModUpdataHelper.Updata(modInfo)) - MessageBox.Show("更新完成, 请手动保存".Translate()); + MessageBox.Show(ModEditWindow.Current, "更新完成, 请手动保存".Translate()); } } pendingHandler.Close(); diff --git a/VPet.ModMaker/Views/ModMakerWindow.xaml.cs b/VPet.ModMaker/Views/ModMakerWindow.xaml.cs index aa00111..797fb63 100644 --- a/VPet.ModMaker/Views/ModMakerWindow.xaml.cs +++ b/VPet.ModMaker/Views/ModMakerWindow.xaml.cs @@ -31,7 +31,7 @@ namespace VPet.ModMaker.Views; public partial class ModMakerWindow : WindowX { public ModMakerWindowVM ViewModel => (ModMakerWindowVM)DataContext; - public Models.ModMaker ModMaker { get; internal set; } + public Models.ModMaker ModMaker { get; internal set; } = null!; public ModMakerWindow() { @@ -65,6 +65,8 @@ public partial class ModMakerWindow : WindowX ) { ViewModel.Histories.Remove(history); + ViewModel.SaveHistories(); + return; } } ViewModel.LoadMod(history.SourcePath);