[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.Input;
using Ryujinx.Input.HLE;
using Ryujinx.Ui.App.Common;
using Ryujinx.Ui.Common;
using Ryujinx.Ui.Common.Configuration;
using Ryujinx.Ui.Common.Helper;
@ -692,7 +693,7 @@ namespace Ryujinx.Ava
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;
});

View file

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

View file

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

View file

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

View file

@ -4,7 +4,7 @@ namespace Ryujinx.Ui.App.Common
{
public class ApplicationCountUpdatedEventArgs : EventArgs
{
public int NumAppsFound { get; set; }
public int NumAppsFound { get; set; }
public int NumAppsLoaded { get; set; }
}
}

View file

@ -18,19 +18,19 @@ namespace Ryujinx.Ui.App.Common
{
public class ApplicationData
{
public bool Favorite { get; set; }
public byte[] Icon { get; set; }
public string TitleName { get; set; }
public string TitleId { get; set; }
public string Developer { get; set; }
public string Version { get; set; }
public string TimePlayed { get; set; }
public double TimePlayedNum { get; set; }
public DateTime? LastPlayed { get; set; }
public string FileExtension { get; set; }
public string FileSize { get; set; }
public double FileSizeBytes { get; set; }
public string Path { get; set; }
public bool Favorite { get; set; }
public byte[] Icon { get; set; }
public string TitleName { get; set; }
public string TitleId { get; set; }
public string Developer { get; set; }
public string Version { get; set; }
public string TimePlayed { get; set; }
public double TimePlayedNum { get; set; }
public DateTime? LastPlayed { get; set; }
public string FileExtension { get; set; }
public string FileSize { get; set; }
public double FileSizeBytes { get; set; }
public string Path { get; set; }
public BlitStruct<ApplicationControlProperty> ControlHolder { get; set; }
[JsonIgnore]
@ -159,7 +159,7 @@ namespace Ryujinx.Ui.App.Common
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();
return BitConverter.ToString(reader.Header.ModuleId.ItemsRo.ToArray()).Replace("-", "").ToUpper()[..16];

View file

@ -26,12 +26,13 @@ using System.Text;
using System.Text.Json;
using System.Threading;
using Path = System.IO.Path;
using TimeSpan = System.TimeSpan;
namespace Ryujinx.Ui.App.Common
{
public class ApplicationLibrary
{
public event EventHandler<ApplicationAddedEventArgs> ApplicationAdded;
public event EventHandler<ApplicationAddedEventArgs> ApplicationAdded;
public event EventHandler<ApplicationCountUpdatedEventArgs> ApplicationCountUpdated;
private readonly byte[] _nspIcon;
@ -41,11 +42,11 @@ namespace Ryujinx.Ui.App.Common
private readonly byte[] _nsoIcon;
private readonly VirtualFileSystem _virtualFileSystem;
private Language _desiredTitleLanguage;
private CancellationTokenSource _cancellationToken;
private Language _desiredTitleLanguage;
private CancellationTokenSource _cancellationToken;
private static readonly ApplicationJsonSerializerContext SerializerContext = new(JsonHelper.GetDefaultSerializerOptions());
private static readonly TitleUpdateMetadataJsonSerializerContext TitleSerializerContext = new(JsonHelper.GetDefaultSerializerOptions());
private static readonly ApplicationJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
private static readonly TitleUpdateMetadataJsonSerializerContext _titleSerializerContext = new(JsonHelper.GetDefaultSerializerOptions());
public ApplicationLibrary(VirtualFileSystem virtualFileSystem)
{
@ -60,7 +61,7 @@ namespace Ryujinx.Ui.App.Common
private static byte[] GetResourceBytes(string resourceName)
{
Stream resourceStream = Assembly.GetCallingAssembly().GetManifestResourceStream(resourceName);
Stream resourceStream = Assembly.GetCallingAssembly().GetManifestResourceStream(resourceName);
byte[] resourceByteArray = new byte[resourceStream.Length];
resourceStream.Read(resourceByteArray);
@ -83,7 +84,7 @@ namespace Ryujinx.Ui.App.Common
public void LoadApplications(List<string> appDirs, Language desiredTitleLanguage)
{
int numApplicationsFound = 0;
int numApplicationsFound = 0;
int numApplicationsLoaded = 0;
_desiredTitleLanguage = desiredTitleLanguage;
@ -114,12 +115,12 @@ namespace Ryujinx.Ui.App.Common
IEnumerable<string> files = Directory.EnumerateFiles(appDir, "*", SearchOption.AllDirectories).Where(file =>
{
return
(Path.GetExtension(file).ToLower() is ".nsp" && ConfigurationState.Instance.Ui.ShownFileTypes.NSP.Value) ||
(Path.GetExtension(file).ToLower() is ".nsp" && ConfigurationState.Instance.Ui.ShownFileTypes.NSP.Value) ||
(Path.GetExtension(file).ToLower() is ".pfs0" && ConfigurationState.Instance.Ui.ShownFileTypes.PFS0.Value) ||
(Path.GetExtension(file).ToLower() is ".xci" && ConfigurationState.Instance.Ui.ShownFileTypes.XCI.Value) ||
(Path.GetExtension(file).ToLower() is ".nca" && ConfigurationState.Instance.Ui.ShownFileTypes.NCA.Value) ||
(Path.GetExtension(file).ToLower() is ".nro" && ConfigurationState.Instance.Ui.ShownFileTypes.NRO.Value) ||
(Path.GetExtension(file).ToLower() is ".nso" && ConfigurationState.Instance.Ui.ShownFileTypes.NSO.Value);
(Path.GetExtension(file).ToLower() is ".xci" && ConfigurationState.Instance.Ui.ShownFileTypes.XCI.Value) ||
(Path.GetExtension(file).ToLower() is ".nca" && ConfigurationState.Instance.Ui.ShownFileTypes.NCA.Value) ||
(Path.GetExtension(file).ToLower() is ".nro" && ConfigurationState.Instance.Ui.ShownFileTypes.NRO.Value) ||
(Path.GetExtension(file).ToLower() is ".nso" && ConfigurationState.Instance.Ui.ShownFileTypes.NSO.Value);
});
foreach (string app in files)
@ -459,27 +460,27 @@ namespace Ryujinx.Ui.App.Common
FileSize = (fileSize < 1) ? (fileSize * 1024).ToString("0.##") + " MiB" : fileSize.ToString("0.##") + " GiB",
FileSizeBytes = fileSize,
Path = applicationPath,
ControlHolder = controlHolder
ControlHolder = controlHolder,
};
numApplicationsLoaded++;
OnApplicationAdded(new ApplicationAddedEventArgs()
OnApplicationAdded(new ApplicationAddedEventArgs
{
AppData = data
AppData = data,
});
OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs()
OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs
{
NumAppsFound = numApplicationsFound,
NumAppsLoaded = numApplicationsLoaded
NumAppsLoaded = numApplicationsLoaded,
});
}
OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs()
OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs
{
NumAppsFound = numApplicationsFound,
NumAppsLoaded = numApplicationsLoaded
NumAppsLoaded = numApplicationsLoaded,
});
}
finally
@ -505,13 +506,13 @@ namespace Ryujinx.Ui.App.Common
// Return the ControlFS
controlFs = controlNca?.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.None);
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 metadataFile = Path.Combine(metadataFolder, "metadata.json");
string metadataFile = Path.Combine(metadataFolder, "metadata.json");
ApplicationMetadata appMetadata;
@ -521,12 +522,12 @@ namespace Ryujinx.Ui.App.Common
appMetadata = new ApplicationMetadata();
JsonHelper.SerializeToFile(metadataFile, appMetadata, SerializerContext.ApplicationMetadata);
JsonHelper.SerializeToFile(metadataFile, appMetadata, _serializerContext.ApplicationMetadata);
}
try
{
appMetadata = JsonHelper.DeserializeFromFile(metadataFile, SerializerContext.ApplicationMetadata);
appMetadata = JsonHelper.DeserializeFromFile(metadataFile, _serializerContext.ApplicationMetadata);
}
catch (JsonException)
{
@ -539,7 +540,7 @@ namespace Ryujinx.Ui.App.Common
{
modifyFunction(appMetadata);
JsonHelper.SerializeToFile(metadataFile, appMetadata, SerializerContext.ApplicationMetadata);
JsonHelper.SerializeToFile(metadataFile, appMetadata, _serializerContext.ApplicationMetadata);
}
return appMetadata;
@ -703,7 +704,7 @@ namespace Ryujinx.Ui.App.Common
}
}
}
catch(Exception)
catch (Exception)
{
Logger.Warning?.Print(LogClass.Application, $"Could not retrieve a valid icon for the app. Default icon will be used. Errored File: {applicationPath}");
}
@ -713,7 +714,7 @@ namespace Ryujinx.Ui.App.Common
private static string ConvertSecondsToFormattedString(double seconds)
{
System.TimeSpan time = System.TimeSpan.FromSeconds(seconds);
TimeSpan time = TimeSpan.FromSeconds(seconds);
string timeString;
if (time.Days != 0)
@ -840,7 +841,7 @@ namespace Ryujinx.Ui.App.Common
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);
@ -884,7 +885,7 @@ namespace Ryujinx.Ui.App.Common
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);
@ -925,12 +926,12 @@ namespace Ryujinx.Ui.App.Common
if (File.Exists(titleUpdateMetadataPath))
{
updatePath = JsonHelper.DeserializeFromFile(titleUpdateMetadataPath, TitleSerializerContext.TitleUpdateMetadata).Selected;
updatePath = JsonHelper.DeserializeFromFile(titleUpdateMetadataPath, _titleSerializerContext.TitleUpdateMetadata).Selected;
if (File.Exists(updatePath))
{
FileStream file = new FileStream(updatePath, FileMode.Open, FileAccess.Read);
PartitionFileSystem nsp = new PartitionFileSystem(file.AsStorage());
FileStream file = new(updatePath, FileMode.Open, FileAccess.Read);
PartitionFileSystem nsp = new(file.AsStorage());
return GetGameUpdateDataFromPartition(fileSystem, nsp, titleIdBase.ToString("x16"), programIndex);
}
@ -941,4 +942,3 @@ namespace Ryujinx.Ui.App.Common
}
}
}

