mirror of
https://github.com/LorisYounger/VPet.ModMaker.git
synced 2024-08-30 18:22:21 +00:00
新增 设置主要文化功能
This commit is contained in:
parent
928d16b572
commit
d10643b94f
@ -58,6 +58,11 @@ public class ModEditWindowVM
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ObservableCommand<string> RemoveCultureCommand { get; } = new();
|
public ObservableCommand<string> RemoveCultureCommand { get; } = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置主要文化命令
|
||||||
|
/// </summary>
|
||||||
|
public ObservableCommand<string> SetMainCultureCommand { get; } = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保存命令
|
/// 保存命令
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -181,6 +186,43 @@ public class ModEditWindowVM
|
|||||||
return;
|
return;
|
||||||
I18nHelper.Current.CultureNames.Remove(oldCulture);
|
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
|
#endregion
|
||||||
|
|
||||||
#region Save
|
#region Save
|
||||||
|
@ -235,6 +235,7 @@ public class ModMakerWindowVM
|
|||||||
public void LoadMod(string path)
|
public void LoadMod(string path)
|
||||||
{
|
{
|
||||||
ModLoader? loader = null;
|
ModLoader? loader = null;
|
||||||
|
var pendingHandler = PendingBox.Show("载入中".Translate());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
loader = new ModLoader(new DirectoryInfo(path));
|
loader = new ModLoader(new DirectoryInfo(path));
|
||||||
@ -242,13 +243,14 @@ public class ModMakerWindowVM
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show("模组载入失败:\n{0}".Translate(ex));
|
MessageBox.Show("模组载入失败:\n{0}".Translate(ex));
|
||||||
|
pendingHandler.Close();
|
||||||
}
|
}
|
||||||
if (loader is not null)
|
if (loader is not null)
|
||||||
{
|
{
|
||||||
var pendingHandler = PendingBox.Show("载入中".Translate());
|
|
||||||
var modInfo = new ModInfoModel(loader);
|
var modInfo = new ModInfoModel(loader);
|
||||||
EditMod(modInfo);
|
EditMod(modInfo);
|
||||||
pendingHandler.Close();
|
pendingHandler.Close();
|
||||||
|
ModEditWindow.InitializeData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -289,6 +289,10 @@
|
|||||||
<Setter Property="ContextMenu">
|
<Setter Property="ContextMenu">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
|
<MenuItem
|
||||||
|
Command="{Binding PlacementTarget.Tag.SetMainCultureCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"
|
||||||
|
CommandParameter="{Binding}"
|
||||||
|
Header="{ll:Str 设为主要语言}" />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Command="{Binding PlacementTarget.Tag.EditCultureCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"
|
Command="{Binding PlacementTarget.Tag.EditCultureCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"
|
||||||
CommandParameter="{Binding}"
|
CommandParameter="{Binding}"
|
||||||
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -53,18 +54,32 @@ public partial class ModEditWindow : Window
|
|||||||
DataContext = new ModEditWindowVM(this);
|
DataContext = new ModEditWindowVM(this);
|
||||||
Closing += ModEditWindow_Closing;
|
Closing += ModEditWindow_Closing;
|
||||||
Closed += ModEditWindow_Closed;
|
Closed += ModEditWindow_Closed;
|
||||||
Loaded += ModEditWindow_Loaded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ModEditWindow_Loaded(object sender, RoutedEventArgs e)
|
/// <summary>
|
||||||
|
/// 初始化数据
|
||||||
|
/// </summary>
|
||||||
|
public void InitializeData()
|
||||||
{
|
{
|
||||||
if (I18nHelper.Current.CultureNames.Count == 0)
|
if (I18nHelper.Current.CultureNames.Count == 0)
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
MessageBox.Show("未添加任何文化,确定要添加文化吗?".Translate(), "", MessageBoxButton.YesNo)
|
MessageBox.Show("未添加任何文化,确定要添加文化吗?".Translate(), "", MessageBoxButton.YesNo)
|
||||||
is MessageBoxResult.Yes
|
is not MessageBoxResult.Yes
|
||||||
)
|
)
|
||||||
|
return;
|
||||||
ViewModel.AddCulture();
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user