mirror of
https://github.com/LorisYounger/VPet.ModMaker.git
synced 2024-08-30 18:22:21 +00:00
使用简单的MVVM重构
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
x:Class="VPet.Plugin.ModMaker.App"
|
x:Class="VPet.Plugin.ModMaker.App"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
StartupUri="ModMakerWindow.xaml">
|
StartupUri="Views/ModMakerWindow.xaml">
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
@ -1,75 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using VPet_Simulator.Windows.Interface;
|
|
||||||
|
|
||||||
namespace VPet.Plugin.ModMaker.ModEdit.FoodEdit;
|
|
||||||
|
|
||||||
public partial class Page_Food
|
|
||||||
{
|
|
||||||
public static Food CreateFoodFromWindow(Window_AddFood addFoodWindow)
|
|
||||||
{
|
|
||||||
return new()
|
|
||||||
{
|
|
||||||
Name = addFoodWindow.TextBox_FoodName.Text,
|
|
||||||
ImageSource = addFoodWindow.Image_FoodImage.Source,
|
|
||||||
Desc = addFoodWindow.TextBox_FoodDescription.Text,
|
|
||||||
Type = (Food.FoodType)
|
|
||||||
Enum.Parse(
|
|
||||||
typeof(Food.FoodType),
|
|
||||||
((ComboBoxItem)addFoodWindow.ComboBox_FoodType.SelectedItem).Tag.ToString()
|
|
||||||
),
|
|
||||||
Strength = (double)addFoodWindow.NumberInput_Strength.Value,
|
|
||||||
StrengthFood = (double)addFoodWindow.NumberInput_StrengthFood.Value,
|
|
||||||
StrengthDrink = (double)addFoodWindow.NumberInput_StrengthDrink.Value,
|
|
||||||
Health = (double)addFoodWindow.NumberInput_Health.Value,
|
|
||||||
Feeling = (double)addFoodWindow.NumberInput_Feeling.Value,
|
|
||||||
Likability = (double)addFoodWindow.NumberInput_Likability.Value,
|
|
||||||
Price = (double)addFoodWindow.NumberInput_Price.Value,
|
|
||||||
Exp = (int)addFoodWindow.NumberInput_Exp.Value,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ChangeFoodInfo(Food oldFood)
|
|
||||||
{
|
|
||||||
var window = new Window_AddFood();
|
|
||||||
window.TextBox_FoodName.Text = oldFood.Name;
|
|
||||||
window.Image_FoodImage.Source = oldFood.ImageSource;
|
|
||||||
window.TextBox_FoodDescription.Text = oldFood.Desc;
|
|
||||||
foreach (ComboBoxItem item in window.ComboBox_FoodType.Items)
|
|
||||||
if (item.Tag.ToString() == oldFood.Type.ToString())
|
|
||||||
window.ComboBox_FoodType.SelectedItem = item;
|
|
||||||
window.NumberInput_Strength.Value = oldFood.Strength;
|
|
||||||
window.NumberInput_StrengthFood.Value = oldFood.StrengthFood;
|
|
||||||
window.NumberInput_StrengthDrink.Value = oldFood.StrengthDrink;
|
|
||||||
window.NumberInput_Health.Value = oldFood.Health;
|
|
||||||
window.NumberInput_Feeling.Value = oldFood.Feeling;
|
|
||||||
window.NumberInput_Likability.Value = oldFood.Likability;
|
|
||||||
window.NumberInput_Price.Value = oldFood.Price;
|
|
||||||
window.NumberInput_Exp.Value = oldFood.Exp;
|
|
||||||
window.Button_AddFoodImage.Visibility = Visibility.Visible;
|
|
||||||
window.Closed += (s, e) =>
|
|
||||||
{
|
|
||||||
if (s is not Window_AddFood addFoodWindow || addFoodWindow.IsCancel)
|
|
||||||
return;
|
|
||||||
var food = CreateFoodFromWindow(addFoodWindow);
|
|
||||||
if (FoodDict.TryGetValue(food.Name, out var tempFood))
|
|
||||||
{
|
|
||||||
FoodDict[food.Name] = Foods[Foods.IndexOf(tempFood)] = food;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Foods[Foods.IndexOf(oldFood)] = food;
|
|
||||||
FoodDict.Remove(oldFood.Name);
|
|
||||||
FoodDict.Add(food.Name, food);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ShowDialogX(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
public event ShowDialogXHandler ShowDialogX;
|
|
||||||
}
|
|
@ -1,98 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Data;
|
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using System.Windows.Navigation;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
using VPet_Simulator.Windows.Interface;
|
|
||||||
|
|
||||||
namespace VPet.Plugin.ModMaker.ModEdit.FoodEdit;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Page_Food.xaml 的交互逻辑
|
|
||||||
/// </summary>
|
|
||||||
public partial class Page_Food : Page
|
|
||||||
{
|
|
||||||
public ObservableCollection<Food> Foods { get; set; } = new();
|
|
||||||
|
|
||||||
public Dictionary<string, Food> FoodDict { get; set; } = new();
|
|
||||||
|
|
||||||
public Page_Food()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
DataGrid_Food.ItemsSource = Foods;
|
|
||||||
// TODO: 多语言
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Button_AddFood_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
var window = new Window_AddFood();
|
|
||||||
window.Closed += (s, e) =>
|
|
||||||
{
|
|
||||||
if (s is not Window_AddFood addFoodWindow || addFoodWindow.IsCancel)
|
|
||||||
return;
|
|
||||||
var food = CreateFoodFromWindow(addFoodWindow);
|
|
||||||
if (FoodDict.TryGetValue(food.Name, out var oldFood))
|
|
||||||
{
|
|
||||||
FoodDict[food.Name] = Foods[Foods.IndexOf(oldFood)] = food;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Foods.Add(food);
|
|
||||||
FoodDict.Add(food.Name, food);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ShowDialogX(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DataGrid_Food_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
|
||||||
{
|
|
||||||
if (sender is not DataGrid dataGrid || dataGrid.SelectedItem is not Food oldFood)
|
|
||||||
return;
|
|
||||||
ChangeFoodInfo(oldFood);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TextBox_SearchFood_TextChanged(object sender, TextChangedEventArgs e)
|
|
||||||
{
|
|
||||||
if (sender is not TextBox textBox)
|
|
||||||
return;
|
|
||||||
if (textBox.Text.Length > 0)
|
|
||||||
{
|
|
||||||
var newList = new ObservableCollection<Food>(
|
|
||||||
Foods.Where(i => i.Name.Contains(textBox.Text))
|
|
||||||
);
|
|
||||||
if (newList.Count != Foods.Count)
|
|
||||||
DataGrid_Food.ItemsSource = newList;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
DataGrid_Food.ItemsSource = Foods;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MenuItem_RemoveFood_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
if (sender is not MenuItem menuItem || menuItem.Tag is not Food food)
|
|
||||||
return;
|
|
||||||
if (DataGrid_Food.ItemsSource is IList list && list.Count != Foods.Count)
|
|
||||||
list.Remove(food);
|
|
||||||
else
|
|
||||||
Foods.Remove(food);
|
|
||||||
FoodDict.Remove(food.Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MenuItem_ChangeFood_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
if (sender is not MenuItem menuItem || menuItem.Tag is not Food food)
|
|
||||||
return;
|
|
||||||
ChangeFoodInfo(food);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
using Microsoft.Win32;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Data;
|
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
using VPet_Simulator.Windows.Interface;
|
|
||||||
|
|
||||||
namespace VPet.Plugin.ModMaker.ModEdit.FoodEdit;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// AddFoodWindow.xaml 的交互逻辑
|
|
||||||
/// </summary>
|
|
||||||
public partial class Window_AddFood : Window
|
|
||||||
{
|
|
||||||
public bool IsCancel { get; internal set; } = true;
|
|
||||||
|
|
||||||
public Window_AddFood()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
Closed += (s, e) =>
|
|
||||||
{
|
|
||||||
if (IsCancel)
|
|
||||||
if (Image_FoodImage.Source is BitmapImage image)
|
|
||||||
image.StreamSource.Close();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Button_AddFoodImage_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
OpenFileDialog openFileDialog =
|
|
||||||
new() { Title = "选择图片", Filter = $"图片|*.jpg;*.jpeg;*.png;*.bmp" };
|
|
||||||
if (openFileDialog.ShowDialog() is true)
|
|
||||||
{
|
|
||||||
Image_FoodImage.Source = Utils.LoadImageToStream(openFileDialog.FileName);
|
|
||||||
Button_AddFoodImage.Visibility = Visibility.Hidden;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MenuItem_ChangeFoodImage_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
OpenFileDialog openFileDialog =
|
|
||||||
new() { Title = "选择图片", Filter = $"图片|*.jpg;*.jpeg;*.png;*.bmp" };
|
|
||||||
if (openFileDialog.ShowDialog() is true)
|
|
||||||
{
|
|
||||||
if (Image_FoodImage.Source is BitmapImage image)
|
|
||||||
image.StreamSource.Close();
|
|
||||||
Image_FoodImage.Source = Utils.LoadImageToStream(openFileDialog.FileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Button_Cancel_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Button_Yes_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
IsCancel = false;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using VPet_Simulator.Windows.Interface;
|
|
||||||
|
|
||||||
namespace VPet.Plugin.ModMaker.ModEdit.LowTextEdit;
|
|
||||||
|
|
||||||
public partial class Page_LowText
|
|
||||||
{
|
|
||||||
public static LowText CreateLowTextFromWindow(Window_AddLowText window)
|
|
||||||
{
|
|
||||||
var lowText = new LowText();
|
|
||||||
lowText.Text = window.TextBox_Text.Text;
|
|
||||||
lowText.Mode = (LowText.ModeType)
|
|
||||||
Enum.Parse(
|
|
||||||
typeof(LowText.ModeType),
|
|
||||||
((ComboBoxItem)window.ComboBox_ModeType.SelectedItem).Tag.ToString()
|
|
||||||
);
|
|
||||||
lowText.Strength = (LowText.StrengthType)
|
|
||||||
Enum.Parse(
|
|
||||||
typeof(LowText.StrengthType),
|
|
||||||
((ComboBoxItem)window.ComboBox_StrengthType.SelectedItem).Tag.ToString()
|
|
||||||
);
|
|
||||||
lowText.Like = (LowText.LikeType)
|
|
||||||
Enum.Parse(
|
|
||||||
typeof(LowText.LikeType),
|
|
||||||
((ComboBoxItem)window.ComboBox_LikeType.SelectedItem).Tag.ToString()
|
|
||||||
);
|
|
||||||
return lowText;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ChangeLowText(LowText oldText)
|
|
||||||
{
|
|
||||||
var window = new Window_AddLowText();
|
|
||||||
window.TextBox_Text.Text = oldText.Text;
|
|
||||||
foreach (ComboBoxItem item in window.ComboBox_ModeType.Items)
|
|
||||||
if (item.Tag.ToString() == oldText.Mode.ToString())
|
|
||||||
window.ComboBox_ModeType.SelectedItem = item;
|
|
||||||
foreach (ComboBoxItem item in window.ComboBox_StrengthType.Items)
|
|
||||||
if (item.Tag.ToString() == oldText.Strength.ToString())
|
|
||||||
window.ComboBox_StrengthType.SelectedItem = item;
|
|
||||||
foreach (ComboBoxItem item in window.ComboBox_LikeType.Items)
|
|
||||||
if (item.Tag.ToString() == oldText.Like.ToString())
|
|
||||||
window.ComboBox_LikeType.SelectedItem = item;
|
|
||||||
window.Closed += (s, e) =>
|
|
||||||
{
|
|
||||||
if (s is not Window_AddLowText lowTextWindow || lowTextWindow.IsCancel)
|
|
||||||
return;
|
|
||||||
var food = CreateLowTextFromWindow(lowTextWindow);
|
|
||||||
if (LowTextDict.TryGetValue(food.Text, out var tempLowText))
|
|
||||||
{
|
|
||||||
LowTextDict[food.Text] = LowTexts[LowTexts.IndexOf(tempLowText)] = food;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LowTexts[LowTexts.IndexOf(oldText)] = food;
|
|
||||||
LowTextDict.Remove(oldText.Text);
|
|
||||||
LowTextDict.Add(food.Text, food);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ShowDialogX(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
public event ShowDialogXHandler ShowDialogX;
|
|
||||||
}
|
|
@ -1,98 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Data;
|
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using System.Windows.Navigation;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
using VPet_Simulator.Windows.Interface;
|
|
||||||
|
|
||||||
namespace VPet.Plugin.ModMaker.ModEdit.LowTextEdit;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Page_LowText.xaml 的交互逻辑
|
|
||||||
/// </summary>
|
|
||||||
public partial class Page_LowText : Page
|
|
||||||
{
|
|
||||||
public ObservableCollection<LowText> LowTexts { get; set; } = new();
|
|
||||||
|
|
||||||
public Dictionary<string, LowText> LowTextDict { get; set; } = new();
|
|
||||||
|
|
||||||
public Page_LowText()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
DataGrid_LowText.ItemsSource = LowTexts;
|
|
||||||
// TODO: 多语言
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Button_AddLowText_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
var window = new Window_AddLowText();
|
|
||||||
window.Closed += (s, e) =>
|
|
||||||
{
|
|
||||||
if (s is not Window_AddLowText addLowTextWindow || addLowTextWindow.IsCancel)
|
|
||||||
return;
|
|
||||||
var lowText = CreateLowTextFromWindow(addLowTextWindow);
|
|
||||||
if (LowTextDict.TryGetValue(lowText.Text, out var oldText))
|
|
||||||
{
|
|
||||||
LowTextDict[lowText.Text] = LowTexts[LowTexts.IndexOf(oldText)] = lowText;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LowTexts.Add(lowText);
|
|
||||||
LowTextDict.Add(lowText.Text, lowText);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ShowDialogX(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DataGrid_Food_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
|
||||||
{
|
|
||||||
if (sender is not DataGrid dataGrid || dataGrid.SelectedItem is not LowText lowText)
|
|
||||||
return;
|
|
||||||
ChangeLowText(lowText);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TextBox_SearchFood_TextChanged(object sender, TextChangedEventArgs e)
|
|
||||||
{
|
|
||||||
if (sender is not TextBox textBox)
|
|
||||||
return;
|
|
||||||
if (textBox.Text.Length > 0)
|
|
||||||
{
|
|
||||||
var newList = new ObservableCollection<LowText>(
|
|
||||||
LowTexts.Where(i => i.Text.Contains(textBox.Text))
|
|
||||||
);
|
|
||||||
if (newList.Count != LowTexts.Count)
|
|
||||||
DataGrid_LowText.ItemsSource = newList;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
DataGrid_LowText.ItemsSource = LowTexts;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MenuItem_ChangeLowText_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
if (sender is not MenuItem menuItem || menuItem.Tag is not LowText lowText)
|
|
||||||
return;
|
|
||||||
ChangeLowText(lowText);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MenuItem_RemoveLowText_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
if (sender is not MenuItem menuItem || menuItem.Tag is not LowText lowText)
|
|
||||||
return;
|
|
||||||
if (DataGrid_LowText.ItemsSource is IList list && list.Count != LowTexts.Count)
|
|
||||||
list.Remove(lowText);
|
|
||||||
else
|
|
||||||
LowTexts.Remove(lowText);
|
|
||||||
LowTextDict.Remove(lowText.Text);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using VPet_Simulator.Windows.Interface;
|
|
||||||
|
|
||||||
namespace VPet.Plugin.ModMaker.ModEdit;
|
|
||||||
|
|
||||||
public partial class Window_ModEdit { }
|
|
@ -1,188 +0,0 @@
|
|||||||
<Window
|
|
||||||
x:Class="VPet.Plugin.ModMaker.ModEdit.Window_ModEdit"
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:local="clr-namespace:VPet.Plugin.ModMaker.ModEdit"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
|
||||||
Title="WinModInfo"
|
|
||||||
Width="800"
|
|
||||||
Height="450"
|
|
||||||
mc:Ignorable="d">
|
|
||||||
<Window.Resources>
|
|
||||||
<ResourceDictionary />
|
|
||||||
</Window.Resources>
|
|
||||||
<Grid>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="1*" />
|
|
||||||
<ColumnDefinition Width="2*" />
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Grid>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Image
|
|
||||||
x:Name="Image_ModImage"
|
|
||||||
Width="256"
|
|
||||||
Height="256"
|
|
||||||
Stretch="Uniform">
|
|
||||||
<Image.ContextMenu>
|
|
||||||
<ContextMenu>
|
|
||||||
<MenuItem
|
|
||||||
x:Name="MenuItem_ChangeModImage"
|
|
||||||
Click="MenuItem_ChangeModImage_Click"
|
|
||||||
Header="修改图片" />
|
|
||||||
</ContextMenu>
|
|
||||||
</Image.ContextMenu>
|
|
||||||
</Image>
|
|
||||||
<Button
|
|
||||||
x:Name="Button_AddModImage"
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Click="Button_AddModImage_Click"
|
|
||||||
Content="添加图片" />
|
|
||||||
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
|
|
||||||
<Grid>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="Auto" />
|
|
||||||
<ColumnDefinition />
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Label Content="模组名称:" />
|
|
||||||
<Label Grid.Row="1" Content="作者:" />
|
|
||||||
<Label Grid.Row="2" Content="游戏版本:" />
|
|
||||||
<Label Grid.Row="3" Content="模组版本:" />
|
|
||||||
<Label Grid.Row="4" Content="模组介绍:" />
|
|
||||||
<TextBox
|
|
||||||
x:Name="TextBox_ModName"
|
|
||||||
Grid.Column="1"
|
|
||||||
pu:TextBoxHelper.Watermark="模组名称" />
|
|
||||||
<TextBox
|
|
||||||
x:Name="TextBox_Author"
|
|
||||||
Grid.Row="1"
|
|
||||||
Grid.Column="1"
|
|
||||||
pu:TextBoxHelper.Watermark="作者" />
|
|
||||||
<TextBox
|
|
||||||
x:Name="TextBox_GameVersion"
|
|
||||||
Grid.Row="2"
|
|
||||||
Grid.Column="1"
|
|
||||||
pu:TextBoxHelper.Watermark="游戏版本" />
|
|
||||||
<TextBox
|
|
||||||
x:Name="TextBox_ModVersion"
|
|
||||||
Grid.Row="3"
|
|
||||||
Grid.Column="1"
|
|
||||||
pu:TextBoxHelper.Watermark="模组版本" />
|
|
||||||
<TextBox
|
|
||||||
x:Name="TextBox_Description"
|
|
||||||
Grid.Row="4"
|
|
||||||
Grid.Column="1"
|
|
||||||
pu:TextBoxHelper.Watermark="模组介绍" />
|
|
||||||
</Grid>
|
|
||||||
</ScrollViewer>
|
|
||||||
</Grid>
|
|
||||||
<Grid Grid.Column="1">
|
|
||||||
<TabControl>
|
|
||||||
<TabItem
|
|
||||||
x:Name="TabItem_Food"
|
|
||||||
Header="食物 (0)"
|
|
||||||
Tag="食物">
|
|
||||||
<Frame x:Name="Frame_Food" />
|
|
||||||
</TabItem>
|
|
||||||
<TabItem Header="物品 (0)" Tag="物品">
|
|
||||||
<Grid>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<TextBox x:Name="TextBox_SearchItem" />
|
|
||||||
<ListBox x:Name="ListBox_Item" />
|
|
||||||
<Button
|
|
||||||
x:Name="Button_AddItem"
|
|
||||||
Grid.Row="1"
|
|
||||||
HorizontalAlignment="Right"
|
|
||||||
VerticalAlignment="Bottom"
|
|
||||||
Click="Button_AddItem_Click"
|
|
||||||
Content="➕"
|
|
||||||
Style="{StaticResource AddButton}" />
|
|
||||||
</Grid>
|
|
||||||
</TabItem>
|
|
||||||
<TabItem Header="动画 (0)">
|
|
||||||
<Grid>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<TextBox x:Name="TextBox_SearchAnime" />
|
|
||||||
<ListBox x:Name="ListBox_Anime" />
|
|
||||||
<Button
|
|
||||||
x:Name="Button_AddAnime"
|
|
||||||
Grid.Row="1"
|
|
||||||
HorizontalAlignment="Right"
|
|
||||||
VerticalAlignment="Bottom"
|
|
||||||
Click="Button_AddAnime_Click"
|
|
||||||
Content="➕"
|
|
||||||
Style="{StaticResource AddButton}" />
|
|
||||||
</Grid>
|
|
||||||
</TabItem>
|
|
||||||
<TabItem Header="语音 (0)">
|
|
||||||
<Grid>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<TextBox x:Name="TextBox_SearchAudio" />
|
|
||||||
<ListBox x:Name="ListBox_Audio" />
|
|
||||||
<Button
|
|
||||||
x:Name="Button_AddAudio"
|
|
||||||
Grid.Row="1"
|
|
||||||
HorizontalAlignment="Right"
|
|
||||||
VerticalAlignment="Bottom"
|
|
||||||
Click="Button_AddAudio_Click"
|
|
||||||
Content="➕"
|
|
||||||
Style="{StaticResource AddButton}" />
|
|
||||||
</Grid>
|
|
||||||
</TabItem>
|
|
||||||
<TabItem Header="点击文本 (0)">
|
|
||||||
<Grid>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<TextBox x:Name="TextBox_SearchClickText" />
|
|
||||||
<ListBox x:Name="ListBox_ClickText" />
|
|
||||||
<Button
|
|
||||||
x:Name="Button_AddClickText"
|
|
||||||
Grid.Row="1"
|
|
||||||
HorizontalAlignment="Right"
|
|
||||||
VerticalAlignment="Bottom"
|
|
||||||
Click="Button_AddClickText_Click"
|
|
||||||
Content="➕"
|
|
||||||
Style="{StaticResource AddButton}" />
|
|
||||||
</Grid>
|
|
||||||
</TabItem>
|
|
||||||
<TabItem
|
|
||||||
x:Name="TabItem_LowText"
|
|
||||||
Header="低状态文本 (0)"
|
|
||||||
Tag="低状态文本">
|
|
||||||
<Frame x:Name="Frame_LowText" />
|
|
||||||
</TabItem>
|
|
||||||
</TabControl>
|
|
||||||
<!--<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Label Content="当前功能" />
|
|
||||||
<TextBox Grid.Row="1" pu:TextBoxHelper.Watermark="搜索功能" />
|
|
||||||
<ListBox Grid.Row="2" d:ItemsSource="{d:SampleData ItemCount=5}" />-->
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
</Window>
|
|
@ -1,97 +0,0 @@
|
|||||||
using Microsoft.Win32;
|
|
||||||
using Panuon.WPF;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Data;
|
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
using VPet.Plugin.ModMaker.ModEdit.FoodEdit;
|
|
||||||
using VPet.Plugin.ModMaker.ModEdit.LowTextEdit;
|
|
||||||
using VPet_Simulator.Windows.Interface;
|
|
||||||
|
|
||||||
namespace VPet.Plugin.ModMaker.ModEdit;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// winModInfo.xaml 的交互逻辑
|
|
||||||
/// </summary>
|
|
||||||
public partial class Window_ModEdit : Window
|
|
||||||
{
|
|
||||||
public string ModName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public Window_ModEdit()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
Closed += WinModInfo_Closed;
|
|
||||||
Frame_Food.Content = InitializeFoodPage();
|
|
||||||
Frame_LowText.Content = InitializeLowTextPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Page_Food InitializeFoodPage()
|
|
||||||
{
|
|
||||||
var page = new Page_Food();
|
|
||||||
page.Foods.CollectionChanged += (s, e) =>
|
|
||||||
{
|
|
||||||
TabItem_Food.Header = $"{TabItem_Food.Tag} ({page.Foods.Count})";
|
|
||||||
};
|
|
||||||
page.ShowDialogX += (w) =>
|
|
||||||
{
|
|
||||||
w.ShowDialogX(this);
|
|
||||||
};
|
|
||||||
return page;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Page_LowText InitializeLowTextPage()
|
|
||||||
{
|
|
||||||
var page = new Page_LowText();
|
|
||||||
page.LowTexts.CollectionChanged += (s, e) =>
|
|
||||||
{
|
|
||||||
TabItem_LowText.Header = $"{TabItem_LowText.Tag} ({page.LowTexts.Count})";
|
|
||||||
};
|
|
||||||
page.ShowDialogX += (w) =>
|
|
||||||
{
|
|
||||||
w.ShowDialogX(this);
|
|
||||||
};
|
|
||||||
return page;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void WinModInfo_Closed(object sender, EventArgs e) { }
|
|
||||||
|
|
||||||
private void Button_AddModImage_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
OpenFileDialog openFileDialog =
|
|
||||||
new() { Title = "选择图片", Filter = $"图片|*.jpg;*.jpeg;*.png;*.bmp" };
|
|
||||||
if (openFileDialog.ShowDialog() is true)
|
|
||||||
{
|
|
||||||
Image_ModImage.Source = new BitmapImage(new Uri(openFileDialog.FileName));
|
|
||||||
Button_AddModImage.Visibility = Visibility.Hidden;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MenuItem_ChangeModImage_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
OpenFileDialog openFileDialog =
|
|
||||||
new() { Title = "选择图片", Filter = $"图片|*.jpg;*.jpeg;*.png;*.bmp" };
|
|
||||||
if (openFileDialog.ShowDialog() is true)
|
|
||||||
{
|
|
||||||
Image_ModImage.Source = new BitmapImage(new Uri(openFileDialog.FileName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Button_AddItem_Click(object sender, RoutedEventArgs e) { }
|
|
||||||
|
|
||||||
private void Button_AddAnime_Click(object sender, RoutedEventArgs e) { }
|
|
||||||
|
|
||||||
private void Button_AddAudio_Click(object sender, RoutedEventArgs e) { }
|
|
||||||
|
|
||||||
private void Button_AddClickText_Click(object sender, RoutedEventArgs e) { }
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using VPet_Simulator.Windows.Interface;
|
|
||||||
|
|
||||||
namespace VPet.Plugin.ModMaker;
|
|
||||||
|
|
||||||
public class ModInfo
|
|
||||||
{
|
|
||||||
public string Name { get; set; } = string.Empty;
|
|
||||||
public string Author { get; set; } = string.Empty;
|
|
||||||
public string GameVersion { get; set; } = string.Empty;
|
|
||||||
public string ModVersion { get; set; } = string.Empty;
|
|
||||||
public string Description { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public List<Food> Foods { get; set; } = new();
|
|
||||||
public List<ClickText> ClickTexts { get; set; } = new();
|
|
||||||
public List<LowText> LowTexts { get; set; } = new();
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
using LinePutScript;
|
|
||||||
using LinePutScript.Localization.WPF;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows;
|
|
||||||
using VPet_Simulator.Windows.Interface;
|
|
||||||
|
|
||||||
namespace VPet.Plugin.ModMaker
|
|
||||||
{
|
|
||||||
public class ModMaker : MainPlugin
|
|
||||||
{
|
|
||||||
public ModMaker(IMainWindow mainwin)
|
|
||||||
: base(mainwin) { }
|
|
||||||
|
|
||||||
public ILine Set;
|
|
||||||
|
|
||||||
public override void LoadPlugin()
|
|
||||||
{
|
|
||||||
Set = MW.Set.FindLine("ModMaker");
|
|
||||||
MenuItem modset = MW.Main.ToolBar.MenuMODConfig;
|
|
||||||
modset.Visibility = Visibility.Visible;
|
|
||||||
var menuset = new MenuItem()
|
|
||||||
{
|
|
||||||
Header = "Mod制作器".Translate(),
|
|
||||||
HorizontalContentAlignment = HorizontalAlignment.Center,
|
|
||||||
};
|
|
||||||
menuset.Click += (s, e) =>
|
|
||||||
{
|
|
||||||
Setting();
|
|
||||||
};
|
|
||||||
modset.Items.Add(menuset);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string PluginName => "ModMaker";
|
|
||||||
public ModMakerWindow Maker;
|
|
||||||
|
|
||||||
public override void Setting()
|
|
||||||
{
|
|
||||||
if (Maker == null)
|
|
||||||
{
|
|
||||||
Maker = new ModMakerWindow();
|
|
||||||
Maker.ModMaker = this;
|
|
||||||
Maker.Show();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Maker.Topmost = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
62
VPet.Plugin.ModMaker/Models/FoodModel.cs
Normal file
62
VPet.Plugin.ModMaker/Models/FoodModel.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using HKW.HKWViewModels.SimpleObservable;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using VPet_Simulator.Windows.Interface;
|
||||||
|
|
||||||
|
namespace VPet.Plugin.ModMaker.Models;
|
||||||
|
|
||||||
|
public class FoodModel : II18nData<I18nFoodModel>
|
||||||
|
{
|
||||||
|
public ObservableValue<string> Id { get; } = new();
|
||||||
|
public ObservableValue<Food.FoodType> Type { get; } = new();
|
||||||
|
public ObservableValue<double> Strength { get; } = new();
|
||||||
|
public ObservableValue<double> StrengthFood { get; } = new();
|
||||||
|
public ObservableValue<double> StrengthDrink { get; } = new();
|
||||||
|
public ObservableValue<double> Feeling { get; } = new();
|
||||||
|
public ObservableValue<double> Health { get; } = new();
|
||||||
|
public ObservableValue<double> Likability { get; } = new();
|
||||||
|
public ObservableValue<double> Price { get; } = new();
|
||||||
|
public ObservableValue<int> Exp { get; } = new();
|
||||||
|
public ObservableValue<BitmapImage> Image { get; } = new();
|
||||||
|
public ObservableValue<I18nFoodModel> CurrentI18nData { get; } = new();
|
||||||
|
public Dictionary<string, I18nFoodModel> I18nDatas { get; } = new();
|
||||||
|
|
||||||
|
public FoodModel()
|
||||||
|
{
|
||||||
|
foreach (var lang in I18nHelper.Instance.Langs)
|
||||||
|
I18nDatas.Add(lang, new());
|
||||||
|
CurrentI18nData.Value = I18nDatas[I18nHelper.Instance.CurrentLang.Value];
|
||||||
|
}
|
||||||
|
|
||||||
|
public Food ToFood()
|
||||||
|
{
|
||||||
|
return new Food()
|
||||||
|
{
|
||||||
|
Type = Type.Value,
|
||||||
|
Strength = Strength.Value,
|
||||||
|
StrengthFood = StrengthFood.Value,
|
||||||
|
StrengthDrink = StrengthDrink.Value,
|
||||||
|
Feeling = Feeling.Value,
|
||||||
|
Health = Health.Value,
|
||||||
|
Likability = Likability.Value,
|
||||||
|
Price = Price.Value,
|
||||||
|
ImageSource = Image.Value,
|
||||||
|
Name = CurrentI18nData is null
|
||||||
|
? I18nDatas.First().Value.Name.Value
|
||||||
|
: CurrentI18nData.Value.Name.Value,
|
||||||
|
Desc = CurrentI18nData is null
|
||||||
|
? I18nDatas.First().Value.Description.Value
|
||||||
|
: CurrentI18nData.Value.Description.Value,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class I18nFoodModel
|
||||||
|
{
|
||||||
|
public ObservableValue<string> Name { get; } = new();
|
||||||
|
public ObservableValue<string> Description { get; } = new();
|
||||||
|
}
|
51
VPet.Plugin.ModMaker/Models/I18nHelper.cs
Normal file
51
VPet.Plugin.ModMaker/Models/I18nHelper.cs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
using HKW.HKWViewModels.SimpleObservable;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace VPet.Plugin.ModMaker.Models;
|
||||||
|
|
||||||
|
public class I18nHelper
|
||||||
|
{
|
||||||
|
public static I18nHelper Instance { get; set; } = new();
|
||||||
|
public ObservableValue<string> CurrentLang { get; } = new();
|
||||||
|
public ObservableCollection<string> Langs { get; } = new();
|
||||||
|
|
||||||
|
public I18nHelper()
|
||||||
|
{
|
||||||
|
Langs.CollectionChanged += Langs_CollectionChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Langs_CollectionChanged(
|
||||||
|
object sender,
|
||||||
|
System.Collections.Specialized.NotifyCollectionChangedEventArgs e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// 替换
|
||||||
|
if (e.NewStartingIndex == e.OldStartingIndex)
|
||||||
|
{
|
||||||
|
ReplaceLang?.Invoke((string)e.OldItems[0], (string)e.NewItems[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 删除
|
||||||
|
if (e.OldItems is not null)
|
||||||
|
{
|
||||||
|
RemoveLang?.Invoke((string)e.OldItems[0]);
|
||||||
|
}
|
||||||
|
// 新增
|
||||||
|
if (e.NewItems is not null)
|
||||||
|
{
|
||||||
|
AddLang?.Invoke((string)e.NewItems[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public event LangEventHandler AddLang;
|
||||||
|
public event LangEventHandler RemoveLang;
|
||||||
|
public event ReplaceLangEventHandler ReplaceLang;
|
||||||
|
|
||||||
|
public delegate void LangEventHandler(string lang);
|
||||||
|
public delegate void ReplaceLangEventHandler(string oldLang, string newLang);
|
||||||
|
}
|
15
VPet.Plugin.ModMaker/Models/II18nData.cs
Normal file
15
VPet.Plugin.ModMaker/Models/II18nData.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using HKW.HKWViewModels.SimpleObservable;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace VPet.Plugin.ModMaker.Models;
|
||||||
|
|
||||||
|
public interface II18nData<T>
|
||||||
|
where T : class
|
||||||
|
{
|
||||||
|
public ObservableValue<T> CurrentI18nData { get; }
|
||||||
|
public Dictionary<string, T> I18nDatas { get; }
|
||||||
|
}
|
31
VPet.Plugin.ModMaker/Models/LowTextModel.cs
Normal file
31
VPet.Plugin.ModMaker/Models/LowTextModel.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using HKW.HKWViewModels.SimpleObservable;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using VPet_Simulator.Windows.Interface;
|
||||||
|
|
||||||
|
namespace VPet.Plugin.ModMaker.Models;
|
||||||
|
|
||||||
|
public class LowTextModel : II18nData<I18nLowTextModel>
|
||||||
|
{
|
||||||
|
public ObservableValue<LowText.ModeType> Mode { get; } = new();
|
||||||
|
public ObservableValue<LowText.StrengthType> Strength { get; } = new();
|
||||||
|
public ObservableValue<LowText.LikeType> Like { get; } = new();
|
||||||
|
|
||||||
|
public ObservableValue<I18nLowTextModel> CurrentI18nData { get; } = new();
|
||||||
|
public Dictionary<string, I18nLowTextModel> I18nDatas { get; } = new();
|
||||||
|
|
||||||
|
public LowTextModel()
|
||||||
|
{
|
||||||
|
foreach (var lang in I18nHelper.Instance.Langs)
|
||||||
|
I18nDatas.Add(lang, new());
|
||||||
|
CurrentI18nData.Value = I18nDatas[I18nHelper.Instance.CurrentLang.Value];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class I18nLowTextModel
|
||||||
|
{
|
||||||
|
public ObservableValue<string> Text { get; } = new();
|
||||||
|
}
|
29
VPet.Plugin.ModMaker/Models/ModInfoModel.cs
Normal file
29
VPet.Plugin.ModMaker/Models/ModInfoModel.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using HKW.HKWViewModels.SimpleObservable;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using VPet_Simulator.Windows.Interface;
|
||||||
|
|
||||||
|
namespace VPet.Plugin.ModMaker.Models;
|
||||||
|
|
||||||
|
public class ModInfoModel
|
||||||
|
{
|
||||||
|
public ObservableValue<string> Author { get; } = new();
|
||||||
|
public ObservableValue<string> GameVersion { get; } = new();
|
||||||
|
public ObservableValue<string> ModVersion { get; } = new();
|
||||||
|
public ObservableValue<BitmapImage> ModImage { get; } = new();
|
||||||
|
public ObservableValue<I18nModInfoModel> CurrentI18nData { get; } = new();
|
||||||
|
public Dictionary<string, I18nModInfoModel> I18nDatas { get; } = new();
|
||||||
|
public List<FoodModel> Foods { get; set; } = new();
|
||||||
|
//public List<ClickText> ClickTexts { get; set; } = new();
|
||||||
|
//public List<LowText> LowTexts { get; set; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class I18nModInfoModel
|
||||||
|
{
|
||||||
|
public ObservableValue<string> Name { get; set; } = new();
|
||||||
|
public ObservableValue<string> Description { get; set; } = new();
|
||||||
|
}
|
55
VPet.Plugin.ModMaker/Models/ModMaker.cs
Normal file
55
VPet.Plugin.ModMaker/Models/ModMaker.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
using LinePutScript;
|
||||||
|
using LinePutScript.Localization.WPF;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows;
|
||||||
|
using VPet_Simulator.Windows.Interface;
|
||||||
|
using VPet.Plugin.ModMaker.Views;
|
||||||
|
|
||||||
|
namespace VPet.Plugin.ModMaker.Models;
|
||||||
|
|
||||||
|
public class ModMaker : MainPlugin
|
||||||
|
{
|
||||||
|
public ModMaker(IMainWindow mainwin)
|
||||||
|
: base(mainwin) { }
|
||||||
|
|
||||||
|
public ILine Set;
|
||||||
|
|
||||||
|
public override void LoadPlugin()
|
||||||
|
{
|
||||||
|
Set = MW.Set.FindLine("ModMaker");
|
||||||
|
MenuItem modset = MW.Main.ToolBar.MenuMODConfig;
|
||||||
|
modset.Visibility = Visibility.Visible;
|
||||||
|
var menuset = new MenuItem()
|
||||||
|
{
|
||||||
|
Header = "Mod制作器".Translate(),
|
||||||
|
HorizontalContentAlignment = HorizontalAlignment.Center,
|
||||||
|
};
|
||||||
|
menuset.Click += (s, e) =>
|
||||||
|
{
|
||||||
|
Setting();
|
||||||
|
};
|
||||||
|
modset.Items.Add(menuset);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string PluginName => "ModMaker";
|
||||||
|
public ModMakerWindow Maker;
|
||||||
|
|
||||||
|
public override void Setting()
|
||||||
|
{
|
||||||
|
if (Maker == null)
|
||||||
|
{
|
||||||
|
Maker = new ModMakerWindow();
|
||||||
|
Maker.ModMaker = this;
|
||||||
|
Maker.Show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Maker.Topmost = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
99
VPet.Plugin.ModMaker/SimpleObservable/ObservableCommand.cs
Normal file
99
VPet.Plugin.ModMaker/SimpleObservable/ObservableCommand.cs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
namespace HKW.HKWViewModels.SimpleObservable;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 可观察命令
|
||||||
|
/// </summary>
|
||||||
|
public class ObservableCommand : ICommand
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 执行的方法
|
||||||
|
/// </summary>
|
||||||
|
public Action? ExecuteAction { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行的异步方法
|
||||||
|
/// </summary>
|
||||||
|
public Func<Task>? ExecuteActionAsync { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取能否执行的方法
|
||||||
|
/// </summary>
|
||||||
|
public Func<bool>? CanExecuteAction { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 能执行的属性
|
||||||
|
/// <para>
|
||||||
|
/// 注意: 仅当 <see cref="CanExecuteAction"/> 为 <see langword="null"/> 时, 此属性才会被使用
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
public ObservableValue<bool> CanExecuteProperty { get; } = new(true);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 等待异步执行完成
|
||||||
|
/// </summary>
|
||||||
|
private readonly ObservableValue<bool> r_waiting = new(false);
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public ObservableCommand()
|
||||||
|
{
|
||||||
|
CanExecuteProperty.PropertyChanged += InvokeCanExecuteChanged;
|
||||||
|
r_waiting.PropertyChanged += InvokeCanExecuteChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InvokeCanExecuteChanged(
|
||||||
|
object? sender,
|
||||||
|
System.ComponentModel.PropertyChangedEventArgs e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
CanExecuteChanged?.Invoke(sender, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 能否被执行
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parameter">参数</param>
|
||||||
|
/// <returns>能被执行为 <see langword="true"/> 否则为 <see langword="false"/></returns>
|
||||||
|
public bool CanExecute(object? parameter)
|
||||||
|
{
|
||||||
|
if (r_waiting.Value is true)
|
||||||
|
return false;
|
||||||
|
return CanExecuteAction is null
|
||||||
|
? CanExecuteProperty.Value
|
||||||
|
: CanExecuteAction?.Invoke() is not false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parameter">参数</param>
|
||||||
|
public async void Execute(object? parameter)
|
||||||
|
{
|
||||||
|
ExecuteAction?.Invoke();
|
||||||
|
await ExecuteAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行异步方法, 会在等待中关闭按钮的可执行性, 完成后恢复
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>等待</returns>
|
||||||
|
private async Task ExecuteAsync()
|
||||||
|
{
|
||||||
|
if (ExecuteActionAsync is null)
|
||||||
|
return;
|
||||||
|
r_waiting.Value = true;
|
||||||
|
await ExecuteActionAsync.Invoke();
|
||||||
|
r_waiting.Value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 能否执行属性被改变事件
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler? CanExecuteChanged;
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
namespace HKW.HKWViewModels.SimpleObservable;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 带参数的可观察命令
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">参数类型</typeparam>
|
||||||
|
public class ObservableCommand<T> : ICommand
|
||||||
|
where T : notnull
|
||||||
|
{
|
||||||
|
/// <inheritdoc cref="ObservableCommand.ExecuteAction"/>
|
||||||
|
public Action<T?>? ExecuteAction { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ObservableCommand.ExecuteActionAsync"/>
|
||||||
|
public Func<T?, Task>? ExecuteActionAsync { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ObservableCommand.CanExecuteAction"/>
|
||||||
|
public Func<T?, bool>? CanExecuteAction { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ObservableCommand.CanExecuteProperty"/>
|
||||||
|
public ObservableValue<bool> CanExecuteProperty { get; } = new(true);
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ObservableCommand.r_waiting"/>
|
||||||
|
private readonly ObservableValue<bool> r_waiting = new(false);
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ObservableCommand.ObservableCommand()"/>
|
||||||
|
public ObservableCommand()
|
||||||
|
{
|
||||||
|
CanExecuteProperty.PropertyChanged += InvokeCanExecuteChanged;
|
||||||
|
r_waiting.PropertyChanged += InvokeCanExecuteChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InvokeCanExecuteChanged(
|
||||||
|
object? sender,
|
||||||
|
System.ComponentModel.PropertyChangedEventArgs e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
CanExecuteChanged?.Invoke(sender, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ObservableCommand.CanExecute(object?)"/>
|
||||||
|
public bool CanExecute(object? parameter)
|
||||||
|
{
|
||||||
|
if (r_waiting.Value is true)
|
||||||
|
return false;
|
||||||
|
return CanExecuteAction is null
|
||||||
|
? CanExecuteProperty.Value
|
||||||
|
: CanExecuteAction?.Invoke((T?)parameter) is not false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ObservableCommand.Execute(object?)"/>
|
||||||
|
public async void Execute(object? parameter)
|
||||||
|
{
|
||||||
|
ExecuteAction?.Invoke((T?)parameter);
|
||||||
|
await ExecuteAsync((T?)parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ObservableCommand.ExecuteActionAsync()"/>
|
||||||
|
/// <param name="parameter">参数</param>
|
||||||
|
private async Task ExecuteAsync(T? parameter)
|
||||||
|
{
|
||||||
|
if (ExecuteActionAsync is null)
|
||||||
|
return;
|
||||||
|
r_waiting.Value = true;
|
||||||
|
await ExecuteActionAsync.Invoke(parameter);
|
||||||
|
r_waiting.Value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ObservableCommand.CanExecuteChanged"/>
|
||||||
|
public event EventHandler? CanExecuteChanged;
|
||||||
|
}
|
79
VPet.Plugin.ModMaker/SimpleObservable/ObservableValue.cs
Normal file
79
VPet.Plugin.ModMaker/SimpleObservable/ObservableValue.cs
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HKW.HKWViewModels.SimpleObservable;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 可观察值
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
public class ObservableValue<T> : INotifyPropertyChanging, INotifyPropertyChanged
|
||||||
|
where T : notnull
|
||||||
|
{
|
||||||
|
private T? _value = default;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前值
|
||||||
|
/// </summary>
|
||||||
|
public T? Value
|
||||||
|
{
|
||||||
|
get => _value;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_value?.Equals(value) is true)
|
||||||
|
return;
|
||||||
|
PropertyChanging?.Invoke(this, new(nameof(Value)));
|
||||||
|
ValueChanging?.Invoke(_value, value);
|
||||||
|
_value = value;
|
||||||
|
PropertyChanged?.Invoke(this, new(nameof(Value)));
|
||||||
|
ValueChanged?.Invoke(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public ObservableValue() { }
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
/// <param name="value">值</param>
|
||||||
|
public ObservableValue(T value)
|
||||||
|
{
|
||||||
|
_value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 属性改变前事件
|
||||||
|
/// </summary>
|
||||||
|
public event PropertyChangingEventHandler? PropertyChanging;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 属性改变后事件
|
||||||
|
/// </summary>
|
||||||
|
public event PropertyChangedEventHandler? PropertyChanged;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 值改变前事件
|
||||||
|
/// </summary>
|
||||||
|
public event ValueChangingEventHandler? ValueChanging;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 值改变后事件
|
||||||
|
/// </summary>
|
||||||
|
public event ValueChangedEventHandler? ValueChanged;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 值改变后事件方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">值</param>
|
||||||
|
public delegate void ValueChangedEventHandler(T? value);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 值改变前事件方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="oldValue">旧值</param>
|
||||||
|
/// <param name="newValue">新值</param>
|
||||||
|
public delegate void ValueChangingEventHandler(T? oldValue, T? newValue);
|
||||||
|
}
|
@ -29,6 +29,7 @@
|
|||||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
@ -88,19 +89,30 @@
|
|||||||
<Compile Include="App.xaml.cs">
|
<Compile Include="App.xaml.cs">
|
||||||
<DependentUpon>App.xaml</DependentUpon>
|
<DependentUpon>App.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="ModEdit\FoodEdit\Page_Food.xaml.cs">
|
<Compile Include="Models\FoodModel.cs" />
|
||||||
<DependentUpon>Page_Food.xaml</DependentUpon>
|
<Compile Include="Models\I18nHelper.cs" />
|
||||||
|
<Compile Include="Models\II18nData.cs" />
|
||||||
|
<Compile Include="Models\LowTextModel.cs" />
|
||||||
|
<Compile Include="ViewModels\ModEdit\FoodEdit\FoodPageVM.cs" />
|
||||||
|
<Compile Include="ViewModels\ModEdit\FoodEdit\FoodEditWindowVM.cs" />
|
||||||
|
<Compile Include="ViewModels\ModEdit\LowTextEdit\LowTextEditWindowVM.cs" />
|
||||||
|
<Compile Include="ViewModels\ModEdit\LowTextEdit\LowTextPageVM.cs" />
|
||||||
|
<Compile Include="ViewModels\ModEdit\LowTextEdit\MapperConfiguration.cs" />
|
||||||
|
<Compile Include="ViewModels\ModEdit\ModEditWindowVM.cs" />
|
||||||
|
<Compile Include="Views\ModEdit\FoodEdit\FoodPage.xaml.cs">
|
||||||
|
<DependentUpon>FoodPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="ModEdit\FoodEdit\Page_Food.cs" />
|
<Compile Include="Views\ModEdit\LowTextEdit\LowTextPage.xaml.cs">
|
||||||
<Compile Include="ModEdit\LowTextEdit\Page_LowText.cs" />
|
<DependentUpon>LowTextPage.xaml</DependentUpon>
|
||||||
<Compile Include="ModEdit\LowTextEdit\Page_LowText.xaml.cs">
|
|
||||||
<DependentUpon>Page_LowText.xaml</DependentUpon>
|
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="ModEdit\LowTextEdit\Window_AddLowText.xaml.cs">
|
<Compile Include="Views\ModEdit\LowTextEdit\LowTextEditWindow.xaml.cs">
|
||||||
<DependentUpon>Window_AddLowText.xaml</DependentUpon>
|
<DependentUpon>LowTextEditWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="ModInfo.cs" />
|
<Compile Include="Views\ModEdit\AddLangWindow.xaml.cs">
|
||||||
<Compile Include="ModMaker.cs" />
|
<DependentUpon>AddLangWindow.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Models\ModInfoModel.cs" />
|
||||||
|
<Compile Include="Models\ModMaker.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs">
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -114,15 +126,18 @@
|
|||||||
<DependentUpon>Settings.settings</DependentUpon>
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="SimpleObservable\ObservableCommand.cs" />
|
||||||
|
<Compile Include="SimpleObservable\ObservableCommand{T}.cs" />
|
||||||
|
<Compile Include="SimpleObservable\ObservableValue.cs" />
|
||||||
<Compile Include="Utils.cs" />
|
<Compile Include="Utils.cs" />
|
||||||
<Compile Include="ModEdit\FoodEdit\Window_AddFood.xaml.cs">
|
<Compile Include="Views\ModEdit\FoodEdit\FoodEditWindow.xaml.cs">
|
||||||
<DependentUpon>Window_AddFood.xaml</DependentUpon>
|
<DependentUpon>FoodEditWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="ModEdit\Window_ModEdit.cs" />
|
<Compile Include="Views\ModEdit\ModEditWindow.xaml.cs">
|
||||||
<Compile Include="ModEdit\Window_ModEdit.xaml.cs">
|
<DependentUpon>ModEditWindow.xaml</DependentUpon>
|
||||||
<DependentUpon>Window_ModEdit.xaml</DependentUpon>
|
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="ModMakerWindow.xaml.cs">
|
<Compile Include="ViewModels\ModMakerWindowVM.cs" />
|
||||||
|
<Compile Include="Views\ModMakerWindow.xaml.cs">
|
||||||
<DependentUpon>ModMakerWindow.xaml</DependentUpon>
|
<DependentUpon>ModMakerWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
@ -140,27 +155,31 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
<Page Include="ModEdit\FoodEdit\Page_Food.xaml">
|
<Page Include="Views\ModEdit\FoodEdit\FoodPage.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="ModEdit\FoodEdit\Window_AddFood.xaml">
|
<Page Include="Views\ModEdit\FoodEdit\FoodEditWindow.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="ModEdit\LowTextEdit\Page_LowText.xaml">
|
<Page Include="Views\ModEdit\LowTextEdit\LowTextPage.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="ModEdit\LowTextEdit\Window_AddLowText.xaml">
|
<Page Include="Views\ModEdit\LowTextEdit\LowTextEditWindow.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="ModEdit\Window_ModEdit.xaml">
|
<Page Include="Views\ModEdit\AddLangWindow.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="ModMakerWindow.xaml">
|
<Page Include="Views\ModEdit\ModEditWindow.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
<Page Include="Views\ModMakerWindow.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
@ -181,5 +200,6 @@
|
|||||||
<Install>false</Install>
|
<Install>false</Install>
|
||||||
</BootstrapperPackage>
|
</BootstrapperPackage>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
@ -0,0 +1,67 @@
|
|||||||
|
using HKW.HKWViewModels.SimpleObservable;
|
||||||
|
using Microsoft.Win32;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using VPet.Plugin.ModMaker.Models;
|
||||||
|
using VPet_Simulator.Windows.Interface;
|
||||||
|
|
||||||
|
namespace VPet.Plugin.ModMaker.ViewModels.ModEdit.FoodEdit;
|
||||||
|
|
||||||
|
public class FoodEditWindowVM
|
||||||
|
{
|
||||||
|
public ObservableCollection<FoodModel> Foods { get; set; }
|
||||||
|
|
||||||
|
#region Value
|
||||||
|
public ObservableValue<FoodModel> Food { get; } = new(new());
|
||||||
|
public ObservableCollection<Food.FoodType> FoodTypes { get; } = new();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Command
|
||||||
|
public ObservableCommand AddImageCommand { get; } = new();
|
||||||
|
public ObservableCommand ChangeImageCommand { get; } = new();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public FoodEditWindowVM()
|
||||||
|
{
|
||||||
|
InitializeFoodTypes();
|
||||||
|
AddImageCommand.ExecuteAction = AddImage;
|
||||||
|
ChangeImageCommand.ExecuteAction = ChangeImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close() { }
|
||||||
|
|
||||||
|
private void InitializeFoodTypes()
|
||||||
|
{
|
||||||
|
foreach (Food.FoodType foodType in Enum.GetValues(typeof(Food.FoodType)))
|
||||||
|
{
|
||||||
|
FoodTypes.Add(foodType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddImage()
|
||||||
|
{
|
||||||
|
OpenFileDialog openFileDialog =
|
||||||
|
new() { Title = "选择图片", Filter = $"图片|*.jpg;*.jpeg;*.png;*.bmp" };
|
||||||
|
if (openFileDialog.ShowDialog() is true)
|
||||||
|
{
|
||||||
|
Food.Value.Image.Value = Utils.LoadImageToStream(openFileDialog.FileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangeImage()
|
||||||
|
{
|
||||||
|
OpenFileDialog openFileDialog =
|
||||||
|
new() { Title = "选择图片", Filter = $"图片|*.jpg;*.jpeg;*.png;*.bmp" };
|
||||||
|
if (openFileDialog.ShowDialog() is true)
|
||||||
|
{
|
||||||
|
Food.Value.Image.Value?.StreamSource?.Close();
|
||||||
|
Food.Value.Image.Value = Utils.LoadImageToStream(openFileDialog.FileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
133
VPet.Plugin.ModMaker/ViewModels/ModEdit/FoodEdit/FoodPageVM.cs
Normal file
133
VPet.Plugin.ModMaker/ViewModels/ModEdit/FoodEdit/FoodPageVM.cs
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
using HKW.HKWViewModels.SimpleObservable;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using VPet.Plugin.ModMaker.Models;
|
||||||
|
using VPet.Plugin.ModMaker.Views.ModEdit.FoodEdit;
|
||||||
|
|
||||||
|
namespace VPet.Plugin.ModMaker.ViewModels.ModEdit.FoodEdit;
|
||||||
|
|
||||||
|
public class FoodPageVM
|
||||||
|
{
|
||||||
|
#region Value
|
||||||
|
public ObservableValue<ObservableCollection<FoodModel>> ShowFoods { get; } = new();
|
||||||
|
public ObservableCollection<FoodModel> Foods { get; } = new();
|
||||||
|
public ObservableValue<string> FilterFoodText { get; } = new();
|
||||||
|
#endregion
|
||||||
|
#region Command
|
||||||
|
public ObservableCommand AddFoodCommand { get; } = new();
|
||||||
|
public ObservableCommand<FoodModel> EditFoodCommand { get; } = new();
|
||||||
|
public ObservableCommand<FoodModel> RemoveFoodCommand { get; } = new();
|
||||||
|
#endregion
|
||||||
|
public FoodPageVM()
|
||||||
|
{
|
||||||
|
ShowFoods.Value = Foods;
|
||||||
|
FilterFoodText.ValueChanged += FilterFoodText_ValueChanged;
|
||||||
|
|
||||||
|
AddFoodCommand.ExecuteAction = AddFood;
|
||||||
|
EditFoodCommand.ExecuteAction = EditFood;
|
||||||
|
RemoveFoodCommand.ExecuteAction = RemoveFood;
|
||||||
|
|
||||||
|
I18nHelper.Instance.CurrentLang.ValueChanged += CurrentLang_ValueChanged;
|
||||||
|
I18nHelper.Instance.AddLang += Instance_AddLang;
|
||||||
|
I18nHelper.Instance.RemoveLang += Instance_RemoveLang;
|
||||||
|
I18nHelper.Instance.ReplaceLang += Instance_ReplaceLang;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CurrentLang_ValueChanged(string value)
|
||||||
|
{
|
||||||
|
foreach (var food in Foods)
|
||||||
|
{
|
||||||
|
food.CurrentI18nData.Value = food.I18nDatas[value];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Instance_AddLang(string lang)
|
||||||
|
{
|
||||||
|
foreach (var food in Foods)
|
||||||
|
{
|
||||||
|
food.I18nDatas.Add(lang, new());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Instance_RemoveLang(string lang)
|
||||||
|
{
|
||||||
|
foreach (var food in Foods)
|
||||||
|
{
|
||||||
|
food.I18nDatas.Remove(lang);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Instance_ReplaceLang(string oldLang, string newLang)
|
||||||
|
{
|
||||||
|
foreach (var food in Foods)
|
||||||
|
{
|
||||||
|
var item = food.I18nDatas[oldLang];
|
||||||
|
food.I18nDatas.Remove(oldLang);
|
||||||
|
food.I18nDatas.Add(newLang, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FilterFoodText_ValueChanged(string value)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
ShowFoods.Value = Foods;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowFoods.Value = new(
|
||||||
|
Foods.Where(f => f.CurrentI18nData.Value.Name.Value.Contains(value))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close() { }
|
||||||
|
|
||||||
|
private void AddFood()
|
||||||
|
{
|
||||||
|
var window = CreateAddFoodWindow();
|
||||||
|
var vm = window.ViewModel;
|
||||||
|
window.ShowDialog();
|
||||||
|
if (window.IsCancel)
|
||||||
|
return;
|
||||||
|
Foods.Add(vm.Food.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EditFood(FoodModel food)
|
||||||
|
{
|
||||||
|
var window = CreateAddFoodWindow();
|
||||||
|
var vm = window.ViewModel;
|
||||||
|
vm.Food.Value = food;
|
||||||
|
window.ShowDialog();
|
||||||
|
// TODO: 需要实现深拷贝
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveFood(FoodModel food)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("确定删除吗", "", MessageBoxButton.YesNo) is MessageBoxResult.No)
|
||||||
|
return;
|
||||||
|
if (ShowFoods.Value.Count == Foods.Count)
|
||||||
|
{
|
||||||
|
Foods.Remove(food);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowFoods.Value.Remove(food);
|
||||||
|
Foods.Remove(food);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private FoodEditWindow CreateAddFoodWindow()
|
||||||
|
{
|
||||||
|
var window = new FoodEditWindow();
|
||||||
|
window.ViewModel.Foods = Foods;
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
using HKW.HKWViewModels.SimpleObservable;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using VPet.Plugin.ModMaker.Models;
|
||||||
|
using VPet_Simulator.Windows.Interface;
|
||||||
|
|
||||||
|
namespace VPet.Plugin.ModMaker.ViewModels.ModEdit.LowTextEdit;
|
||||||
|
|
||||||
|
public class LowTextEditWindowVM
|
||||||
|
{
|
||||||
|
#region Value
|
||||||
|
public ObservableCollection<LowTextModel> LowTexts { get; set; }
|
||||||
|
public ObservableValue<LowTextModel> LowText { get; } = new(new());
|
||||||
|
|
||||||
|
public ObservableCollection<LowText.ModeType> LowTextModeTypes { get; } = new();
|
||||||
|
public ObservableCollection<LowText.LikeType> LowTextLikeTypes { get; } = new();
|
||||||
|
public ObservableCollection<LowText.StrengthType> LowTextStrengthTypes { get; } = new();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public LowTextEditWindowVM()
|
||||||
|
{
|
||||||
|
foreach (LowText.ModeType mode in Enum.GetValues(typeof(LowText.ModeType)))
|
||||||
|
LowTextModeTypes.Add(mode);
|
||||||
|
foreach (LowText.LikeType mode in Enum.GetValues(typeof(LowText.LikeType)))
|
||||||
|
LowTextLikeTypes.Add(mode);
|
||||||
|
foreach (LowText.StrengthType mode in Enum.GetValues(typeof(LowText.StrengthType)))
|
||||||
|
LowTextStrengthTypes.Add(mode);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,143 @@
|
|||||||
|
using HKW.HKWViewModels.SimpleObservable;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using VPet.Plugin.ModMaker.Models;
|
||||||
|
using VPet.Plugin.ModMaker.Views.ModEdit.LowTextEdit;
|
||||||
|
using Expression = System.Linq.Expressions.Expression;
|
||||||
|
|
||||||
|
namespace VPet.Plugin.ModMaker.ViewModels.ModEdit.LowTextEdit;
|
||||||
|
|
||||||
|
public class LowTextPageVM
|
||||||
|
{
|
||||||
|
#region Value
|
||||||
|
public ObservableValue<string> FilterLowText { get; } = new();
|
||||||
|
public ObservableValue<ObservableCollection<LowTextModel>> ShowLowTexts { get; } = new();
|
||||||
|
public ObservableCollection<LowTextModel> LowTexts { get; } = new();
|
||||||
|
#endregion
|
||||||
|
#region Command
|
||||||
|
public ObservableCommand AddLowTextCommand { get; } = new();
|
||||||
|
public ObservableCommand<LowTextModel> EditLowTextCommand { get; } = new();
|
||||||
|
public ObservableCommand<LowTextModel> RemoveLowTextCommand { get; } = new();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public LowTextPageVM()
|
||||||
|
{
|
||||||
|
ShowLowTexts.Value = LowTexts;
|
||||||
|
FilterLowText.ValueChanged += FilterLowText_ValueChanged;
|
||||||
|
AddLowTextCommand.ExecuteAction = AddLowText;
|
||||||
|
EditLowTextCommand.ExecuteAction = EditLowText;
|
||||||
|
RemoveLowTextCommand.ExecuteAction = RemoveLowText;
|
||||||
|
|
||||||
|
I18nHelper.Instance.CurrentLang.ValueChanged += CurrentLang_ValueChanged;
|
||||||
|
I18nHelper.Instance.AddLang += Instance_AddLang;
|
||||||
|
I18nHelper.Instance.RemoveLang += Instance_RemoveLang;
|
||||||
|
I18nHelper.Instance.ReplaceLang += Instance_ReplaceLang;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FilterLowText_ValueChanged(string value)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
ShowLowTexts.Value = LowTexts;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowLowTexts.Value = new(
|
||||||
|
LowTexts.Where(f => f.CurrentI18nData.Value.Text.Value.Contains(value))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddLowText()
|
||||||
|
{
|
||||||
|
var window = CreateLowTextEditWindow();
|
||||||
|
var vm = window.ViewModel;
|
||||||
|
window.ShowDialog();
|
||||||
|
if (window.IsCancel)
|
||||||
|
return;
|
||||||
|
LowTexts.Add(vm.LowText.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EditLowText(LowTextModel lowText)
|
||||||
|
{
|
||||||
|
var window = CreateLowTextEditWindow();
|
||||||
|
var vm = window.ViewModel;
|
||||||
|
vm.LowText.Value = lowText;
|
||||||
|
window.ShowDialog();
|
||||||
|
// TODO: 需要实现深拷贝
|
||||||
|
//if (window.IsCancel)
|
||||||
|
// return;
|
||||||
|
//if (ShowLowTexts.Value.Count == LowTexts.Count)
|
||||||
|
//{
|
||||||
|
// LowTexts[LowTexts.IndexOf(lowText)] = lowText;
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// LowTexts[LowTexts.IndexOf(lowText)] = lowText;
|
||||||
|
// ShowLowTexts.Value[ShowLowTexts.Value.IndexOf(lowText)] = lowText;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveLowText(LowTextModel lowText)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("确定删除吗", "", MessageBoxButton.YesNo) is MessageBoxResult.No)
|
||||||
|
return;
|
||||||
|
if (ShowLowTexts.Value.Count == LowTexts.Count)
|
||||||
|
{
|
||||||
|
LowTexts.Remove(lowText);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowLowTexts.Value.Remove(lowText);
|
||||||
|
LowTexts.Remove(lowText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CurrentLang_ValueChanged(string value)
|
||||||
|
{
|
||||||
|
foreach (var lowText in LowTexts)
|
||||||
|
{
|
||||||
|
lowText.CurrentI18nData.Value = lowText.I18nDatas[value];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Instance_AddLang(string lang)
|
||||||
|
{
|
||||||
|
foreach (var lowText in LowTexts)
|
||||||
|
{
|
||||||
|
lowText.I18nDatas.Add(lang, new());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Instance_RemoveLang(string lang)
|
||||||
|
{
|
||||||
|
foreach (var lowText in LowTexts)
|
||||||
|
{
|
||||||
|
lowText.I18nDatas.Remove(lang);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Instance_ReplaceLang(string oldLang, string newLang)
|
||||||
|
{
|
||||||
|
foreach (var lowText in LowTexts)
|
||||||
|
{
|
||||||
|
var item = lowText.I18nDatas[oldLang];
|
||||||
|
lowText.I18nDatas.Remove(oldLang);
|
||||||
|
lowText.I18nDatas.Add(newLang, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private LowTextEditWindow CreateLowTextEditWindow()
|
||||||
|
{
|
||||||
|
var window = new LowTextEditWindow();
|
||||||
|
window.ViewModel.LowTexts = LowTexts;
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace VPet.Plugin.ModMaker.ViewModels.ModEdit.LowTextEdit;
|
||||||
|
internal class MapperConfiguration
|
||||||
|
{
|
||||||
|
private Func<object, object> value;
|
||||||
|
|
||||||
|
public MapperConfiguration(Func<object, object> value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
139
VPet.Plugin.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs
Normal file
139
VPet.Plugin.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
using HKW.HKWViewModels.SimpleObservable;
|
||||||
|
using Microsoft.Win32;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using VPet.Plugin.ModMaker.Models;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using VPet.Plugin.ModMaker.Views.ModEdit;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace VPet.Plugin.ModMaker.ViewModels.ModEdit;
|
||||||
|
|
||||||
|
public class ModEditWindowVM
|
||||||
|
{
|
||||||
|
public ModEditWindow ModEditWindow { get; }
|
||||||
|
|
||||||
|
#region Value
|
||||||
|
public ObservableValue<BitmapImage> ModImage { get; } = new();
|
||||||
|
public ObservableValue<ModInfoModel> ModInfo { get; } = new(new());
|
||||||
|
public ObservableValue<string> CurrentLang { get; } = new();
|
||||||
|
public I18nHelper I18nData => I18nHelper.Instance;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Command
|
||||||
|
public ObservableCommand AddImageCommand { get; } = new();
|
||||||
|
public ObservableCommand ChangeImageCommand { get; } = new();
|
||||||
|
public ObservableCommand AddLangCommand { get; } = new();
|
||||||
|
|
||||||
|
public ObservableCommand<string> EditLangCommand { get; } = new();
|
||||||
|
public ObservableCommand<string> RemoveLangCommand { get; } = new();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public ModEditWindowVM() { }
|
||||||
|
|
||||||
|
public ModEditWindowVM(ModEditWindow window)
|
||||||
|
{
|
||||||
|
ModEditWindow = window;
|
||||||
|
|
||||||
|
I18nHelper.Instance.AddLang += I18nData_AddLang;
|
||||||
|
I18nHelper.Instance.RemoveLang += I18nData_RemoveLang;
|
||||||
|
I18nHelper.Instance.ReplaceLang += I18nData_ReplaceLang;
|
||||||
|
CurrentLang.ValueChanged += CurrentLang_ValueChanged;
|
||||||
|
|
||||||
|
AddImageCommand.ExecuteAction = AddImage;
|
||||||
|
ChangeImageCommand.ExecuteAction = ChangeImage;
|
||||||
|
AddLangCommand.ExecuteAction = AddLang;
|
||||||
|
EditLangCommand.ExecuteAction = EditLang;
|
||||||
|
RemoveLangCommand.ExecuteAction = RemoveLang;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void I18nData_AddLang(string lang)
|
||||||
|
{
|
||||||
|
ModInfo.Value.I18nDatas.Add(lang, new());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void I18nData_RemoveLang(string lang)
|
||||||
|
{
|
||||||
|
ModInfo.Value.I18nDatas.Remove(lang);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void I18nData_ReplaceLang(string oldLang, string newLang)
|
||||||
|
{
|
||||||
|
var info = ModInfo.Value.I18nDatas[oldLang];
|
||||||
|
ModInfo.Value.I18nDatas.Remove(oldLang);
|
||||||
|
ModInfo.Value.I18nDatas.Add(newLang, info);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CurrentLang_ValueChanged(string value)
|
||||||
|
{
|
||||||
|
if (value is null)
|
||||||
|
return;
|
||||||
|
ModInfo.Value.CurrentI18nData.Value = ModInfo.Value.I18nDatas[value];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
ModInfo.Value.ModImage.Value?.StreamSource?.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddImage()
|
||||||
|
{
|
||||||
|
OpenFileDialog openFileDialog =
|
||||||
|
new() { Title = "选择图片", Filter = $"图片|*.jpg;*.jpeg;*.png;*.bmp" };
|
||||||
|
if (openFileDialog.ShowDialog() is true)
|
||||||
|
{
|
||||||
|
ModInfo.Value.ModImage.Value = Utils.LoadImageToStream(openFileDialog.FileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangeImage()
|
||||||
|
{
|
||||||
|
OpenFileDialog openFileDialog =
|
||||||
|
new() { Title = "选择图片", Filter = $"图片|*.jpg;*.jpeg;*.png;*.bmp" };
|
||||||
|
if (openFileDialog.ShowDialog() is true)
|
||||||
|
{
|
||||||
|
ModInfo.Value.ModImage.Value?.StreamSource?.Close();
|
||||||
|
ModInfo.Value.ModImage.Value = Utils.LoadImageToStream(openFileDialog.FileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddLang()
|
||||||
|
{
|
||||||
|
var window = CreateAddLangWindow();
|
||||||
|
window.ShowDialog();
|
||||||
|
if (window.IsCancel)
|
||||||
|
return;
|
||||||
|
I18nHelper.Instance.Langs.Add(window.Lang.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EditLang(string oldLang)
|
||||||
|
{
|
||||||
|
var window = CreateAddLangWindow();
|
||||||
|
window.Lang.Value = oldLang;
|
||||||
|
window.ShowDialog();
|
||||||
|
if (window.IsCancel)
|
||||||
|
return;
|
||||||
|
I18nHelper.Instance.Langs[I18nHelper.Instance.Langs.IndexOf(oldLang)] = window.Lang.Value;
|
||||||
|
CurrentLang.Value = window.Lang.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveLang(string oldLang)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("确定删除吗", "", MessageBoxButton.YesNo) is MessageBoxResult.No)
|
||||||
|
return;
|
||||||
|
I18nHelper.Instance.Langs.Remove(oldLang);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Window_AddLang CreateAddLangWindow()
|
||||||
|
{
|
||||||
|
var window = new Window_AddLang();
|
||||||
|
window.Langs = I18nHelper.Instance.Langs;
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
}
|
41
VPet.Plugin.ModMaker/ViewModels/ModMakerWindowVM.cs
Normal file
41
VPet.Plugin.ModMaker/ViewModels/ModMakerWindowVM.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using HKW.HKWViewModels.SimpleObservable;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using VPet.Plugin.ModMaker.Models;
|
||||||
|
using VPet.Plugin.ModMaker.Views;
|
||||||
|
using VPet.Plugin.ModMaker.Views.ModEdit;
|
||||||
|
|
||||||
|
namespace VPet.Plugin.ModMaker.ViewModels;
|
||||||
|
|
||||||
|
public class WindowVM_ModMaker
|
||||||
|
{
|
||||||
|
public ModMakerWindow ModMakerWindow { get; }
|
||||||
|
|
||||||
|
public ModEditWindow ModEditWindow { get; private set; }
|
||||||
|
|
||||||
|
public ObservableCommand CreateNewModCommand { get; set; } =
|
||||||
|
new() { ExecuteAction = () => { } };
|
||||||
|
|
||||||
|
public WindowVM_ModMaker() { }
|
||||||
|
|
||||||
|
public WindowVM_ModMaker(ModMakerWindow window)
|
||||||
|
{
|
||||||
|
ModMakerWindow = window;
|
||||||
|
CreateNewModCommand.ExecuteAction = CreateNewMod;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateNewMod()
|
||||||
|
{
|
||||||
|
I18nHelper.Instance = new();
|
||||||
|
ModEditWindow = new();
|
||||||
|
ModEditWindow.Show();
|
||||||
|
ModMakerWindow.Hide();
|
||||||
|
ModEditWindow.Closed += (s, e) =>
|
||||||
|
{
|
||||||
|
ModMakerWindow.Close();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
53
VPet.Plugin.ModMaker/Views/ModEdit/AddLangWindow.xaml
Normal file
53
VPet.Plugin.ModMaker/Views/ModEdit/AddLangWindow.xaml
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<Window
|
||||||
|
x:Class="VPet.Plugin.ModMaker.Views.ModEdit.Window_AddLang"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:VPet.Plugin.ModMaker.Views.ModEdit"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
||||||
|
xmlns:vm="clr-namespace:VPet.Plugin.ModMaker.ViewModels.ModEdit"
|
||||||
|
Title="Window_AddLang"
|
||||||
|
Width="400"
|
||||||
|
Height="300"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
<d:Window.DataContext>
|
||||||
|
<local:Window_AddLang />
|
||||||
|
</d:Window.DataContext>
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBox
|
||||||
|
x:Name="TextBox_Lang"
|
||||||
|
pu:TextBoxHelper.Watermark="语言/区域标记,如: 'zh-CN', 'en-US'"
|
||||||
|
Text="{Binding Lang.Value, UpdateSourceTrigger=PropertyChanged}" />
|
||||||
|
<TextBlock Grid.Row="1">
|
||||||
|
<Hyperlink Click="Hyperlink_Click">详情请参阅 Windows 支持的语言/区域名称列表中的“语言标记”列</Hyperlink>
|
||||||
|
</TextBlock>
|
||||||
|
</Grid>
|
||||||
|
<Grid Grid.Row="1">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition />
|
||||||
|
<ColumnDefinition />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Button
|
||||||
|
x:Name="Button_Cancel"
|
||||||
|
Margin="10"
|
||||||
|
Click="Button_Cancel_Click"
|
||||||
|
Content="取消" />
|
||||||
|
<Button
|
||||||
|
x:Name="Button_Yes"
|
||||||
|
Grid.Column="1"
|
||||||
|
Margin="10"
|
||||||
|
Click="Button_Yes_Click"
|
||||||
|
Content="确定" />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
68
VPet.Plugin.ModMaker/Views/ModEdit/AddLangWindow.xaml.cs
Normal file
68
VPet.Plugin.ModMaker/Views/ModEdit/AddLangWindow.xaml.cs
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
using HKW.HKWViewModels.SimpleObservable;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using VPet.Plugin.ModMaker.ViewModels.ModEdit;
|
||||||
|
|
||||||
|
namespace VPet.Plugin.ModMaker.Views.ModEdit;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Window_AddLang.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
public partial class Window_AddLang : Window
|
||||||
|
{
|
||||||
|
public bool IsCancel { get; internal set; } = true;
|
||||||
|
|
||||||
|
public ObservableCollection<string> Langs { get; internal set; }
|
||||||
|
|
||||||
|
public ObservableValue<string> Lang { get; } = new();
|
||||||
|
|
||||||
|
public Window_AddLang()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.DataContext = this;
|
||||||
|
TextBox_Lang.Focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Button_Cancel_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Button_Yes_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(Lang.Value))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Lang不可为空", "", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Langs.Contains(Lang.Value))
|
||||||
|
{
|
||||||
|
MessageBox.Show("此语言已存在", "", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
IsCancel = false;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Hyperlink_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Process.Start(
|
||||||
|
new ProcessStartInfo(
|
||||||
|
"https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,19 @@
|
|||||||
<Window
|
<Window
|
||||||
x:Class="VPet.Plugin.ModMaker.ModEdit.FoodEdit.Window_AddFood"
|
x:Class="VPet.Plugin.ModMaker.Views.ModEdit.FoodEdit.FoodEditWindow"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:VPet.Plugin.ModMaker.ModEdit.FoodEdit"
|
xmlns:local="clr-namespace:VPet.Plugin.ModMaker.Views.ModEdit.FoodEdit"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
||||||
Title="AddFoodWindow"
|
xmlns:vm="clr-namespace:VPet.Plugin.ModMaker.ViewModels.ModEdit.FoodEdit"
|
||||||
|
Title="Window_FoodEdit"
|
||||||
Width="800"
|
Width="800"
|
||||||
Height="450"
|
Height="450"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
<d:Window.DataContext>
|
||||||
|
<vm:FoodEditWindowVM />
|
||||||
|
</d:Window.DataContext>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
@ -24,22 +28,30 @@
|
|||||||
x:Name="Image_FoodImage"
|
x:Name="Image_FoodImage"
|
||||||
Width="256"
|
Width="256"
|
||||||
Height="256"
|
Height="256"
|
||||||
|
Source="{Binding Food.Value.Image.Value}"
|
||||||
Stretch="Uniform">
|
Stretch="Uniform">
|
||||||
<Image.ContextMenu>
|
<Image.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<MenuItem
|
<MenuItem Command="{Binding ChangeImageCommand}" Header="修改图片" />
|
||||||
x:Name="MenuItem_ChangeFoodImage"
|
|
||||||
Click="MenuItem_ChangeFoodImage_Click"
|
|
||||||
Header="修改图片" />
|
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</Image.ContextMenu>
|
</Image.ContextMenu>
|
||||||
</Image>
|
</Image>
|
||||||
<Button
|
<Button
|
||||||
x:Name="Button_AddFoodImage"
|
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Click="Button_AddFoodImage_Click"
|
Command="{Binding AddImageCommand}"
|
||||||
Content="添加图片" />
|
Content="添加图片">
|
||||||
|
<Button.Style>
|
||||||
|
<Style BasedOn="{StaticResource {x:Type Button}}" TargetType="Button">
|
||||||
|
<Setter Property="Visibility" Value="Hidden" />
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding Food.Value.Image.Value}" Value="{x:Null}">
|
||||||
|
<Setter Property="Visibility" Value="Visible" />
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Button.Style>
|
||||||
|
</Button>
|
||||||
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
|
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@ -47,37 +59,36 @@
|
|||||||
<ColumnDefinition />
|
<ColumnDefinition />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Label Content="食物名称:" />
|
<Label Content="食物Id:" />
|
||||||
<TextBox
|
<TextBox
|
||||||
x:Name="TextBox_FoodName"
|
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
pu:TextBoxHelper.Watermark="食物名称" />
|
pu:TextBoxHelper.Watermark="食物Id"
|
||||||
<Label Content="食物名称:" />
|
Text="{Binding Food.Value.Id.Value}" />
|
||||||
<Label Grid.Row="1" Content="食物类型:" />
|
<Label Grid.Row="1" Content="食物类型:" />
|
||||||
<ComboBox
|
<ComboBox
|
||||||
x:Name="ComboBox_FoodType"
|
x:Name="ComboBox_FoodType"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
SelectedIndex="0">
|
ItemsSource="{Binding FoodTypes}"
|
||||||
<ComboBoxItem Content="食物" Tag="Food" />
|
SelectedItem="{Binding Food.Value.Type.Value}" />
|
||||||
<ComboBoxItem Content="收藏" Tag="Star" />
|
<Label Grid.Row="2" Content="食物名称:" />
|
||||||
<ComboBoxItem Content="正餐" Tag="Meal" />
|
|
||||||
<ComboBoxItem Content="零食" Tag="Snack" />
|
|
||||||
<ComboBoxItem Content="饮料" Tag="Drink" />
|
|
||||||
<ComboBoxItem Content="功能性" Tag="Functional" />
|
|
||||||
<ComboBoxItem Content="药品" Tag="Drug" />
|
|
||||||
<!--<ComboBoxItem Content="礼物" Tag="Gift" />-->
|
|
||||||
</ComboBox>
|
|
||||||
<Label Grid.Row="2" Content="食物描述:" />
|
|
||||||
<TextBox
|
<TextBox
|
||||||
x:Name="TextBox_FoodDescription"
|
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
pu:TextBoxHelper.Watermark="食物描述" />
|
pu:TextBoxHelper.Watermark="食物名称"
|
||||||
|
Text="{Binding Food.Value.CurrentI18nData.Value.Name.Value}" />
|
||||||
|
<Label Content="食物名称:" />
|
||||||
|
<Label Grid.Row="3" Content="食物描述:" />
|
||||||
|
<TextBox
|
||||||
|
Grid.Row="3"
|
||||||
|
Grid.Column="1"
|
||||||
|
pu:TextBoxHelper.Watermark="食物描述"
|
||||||
|
Text="{Binding Food.Value.CurrentI18nData.Value.Description.Value}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -106,42 +117,46 @@
|
|||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Label Content="饱腹值:" />
|
<Label Content="饱腹值:" />
|
||||||
<pu:NumberInput x:Name="NumberInput_StrengthFood" Grid.Column="1" />
|
<pu:NumberInput
|
||||||
|
x:Name="NumberInput_StrengthFood"
|
||||||
|
Grid.Column="1"
|
||||||
|
Value="{Binding Food.Value.StrengthFood.Value}" />
|
||||||
<Label Grid.Row="2" Content="口渴值:" />
|
<Label Grid.Row="2" Content="口渴值:" />
|
||||||
<pu:NumberInput
|
<pu:NumberInput
|
||||||
x:Name="NumberInput_StrengthDrink"
|
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Grid.Column="1" />
|
Grid.Column="1"
|
||||||
|
Value="{Binding Food.Value.StrengthDrink.Value}" />
|
||||||
<Label Grid.Row="3" Content="健康值:" />
|
<Label Grid.Row="3" Content="健康值:" />
|
||||||
<pu:NumberInput
|
<pu:NumberInput
|
||||||
x:Name="NumberInput_Health"
|
|
||||||
Grid.Row="3"
|
Grid.Row="3"
|
||||||
Grid.Column="1" />
|
Grid.Column="1"
|
||||||
|
Value="{Binding Food.Value.Health.Value}" />
|
||||||
<Label Grid.Row="4" Content="体力值:" />
|
<Label Grid.Row="4" Content="体力值:" />
|
||||||
<pu:NumberInput
|
<pu:NumberInput
|
||||||
x:Name="NumberInput_Strength"
|
|
||||||
Grid.Row="4"
|
Grid.Row="4"
|
||||||
Grid.Column="1" />
|
Grid.Column="1"
|
||||||
|
Value="{Binding Food.Value.Strength.Value}" />
|
||||||
<Label Grid.Row="5" Content="心情值:" />
|
<Label Grid.Row="5" Content="心情值:" />
|
||||||
<pu:NumberInput
|
<pu:NumberInput
|
||||||
x:Name="NumberInput_Feeling"
|
|
||||||
Grid.Row="5"
|
Grid.Row="5"
|
||||||
Grid.Column="1" />
|
Grid.Column="1"
|
||||||
|
Value="{Binding Food.Value.Feeling.Value}" />
|
||||||
<Label Grid.Row="6" Content="好感值:" />
|
<Label Grid.Row="6" Content="好感值:" />
|
||||||
<pu:NumberInput
|
<pu:NumberInput
|
||||||
x:Name="NumberInput_Likability"
|
|
||||||
Grid.Row="6"
|
Grid.Row="6"
|
||||||
Grid.Column="1" />
|
Grid.Column="1"
|
||||||
|
Value="{Binding Food.Value.Likability.Value}" />
|
||||||
<Label Grid.Row="7" Content="经验值:" />
|
<Label Grid.Row="7" Content="经验值:" />
|
||||||
<pu:NumberInput
|
<pu:NumberInput
|
||||||
x:Name="NumberInput_Exp"
|
|
||||||
Grid.Row="7"
|
Grid.Row="7"
|
||||||
Grid.Column="1" />
|
Grid.Column="1"
|
||||||
|
Value="{Binding Food.Value.Exp.Value}" />
|
||||||
<Label Grid.Row="8" Content="价格:" />
|
<Label Grid.Row="8" Content="价格:" />
|
||||||
<pu:NumberInput
|
<pu:NumberInput
|
||||||
x:Name="NumberInput_Price"
|
x:Name="NumberInput_Price"
|
||||||
Grid.Row="8"
|
Grid.Row="8"
|
||||||
Grid.Column="1" />
|
Grid.Column="1"
|
||||||
|
Value="{Binding Food.Value.Price.Value}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
<Grid Grid.Row="2">
|
<Grid Grid.Row="2">
|
@ -0,0 +1,66 @@
|
|||||||
|
using Microsoft.Win32;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using VPet.Plugin.ModMaker.ViewModels.ModEdit.FoodEdit;
|
||||||
|
using VPet_Simulator.Windows.Interface;
|
||||||
|
|
||||||
|
namespace VPet.Plugin.ModMaker.Views.ModEdit.FoodEdit;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// AddFoodWindow.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
public partial class FoodEditWindow : Window
|
||||||
|
{
|
||||||
|
public bool IsCancel { get; internal set; } = true;
|
||||||
|
|
||||||
|
public FoodEditWindowVM ViewModel => (FoodEditWindowVM)DataContext;
|
||||||
|
|
||||||
|
public FoodEditWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
DataContext = new FoodEditWindowVM();
|
||||||
|
Closed += (s, e) =>
|
||||||
|
{
|
||||||
|
ViewModel.Close();
|
||||||
|
if (IsCancel)
|
||||||
|
ViewModel.Food.Value.Image.Value?.StreamSource?.Close();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Button_Cancel_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Button_Yes_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(ViewModel.Food.Value.Id.Value))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Id不可为空", "", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ViewModel.Food.Value.CurrentI18nData.Value.Name.Value is null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("名称不可为空", "", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ViewModel.Food.Value.Image.Value is null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("图像不可为空", "", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
IsCancel = false;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
@ -1,28 +1,30 @@
|
|||||||
<Page
|
<Page
|
||||||
x:Class="VPet.Plugin.ModMaker.ModEdit.FoodEdit.Page_Food"
|
x:Class="VPet.Plugin.ModMaker.Views.ModEdit.FoodEdit.FoodPage"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:VPet.Plugin.ModMaker.ModEdit"
|
xmlns:local="clr-namespace:VPet.Plugin.ModMaker.Views.ModEdit.FoodEdit"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
||||||
|
xmlns:vm="clr-namespace:VPet.Plugin.ModMaker.ViewModels.ModEdit.FoodEdit"
|
||||||
Title="Page_Food"
|
Title="Page_Food"
|
||||||
d:DesignHeight="450"
|
d:DesignHeight="450"
|
||||||
d:DesignWidth="800"
|
d:DesignWidth="800"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
<d:Page.DataContext>
|
||||||
|
<vm:FoodPageVM />
|
||||||
|
</d:Page.DataContext>
|
||||||
<Page.Resources>
|
<Page.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ContextMenu x:Key="ContextMenu_DataGridRow">
|
<ContextMenu x:Key="ContextMenu_DataGridRow" x:Shared="false">
|
||||||
<MenuItem
|
<MenuItem
|
||||||
x:Name="MenuItem_ChangeFood"
|
Command="{Binding DataContext.EditFoodCommand, RelativeSource={RelativeSource AncestorType=Page, Mode=FindAncestor}}"
|
||||||
Click="MenuItem_ChangeFood_Click"
|
CommandParameter="{Binding DataContext, RelativeSource={RelativeSource AncestorType=DataGridRow, Mode=FindAncestor}}"
|
||||||
Header="修改食物"
|
Header="修改食物" />
|
||||||
Tag="{Binding Tag, RelativeSource={RelativeSource AncestorType=DataGridRow, Mode=FindAncestor}}" />
|
|
||||||
<MenuItem
|
<MenuItem
|
||||||
x:Name="MenuItem_RemoveFood"
|
Command="{Binding DataContext.RemoveFoodCommand, RelativeSource={RelativeSource AncestorType=Page, Mode=FindAncestor}}"
|
||||||
Click="MenuItem_RemoveFood_Click"
|
CommandParameter="{Binding DataContext, RelativeSource={RelativeSource AncestorType=DataGridRow, Mode=FindAncestor}}"
|
||||||
Header="删除食物"
|
Header="删除食物" />
|
||||||
Tag="{Binding Tag, RelativeSource={RelativeSource AncestorType=DataGridRow, Mode=FindAncestor}}" />
|
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
@ -31,10 +33,7 @@
|
|||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<TextBox
|
<TextBox pu:TextBoxHelper.Watermark="搜索食物" Text="{Binding FilterFoodText.Value, UpdateSourceTrigger=PropertyChanged}" />
|
||||||
x:Name="TextBox_SearchFood"
|
|
||||||
pu:TextBoxHelper.Watermark="搜索食物"
|
|
||||||
TextChanged="TextBox_SearchFood_TextChanged" />
|
|
||||||
<DataGrid
|
<DataGrid
|
||||||
x:Name="DataGrid_Food"
|
x:Name="DataGrid_Food"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
@ -43,6 +42,7 @@
|
|||||||
AutoGenerateColumns="False"
|
AutoGenerateColumns="False"
|
||||||
CanUserAddRows="False"
|
CanUserAddRows="False"
|
||||||
GridLinesVisibility="Horizontal"
|
GridLinesVisibility="Horizontal"
|
||||||
|
ItemsSource="{Binding Foods}"
|
||||||
MouseDoubleClick="DataGrid_Food_MouseDoubleClick"
|
MouseDoubleClick="DataGrid_Food_MouseDoubleClick"
|
||||||
RowDetailsVisibilityMode="Visible"
|
RowDetailsVisibilityMode="Visible"
|
||||||
RowHeight="64"
|
RowHeight="64"
|
||||||
@ -57,12 +57,12 @@
|
|||||||
</DataGrid.RowStyle>
|
</DataGrid.RowStyle>
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn
|
<DataGridTextColumn
|
||||||
Binding="{Binding Name}"
|
Binding="{Binding Id.Value}"
|
||||||
CanUserSort="True"
|
CanUserSort="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
SortMemberPath="Name">
|
SortMemberPath="Name">
|
||||||
<DataGridTextColumn.Header>
|
<DataGridTextColumn.Header>
|
||||||
<Label Content="食物名称" />
|
<Label Content="食物ID" />
|
||||||
</DataGridTextColumn.Header>
|
</DataGridTextColumn.Header>
|
||||||
</DataGridTextColumn>
|
</DataGridTextColumn>
|
||||||
<DataGridTemplateColumn IsReadOnly="True">
|
<DataGridTemplateColumn IsReadOnly="True">
|
||||||
@ -76,7 +76,7 @@
|
|||||||
Height="64"
|
Height="64"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Source="{Binding ImageSource, IsAsync=True}"
|
Source="{Binding Image.Value, IsAsync=True}"
|
||||||
Stretch="Uniform">
|
Stretch="Uniform">
|
||||||
<Image.ToolTip>
|
<Image.ToolTip>
|
||||||
<Image
|
<Image
|
||||||
@ -84,7 +84,7 @@
|
|||||||
Height="256"
|
Height="256"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Source="{Binding ImageSource, IsAsync=True}"
|
Source="{Binding Image.Value, IsAsync=True}"
|
||||||
Stretch="Uniform" />
|
Stretch="Uniform" />
|
||||||
</Image.ToolTip>
|
</Image.ToolTip>
|
||||||
</Image>
|
</Image>
|
||||||
@ -92,7 +92,16 @@
|
|||||||
</DataGridTemplateColumn.CellTemplate>
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
</DataGridTemplateColumn>
|
</DataGridTemplateColumn>
|
||||||
<DataGridTextColumn
|
<DataGridTextColumn
|
||||||
Binding="{Binding Type}"
|
Binding="{Binding CurrentI18nData.Value.Name.Value}"
|
||||||
|
CanUserSort="True"
|
||||||
|
IsReadOnly="True"
|
||||||
|
SortMemberPath="Name">
|
||||||
|
<DataGridTextColumn.Header>
|
||||||
|
<Label Content="食物名称" />
|
||||||
|
</DataGridTextColumn.Header>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
<DataGridTextColumn
|
||||||
|
Binding="{Binding Type.Value}"
|
||||||
CanUserSort="True"
|
CanUserSort="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
SortMemberPath="Type">
|
SortMemberPath="Type">
|
||||||
@ -101,7 +110,7 @@
|
|||||||
</DataGridTextColumn.Header>
|
</DataGridTextColumn.Header>
|
||||||
</DataGridTextColumn>
|
</DataGridTextColumn>
|
||||||
<DataGridTextColumn
|
<DataGridTextColumn
|
||||||
Binding="{Binding StrengthFood}"
|
Binding="{Binding StrengthFood.Value}"
|
||||||
CanUserSort="True"
|
CanUserSort="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
SortMemberPath="StrengthFood">
|
SortMemberPath="StrengthFood">
|
||||||
@ -110,7 +119,7 @@
|
|||||||
</DataGridTextColumn.Header>
|
</DataGridTextColumn.Header>
|
||||||
</DataGridTextColumn>
|
</DataGridTextColumn>
|
||||||
<DataGridTextColumn
|
<DataGridTextColumn
|
||||||
Binding="{Binding StrengthDrink}"
|
Binding="{Binding StrengthDrink.Value}"
|
||||||
CanUserSort="True"
|
CanUserSort="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
SortMemberPath="StrengthDrink">
|
SortMemberPath="StrengthDrink">
|
||||||
@ -119,7 +128,7 @@
|
|||||||
</DataGridTextColumn.Header>
|
</DataGridTextColumn.Header>
|
||||||
</DataGridTextColumn>
|
</DataGridTextColumn>
|
||||||
<DataGridTextColumn
|
<DataGridTextColumn
|
||||||
Binding="{Binding Health}"
|
Binding="{Binding Health.Value}"
|
||||||
CanUserSort="True"
|
CanUserSort="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
SortMemberPath="Health">
|
SortMemberPath="Health">
|
||||||
@ -128,7 +137,7 @@
|
|||||||
</DataGridTextColumn.Header>
|
</DataGridTextColumn.Header>
|
||||||
</DataGridTextColumn>
|
</DataGridTextColumn>
|
||||||
<DataGridTextColumn
|
<DataGridTextColumn
|
||||||
Binding="{Binding Strength}"
|
Binding="{Binding Strength.Value}"
|
||||||
CanUserSort="True"
|
CanUserSort="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
SortMemberPath="Strength">
|
SortMemberPath="Strength">
|
||||||
@ -137,7 +146,7 @@
|
|||||||
</DataGridTextColumn.Header>
|
</DataGridTextColumn.Header>
|
||||||
</DataGridTextColumn>
|
</DataGridTextColumn>
|
||||||
<DataGridTextColumn
|
<DataGridTextColumn
|
||||||
Binding="{Binding Feeling}"
|
Binding="{Binding Feeling.Value}"
|
||||||
CanUserSort="True"
|
CanUserSort="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
SortMemberPath="Feeling">
|
SortMemberPath="Feeling">
|
||||||
@ -146,7 +155,7 @@
|
|||||||
</DataGridTextColumn.Header>
|
</DataGridTextColumn.Header>
|
||||||
</DataGridTextColumn>
|
</DataGridTextColumn>
|
||||||
<DataGridTextColumn
|
<DataGridTextColumn
|
||||||
Binding="{Binding Likability}"
|
Binding="{Binding Likability.Value}"
|
||||||
CanUserSort="True"
|
CanUserSort="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
SortMemberPath="Likability">
|
SortMemberPath="Likability">
|
||||||
@ -155,7 +164,7 @@
|
|||||||
</DataGridTextColumn.Header>
|
</DataGridTextColumn.Header>
|
||||||
</DataGridTextColumn>
|
</DataGridTextColumn>
|
||||||
<DataGridTextColumn
|
<DataGridTextColumn
|
||||||
Binding="{Binding Exp}"
|
Binding="{Binding Exp.Value}"
|
||||||
CanUserSort="True"
|
CanUserSort="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
SortMemberPath="Exp">
|
SortMemberPath="Exp">
|
||||||
@ -164,7 +173,7 @@
|
|||||||
</DataGridTextColumn.Header>
|
</DataGridTextColumn.Header>
|
||||||
</DataGridTextColumn>
|
</DataGridTextColumn>
|
||||||
<DataGridTextColumn
|
<DataGridTextColumn
|
||||||
Binding="{Binding Price}"
|
Binding="{Binding Price.Value}"
|
||||||
CanUserSort="True"
|
CanUserSort="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
SortMemberPath="Price">
|
SortMemberPath="Price">
|
||||||
@ -173,10 +182,10 @@
|
|||||||
</DataGridTextColumn.Header>
|
</DataGridTextColumn.Header>
|
||||||
</DataGridTextColumn>
|
</DataGridTextColumn>
|
||||||
<DataGridTextColumn
|
<DataGridTextColumn
|
||||||
Binding="{Binding Desc}"
|
Binding="{Binding CurrentI18nData.Value.Description.Value}"
|
||||||
CanUserSort="True"
|
CanUserSort="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
SortMemberPath="Desc">
|
SortMemberPath="Description">
|
||||||
<DataGridTextColumn.Header>
|
<DataGridTextColumn.Header>
|
||||||
<Label Content="描述" />
|
<Label Content="描述" />
|
||||||
</DataGridTextColumn.Header>
|
</DataGridTextColumn.Header>
|
||||||
@ -188,7 +197,7 @@
|
|||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
VerticalAlignment="Bottom"
|
VerticalAlignment="Bottom"
|
||||||
Click="Button_AddFood_Click"
|
Command="{Binding AddFoodCommand}"
|
||||||
Content="➕"
|
Content="➕"
|
||||||
Style="{StaticResource AddButton}" />
|
Style="{StaticResource AddButton}" />
|
||||||
</Grid>
|
</Grid>
|
42
VPet.Plugin.ModMaker/Views/ModEdit/FoodEdit/FoodPage.xaml.cs
Normal file
42
VPet.Plugin.ModMaker/Views/ModEdit/FoodEdit/FoodPage.xaml.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using VPet.Plugin.ModMaker.Models;
|
||||||
|
using VPet.Plugin.ModMaker.ViewModels.ModEdit.FoodEdit;
|
||||||
|
using VPet_Simulator.Windows.Interface;
|
||||||
|
|
||||||
|
namespace VPet.Plugin.ModMaker.Views.ModEdit.FoodEdit;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Page_Food.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
public partial class FoodPage : Page
|
||||||
|
{
|
||||||
|
public FoodPageVM ViewModel => (FoodPageVM)DataContext;
|
||||||
|
|
||||||
|
public FoodPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
DataContext = new FoodPageVM();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DataGrid_Food_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is not DataGrid dataGrid || dataGrid.SelectedItem is not FoodModel food)
|
||||||
|
return;
|
||||||
|
ViewModel.EditFood(food);
|
||||||
|
}
|
||||||
|
}
|
@ -1,43 +1,31 @@
|
|||||||
<Window
|
<Window
|
||||||
x:Class="VPet.Plugin.ModMaker.ModEdit.LowTextEdit.Window_AddLowText"
|
x:Class="VPet.Plugin.ModMaker.Views.ModEdit.LowTextEdit.LowTextEditWindow"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:VPet.Plugin.ModMaker.ModEdit.LowTextEdit"
|
xmlns:local="clr-namespace:VPet.Plugin.ModMaker.Views.ModEdit.LowTextEdit"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
||||||
|
xmlns:vm="clr-namespace:VPet.Plugin.ModMaker.ViewModels.ModEdit.LowTextEdit"
|
||||||
Title="Page_LowText"
|
Title="Page_LowText"
|
||||||
Width="800"
|
Width="800"
|
||||||
Height="450"
|
Height="450"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
<d:Window.DataContext>
|
||||||
|
<vm:LowTextEditWindowVM />
|
||||||
|
</d:Window.DataContext>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition />
|
<ColumnDefinition />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Grid>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition />
|
|
||||||
<ColumnDefinition Width="Auto" />
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<ComboBox x:Name="ComboBox_Langs" />
|
|
||||||
<Button
|
|
||||||
x:Name="Button_AddLang"
|
|
||||||
Grid.Column="1"
|
|
||||||
Content="添加语言" />
|
|
||||||
</Grid>
|
|
||||||
<TextBox
|
<TextBox
|
||||||
x:Name="TextBox_Text"
|
x:Name="TextBox_Text"
|
||||||
Grid.Row="1"
|
|
||||||
VerticalContentAlignment="Top"
|
VerticalContentAlignment="Top"
|
||||||
d:Text="这是一个测试文本,这是一个测试文本,这是一个测试文本,这是一个测试文本,这是一个测试文本,这是一个测试文本,这是一个测试文本,"
|
d:Text="这是一个测试文本,这是一个测试文本,这是一个测试文本,这是一个测试文本,这是一个测试文本,这是一个测试文本,这是一个测试文本,"
|
||||||
pu:TextBoxHelper.Watermark="文本"
|
pu:TextBoxHelper.Watermark="文本"
|
||||||
|
Text="{Binding LowText.Value.CurrentI18nData.Value.Text.Value, UpdateSourceTrigger=PropertyChanged}"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Grid.Column="1">
|
<Grid Grid.Column="1">
|
||||||
@ -57,33 +45,21 @@
|
|||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Label Content="状态" />
|
<Label Content="状态" />
|
||||||
<ComboBox
|
<ComboBox
|
||||||
x:Name="ComboBox_ModeType"
|
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
SelectedIndex="0">
|
ItemsSource="{Binding LowTextModeTypes}"
|
||||||
<ComboBoxItem Content="普通" Tag="H" />
|
SelectedItem="{Binding LowText.Value.Mode.Value}" />
|
||||||
<ComboBoxItem Content="生病" Tag="L" />
|
|
||||||
</ComboBox>
|
|
||||||
<Label Grid.Row="1" Content="口渴/饥饿状态" />
|
<Label Grid.Row="1" Content="口渴/饥饿状态" />
|
||||||
<ComboBox
|
<ComboBox
|
||||||
x:Name="ComboBox_StrengthType"
|
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
SelectedIndex="0">
|
ItemsSource="{Binding LowTextStrengthTypes}"
|
||||||
<ComboBoxItem Content="一般口渴/饥饿" Tag="L" />
|
SelectedItem="{Binding LowText.Value.Strength.Value}" />
|
||||||
<ComboBoxItem Content="有点口渴/饥饿" Tag="M" />
|
|
||||||
<ComboBoxItem Content="非常口渴/饥饿" Tag="S" />
|
|
||||||
</ComboBox>
|
|
||||||
<Label Grid.Row="2" Content="好感度需求" />
|
<Label Grid.Row="2" Content="好感度需求" />
|
||||||
<ComboBox
|
<ComboBox
|
||||||
x:Name="ComboBox_LikeType"
|
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
SelectedIndex="0">
|
ItemsSource="{Binding LowTextLikeTypes}"
|
||||||
<ComboBoxItem Content="无" Tag="N" />
|
SelectedItem="{Binding LowText.Value.Like.Value}" />
|
||||||
<ComboBoxItem Content="低" Tag="S" />
|
|
||||||
<ComboBoxItem Content="中" Tag="M" />
|
|
||||||
<ComboBoxItem Content="高" Tag="L" />
|
|
||||||
</ComboBox>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Grid.Row="1">
|
<Grid Grid.Row="1">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
@ -12,19 +12,22 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using VPet.Plugin.ModMaker.ViewModels.ModEdit.LowTextEdit;
|
||||||
|
|
||||||
namespace VPet.Plugin.ModMaker.ModEdit.LowTextEdit;
|
namespace VPet.Plugin.ModMaker.Views.ModEdit.LowTextEdit;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Window_AddLowText.xaml 的交互逻辑
|
/// Window_AddLowText.xaml 的交互逻辑
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class Window_AddLowText : Window
|
public partial class LowTextEditWindow : Window
|
||||||
{
|
{
|
||||||
public bool IsCancel { get; internal set; } = true;
|
public LowTextEditWindowVM ViewModel => (LowTextEditWindowVM)DataContext;
|
||||||
|
public bool IsCancel { get; private set; } = true;
|
||||||
|
|
||||||
public Window_AddLowText()
|
public LowTextEditWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
DataContext = new LowTextEditWindowVM();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button_Cancel_Click(object sender, RoutedEventArgs e)
|
private void Button_Cancel_Click(object sender, RoutedEventArgs e)
|
@ -1,29 +1,30 @@
|
|||||||
<Page
|
<Page
|
||||||
x:Class="VPet.Plugin.ModMaker.ModEdit.LowTextEdit.Page_LowText"
|
x:Class="VPet.Plugin.ModMaker.Views.ModEdit.LowTextEdit.LowTextPage"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:VPet.Plugin.ModMaker.ModEdit.LowTextEdit"
|
xmlns:local="clr-namespace:VPet.Plugin.ModMaker.Views.ModEdit.LowTextEdit"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
||||||
|
xmlns:vm="clr-namespace:VPet.Plugin.ModMaker.ViewModels.ModEdit.LowTextEdit"
|
||||||
Title="Page_LowText"
|
Title="Page_LowText"
|
||||||
d:DesignHeight="450"
|
d:DesignHeight="450"
|
||||||
d:DesignWidth="800"
|
d:DesignWidth="800"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
<d:Page.DataContext>
|
||||||
|
<vm:LowTextPageVM />
|
||||||
|
</d:Page.DataContext>
|
||||||
<Page.Resources>
|
<Page.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ContextMenu x:Key="ContextMenu_DataGridRow">
|
<ContextMenu x:Key="ContextMenu_DataGridRow" x:Shared="false">
|
||||||
<MenuItem
|
<MenuItem
|
||||||
x:Name="MenuItem_ChangeLowText"
|
Command="{Binding DataContext.EditLowTextCommand, RelativeSource={RelativeSource AncestorType=Page, Mode=FindAncestor}}"
|
||||||
Click="MenuItem_ChangeLowText_Click"
|
CommandParameter="{Binding DataContext, RelativeSource={RelativeSource AncestorType=DataGridRow, Mode=FindAncestor}}"
|
||||||
Header="修改低状态文本"
|
Header="修改低状态文本" />
|
||||||
Tag="{Binding Tag, RelativeSource={RelativeSource AncestorType=DataGridRow, Mode=FindAncestor}}" />
|
|
||||||
<MenuItem
|
<MenuItem
|
||||||
x:Name="MenuItem_RemoveLowText"
|
Command="{Binding DataContext.RemoveLowTextCommand, RelativeSource={RelativeSource AncestorType=Page, Mode=FindAncestor}}"
|
||||||
Click="MenuItem_RemoveLowText_Click"
|
CommandParameter="{Binding DataContext, RelativeSource={RelativeSource AncestorType=DataGridRow, Mode=FindAncestor}}"
|
||||||
Header="删除低状态文本"
|
Header="删除低状态文本" />
|
||||||
Tag="{Binding Tag, RelativeSource={RelativeSource AncestorType=DataGridRow, Mode=FindAncestor}}" />
|
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
@ -35,7 +36,7 @@
|
|||||||
<TextBox
|
<TextBox
|
||||||
x:Name="TextBox_SearchFood"
|
x:Name="TextBox_SearchFood"
|
||||||
pu:TextBoxHelper.Watermark="搜索文本"
|
pu:TextBoxHelper.Watermark="搜索文本"
|
||||||
TextChanged="TextBox_SearchFood_TextChanged" />
|
Text="{Binding FilterLowText.Value, UpdateSourceTrigger=PropertyChanged}" />
|
||||||
<DataGrid
|
<DataGrid
|
||||||
x:Name="DataGrid_LowText"
|
x:Name="DataGrid_LowText"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
@ -44,6 +45,7 @@
|
|||||||
AutoGenerateColumns="False"
|
AutoGenerateColumns="False"
|
||||||
CanUserAddRows="False"
|
CanUserAddRows="False"
|
||||||
GridLinesVisibility="Horizontal"
|
GridLinesVisibility="Horizontal"
|
||||||
|
ItemsSource="{Binding ShowLowTexts.Value}"
|
||||||
MouseDoubleClick="DataGrid_Food_MouseDoubleClick"
|
MouseDoubleClick="DataGrid_Food_MouseDoubleClick"
|
||||||
RowDetailsVisibilityMode="Visible"
|
RowDetailsVisibilityMode="Visible"
|
||||||
RowHeight="64"
|
RowHeight="64"
|
||||||
@ -58,7 +60,7 @@
|
|||||||
</DataGrid.RowStyle>
|
</DataGrid.RowStyle>
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn
|
<DataGridTextColumn
|
||||||
Binding="{Binding Text}"
|
Binding="{Binding CurrentI18nData.Value.Text.Value}"
|
||||||
CanUserSort="True"
|
CanUserSort="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
SortMemberPath="Name">
|
SortMemberPath="Name">
|
||||||
@ -67,7 +69,7 @@
|
|||||||
</DataGridTextColumn.Header>
|
</DataGridTextColumn.Header>
|
||||||
</DataGridTextColumn>
|
</DataGridTextColumn>
|
||||||
<DataGridTextColumn
|
<DataGridTextColumn
|
||||||
Binding="{Binding Mode}"
|
Binding="{Binding Mode.Value}"
|
||||||
CanUserSort="True"
|
CanUserSort="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
SortMemberPath="Type">
|
SortMemberPath="Type">
|
||||||
@ -76,7 +78,7 @@
|
|||||||
</DataGridTextColumn.Header>
|
</DataGridTextColumn.Header>
|
||||||
</DataGridTextColumn>
|
</DataGridTextColumn>
|
||||||
<DataGridTextColumn
|
<DataGridTextColumn
|
||||||
Binding="{Binding Strength}"
|
Binding="{Binding Strength.Value}"
|
||||||
CanUserSort="True"
|
CanUserSort="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
SortMemberPath="StrengthFood">
|
SortMemberPath="StrengthFood">
|
||||||
@ -85,7 +87,7 @@
|
|||||||
</DataGridTextColumn.Header>
|
</DataGridTextColumn.Header>
|
||||||
</DataGridTextColumn>
|
</DataGridTextColumn>
|
||||||
<DataGridTextColumn
|
<DataGridTextColumn
|
||||||
Binding="{Binding Like}"
|
Binding="{Binding Like.Value}"
|
||||||
CanUserSort="True"
|
CanUserSort="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
SortMemberPath="StrengthDrink">
|
SortMemberPath="StrengthDrink">
|
||||||
@ -100,7 +102,7 @@
|
|||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
VerticalAlignment="Bottom"
|
VerticalAlignment="Bottom"
|
||||||
Click="Button_AddLowText_Click"
|
Command="{Binding AddLowTextCommand}"
|
||||||
Content="➕"
|
Content="➕"
|
||||||
Style="{StaticResource AddButton}" />
|
Style="{StaticResource AddButton}" />
|
||||||
</Grid>
|
</Grid>
|
@ -0,0 +1,97 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using VPet.Plugin.ModMaker.Models;
|
||||||
|
using VPet.Plugin.ModMaker.ViewModels.ModEdit.LowTextEdit;
|
||||||
|
using VPet_Simulator.Windows.Interface;
|
||||||
|
|
||||||
|
namespace VPet.Plugin.ModMaker.Views.ModEdit.LowTextEdit;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Page_LowText.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
public partial class LowTextPage : Page
|
||||||
|
{
|
||||||
|
public LowTextPageVM ViewModel => (LowTextPageVM)DataContext;
|
||||||
|
|
||||||
|
public LowTextPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
DataContext = new LowTextPageVM();
|
||||||
|
}
|
||||||
|
|
||||||
|
//private void Button_AddLowText_Click(object sender, RoutedEventArgs e)
|
||||||
|
//{
|
||||||
|
// var window = new LowTextEditWindow();
|
||||||
|
// window.Closed += (s, e) =>
|
||||||
|
// {
|
||||||
|
// if (s is not LowTextEditWindow addLowTextWindow || addLowTextWindow.IsCancel)
|
||||||
|
// return;
|
||||||
|
// var lowText = CreateLowTextFromWindow(addLowTextWindow);
|
||||||
|
// if (LowTextDict.TryGetValue(lowText.Text, out var oldText))
|
||||||
|
// {
|
||||||
|
// LowTextDict[lowText.Text] = LowTexts[LowTexts.IndexOf(oldText)] = lowText;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// LowTexts.Add(lowText);
|
||||||
|
// LowTextDict.Add(lowText.Text, lowText);
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
// ShowDialogX(window);
|
||||||
|
//}
|
||||||
|
|
||||||
|
private void DataGrid_Food_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is not DataGrid dataGrid || dataGrid.SelectedItem is not LowTextModel lowText)
|
||||||
|
return;
|
||||||
|
ViewModel.EditLowText(lowText);
|
||||||
|
}
|
||||||
|
|
||||||
|
//private void TextBox_SearchFood_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
|
//{
|
||||||
|
// if (sender is not TextBox textBox)
|
||||||
|
// return;
|
||||||
|
// if (textBox.Text.Length > 0)
|
||||||
|
// {
|
||||||
|
// var newList = new ObservableCollection<LowText>(
|
||||||
|
// LowTexts.Where(i => i.Text.Contains(textBox.Text))
|
||||||
|
// );
|
||||||
|
// if (newList.Count != LowTexts.Count)
|
||||||
|
// DataGrid_LowText.ItemsSource = newList;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// DataGrid_LowText.ItemsSource = LowTexts;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//private void MenuItem_ChangeLowText_Click(object sender, RoutedEventArgs e)
|
||||||
|
//{
|
||||||
|
// if (sender is not MenuItem menuItem || menuItem.Tag is not LowText lowText)
|
||||||
|
// return;
|
||||||
|
// ChangeLowText(lowText);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//private void MenuItem_RemoveLowText_Click(object sender, RoutedEventArgs e)
|
||||||
|
//{
|
||||||
|
// if (sender is not MenuItem menuItem || menuItem.Tag is not LowText lowText)
|
||||||
|
// return;
|
||||||
|
// if (DataGrid_LowText.ItemsSource is IList list && list.Count != LowTexts.Count)
|
||||||
|
// list.Remove(lowText);
|
||||||
|
// else
|
||||||
|
// LowTexts.Remove(lowText);
|
||||||
|
// LowTextDict.Remove(lowText.Text);
|
||||||
|
//}
|
||||||
|
}
|
252
VPet.Plugin.ModMaker/Views/ModEdit/ModEditWindow.xaml
Normal file
252
VPet.Plugin.ModMaker/Views/ModEdit/ModEditWindow.xaml
Normal file
@ -0,0 +1,252 @@
|
|||||||
|
<Window
|
||||||
|
x:Class="VPet.Plugin.ModMaker.Views.ModEdit.ModEditWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:VPet.Plugin.ModMaker.Views.ModEdit"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
||||||
|
xmlns:vm="clr-namespace:VPet.Plugin.ModMaker.ViewModels.ModEdit"
|
||||||
|
Title="ModEditWindow"
|
||||||
|
Width="800"
|
||||||
|
Height="450"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
<d:Window.DataContext>
|
||||||
|
<vm:ModEditWindowVM />
|
||||||
|
</d:Window.DataContext>
|
||||||
|
<Window.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<ContextMenu x:Key="ContextMenu_Lang" x:Shared="false">
|
||||||
|
<MenuItem
|
||||||
|
Command="{Binding DataContext.ChangeLangCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"
|
||||||
|
CommandParameter="{Binding Content, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}}"
|
||||||
|
Header="修改语言" />
|
||||||
|
<MenuItem
|
||||||
|
Command="{Binding DataContext.RemoveLangCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"
|
||||||
|
CommandParameter="{Binding Content, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}}"
|
||||||
|
Header="删除语言" />
|
||||||
|
</ContextMenu>
|
||||||
|
</ResourceDictionary>
|
||||||
|
</Window.Resources>
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.Style>
|
||||||
|
<Style TargetType="Grid">
|
||||||
|
<Setter Property="IsEnabled" Value="True" />
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding SelectedItem, ElementName=ListBox_Langs}" Value="{x:Null}">
|
||||||
|
<Setter Property="IsEnabled" Value="False" />
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Grid.Style>
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Image
|
||||||
|
x:Name="Image_ModImage"
|
||||||
|
Width="256"
|
||||||
|
Height="256"
|
||||||
|
Source="{Binding ModInfo.Value.ModImage.Value}"
|
||||||
|
Stretch="Uniform">
|
||||||
|
<Image.ContextMenu>
|
||||||
|
<ContextMenu>
|
||||||
|
<MenuItem
|
||||||
|
x:Name="MenuItem_ChangeModImage"
|
||||||
|
Command="{Binding ChangeImageCommand}"
|
||||||
|
Header="修改图片" />
|
||||||
|
</ContextMenu>
|
||||||
|
</Image.ContextMenu>
|
||||||
|
</Image>
|
||||||
|
<Button
|
||||||
|
x:Name="Button_AddModImage"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Command="{Binding AddImageCommand}"
|
||||||
|
Content="添加图片">
|
||||||
|
<Button.Style>
|
||||||
|
<Style BasedOn="{StaticResource {x:Type Button}}" TargetType="Button">
|
||||||
|
<Setter Property="Visibility" Value="Hidden" />
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding ModInfo.Value.ModImage.Value}" Value="{x:Null}">
|
||||||
|
<Setter Property="Visibility" Value="Visible" />
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Button.Style>
|
||||||
|
</Button>
|
||||||
|
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Label Content="模组名称:" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="TextBox_ModName"
|
||||||
|
Grid.Column="1"
|
||||||
|
pu:TextBoxHelper.Watermark="模组名称"
|
||||||
|
Text="{Binding ModInfo.Value.CurrentI18nData.Value.Name.Value}" />
|
||||||
|
<Label Grid.Row="1" Content="作者:" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="TextBox_Author"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
pu:TextBoxHelper.Watermark="作者"
|
||||||
|
Text="{Binding ModInfo.Value.Author.Value}" />
|
||||||
|
<Label Grid.Row="2" Content="游戏版本:" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="TextBox_GameVersion"
|
||||||
|
Grid.Row="2"
|
||||||
|
Grid.Column="1"
|
||||||
|
pu:TextBoxHelper.Watermark="游戏版本"
|
||||||
|
Text="{Binding ModInfo.Value.GameVersion.Value}" />
|
||||||
|
<Label Grid.Row="3" Content="模组版本:" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="TextBox_ModVersion"
|
||||||
|
Grid.Row="3"
|
||||||
|
Grid.Column="1"
|
||||||
|
pu:TextBoxHelper.Watermark="模组版本"
|
||||||
|
Text="{Binding ModInfo.Value.ModVersion.Value}" />
|
||||||
|
<Label Grid.Row="4" Content="模组介绍:" />
|
||||||
|
<TextBox
|
||||||
|
x:Name="TextBox_Description"
|
||||||
|
Grid.Row="4"
|
||||||
|
Grid.Column="1"
|
||||||
|
pu:TextBoxHelper.Watermark="模组介绍"
|
||||||
|
Text="{Binding ModInfo.Value.CurrentI18nData.Value.Description.Value}" />
|
||||||
|
</Grid>
|
||||||
|
</ScrollViewer>
|
||||||
|
</Grid>
|
||||||
|
<Grid Grid.Column="1">
|
||||||
|
<TabControl>
|
||||||
|
<TabItem
|
||||||
|
x:Name="TabItem_Food"
|
||||||
|
Header="食物 (0)"
|
||||||
|
Tag="食物">
|
||||||
|
<Frame Content="{Binding ModEditWindow.FoodPage}" />
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="物品 (0)" Tag="物品">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBox x:Name="TextBox_SearchItem" />
|
||||||
|
<ListBox x:Name="ListBox_Item" />
|
||||||
|
<Button
|
||||||
|
x:Name="Button_AddItem"
|
||||||
|
Grid.Row="1"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Click="Button_AddItem_Click"
|
||||||
|
Content="➕"
|
||||||
|
Style="{StaticResource AddButton}" />
|
||||||
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="动画 (0)">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBox x:Name="TextBox_SearchAnime" />
|
||||||
|
<ListBox x:Name="ListBox_Anime" />
|
||||||
|
<Button
|
||||||
|
x:Name="Button_AddAnime"
|
||||||
|
Grid.Row="1"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Click="Button_AddAnime_Click"
|
||||||
|
Content="➕"
|
||||||
|
Style="{StaticResource AddButton}" />
|
||||||
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="语音 (0)">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBox x:Name="TextBox_SearchAudio" />
|
||||||
|
<ListBox x:Name="ListBox_Audio" />
|
||||||
|
<Button
|
||||||
|
x:Name="Button_AddAudio"
|
||||||
|
Grid.Row="1"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Click="Button_AddAudio_Click"
|
||||||
|
Content="➕"
|
||||||
|
Style="{StaticResource AddButton}" />
|
||||||
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="点击文本 (0)">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBox x:Name="TextBox_SearchClickText" />
|
||||||
|
<ListBox x:Name="ListBox_ClickText" />
|
||||||
|
<Button
|
||||||
|
x:Name="Button_AddClickText"
|
||||||
|
Grid.Row="1"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Click="Button_AddClickText_Click"
|
||||||
|
Content="➕"
|
||||||
|
Style="{StaticResource AddButton}" />
|
||||||
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem
|
||||||
|
x:Name="TabItem_LowText"
|
||||||
|
Header="低状态文本 (0)"
|
||||||
|
Tag="低状态文本">
|
||||||
|
<Frame Content="{Binding ModEditWindow.LowTextPage}" />
|
||||||
|
</TabItem>
|
||||||
|
</TabControl>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
<Grid Grid.Column="1">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Button
|
||||||
|
x:Name="Button_AddLang"
|
||||||
|
Command="{Binding AddLangCommand}"
|
||||||
|
Content="添加语言" />
|
||||||
|
<ListBox
|
||||||
|
x:Name="ListBox_Langs"
|
||||||
|
Grid.Row="1"
|
||||||
|
d:ItemsSource="{d:SampleData ItemCount=5}"
|
||||||
|
ItemsSource="{Binding I18nData.Langs}"
|
||||||
|
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||||
|
SelectedItem="{Binding I18nData.CurrentLang.Value}">
|
||||||
|
<ListBox.ItemContainerStyle>
|
||||||
|
<Style BasedOn="{StaticResource {x:Type ListBoxItem}}" TargetType="ListBoxItem">
|
||||||
|
<Setter Property="Content" Value="{Binding}" />
|
||||||
|
<Setter Property="ContextMenu" Value="{StaticResource ContextMenu_Lang}" />
|
||||||
|
</Style>
|
||||||
|
</ListBox.ItemContainerStyle>
|
||||||
|
</ListBox>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
75
VPet.Plugin.ModMaker/Views/ModEdit/ModEditWindow.xaml.cs
Normal file
75
VPet.Plugin.ModMaker/Views/ModEdit/ModEditWindow.xaml.cs
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
using Microsoft.Win32;
|
||||||
|
using Panuon.WPF;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using VPet.Plugin.ModMaker.ViewModels.ModEdit;
|
||||||
|
using VPet.Plugin.ModMaker.Views.ModEdit.FoodEdit;
|
||||||
|
using VPet.Plugin.ModMaker.Views.ModEdit.LowTextEdit;
|
||||||
|
using VPet_Simulator.Windows.Interface;
|
||||||
|
|
||||||
|
namespace VPet.Plugin.ModMaker.Views.ModEdit;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// winModInfo.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
public partial class ModEditWindow : Window
|
||||||
|
{
|
||||||
|
public ModEditWindowVM ViewModel => (ModEditWindowVM)this.DataContext;
|
||||||
|
public FoodPage FoodPage { get; } = new FoodPage();
|
||||||
|
public LowTextPage LowTextPage { get; } = new LowTextPage();
|
||||||
|
|
||||||
|
public ModEditWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
DataContext = new ModEditWindowVM(this);
|
||||||
|
Closed += Window_ModEdit_Closed;
|
||||||
|
FoodPage.ViewModel.Foods.CollectionChanged += Foods_CollectionChanged;
|
||||||
|
LowTextPage.ViewModel.LowTexts.CollectionChanged += LowTexts_CollectionChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LowTexts_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
LowTextPage.ViewModel.LowTexts.CollectionChanged += (s, e) =>
|
||||||
|
{
|
||||||
|
TabItem_LowText.Header =
|
||||||
|
$"{TabItem_LowText.Tag} ({LowTextPage.ViewModel.LowTexts.Count})";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Foods_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
FoodPage.ViewModel.Foods.CollectionChanged += (s, e) =>
|
||||||
|
{
|
||||||
|
TabItem_Food.Header = $"{TabItem_Food.Tag} ({FoodPage.ViewModel.Foods.Count})";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Window_ModEdit_Closed(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ViewModel.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Button_AddItem_Click(object sender, RoutedEventArgs e) { }
|
||||||
|
|
||||||
|
private void Button_AddAnime_Click(object sender, RoutedEventArgs e) { }
|
||||||
|
|
||||||
|
private void Button_AddAudio_Click(object sender, RoutedEventArgs e) { }
|
||||||
|
|
||||||
|
private void Button_AddClickText_Click(object sender, RoutedEventArgs e) { }
|
||||||
|
|
||||||
|
private void Button_AddLang_Click(object sender, RoutedEventArgs e) { }
|
||||||
|
}
|
@ -1,17 +1,21 @@
|
|||||||
<Window
|
<Window
|
||||||
x:Class="VPet.Plugin.ModMaker.ModMakerWindow"
|
x:Class="VPet.Plugin.ModMaker.Views.ModMakerWindow"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
|
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
|
||||||
xmlns:local="clr-namespace:VPet.Plugin.ModMaker"
|
xmlns:local="clr-namespace:VPet.Plugin.ModMaker.Views"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI"
|
xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI"
|
||||||
|
xmlns:vm="clr-namespace:VPet.Plugin.ModMaker.ViewModels"
|
||||||
Title="{ll:Str Mod制作器}"
|
Title="{ll:Str Mod制作器}"
|
||||||
Width="600"
|
Width="600"
|
||||||
Height="450"
|
Height="450"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
<d:Window.DataContext>
|
||||||
|
<vm:WindowVM_ModMaker />
|
||||||
|
</d:Window.DataContext>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition />
|
<ColumnDefinition />
|
||||||
@ -39,7 +43,7 @@
|
|||||||
<StackPanel Grid.Row="1">
|
<StackPanel Grid.Row="1">
|
||||||
<Button
|
<Button
|
||||||
x:Name="Button_CreateNewMod"
|
x:Name="Button_CreateNewMod"
|
||||||
Click="Button_CreateNewMod_Click"
|
Command="{Binding CreateNewModCommand}"
|
||||||
Content="创建新的模组" />
|
Content="创建新的模组" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
@ -12,31 +12,24 @@ using System.Windows.Input;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
using VPet.Plugin.ModMaker.ModEdit;
|
using VPet.Plugin.ModMaker.Models;
|
||||||
|
using VPet.Plugin.ModMaker.ViewModels;
|
||||||
|
using VPet.Plugin.ModMaker.Views.ModEdit;
|
||||||
|
|
||||||
namespace VPet.Plugin.ModMaker;
|
namespace VPet.Plugin.ModMaker.Views;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// winModMaker.xaml 的交互逻辑
|
/// winModMaker.xaml 的交互逻辑
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class ModMakerWindow : Window
|
public partial class ModMakerWindow : Window
|
||||||
{
|
{
|
||||||
public ModMaker ModMaker { get; set; }
|
public WindowVM_ModMaker ViewModel => (WindowVM_ModMaker)this.DataContext;
|
||||||
public Window_ModEdit ModEditWindow { get; set; }
|
public Models.ModMaker ModMaker { get; set; }
|
||||||
|
public ModEditWindow ModEditWindow { get; set; }
|
||||||
|
|
||||||
public ModMakerWindow()
|
public ModMakerWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
DataContext = new WindowVM_ModMaker(this);
|
||||||
|
|
||||||
private void Button_CreateNewMod_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
ModEditWindow = new();
|
|
||||||
ModEditWindow.Show();
|
|
||||||
this.Hide();
|
|
||||||
ModEditWindow.Closed += (s, e) =>
|
|
||||||
{
|
|
||||||
this.Close();
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user