0
0
mirror of https://github.com/sp-tarkov/launcher.git synced 2025-02-12 17:30:42 -05:00

move first run checks to main viewmodel

This commit is contained in:
IsWaffle 2023-12-09 17:23:28 -05:00
parent 6489ef4793
commit 26d1813f3e
2 changed files with 30 additions and 31 deletions

View File

@ -7,6 +7,10 @@ using System.IO;
using Splat;
using Aki.Launcher.Models.Aki;
using Aki.Launcher.Helpers;
using Aki.Launcher.ViewModels.Dialogs;
using Avalonia.Threading;
using dialogHost = DialogHost.DialogHost;
namespace Aki.Launcher.ViewModels
{
@ -29,6 +33,32 @@ namespace Aki.Launcher.ViewModels
LauncherSettingsProvider.Instance.AllowSettings = true;
if (LauncherSettingsProvider.Instance.FirstRun)
{
Dispatcher.UIThread.InvokeAsync(async () =>
{
LauncherSettingsProvider.Instance.FirstRun = false;
LocalizationProvider.TryAutoSetLocale();
var viewModel = new ConfirmationDialogViewModel(this,
LocalizationProvider.Instance.copy_live_settings_question,
LocalizationProvider.Instance.yes,
LocalizationProvider.Instance.no);
var confirmCopySettings = await dialogHost.Show(viewModel);
if (confirmCopySettings is bool and true)
{
var settingsVm = new SettingsViewModel(this);
await settingsVm.ResetGameSettingsCommand();
}
LauncherSettingsProvider.Instance.SaveSettings();
});
}
this.WhenActivated((CompositeDisposable disposables) =>
{
Router.Navigate.Execute(new ConnectServerViewModel(this));

View File

@ -8,7 +8,6 @@ using System.Threading.Tasks;
using Aki.Launcher.Attributes;
using Aki.Launcher.ViewModels.Dialogs;
using Avalonia.Threading;
using System.Reactive.Disposables;
using System.Diagnostics;
using System.IO;
using Aki.Launcher.Models.Aki;
@ -62,36 +61,6 @@ namespace Aki.Launcher.ViewModels
public ProfileViewModel(IScreen Host) : base(Host)
{
this.WhenActivated((CompositeDisposable disposables) =>
{
Task.Run(async () =>
{
await GameVersionCheck();
await Dispatcher.UIThread.InvokeAsync(async () =>
{
if (LauncherSettingsProvider.Instance.FirstRun)
{
LauncherSettingsProvider.Instance.FirstRun = false;
LauncherSettingsProvider.Instance.SaveSettings();
var confirmCopySettings = await ShowDialog(new ConfirmationDialogViewModel(Host,
LocalizationProvider.Instance.copy_live_settings_question,
LocalizationProvider.Instance.yes,
LocalizationProvider.Instance.no));
if (confirmCopySettings != null && confirmCopySettings is bool confirmed && confirmed)
{
var settingsVM = new SettingsViewModel(Host);
await settingsVM.ResetGameSettingsCommand();
}
}
});
});
});
// cache and load side image if profile has a side
if(AccountManager.SelectedProfileInfo != null && AccountManager.SelectedProfileInfo.Side != null)
{