Skip to content

Commit

Permalink
display actual size and saved space by hard links
Browse files Browse the repository at this point in the history
  • Loading branch information
Scighost committed Dec 26, 2024
1 parent e3bc5af commit 9bbae33
Show file tree
Hide file tree
Showing 9 changed files with 649 additions and 376 deletions.
6 changes: 3 additions & 3 deletions src/Starward.Core/HoYoPlay/GameInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,21 @@ public class GameInfoDisplay
/// 大背景图
/// </summary>
[JsonPropertyName("background")]
public GameImage Background { get; set; }
public GameImage? Background { get; set; }


/// <summary>
/// 游戏Logo
/// </summary>
[JsonPropertyName("logo")]
public GameImage Logo { get; set; }
public GameImage? Logo { get; set; }


/// <summary>
/// 小缩略背景图
/// </summary>
[JsonPropertyName("thumbnail")]
public GameImage Thumbnail { get; set; }
public GameImage? Thumbnail { get; set; }

}

Expand Down
18 changes: 18 additions & 0 deletions src/Starward.Language/Lang.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/Starward.Language/Lang.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1645,4 +1645,10 @@ Do you accept the risk and continue to use it?</value>
<data name="GameLauncherSettingDialog_UseVersionPoster" xml:space="preserve">
<value>Use Version Poster</value>
</data>
<data name="GameSelector_ActualSizeOfInstalledGames" xml:space="preserve">
<value>Actual Size of Installed Games</value>
</data>
<data name="GameSelector_StorageSpaceSavedByHardLinks" xml:space="preserve">
<value>Storage Space Saved by Hard Links</value>
</data>
</root>
6 changes: 6 additions & 0 deletions src/Starward.Language/Lang.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1645,4 +1645,10 @@
<data name="GameLauncherSettingDialog_UseVersionPoster" xml:space="preserve">
<value>使用版本海报</value>
</data>
<data name="GameSelector_ActualSizeOfInstalledGames" xml:space="preserve">
<value>已安装游戏实际占用空间</value>
</data>
<data name="GameSelector_StorageSpaceSavedByHardLinks" xml:space="preserve">
<value>通过硬链接节省存储空间</value>
</data>
</root>
17 changes: 2 additions & 15 deletions src/Starward/Features/GameSelector/GameBizDisplay.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Starward.Core.HoYoPlay;
using Starward.Core.HoYoPlay;
using System.Collections.Generic;


Expand All @@ -11,18 +10,6 @@ public class GameBizDisplay
public GameInfo GameInfo { get; set; }


public List<GameBizDisplayServer> Servers { get; set; } = new();

}


public class GameBizDisplayServer : ObservableObject
{

public GameBizIcon GameBizIcon { get; set; }


public bool IsPinned { get; set => SetProperty(ref field, value); }

public List<GameBizIcon> Servers { get; set; } = new();

}
31 changes: 31 additions & 0 deletions src/Starward/Features/GameSelector/GameBizIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public partial class GameBizIcon : ObservableObject, IEquatable<GameBizIcon>
{


private const double GB = 1 << 30;


public GameId GameId { get; set; }

public GameBiz GameBiz { get; set; }
Expand All @@ -25,6 +28,15 @@ public partial class GameBizIcon : ObservableObject, IEquatable<GameBizIcon>

public double MaskOpacity { get; set => SetProperty(ref field, value); } = 1.0;

public bool IsPinned { get; set => SetProperty(ref field, value); }

public string? InstallPath { get; set => SetProperty(ref field, value); }

public long TotalSize { get; set { field = value; OnPropertyChanged(nameof(TotalSizeText)); } }

public string? TotalSizeText => TotalSize == 0 ? null : $"{TotalSize / GB:F2}GB";


public bool IsSelected
{
get;
Expand Down Expand Up @@ -61,6 +73,25 @@ public GameBizIcon(GameInfo gameInfo)



public void UpdateInfo()
{
GameIcon = GameBizToIcon(GameBiz);
ServerIcon = GameBizToServerIcon(GameBiz);
GameName = GameBiz.ToGameName();
ServerName = GameBiz.ToGameServerName();
}


public void UpdateInfo(GameInfo gameInfo)
{
GameIcon = gameInfo.Display.Icon.Url;
ServerIcon = GameBizToServerIcon(gameInfo.GameBiz);
GameName = gameInfo.Display.Name;
ServerName = gameInfo.GameBiz.ToGameServerName();
}



private static string GameBizToIcon(GameBiz gameBiz)
{
return gameBiz.Game switch
Expand Down
Loading

0 comments on commit 9bbae33

Please sign in to comment.