[Ryujinx.Ui.Common] Address dotnet-format issues (#5392)

* dotnet format style --severity info

Some changes were manually reverted.

* dotnet format analyzers --serverity info

Some changes have been minimally adapted.

* Silence dotnet format IDE0060 warnings

* Address dotnet format CA1401 warnings

* dotnet-format fixes after rebase

* Address most dotnet format whitespace warnings

* Apply dotnet format whitespace formatting

A few of them have been manually reverted and the corresponding warning was silenced

* Another rebase, another dotnet format run

* Run dotnet format style after rebase

* Add comments to disabled warnings

* Remove a few unused parameters

* Simplify properties and array initialization, Use const when possible, Remove trailing commas

* Address IDE0251 warnings

* Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas"

This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e.

* dotnet format whitespace after rebase

* Small optimizations

* Remove alignment

* Apply formatting

* Fix build issues

* Final pass for dotnet format

* Add trailing commas

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Add trailing commas

---------

Co-authored-by: Ac_K <Acoustik666@gmail.com>
This commit is contained in:
TSRBerry 2023-06-29 02:39:22 +02:00 committed by GitHub
parent 7c989f88bd
commit 6e28a4dd13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 761 additions and 696 deletions

View file

@ -32,6 +32,7 @@ using Ryujinx.HLE.HOS.Services.Account.Acc;
using Ryujinx.HLE.HOS.SystemState; using Ryujinx.HLE.HOS.SystemState;
using Ryujinx.Input; using Ryujinx.Input;
using Ryujinx.Input.HLE; using Ryujinx.Input.HLE;
using Ryujinx.Ui.App.Common;
using Ryujinx.Ui.Common; using Ryujinx.Ui.Common;
using Ryujinx.Ui.Common.Configuration; using Ryujinx.Ui.Common.Configuration;
using Ryujinx.Ui.Common.Helper; using Ryujinx.Ui.Common.Helper;
@ -692,7 +693,7 @@ namespace Ryujinx.Ava
DiscordIntegrationModule.SwitchToPlayingState(Device.Processes.ActiveApplication.ProgramIdText, Device.Processes.ActiveApplication.Name); DiscordIntegrationModule.SwitchToPlayingState(Device.Processes.ActiveApplication.ProgramIdText, Device.Processes.ActiveApplication.Name);
_viewModel.ApplicationLibrary.LoadAndSaveMetaData(Device.Processes.ActiveApplication.ProgramIdText, appMetadata => ApplicationLibrary.LoadAndSaveMetaData(Device.Processes.ActiveApplication.ProgramIdText, appMetadata =>
{ {
appMetadata.LastPlayed = DateTime.UtcNow; appMetadata.LastPlayed = DateTime.UtcNow;
}); });

View file

@ -42,7 +42,7 @@ namespace Ryujinx.Ava.UI.Controls
{ {
viewModel.SelectedApplication.Favorite = !viewModel.SelectedApplication.Favorite; viewModel.SelectedApplication.Favorite = !viewModel.SelectedApplication.Favorite;
viewModel.ApplicationLibrary.LoadAndSaveMetaData(viewModel.SelectedApplication.TitleId, appMetadata => ApplicationLibrary.LoadAndSaveMetaData(viewModel.SelectedApplication.TitleId, appMetadata =>
{ {
appMetadata.Favorite = viewModel.SelectedApplication.Favorite; appMetadata.Favorite = viewModel.SelectedApplication.Favorite;
}); });

View file

@ -3,6 +3,7 @@ using LibHac.Ncm;
using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Ava.UI.Windows; using Ryujinx.Ava.UI.Windows;
using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.FileSystem;
using Ryujinx.Ui.App.Common;
using System; using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -74,7 +75,7 @@ namespace Ryujinx.Ava.UI.Models
} }
else else
{ {
var appMetadata = MainWindow.MainWindowViewModel.ApplicationLibrary.LoadAndSaveMetaData(TitleIdString); var appMetadata = ApplicationLibrary.LoadAndSaveMetaData(TitleIdString);
Title = appMetadata.Title ?? TitleIdString; Title = appMetadata.Title ?? TitleIdString;
} }

View file

@ -239,28 +239,28 @@ namespace Ryujinx.Ava.UI.Renderer
IPlatformHandle CreateMacOS() IPlatformHandle CreateMacOS()
{ {
// Create a new CAMetalLayer. // Create a new CAMetalLayer.
IntPtr layerClass = ObjectiveC.objc_getClass("CAMetalLayer"); ObjectiveC.Object layerObject = new("CAMetalLayer");
IntPtr metalLayer = ObjectiveC.IntPtr_objc_msgSend(layerClass, "alloc"); ObjectiveC.Object metalLayer = layerObject.GetFromMessage("alloc");
ObjectiveC.objc_msgSend(metalLayer, "init"); metalLayer.SendMessage("init");
// Create a child NSView to render into. // Create a child NSView to render into.
IntPtr nsViewClass = ObjectiveC.objc_getClass("NSView"); ObjectiveC.Object nsViewObject = new("NSView");
IntPtr child = ObjectiveC.IntPtr_objc_msgSend(nsViewClass, "alloc"); ObjectiveC.Object child = nsViewObject.GetFromMessage("alloc");
ObjectiveC.objc_msgSend(child, "init", new ObjectiveC.NSRect(0, 0, 0, 0)); child.SendMessage("init", new ObjectiveC.NSRect(0, 0, 0, 0));
// Make its renderer our metal layer. // Make its renderer our metal layer.
ObjectiveC.objc_msgSend(child, "setWantsLayer:", 1); child.SendMessage("setWantsLayer:", 1);
ObjectiveC.objc_msgSend(child, "setLayer:", metalLayer); child.SendMessage("setLayer:", metalLayer);
ObjectiveC.objc_msgSend(metalLayer, "setContentsScale:", Program.DesktopScaleFactor); metalLayer.SendMessage("setContentsScale:", Program.DesktopScaleFactor);
// Ensure the scale factor is up to date. // Ensure the scale factor is up to date.
_updateBoundsCallback = rect => _updateBoundsCallback = rect =>
{ {
ObjectiveC.objc_msgSend(metalLayer, "setContentsScale:", Program.DesktopScaleFactor); metalLayer.SendMessage("setContentsScale:", Program.DesktopScaleFactor);
}; };
IntPtr nsView = child; IntPtr nsView = child.ObjPtr;
MetalLayer = metalLayer; MetalLayer = metalLayer.ObjPtr;
NsView = nsView; NsView = nsView;
return new PlatformHandle(nsView, "NSView"); return new PlatformHandle(nsView, "NSView");

View file

@ -159,7 +159,7 @@ namespace Ryujinx.Ui.App.Common
codeFs.OpenFile(ref nsoFile.Ref, $"/{MainExeFs}".ToU8Span(), OpenMode.Read).ThrowIfFailure(); codeFs.OpenFile(ref nsoFile.Ref, $"/{MainExeFs}".ToU8Span(), OpenMode.Read).ThrowIfFailure();
NsoReader reader = new NsoReader(); NsoReader reader = new();
reader.Initialize(nsoFile.Release().AsStorage().AsFile(OpenMode.Read)).ThrowIfFailure(); reader.Initialize(nsoFile.Release().AsStorage().AsFile(OpenMode.Read)).ThrowIfFailure();
return BitConverter.ToString(reader.Header.ModuleId.ItemsRo.ToArray()).Replace("-", "").ToUpper()[..16]; return BitConverter.ToString(reader.Header.ModuleId.ItemsRo.ToArray()).Replace("-", "").ToUpper()[..16];

View file

@ -26,6 +26,7 @@ using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Threading; using System.Threading;
using Path = System.IO.Path; using Path = System.IO.Path;
using TimeSpan = System.TimeSpan;
namespace Ryujinx.Ui.App.Common namespace Ryujinx.Ui.App.Common
{ {
@ -44,8 +45,8 @@ namespace Ryujinx.Ui.App.Common
private Language _desiredTitleLanguage; private Language _desiredTitleLanguage;
private CancellationTokenSource _cancellationToken; private CancellationTokenSource _cancellationToken;
private static readonly ApplicationJsonSerializerContext SerializerContext = new(JsonHelper.GetDefaultSerializerOptions()); private static readonly ApplicationJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
private static readonly TitleUpdateMetadataJsonSerializerContext TitleSerializerContext = new(JsonHelper.GetDefaultSerializerOptions()); private static readonly TitleUpdateMetadataJsonSerializerContext _titleSerializerContext = new(JsonHelper.GetDefaultSerializerOptions());
public ApplicationLibrary(VirtualFileSystem virtualFileSystem) public ApplicationLibrary(VirtualFileSystem virtualFileSystem)
{ {
@ -459,27 +460,27 @@ namespace Ryujinx.Ui.App.Common
FileSize = (fileSize < 1) ? (fileSize * 1024).ToString("0.##") + " MiB" : fileSize.ToString("0.##") + " GiB", FileSize = (fileSize < 1) ? (fileSize * 1024).ToString("0.##") + " MiB" : fileSize.ToString("0.##") + " GiB",
FileSizeBytes = fileSize, FileSizeBytes = fileSize,
Path = applicationPath, Path = applicationPath,
ControlHolder = controlHolder ControlHolder = controlHolder,
}; };
numApplicationsLoaded++; numApplicationsLoaded++;
OnApplicationAdded(new ApplicationAddedEventArgs() OnApplicationAdded(new ApplicationAddedEventArgs
{ {
AppData = data AppData = data,
}); });
OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs() OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs
{ {
NumAppsFound = numApplicationsFound, NumAppsFound = numApplicationsFound,
NumAppsLoaded = numApplicationsLoaded NumAppsLoaded = numApplicationsLoaded,
}); });
} }
OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs() OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs
{ {
NumAppsFound = numApplicationsFound, NumAppsFound = numApplicationsFound,
NumAppsLoaded = numApplicationsLoaded NumAppsLoaded = numApplicationsLoaded,
}); });
} }
finally finally
@ -508,7 +509,7 @@ namespace Ryujinx.Ui.App.Common
titleId = controlNca?.Header.TitleId.ToString("x16"); titleId = controlNca?.Header.TitleId.ToString("x16");
} }
public 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");
string metadataFile = Path.Combine(metadataFolder, "metadata.json"); string metadataFile = Path.Combine(metadataFolder, "metadata.json");
@ -521,12 +522,12 @@ namespace Ryujinx.Ui.App.Common
appMetadata = new ApplicationMetadata(); appMetadata = new ApplicationMetadata();
JsonHelper.SerializeToFile(metadataFile, appMetadata, SerializerContext.ApplicationMetadata); JsonHelper.SerializeToFile(metadataFile, appMetadata, _serializerContext.ApplicationMetadata);
} }
try try
{ {
appMetadata = JsonHelper.DeserializeFromFile(metadataFile, SerializerContext.ApplicationMetadata); appMetadata = JsonHelper.DeserializeFromFile(metadataFile, _serializerContext.ApplicationMetadata);
} }
catch (JsonException) catch (JsonException)
{ {
@ -539,7 +540,7 @@ namespace Ryujinx.Ui.App.Common
{ {
modifyFunction(appMetadata); modifyFunction(appMetadata);
JsonHelper.SerializeToFile(metadataFile, appMetadata, SerializerContext.ApplicationMetadata); JsonHelper.SerializeToFile(metadataFile, appMetadata, _serializerContext.ApplicationMetadata);
} }
return appMetadata; return appMetadata;
@ -713,7 +714,7 @@ namespace Ryujinx.Ui.App.Common
private static string ConvertSecondsToFormattedString(double seconds) private static string ConvertSecondsToFormattedString(double seconds)
{ {
System.TimeSpan time = System.TimeSpan.FromSeconds(seconds); TimeSpan time = TimeSpan.FromSeconds(seconds);
string timeString; string timeString;
if (time.Days != 0) if (time.Days != 0)
@ -840,7 +841,7 @@ namespace Ryujinx.Ui.App.Common
pfs.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure(); pfs.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
Nca nca = new Nca(fileSystem.KeySet, ncaFile.Release().AsStorage()); Nca nca = new(fileSystem.KeySet, ncaFile.Release().AsStorage());
int ncaProgramIndex = (int)(nca.Header.TitleId & 0xF); int ncaProgramIndex = (int)(nca.Header.TitleId & 0xF);
@ -884,7 +885,7 @@ namespace Ryujinx.Ui.App.Common
pfs.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure(); pfs.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
Nca nca = new Nca(fileSystem.KeySet, ncaFile.Release().AsStorage()); Nca nca = new(fileSystem.KeySet, ncaFile.Release().AsStorage());
int ncaProgramIndex = (int)(nca.Header.TitleId & 0xF); int ncaProgramIndex = (int)(nca.Header.TitleId & 0xF);
@ -925,12 +926,12 @@ namespace Ryujinx.Ui.App.Common
if (File.Exists(titleUpdateMetadataPath)) if (File.Exists(titleUpdateMetadataPath))
{ {
updatePath = JsonHelper.DeserializeFromFile(titleUpdateMetadataPath, TitleSerializerContext.TitleUpdateMetadata).Selected; updatePath = JsonHelper.DeserializeFromFile(titleUpdateMetadataPath, _titleSerializerContext.TitleUpdateMetadata).Selected;
if (File.Exists(updatePath)) if (File.Exists(updatePath))
{ {
FileStream file = new FileStream(updatePath, FileMode.Open, FileAccess.Read); FileStream file = new(updatePath, FileMode.Open, FileAccess.Read);
PartitionFileSystem nsp = new PartitionFileSystem(file.AsStorage()); PartitionFileSystem nsp = new(file.AsStorage());
return GetGameUpdateDataFromPartition(fileSystem, nsp, titleIdBase.ToString("x16"), programIndex); return GetGameUpdateDataFromPartition(fileSystem, nsp, titleIdBase.ToString("x16"), programIndex);
} }
@ -941,4 +942,3 @@ namespace Ryujinx.Ui.App.Common
} }
} }
} }

