**VPet.Solution:**

- 主界面布局修改, 添加`第一次启动失败`按钮

SettingEditor:
- 设置主页面修改, 添加`全部重置`按钮, 列表项右键菜单功能移至页面右侧
- 模组管理页面修复名称和描述未载入翻译的问题

SaveViewer:
- 存档列表添加`哈希`列
This commit is contained in:
Hakoyu 2024-01-25 21:56:38 +08:00
parent 440d2fdda7
commit 5c5fafee94
12 changed files with 219 additions and 106 deletions

View File

@ -8,6 +8,7 @@
<FileVersion>1.0.0.0</FileVersion>
<Product>VPet-Simulator.Tool</Product>
<Copyright>Copyright © 2022</Copyright>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">

View File

@ -7,6 +7,7 @@
<UseWPF>true</UseWPF>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>

View File

@ -107,6 +107,14 @@ public class ModLoader
ItemID = 0;
CacheDate = modlps.GetDateTime("cachedate", DateTime.MinValue);
var imagePath = Path.Combine(path, "icon.png");
//加载翻译
foreach (var line in modlps.FindAllLine("lang"))
{
var lps = new LPS();
foreach (var sub in line)
lps.Add(new Line(sub.Name, sub.Info));
LocalizeCore.AddCulture(line.Info, lps);
}
if (File.Exists(imagePath))
{
try

View File

@ -4,6 +4,7 @@ using LinePutScript.Localization.WPF;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -296,6 +297,15 @@ public class ModModel : ObservableClass<ModModel>
PropertyChanged += ModModel_PropertyChanged;
ReflectionUtils.SetValue(loader, this);
RefreshState();
Name = Name.Translate();
Description = Description.Translate();
LocalizeCore.BindingNotify.PropertyChanged += BindingNotify_PropertyChanged;
}
private void BindingNotify_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
Name = Name.Translate();
Description = Description.Translate();
}
public void RefreshState()

View File

@ -14,7 +14,6 @@
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

View File

@ -1,4 +1,7 @@
using System;
using HKW.HKWUtils.Observable;
using LinePutScript.Localization.WPF;
using Panuon.WPF.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -6,4 +9,50 @@ using System.Threading.Tasks;
namespace VPet.Solution.ViewModels;
public class MainWindowVM : ObservableClass<MainWindowVM> { }
public class MainWindowVM : ObservableClass<MainWindowVM>
{
public MainWindowVM()
{
LocalizeCore.StoreTranslation = true;
LocalizeCore.LoadDefaultCulture();
CurrentCulture = LocalizeCore.CurrentCulture;
FirstStartFailedCommand.ExecuteCommand += FirstStartFailedCommand_ExecuteCommand;
OpenLocalTextCommand.ExecuteCommand += OpenLocalTextCommand_ExecuteCommand;
}
private void OpenLocalTextCommand_ExecuteCommand()
{
var sb = new StringBuilder();
foreach (var a in LocalizeCore.StoreTranslationList)
sb.AppendLine(a.Replace("\r\n", "\\r\\n"));
MessageBoxX.Show(sb.ToString());
}
private void FirstStartFailedCommand_ExecuteCommand()
{
Utils.OpenLink(
"https://steamcommunity.com/games/1920960/announcements/detail/3681184905256253203"
);
}
#region Property
public IEnumerable<string> AvailableCultures => LocalizeCore.AvailableCultures;
#region CurrentCulture
private string _currentCulture = string.Empty;
public string CurrentCulture
{
get => _currentCulture;
set
{
SetProperty(ref _currentCulture, value);
LocalizeCore.LoadCulture(_currentCulture);
}
}
#endregion
#endregion
#region Command
public ObservableCommand FirstStartFailedCommand { get; } = new();
public ObservableCommand OpenLocalTextCommand { get; } = new();
#endregion
}

View File

