mirror of
https://github.com/LorisYounger/VPet.ModMaker.git
synced 2024-08-30 18:22:21 +00:00
实装 Page_LowText
This commit is contained in:
parent
3898b6108c
commit
d5328cecad
@ -7,6 +7,7 @@
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/VPet-Simulator.Windows.Interface;component/ResourceStyle.xaml" />
|
||||
<ResourceDictionary Source="Styles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
|
75
VPet.Plugin.ModMaker/ModEdit/FoodEdit/Page_Food.cs
Normal file
75
VPet.Plugin.ModMaker/ModEdit/FoodEdit/Page_Food.cs
Normal file
@ -0,0 +1,75 @@
|
||||
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;
|
||||
}
|
195
VPet.Plugin.ModMaker/ModEdit/FoodEdit/Page_Food.xaml
Normal file
195
VPet.Plugin.ModMaker/ModEdit/FoodEdit/Page_Food.xaml
Normal file
@ -0,0 +1,195 @@
|
||||
<Page
|
||||
x:Class="VPet.Plugin.ModMaker.ModEdit.FoodEdit.Page_Food"
|
||||
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="Page_Food"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
<Page.Resources>
|
||||
<ResourceDictionary>
|
||||
<ContextMenu x:Key="ContextMenu_DataGridRow">
|
||||
<MenuItem
|
||||
x:Name="MenuItem_ChangeFood"
|
||||
Click="MenuItem_ChangeFood_Click"
|
||||
Header="修改食物"
|
||||
Tag="{Binding Tag, RelativeSource={RelativeSource AncestorType=DataGridRow, Mode=FindAncestor}}" />
|
||||
<MenuItem
|
||||
x:Name="MenuItem_RemoveFood"
|
||||
Click="MenuItem_RemoveFood_Click"
|
||||
Header="删除食物"
|
||||
Tag="{Binding Tag, RelativeSource={RelativeSource AncestorType=DataGridRow, Mode=FindAncestor}}" />
|
||||
</ContextMenu>
|
||||
</ResourceDictionary>
|
||||
</Page.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox
|
||||
x:Name="TextBox_SearchFood"
|
||||
pu:TextBoxHelper.Watermark="搜索食物"
|
||||
TextChanged="TextBox_SearchFood_TextChanged" />
|
||||
<DataGrid
|
||||
x:Name="DataGrid_Food"
|
||||
Grid.Row="1"
|
||||
d:ItemsSource="{d:SampleData ItemCount=5}"
|
||||
pu:DataGridHelper.ColumnHeaderHorizontalContentAlignment="Center"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserAddRows="False"
|
||||
GridLinesVisibility="Horizontal"
|
||||
MouseDoubleClick="DataGrid_Food_MouseDoubleClick"
|
||||
RowDetailsVisibilityMode="Visible"
|
||||
RowHeight="64"
|
||||
VirtualizingStackPanel.IsVirtualizing="True"
|
||||
VirtualizingStackPanel.VirtualizationMode="Recycling">
|
||||
<DataGrid.RowStyle>
|
||||
<Style BasedOn="{StaticResource {x:Type DataGridRow}}" TargetType="DataGridRow">
|
||||
<Setter Property="Height" Value="64" />
|
||||
<Setter Property="Tag" Value="{Binding}" />
|
||||
<Setter Property="ContextMenu" Value="{StaticResource ContextMenu_DataGridRow}" />
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Name}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Name">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="食物名称" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTemplateColumn IsReadOnly="True">
|
||||
<DataGridTemplateColumn.Header>
|
||||
<Label Content="食物图片" />
|
||||
</DataGridTemplateColumn.Header>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Image
|
||||
Width="64"
|
||||
Height="64"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Source="{Binding ImageSource, IsAsync=True}"
|
||||
Stretch="Uniform">
|
||||
<Image.ToolTip>
|
||||
<Image
|
||||
Width="256"
|
||||
Height="256"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Source="{Binding ImageSource, IsAsync=True}"
|
||||
Stretch="Uniform" />
|
||||
</Image.ToolTip>
|
||||
</Image>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Type}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Type">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="食物类型" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding StrengthFood}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="StrengthFood">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="饱腹值" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding StrengthDrink}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="StrengthDrink">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="口渴值" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Health}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Health">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="健康值" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Strength}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Strength">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="体力值" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Feeling}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Feeling">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="心情值" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Likability}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Likability">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="好感值" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Exp}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Exp">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="经验值" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Price}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Price">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="价格" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Desc}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Desc">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="描述" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<Button
|
||||
x:Name="Button_AddFood"
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Click="Button_AddFood_Click"
|
||||
Content="➕"
|
||||
Style="{StaticResource AddButton}" />
|
||||
</Grid>
|
||||
</Page>
|
98
VPet.Plugin.ModMaker/ModEdit/FoodEdit/Page_Food.xaml.cs
Normal file
98
VPet.Plugin.ModMaker/ModEdit/FoodEdit/Page_Food.xaml.cs
Normal file
@ -0,0 +1,98 @@
|
||||
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,9 +1,9 @@
|
||||
<Window
|
||||
x:Class="VPet.Plugin.ModMaker.WinModEdit.AddFoodWindow"
|
||||
x:Class="VPet.Plugin.ModMaker.ModEdit.FoodEdit.Window_AddFood"
|
||||
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.WinModEdit"
|
||||
xmlns:local="clr-namespace:VPet.Plugin.ModMaker.ModEdit.FoodEdit"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
||||
Title="AddFoodWindow"
|
||||
@ -106,52 +106,42 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Label Content="饱腹值:" />
|
||||
<TextBox
|
||||
x:Name="TextBox_StrengthFood"
|
||||
Grid.Column="1"
|
||||
pu:TextBoxHelper.Watermark="饱腹值" />
|
||||
<pu:NumberInput x:Name="NumberInput_StrengthFood" Grid.Column="1" />
|
||||
<Label Grid.Row="2" Content="口渴值:" />
|
||||
<TextBox
|
||||
x:Name="TextBox_StrengthDrink"
|
||||
<pu:NumberInput
|
||||
x:Name="NumberInput_StrengthDrink"
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
pu:TextBoxHelper.Watermark="口渴值" />
|
||||
Grid.Column="1" />
|
||||
<Label Grid.Row="3" Content="健康值:" />
|
||||
<TextBox
|
||||
x:Name="TextBox_Health"
|
||||
<pu:NumberInput
|
||||
x:Name="NumberInput_Health"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
pu:TextBoxHelper.Watermark="健康值" />
|
||||
Grid.Column="1" />
|
||||
<Label Grid.Row="4" Content="体力值:" />
|
||||
<TextBox
|
||||
x:Name="TextBox_Strength"
|
||||
<pu:NumberInput
|
||||
x:Name="NumberInput_Strength"
|
||||
Grid.Row="4"
|
||||
Grid.Column="1"
|
||||
pu:TextBoxHelper.Watermark="体力值" />
|
||||
Grid.Column="1" />
|
||||
<Label Grid.Row="5" Content="心情值:" />
|
||||
<TextBox
|
||||
x:Name="TextBox_Feeling"
|
||||
<pu:NumberInput
|
||||
x:Name="NumberInput_Feeling"
|
||||
Grid.Row="5"
|
||||
Grid.Column="1"
|
||||
pu:TextBoxHelper.Watermark="心情值" />
|
||||
Grid.Column="1" />
|
||||
<Label Grid.Row="6" Content="好感值:" />
|
||||
<TextBox
|
||||
x:Name="TextBox_Likability"
|
||||
<pu:NumberInput
|
||||
x:Name="NumberInput_Likability"
|
||||
Grid.Row="6"
|
||||
Grid.Column="1"
|
||||
pu:TextBoxHelper.Watermark="好感值" />
|
||||
Grid.Column="1" />
|
||||
<Label Grid.Row="7" Content="经验值:" />
|
||||
<TextBox
|
||||
x:Name="TextBox_Exp"
|
||||
<pu:NumberInput
|
||||
x:Name="NumberInput_Exp"
|
||||
Grid.Row="7"
|
||||
Grid.Column="1"
|
||||
pu:TextBoxHelper.Watermark="经验值" />
|
||||
Grid.Column="1" />
|
||||
<Label Grid.Row="8" Content="价格:" />
|
||||
<TextBox
|
||||
x:Name="TextBox_Price"
|
||||
<pu:NumberInput
|
||||
x:Name="NumberInput_Price"
|
||||
Grid.Row="8"
|
||||
Grid.Column="1"
|
||||
pu:TextBoxHelper.Watermark="价格" />
|
||||
Grid.Column="1" />
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
<Grid Grid.Row="2">
|
@ -12,20 +12,26 @@ 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.WinModEdit;
|
||||
namespace VPet.Plugin.ModMaker.ModEdit.FoodEdit;
|
||||
|
||||
/// <summary>
|
||||
/// AddFoodWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AddFoodWindow : Window
|
||||
public partial class Window_AddFood : Window
|
||||
{
|
||||
public bool IsCancel { get; internal set; } = true;
|
||||
public BitmapImage FoodImage { get; internal set; }
|
||||
|
||||
public AddFoodWindow()
|
||||
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)
|
||||
@ -34,9 +40,7 @@ public partial class AddFoodWindow : Window
|
||||
new() { Title = "选择图片", Filter = $"图片|*.jpg;*.jpeg;*.png;*.bmp" };
|
||||
if (openFileDialog.ShowDialog() is true)
|
||||
{
|
||||
Image_FoodImage.Source = FoodImage = Utils.LoadImageToMemoryStream(
|
||||
openFileDialog.FileName
|
||||
);
|
||||
Image_FoodImage.Source = Utils.LoadImageToStream(openFileDialog.FileName);
|
||||
Button_AddFoodImage.Visibility = Visibility.Hidden;
|
||||
}
|
||||
}
|
||||
@ -47,17 +51,14 @@ public partial class AddFoodWindow : Window
|
||||
new() { Title = "选择图片", Filter = $"图片|*.jpg;*.jpeg;*.png;*.bmp" };
|
||||
if (openFileDialog.ShowDialog() is true)
|
||||
{
|
||||
if (Image_FoodImage.Source is BitmapImage bitmapImage)
|
||||
bitmapImage.StreamSource.Close();
|
||||
Image_FoodImage.Source = FoodImage = Utils.LoadImageToMemoryStream(
|
||||
openFileDialog.FileName
|
||||
);
|
||||
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)
|
||||
{
|
||||
FoodImage?.StreamSource.Close();
|
||||
Close();
|
||||
}
|
||||
|
68
VPet.Plugin.ModMaker/ModEdit/LowTextEdit/Page_LowText.cs
Normal file
68
VPet.Plugin.ModMaker/ModEdit/LowTextEdit/Page_LowText.cs
Normal file
@ -0,0 +1,68 @@
|
||||
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;
|
||||
}
|
107
VPet.Plugin.ModMaker/ModEdit/LowTextEdit/Page_LowText.xaml
Normal file
107
VPet.Plugin.ModMaker/ModEdit/LowTextEdit/Page_LowText.xaml
Normal file
@ -0,0 +1,107 @@
|
||||
<Page
|
||||
x:Class="VPet.Plugin.ModMaker.ModEdit.LowTextEdit.Page_LowText"
|
||||
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.LowTextEdit"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
||||
Title="Page_LowText"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Page.Resources>
|
||||
<ResourceDictionary>
|
||||
<ContextMenu x:Key="ContextMenu_DataGridRow">
|
||||
<MenuItem
|
||||
x:Name="MenuItem_ChangeLowText"
|
||||
Click="MenuItem_ChangeLowText_Click"
|
||||
Header="修改低状态文本"
|
||||
Tag="{Binding Tag, RelativeSource={RelativeSource AncestorType=DataGridRow, Mode=FindAncestor}}" />
|
||||
<MenuItem
|
||||
x:Name="MenuItem_RemoveLowText"
|
||||
Click="MenuItem_RemoveLowText_Click"
|
||||
Header="删除低状态文本"
|
||||
Tag="{Binding Tag, RelativeSource={RelativeSource AncestorType=DataGridRow, Mode=FindAncestor}}" />
|
||||
</ContextMenu>
|
||||
</ResourceDictionary>
|
||||
</Page.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox
|
||||
x:Name="TextBox_SearchFood"
|
||||
pu:TextBoxHelper.Watermark="搜索文本"
|
||||
TextChanged="TextBox_SearchFood_TextChanged" />
|
||||
<DataGrid
|
||||
x:Name="DataGrid_LowText"
|
||||
Grid.Row="1"
|
||||
d:ItemsSource="{d:SampleData ItemCount=5}"
|
||||
pu:DataGridHelper.ColumnHeaderHorizontalContentAlignment="Center"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserAddRows="False"
|
||||
GridLinesVisibility="Horizontal"
|
||||
MouseDoubleClick="DataGrid_Food_MouseDoubleClick"
|
||||
RowDetailsVisibilityMode="Visible"
|
||||
RowHeight="64"
|
||||
VirtualizingStackPanel.IsVirtualizing="True"
|
||||
VirtualizingStackPanel.VirtualizationMode="Recycling">
|
||||
<DataGrid.RowStyle>
|
||||
<Style BasedOn="{StaticResource {x:Type DataGridRow}}" TargetType="DataGridRow">
|
||||
<Setter Property="Height" Value="64" />
|
||||
<Setter Property="Tag" Value="{Binding}" />
|
||||
<Setter Property="ContextMenu" Value="{StaticResource ContextMenu_DataGridRow}" />
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Text}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Name">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="文本" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Mode}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Type">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="状态" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Strength}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="StrengthFood">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="口渴/饥饿需求" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Like}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="StrengthDrink">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="好感需求" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<Button
|
||||
x:Name="Button_AddLowText"
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Click="Button_AddLowText_Click"
|
||||
Content="➕"
|
||||
Style="{StaticResource AddButton}" />
|
||||
</Grid>
|
||||
</Page>
|
@ -0,0 +1,98 @@
|
||||
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);
|
||||
}
|
||||
}
|
107
VPet.Plugin.ModMaker/ModEdit/LowTextEdit/Window_AddLowText.xaml
Normal file
107
VPet.Plugin.ModMaker/ModEdit/LowTextEdit/Window_AddLowText.xaml
Normal file
@ -0,0 +1,107 @@
|
||||
<Window
|
||||
x:Class="VPet.Plugin.ModMaker.ModEdit.LowTextEdit.Window_AddLowText"
|
||||
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.LowTextEdit"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
||||
Title="Page_LowText"
|
||||
Width="800"
|
||||
Height="450"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<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
|
||||
x:Name="TextBox_Text"
|
||||
Grid.Row="1"
|
||||
VerticalContentAlignment="Top"
|
||||
d:Text="这是一个测试文本,这是一个测试文本,这是一个测试文本,这是一个测试文本,这是一个测试文本,这是一个测试文本,这是一个测试文本,"
|
||||
pu:TextBoxHelper.Watermark="文本"
|
||||
TextWrapping="Wrap" />
|
||||
</Grid>
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Label Content="状态" />
|
||||
<ComboBox
|
||||
x:Name="ComboBox_ModeType"
|
||||
Grid.Column="1"
|
||||
SelectedIndex="0">
|
||||
<ComboBoxItem Content="普通" Tag="H" />
|
||||
<ComboBoxItem Content="生病" Tag="L" />
|
||||
</ComboBox>
|
||||
<Label Grid.Row="1" Content="口渴/饥饿状态" />
|
||||
<ComboBox
|
||||
x:Name="ComboBox_StrengthType"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
SelectedIndex="0">
|
||||
<ComboBoxItem Content="一般口渴/饥饿" Tag="L" />
|
||||
<ComboBoxItem Content="有点口渴/饥饿" Tag="M" />
|
||||
<ComboBoxItem Content="非常口渴/饥饿" Tag="S" />
|
||||
</ComboBox>
|
||||
<Label Grid.Row="2" Content="好感度需求" />
|
||||
<ComboBox
|
||||
x:Name="ComboBox_LikeType"
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
SelectedIndex="0">
|
||||
<ComboBoxItem Content="无" Tag="N" />
|
||||
<ComboBoxItem Content="低" Tag="S" />
|
||||
<ComboBoxItem Content="中" Tag="M" />
|
||||
<ComboBoxItem Content="高" Tag="L" />
|
||||
</ComboBox>
|
||||
</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>
|
||||
</Grid>
|
||||
</Window>
|
@ -0,0 +1,40 @@
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace VPet.Plugin.ModMaker.ModEdit.LowTextEdit;
|
||||
|
||||
/// <summary>
|
||||
/// Window_AddLowText.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class Window_AddLowText : Window
|
||||
{
|
||||
public bool IsCancel { get; internal set; } = true;
|
||||
|
||||
public Window_AddLowText()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Button_Cancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Button_Yes_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
IsCancel = false;
|
||||
Close();
|
||||
}
|
||||
}
|
11
VPet.Plugin.ModMaker/ModEdit/Window_ModEdit.cs
Normal file
11
VPet.Plugin.ModMaker/ModEdit/Window_ModEdit.cs
Normal file
@ -0,0 +1,11 @@
|
||||
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 { }
|
188
VPet.Plugin.ModMaker/ModEdit/Window_ModEdit.xaml
Normal file
188
VPet.Plugin.ModMaker/ModEdit/Window_ModEdit.xaml
Normal file
@ -0,0 +1,188 @@
|
||||
<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>
|
97
VPet.Plugin.ModMaker/ModEdit/Window_ModEdit.xaml.cs
Normal file
97
VPet.Plugin.ModMaker/ModEdit/Window_ModEdit.xaml.cs
Normal file
@ -0,0 +1,97 @@
|
||||
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) { }
|
||||
}
|
@ -12,7 +12,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using VPet.Plugin.ModMaker.WinModEdit;
|
||||
using VPet.Plugin.ModMaker.ModEdit;
|
||||
|
||||
namespace VPet.Plugin.ModMaker;
|
||||
|
||||
@ -22,7 +22,7 @@ namespace VPet.Plugin.ModMaker;
|
||||
public partial class ModMakerWindow : Window
|
||||
{
|
||||
public ModMaker ModMaker { get; set; }
|
||||
public ModEditWindow WinModEdit { get; set; }
|
||||
public Window_ModEdit ModEditWindow { get; set; }
|
||||
|
||||
public ModMakerWindow()
|
||||
{
|
||||
@ -31,10 +31,10 @@ public partial class ModMakerWindow : Window
|
||||
|
||||
private void Button_CreateNewMod_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
WinModEdit = new();
|
||||
WinModEdit.Show();
|
||||
ModEditWindow = new();
|
||||
ModEditWindow.Show();
|
||||
this.Hide();
|
||||
WinModEdit.Closed += (s, e) =>
|
||||
ModEditWindow.Closed += (s, e) =>
|
||||
{
|
||||
this.Close();
|
||||
};
|
||||
|
16
VPet.Plugin.ModMaker/Styles.xaml
Normal file
16
VPet.Plugin.ModMaker/Styles.xaml
Normal file
@ -0,0 +1,16 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:pu="https://opensource.panuon.com/wpf-ui">
|
||||
<Style
|
||||
x:Key="AddButton"
|
||||
BasedOn="{StaticResource {x:Type Button}}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Background" Value="{StaticResource DARKPrimary}" />
|
||||
<Setter Property="pu:ButtonHelper.ShadowColor" Value="{StaticResource ShadowColor}" />
|
||||
<Setter Property="FontSize" Value="24" />
|
||||
<Setter Property="Padding" Value="10" />
|
||||
<Setter Property="Margin" Value="10" />
|
||||
<Setter Property="pu:ButtonHelper.CornerRadius" Value="24" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
@ -4,12 +4,22 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace VPet.Plugin.ModMaker;
|
||||
|
||||
internal static class Utils
|
||||
{
|
||||
public static BitmapImage LoadImageToStream(string imagePath)
|
||||
{
|
||||
BitmapImage bitmapImage = new();
|
||||
bitmapImage.BeginInit();
|
||||
bitmapImage.StreamSource = new StreamReader(imagePath).BaseStream;
|
||||
bitmapImage.EndInit();
|
||||
return bitmapImage;
|
||||
}
|
||||
|
||||
public static BitmapImage LoadImageToMemoryStream(string imagePath)
|
||||
{
|
||||
BitmapImage bitmapImage = new();
|
||||
@ -22,4 +32,17 @@ internal static class Utils
|
||||
bitmapImage.EndInit();
|
||||
return bitmapImage;
|
||||
}
|
||||
|
||||
public static void ShowDialogX(this Window window, Window owner)
|
||||
{
|
||||
owner.IsEnabled = false;
|
||||
window.Owner = owner;
|
||||
window.Closed += (s, e) =>
|
||||
{
|
||||
owner.IsEnabled = true;
|
||||
};
|
||||
window.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void ShowDialogXHandler(Window window);
|
||||
|
@ -88,6 +88,17 @@
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ModEdit\FoodEdit\Page_Food.xaml.cs">
|
||||
<DependentUpon>Page_Food.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ModEdit\FoodEdit\Page_Food.cs" />
|
||||
<Compile Include="ModEdit\LowTextEdit\Page_LowText.cs" />
|
||||
<Compile Include="ModEdit\LowTextEdit\Page_LowText.xaml.cs">
|
||||
<DependentUpon>Page_LowText.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ModEdit\LowTextEdit\Window_AddLowText.xaml.cs">
|
||||
<DependentUpon>Window_AddLowText.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ModInfo.cs" />
|
||||
<Compile Include="ModMaker.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
@ -104,12 +115,12 @@
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="Utils.cs" />
|
||||
<Compile Include="WinModEdit\AddFoodWindow.xaml.cs">
|
||||
<DependentUpon>AddFoodWindow.xaml</DependentUpon>
|
||||
<Compile Include="ModEdit\FoodEdit\Window_AddFood.xaml.cs">
|
||||
<DependentUpon>Window_AddFood.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WinModEdit\ModEditWindow.cs" />
|
||||
<Compile Include="WinModEdit\ModEditWindow.xaml.cs">
|
||||
<DependentUpon>ModEditWindow.xaml</DependentUpon>
|
||||
<Compile Include="ModEdit\Window_ModEdit.cs" />
|
||||
<Compile Include="ModEdit\Window_ModEdit.xaml.cs">
|
||||
<DependentUpon>Window_ModEdit.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ModMakerWindow.xaml.cs">
|
||||
<DependentUpon>ModMakerWindow.xaml</DependentUpon>
|
||||
@ -129,11 +140,23 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="WinModEdit\AddFoodWindow.xaml">
|
||||
<Page Include="ModEdit\FoodEdit\Page_Food.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="WinModEdit\ModEditWindow.xaml">
|
||||
<Page Include="ModEdit\FoodEdit\Window_AddFood.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="ModEdit\LowTextEdit\Page_LowText.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="ModEdit\LowTextEdit\Window_AddLowText.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="ModEdit\Window_ModEdit.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
@ -141,6 +164,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Styles.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.6.2">
|
||||
|
@ -1,35 +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.WinModEdit;
|
||||
|
||||
public partial class ModEditWindow
|
||||
{
|
||||
public static Food CreateFoodFormWindow(AddFoodWindow 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.Parse(addFoodWindow.TextBox_Strength.Text),
|
||||
StrengthFood = double.Parse(addFoodWindow.TextBox_StrengthFood.Text),
|
||||
StrengthDrink = double.Parse(addFoodWindow.TextBox_StrengthDrink.Text),
|
||||
Health = double.Parse(addFoodWindow.TextBox_Health.Text),
|
||||
Feeling = double.Parse(addFoodWindow.TextBox_Feeling.Text),
|
||||
Likability = double.Parse(addFoodWindow.TextBox_Likability.Text),
|
||||
Price = double.Parse(addFoodWindow.TextBox_Price.Text),
|
||||
Exp = int.Parse(addFoodWindow.TextBox_Exp.Text),
|
||||
};
|
||||
}
|
||||
}
|
@ -1,374 +0,0 @@
|
||||
<Window
|
||||
x:Class="VPet.Plugin.ModMaker.WinModEdit.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"
|
||||
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>
|
||||
<Style
|
||||
x:Key="AddButton"
|
||||
BasedOn="{StaticResource {x:Type Button}}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Background" Value="{StaticResource DARKPrimary}" />
|
||||
<Setter Property="pu:ButtonHelper.ShadowColor" Value="{StaticResource ShadowColor}" />
|
||||
<Setter Property="FontSize" Value="24" />
|
||||
<Setter Property="Padding" Value="10" />
|
||||
<Setter Property="Margin" Value="10" />
|
||||
<Setter Property="pu:ButtonHelper.CornerRadius" Value="24" />
|
||||
</Style>
|
||||
<ContextMenu x:Key="ContextMenu_DataGridRow">
|
||||
<MenuItem x:Name="MenuItem_RemoveFood" Click="MenuItem_RemoveFood_Click" />
|
||||
</ContextMenu>
|
||||
</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 Header="食物 (0)">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox x:Name="TextBox_SearchFood" />
|
||||
<DataGrid
|
||||
x:Name="DataGrid_Food"
|
||||
Grid.Row="1"
|
||||
d:ItemsSource="{d:SampleData ItemCount=5}"
|
||||
pu:DataGridHelper.ColumnHeaderHorizontalContentAlignment="Center"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserAddRows="False"
|
||||
GridLinesVisibility="Horizontal"
|
||||
MouseDoubleClick="DataGrid_Food_MouseDoubleClick"
|
||||
RowDetailsVisibilityMode="Visible"
|
||||
RowHeight="64"
|
||||
VirtualizingStackPanel.IsVirtualizing="True"
|
||||
VirtualizingStackPanel.VirtualizationMode="Recycling">
|
||||
<DataGrid.RowStyle>
|
||||
<Style BasedOn="{StaticResource {x:Type DataGridRow}}" TargetType="DataGridRow">
|
||||
<Setter Property="Height" Value="64" />
|
||||
<Setter Property="Tag" Value="{Binding}" />
|
||||
<Setter Property="ContextMenu" Value="{StaticResource ContextMenu_DataGridRow}" />
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Name}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Name">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="食物名称" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTemplateColumn IsReadOnly="True">
|
||||
<DataGridTemplateColumn.Header>
|
||||
<Label Content="食物图片" />
|
||||
</DataGridTemplateColumn.Header>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Image
|
||||
Width="64"
|
||||
Height="64"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Source="{Binding ImageSource, IsAsync=True}"
|
||||
Stretch="Uniform">
|
||||
<Image.ToolTip>
|
||||
<Image
|
||||
Width="256"
|
||||
Height="256"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Source="{Binding ImageSource, IsAsync=True}"
|
||||
Stretch="Uniform" />
|
||||
</Image.ToolTip>
|
||||
</Image>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Type}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Type">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="食物类型" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding StrengthFood}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="StrengthFood">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="饱腹值" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding StrengthDrink}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="StrengthDrink">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="口渴值" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Health}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Health">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="健康值" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Strength}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Strength">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="体力值" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Feeling}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Feeling">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="心情值" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Likability}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Likability">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="好感值" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Exp}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Exp">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="经验值" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Price}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Price">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="价格" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Desc}"
|
||||
CanUserSort="True"
|
||||
IsReadOnly="True"
|
||||
SortMemberPath="Desc">
|
||||
<DataGridTextColumn.Header>
|
||||
<Label Content="描述" />
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<Button
|
||||
x:Name="Button_AddFood"
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Click="Button_AddFood_Click"
|
||||
Content="➕"
|
||||
Style="{StaticResource AddButton}" />
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="物品 (0)">
|
||||
<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 Header="低状态文本 (0)">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox x:Name="TextBox_SearchLowText" />
|
||||
<ListBox x:Name="ListBox_LowText" />
|
||||
<Button
|
||||
x:Name="Button_AddLowText"
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Click="Button_AddLowText_Click"
|
||||
Content="➕"
|
||||
Style="{StaticResource AddButton}" />
|
||||
</Grid>
|
||||
</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,147 +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_Simulator.Windows.Interface;
|
||||
|
||||
namespace VPet.Plugin.ModMaker.WinModEdit;
|
||||
|
||||
/// <summary>
|
||||
/// winModInfo.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ModEditWindow : Window
|
||||
{
|
||||
public string ModName { get; set; } = string.Empty;
|
||||
public ObservableCollection<Food> Foods { get; set; } = new();
|
||||
|
||||
public Dictionary<string, Food> FoodDict { get; set; } = new();
|
||||
|
||||
public ModEditWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataGrid_Food.ItemsSource = Foods;
|
||||
Closed += WinModInfo_Closed;
|
||||
}
|
||||
|
||||
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_AddFood_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.IsEnabled = false;
|
||||
var window = new AddFoodWindow();
|
||||
window.Closed += (s, e) =>
|
||||
{
|
||||
if (s is not AddFoodWindow addFoodWindow)
|
||||
return;
|
||||
if (addFoodWindow.IsCancel)
|
||||
{
|
||||
this.IsEnabled = true;
|
||||
return;
|
||||
}
|
||||
var food = CreateFoodFormWindow(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);
|
||||
}
|
||||
this.IsEnabled = true;
|
||||
};
|
||||
window.Show();
|
||||
}
|
||||
|
||||
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_AddLowText_Click(object sender, RoutedEventArgs e) { }
|
||||
|
||||
private void DataGrid_Food_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (sender is not DataGrid dataGrid || dataGrid.SelectedItem is not Food oldFood)
|
||||
return;
|
||||
this.IsEnabled = false;
|
||||
var window = new AddFoodWindow();
|
||||
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.TextBox_Strength.Text = oldFood.Strength.ToString();
|
||||
window.TextBox_StrengthFood.Text = oldFood.StrengthFood.ToString();
|
||||
window.TextBox_StrengthDrink.Text = oldFood.StrengthDrink.ToString();
|
||||
window.TextBox_Health.Text = oldFood.Health.ToString();
|
||||
window.TextBox_Feeling.Text = oldFood.Feeling.ToString();
|
||||
window.TextBox_Likability.Text = oldFood.Likability.ToString();
|
||||
window.TextBox_Price.Text = oldFood.Price.ToString();
|
||||
window.TextBox_Exp.Text = oldFood.Exp.ToString();
|
||||
window.Button_AddFoodImage.Visibility = Visibility.Hidden;
|
||||
window.Closed += (s, e) =>
|
||||
{
|
||||
if (s is not AddFoodWindow addFoodWindow)
|
||||
return;
|
||||
if (addFoodWindow.IsCancel)
|
||||
{
|
||||
this.IsEnabled = true;
|
||||
return;
|
||||
}
|
||||
var food = CreateFoodFormWindow(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);
|
||||
}
|
||||
this.IsEnabled = true;
|
||||
};
|
||||
window.Show();
|
||||
}
|
||||
|
||||
private void MenuItem_RemoveFood_Click(object sender, RoutedEventArgs e) { }
|
||||
}
|
Loading…
Reference in New Issue
Block a user