[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

@ -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,6 +26,7 @@ using System.Text;
using System.Text.Json;
using System.Threading;
using Path = System.IO.Path;
using TimeSpan = System.TimeSpan;
namespace Ryujinx.Ui.App.Common
{
@ -44,8 +45,8 @@ namespace Ryujinx.Ui.App.Common
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)
{
@ -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
@ -508,7 +509,7 @@ namespace Ryujinx.Ui.App.Common
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");
@ -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

@ -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,
}
}

View File

@ -278,7 +278,7 @@ namespace Ryujinx.Ui.Common.Configuration
EnableFsAccessLog = new ReactiveObject<bool>();
FilteredClasses = new ReactiveObject<LogClass[]>();
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>();
}
}
@ -370,27 +370,27 @@ namespace Ryujinx.Ui.Common.Configuration
TimeZone = new ReactiveObject<string>();
SystemTimeOffset = new ReactiveObject<long>();
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.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnablePtc));
EnablePtc.Event += static (sender, e) => LogValueChange(e, nameof(EnablePtc));
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.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableFsIntegrityChecks));
EnableFsIntegrityChecks.Event += static (sender, e) => LogValueChange(e, nameof(EnableFsIntegrityChecks));
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.Event += static (sender, e) => LogValueChange(sender, e, nameof(AudioBackend));
AudioBackend.Event += static (sender, e) => LogValueChange(e, nameof(AudioBackend));
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.Event += static (sender, e) => LogValueChange(sender, e, nameof(ExpandRam));
ExpandRam.Event += static (sender, e) => LogValueChange(e, nameof(ExpandRam));
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.Event += static (sender, e) => LogValueChange(sender, e, nameof(AudioVolume));
AudioVolume.Event += static (sender, e) => LogValueChange(e, nameof(AudioVolume));
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()
{
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.Event += static (sender, e) => LogValueChange(sender, e, nameof(ResScale));
ResScale.Event += static (sender, e) => LogValueChange(e, nameof(ResScale));
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.Event += static (sender, e) => LogValueChange(sender, e, nameof(MaxAnisotropy));
MaxAnisotropy.Event += static (sender, e) => LogValueChange(e, nameof(MaxAnisotropy));
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>();
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.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableShaderCache));
EnableShaderCache.Event += static (sender, e) => LogValueChange(e, nameof(EnableShaderCache));
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.Event += static (sender, e) => LogValueChange(sender, e, nameof(GraphicsBackend));
GraphicsBackend.Event += static (sender, e) => LogValueChange(e, nameof(GraphicsBackend));
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.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableMacroHLE));
EnableMacroHLE.Event += static (sender, e) => LogValueChange(e, nameof(EnableMacroHLE));
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.Event += static (sender, e) => LogValueChange(sender, e, nameof(ScalingFilter));
ScalingFilter.Event += static (sender, e) => LogValueChange(e, nameof(ScalingFilter));
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()
{
ConfigurationFileFormat configurationFile = new ConfigurationFileFormat
ConfigurationFileFormat configurationFile = new()
{
Version = ConfigurationFileFormat.CurrentVersion,
BackendThreading = Graphics.BackendThreading,
@ -688,12 +688,12 @@ namespace Ryujinx.Ui.Common.Configuration
LastPlayedColumn = Ui.GuiColumns.LastPlayedColumn,
FileExtColumn = Ui.GuiColumns.FileExtColumn,
FileSizeColumn = Ui.GuiColumns.FileSizeColumn,
PathColumn = Ui.GuiColumns.PathColumn
PathColumn = Ui.GuiColumns.PathColumn,
},
ColumnSort = new ColumnSort
{
SortColumnId = Ui.ColumnSort.SortColumnId,
SortAscending = Ui.ColumnSort.SortAscending
SortAscending = Ui.ColumnSort.SortAscending,
},
GameDirs = Ui.GameDirs,
ShownFileTypes = new ShownFileTypes
@ -732,7 +732,7 @@ namespace Ryujinx.Ui.Common.Configuration
InputConfig = Hid.InputConfig,
GraphicsBackend = Graphics.GraphicsBackend,
PreferredGpu = Graphics.PreferredGpu,
MultiplayerLanInterfaceId = Multiplayer.LanInterfaceId
MultiplayerLanInterfaceId = Multiplayer.LanInterfaceId,
};
return configurationFile;
@ -767,7 +767,7 @@ namespace Ryujinx.Ui.Common.Configuration
EnableDiscordIntegration.Value = true;
CheckUpdatesOnStart.Value = true;
ShowConfirmExit.Value = true;
HideCursor.Value = Ryujinx.Common.Configuration.HideCursorMode.Never;
HideCursor.Value = HideCursorMode.Never;
Graphics.EnableVsync.Value = true;
Graphics.EnableShaderCache.Value = true;
Graphics.EnableTextureRecompression.Value = false;
@ -833,7 +833,7 @@ namespace Ryujinx.Ui.Common.Configuration
ResScaleUp = Key.Unbound,
ResScaleDown = Key.Unbound,
VolumeUp = Key.Unbound,
VolumeDown = Key.Unbound
VolumeDown = Key.Unbound,
};
Hid.InputConfig.Value = new List<InputConfig>
{
@ -854,9 +854,8 @@ namespace Ryujinx.Ui.Common.Configuration
ButtonL = Key.E,
ButtonZl = Key.Q,
ButtonSl = Key.Unbound,
ButtonSr = Key.Unbound
ButtonSr = Key.Unbound,
},
LeftJoyconStick = new JoyconConfigKeyboardStick<Key>
{
StickUp = Key.W,
@ -865,7 +864,6 @@ namespace Ryujinx.Ui.Common.Configuration
StickRight = Key.D,
StickButton = Key.F,
},
RightJoycon = new RightJoyconCommonConfig<Key>
{
ButtonA = Key.Z,
@ -876,9 +874,8 @@ namespace Ryujinx.Ui.Common.Configuration
ButtonR = Key.U,
ButtonZr = Key.O,
ButtonSl = Key.Unbound,
ButtonSr = Key.Unbound
ButtonSr = Key.Unbound,
},
RightJoyconStick = new JoyconConfigKeyboardStick<Key>
{
StickUp = Key.I,
@ -886,8 +883,8 @@ namespace Ryujinx.Ui.Common.Configuration
StickLeft = Key.J,
StickRight = Key.L,
StickButton = Key.H,
}
}
},
},
};
}
@ -958,12 +955,12 @@ namespace Ryujinx.Ui.Common.Configuration
configurationFileFormat.ColumnSort = new ColumnSort
{
SortColumnId = 0,
SortAscending = false
SortAscending = false,
};
configurationFileFormat.Hotkeys = new KeyboardHotkeys
{
ToggleVsync = Key.F1
ToggleVsync = Key.F1,
};
configurationFileUpdated = true;
@ -1074,9 +1071,8 @@ namespace Ryujinx.Ui.Common.Configuration
ButtonL = Key.E,
ButtonZl = Key.Q,
ButtonSl = Key.Unbound,
ButtonSr = Key.Unbound
ButtonSr = Key.Unbound,
},
LeftJoyconStick = new JoyconConfigKeyboardStick<Key>
{
StickUp = Key.W,
@ -1085,7 +1081,6 @@ namespace Ryujinx.Ui.Common.Configuration
StickRight = Key.D,
StickButton = Key.F,
},
RightJoycon = new RightJoyconCommonConfig<Key>
{
ButtonA = Key.Z,
@ -1096,9 +1091,8 @@ namespace Ryujinx.Ui.Common.Configuration
ButtonR = Key.U,
ButtonZr = Key.O,
ButtonSl = Key.Unbound,
ButtonSr = Key.Unbound
ButtonSr = Key.Unbound,
},
RightJoyconStick = new JoyconConfigKeyboardStick<Key>
{
StickUp = Key.I,
@ -1106,8 +1100,8 @@ namespace Ryujinx.Ui.Common.Configuration
StickLeft = Key.J,
StickRight = Key.L,
StickButton = Key.H,
}
}
},
},
};
configurationFileUpdated = true;
@ -1145,7 +1139,7 @@ namespace Ryujinx.Ui.Common.Configuration
configurationFileFormat.Hotkeys = new KeyboardHotkeys
{
ToggleVsync = Key.F1,
Screenshot = Key.F8
Screenshot = Key.F8,
};
configurationFileUpdated = true;
@ -1159,7 +1153,7 @@ namespace Ryujinx.Ui.Common.Configuration
{
ToggleVsync = Key.F1,
Screenshot = Key.F8,
ShowUi = Key.F4
ShowUi = Key.F4,
};
configurationFileUpdated = true;
@ -1169,7 +1163,7 @@ namespace Ryujinx.Ui.Common.Configuration
{
Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 30.");
foreach(InputConfig config in configurationFileFormat.InputConfig)
foreach (InputConfig config in configurationFileFormat.InputConfig)
{
if (config is StandardControllerInputConfig controllerConfig)
{
@ -1177,7 +1171,7 @@ namespace Ryujinx.Ui.Common.Configuration
{
EnableRumble = false,
StrongRumble = 1f,
WeakRumble = 1f
WeakRumble = 1f,
};
}
}
@ -1203,7 +1197,7 @@ namespace Ryujinx.Ui.Common.Configuration
ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync,
Screenshot = configurationFileFormat.Hotkeys.Screenshot,
ShowUi = configurationFileFormat.Hotkeys.ShowUi,
Pause = Key.F5
Pause = Key.F5,
};
configurationFileUpdated = true;
@ -1219,7 +1213,7 @@ namespace Ryujinx.Ui.Common.Configuration
Screenshot = configurationFileFormat.Hotkeys.Screenshot,
ShowUi = configurationFileFormat.Hotkeys.ShowUi,
Pause = configurationFileFormat.Hotkeys.Pause,
ToggleMute = Key.F2
ToggleMute = Key.F2,
};
configurationFileFormat.AudioVolume = 1;
@ -1295,7 +1289,7 @@ namespace Ryujinx.Ui.Common.Configuration
Pause = configurationFileFormat.Hotkeys.Pause,
ToggleMute = configurationFileFormat.Hotkeys.ToggleMute,
ResScaleUp = Key.Unbound,
ResScaleDown = Key.Unbound
ResScaleDown = Key.Unbound,
};
configurationFileUpdated = true;
@ -1326,7 +1320,7 @@ namespace Ryujinx.Ui.Common.Configuration
ResScaleUp = configurationFileFormat.Hotkeys.ResScaleUp,
ResScaleDown = configurationFileFormat.Hotkeys.ResScaleDown,
VolumeUp = Key.Unbound,
VolumeDown = Key.Unbound
VolumeDown = Key.Unbound,
};
}
@ -1366,7 +1360,7 @@ namespace Ryujinx.Ui.Common.Configuration
XCI = true,
NCA = true,
NRO = true,
NSO = true
NSO = true,
};
configurationFileUpdated = true;
@ -1499,7 +1493,7 @@ namespace Ryujinx.Ui.Common.Configuration
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}");
}

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

@ -19,19 +19,19 @@ namespace Ryujinx.Ui.Common
Assets = new Assets
{
LargeImageKey = "ryujinx",
LargeImageText = Description
LargeImageText = Description,
},
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;
@ -74,14 +74,14 @@ namespace Ryujinx.Ui.Common
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

@ -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)
{
@ -25,7 +25,7 @@ namespace Ryujinx.Ui.Common.Helper
{
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,13 +20,11 @@ namespace Ryujinx.Ui.Common.Helper
return true;
}
else
{
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;
}
}
}
}

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;
});