| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687 |
- using Avalonia;
- using Avalonia.Controls;
- using Avalonia.Controls.Primitives;
- using Avalonia.Interactivity;
- using Avalonia.Platform;
- using Avalonia.Threading;
- using DynamicData;
- using FluentAvalonia.UI.Controls;
- using LibHac.Tools.FsSystem;
- using Ryujinx.Ava.Common;
- using Ryujinx.Ava.Common.Locale;
- using Ryujinx.Ava.Input;
- using Ryujinx.Ava.UI.Applet;
- using Ryujinx.Ava.UI.Helpers;
- using Ryujinx.Ava.UI.ViewModels;
- using Ryujinx.Common.Logging;
- using Ryujinx.Graphics.Gpu;
- using Ryujinx.HLE.FileSystem;
- using Ryujinx.HLE.HOS;
- using Ryujinx.HLE.HOS.Services.Account.Acc;
- using Ryujinx.Input.HLE;
- using Ryujinx.Input.SDL2;
- using Ryujinx.Modules;
- using Ryujinx.UI.App.Common;
- using Ryujinx.UI.Common;
- using Ryujinx.UI.Common.Configuration;
- using Ryujinx.UI.Common.Helper;
- using System;
- using System.Collections.Generic;
- using System.Reactive.Linq;
- using System.Runtime.Versioning;
- using System.Threading;
- using System.Threading.Tasks;
- namespace Ryujinx.Ava.UI.Windows
- {
- public partial class MainWindow : StyleableWindow
- {
- internal static MainWindowViewModel MainWindowViewModel { get; private set; }
- private bool _isLoading;
- private bool _applicationsLoadedOnce;
- private UserChannelPersistence _userChannelPersistence;
- private static bool _deferLoad;
- private static string _launchPath;
- private static string _launchApplicationId;
- private static bool _startFullscreen;
- internal readonly AvaHostUIHandler UiHandler;
- private IDisposable _appLibraryAppsSubscription;
- public VirtualFileSystem VirtualFileSystem { get; private set; }
- public ContentManager ContentManager { get; private set; }
- public AccountManager AccountManager { get; private set; }
- public LibHacHorizonManager LibHacHorizonManager { get; private set; }
- public InputManager InputManager { get; private set; }
- internal MainWindowViewModel ViewModel { get; private set; }
- public SettingsWindow SettingsWindow { get; set; }
- public static bool ShowKeyErrorOnLoad { get; set; }
- public ApplicationLibrary ApplicationLibrary { get; set; }
- public readonly double StatusBarHeight;
- public readonly double MenuBarHeight;
- public MainWindow()
- {
- ViewModel = new MainWindowViewModel();
- MainWindowViewModel = ViewModel;
- DataContext = ViewModel;
- InitializeComponent();
- Load();
- UiHandler = new AvaHostUIHandler(this);
- ViewModel.Title = $"Ryujinx {Program.Version}";
- // NOTE: Height of MenuBar and StatusBar is not usable here, since it would still be 0 at this point.
- StatusBarHeight = StatusBarView.StatusBar.MinHeight;
- MenuBarHeight = MenuBar.MinHeight;
- double barHeight = MenuBarHeight + StatusBarHeight;
- Height = ((Height - barHeight) / Program.WindowScaleFactor) + barHeight;
- Width /= Program.WindowScaleFactor;
- SetWindowSizePosition();
- if (Program.PreviewerDetached)
- {
- InputManager = new InputManager(new AvaloniaKeyboardDriver(this), new SDL2GamepadDriver());
- this.GetObservable(IsActiveProperty).Subscribe(IsActiveChanged);
- this.ScalingChanged += OnScalingChanged;
- }
- }
- /// <summary>
- /// Event handler for detecting OS theme change when using "Follow OS theme" option
- /// </summary>
- private void OnPlatformColorValuesChanged(object sender, PlatformColorValues e)
- {
- if (Application.Current is App app)
- {
- app.ApplyConfiguredTheme();
- }
- }
- protected override void OnClosed(EventArgs e)
- {
- base.OnClosed(e);
- if (PlatformSettings != null)
- {
- PlatformSettings.ColorValuesChanged -= OnPlatformColorValuesChanged;
- }
- }
- protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
- {
- base.OnApplyTemplate(e);
- NotificationHelper.SetNotificationManager(this);
- }
- private void IsActiveChanged(bool obj)
- {
- ViewModel.IsActive = obj;
- }
- private void OnScalingChanged(object sender, EventArgs e)
- {
- Program.DesktopScaleFactor = this.RenderScaling;
- }
- private void ApplicationLibrary_ApplicationCountUpdated(object sender, ApplicationCountUpdatedEventArgs e)
- {
- LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.StatusBarGamesLoaded, e.NumAppsLoaded, e.NumAppsFound);
- Dispatcher.UIThread.Post(() =>
- {
- ViewModel.StatusBarProgressValue = e.NumAppsLoaded;
- ViewModel.StatusBarProgressMaximum = e.NumAppsFound;
- if (e.NumAppsFound == 0)
- {
- StatusBarView.LoadProgressBar.IsVisible = false;
- }
- if (e.NumAppsLoaded == e.NumAppsFound)
- {
- StatusBarView.LoadProgressBar.IsVisible = false;
- }
- });
- }
- public void Application_Opened(object sender, ApplicationOpenedEventArgs args)
- {
- if (args.Application != null)
- {
- ViewModel.SelectedIcon = args.Application.Icon;
- ViewModel.LoadApplication(args.Application).Wait();
- }
- args.Handled = true;
- }
- internal static void DeferLoadApplication(string launchPathArg, string launchApplicationId, bool startFullscreenArg)
- {
- _deferLoad = true;
- _launchPath = launchPathArg;
- _launchApplicationId = launchApplicationId;
- _startFullscreen = startFullscreenArg;
- }
- public void SwitchToGameControl(bool startFullscreen = false)
- {
- ViewModel.ShowLoadProgress = false;
- ViewModel.ShowContent = true;
- ViewModel.IsLoadingIndeterminate = false;
- if (startFullscreen && ViewModel.WindowState != WindowState.FullScreen)
- {
- ViewModel.ToggleFullscreen();
- }
- }
- public void ShowLoading(bool startFullscreen = false)
- {
- ViewModel.ShowContent = false;
- ViewModel.ShowLoadProgress = true;
- ViewModel.IsLoadingIndeterminate = true;
- if (startFullscreen && ViewModel.WindowState != WindowState.FullScreen)
- {
- ViewModel.ToggleFullscreen();
- }
- }
- private void Initialize()
- {
- _userChannelPersistence = new UserChannelPersistence();
- VirtualFileSystem = VirtualFileSystem.CreateInstance();
- LibHacHorizonManager = new LibHacHorizonManager();
- ContentManager = new ContentManager(VirtualFileSystem);
- LibHacHorizonManager.InitializeFsServer(VirtualFileSystem);
- LibHacHorizonManager.InitializeArpServer();
- LibHacHorizonManager.InitializeBcatServer();
- LibHacHorizonManager.InitializeSystemClients();
- IntegrityCheckLevel checkLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks
- ? IntegrityCheckLevel.ErrorOnInvalid
- : IntegrityCheckLevel.None;
- ApplicationLibrary = new ApplicationLibrary(VirtualFileSystem, checkLevel)
- {
- DesiredLanguage = ConfigurationState.Instance.System.Language,
- };
- // Save data created before we supported extra data in directory save data will not work properly if
- // given empty extra data. Luckily some of that extra data can be created using the data from the
- // save data indexer, which should be enough to check access permissions for user saves.
- // Every single save data's extra data will be checked and fixed if needed each time the emulator is opened.
- // Consider removing this at some point in the future when we don't need to worry about old saves.
- VirtualFileSystem.FixExtraData(LibHacHorizonManager.RyujinxClient);
- AccountManager = new AccountManager(LibHacHorizonManager.RyujinxClient, CommandLineState.Profile);
- VirtualFileSystem.ReloadKeySet();
- ApplicationHelper.Initialize(VirtualFileSystem, AccountManager, LibHacHorizonManager.RyujinxClient);
- }
- [SupportedOSPlatform("linux")]
- private static async Task ShowVmMaxMapCountWarning()
- {
- LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.LinuxVmMaxMapCountWarningTextSecondary,
- LinuxHelper.VmMaxMapCount, LinuxHelper.RecommendedVmMaxMapCount);
- await ContentDialogHelper.CreateWarningDialog(
- LocaleManager.Instance[LocaleKeys.LinuxVmMaxMapCountWarningTextPrimary],
- LocaleManager.Instance[LocaleKeys.LinuxVmMaxMapCountWarningTextSecondary]
- );
- }
- [SupportedOSPlatform("linux")]
- private static async Task ShowVmMaxMapCountDialog()
- {
- LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.LinuxVmMaxMapCountDialogTextPrimary,
- LinuxHelper.RecommendedVmMaxMapCount);
- UserResult response = await ContentDialogHelper.ShowTextDialog(
- $"Ryujinx - {LocaleManager.Instance[LocaleKeys.LinuxVmMaxMapCountDialogTitle]}",
- LocaleManager.Instance[LocaleKeys.LinuxVmMaxMapCountDialogTextPrimary],
- LocaleManager.Instance[LocaleKeys.LinuxVmMaxMapCountDialogTextSecondary],
- LocaleManager.Instance[LocaleKeys.LinuxVmMaxMapCountDialogButtonUntilRestart],
- LocaleManager.Instance[LocaleKeys.LinuxVmMaxMapCountDialogButtonPersistent],
- LocaleManager.Instance[LocaleKeys.InputDialogNo],
- (int)Symbol.Help
- );
- int rc;
- switch (response)
- {
- case UserResult.Ok:
- rc = LinuxHelper.RunPkExec($"echo {LinuxHelper.RecommendedVmMaxMapCount} > {LinuxHelper.VmMaxMapCountPath}");
- if (rc == 0)
- {
- Logger.Info?.Print(LogClass.Application, $"vm.max_map_count set to {LinuxHelper.VmMaxMapCount} until the next restart.");
- }
- else
- {
- Logger.Error?.Print(LogClass.Application, $"Unable to change vm.max_map_count. Process exited with code: {rc}");
- }
- break;
- case UserResult.No:
- rc = LinuxHelper.RunPkExec($"echo \"vm.max_map_count = {LinuxHelper.RecommendedVmMaxMapCount}\" > {LinuxHelper.SysCtlConfigPath} && sysctl -p {LinuxHelper.SysCtlConfigPath}");
- if (rc == 0)
- {
- Logger.Info?.Print(LogClass.Application, $"vm.max_map_count set to {LinuxHelper.VmMaxMapCount}. Written to config: {LinuxHelper.SysCtlConfigPath}");
- }
- else
- {
- Logger.Error?.Print(LogClass.Application, $"Unable to write new value for vm.max_map_count to config. Process exited with code: {rc}");
- }
- break;
- }
- }
- private async Task CheckLaunchState()
- {
- if (OperatingSystem.IsLinux() && LinuxHelper.VmMaxMapCount < LinuxHelper.RecommendedVmMaxMapCount)
- {
- Logger.Warning?.Print(LogClass.Application, $"The value of vm.max_map_count is lower than {LinuxHelper.RecommendedVmMaxMapCount}. ({LinuxHelper.VmMaxMapCount})");
- if (LinuxHelper.PkExecPath is not null)
- {
- await Dispatcher.UIThread.InvokeAsync(ShowVmMaxMapCountDialog);
- }
- else
- {
- await Dispatcher.UIThread.InvokeAsync(ShowVmMaxMapCountWarning);
- }
- }
- if (!ShowKeyErrorOnLoad)
- {
- if (_deferLoad)
- {
- _deferLoad = false;
- if (ApplicationLibrary.TryGetApplicationsFromFile(_launchPath, out List<ApplicationData> applications))
- {
- ApplicationData applicationData;
- if (_launchApplicationId != null)
- {
- applicationData = applications.Find(application => application.IdString == _launchApplicationId);
- if (applicationData != null)
- {
- await ViewModel.LoadApplication(applicationData, _startFullscreen);
- }
- else
- {
- Logger.Error?.Print(LogClass.Application, $"Couldn't find requested application id '{_launchApplicationId}' in '{_launchPath}'.");
- await Dispatcher.UIThread.InvokeAsync(async () => await UserErrorDialog.ShowUserErrorDialog(UserError.ApplicationNotFound));
- }
- }
- else
- {
- applicationData = applications[0];
- await ViewModel.LoadApplication(applicationData, _startFullscreen);
- }
- }
- else
- {
- Logger.Error?.Print(LogClass.Application, $"Couldn't find any application in '{_launchPath}'.");
- await Dispatcher.UIThread.InvokeAsync(async () => await UserErrorDialog.ShowUserErrorDialog(UserError.ApplicationNotFound));
- }
- }
- }
- else
- {
- ShowKeyErrorOnLoad = false;
- await Dispatcher.UIThread.InvokeAsync(async () => await UserErrorDialog.ShowUserErrorDialog(UserError.NoKeys));
- }
- if (ConfigurationState.Instance.CheckUpdatesOnStart.Value && Updater.CanUpdate(false))
- {
- await Updater.BeginParse(this, false).ContinueWith(task =>
- {
- Logger.Error?.Print(LogClass.Application, $"Updater Error: {task.Exception}");
- }, TaskContinuationOptions.OnlyOnFaulted);
- }
- }
- private void Load()
- {
- StatusBarView.VolumeStatus.Click += VolumeStatus_CheckedChanged;
- ApplicationGrid.ApplicationOpened += Application_Opened;
- ApplicationGrid.DataContext = ViewModel;
- ApplicationList.ApplicationOpened += Application_Opened;
- ApplicationList.DataContext = ViewModel;
- }
- private void SetWindowSizePosition()
- {
- if (!ConfigurationState.Instance.RememberWindowState)
- {
- ViewModel.WindowHeight = (720 + StatusBarHeight + MenuBarHeight) * Program.WindowScaleFactor;
- ViewModel.WindowWidth = 1280 * Program.WindowScaleFactor;
- WindowState = WindowState.Normal;
- WindowStartupLocation = WindowStartupLocation.CenterScreen;
- return;
- }
- PixelPoint savedPoint = new(ConfigurationState.Instance.UI.WindowStartup.WindowPositionX,
- ConfigurationState.Instance.UI.WindowStartup.WindowPositionY);
- ViewModel.WindowHeight = ConfigurationState.Instance.UI.WindowStartup.WindowSizeHeight * Program.WindowScaleFactor;
- ViewModel.WindowWidth = ConfigurationState.Instance.UI.WindowStartup.WindowSizeWidth * Program.WindowScaleFactor;
- ViewModel.WindowState = ConfigurationState.Instance.UI.WindowStartup.WindowMaximized.Value ? WindowState.Maximized : WindowState.Normal;
- if (CheckScreenBounds(savedPoint))
- {
- Position = savedPoint;
- }
- else
- {
- WindowStartupLocation = WindowStartupLocation.CenterScreen;
- }
- }
- private bool CheckScreenBounds(PixelPoint configPoint)
- {
- for (int i = 0; i < Screens.ScreenCount; i++)
- {
- if (Screens.All[i].Bounds.Contains(configPoint))
- {
- return true;
- }
- }
- Logger.Warning?.Print(LogClass.Application, "Failed to find valid start-up coordinates. Defaulting to primary monitor center.");
- return false;
- }
- private void SaveWindowSizePosition()
- {
- ConfigurationState.Instance.UI.WindowStartup.WindowMaximized.Value = WindowState == WindowState.Maximized;
- // Only save rectangle properties if the window is not in a maximized state.
- if (WindowState != WindowState.Maximized)
- {
- ConfigurationState.Instance.UI.WindowStartup.WindowSizeHeight.Value = (int)Height;
- ConfigurationState.Instance.UI.WindowStartup.WindowSizeWidth.Value = (int)Width;
- ConfigurationState.Instance.UI.WindowStartup.WindowPositionX.Value = Position.X;
- ConfigurationState.Instance.UI.WindowStartup.WindowPositionY.Value = Position.Y;
- }
- MainWindowViewModel.SaveConfig();
- }
- protected override void OnOpened(EventArgs e)
- {
- base.OnOpened(e);
- Initialize();
- /// <summary>
- /// Subscribe to the ColorValuesChanged event
- /// </summary>
- PlatformSettings.ColorValuesChanged += OnPlatformColorValuesChanged;
- ViewModel.Initialize(
- ContentManager,
- StorageProvider,
- ApplicationLibrary,
- VirtualFileSystem,
- AccountManager,
- InputManager,
- _userChannelPersistence,
- LibHacHorizonManager,
- UiHandler,
- ShowLoading,
- SwitchToGameControl,
- SetMainContent,
- this);
- ApplicationLibrary.ApplicationCountUpdated += ApplicationLibrary_ApplicationCountUpdated;
- _appLibraryAppsSubscription?.Dispose();
- _appLibraryAppsSubscription = ApplicationLibrary.Applications
- .Connect()
- .ObserveOn(SynchronizationContext.Current)
- .Bind(ViewModel.Applications)
- .Subscribe();
- ViewModel.RefreshFirmwareStatus();
- // Load applications if no application was requested by the command line
- if (!_deferLoad)
- {
- LoadApplications();
- }
- #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
- CheckLaunchState();
- #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
- }
- private void SetMainContent(Control content = null)
- {
- content ??= GameLibrary;
- if (MainContent.Content != content)
- {
- // Load applications while switching to the GameLibrary if we haven't done that yet
- if (!_applicationsLoadedOnce && content == GameLibrary)
- {
- LoadApplications();
- }
- MainContent.Content = content;
- }
- }
- public static void UpdateGraphicsConfig()
- {
- #pragma warning disable IDE0055 // Disable formatting
- GraphicsConfig.ResScale = ConfigurationState.Instance.Graphics.ResScale == -1 ? ConfigurationState.Instance.Graphics.ResScaleCustom : ConfigurationState.Instance.Graphics.ResScale;
- GraphicsConfig.MaxAnisotropy = ConfigurationState.Instance.Graphics.MaxAnisotropy;
- GraphicsConfig.ShadersDumpPath = ConfigurationState.Instance.Graphics.ShadersDumpPath;
- GraphicsConfig.EnableShaderCache = ConfigurationState.Instance.Graphics.EnableShaderCache;
- GraphicsConfig.EnableTextureRecompression = ConfigurationState.Instance.Graphics.EnableTextureRecompression;
- GraphicsConfig.EnableMacroHLE = ConfigurationState.Instance.Graphics.EnableMacroHLE;
- #pragma warning restore IDE0055
- }
- private void VolumeStatus_CheckedChanged(object sender, RoutedEventArgs e)
- {
- var volumeSplitButton = sender as ToggleSplitButton;
- if (ViewModel.IsGameRunning)
- {
- if (!volumeSplitButton.IsChecked)
- {
- ViewModel.AppHost.Device.SetVolume(ViewModel.VolumeBeforeMute);
- }
- else
- {
- ViewModel.VolumeBeforeMute = ViewModel.AppHost.Device.GetVolume();
- ViewModel.AppHost.Device.SetVolume(0);
- }
- ViewModel.Volume = ViewModel.AppHost.Device.GetVolume();
- }
- }
- protected override void OnClosing(WindowClosingEventArgs e)
- {
- if (!ViewModel.IsClosing && ViewModel.AppHost != null && ConfigurationState.Instance.ShowConfirmExit)
- {
- e.Cancel = true;
- ConfirmExit();
- return;
- }
- ViewModel.IsClosing = true;
- if (ViewModel.AppHost != null)
- {
- ViewModel.AppHost.AppExit -= ViewModel.AppHost_AppExit;
- ViewModel.AppHost.AppExit += (sender, e) =>
- {
- ViewModel.AppHost = null;
- Dispatcher.UIThread.Post(() =>
- {
- MainContent = null;
- Close();
- });
- };
- ViewModel.AppHost?.Stop();
- e.Cancel = true;
- return;
- }
- if (ConfigurationState.Instance.RememberWindowState)
- {
- SaveWindowSizePosition();
- }
- ApplicationLibrary.CancelLoading();
- InputManager.Dispose();
- _appLibraryAppsSubscription?.Dispose();
- Program.Exit();
- base.OnClosing(e);
- }
- private void ConfirmExit()
- {
- Dispatcher.UIThread.InvokeAsync(async () =>
- {
- ViewModel.IsClosing = await ContentDialogHelper.CreateExitDialog();
- if (ViewModel.IsClosing)
- {
- Close();
- }
- });
- }
- public void LoadApplications()
- {
- _applicationsLoadedOnce = true;
- StatusBarView.LoadProgressBar.IsVisible = true;
- ViewModel.StatusBarProgressMaximum = 0;
- ViewModel.StatusBarProgressValue = 0;
- LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.StatusBarGamesLoaded, 0, 0);
- ReloadGameList();
- }
- public void ToggleFileType(string fileType)
- {
- _ = fileType switch
- {
- #pragma warning disable IDE0055 // Disable formatting
- "NSP" => ConfigurationState.Instance.UI.ShownFileTypes.NSP.Value = !ConfigurationState.Instance.UI.ShownFileTypes.NSP,
- "PFS0" => ConfigurationState.Instance.UI.ShownFileTypes.PFS0.Value = !ConfigurationState.Instance.UI.ShownFileTypes.PFS0,
- "XCI" => ConfigurationState.Instance.UI.ShownFileTypes.XCI.Value = !ConfigurationState.Instance.UI.ShownFileTypes.XCI,
- "NCA" => ConfigurationState.Instance.UI.ShownFileTypes.NCA.Value = !ConfigurationState.Instance.UI.ShownFileTypes.NCA,
- "NRO" => ConfigurationState.Instance.UI.ShownFileTypes.NRO.Value = !ConfigurationState.Instance.UI.ShownFileTypes.NRO,
- "NSO" => ConfigurationState.Instance.UI.ShownFileTypes.NSO.Value = !ConfigurationState.Instance.UI.ShownFileTypes.NSO,
- _ => throw new ArgumentOutOfRangeException(fileType),
- #pragma warning restore IDE0055
- };
- ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
- LoadApplications();
- }
- private void ReloadGameList()
- {
- if (_isLoading)
- {
- return;
- }
- _isLoading = true;
- Thread applicationLibraryThread = new(() =>
- {
- ApplicationLibrary.DesiredLanguage = ConfigurationState.Instance.System.Language;
- ApplicationLibrary.LoadApplications(ConfigurationState.Instance.UI.GameDirs);
- var autoloadDirs = ConfigurationState.Instance.UI.AutoloadDirs.Value;
- if (autoloadDirs.Count > 0)
- {
- var updatesLoaded = ApplicationLibrary.AutoLoadTitleUpdates(autoloadDirs);
- var dlcLoaded = ApplicationLibrary.AutoLoadDownloadableContents(autoloadDirs);
- ShowNewContentAddedDialog(dlcLoaded, updatesLoaded);
- }
- _isLoading = false;
- })
- {
- Name = "GUI.ApplicationLibraryThread",
- IsBackground = true,
- };
- applicationLibraryThread.Start();
- }
- private Task ShowNewContentAddedDialog(int numDlcAdded, int numUpdatesAdded)
- {
- var msg = "";
- if (numDlcAdded > 0 && numUpdatesAdded > 0)
- {
- msg = string.Format(LocaleManager.Instance[LocaleKeys.AutoloadDlcAndUpdateAddedMessage], numDlcAdded, numUpdatesAdded);
- }
- else if (numDlcAdded > 0)
- {
- msg = string.Format(LocaleManager.Instance[LocaleKeys.AutoloadDlcAddedMessage], numDlcAdded);
- }
- else if (numUpdatesAdded > 0)
- {
- msg = string.Format(LocaleManager.Instance[LocaleKeys.AutoloadUpdateAddedMessage], numUpdatesAdded);
- }
- else
- {
- return Task.CompletedTask;
- }
- return Dispatcher.UIThread.InvokeAsync(async () =>
- {
- await ContentDialogHelper.ShowTextDialog(LocaleManager.Instance[LocaleKeys.DialogConfirmationTitle],
- msg, "", "", "", LocaleManager.Instance[LocaleKeys.InputDialogOk], (int)Symbol.Checkmark);
- });
- }
- }
- }
|