View file

@ -9,6 +9,6 @@ namespace Ryujinx.Ui.Common.Configuration
Dummy, Dummy,
OpenAl, OpenAl,
SoundIo, SoundIo,
SDL2 SDL2,
} }
} }

View file

@ -4,6 +4,6 @@ namespace Ryujinx.Ui.Common.Configuration
{ {
Success = 0, Success = 0,
NotLoaded = 1, NotLoaded = 1,
MigratedFromPreVulkan = 1 << 8 MigratedFromPreVulkan = 1 << 8,
} }
} }

View file

@ -278,7 +278,7 @@ namespace Ryujinx.Ui.Common.Configuration
EnableFsAccessLog = new ReactiveObject<bool>(); EnableFsAccessLog = new ReactiveObject<bool>();
FilteredClasses = new ReactiveObject<LogClass[]>(); FilteredClasses = new ReactiveObject<LogClass[]>();
EnableFileLog = new ReactiveObject<bool>(); EnableFileLog = new ReactiveObject<bool>();
EnableFileLog.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableFileLog)); EnableFileLog.Event += static (sender, e) => LogValueChange(e, nameof(EnableFileLog));
GraphicsDebugLevel = new ReactiveObject<GraphicsDebugLevel>(); GraphicsDebugLevel = new ReactiveObject<GraphicsDebugLevel>();
} }
} }
@ -370,27 +370,27 @@ namespace Ryujinx.Ui.Common.Configuration
TimeZone = new ReactiveObject<string>(); TimeZone = new ReactiveObject<string>();
SystemTimeOffset = new ReactiveObject<long>(); SystemTimeOffset = new ReactiveObject<long>();
EnableDockedMode = new ReactiveObject<bool>(); EnableDockedMode = new ReactiveObject<bool>();
EnableDockedMode.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableDockedMode)); EnableDockedMode.Event += static (sender, e) => LogValueChange(e, nameof(EnableDockedMode));
EnablePtc = new ReactiveObject<bool>(); EnablePtc = new ReactiveObject<bool>();
EnablePtc.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnablePtc)); EnablePtc.Event += static (sender, e) => LogValueChange(e, nameof(EnablePtc));
EnableInternetAccess = new ReactiveObject<bool>(); EnableInternetAccess = new ReactiveObject<bool>();
EnableInternetAccess.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableInternetAccess)); EnableInternetAccess.Event += static (sender, e) => LogValueChange(e, nameof(EnableInternetAccess));
EnableFsIntegrityChecks = new ReactiveObject<bool>(); EnableFsIntegrityChecks = new ReactiveObject<bool>();
EnableFsIntegrityChecks.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableFsIntegrityChecks)); EnableFsIntegrityChecks.Event += static (sender, e) => LogValueChange(e, nameof(EnableFsIntegrityChecks));
FsGlobalAccessLogMode = new ReactiveObject<int>(); FsGlobalAccessLogMode = new ReactiveObject<int>();
FsGlobalAccessLogMode.Event += static (sender, e) => LogValueChange(sender, e, nameof(FsGlobalAccessLogMode)); FsGlobalAccessLogMode.Event += static (sender, e) => LogValueChange(e, nameof(FsGlobalAccessLogMode));
AudioBackend = new ReactiveObject<AudioBackend>(); AudioBackend = new ReactiveObject<AudioBackend>();
AudioBackend.Event += static (sender, e) => LogValueChange(sender, e, nameof(AudioBackend)); AudioBackend.Event += static (sender, e) => LogValueChange(e, nameof(AudioBackend));
MemoryManagerMode = new ReactiveObject<MemoryManagerMode>(); MemoryManagerMode = new ReactiveObject<MemoryManagerMode>();
MemoryManagerMode.Event += static (sender, e) => LogValueChange(sender, e, nameof(MemoryManagerMode)); MemoryManagerMode.Event += static (sender, e) => LogValueChange(e, nameof(MemoryManagerMode));
ExpandRam = new ReactiveObject<bool>(); ExpandRam = new ReactiveObject<bool>();
ExpandRam.Event += static (sender, e) => LogValueChange(sender, e, nameof(ExpandRam)); ExpandRam.Event += static (sender, e) => LogValueChange(e, nameof(ExpandRam));
IgnoreMissingServices = new ReactiveObject<bool>(); IgnoreMissingServices = new ReactiveObject<bool>();
IgnoreMissingServices.Event += static (sender, e) => LogValueChange(sender, e, nameof(IgnoreMissingServices)); IgnoreMissingServices.Event += static (sender, e) => LogValueChange(e, nameof(IgnoreMissingServices));
AudioVolume = new ReactiveObject<float>(); AudioVolume = new ReactiveObject<float>();
AudioVolume.Event += static (sender, e) => LogValueChange(sender, e, nameof(AudioVolume)); AudioVolume.Event += static (sender, e) => LogValueChange(e, nameof(AudioVolume));
UseHypervisor = new ReactiveObject<bool>(); UseHypervisor = new ReactiveObject<bool>();
UseHypervisor.Event += static (sender, e) => LogValueChange(sender, e, nameof(UseHypervisor)); UseHypervisor.Event += static (sender, e) => LogValueChange(e, nameof(UseHypervisor));
} }
} }
@ -513,34 +513,34 @@ namespace Ryujinx.Ui.Common.Configuration
public GraphicsSection() public GraphicsSection()
{ {
BackendThreading = new ReactiveObject<BackendThreading>(); BackendThreading = new ReactiveObject<BackendThreading>();
BackendThreading.Event += static (sender, e) => LogValueChange(sender, e, nameof(BackendThreading)); BackendThreading.Event += static (sender, e) => LogValueChange(e, nameof(BackendThreading));
ResScale = new ReactiveObject<int>(); ResScale = new ReactiveObject<int>();
ResScale.Event += static (sender, e) => LogValueChange(sender, e, nameof(ResScale)); ResScale.Event += static (sender, e) => LogValueChange(e, nameof(ResScale));
ResScaleCustom = new ReactiveObject<float>(); ResScaleCustom = new ReactiveObject<float>();
ResScaleCustom.Event += static (sender, e) => LogValueChange(sender, e, nameof(ResScaleCustom)); ResScaleCustom.Event += static (sender, e) => LogValueChange(e, nameof(ResScaleCustom));
MaxAnisotropy = new ReactiveObject<float>(); MaxAnisotropy = new ReactiveObject<float>();
MaxAnisotropy.Event += static (sender, e) => LogValueChange(sender, e, nameof(MaxAnisotropy)); MaxAnisotropy.Event += static (sender, e) => LogValueChange(e, nameof(MaxAnisotropy));
AspectRatio = new ReactiveObject<AspectRatio>(); AspectRatio = new ReactiveObject<AspectRatio>();
AspectRatio.Event += static (sender, e) => LogValueChange(sender, e, nameof(AspectRatio)); AspectRatio.Event += static (sender, e) => LogValueChange(e, nameof(AspectRatio));
ShadersDumpPath = new ReactiveObject<string>(); ShadersDumpPath = new ReactiveObject<string>();
EnableVsync = new ReactiveObject<bool>(); EnableVsync = new ReactiveObject<bool>();
EnableVsync.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableVsync)); EnableVsync.Event += static (sender, e) => LogValueChange(e, nameof(EnableVsync));
EnableShaderCache = new ReactiveObject<bool>(); EnableShaderCache = new ReactiveObject<bool>();
EnableShaderCache.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableShaderCache)); EnableShaderCache.Event += static (sender, e) => LogValueChange(e, nameof(EnableShaderCache));
EnableTextureRecompression = new ReactiveObject<bool>(); EnableTextureRecompression = new ReactiveObject<bool>();
EnableTextureRecompression.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableTextureRecompression)); EnableTextureRecompression.Event += static (sender, e) => LogValueChange(e, nameof(EnableTextureRecompression));
GraphicsBackend = new ReactiveObject<GraphicsBackend>(); GraphicsBackend = new ReactiveObject<GraphicsBackend>();
GraphicsBackend.Event += static (sender, e) => LogValueChange(sender, e, nameof(GraphicsBackend)); GraphicsBackend.Event += static (sender, e) => LogValueChange(e, nameof(GraphicsBackend));
PreferredGpu = new ReactiveObject<string>(); PreferredGpu = new ReactiveObject<string>();
PreferredGpu.Event += static (sender, e) => LogValueChange(sender, e, nameof(PreferredGpu)); PreferredGpu.Event += static (sender, e) => LogValueChange(e, nameof(PreferredGpu));
EnableMacroHLE = new ReactiveObject<bool>(); EnableMacroHLE = new ReactiveObject<bool>();
EnableMacroHLE.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableMacroHLE)); EnableMacroHLE.Event += static (sender, e) => LogValueChange(e, nameof(EnableMacroHLE));
AntiAliasing = new ReactiveObject<AntiAliasing>(); AntiAliasing = new ReactiveObject<AntiAliasing>();
AntiAliasing.Event += static (sender, e) => LogValueChange(sender, e, nameof(AntiAliasing)); AntiAliasing.Event += static (sender, e) => LogValueChange(e, nameof(AntiAliasing));
ScalingFilter = new ReactiveObject<ScalingFilter>(); ScalingFilter = new ReactiveObject<ScalingFilter>();
ScalingFilter.Event += static (sender, e) => LogValueChange(sender, e, nameof(ScalingFilter)); ScalingFilter.Event += static (sender, e) => LogValueChange(e, nameof(ScalingFilter));
ScalingFilterLevel = new ReactiveObject<int>(); ScalingFilterLevel = new ReactiveObject<int>();
ScalingFilterLevel.Event += static (sender, e) => LogValueChange(sender, e, nameof(ScalingFilterLevel)); ScalingFilterLevel.Event += static (sender, e) => LogValueChange(e, nameof(ScalingFilterLevel));
} }
} }
@ -631,7 +631,7 @@ namespace Ryujinx.Ui.Common.Configuration
public ConfigurationFileFormat ToFileFormat() public ConfigurationFileFormat ToFileFormat()
{ {
ConfigurationFileFormat configurationFile = new ConfigurationFileFormat ConfigurationFileFormat configurationFile = new()
{ {
Version = ConfigurationFileFormat.CurrentVersion, Version = ConfigurationFileFormat.CurrentVersion,
BackendThreading = Graphics.BackendThreading, BackendThreading = Graphics.BackendThreading,
@ -688,12 +688,12 @@ namespace Ryujinx.Ui.Common.Configuration
LastPlayedColumn = Ui.GuiColumns.LastPlayedColumn, LastPlayedColumn = Ui.GuiColumns.LastPlayedColumn,
FileExtColumn = Ui.GuiColumns.FileExtColumn, FileExtColumn = Ui.GuiColumns.FileExtColumn,
FileSizeColumn = Ui.GuiColumns.FileSizeColumn, FileSizeColumn = Ui.GuiColumns.FileSizeColumn,
PathColumn = Ui.GuiColumns.PathColumn PathColumn = Ui.GuiColumns.PathColumn,
}, },
ColumnSort = new ColumnSort ColumnSort = new ColumnSort
{ {
SortColumnId = Ui.ColumnSort.SortColumnId, SortColumnId = Ui.ColumnSort.SortColumnId,
SortAscending = Ui.ColumnSort.SortAscending SortAscending = Ui.ColumnSort.SortAscending,
}, },
GameDirs = Ui.GameDirs, GameDirs = Ui.GameDirs,
ShownFileTypes = new ShownFileTypes ShownFileTypes = new ShownFileTypes
@ -732,7 +732,7 @@ namespace Ryujinx.Ui.Common.Configuration
InputConfig = Hid.InputConfig, InputConfig = Hid.InputConfig,
GraphicsBackend = Graphics.GraphicsBackend, GraphicsBackend = Graphics.GraphicsBackend,
PreferredGpu = Graphics.PreferredGpu, PreferredGpu = Graphics.PreferredGpu,
MultiplayerLanInterfaceId = Multiplayer.LanInterfaceId MultiplayerLanInterfaceId = Multiplayer.LanInterfaceId,
}; };
return configurationFile; return configurationFile;
@ -767,7 +767,7 @@ namespace Ryujinx.Ui.Common.Configuration
EnableDiscordIntegration.Value = true; EnableDiscordIntegration.Value = true;
CheckUpdatesOnStart.Value = true; CheckUpdatesOnStart.Value = true;
ShowConfirmExit.Value = true; ShowConfirmExit.Value = true;
HideCursor.Value = Ryujinx.Common.Configuration.HideCursorMode.Never; HideCursor.Value = HideCursorMode.Never;
Graphics.EnableVsync.Value = true; Graphics.EnableVsync.Value = true;
Graphics.EnableShaderCache.Value = true; Graphics.EnableShaderCache.Value = true;
Graphics.EnableTextureRecompression.Value = false; Graphics.EnableTextureRecompression.Value = false;
@ -833,7 +833,7 @@ namespace Ryujinx.Ui.Common.Configuration
ResScaleUp = Key.Unbound, ResScaleUp = Key.Unbound,
ResScaleDown = Key.Unbound, ResScaleDown = Key.Unbound,
VolumeUp = Key.Unbound, VolumeUp = Key.Unbound,
VolumeDown = Key.Unbound VolumeDown = Key.Unbound,
}; };
Hid.InputConfig.Value = new List<InputConfig> Hid.InputConfig.Value = new List<InputConfig>
{ {
@ -854,9 +854,8 @@ namespace Ryujinx.Ui.Common.Configuration
ButtonL = Key.E, ButtonL = Key.E,
ButtonZl = Key.Q, ButtonZl = Key.Q,
ButtonSl = Key.Unbound, ButtonSl = Key.Unbound,
ButtonSr = Key.Unbound ButtonSr = Key.Unbound,
}, },
LeftJoyconStick = new JoyconConfigKeyboardStick<Key> LeftJoyconStick = new JoyconConfigKeyboardStick<Key>
{ {
StickUp = Key.W, StickUp = Key.W,
@ -865,7 +864,6 @@ namespace Ryujinx.Ui.Common.Configuration
StickRight = Key.D, StickRight = Key.D,
StickButton = Key.F, StickButton = Key.F,
}, },
RightJoycon = new RightJoyconCommonConfig<Key> RightJoycon = new RightJoyconCommonConfig<Key>
{ {
ButtonA = Key.Z, ButtonA = Key.Z,
@ -876,9 +874,8 @@ namespace Ryujinx.Ui.Common.Configuration
ButtonR = Key.U, ButtonR = Key.U,
ButtonZr = Key.O, ButtonZr = Key.O,
ButtonSl = Key.Unbound, ButtonSl = Key.Unbound,
ButtonSr = Key.Unbound ButtonSr = Key.Unbound,
}, },
RightJoyconStick = new JoyconConfigKeyboardStick<Key> RightJoyconStick = new JoyconConfigKeyboardStick<Key>
{ {
StickUp = Key.I, StickUp = Key.I,
@ -886,8 +883,8 @@ namespace Ryujinx.Ui.Common.Configuration
StickLeft = Key.J, StickLeft = Key.J,
StickRight = Key.L, StickRight = Key.L,
StickButton = Key.H, StickButton = Key.H,
} },
} },
}; };
} }
@ -958,12 +955,12 @@ namespace Ryujinx.Ui.Common.Configuration
configurationFileFormat.ColumnSort = new ColumnSort configurationFileFormat.ColumnSort = new ColumnSort
{ {
SortColumnId = 0, SortColumnId = 0,
SortAscending = false SortAscending = false,
}; };
configurationFileFormat.Hotkeys = new KeyboardHotkeys configurationFileFormat.Hotkeys = new KeyboardHotkeys
{ {
ToggleVsync = Key.F1 ToggleVsync = Key.F1,
}; };
configurationFileUpdated = true; configurationFileUpdated = true;
@ -1074,9 +1071,8 @@ namespace Ryujinx.Ui.Common.Configuration
ButtonL = Key.E, ButtonL = Key.E,
ButtonZl = Key.Q, ButtonZl = Key.Q,
ButtonSl = Key.Unbound, ButtonSl = Key.Unbound,
ButtonSr = Key.Unbound ButtonSr = Key.Unbound,
}, },
LeftJoyconStick = new JoyconConfigKeyboardStick<Key> LeftJoyconStick = new JoyconConfigKeyboardStick<Key>
{ {
StickUp = Key.W, StickUp = Key.W,
@ -1085,7 +1081,6 @@ namespace Ryujinx.Ui.Common.Configuration
StickRight = Key.D, StickRight = Key.D,
StickButton = Key.F, StickButton = Key.F,
}, },
RightJoycon = new RightJoyconCommonConfig<Key> RightJoycon = new RightJoyconCommonConfig<Key>
{ {
ButtonA = Key.Z, ButtonA = Key.Z,
@ -1096,9 +1091,8 @@ namespace Ryujinx.Ui.Common.Configuration
ButtonR = Key.U, ButtonR = Key.U,
ButtonZr = Key.O, ButtonZr = Key.O,
ButtonSl = Key.Unbound, ButtonSl = Key.Unbound,
ButtonSr = Key.Unbound ButtonSr = Key.Unbound,
}, },
RightJoyconStick = new JoyconConfigKeyboardStick<Key> RightJoyconStick = new JoyconConfigKeyboardStick<Key>
{ {
StickUp = Key.I, StickUp = Key.I,
@ -1106,8 +1100,8 @@ namespace Ryujinx.Ui.Common.Configuration
StickLeft = Key.J, StickLeft = Key.J,
StickRight = Key.L, StickRight = Key.L,
StickButton = Key.H, StickButton = Key.H,
} },
} },
}; };
configurationFileUpdated = true; configurationFileUpdated = true;
@ -1145,7 +1139,7 @@ namespace Ryujinx.Ui.Common.Configuration
configurationFileFormat.Hotkeys = new KeyboardHotkeys configurationFileFormat.Hotkeys = new KeyboardHotkeys
{ {
ToggleVsync = Key.F1, ToggleVsync = Key.F1,
Screenshot = Key.F8 Screenshot = Key.F8,
}; };
configurationFileUpdated = true; configurationFileUpdated = true;
@ -1159,7 +1153,7 @@ namespace Ryujinx.Ui.Common.Configuration
{ {
ToggleVsync = Key.F1, ToggleVsync = Key.F1,
Screenshot = Key.F8, Screenshot = Key.F8,
ShowUi = Key.F4 ShowUi = Key.F4,
}; };
configurationFileUpdated = true; configurationFileUpdated = true;
@ -1177,7 +1171,7 @@ namespace Ryujinx.Ui.Common.Configuration
{ {
EnableRumble = false, EnableRumble = false,
StrongRumble = 1f, StrongRumble = 1f,
WeakRumble = 1f WeakRumble = 1f,
}; };
} }
} }
@ -1203,7 +1197,7 @@ namespace Ryujinx.Ui.Common.Configuration
ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync, ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync,
Screenshot = configurationFileFormat.Hotkeys.Screenshot, Screenshot = configurationFileFormat.Hotkeys.Screenshot,
ShowUi = configurationFileFormat.Hotkeys.ShowUi, ShowUi = configurationFileFormat.Hotkeys.ShowUi,
Pause = Key.F5 Pause = Key.F5,
}; };
configurationFileUpdated = true; configurationFileUpdated = true;
@ -1219,7 +1213,7 @@ namespace Ryujinx.Ui.Common.Configuration
Screenshot = configurationFileFormat.Hotkeys.Screenshot, Screenshot = configurationFileFormat.Hotkeys.Screenshot,
ShowUi = configurationFileFormat.Hotkeys.ShowUi, ShowUi = configurationFileFormat.Hotkeys.ShowUi,
Pause = configurationFileFormat.Hotkeys.Pause, Pause = configurationFileFormat.Hotkeys.Pause,
ToggleMute = Key.F2 ToggleMute = Key.F2,
}; };
configurationFileFormat.AudioVolume = 1; configurationFileFormat.AudioVolume = 1;
@ -1295,7 +1289,7 @@ namespace Ryujinx.Ui.Common.Configuration
Pause = configurationFileFormat.Hotkeys.Pause, Pause = configurationFileFormat.Hotkeys.Pause,
ToggleMute = configurationFileFormat.Hotkeys.ToggleMute, ToggleMute = configurationFileFormat.Hotkeys.ToggleMute,
ResScaleUp = Key.Unbound, ResScaleUp = Key.Unbound,
ResScaleDown = Key.Unbound ResScaleDown = Key.Unbound,
}; };
configurationFileUpdated = true; configurationFileUpdated = true;
@ -1326,7 +1320,7 @@ namespace Ryujinx.Ui.Common.Configuration
ResScaleUp = configurationFileFormat.Hotkeys.ResScaleUp, ResScaleUp = configurationFileFormat.Hotkeys.ResScaleUp,
ResScaleDown = configurationFileFormat.Hotkeys.ResScaleDown, ResScaleDown = configurationFileFormat.Hotkeys.ResScaleDown,
VolumeUp = Key.Unbound, VolumeUp = Key.Unbound,
VolumeDown = Key.Unbound VolumeDown = Key.Unbound,
}; };
} }
@ -1366,7 +1360,7 @@ namespace Ryujinx.Ui.Common.Configuration
XCI = true, XCI = true,
NCA = true, NCA = true,
NRO = true, NRO = true,
NSO = true NSO = true,
}; };
configurationFileUpdated = true; configurationFileUpdated = true;
@ -1499,7 +1493,7 @@ namespace Ryujinx.Ui.Common.Configuration
return result; return result;
} }
private static void LogValueChange<T>(object sender, ReactiveEventArgs<T> eventArgs, string valueName) private static void LogValueChange<T>(ReactiveEventArgs<T> eventArgs, string valueName)
{ {
Ryujinx.Common.Logging.Logger.Info?.Print(LogClass.Configuration, $"{valueName} set to: {eventArgs.NewValue}"); Ryujinx.Common.Logging.Logger.Info?.Print(LogClass.Configuration, $"{valueName} set to: {eventArgs.NewValue}");
} }

