0
0
mirror of https://github.com/sp-tarkov/launcher.git synced 2025-02-13 07:10:44 -05:00
launcher/project/SPT.Launcher/Models/GameStarterFrontend.cs

47 lines
1.9 KiB
C#

using SPT.Launcher.Helpers;
using SPT.Launcher.Interfaces;
using SPT.Launcher.Models.Launcher;
using SPT.Launcher.ViewModels.Dialogs;
using SPT.Launcher.ViewModels.Notifications;
using Avalonia.Controls.Notifications;
using Splat;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace SPT.Launcher.Models
{
public class GameStarterFrontend : IGameStarterFrontend
{
private WindowNotificationManager notificationManager => Locator.Current.GetService<WindowNotificationManager>();
public async Task CompletePatchTask(IAsyncEnumerable<PatchResultInfo> task)
{
notificationManager.Show(new SPTNotificationViewModel(null, "", $"{LocalizationProvider.Instance.patching} ..."));
var iter = task.GetAsyncEnumerator();
while (await iter.MoveNextAsync())
{
var info = iter.Current;
if (!info.OK)
{
if(info.Status == ByteBanger.PatchResultType.InputChecksumMismatch)
{
var result = await DialogHost.DialogHost.Show(new ConfirmationDialogViewModel(null, LocalizationProvider.Instance.file_mismatch_dialog_message));
if(result != null && result is bool confirmation && !confirmation)
{
notificationManager.Show(new SPTNotificationViewModel(null, "", LocalizationProvider.Instance.failed_core_patch, NotificationType.Error));
throw new TaskCanceledException();
}
}
else
{
notificationManager.Show(new SPTNotificationViewModel(null, "", LocalizationProvider.Instance.failed_core_patch, NotificationType.Error));
throw new TaskCanceledException();
}
}
}
}
}
}