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> /// </summary>
public ObservableCollection<StatisticDataModel> Statistics { get; set; } = new(); public ObservableCollection<StatisticDataModel> Statistics { get; set; } = new();
/// <summary>
/// 是损坏的
/// </summary>
public bool IsDamaged { get; set; }
#region DateSaved #region DateSaved
private DateTime _dateSaved; private DateTime _dateSaved;
public DateTime DateSaved public DateTime DateSaved
@ -162,12 +167,41 @@ public class SaveModel : ObservableClass<SaveModel>
} }
#endregion #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) public SaveModel(string filePath, GameSave_v2 save)
{ {
Name = Path.GetFileNameWithoutExtension(filePath); Name = Path.GetFileNameWithoutExtension(filePath);
FilePath = filePath; FilePath = filePath;
DateSaved = File.GetLastWriteTime(filePath); DateSaved = File.GetLastWriteTime(filePath);
LoadSave(save.GameSave); LoadSave(save.GameSave);
if (save.Statistics.Data.TryGetValue("stat_total_time", out var time))
TotalTime = time.GetInteger64();
foreach (var data in save.Statistics.Data) foreach (var data in save.Statistics.Data)
{ {
Statistics.Add( Statistics.Add(

View File

@ -101,10 +101,14 @@ public class SaveWindowVM : ObservableClass<SaveWindowVM>
private void LoadSaves() private void LoadSaves()
{ {
var saveDirectory = Path.Combine(Environment.CurrentDirectory, "Saves"); 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 lps = new LPS(File.ReadAllText(file));
var saveModel = new SaveModel(file, save); 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); _saves.Add(saveModel);
} }
} }

View File

@ -87,6 +87,13 @@
Style="{DynamicResource Label_BaseStyle}" /> Style="{DynamicResource Label_BaseStyle}" />
<TextBlock Style="{DynamicResource TextBlock_LeftCenter}" Text="{Binding Save.StrengthDrink}" /> <TextBlock Style="{DynamicResource TextBlock_LeftCenter}" Text="{Binding Save.StrengthDrink}" />
</DockPanel> </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> </StackPanel>
</ScrollViewer> </ScrollViewer>
</Page> </Page>

View File

@ -33,17 +33,17 @@
pu:TextBoxHelper.Watermark="{ll:Str 搜索存档}" pu:TextBoxHelper.Watermark="{ll:Str 搜索存档}"
Style="{DynamicResource StandardTextBoxStyle}" Style="{DynamicResource StandardTextBoxStyle}"
Text="{Binding SearchSave, UpdateSourceTrigger=PropertyChanged}" /> Text="{Binding SearchSave, UpdateSourceTrigger=PropertyChanged}" />
<ListBox <DataGrid
x:Name="ListBox_Saves" x:Name="DataGrid_Saves"
Grid.Row="1" Grid.Row="1"
d:ItemsSource="{d:SampleData ItemCount=5}" d:ItemsSource="{d:SampleData ItemCount=5}"
AutoGenerateColumns="False"
CanUserAddRows="False"
ItemsSource="{Binding ShowSaves}" ItemsSource="{Binding ShowSaves}"
SelectedItem="{Binding CurrentSave}" SelectedItem="{Binding CurrentSave}">
Style="{DynamicResource SideMenuListBoxStyle}"> <DataGrid.RowStyle>
<ListBox.ItemContainerStyle> <Style BasedOn="{StaticResource {x:Type DataGridRow}}" TargetType="DataGridRow">
<Style BasedOn="{StaticResource {x:Type ListBoxItem}}" TargetType="ListBoxItem">
<Setter Property="Tag" Value="{Binding DataContext, RelativeSource={RelativeSource AncestorType=Window}}" /> <Setter Property="Tag" Value="{Binding DataContext, RelativeSource={RelativeSource AncestorType=Window}}" />
<Setter Property="Content" Value="{Binding Name}" />
<Setter Property="ToolTip" Value="{Binding FilePath}" /> <Setter Property="ToolTip" Value="{Binding FilePath}" />
<Setter Property="ContextMenu"> <Setter Property="ContextMenu">
<Setter.Value> <Setter.Value>
@ -60,10 +60,27 @@
</Setter.Value> </Setter.Value>
</Setter> </Setter>
</Style> </Style>
</ListBox.ItemContainerStyle> </DataGrid.RowStyle>
</ListBox> <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 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> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition /> <RowDefinition />