View file

@ -23,6 +23,6 @@ namespace Ryujinx.Ui.Common.Configuration.System
LatinAmericanSpanish, LatinAmericanSpanish,
SimplifiedChinese, SimplifiedChinese,
TraditionalChinese, TraditionalChinese,
BrazilianPortuguese BrazilianPortuguese,
} }
} }

View file

@ -12,6 +12,6 @@ namespace Ryujinx.Ui.Common.Configuration.System
Australia, Australia,
China, China,
Korea, Korea,
Taiwan Taiwan,
} }
} }

View file

@ -19,19 +19,19 @@ namespace Ryujinx.Ui.Common
Assets = new Assets Assets = new Assets
{ {
LargeImageKey = "ryujinx", LargeImageKey = "ryujinx",
LargeImageText = Description LargeImageText = Description,
}, },
Details = "Main Menu", Details = "Main Menu",
State = "Idling", State = "Idling",
Timestamps = Timestamps.Now, Timestamps = Timestamps.Now,
Buttons = new Button[] Buttons = new[]
{ {
new Button() new Button
{ {
Label = "Website", Label = "Website",
Url = "https://ryujinx.org/" Url = "https://ryujinx.org/",
} },
} },
}; };
ConfigurationState.Instance.EnableDiscordIntegration.Event += Update; ConfigurationState.Instance.EnableDiscordIntegration.Event += Update;
@ -74,14 +74,14 @@ namespace Ryujinx.Ui.Common
Details = $"Playing {titleName}", Details = $"Playing {titleName}",
State = (titleId == "0000000000000000") ? "Homebrew" : titleId.ToUpper(), State = (titleId == "0000000000000000") ? "Homebrew" : titleId.ToUpper(),
Timestamps = Timestamps.Now, Timestamps = Timestamps.Now,
Buttons = new Button[] Buttons = new[]
{ {
new Button() new Button
{ {
Label = "Website", Label = "Website",
Url = "https://ryujinx.org/" Url = "https://ryujinx.org/",
} },
} },
}); });
} }

