diff --git a/VPet.ModMaker/VPet.ModMaker.csproj b/VPet.ModMaker/VPet.ModMaker.csproj
index 7aff785..9357f37 100644
--- a/VPet.ModMaker/VPet.ModMaker.csproj
+++ b/VPet.ModMaker/VPet.ModMaker.csproj
@@ -78,10 +78,10 @@
4.0
- ..\packages\VPet-Simulator.Core.1.0.7\lib\net462\VPet-Simulator.Core.dll
+ ..\packages\VPet-Simulator.Core.1.0.8\lib\net462\VPet-Simulator.Core.dll
- ..\packages\VPet-Simulator.Windows.Interface.1.0.7\lib\net462\VPet-Simulator.Windows.Interface.dll
+ ..\packages\VPet-Simulator.Windows.Interface.1.0.8\lib\net462\VPet-Simulator.Windows.Interface.dll
diff --git a/VPet.ModMaker/ViewModels/ModEdit/AddCultureWindowVM.cs b/VPet.ModMaker/ViewModels/ModEdit/AddCultureWindowVM.cs
index cceab00..154a316 100644
--- a/VPet.ModMaker/ViewModels/ModEdit/AddCultureWindowVM.cs
+++ b/VPet.ModMaker/ViewModels/ModEdit/AddCultureWindowVM.cs
@@ -11,11 +11,25 @@ namespace VPet.ModMaker.ViewModels.ModEdit;
public class AddCultureWindowVM
{
+ ///
+ /// 显示的文化
+ ///
public ObservableValue> ShowCultures { get; } = new();
+
+ ///
+ /// 全部文化
+ ///
public static ObservableCollection AllCultures { get; set; } =
new(LinePutScript.Localization.WPF.LocalizeCore.AvailableCultures);
+
+ ///
+ /// 当前文化
+ ///
public ObservableValue Culture { get; } = new();
+ ///
+ /// 搜索文化
+ ///
public ObservableValue Search { get; } = new();
public AddCultureWindowVM()
diff --git a/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs b/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs
index b91086d..5eff170 100644
--- a/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs
+++ b/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs
@@ -23,65 +23,74 @@ public class ModEditWindowVM
public ModEditWindow ModEditWindow { get; }
#region Value
+ ///
+ /// 当前模组信息
+ ///
public ObservableValue ModInfo { get; } = new(ModInfoModel.Current);
- public ObservableValue CurrentLang { get; } = new();
+
+ ///
+ /// I18n数据
+ ///
public I18nHelper I18nData => I18nHelper.Current;
#endregion
#region Command
- public ObservableCommand AddImageCommand { get; } = new();
+
+ ///
+ /// 改变图片命令
+ ///
public ObservableCommand ChangeImageCommand { get; } = new();
+
+ ///
+ /// 添加文化命令
+ ///
public ObservableCommand AddCultureCommand { get; } = new();
+ ///
+ /// 编辑文化命令
+ ///
public ObservableCommand EditCultureCommand { get; } = new();
+
+ ///
+ /// 删除文化命令
+ ///
public ObservableCommand RemoveCultureCommand { get; } = new();
+ ///
+ /// 保存命令
+ ///
public ObservableCommand SaveCommand { get; } = new();
+
+ ///
+ /// 保存至命令
+ ///
public ObservableCommand SaveToCommand { get; } = new();
#endregion
- public ModEditWindowVM() { }
-
public ModEditWindowVM(ModEditWindow window)
{
ModEditWindow = window;
- CurrentLang.ValueChanged += CurrentLang_ValueChanged;
- AddImageCommand.ExecuteEvent += AddImage;
ChangeImageCommand.ExecuteEvent += ChangeImage;
AddCultureCommand.ExecuteEvent += AddCulture;
EditCultureCommand.ExecuteEvent += EditCulture;
- RemoveCultureCommand.ExecuteEvent += RemoveLang;
+ RemoveCultureCommand.ExecuteEvent += RemoveCulture;
+
SaveCommand.ExecuteEvent += Save;
SaveToCommand.ExecuteEvent += SaveTo;
}
- private void CurrentLang_ValueChanged(string oldValue, string newValue)
- {
- if (newValue is null)
- return;
- ModInfo.Value.CurrentI18nData.Value = ModInfo.Value.I18nDatas[newValue];
- }
-
+ ///
+ /// 关闭
+ ///
public void Close()
{
ModInfo.Value.Image.Value?.StreamSource?.Close();
}
- private void AddImage()
- {
- OpenFileDialog openFileDialog =
- new()
- {
- Title = "选择图片".Translate(),
- Filter = $"图片|*.jpg;*.jpeg;*.png;*.bmp".Translate()
- };
- if (openFileDialog.ShowDialog() is true)
- {
- ModInfo.Value.Image.Value = Utils.LoadImageToMemoryStream(openFileDialog.FileName);
- }
- }
-
+ ///
+ /// 改变图片
+ ///
private void ChangeImage()
{
OpenFileDialog openFileDialog =
@@ -97,6 +106,10 @@ public class ModEditWindowVM
}
}
+ #region Culture
+ ///
+ /// 添加文化
+ ///
public void AddCulture()
{
var window = new AddCultureWindow();
@@ -108,32 +121,48 @@ public class ModEditWindowVM
I18nHelper.Current.CultureName.Value = window.ViewModel.Culture.Value;
}
- private void EditCulture(string oldLang)
+ ///
+ /// 编辑文化
+ ///
+ /// 旧文化
+ private void EditCulture(string oldCulture)
{
var window = new AddCultureWindow();
- window.ViewModel.Culture.Value = oldLang.Translate();
+ window.ViewModel.Culture.Value = oldCulture.Translate();
window.ShowDialog();
if (window.IsCancel)
return;
- I18nHelper.Current.CultureNames[I18nHelper.Current.CultureNames.IndexOf(oldLang)] = window
- .ViewModel
- .Culture
- .Value;
- CurrentLang.Value = window.ViewModel.Culture.Value;
+ I18nHelper.Current.CultureNames[I18nHelper.Current.CultureNames.IndexOf(oldCulture)] =
+ window.ViewModel.Culture.Value;
}
- private void RemoveLang(string oldLang)
+ ///
+ /// 删除文化
+ ///
+ /// 旧文化
+ private void RemoveCulture(string oldCulture)
{
if (
- MessageBox.Show("确定删除吗".Translate(), "".Translate(), MessageBoxButton.YesNo)
- is MessageBoxResult.No
+ MessageBox.Show(
+ "确定删除文化 {0} 吗".Translate(oldCulture),
+ "".Translate(),
+ MessageBoxButton.YesNo
+ ) is MessageBoxResult.No
)
return;
- I18nHelper.Current.CultureNames.Remove(oldLang);
+ I18nHelper.Current.CultureNames.Remove(oldCulture);
}
+ #endregion
+ #region Save
+ ///
+ /// 保存
+ ///
private void Save()
{
+ if (MessageBox.Show("确定保存吗".Translate()) is not MessageBoxResult.Yes)
+ return;
+
if (string.IsNullOrEmpty(ModInfo.Value.SourcePath.Value))
{
MessageBox.Show("源路径为空, 请使用 保存至".Translate());
@@ -151,6 +180,9 @@ public class ModEditWindowVM
MessageBox.Show("保存成功".Translate());
}
+ ///
+ /// 保存至
+ ///
private void SaveTo()
{
if (ValidationData(ModInfo.Value) is false)
@@ -183,6 +215,11 @@ public class ModEditWindowVM
}
}
+ ///
+ /// 验证数据
+ ///
+ /// 模型
+ /// 成功为 失败为
private bool ValidationData(ModInfoModel model)
{
if (I18nHelper.Current.CultureNames.Count == 0)
@@ -207,4 +244,5 @@ public class ModEditWindowVM
}
return true;
}
+ #endregion
}
diff --git a/VPet.ModMaker/ViewModels/ModMakerWindowVM.cs b/VPet.ModMaker/ViewModels/ModMakerWindowVM.cs
index 00d9946..732e11f 100644
--- a/VPet.ModMaker/ViewModels/ModMakerWindowVM.cs
+++ b/VPet.ModMaker/ViewModels/ModMakerWindowVM.cs
@@ -25,19 +25,42 @@ public class ModMakerWindowVM
public ModEditWindow ModEditWindow { get; private set; }
+ ///
+ /// 历史搜索文本
+ ///
public ObservableValue HistoriesSearchText { get; } = new();
- public ObservableCollection Mods { get; } = new();
+ ///
+ /// 显示的历史
+ ///
public ObservableValue> ShowHistories { get; } = new();
+
+ ///
+ /// 历史
+ ///
public ObservableCollection Histories { get; } = new();
#endregion
#region Command
+ ///
+ /// 创建新模组命令
+ ///
public ObservableCommand CreateNewModCommand { get; } = new();
+
+ ///
+ /// 从文件载入模组命令
+ ///
public ObservableCommand LoadModFromFileCommand { get; } = new();
+
+ ///
+ /// 清除历史命令
+ ///
public ObservableCommand ClearHistoriesCommand { get; } = new();
+
+ ///
+ /// 删除历史命令
+ ///
public ObservableCommand RemoveHistoryCommand { get; } = new();
#endregion
- public ModMakerWindowVM() { }
public ModMakerWindowVM(ModMakerWindow window)
{
@@ -48,15 +71,27 @@ public class ModMakerWindowVM
LoadModFromFileCommand.ExecuteEvent += LoadModFromFile;
ClearHistoriesCommand.ExecuteEvent += ClearHistories;
RemoveHistoryCommand.ExecuteEvent += RemoveHistory;
- HistoriesSearchText.ValueChanged += ModSearchText_ValueChanged;
+ HistoriesSearchText.ValueChanged += HistoriesSearchText_ValueChanged;
}
+ private void HistoriesSearchText_ValueChanged(string oldValue, string newValue)
+ {
+ if (string.IsNullOrEmpty(newValue))
+ ShowHistories.Value = Histories;
+ else
+ ShowHistories.Value = new(Histories.Where(i => i.Id.Contains(newValue)));
+ }
+
+ #region History
private void RemoveHistory(ModMakerHistory value)
{
Histories.Remove(value);
SaveHistories();
}
+ ///
+ /// 载入历史
+ ///
private void LoadHistories()
{
if (File.Exists(ModMakerInfo.HistoryFile) is false)
@@ -70,6 +105,9 @@ public class ModMakerWindowVM
}
}
+ ///
+ /// 保存历史
+ ///
private void SaveHistories()
{
Directory.CreateDirectory(nameof(ModMaker));
@@ -77,6 +115,7 @@ public class ModMakerWindowVM
File.Create(ModMakerInfo.HistoryFile).Close();
var lps = new LPS();
foreach (var history in Histories)
+ {
lps.Add(
new Line(nameof(history))
{
@@ -85,9 +124,14 @@ public class ModMakerWindowVM
new Sub("LastTime", history.LastTime.ToString("yyyy/MM/dd HH:mm"))
}
);
+ }
File.WriteAllText(ModMakerInfo.HistoryFile, lps.ToString());
}
+ ///
+ /// 添加历史
+ ///
+ /// 模组信息
private void AddHistories(ModInfoModel modInfo)
{
if (
@@ -112,47 +156,6 @@ public class ModMakerWindowVM
}
}
- private void ModSearchText_ValueChanged(string oldValue, string newValue)
- {
- if (string.IsNullOrEmpty(newValue))
- ShowHistories.Value = Histories;
- else
- ShowHistories.Value = new(Histories.Where(i => i.Id.Contains(newValue)));
- }
-
- public void CreateNewMod()
- {
- ModInfoModel.Current = new();
- ShowEditWindow();
- }
-
- public void EditMod(ModInfoModel modInfo)
- {
- ModInfoModel.Current = modInfo;
- ShowEditWindow();
- }
-
- private void ShowEditWindow()
- {
- if (string.IsNullOrEmpty(ModInfoModel.Current.SourcePath.Value) is false)
- AddHistories(ModInfoModel.Current);
- SaveHistories();
- ModEditWindow = new();
- ModEditWindow.Show();
- ModMakerWindow.Hide();
- ModEditWindow.Closed += (s, e) =>
- {
- var modInfo = ModInfoModel.Current;
- if (string.IsNullOrEmpty(modInfo.SourcePath.Value) is false)
- AddHistories(modInfo);
- SaveHistories();
- ModInfoModel.Current.Close();
- ModInfoModel.Current = null;
- I18nHelper.Current = new();
- ModMakerWindow.Show();
- };
- }
-
private void ClearHistories()
{
if (
@@ -164,7 +167,58 @@ public class ModMakerWindowVM
Histories.Clear();
File.WriteAllText(ModMakerInfo.HistoryFile, string.Empty);
}
+ #endregion
+ #region Mod
+ ///
+ /// 创建新模组
+ ///
+ public void CreateNewMod()
+ {
+ ModInfoModel.Current = new();
+ ShowEditWindow();
+ }
+
+ ///
+ /// 编辑模组
+ ///
+ /// 模组信息
+ public void EditMod(ModInfoModel modInfo)
+ {
+ ModInfoModel.Current = modInfo;
+ ShowEditWindow();
+ }
+
+ ///
+ /// 显示模组编辑窗口
+ ///
+ private void ShowEditWindow()
+ {
+ ModMakerWindow.Hide();
+ // 将当前模组添加到历史
+ if (string.IsNullOrEmpty(ModInfoModel.Current.SourcePath.Value) is false)
+ AddHistories(ModInfoModel.Current);
+ SaveHistories();
+ ModEditWindow = new();
+ ModEditWindow.Show();
+ ModEditWindow.Closed += (s, e) =>
+ {
+ var modInfo = ModInfoModel.Current;
+ if (string.IsNullOrEmpty(modInfo.SourcePath.Value) is false)
+ {
+ AddHistories(modInfo);
+ SaveHistories();
+ }
+ ModInfoModel.Current.Close();
+ ModInfoModel.Current = null;
+ I18nHelper.Current = new();
+ ModMakerWindow.Show();
+ };
+ }
+
+ ///
+ /// 从文件载入模组
+ ///
public void LoadModFromFile()
{
OpenFileDialog openFileDialog =
@@ -180,6 +234,10 @@ public class ModMakerWindowVM
}
}
+ ///
+ /// 载入模组
+ ///
+ /// 位置
public void LoadMod(string path)
{
try
@@ -200,4 +258,5 @@ public class ModMakerWindowVM
MessageBox.Show("模组载入失败:\n{0}".Translate(ex));
}
}
+ #endregion
}
diff --git a/VPet.ModMaker/Views/ModEdit/AddCultureWindow.xaml b/VPet.ModMaker/Views/ModEdit/AddCultureWindow.xaml
index b5729bc..a7363d6 100644
--- a/VPet.ModMaker/Views/ModEdit/AddCultureWindow.xaml
+++ b/VPet.ModMaker/Views/ModEdit/AddCultureWindow.xaml
@@ -1,4 +1,4 @@
-
+ Content="{ll:Str 取消}"
+ IsCancel="True" />
+ Content="{ll:Str 确定}"
+ IsDefault="True" />
@@ -70,4 +72,4 @@
SelectedItem="{Binding Culture.Value}" />
-
+
diff --git a/VPet.ModMaker/Views/ModEdit/AddCultureWindow.xaml.cs b/VPet.ModMaker/Views/ModEdit/AddCultureWindow.xaml.cs
index fc6686e..d63dccd 100644
--- a/VPet.ModMaker/Views/ModEdit/AddCultureWindow.xaml.cs
+++ b/VPet.ModMaker/Views/ModEdit/AddCultureWindow.xaml.cs
@@ -1,4 +1,6 @@
using HKW.HKWViewModels.SimpleObservable;
+using LinePutScript.Localization.WPF;
+using Panuon.WPF.UI;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -23,7 +25,7 @@ namespace VPet.ModMaker.Views.ModEdit;
///
/// Window_AddLang.xaml 的交互逻辑
///
-public partial class AddCultureWindow : Window
+public partial class AddCultureWindow : WindowX
{
public bool IsCancel { get; private set; } = true;
@@ -34,6 +36,7 @@ public partial class AddCultureWindow : Window
InitializeComponent();
DataContext = new AddCultureWindowVM();
TextBox_Lang.Focus();
+ TextBox_Lang.Dispatcher.InvokeAsync(TextBox_Lang.SelectAll);
}
private void Button_Cancel_Click(object sender, RoutedEventArgs e)
@@ -43,14 +46,14 @@ public partial class AddCultureWindow : Window
private void Button_Yes_Click(object sender, RoutedEventArgs e)
{
- if (string.IsNullOrEmpty(ViewModel.Culture.Value))
+ if (string.IsNullOrWhiteSpace(ViewModel.Culture.Value))
{
- MessageBox.Show("文化不可为空", "", MessageBoxButton.OK, MessageBoxImage.Warning);
+ MessageBox.Show("文化不可为空".Translate(), "", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
if (I18nHelper.Current.CultureNames.Contains(ViewModel.Culture.Value))
{
- MessageBox.Show("此文化已存在", "", MessageBoxButton.OK, MessageBoxImage.Warning);
+ MessageBox.Show("此文化已存在".Translate(), "", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
IsCancel = false;
diff --git a/VPet.ModMaker/Views/ModEdit/AnimeEdit/AnimeEditWindow.xaml b/VPet.ModMaker/Views/ModEdit/AnimeEdit/AnimeEditWindow.xaml
index b62d50f..729552d 100644
--- a/VPet.ModMaker/Views/ModEdit/AnimeEdit/AnimeEditWindow.xaml
+++ b/VPet.ModMaker/Views/ModEdit/AnimeEdit/AnimeEditWindow.xaml
@@ -11,10 +11,8 @@
Title="AnimeEditWindow"
Width="1000"
Height="600"
+ d:DataContext="{d:DesignInstance Type=vm:AnimeEditWindowVM}"
mc:Ignorable="d">
-
-
-
diff --git a/VPet.ModMaker/Views/ModEdit/MoveEdit/MoveEditWindow.xaml b/VPet.ModMaker/Views/ModEdit/MoveEdit/MoveEditWindow.xaml
index c980785..cd3e81c 100644
--- a/VPet.ModMaker/Views/ModEdit/MoveEdit/MoveEditWindow.xaml
+++ b/VPet.ModMaker/Views/ModEdit/MoveEdit/MoveEditWindow.xaml
@@ -11,11 +11,9 @@
Title="MoveEditWindow"
Width="800"
Height="450"
+ d:DataContext="{d:DesignInstance Type=vm:MoveEditWindowVM}"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
-
-
-
diff --git a/VPet.ModMaker/Views/ModEdit/MoveEdit/MovePage.xaml b/VPet.ModMaker/Views/ModEdit/MoveEdit/MovePage.xaml
index 787cb44..26362e3 100644
--- a/VPet.ModMaker/Views/ModEdit/MoveEdit/MovePage.xaml
+++ b/VPet.ModMaker/Views/ModEdit/MoveEdit/MovePage.xaml
@@ -9,13 +9,10 @@
xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:vm="clr-namespace:VPet.ModMaker.ViewModels.ModEdit.MoveEdit"
Title="MovePage"
+ d:DataContext="{d:DesignInstance Type=vm:MovePageVM}"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
-
-
-
-
diff --git a/VPet.ModMaker/Views/ModEdit/PetEdit/PetEditWindow.xaml b/VPet.ModMaker/Views/ModEdit/PetEdit/PetEditWindow.xaml
index 76b15d5..ffa2842 100644
--- a/VPet.ModMaker/Views/ModEdit/PetEdit/PetEditWindow.xaml
+++ b/VPet.ModMaker/Views/ModEdit/PetEdit/PetEditWindow.xaml
@@ -11,11 +11,9 @@
Title="PetEditWindow"
Width="800"
Height="450"
+ d:DataContext="{d:DesignInstance Type=vm:PetEditWindowVM}"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
-
-
-