Skip to content

Commit

Permalink
misc: More cleanup changes
Browse files Browse the repository at this point in the history
  • Loading branch information
GreemDev committed Oct 17, 2024
1 parent 1800ecc commit a13cf09
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
41 changes: 16 additions & 25 deletions src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Avalonia.Platform.Storage;
using Avalonia.Threading;
using DynamicData;
using DynamicData.Alias;
using DynamicData.Binding;
using FluentAvalonia.UI.Controls;
using LibHac.Common;
Expand Down Expand Up @@ -115,12 +114,13 @@ public class MainWindowViewModel : BaseModel

public MainWindowViewModel()
{
Applications = new ObservableCollectionExtended<ApplicationData>();
Applications = [];

Applications.ToObservableChangeSet()
.Filter(Filter)
.Sort(GetComparer())
.Bind(out _appsObservableList).AsObservableList();
.Bind(out _appsObservableList)
.AsObservableList();

_rendererWaitEvent = new AutoResetEvent(false);

Expand Down Expand Up @@ -1114,7 +1114,7 @@ private async Task HandleFirmwareInstallation(string filename)

private void ProgressHandler<T>(T state, int current, int total) where T : Enum
{
Dispatcher.UIThread.Post((() =>
Dispatcher.UIThread.Post(() =>
{
ProgressMaximum = total;
ProgressValue = current;
Expand Down Expand Up @@ -1160,7 +1160,7 @@ private void ProgressHandler<T>(T state, int current, int total) where T : Enum
default:
throw new ArgumentException($"Unknown Progress Handler type {typeof(T)}");
}
}));
});
}

private void PrepareLoadScreen()
Expand Down Expand Up @@ -1231,15 +1231,15 @@ private void Update_StatusBar(object sender, StatusUpdatedEventArgs args)
{
Dispatcher.UIThread.InvokeAsync(() =>
{
Application.Current.Styles.TryGetResource(args.VSyncEnabled
Application.Current!.Styles.TryGetResource(args.VSyncEnabled
? "VsyncEnabled"
: "VsyncDisabled",
Application.Current.ActualThemeVariant,
out object color);
if (color is not null)
if (color is Color clr)
{
VsyncColor = new SolidColorBrush((Color)color);
VsyncColor = new SolidColorBrush(clr);
}
DockedStatusText = args.DockedMode;
Expand Down Expand Up @@ -1534,14 +1534,12 @@ public async Task OpenFile()

public async Task LoadDlcFromFolder()
{
await LoadContentFromFolder(LocaleKeys.AutoloadDlcAddedMessage,
dirs => ApplicationLibrary.AutoLoadDownloadableContents(dirs));
await LoadContentFromFolder(LocaleKeys.AutoloadDlcAddedMessage, ApplicationLibrary.AutoLoadDownloadableContents);
}

public async Task LoadTitleUpdatesFromFolder()
{
await LoadContentFromFolder(LocaleKeys.AutoloadUpdateAddedMessage,
dirs => ApplicationLibrary.AutoLoadTitleUpdates(dirs));
await LoadContentFromFolder(LocaleKeys.AutoloadUpdateAddedMessage, ApplicationLibrary.AutoLoadTitleUpdates);
}

public async Task OpenFolder()
Expand Down Expand Up @@ -1655,7 +1653,10 @@ public void RefreshFirmwareStatus()
{
version = ContentManager.GetCurrentFirmwareVersion();
}
catch (Exception) { }
catch (Exception)
{
// ignored
}

bool hasApplet = false;

Expand Down Expand Up @@ -1752,12 +1753,7 @@ public static async Task PerformanceCheck()
string mainMessage = LocaleManager.Instance[LocaleKeys.DialogPerformanceCheckLoggingEnabledMessage];
string secondaryMessage = LocaleManager.Instance[LocaleKeys.DialogPerformanceCheckLoggingEnabledConfirmMessage];

UserResult result = await ContentDialogHelper.CreateConfirmationDialog(
mainMessage,
secondaryMessage,
LocaleManager.Instance[LocaleKeys.InputDialogYes],
LocaleManager.Instance[LocaleKeys.InputDialogNo],
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
UserResult result = await ContentDialogHelper.CreateLocalizedConfirmationDialog(mainMessage, secondaryMessage);

if (result == UserResult.Yes)
{
Expand All @@ -1772,12 +1768,7 @@ public static async Task PerformanceCheck()
string mainMessage = LocaleManager.Instance[LocaleKeys.DialogPerformanceCheckShaderDumpEnabledMessage];
string secondaryMessage = LocaleManager.Instance[LocaleKeys.DialogPerformanceCheckShaderDumpEnabledConfirmMessage];

UserResult result = await ContentDialogHelper.CreateConfirmationDialog(
mainMessage,
secondaryMessage,
LocaleManager.Instance[LocaleKeys.InputDialogYes],
LocaleManager.Instance[LocaleKeys.InputDialogNo],
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
UserResult result = await ContentDialogHelper.CreateLocalizedConfirmationDialog(mainMessage, secondaryMessage);

if (result == UserResult.Yes)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Ryujinx/UI/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -455,14 +455,14 @@ public void LoadCurrentConfiguration()

// Graphics
GraphicsBackendIndex = (int)config.Graphics.GraphicsBackend.Value;
// Physical devices are queried asynchronously hence the prefered index config value is loaded in LoadAvailableGpus().
// Physical devices are queried asynchronously hence the preferred index config value is loaded in LoadAvailableGpus().
EnableShaderCache = config.Graphics.EnableShaderCache;
EnableTextureRecompression = config.Graphics.EnableTextureRecompression;
EnableMacroHLE = config.Graphics.EnableMacroHLE;
EnableColorSpacePassthrough = config.Graphics.EnableColorSpacePassthrough;
ResolutionScale = config.Graphics.ResScale == -1 ? 4 : config.Graphics.ResScale - 1;
CustomResolutionScale = config.Graphics.ResScaleCustom;
MaxAnisotropy = config.Graphics.MaxAnisotropy == -1 ? 0 : (int)(MathF.Log2(config.Graphics.MaxAnisotropy));
MaxAnisotropy = config.Graphics.MaxAnisotropy == -1 ? 0 : (int)MathF.Log2(config.Graphics.MaxAnisotropy);
AspectRatio = (int)config.Graphics.AspectRatio.Value;
GraphicsBackendMultithreadingIndex = (int)config.Graphics.BackendThreading.Value;
ShaderDumpPath = config.Graphics.ShadersDumpPath;
Expand Down

0 comments on commit a13cf09

Please sign in to comment.