View file

@ -19,7 +19,7 @@ namespace Ryujinx.Ui.Common
FileTypes.NCA => config.NCA.Value, FileTypes.NCA => config.NCA.Value,
FileTypes.NRO => config.NRO.Value, FileTypes.NRO => config.NRO.Value,
FileTypes.NSO => config.NSO.Value, FileTypes.NSO => config.NSO.Value,
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null) _ => throw new ArgumentOutOfRangeException(nameof(type), type, null),
}; };
} }
} }

View file

@ -49,8 +49,8 @@ namespace Ryujinx.Ui.Common.Helper
StartInfo = StartInfo =
{ {
FileName = PkExecPath, FileName = PkExecPath,
ArgumentList = { "sh", "-c", command } ArgumentList = { "sh", "-c", command },
} },
}; };
process.Start(); process.Start();

View file

@ -1,8 +1,6 @@
using System; using System;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.Versioning; using System.Runtime.Versioning;
using System.Text;
namespace Ryujinx.Ui.Common.Helper namespace Ryujinx.Ui.Common.Helper
{ {
@ -12,44 +10,109 @@ namespace Ryujinx.Ui.Common.Helper
private const string ObjCRuntime = "/usr/lib/libobjc.A.dylib"; private const string ObjCRuntime = "/usr/lib/libobjc.A.dylib";
[LibraryImport(ObjCRuntime, StringMarshalling = StringMarshalling.Utf8)] [LibraryImport(ObjCRuntime, StringMarshalling = StringMarshalling.Utf8)]
private static unsafe partial IntPtr sel_getUid(string name); private static partial IntPtr sel_getUid(string name);
[LibraryImport(ObjCRuntime, StringMarshalling = StringMarshalling.Utf8)] [LibraryImport(ObjCRuntime, StringMarshalling = StringMarshalling.Utf8)]
public static partial IntPtr objc_getClass(string name); private static partial IntPtr objc_getClass(string name);
[LibraryImport(ObjCRuntime)] [LibraryImport(ObjCRuntime)]
public static partial void objc_msgSend(IntPtr receiver, Selector selector); private static partial void objc_msgSend(IntPtr receiver, Selector selector);
[LibraryImport(ObjCRuntime)] [LibraryImport(ObjCRuntime)]
public static partial void objc_msgSend(IntPtr receiver, Selector selector, byte value); private static partial void objc_msgSend(IntPtr receiver, Selector selector, byte value);
[LibraryImport(ObjCRuntime)] [LibraryImport(ObjCRuntime)]
public static partial void objc_msgSend(IntPtr receiver, Selector selector, IntPtr value); private static partial void objc_msgSend(IntPtr receiver, Selector selector, IntPtr value);
[LibraryImport(ObjCRuntime)] [LibraryImport(ObjCRuntime)]
public static partial void objc_msgSend(IntPtr receiver, Selector selector, NSRect point); private static partial void objc_msgSend(IntPtr receiver, Selector selector, NSRect point);
[LibraryImport(ObjCRuntime)] [LibraryImport(ObjCRuntime)]
public static partial void objc_msgSend(IntPtr receiver, Selector selector, double value); private static partial void objc_msgSend(IntPtr receiver, Selector selector, double value);
[LibraryImport(ObjCRuntime, EntryPoint = "objc_msgSend")] [LibraryImport(ObjCRuntime, EntryPoint = "objc_msgSend")]
public static partial IntPtr IntPtr_objc_msgSend(IntPtr receiver, Selector selector); private static partial IntPtr IntPtr_objc_msgSend(IntPtr receiver, Selector selector);
[LibraryImport(ObjCRuntime, EntryPoint = "objc_msgSend")] [LibraryImport(ObjCRuntime, EntryPoint = "objc_msgSend")]
public static partial IntPtr IntPtr_objc_msgSend(IntPtr receiver, Selector selector, IntPtr param); private static partial IntPtr IntPtr_objc_msgSend(IntPtr receiver, Selector selector, IntPtr param);
[LibraryImport(ObjCRuntime, EntryPoint = "objc_msgSend", StringMarshalling = StringMarshalling.Utf8)] [LibraryImport(ObjCRuntime, EntryPoint = "objc_msgSend", StringMarshalling = StringMarshalling.Utf8)]
public static partial IntPtr IntPtr_objc_msgSend(IntPtr receiver, Selector selector, string param); private static partial IntPtr IntPtr_objc_msgSend(IntPtr receiver, Selector selector, string param);
[LibraryImport(ObjCRuntime, EntryPoint = "objc_msgSend")] [LibraryImport(ObjCRuntime, EntryPoint = "objc_msgSend")]
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]
public static partial bool bool_objc_msgSend(IntPtr receiver, Selector selector, IntPtr param); private static partial bool bool_objc_msgSend(IntPtr receiver, Selector selector, IntPtr param);
public struct Selector public readonly struct Object
{
public readonly IntPtr ObjPtr;
private Object(IntPtr pointer)
{
ObjPtr = pointer;
}
public Object(string name)
{
ObjPtr = objc_getClass(name);
}
public void SendMessage(Selector selector)
{
objc_msgSend(ObjPtr, selector);
}
public void SendMessage(Selector selector, byte value)
{
objc_msgSend(ObjPtr, selector, value);
}
public void SendMessage(Selector selector, Object obj)
{
objc_msgSend(ObjPtr, selector, obj.ObjPtr);
}
public void SendMessage(Selector selector, NSRect point)
{
objc_msgSend(ObjPtr, selector, point);
}
public void SendMessage(Selector selector, double value)
{
objc_msgSend(ObjPtr, selector, value);
}
public Object GetFromMessage(Selector selector)
{
return new Object(IntPtr_objc_msgSend(ObjPtr, selector));
}
public Object GetFromMessage(Selector selector, Object obj)
{
return new Object(IntPtr_objc_msgSend(ObjPtr, selector, obj.ObjPtr));
}
public Object GetFromMessage(Selector selector, NSString nsString)
{
return new Object(IntPtr_objc_msgSend(ObjPtr, selector, nsString.StrPtr));
}
public Object GetFromMessage(Selector selector, string param)
{
return new Object(IntPtr_objc_msgSend(ObjPtr, selector, param));
}
public bool GetBoolFromMessage(Selector selector, Object obj)
{
return bool_objc_msgSend(ObjPtr, selector, obj.ObjPtr);
}
}
public readonly struct Selector
{ {
public readonly IntPtr SelPtr; public readonly IntPtr SelPtr;
public unsafe Selector(string name) private Selector(string name)
{ {
SelPtr = sel_getUid(name); SelPtr = sel_getUid(name);
} }
@ -57,7 +120,7 @@ namespace Ryujinx.Ui.Common.Helper
public static implicit operator Selector(string value) => new(value); public static implicit operator Selector(string value) => new(value);
} }
public struct NSString public readonly struct NSString
{ {
public readonly IntPtr StrPtr; public readonly IntPtr StrPtr;

View file

@ -9,13 +9,13 @@ namespace Ryujinx.Ui.Common.Helper
public static partial class OpenHelper public static partial class OpenHelper
{ {
[LibraryImport("shell32.dll", SetLastError = true)] [LibraryImport("shell32.dll", SetLastError = true)]
public static partial int SHOpenFolderAndSelectItems(IntPtr pidlFolder, uint cidl, IntPtr apidl, uint dwFlags); private static partial int SHOpenFolderAndSelectItems(IntPtr pidlFolder, uint cidl, IntPtr apidl, uint dwFlags);
[LibraryImport("shell32.dll", SetLastError = true)] [LibraryImport("shell32.dll", SetLastError = true)]
public static partial void ILFree(IntPtr pidlList); private static partial void ILFree(IntPtr pidlList);
[LibraryImport("shell32.dll", SetLastError = true)] [LibraryImport("shell32.dll", SetLastError = true)]
public static partial IntPtr ILCreateFromPathW([MarshalAs(UnmanagedType.LPWStr)] string pszPath); private static partial IntPtr ILCreateFromPathW([MarshalAs(UnmanagedType.LPWStr)] string pszPath);
public static void OpenFolder(string path) public static void OpenFolder(string path)
{ {
@ -25,7 +25,7 @@ namespace Ryujinx.Ui.Common.Helper
{ {
FileName = path, FileName = path,
UseShellExecute = true, UseShellExecute = true,
Verb = "open" Verb = "open",
}); });
} }
else else
@ -56,16 +56,16 @@ namespace Ryujinx.Ui.Common.Helper
else if (OperatingSystem.IsMacOS()) else if (OperatingSystem.IsMacOS())
{ {
ObjectiveC.NSString nsStringPath = new(path); ObjectiveC.NSString nsStringPath = new(path);
IntPtr nsUrl = ObjectiveC.objc_getClass("NSURL"); ObjectiveC.Object nsUrl = new("NSURL");
var urlPtr = ObjectiveC.IntPtr_objc_msgSend(nsUrl, "fileURLWithPath:", nsStringPath); var urlPtr = nsUrl.GetFromMessage("fileURLWithPath:", nsStringPath);
IntPtr nsArray = ObjectiveC.objc_getClass("NSArray"); ObjectiveC.Object nsArray = new("NSArray");
IntPtr urlArray = ObjectiveC.IntPtr_objc_msgSend(nsArray, "arrayWithObject:", urlPtr); ObjectiveC.Object urlArray = nsArray.GetFromMessage("arrayWithObject:", urlPtr);
IntPtr nsWorkspace = ObjectiveC.objc_getClass("NSWorkspace"); ObjectiveC.Object nsWorkspace = new("NSWorkspace");
IntPtr sharedWorkspace = ObjectiveC.IntPtr_objc_msgSend(nsWorkspace, "sharedWorkspace"); ObjectiveC.Object sharedWorkspace = nsWorkspace.GetFromMessage("sharedWorkspace");
ObjectiveC.objc_msgSend(sharedWorkspace, "activateFileViewerSelectingURLs:", urlArray); sharedWorkspace.SendMessage("activateFileViewerSelectingURLs:", urlArray);
} }
else if (OperatingSystem.IsLinux()) else if (OperatingSystem.IsLinux())
{ {
@ -95,13 +95,13 @@ namespace Ryujinx.Ui.Common.Helper
else if (OperatingSystem.IsMacOS()) else if (OperatingSystem.IsMacOS())
{ {
ObjectiveC.NSString nsStringPath = new(url); ObjectiveC.NSString nsStringPath = new(url);
IntPtr nsUrl = ObjectiveC.objc_getClass("NSURL"); ObjectiveC.Object nsUrl = new("NSURL");
var urlPtr = ObjectiveC.IntPtr_objc_msgSend(nsUrl, "URLWithString:", nsStringPath); var urlPtr = nsUrl.GetFromMessage("URLWithString:", nsStringPath);
IntPtr nsWorkspace = ObjectiveC.objc_getClass("NSWorkspace"); ObjectiveC.Object nsWorkspace = new("NSWorkspace");
IntPtr sharedWorkspace = ObjectiveC.IntPtr_objc_msgSend(nsWorkspace, "sharedWorkspace"); ObjectiveC.Object sharedWorkspace = nsWorkspace.GetFromMessage("sharedWorkspace");
ObjectiveC.bool_objc_msgSend(sharedWorkspace, "openURL:", urlPtr); sharedWorkspace.GetBoolFromMessage("openURL:", urlPtr);
} }
else else
{ {

View file

@ -20,13 +20,11 @@ namespace Ryujinx.Ui.Common.Helper
return true; return true;
} }
else
{
error = UserError.NoFirmware; error = UserError.NoFirmware;
return false; return false;
} }
}
public static bool CanFixStartApplication(ContentManager contentManager, string baseApplicationPath, UserError error, out SystemVersion firmwareVersion) public static bool CanFixStartApplication(ContentManager contentManager, string baseApplicationPath, UserError error, out SystemVersion firmwareVersion)
{ {
@ -107,12 +105,10 @@ namespace Ryujinx.Ui.Common.Helper
return IsFirmwareValid(contentManager, out error); return IsFirmwareValid(contentManager, out error);
} }
else
{
error = UserError.ApplicationNotFound; error = UserError.ApplicationNotFound;
return false; return false;
} }
} }
} }
}

