Skip to content

Commit

Permalink
Updating Game Time Removes Start Date #239
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacro59 committed Nov 19, 2024
1 parent 8a4fe65 commit 4dae437
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 34 deletions.
23 changes: 7 additions & 16 deletions source/Models/Api/EditData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class Comp100
public string Notes { get; set; } = string.Empty;
}

public class CompletionDate
public class Date
{
[SerializationPropertyName("year")]
public string Year { get; set; } = "0000";
Expand Down Expand Up @@ -76,16 +76,19 @@ public class CustomLabels
public class General
{
[SerializationPropertyName("progress")]
public Progress Progress { get; set; } = new Progress();
public Time Progress { get; set; } = new Time();

[SerializationPropertyName("retirementNotes")]
public string RetirementNotes { get; set; } = string.Empty;

[SerializationPropertyName("completionDate")]
public CompletionDate CompletionDate { get; set; } = new CompletionDate();
public Date CompletionDate { get; set; } = new Date();

[SerializationPropertyName("startDate")]
public Date StartDate { get; set; } = new Date();

[SerializationPropertyName("progressBefore")]
public Progress ProgressBefore { get; set; } = new Progress();
public Time ProgressBefore { get; set; } = new Time();
}

public class Lists
Expand Down Expand Up @@ -148,18 +151,6 @@ public class PercAny
public string Notes { get; set; } = string.Empty;
}

public class Progress
{
[SerializationPropertyName("hours")]
public int Hours { get; set; }

[SerializationPropertyName("minutes")]
public int Minutes { get; set; }

[SerializationPropertyName("seconds")]
public int Seconds { get; set; }
}