@ -72,6 +72,11 @@ public class SettingWindowVM : ObservableClass<SettingWindowVM>
/// 保存全部
/// </summary>
public ObservableCommand SaveAllSettingCommand { get; } = new();
/// <summary>
/// 重置全部
/// </summary>
public ObservableCommand ResetAllSettingCommand { get; } = new();
#endregion
public SettingWindowVM()
{
@ -85,6 +90,24 @@ public class SettingWindowVM : ObservableClass<SettingWindowVM>
ResetSettingCommand.ExecuteCommand += ResetSettingCommand_ExecuteCommand;
SaveSettingCommand.ExecuteCommand += SaveSettingCommand_ExecuteCommand;
SaveAllSettingCommand.ExecuteCommand += SaveAllSettingCommand_ExecuteCommand;
ResetAllSettingCommand.ExecuteCommand += ResetAllSettingCommand_ExecuteCommand;
}
private void ResetAllSettingCommand_ExecuteCommand()
{
if (
MessageBox.Show(
SettingWindow.Instance,
"确定全部重置吗".Translate(),
"",
MessageBoxButton.YesNo,
MessageBoxImage.Warning
)
is not MessageBoxResult.Yes
)
return;
for (var i = 0; i < _settings.Count; i++)
_settings[i] = new SettingModel();
}
private void OpenFileInExplorerCommand_ExecuteCommand(SettingModel parameter)

View File

@ -18,36 +18,54 @@
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button
x:Name="Button_OpenSettingEditor"
Click="Button_OpenSettingEditor_Click"
Content="{ll:Str 打开设置编辑器}"
FontSize="16"
Style="{DynamicResource Button_BaseStyle}" />
<Button
x:Name="Button_OpenSaveViewer"
Grid.Column="1"
Click="Button_OpenSaveViewer_Click"
Content="{ll:Str 打开存档查看器}"
FontSize="16"
Style="{DynamicResource Button_BaseStyle}" />
<Button
x:Name="Button_OpenLocalText"
Grid.Column="1"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Click="Button_OpenLocalText_Click"
Content="{ll:Str 打开翻译文本}" />
<Grid.RowDefinitions>
<RowDefinition Height="Auto" MinHeight="200" />
<RowDefinition />
</Grid.RowDefinitions>
<Label
Height="Auto"
Content="{ll:Str 'VPET 问题解决工具'}"
FontSize="32"
Style="{DynamicResource Label_BaseStyle}" />
<ComboBox
x:Name="ComboBox_Langs"
Grid.Column="1"
HorizontalAlignment="Right"
VerticalAlignment="Top"
SelectionChanged="ComboBox_Langs_SelectionChanged"
Style="{DynamicResource ComboBox_BaseStyle}" />
ItemsSource="{Binding AvailableCultures}"
SelectedItem="{Binding CurrentCulture}"
Style="{DynamicResource ComboBox_BaseStyle}">
<ComboBox.ContextMenu>
<ContextMenu>
<MenuItem Command="{Binding OpenLocalTextCommand}" Header="{ll:Str 打开翻译文本}" />
</ContextMenu>
</ComboBox.ContextMenu>
</ComboBox>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel>
<Button
x:Name="Button_OpenSettingEditor"
Click="Button_OpenSettingEditor_Click"
Content="{ll:Str 打开设置编辑器}"
FontSize="16"
Style="{DynamicResource Button_BaseStyle}" />
<Button
x:Name="Button_OpenSaveViewer"
Click="Button_OpenSaveViewer_Click"
Content="{ll:Str 打开存档查看器}"
FontSize="16"
Style="{DynamicResource Button_BaseStyle}" />
</StackPanel>
<Button
Grid.Row="1"
Command="{Binding FirstStartFailedCommand}"
Content="{ll:Str '第一次启动桌宠打不开?'}"
FontSize="16"
Style="{DynamicResource LinkButtonStyle}" />
</Grid>
</Grid>
</pu:WindowX>

View File