View file

@ -29,29 +29,39 @@ namespace Ryujinx.Ui.Common.Models.Amiibo
[JsonPropertyName("gamesSwitch")] [JsonPropertyName("gamesSwitch")]
public List<AmiiboApiGamesSwitch> GamesSwitch { get; set; } public List<AmiiboApiGamesSwitch> GamesSwitch { get; set; }
public override string ToString() public readonly override string ToString()
{ {
return Name; return Name;
} }
public string GetId() public readonly string GetId()
{ {
return Head + Tail; return Head + Tail;
} }
public bool Equals(AmiiboApi other) public readonly bool Equals(AmiiboApi other)
{ {
return Head + Tail == other.Head + other.Tail; return Head + Tail == other.Head + other.Tail;
} }
public override bool Equals(object obj) public readonly override bool Equals(object obj)
{ {
return obj is AmiiboApi other && Equals(other); return obj is AmiiboApi other && Equals(other);
} }
public override int GetHashCode() public readonly override int GetHashCode()
{ {
return HashCode.Combine(Head, Tail); return HashCode.Combine(Head, Tail);
} }
public static bool operator ==(AmiiboApi left, AmiiboApi right)
{
return left.Equals(right);
}
public static bool operator !=(AmiiboApi left, AmiiboApi right)
{
return !(left == right);
}
} }
} }