public class Review
{
[SerializationPropertyName("score")]
Expand Down
3 changes: 3 additions & 0 deletions source/Models/Api/UserGamesList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ public class GamesList
[SerializationPropertyName("retired_notes")]
public string RetiredNotes { get; set; }

[SerializationPropertyName("date_start")]
public string DateStart { get; set; }

[SerializationPropertyName("date_complete")]
public string DateComplete { get; set; }

Expand Down
1 change: 1 addition & 0 deletions source/Models/HltbUserStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class TitleList
public bool IsReplay { get; set; }
public bool IsRetired { get; set; }

public DateTime StartDate { get; set; } = default;
public DateTime LastUpdate { get; set; } = default;

public DateTime? Completion { get; set; }
Expand Down
16 changes: 9 additions & 7 deletions source/Services/HowLongToBeatClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,13 @@ private TitleList GetTitleList(GamesList gamesList)
{
try
{
_ = DateTime.TryParse(gamesList.DateUpdated, out DateTime LastUpdate);
_ = DateTime.TryParse(gamesList.DateComplete, out DateTime Completion);
DateTime? CompletionFinal = null;
if (Completion != default)
_ = DateTime.TryParse(gamesList.DateUpdated, out DateTime lastUpdate);
_ = DateTime.TryParse(gamesList.DateComplete, out DateTime completion);
_ = DateTime.TryParse(gamesList.DateStart, out DateTime dateStart);
DateTime? completionFinal = null;
if (completion != default)
{
CompletionFinal = Completion;
completionFinal = completion;
}

TitleList titleList = new TitleList
Expand All @@ -449,8 +450,9 @@ private TitleList GetTitleList(GamesList gamesList)
IsReplay = gamesList.PlayCount == 2,
IsRetired = gamesList.ListRetired == 1,
Storefront = gamesList.PlayStorefront,
LastUpdate = LastUpdate,
Completion = CompletionFinal,
StartDate = dateStart,
LastUpdate = lastUpdate,
Completion = completionFinal,
HltbUserData = new HltbData
{
GameType = gamesList.GameType.IsEqual("game") ? GameType.Game : gamesList.GameType.IsEqual("multi") ? GameType.Multi : GameType.Compil,
Expand Down
4 changes: 4 additions & 0 deletions source/Views/HowLongToBeatUserView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@
</GridViewColumn.CellTemplate>
</GridViewColumn>

<GridViewColumn Width="120" DisplayMemberBinding="{Binding StartDate, Converter={StaticResource LocalDateConverter}}" x:Name="lvGameStartDate">
<GridViewColumnHeader Content="{DynamicResource LOCCommonStartDate}" />
</GridViewColumn>

<GridViewColumn Width="120" DisplayMemberBinding="{Binding LastUpdate, Converter={StaticResource LocalDateConverter}}" x:Name="lvGameCompletion">
<GridViewColumnHeader Content="{DynamicResource LOCCommonLastUpdate}" />
</GridViewColumn>
Expand Down
6 changes: 3 additions & 3 deletions source/Views/HowLongToBeatView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:controls="clr-namespace:HowLongToBeat.Controls"
xmlns:local="clr-namespace:HowLongToBeat.Views"
xmlns:converters="clr-namespace:CommonPlayniteShared.Converters"
mc:Ignorable="d" Width="750" Height="400"
mc:Ignorable="d" Width="900" Height="400"
d:DataContext="{d:DesignInstance local:HowLongToBeatViewData}">

<UserControl.Resources>
Expand Down Expand Up @@ -56,7 +56,7 @@
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="auto" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
Expand All @@ -67,7 +67,7 @@

<TextBlock Name="Hltb_DataType" Grid.Column="2" Grid.Row="0" FontSize="16" Style="{DynamicResource BaseTextBlockStyle}" VerticalAlignment="Center" HorizontalAlignment="Center" />

<TextBlock Name="Hltb_El0_tb" Grid.Column="3" Grid.Row="0" FontSize="16" Style="{DynamicResource BaseTextBlockStyle}" VerticalAlignment="Center" HorizontalAlignment="Center" />
<TextBlock Name="Hltb_El0_tb" TextWrapping="Wrap" TextAlignment="Center" Margin="0,5" Grid.Column="3" Grid.Row="0" FontSize="16" Style="{DynamicResource BaseTextBlockStyle}" VerticalAlignment="Center" HorizontalAlignment="Center" />
<RadioButton GroupName="DataUser" Checked="Hltb_El0_Checked" Name="Hltb_El0" Grid.Column="3" Grid.Row="0" FontSize="16" VerticalAlignment="Center" HorizontalAlignment="Center" />
<RadioButton GroupName="DataUser" Checked="Hltb_El0_Checked" Name="Hltb_El0_1" Margin="10,0,0,0" Visibility="Collapsed" Grid.Column="4" Grid.Row="0" FontSize="16" VerticalAlignment="Center" HorizontalAlignment="Center" />
<RadioButton GroupName="DataUser" Checked="Hltb_El0_Checked" Name="Hltb_El0_2" Margin="10,0,0,0" Visibility="Collapsed" Grid.Column="5" Grid.Row="0" FontSize="16" VerticalAlignment="Center" HorizontalAlignment="Center" />
Expand Down
25 changes: 17 additions & 8 deletions source/Views/HowLongToBeatView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,6 @@ private void Init(GameHowLongToBeat gameHowLongToBeat)
((HowLongToBeatViewData)DataContext).SourceLink = gameHowLongToBeat.SourceLink;
}

var Items = gameHowLongToBeat.Items;
var a = Items?.Count > 0 && Items?.First() != null && !Items.First().IsEmpty;
var aa = Items?.Count > 0;
var aaa = Items?.First() != null;
var aaaa = !Items.First().IsEmpty;

if (!gameHowLongToBeat.HasData)
{
PART_GridProgressBar.Visibility = Visibility.Hidden;
Expand Down Expand Up @@ -165,13 +159,28 @@ private void Init(GameHowLongToBeat gameHowLongToBeat)


LocalDateConverter localDateConverter = new LocalDateConverter();
Hltb_0.Content = localDateConverter.Convert(titleList.LastUpdate, null, null, CultureInfo.CurrentCulture).ToString();
string dateStart = localDateConverter.Convert(titleList.StartDate, null, null, CultureInfo.CurrentCulture).ToString();
string lastUpdate = localDateConverter.Convert(titleList.LastUpdate, null, null, CultureInfo.CurrentCulture).ToString();
string content = string.Empty;
if (!dateStart.IsNullOrEmpty())
{
content += ResourceProvider.GetString("LOCCommonStartDate") + ": " + dateStart;
}
if (!lastUpdate.IsNullOrEmpty())
{
if (!content.IsNullOrEmpty())
{
content += Environment.NewLine;
}
content += ResourceProvider.GetString("LOCCommonLastUpdate") + ": " + lastUpdate;
}
Hltb_0.Content = content;
Hltb_0.Tag = titleList.UserGameId;
Hltb_0.Visibility = Visibility.Visible;

if (idx == 0)
{
Hltb_El0_tb.Text = localDateConverter.Convert(titleList.LastUpdate, null, null, CultureInfo.CurrentCulture).ToString();
Hltb_El0_tb.Text = content;
Hltb_El0_tb.Tag = titleList.UserGameId;
Hltb_El0_tb.Visibility = Visibility.Visible;
Hltb_0.Visibility = Visibility.Collapsed;
Expand Down

0 comments on commit 4dae437

Please sign in to comment.