diff --git a/src/PSLauncher.App/App.xaml.cs b/src/PSLauncher.App/App.xaml.cs index 9dff42c..dd5c313 100644 --- a/src/PSLauncher.App/App.xaml.cs +++ b/src/PSLauncher.App/App.xaml.cs @@ -55,6 +55,7 @@ public partial class App : Application services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(sp => new ManifestService( diff --git a/src/PSLauncher.App/ViewModels/MainViewModel.cs b/src/PSLauncher.App/ViewModels/MainViewModel.cs index c099e20..9f28376 100644 --- a/src/PSLauncher.App/ViewModels/MainViewModel.cs +++ b/src/PSLauncher.App/ViewModels/MainViewModel.cs @@ -130,6 +130,13 @@ public sealed partial class MainViewModel : ObservableObject rows.Add(row); } + // Marque les rows distantes qui ont un DL en pause (partial + state.json présents) + foreach (var r in rows.Where(r => r.IsRemoteOnly)) + { + var st = _downloadManager.GetResumableState(r.Version); + if (st is not null) r.ResumableBytes = st.DownloadedBytes; + } + // Featured : plus haute installée, sinon plus haute distante var featured = rows.FirstOrDefault(r => r.IsInstalled) ?? rows.FirstOrDefault(); FeaturedVersion = featured; diff --git a/src/PSLauncher.App/ViewModels/VersionRowViewModel.cs b/src/PSLauncher.App/ViewModels/VersionRowViewModel.cs index b0ca89e..a4b043a 100644 --- a/src/PSLauncher.App/ViewModels/VersionRowViewModel.cs +++ b/src/PSLauncher.App/ViewModels/VersionRowViewModel.cs @@ -37,6 +37,24 @@ public sealed partial class VersionRowViewModel : ObservableObject [ObservableProperty] private double _progressPercent; [ObservableProperty] private string? _progressDetail; + [ObservableProperty] + [NotifyPropertyChangedFor(nameof(InstallButtonLabel))] + [NotifyPropertyChangedFor(nameof(HasResumableDownload))] + private long _resumableBytes; + + public bool HasResumableDownload => ResumableBytes > 0; + + public string InstallButtonLabel + { + get + { + if (!HasResumableDownload) return "⬇ Installer"; + if (Remote is null || Remote.Download.SizeBytes <= 0) return "↻ Reprendre"; + var pct = (double)ResumableBytes / Remote.Download.SizeBytes * 100.0; + return $"↻ Reprendre ({pct:0}%)"; + } + } + public bool IsInstalled => State is VersionRowState.InstalledIdle or VersionRowState.Uninstalling; public bool IsRemoteOnly => State is VersionRowState.AvailableIdle; public bool IsBusy => State is VersionRowState.Downloading or VersionRowState.Installing or VersionRowState.Uninstalling; diff --git a/src/PSLauncher.App/Views/MainWindow.xaml b/src/PSLauncher.App/Views/MainWindow.xaml index 3d30f29..c114fb8 100644 --- a/src/PSLauncher.App/Views/MainWindow.xaml +++ b/src/PSLauncher.App/Views/MainWindow.xaml @@ -102,7 +102,7 @@ Command="{Binding LaunchCommand}" Visibility="{Binding IsInstalled, Converter={StaticResource BoolToVisibility}}" />