View file

@ -34,6 +34,6 @@
/// <summary> /// <summary>
/// An unknown error. /// An unknown error.
/// </summary> /// </summary>
Unknown = 0xDEAD Unknown = 0xDEAD,
} }
} }

View file

@ -874,7 +874,7 @@ namespace Ryujinx.Ui
DiscordIntegrationModule.SwitchToPlayingState(_emulationContext.Processes.ActiveApplication.ProgramIdText, DiscordIntegrationModule.SwitchToPlayingState(_emulationContext.Processes.ActiveApplication.ProgramIdText,
_emulationContext.Processes.ActiveApplication.ApplicationControlProperties.Title[(int)_emulationContext.System.State.DesiredTitleLanguage].NameString.ToString()); _emulationContext.Processes.ActiveApplication.ApplicationControlProperties.Title[(int)_emulationContext.System.State.DesiredTitleLanguage].NameString.ToString());
_applicationLibrary.LoadAndSaveMetaData(_emulationContext.Processes.ActiveApplication.ProgramIdText, appMetadata => ApplicationLibrary.LoadAndSaveMetaData(_emulationContext.Processes.ActiveApplication.ProgramIdText, appMetadata =>
{ {
appMetadata.LastPlayed = DateTime.UtcNow; appMetadata.LastPlayed = DateTime.UtcNow;
}); });
@ -1017,7 +1017,7 @@ namespace Ryujinx.Ui
{ {
if (_gameLoaded) if (_gameLoaded)
{ {
_applicationLibrary.LoadAndSaveMetaData(titleId, appMetadata => ApplicationLibrary.LoadAndSaveMetaData(titleId, appMetadata =>
{ {
if (appMetadata.LastPlayed.HasValue) if (appMetadata.LastPlayed.HasValue)
{ {
@ -1156,7 +1156,7 @@ namespace Ryujinx.Ui
_tableStore.SetValue(treeIter, 0, newToggleValue); _tableStore.SetValue(treeIter, 0, newToggleValue);
_applicationLibrary.LoadAndSaveMetaData(titleId, appMetadata => ApplicationLibrary.LoadAndSaveMetaData(titleId, appMetadata =>
{ {
appMetadata.Favorite = newToggleValue; appMetadata.Favorite = newToggleValue;
}); });