View file

@ -6,7 +6,7 @@ namespace Ryujinx.Ui.App.Common
public class ApplicationMetadata
{
public string Title { get; set; }
public bool Favorite { get; set; }
public bool Favorite { get; set; }
public double TimePlayed { get; set; }
[JsonPropertyName("last_played_utc")]

View file

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

View file

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

File diff suppressed because it is too large Load diff

View file

@ -9,16 +9,16 @@ namespace Ryujinx.Ui.Common.Configuration
{
public static void Initialize()
{
ConfigurationState.Instance.Logger.EnableDebug.Event += ReloadEnableDebug;
ConfigurationState.Instance.Logger.EnableStub.Event += ReloadEnableStub;
ConfigurationState.Instance.Logger.EnableInfo.Event += ReloadEnableInfo;
ConfigurationState.Instance.Logger.EnableWarn.Event += ReloadEnableWarning;
ConfigurationState.Instance.Logger.EnableError.Event += ReloadEnableError;
ConfigurationState.Instance.Logger.EnableTrace.Event += ReloadEnableTrace;
ConfigurationState.Instance.Logger.EnableGuest.Event += ReloadEnableGuest;
ConfigurationState.Instance.Logger.EnableDebug.Event += ReloadEnableDebug;
ConfigurationState.Instance.Logger.EnableStub.Event += ReloadEnableStub;
ConfigurationState.Instance.Logger.EnableInfo.Event += ReloadEnableInfo;
ConfigurationState.Instance.Logger.EnableWarn.Event += ReloadEnableWarning;
ConfigurationState.Instance.Logger.EnableError.Event += ReloadEnableError;
ConfigurationState.Instance.Logger.EnableTrace.Event += ReloadEnableTrace;
ConfigurationState.Instance.Logger.EnableGuest.Event += ReloadEnableGuest;
ConfigurationState.Instance.Logger.EnableFsAccessLog.Event += ReloadEnableFsAccessLog;
ConfigurationState.Instance.Logger.FilteredClasses.Event += ReloadFilteredClasses;
ConfigurationState.Instance.Logger.EnableFileLog.Event += ReloadFileLogger;
ConfigurationState.Instance.Logger.FilteredClasses.Event += ReloadFilteredClasses;
ConfigurationState.Instance.Logger.EnableFileLog.Event += ReloadFileLogger;
}
private static void ReloadEnableDebug(object sender, ReactiveEventArgs<bool> e)

View file

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

View file

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

View file

@ -2,7 +2,7 @@
{
public struct ColumnSort
{
public int SortColumnId { get; set; }
public int SortColumnId { get; set; }
public bool SortAscending { get; set; }
}
}

View file

@ -2,15 +2,15 @@
{
public struct GuiColumns
{
public bool FavColumn { get; set; }
public bool IconColumn { get; set; }
public bool AppColumn { get; set; }
public bool DevColumn { get; set; }
public bool VersionColumn { get; set; }
public bool FavColumn { get; set; }
public bool IconColumn { get; set; }
public bool AppColumn { get; set; }
public bool DevColumn { get; set; }
public bool VersionColumn { get; set; }
public bool TimePlayedColumn { get; set; }
public bool LastPlayedColumn { get; set; }
public bool FileExtColumn { get; set; }
public bool FileSizeColumn { get; set; }
public bool PathColumn { get; set; }
public bool FileExtColumn { get; set; }
public bool FileSizeColumn { get; set; }
public bool PathColumn { get; set; }
}
}

View file

@ -2,11 +2,11 @@ namespace Ryujinx.Ui.Common.Configuration.Ui
{
public struct ShownFileTypes
{
public bool NSP { get; set; }
public bool NSP { get; set; }
public bool PFS0 { get; set; }
public bool XCI { get; set; }
public bool NCA { get; set; }
public bool NRO { get; set; }
public bool NSO { get; set; }
public bool XCI { get; set; }
public bool NCA { get; set; }
public bool NRO { get; set; }
public bool NSO { get; set; }
}
}

View file

@ -7,10 +7,10 @@ namespace Ryujinx.Ui.Common
public static class DiscordIntegrationModule
{
private const string Description = "A simple, experimental Nintendo Switch emulator.";
private const string CliendId = "568815339807309834";
private const string CliendId = "568815339807309834";
private static DiscordRpcClient _discordClient;
private static RichPresence _discordPresenceMain;
private static RichPresence _discordPresenceMain;
public static void Initialize()
{
@ -18,20 +18,20 @@ namespace Ryujinx.Ui.Common
{
Assets = new Assets
{
LargeImageKey = "ryujinx",
LargeImageText = Description
LargeImageKey = "ryujinx",
LargeImageText = Description,
},
Details = "Main Menu",
State = "Idling",
Details = "Main Menu",
State = "Idling",
Timestamps = Timestamps.Now,
Buttons = new Button[]
Buttons = new[]
{
new Button()
new Button
{
Label = "Website",
Url = "https://ryujinx.org/"
}
}
Url = "https://ryujinx.org/",
},
},
};
ConfigurationState.Instance.EnableDiscordIntegration.Event += Update;
@ -66,22 +66,22 @@ namespace Ryujinx.Ui.Common
{
Assets = new Assets
{
LargeImageKey = "game",
LargeImageKey = "game",
LargeImageText = titleName,
SmallImageKey = "ryujinx",
SmallImageKey = "ryujinx",
SmallImageText = Description,
},
Details = $"Playing {titleName}",
State = (titleId == "0000000000000000") ? "Homebrew" : titleId.ToUpper(),
Details = $"Playing {titleName}",
State = (titleId == "0000000000000000") ? "Homebrew" : titleId.ToUpper(),
Timestamps = Timestamps.Now,
Buttons = new Button[]
Buttons = new[]
{
new Button()
new Button
{
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.NRO => config.NRO.Value,
FileTypes.NSO => config.NSO.Value,
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null),
};
}
}

View file

@ -7,13 +7,13 @@ namespace Ryujinx.Ui.Common.Helper
{
public static string[] Arguments { get; private set; }
public static bool? OverrideDockedMode { get; private set; }
public static bool? OverrideDockedMode { get; private set; }
public static string OverrideGraphicsBackend { get; private set; }
public static string OverrideHideCursor { get; private set; }
public static string BaseDirPathArg { get; private set; }
public static string Profile { get; private set; }
public static string LaunchPathArg { get; private set; }
public static bool StartFullscreenArg { get; private set; }
public static string OverrideHideCursor { get; private set; }
public static string BaseDirPathArg { get; private set; }
public static string Profile { get; private set; }
public static string LaunchPathArg { get; private set; }
public static bool StartFullscreenArg { get; private set; }
public static void ParseArguments(string[] args)
{

View file

@ -17,7 +17,7 @@ namespace Ryujinx.Ui.Common.Helper
private static readonly string _mimeDbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share", "mime");
private const int SHCNE_ASSOCCHANGED = 0x8000000;
private const int SHCNF_FLUSH = 0x1000;
private const int SHCNF_FLUSH = 0x1000;
[LibraryImport("shell32.dll", SetLastError = true)]
public static partial void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);

View file

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

View file

@ -1,8 +1,6 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
namespace Ryujinx.Ui.Common.Helper
{
@ -12,44 +10,109 @@ namespace Ryujinx.Ui.Common.Helper
private const string ObjCRuntime = "/usr/lib/libobjc.A.dylib";
[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)]
public static partial IntPtr objc_getClass(string name);
private static partial IntPtr objc_getClass(string name);
[LibraryImport(ObjCRuntime)]
public static partial void objc_msgSend(IntPtr receiver, Selector selector);
private static partial void objc_msgSend(IntPtr receiver, Selector selector);
[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)]
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)]
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)]
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")]
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")]
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)]
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")]
[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 unsafe Selector(string name)
private Selector(string name)
{
SelPtr = sel_getUid(name);
}
@ -57,7 +120,7 @@ namespace Ryujinx.Ui.Common.Helper
public static implicit operator Selector(string value) => new(value);
}
public struct NSString
public readonly struct NSString
{
public readonly IntPtr StrPtr;

View file

@ -9,13 +9,13 @@ namespace Ryujinx.Ui.Common.Helper
public static partial class OpenHelper
{
[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)]
public static partial void ILFree(IntPtr pidlList);
private static partial void ILFree(IntPtr pidlList);
[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)
{
@ -23,9 +23,9 @@ namespace Ryujinx.Ui.Common.Helper
{
Process.Start(new ProcessStartInfo
{
FileName = path,
FileName = path,
UseShellExecute = true,
Verb = "open"
Verb = "open",
});
}
else
@ -56,16 +56,16 @@ namespace Ryujinx.Ui.Common.Helper
else if (OperatingSystem.IsMacOS())
{
ObjectiveC.NSString nsStringPath = new(path);
IntPtr nsUrl = ObjectiveC.objc_getClass("NSURL");
var urlPtr = ObjectiveC.IntPtr_objc_msgSend(nsUrl, "fileURLWithPath:", nsStringPath);
ObjectiveC.Object nsUrl = new("NSURL");
var urlPtr = nsUrl.GetFromMessage("fileURLWithPath:", nsStringPath);
IntPtr nsArray = ObjectiveC.objc_getClass("NSArray");
IntPtr urlArray = ObjectiveC.IntPtr_objc_msgSend(nsArray, "arrayWithObject:", urlPtr);
ObjectiveC.Object nsArray = new("NSArray");
ObjectiveC.Object urlArray = nsArray.GetFromMessage("arrayWithObject:", urlPtr);
IntPtr nsWorkspace = ObjectiveC.objc_getClass("NSWorkspace");
IntPtr sharedWorkspace = ObjectiveC.IntPtr_objc_msgSend(nsWorkspace, "sharedWorkspace");
ObjectiveC.Object nsWorkspace = new("NSWorkspace");
ObjectiveC.Object sharedWorkspace = nsWorkspace.GetFromMessage("sharedWorkspace");
ObjectiveC.objc_msgSend(sharedWorkspace, "activateFileViewerSelectingURLs:", urlArray);
sharedWorkspace.SendMessage("activateFileViewerSelectingURLs:", urlArray);
}
else if (OperatingSystem.IsLinux())
{
@ -95,13 +95,13 @@ namespace Ryujinx.Ui.Common.Helper
else if (OperatingSystem.IsMacOS())
{
ObjectiveC.NSString nsStringPath = new(url);
IntPtr nsUrl = ObjectiveC.objc_getClass("NSURL");
var urlPtr = ObjectiveC.IntPtr_objc_msgSend(nsUrl, "URLWithString:", nsStringPath);
ObjectiveC.Object nsUrl = new("NSURL");
var urlPtr = nsUrl.GetFromMessage("URLWithString:", nsStringPath);
IntPtr nsWorkspace = ObjectiveC.objc_getClass("NSWorkspace");
IntPtr sharedWorkspace = ObjectiveC.IntPtr_objc_msgSend(nsWorkspace, "sharedWorkspace");
ObjectiveC.Object nsWorkspace = new("NSWorkspace");
ObjectiveC.Object sharedWorkspace = nsWorkspace.GetFromMessage("sharedWorkspace");
ObjectiveC.bool_objc_msgSend(sharedWorkspace, "openURL:", urlPtr);
sharedWorkspace.GetBoolFromMessage("openURL:", urlPtr);
}
else
{

View file

@ -20,12 +20,10 @@ namespace Ryujinx.Ui.Common.Helper
return true;
}
else
{
error = UserError.NoFirmware;
return false;
}
error = UserError.NoFirmware;
return false;
}
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);
}
else
{
error = UserError.ApplicationNotFound;
return false;
}
error = UserError.ApplicationNotFound;
return false;
}
}
}

