VPet.Solution 更新

This commit is contained in:
Hakoyu 2024-01-13 23:31:39 +08:00
parent e9f00b2f7a
commit cc9306697e
4 changed files with 75 additions and 13 deletions

View File

@ -31,6 +31,11 @@ public class SaveModel : ObservableClass<SaveModel>
/// </summary>
public ObservableCollection<StatisticDataModel> Statistics { get; set; } = new();
/// <summary>
/// 是损坏的
/// </summary>
public bool IsDamaged { get; set; }
#region DateSaved
private DateTime _dateSaved;
public DateTime DateSaved
@ -162,12 +167,41 @@ public class SaveModel : ObservableClass<SaveModel>
}
#endregion
#region HashCode
private long _hashCode;
public long HashCode
{
get => _hashCode;
set => SetProperty(ref _hashCode, value);
}
#endregion
#region TotalTime
private long _totalTime;
/// <summary>
/// 游玩总时长
/// </summary>
public long TotalTime
{
get => _totalTime;
set => SetProperty(ref _totalTime, value);
}
#endregion
public SaveModel(string filePath, GameSave_v2 save)
{
Name = Path.GetFileNameWithoutExtension(filePath);
FilePath = filePath;
DateSaved = File.GetLastWriteTime(filePath);
LoadSave(save.GameSave);
if (save.Statistics.Data.TryGetValue("stat_total_time", out var time))
TotalTime = time.GetInteger64();
foreach (var data in save.Statistics.Data)
{
Statistics.Add(

View File

@ -101,10 +101,14 @@ public class SaveWindowVM : ObservableClass<SaveWindowVM>
private void LoadSaves()
{
var saveDirectory = Path.Combine(Environment.CurrentDirectory, "Saves");
foreach (var file in Directory.EnumerateFiles(saveDirectory))
if (Directory.Exists(saveDirectory) is false)
return;
foreach (var file in Directory.EnumerateFiles(saveDirectory).Where(s => s.EndsWith(".lps")))
{
var save = new GameSave_v2(new LPS(File.ReadAllText(file)));
var saveModel = new SaveModel(file, save);
var lps = new LPS(File.ReadAllText(file));
var hashCode = lps.FindLine("hash")?.InfoToInt64 is long hash ? hash : 0;
var save = new GameSave_v2(lps);
var saveModel = new SaveModel(file, save) { HashCode = hashCode };
_saves.Add(saveModel);
}
}

View File

@ -87,6 +87,13 @@
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.HashCode}" />
</DockPanel>
</StackPanel>
</ScrollViewer>
</Page>

View File

@ -33,17 +33,17 @@
pu:TextBoxHelper.Watermark="{ll:Str 搜索存档}"
Style="{DynamicResource StandardTextBoxStyle}"
Text="{Binding SearchSave, UpdateSourceTrigger=PropertyChanged}" />
<ListBox
x:Name="ListBox_Saves"
<DataGrid
x:Name="DataGrid_Saves"
Grid.Row="1"
d:ItemsSource="{d:SampleData ItemCount=5}"
AutoGenerateColumns="False"
CanUserAddRows="False"
ItemsSource="{Binding ShowSaves}"
SelectedItem="{Binding CurrentSave}"
Style="{DynamicResource SideMenuListBoxStyle}">
<ListBox.ItemContainerStyle>
<Style BasedOn="{StaticResource {x:Type ListBoxItem}}" TargetType="ListBoxItem">
SelectedItem="{Binding CurrentSave}">
<DataGrid.RowStyle>
<Style BasedOn="{StaticResource {x:Type DataGridRow}}" TargetType="DataGridRow">
<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>
@ -60,10 +60,27 @@
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn
Binding="{Binding Name}"
ElementStyle="{DynamicResource TextBlock_LeftCenter}"
Header="{ll:Str 名称}"
IsReadOnly="True" />
<DataGridTextColumn
Binding="{Binding DateSaved}"
ElementStyle="{DynamicResource TextBlock_LeftCenter}"
Header="{ll:Str 保存时间}"
IsReadOnly="True" />
<DataGridTextColumn
Binding="{Binding TotalTime}"
ElementStyle="{DynamicResource TextBlock_LeftCenter}"
Header="{ll:Str 游玩时长}"
IsReadOnly="True" />
</DataGrid.Columns>
</DataGrid>
</Grid>
<Grid Grid.Column="1" IsEnabled="{Binding SelectedItem, ElementName=ListBox_Saves, Converter={StaticResource NullToFalse}}">
<Grid Grid.Column="1" IsEnabled="{Binding SelectedItem, ElementName=DataGrid_Saves, Converter={StaticResource NullToFalse}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />