diff --git a/VPet.ModMaker/Models/Expansions.cs b/VPet.ModMaker/Models/Expansions.cs index 0883804..8338929 100644 --- a/VPet.ModMaker/Models/Expansions.cs +++ b/VPet.ModMaker/Models/Expansions.cs @@ -80,6 +80,8 @@ public static class Extensions /// 路径 public static void SaveToPng(this BitmapSource image, string path) { + if (image is null) + return; if (path.EndsWith(".png") is false) path += ".png"; var encoder = new PngBitmapEncoder(); diff --git a/VPet.ModMaker/Models/ModModel/ModInfoModel.cs b/VPet.ModMaker/Models/ModModel/ModInfoModel.cs index 1ccd71e..937b491 100644 --- a/VPet.ModMaker/Models/ModModel/ModInfoModel.cs +++ b/VPet.ModMaker/Models/ModModel/ModInfoModel.cs @@ -249,52 +249,51 @@ public class ModInfoModel : I18nModel if (I18nHelper.Current.CultureNames.Contains(lang) is false) I18nHelper.Current.CultureNames.Add(lang); } - if (I18nHelper.Current.CultureNames.Count > 0) + if (I18nHelper.Current.CultureNames.Count == 0) + return; + I18nHelper.Current.CultureName.Value = I18nHelper.Current.CultureNames.First(); + foreach (var i18nData in OtherI18nDatas) { - I18nHelper.Current.CultureName.Value = I18nHelper.Current.CultureNames.First(); - foreach (var i18nData in OtherI18nDatas) + foreach (var food in Foods) { - foreach (var food in Foods) + var foodI18n = food.I18nDatas[i18nData.Key]; + if (i18nData.Value.TryGetValue(food.Id.Value, out var name)) + foodI18n.Name.Value = name; + if (i18nData.Value.TryGetValue(food.DescriptionId.Value, out var description)) + foodI18n.Description.Value = description; + } + foreach (var lowText in LowTexts) + { + var lowTextI18n = lowText.I18nDatas[i18nData.Key]; + if (i18nData.Value.TryGetValue(lowText.Id.Value, out var text)) + lowTextI18n.Text.Value = text; + } + foreach (var clickText in ClickTexts) + { + var clickTextI18n = clickText.I18nDatas[i18nData.Key]; + if (i18nData.Value.TryGetValue(clickText.Id.Value, out var text)) + clickTextI18n.Text.Value = text; + } + foreach (var selectText in SelectTexts) + { + var selectTextI18n = selectText.I18nDatas[i18nData.Key]; + if (i18nData.Value.TryGetValue(selectText.Id.Value, out var text)) + selectTextI18n.Text.Value = text; + if (i18nData.Value.TryGetValue(selectText.ChooseId.Value, out var choose)) + selectTextI18n.Choose.Value = choose; + } + foreach (var pet in Pets) + { + var petI18n = pet.I18nDatas[i18nData.Key]; + if (i18nData.Value.TryGetValue(pet.Id.Value, out var name)) + petI18n.Name.Value = name; + if (i18nData.Value.TryGetValue(pet.DescriptionId.Value, out var description)) + petI18n.Description.Value = description; + foreach (var work in pet.Works) { - var foodI18n = food.I18nDatas[i18nData.Key]; - if (i18nData.Value.TryGetValue(food.Id.Value, out var name)) - foodI18n.Name.Value = name; - if (i18nData.Value.TryGetValue(food.DescriptionId.Value, out var description)) - foodI18n.Description.Value = description; - } - foreach (var lowText in LowTexts) - { - var lowTextI18n = lowText.I18nDatas[i18nData.Key]; - if (i18nData.Value.TryGetValue(lowText.Id.Value, out var text)) - lowTextI18n.Text.Value = text; - } - foreach (var clickText in ClickTexts) - { - var clickTextI18n = clickText.I18nDatas[i18nData.Key]; - if (i18nData.Value.TryGetValue(clickText.Id.Value, out var text)) - clickTextI18n.Text.Value = text; - } - foreach (var selectText in SelectTexts) - { - var selectTextI18n = selectText.I18nDatas[i18nData.Key]; - if (i18nData.Value.TryGetValue(selectText.Id.Value, out var text)) - selectTextI18n.Text.Value = text; - if (i18nData.Value.TryGetValue(selectText.ChooseId.Value, out var choose)) - selectTextI18n.Choose.Value = choose; - } - foreach (var pet in Pets) - { - var petI18n = pet.I18nDatas[i18nData.Key]; - if (i18nData.Value.TryGetValue(pet.Id.Value, out var name)) - petI18n.Name.Value = name; - if (i18nData.Value.TryGetValue(pet.DescriptionId.Value, out var description)) - petI18n.Description.Value = description; - foreach (var work in pet.Works) - { - var workI18n = work.I18nDatas[i18nData.Key]; - if (i18nData.Value.TryGetValue(work.Id.Value, out var workName)) - workI18n.Name.Value = workName; - } + var workI18n = work.I18nDatas[i18nData.Key]; + if (i18nData.Value.TryGetValue(work.Id.Value, out var workName)) + workI18n.Name.Value = workName; } } } diff --git a/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs b/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs index 6919e8a..6835f71 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs @@ -200,21 +200,21 @@ public class ModEditWindowVM if (saveFileDialog.ShowDialog() is true) { var pending = PendingBox.Show("保存中".Translate()); - try - { - var path = Path.GetDirectoryName(saveFileDialog.FileName); - ModInfo.Value.SaveTo(path); - if (string.IsNullOrWhiteSpace(ModInfo.Value.SourcePath.Value)) - ModInfo.Value.SourcePath.Value = path; - pending.Close(); - MessageBox.Show(ModEditWindow, "保存成功".Translate()); - } - catch (Exception ex) - { - pending.Close(); - MessageBox.Show($"保存失败 错误信息:\n{0}".Translate(ex)); - return; - } + //try + //{ + var path = Path.GetDirectoryName(saveFileDialog.FileName); + ModInfo.Value.SaveTo(path); + if (string.IsNullOrWhiteSpace(ModInfo.Value.SourcePath.Value)) + ModInfo.Value.SourcePath.Value = path; + pending.Close(); + MessageBox.Show(ModEditWindow, "保存成功".Translate()); + //} + //catch (Exception ex) + //{ + // pending.Close(); + // MessageBox.Show("保存失败 错误信息:\n{0}".Translate(ex)); + // return; + //} } } diff --git a/VPet.ModMaker/Views/ModMakerWindow.xaml b/VPet.ModMaker/Views/ModMakerWindow.xaml index b9bcd55..8f70c1b 100644 --- a/VPet.ModMaker/Views/ModMakerWindow.xaml +++ b/VPet.ModMaker/Views/ModMakerWindow.xaml @@ -36,7 +36,7 @@