@ -30,10 +30,6 @@ public partial class MainWindow : WindowX
}
InitializeComponent();
this.SetViewModel<MainWindowVM>();
LocalizeCore.StoreTranslation = true;
LocalizeCore.LoadDefaultCulture();
ComboBox_Langs.ItemsSource = LocalizeCore.AvailableCultures;
ComboBox_Langs.SelectedItem = LocalizeCore.CurrentCulture;
Closed += MainWindow_Closed;
}
@ -52,17 +48,4 @@ public partial class MainWindow : WindowX
{
SaveWindow.ShowOrActivate();
}
private void Button_OpenLocalText_Click(object sender, RoutedEventArgs e)
{
var sb = new StringBuilder();
foreach (var a in LocalizeCore.StoreTranslationList)
sb.AppendLine(a.Replace("\r\n", "\\r\\n"));
MessageBoxX.Show(sb.ToString());
}
private void ComboBox_Langs_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
LocalizeCore.LoadCulture((string)ComboBox_Langs.SelectedItem);
}
}

View File

@ -87,13 +87,6 @@
Style="{DynamicResource Label_BaseStyle}" />
<TextBlock Style="{DynamicResource TextBlock_LeftCenter}" Text="{Binding Save.StrengthDrink}" />
</DockPanel>
<DockPanel>
<Label
h:ElementHelper.UniformMinWidthGroup="A"
Content="{ll:Str 哈希检查}"
Style="{DynamicResource Label_BaseStyle}" />
<TextBlock Style="{DynamicResource TextBlock_LeftCenter}" Text="{Binding Save.HashChecked}" />
</DockPanel>
</StackPanel>
</ScrollViewer>
</Page>

View File

@ -77,6 +77,11 @@
ElementStyle="{DynamicResource TextBlock_LeftCenter}"
Header="{ll:Str 游玩时长}"
IsReadOnly="True" />
<DataGridTextColumn
Binding="{Binding HashChecked}"
ElementStyle="{DynamicResource TextBlock_LeftCenter}"
Header="{ll:Str 哈希}"
IsReadOnly="True" />
</DataGrid.Columns>
</DataGrid>
</Grid>

View File

