From 26d1813f3e9139aa21266cf644b91b691af5f5f9 Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Sat, 9 Dec 2023 17:23:28 -0500 Subject: [PATCH] move first run checks to main viewmodel --- .../ViewModels/MainWindowViewModel.cs | 30 ++++++++++++++++++ .../ViewModels/ProfileViewModel.cs | 31 ------------------- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/project/Aki.Launcher/ViewModels/MainWindowViewModel.cs b/project/Aki.Launcher/ViewModels/MainWindowViewModel.cs index 1825700..c3306b9 100644 --- a/project/Aki.Launcher/ViewModels/MainWindowViewModel.cs +++ b/project/Aki.Launcher/ViewModels/MainWindowViewModel.cs @@ -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)); diff --git a/project/Aki.Launcher/ViewModels/ProfileViewModel.cs b/project/Aki.Launcher/ViewModels/ProfileViewModel.cs index 699545c..03d1cbe 100644 --- a/project/Aki.Launcher/ViewModels/ProfileViewModel.cs +++ b/project/Aki.Launcher/ViewModels/ProfileViewModel.cs @@ -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) {