View file

@ -29,29 +29,39 @@ namespace Ryujinx.Ui.Common.Models.Amiibo
[JsonPropertyName("gamesSwitch")]
public List<AmiiboApiGamesSwitch> GamesSwitch { get; set; }
public override string ToString()
public readonly override string ToString()
{
return Name;
}
public string GetId()
public readonly string GetId()
{
return Head + Tail;
}
public bool Equals(AmiiboApi other)
public readonly bool Equals(AmiiboApi other)
{
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);
}
public override int GetHashCode()
public readonly override int GetHashCode()
{
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>
/// An unknown error.
/// </summary>
Unknown = 0xDEAD
Unknown = 0xDEAD,
}
}

View file

@ -874,7 +874,7 @@ namespace Ryujinx.Ui
DiscordIntegrationModule.SwitchToPlayingState(_emulationContext.Processes.ActiveApplication.ProgramIdText,
_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;
});
@ -1017,7 +1017,7 @@ namespace Ryujinx.Ui
{
if (_gameLoaded)
{
_applicationLibrary.LoadAndSaveMetaData(titleId, appMetadata =>
ApplicationLibrary.LoadAndSaveMetaData(titleId, appMetadata =>
{
if (appMetadata.LastPlayed.HasValue)
{
@ -1156,7 +1156,7 @@ namespace Ryujinx.Ui
_tableStore.SetValue(treeIter, 0, newToggleValue);
_applicationLibrary.LoadAndSaveMetaData(titleId, appMetadata =>
ApplicationLibrary.LoadAndSaveMetaData(titleId, appMetadata =>
{
appMetadata.Favorite = newToggleValue;
});