diff --git a/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs b/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs index 785c54a..be89046 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs @@ -58,6 +58,11 @@ public class ModEditWindowVM /// public ObservableCommand RemoveCultureCommand { get; } = new(); + /// + /// 设置主要文化命令 + /// + public ObservableCommand SetMainCultureCommand { get; } = new(); + /// /// 保存命令 /// @@ -181,6 +186,43 @@ public class ModEditWindowVM return; I18nHelper.Current.CultureNames.Remove(oldCulture); } + + public void SetMainCulture(string culture) + { + if ( + MessageBox.Show( + "!!!注意!!!\n此操作会将所有Id设为当前文化的翻译内容,仅适用于初次设置多文化的模组\n确定要继续吗?".Translate(), + "", + MessageBoxButton.YesNo + ) + is not MessageBoxResult.Yes + ) + return; + ModInfo.Value.I18nDatas[culture].Name.Value = ModInfo.Value.Id.Value; + ModInfo.Value.I18nDatas[culture].Description.Value = ModInfo.Value.DescriptionId.Value; + foreach (var food in ModInfo.Value.Foods) + { + food.I18nDatas[culture].Name.Value = food.Id.Value; + food.I18nDatas[culture].Description.Value = food.DescriptionId.Value; + } + foreach (var text in ModInfo.Value.LowTexts) + text.I18nDatas[culture].Text.Value = text.Id.Value; + foreach (var text in ModInfo.Value.ClickTexts) + text.I18nDatas[culture].Text.Value = text.Id.Value; + foreach (var text in ModInfo.Value.SelectTexts) + { + text.I18nDatas[culture].Text.Value = text.Id.Value; + text.I18nDatas[culture].Choose.Value = text.ChooseId.Value; + } + foreach (var pet in ModInfo.Value.Pets) + { + pet.I18nDatas[culture].Name.Value = pet.Id.Value; + pet.I18nDatas[culture].PetName.Value = pet.PetNameId.Value; + pet.I18nDatas[culture].Description.Value = pet.DescriptionId.Value; + foreach (var work in pet.Works) + work.I18nDatas[culture].Name.Value = work.Id.Value; + } + } #endregion #region Save diff --git a/VPet.ModMaker/ViewModels/ModMakerWindowVM.cs b/VPet.ModMaker/ViewModels/ModMakerWindowVM.cs index 5fe75ae..486c394 100644 --- a/VPet.ModMaker/ViewModels/ModMakerWindowVM.cs +++ b/VPet.ModMaker/ViewModels/ModMakerWindowVM.cs @@ -235,6 +235,7 @@ public class ModMakerWindowVM public void LoadMod(string path) { ModLoader? loader = null; + var pendingHandler = PendingBox.Show("载入中".Translate()); try { loader = new ModLoader(new DirectoryInfo(path)); @@ -242,13 +243,14 @@ public class ModMakerWindowVM catch (Exception ex) { MessageBox.Show("模组载入失败:\n{0}".Translate(ex)); + pendingHandler.Close(); } if (loader is not null) { - var pendingHandler = PendingBox.Show("载入中".Translate()); var modInfo = new ModInfoModel(loader); EditMod(modInfo); pendingHandler.Close(); + ModEditWindow.InitializeData(); } } #endregion diff --git a/VPet.ModMaker/Views/ModEdit/ModEditWindow.xaml b/VPet.ModMaker/Views/ModEdit/ModEditWindow.xaml index 296e180..ff70b5a 100644 --- a/VPet.ModMaker/Views/ModEdit/ModEditWindow.xaml +++ b/VPet.ModMaker/Views/ModEdit/ModEditWindow.xaml @@ -289,6 +289,10 @@ + + /// 初始化数据 + /// + public void InitializeData() { if (I18nHelper.Current.CultureNames.Count == 0) { if ( MessageBox.Show("未添加任何文化,确定要添加文化吗?".Translate(), "", MessageBoxButton.YesNo) - is MessageBoxResult.Yes + is not MessageBoxResult.Yes ) - ViewModel.AddCulture(); + return; + ViewModel.AddCulture(); + if ( + I18nHelper.Current.CultureNames.Count == 0 + || MessageBox.Show( + "需要将文化 {0} 设为主要文化吗?".Translate(I18nHelper.Current.CultureNames.First()), + "", + MessageBoxButton.YesNo + ) + is not MessageBoxResult.Yes + ) + return; + ViewModel.SetMainCulture(I18nHelper.Current.CultureNames.First()); } }