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

52 lines
2.2 KiB
C#
Raw Permalink Normal View History

2024-05-21 20:15:19 +01:00
using SPT.Launcher.Helpers;
using SPT.Launcher.Interfaces;
using SPT.Launcher.Models.Launcher;
using SPT.Launcher.ViewModels.Dialogs;
using SPT.Launcher.ViewModels.Notifications;
2023-03-03 19:25:33 +00:00
using Avalonia.Controls.Notifications;
using Splat;
using System.Collections.Generic;
using System.Threading.Tasks;
2024-07-06 11:48:16 -04:00
using DialogHostAvalonia;
2023-03-03 19:25:33 +00:00
2024-05-21 20:15:19 +01:00
namespace SPT.Launcher.Models
2023-03-03 19:25:33 +00:00
{
public class GameStarterFrontend : IGameStarterFrontend
{
private WindowNotificationManager notificationManager => Locator.Current.GetService<WindowNotificationManager>();
public async Task CompletePatchTask(IAsyncEnumerable<PatchResultInfo> task)
{
2024-05-21 20:15:19 +01:00
notificationManager.Show(new SPTNotificationViewModel(null, "", $"{LocalizationProvider.Instance.patching} ..."));
2023-03-03 19:25:33 +00:00
var iter = task.GetAsyncEnumerator();
while (await iter.MoveNextAsync())
{
var info = iter.Current;
if (!info.OK)
{
if(info.Status == ByteBanger.PatchResultType.InputChecksumMismatch)
{
string serverVersion = ServerManager.GetVersion();
var localeText = string.Format(LocalizationProvider.Instance.file_mismatch_dialog_message, serverVersion);
2024-06-02 14:46:53 -04:00
2024-07-06 11:48:16 -04:00
var result = await DialogHost.Show(new ConfirmationDialogViewModel(null, localeText, null, null, LauncherSettingsProvider.Instance.IsDevMode));
2023-03-03 19:25:33 +00:00
if(result != null && result is bool confirmation && !confirmation)
{
2024-05-21 20:15:19 +01:00
notificationManager.Show(new SPTNotificationViewModel(null, "", LocalizationProvider.Instance.failed_core_patch, NotificationType.Error));
2023-03-03 19:25:33 +00:00
throw new TaskCanceledException();
}
}
else
{
2024-05-21 20:15:19 +01:00
notificationManager.Show(new SPTNotificationViewModel(null, "", LocalizationProvider.Instance.failed_core_patch, NotificationType.Error));
2023-03-03 19:25:33 +00:00
throw new TaskCanceledException();
}
}
}
}
}
}