@ -27,7 +27,6 @@
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBox
pu:TextBoxHelper.Watermark="{ll:Str 搜索设置}"
@ -45,63 +44,87 @@
<Setter Property="Tag" Value="{Binding DataContext, RelativeSource={RelativeSource AncestorType=Window}}" />
<Setter Property="Content" Value="{Binding Name}" />
<Setter Property="ToolTip" Value="{Binding FilePath}" />
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Mode=Self}}">
<MenuItem
Command="{Binding PlacementTarget.Tag.OpenFileCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
CommandParameter="{Binding}"
Header="{ll:Str 打开文件}" />
<MenuItem
Command="{Binding PlacementTarget.Tag.OpenFileInExplorerCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
CommandParameter="{Binding}"
Header="{ll:Str 从资源管理器打开文件}" />
<MenuItem
Command="{Binding PlacementTarget.Tag.SaveSettingCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
CommandParameter="{Binding}"
Header="{ll:Str 保存}" />
<MenuItem
Command="{Binding PlacementTarget.Tag.ResetSettingCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
CommandParameter="{Binding}"
Header="{ll:Str 重置}" />
</ContextMenu>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
<Button
Grid.Row="3"
Margin="0"
HorizontalAlignment="Stretch"
Command="{Binding SaveAllSettingCommand}"
Content="{ll:Str 全部保存}"
Style="{DynamicResource Button_BaseStyle}" />
<StackPanel Grid.Row="2">
<Button
Margin="0"
HorizontalAlignment="Stretch"
Command="{Binding ResetAllSettingCommand}"
Content="{ll:Str 全部重置}"
Style="{DynamicResource Button_BaseStyle}" />
<Button
Margin="0"
HorizontalAlignment="Stretch"
Command="{Binding SaveAllSettingCommand}"
Content="{ll:Str 全部保存}"
Style="{DynamicResource Button_BaseStyle}" />
</StackPanel>
</Grid>
<Grid Grid.Column="1" IsEnabled="{Binding SelectedItem, ElementName=ListBox_Saves, Converter={StaticResource NullToFalse}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<ListBox x:Name="ListBox_Pages" Style="{DynamicResource SideMenuListBoxStyle}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBoxItem x:Name="ListBoxItem_GraphicsSettings" Content="{ll:Str 图形}" />
<ListBoxItem x:Name="ListBoxItem_SystemSettings" Content="{ll:Str 系统}" />
<ListBoxItem x:Name="ListBoxItem_InteractiveSettings" Content="{ll:Str 互动}" />
<ListBoxItem x:Name="ListBoxItem_CustomizedSettings" Content="{ll:Str 自定}" />
<ListBoxItem x:Name="ListBoxItem_DiagnosticSettings" Content="{ll:Str 诊断}" />
<ListBoxItem x:Name="ListBoxItem_ModSettings" Content="{ll:Str Mod管理}" />
</ListBox>
<Frame
x:Name="Frame_Main"
Grid.Row="1"
Content="{Binding SelectedItem.Tag, ElementName=ListBox_Pages}"
ContentRendered="Frame_Main_ContentRendered"
NavigationUIVisibility="Hidden" />
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<ListBox x:Name="ListBox_Pages" Style="{DynamicResource SideMenuListBoxStyle}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBoxItem x:Name="ListBoxItem_GraphicsSettings" Content="{ll:Str 图形}" />
<ListBoxItem x:Name="ListBoxItem_SystemSettings" Content="{ll:Str 系统}" />
<ListBoxItem x:Name="ListBoxItem_InteractiveSettings" Content="{ll:Str 互动}" />
<ListBoxItem x:Name="ListBoxItem_CustomizedSettings" Content="{ll:Str 自定}" />
<ListBoxItem x:Name="ListBoxItem_DiagnosticSettings" Content="{ll:Str 诊断}" />
<ListBoxItem x:Name="ListBoxItem_ModSettings" Content="{ll:Str Mod管理}" />
</ListBox>
<Frame
x:Name="Frame_Main"
Grid.Row="1"
Content="{Binding SelectedItem.Tag, ElementName=ListBox_Pages}"
ContentRendered="Frame_Main_ContentRendered"
NavigationUIVisibility="Hidden" />
</Grid>
<StackPanel Grid.Column="1" MinWidth="100">
<Button
Margin="0"
HorizontalAlignment="Stretch"
Command="{Binding OpenFileCommand}"
CommandParameter="{Binding SelectedItem, ElementName=ListBox_Saves}"
Content="{ll:Str 打开文件}"
Style="{StaticResource Button_BaseStyle}" />
<Button
Grid.Column="1"
Margin="0"
HorizontalAlignment="Stretch"
Command="{Binding OpenFileInExplorerCommand}"
CommandParameter="{Binding SelectedItem, ElementName=ListBox_Saves}"
Content="{ll:Str 从资源管理器打开文件}"
Style="{StaticResource Button_BaseStyle}" />
<Button
Grid.Column="2"
Margin="0"
HorizontalAlignment="Stretch"
Command="{Binding SaveSettingCommand}"
CommandParameter="{Binding SelectedItem, ElementName=ListBox_Saves}"
Content="{ll:Str 保存}"
Style="{StaticResource Button_BaseStyle}" />
<Button
Grid.Column="3"
Margin="0"
HorizontalAlignment="Stretch"
Command="{Binding ResetSettingCommand}"
CommandParameter="{Binding SelectedItem, ElementName=ListBox_Saves}"
Content="{ll:Str 重置}"
Style="{StaticResource Button_BaseStyle}" />
</StackPanel>
<!--<TabControl
x:Name="MainTab"
Grid.Column="1"