Remove dead code; bind to AppLibrary apps directly in mainwindow

This commit is contained in:
Jimmy Reichley 2024-08-18 16:37:18 -04:00
parent bc60126a24
commit 20e0dbe97f
No known key found for this signature in database
GPG Key ID: 67715DC5A329803C
6 changed files with 17 additions and 61 deletions

View File

@ -1,5 +1,4 @@
using DynamicData; using DynamicData;
using DynamicData.Kernel;
using LibHac; using LibHac;
using LibHac.Common; using LibHac.Common;
using LibHac.Fs; using LibHac.Fs;
@ -24,7 +23,6 @@ using Ryujinx.UI.Common.Helper;
using Ryujinx.UI.Common.Models; using Ryujinx.UI.Common.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@ -44,8 +42,6 @@ namespace Ryujinx.UI.App.Common
public Language DesiredLanguage { get; set; } public Language DesiredLanguage { get; set; }
public event EventHandler<ApplicationAddedEventArgs> ApplicationAdded; public event EventHandler<ApplicationAddedEventArgs> ApplicationAdded;
public event EventHandler<ApplicationCountUpdatedEventArgs> ApplicationCountUpdated; public event EventHandler<ApplicationCountUpdatedEventArgs> ApplicationCountUpdated;
public event EventHandler<TitleUpdateAddedEventArgs> TitleUpdateAdded;
public event EventHandler<DownloadableContentAddedEventArgs> DownloadableContentAdded;
public IObservableCache<ApplicationData, string> Applications; public IObservableCache<ApplicationData, string> Applications;
public IObservableCache<(TitleUpdateModel TitleUpdate, bool IsSelected), TitleUpdateModel> TitleUpdates; public IObservableCache<(TitleUpdateModel TitleUpdate, bool IsSelected), TitleUpdateModel> TitleUpdates;
@ -553,6 +549,7 @@ namespace Ryujinx.UI.App.Common
{ {
Logger.Warning?.Print(LogClass.Application, $"The file encountered was not of a valid type. File: '{filePath}' Error: {exception}"); Logger.Warning?.Print(LogClass.Application, $"The file encountered was not of a valid type. File: '{filePath}' Error: {exception}");
} }
return false; return false;
} }
@ -1056,16 +1053,6 @@ namespace Ryujinx.UI.App.Common
ApplicationCountUpdated?.Invoke(null, e); ApplicationCountUpdated?.Invoke(null, e);
} }
protected void OnTitleUpdateAdded(TitleUpdateAddedEventArgs e)
{
TitleUpdateAdded?.Invoke(null, e);
}
protected void OnDownloadableContentAdded(DownloadableContentAddedEventArgs e)
{
DownloadableContentAdded?.Invoke(null, e);
}
public static ApplicationMetadata LoadAndSaveMetaData(string titleId, Action<ApplicationMetadata> modifyFunction = null) public static ApplicationMetadata LoadAndSaveMetaData(string titleId, Action<ApplicationMetadata> modifyFunction = null)
{ {
string metadataFolder = Path.Combine(AppDataManager.GamesDirPath, titleId, "gui"); string metadataFolder = Path.Combine(AppDataManager.GamesDirPath, titleId, "gui");

View File

@ -1,10 +0,0 @@
using Ryujinx.UI.Common.Models;
using System;
namespace Ryujinx.UI.App.Common
{
public class DownloadableContentAddedEventArgs : EventArgs
{
public DownloadableContentModel DownloadableContent { get; set; }
}
}

View File

@ -1,10 +0,0 @@
using Ryujinx.UI.Common.Models;
using System;
namespace Ryujinx.UI.App.Common
{
public class TitleUpdateAddedEventArgs : EventArgs
{
public TitleUpdateModel TitleUpdate { get; set; }
}
}

View File

@ -6,6 +6,7 @@ using Avalonia.Media;
using Avalonia.Platform.Storage; using Avalonia.Platform.Storage;
using Avalonia.Threading; using Avalonia.Threading;
using DynamicData; using DynamicData;
using DynamicData.Alias;
using DynamicData.Binding; using DynamicData.Binding;
using LibHac.Common; using LibHac.Common;
using Ryujinx.Ava.Common; using Ryujinx.Ava.Common;
@ -50,7 +51,7 @@ namespace Ryujinx.Ava.UI.ViewModels
{ {
private const int HotKeyPressDelayMs = 500; private const int HotKeyPressDelayMs = 500;
private ObservableCollection<ApplicationData> _applications; private ObservableCollectionExtended<ApplicationData> _applications;
private string _aspectStatusText; private string _aspectStatusText;
private string _loadHeading; private string _loadHeading;
@ -112,8 +113,8 @@ namespace Ryujinx.Ava.UI.ViewModels
public MainWindowViewModel() public MainWindowViewModel()
{ {
Applications = new ObservableCollection<ApplicationData>(); Applications = new ObservableCollectionExtended<ApplicationData>();
Applications.ToObservableChangeSet() Applications.ToObservableChangeSet()
.Filter(Filter) .Filter(Filter)
.Sort(GetComparer()) .Sort(GetComparer())
@ -741,7 +742,7 @@ namespace Ryujinx.Ava.UI.ViewModels
get => FileAssociationHelper.IsTypeAssociationSupported; get => FileAssociationHelper.IsTypeAssociationSupported;
} }
public ObservableCollection<ApplicationData> Applications public ObservableCollectionExtended<ApplicationData> Applications
{ {
get => _applications; get => _applications;
set set

View File

@ -53,7 +53,7 @@ namespace Ryujinx.Ava.UI.Views.Main
{ {
Window.LoadApplications(); Window.LoadApplications();
} }
private void VolumeStatus_OnPointerWheelChanged(object sender, PointerWheelEventArgs e) private void VolumeStatus_OnPointerWheelChanged(object sender, PointerWheelEventArgs e)
{ {
// Change the volume by 5% at a time // Change the volume by 5% at a time

View File

@ -4,6 +4,7 @@ using Avalonia.Controls.Primitives;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Platform; using Avalonia.Platform;
using Avalonia.Threading; using Avalonia.Threading;
using DynamicData;
using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Controls;
using LibHac.Tools.FsSystem; using LibHac.Tools.FsSystem;
using Ryujinx.Ava.Common; using Ryujinx.Ava.Common;
@ -26,6 +27,7 @@ using Ryujinx.UI.Common.Configuration;
using Ryujinx.UI.Common.Helper; using Ryujinx.UI.Common.Helper;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reactive.Linq;
using System.Runtime.Versioning; using System.Runtime.Versioning;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -45,6 +47,7 @@ namespace Ryujinx.Ava.UI.Windows
private static string _launchApplicationId; private static string _launchApplicationId;
private static bool _startFullscreen; private static bool _startFullscreen;
internal readonly AvaHostUIHandler UiHandler; internal readonly AvaHostUIHandler UiHandler;
private IDisposable _appLibraryAppsSubscription;
public VirtualFileSystem VirtualFileSystem { get; private set; } public VirtualFileSystem VirtualFileSystem { get; private set; }
public ContentManager ContentManager { get; private set; } public ContentManager ContentManager { get; private set; }
@ -136,26 +139,6 @@ namespace Ryujinx.Ava.UI.Windows
Program.DesktopScaleFactor = this.RenderScaling; Program.DesktopScaleFactor = this.RenderScaling;
} }
private void ApplicationLibrary_ApplicationAdded(object sender, ApplicationAddedEventArgs e)
{
Dispatcher.UIThread.Post(() =>
{
ViewModel.Applications.Add(e.AppData);
});
}
private void ApplicationLibrary_DownloadableContentAdded(object sender, DownloadableContentAddedEventArgs e)
{
var it = e.DownloadableContent;
Console.WriteLine("[{0}]: {1} ({2})", it.TitleIdBase, it.ContainerPath, it.FullPath);
}
private void ApplicationLibrary_TitleUpdateAdded(object sender, TitleUpdateAddedEventArgs e)
{
var it = e.TitleUpdate;
Console.WriteLine("[{0}]: {1}", it.TitleIdBase, it.Path);
}
private void ApplicationLibrary_ApplicationCountUpdated(object sender, ApplicationCountUpdatedEventArgs e) private void ApplicationLibrary_ApplicationCountUpdated(object sender, ApplicationCountUpdatedEventArgs e)
{ {
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.StatusBarGamesLoaded, e.NumAppsLoaded, e.NumAppsFound); LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.StatusBarGamesLoaded, e.NumAppsLoaded, e.NumAppsFound);
@ -484,7 +467,12 @@ namespace Ryujinx.Ava.UI.Windows
this); this);
ApplicationLibrary.ApplicationCountUpdated += ApplicationLibrary_ApplicationCountUpdated; ApplicationLibrary.ApplicationCountUpdated += ApplicationLibrary_ApplicationCountUpdated;
ApplicationLibrary.ApplicationAdded += ApplicationLibrary_ApplicationAdded; _appLibraryAppsSubscription?.Dispose();
_appLibraryAppsSubscription = ApplicationLibrary.Applications
.Connect()
.ObserveOn(SynchronizationContext.Current)
.Bind(ViewModel.Applications)
.Subscribe();
ViewModel.RefreshFirmwareStatus(); ViewModel.RefreshFirmwareStatus();
@ -587,6 +575,7 @@ namespace Ryujinx.Ava.UI.Windows
ApplicationLibrary.CancelLoading(); ApplicationLibrary.CancelLoading();
InputManager.Dispose(); InputManager.Dispose();
_appLibraryAppsSubscription?.Dispose();
Program.Exit(); Program.Exit();
base.OnClosing(e); base.OnClosing(e);
@ -608,7 +597,6 @@ namespace Ryujinx.Ava.UI.Windows
public void LoadApplications() public void LoadApplications()
{ {
_applicationsLoadedOnce = true; _applicationsLoadedOnce = true;
ViewModel.Applications.Clear();
StatusBarView.LoadProgressBar.IsVisible = true; StatusBarView.LoadProgressBar.IsVisible = true;
ViewModel.StatusBarProgressMaximum = 0; ViewModel.StatusBarProgressMaximum = 0;