mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2026-03-11 21:15:39 +00:00
cleanup
This commit is contained in:
parent
8ccbf33327
commit
e4abc3a960
3 changed files with 58 additions and 44 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
|
using CommandLine;
|
||||||
using DiscordRPC;
|
using DiscordRPC;
|
||||||
using Gommon;
|
using Gommon;
|
||||||
using Projektanker.Icons.Avalonia;
|
using Projektanker.Icons.Avalonia;
|
||||||
|
|
@ -78,35 +79,38 @@ namespace Ryujinx.Ava
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool noGuiArg = ConsumeCommandLineArgument(ref args, "--no-gui") || ConsumeCommandLineArgument(ref args, "nogui");
|
PreviewerDetached = true;
|
||||||
bool coreDumpArg = ConsumeCommandLineArgument(ref args, "--core-dumps");
|
|
||||||
|
if (ConsumeCommandLineArgument(ref args, "--no-gui")
|
||||||
|
|| ConsumeCommandLineArgument(ref args, "nogui"))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HeadlessRyujinx.Entrypoint(args);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Error?.PrintMsg(LogClass.Application, $"Exception occurred when running Headless Ryujinx: {e.Message}\n{e.StackTrace}");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Initialize(args, out RyujinxOptions options))
|
||||||
|
{
|
||||||
|
Logger.Flush();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Ryujinx causes core dumps on Linux when it exits "uncleanly", eg. through an unhandled exception.
|
// TODO: Ryujinx causes core dumps on Linux when it exits "uncleanly", eg. through an unhandled exception.
|
||||||
// This is undesirable and causes very odd behavior during development (the process stops responding,
|
// This is undesirable and causes very odd behavior during development (the process stops responding,
|
||||||
// the .NET debugger freezes or suddenly detaches, /tmp/ gets filled etc.), unless explicitly requested by the user.
|
// the .NET debugger freezes or suddenly detaches, /tmp/ gets filled etc.), unless explicitly requested by the user.
|
||||||
// This needs to be investigated, but calling prctl() is better than modifying system-wide settings or leaving this be.
|
// This needs to be investigated, but calling prctl() is better than modifying system-wide settings or leaving this be.
|
||||||
if (!coreDumpArg)
|
if (!options.CoreDumpsEnabled)
|
||||||
{
|
{
|
||||||
OsUtils.SetCoreDumpable(false);
|
OsUtils.SetCoreDumpable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
PreviewerDetached = true;
|
|
||||||
|
|
||||||
if (noGuiArg)
|
|
||||||
{
|
|
||||||
HeadlessRyujinx.Entrypoint(args);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Initialize(args);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
LoggerAdapter.Register();
|
LoggerAdapter.Register();
|
||||||
|
|
||||||
IconProvider.Current
|
IconProvider.Current
|
||||||
|
|
@ -144,13 +148,14 @@ namespace Ryujinx.Ava
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Initialize(string[] args)
|
private static Result Initialize(string[] args, out RyujinxOptions options)
|
||||||
{
|
{
|
||||||
// Ensure Discord presence timestamp begins at the absolute start of when Ryujinx is launched
|
// Ensure Discord presence timestamp begins at the absolute start of when Ryujinx is launched
|
||||||
DiscordIntegrationModule.EmulatorStartedAt = Timestamps.Now;
|
DiscordIntegrationModule.EmulatorStartedAt = Timestamps.Now;
|
||||||
|
|
||||||
// Parse arguments
|
// Parse arguments
|
||||||
RyujinxOptions.Read(args, out RyujinxOptions options);
|
Result res = RyujinxOptions.Read(args, out options);
|
||||||
|
if (!res) return res;
|
||||||
|
|
||||||
if (OperatingSystem.IsMacOS())
|
if (OperatingSystem.IsMacOS())
|
||||||
{
|
{
|
||||||
|
|
@ -207,6 +212,8 @@ namespace Ryujinx.Ava
|
||||||
{
|
{
|
||||||
MainWindow.DeferLoadApplication(options.LaunchPath, options.LaunchApplicationId, options.StartFullscreen);
|
MainWindow.DeferLoadApplication(options.LaunchPath, options.LaunchApplicationId, options.StartFullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetDirGameUserConfig(string gameId, bool changeFolderForGame = false)
|
public static string GetDirGameUserConfig(string gameId, bool changeFolderForGame = false)
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ namespace Ryujinx.Ava.Utilities
|
||||||
{
|
{
|
||||||
public static RyujinxOptions Shared { get; private set; }
|
public static RyujinxOptions Shared { get; private set; }
|
||||||
|
|
||||||
|
// ReSharper disable once UnusedMethodReturnValue.Global
|
||||||
public static Result Read(string[] args, out RyujinxOptions options)
|
public static Result Read(string[] args, out RyujinxOptions options)
|
||||||
{
|
{
|
||||||
options = null;
|
options = null;
|
||||||
|
|
@ -20,20 +21,8 @@ namespace Ryujinx.Ava.Utilities
|
||||||
ParserResult<RyujinxOptions> parseResult =
|
ParserResult<RyujinxOptions> parseResult =
|
||||||
Parser.ParseArguments<RyujinxOptions>(args);
|
Parser.ParseArguments<RyujinxOptions>(args);
|
||||||
|
|
||||||
if (parseResult is NotParsed<RyujinxOptions> notParsed)
|
if (parseResult is NotParsed<RyujinxOptions>)
|
||||||
{
|
|
||||||
if (notParsed.Errors.None(x =>
|
|
||||||
x.Tag is ErrorType.HelpRequestedError or ErrorType.HelpVerbRequestedError))
|
|
||||||
{
|
|
||||||
Logger.Notice.Print(LogClass.Application, "Failed to parse command-line arguments:");
|
|
||||||
foreach (var error in notParsed.Errors)
|
|
||||||
{
|
|
||||||
Logger.Notice.Print(LogClass.Application, $" - {error.Tag}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result.Fail;
|
return Result.Fail;
|
||||||
}
|
|
||||||
|
|
||||||
options = Shared = parseResult.Value;
|
options = Shared = parseResult.Value;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,8 @@ namespace Ryujinx.Ava.Utilities
|
||||||
{
|
{
|
||||||
InputArguments = args;
|
InputArguments = args;
|
||||||
|
|
||||||
{ // Docked Mode Override
|
{
|
||||||
|
// Docked Mode Override
|
||||||
if (DockedMode && HandheldMode)
|
if (DockedMode && HandheldMode)
|
||||||
{
|
{
|
||||||
return Result.MessageFailure(
|
return Result.MessageFailure(
|
||||||
|
|
@ -33,7 +34,8 @@ namespace Ryujinx.Ava.Utilities
|
||||||
if (DockedMode) DockedModeOverride = true;
|
if (DockedMode) DockedModeOverride = true;
|
||||||
if (HandheldMode) DockedModeOverride = false;
|
if (HandheldMode) DockedModeOverride = false;
|
||||||
}
|
}
|
||||||
{ // Hardware Acceleration Override
|
{
|
||||||
|
// Hardware Acceleration Override
|
||||||
if (SoftwareGui)
|
if (SoftwareGui)
|
||||||
{
|
{
|
||||||
HardwareAccelerationOverride = false;
|
HardwareAccelerationOverride = false;
|
||||||
|
|
@ -57,10 +59,12 @@ namespace Ryujinx.Ava.Utilities
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Option("docked-mode", Required = false, Default = false, HelpText = "Launch the game in Docked mode.")]
|
[Option("docked-mode", Required = false, Default = false,
|
||||||
|
HelpText = "Launch the game in Docked mode. Causes an error if used in tandem with --handheld-mode.")]
|
||||||
public bool DockedMode { get; set; }
|
public bool DockedMode { get; set; }
|
||||||
|
|
||||||
[Option("handheld-mode", Required = false, Default = false, HelpText = "Launch the game in Handheld mode.")]
|
[Option("handheld-mode", Required = false, Default = false,
|
||||||
|
HelpText = "Launch the game in Handheld mode. Causes an error if used in tandem with --docked-mode.")]
|
||||||
public bool HandheldMode { get; set; }
|
public bool HandheldMode { get; set; }
|
||||||
|
|
||||||
[Option("software-gui", Required = false, Default = false,
|
[Option("software-gui", Required = false, Default = false,
|
||||||
|
|
@ -108,20 +112,34 @@ namespace Ryujinx.Ava.Utilities
|
||||||
Default = "{EmuVersion}\n{GuestName} {GuestVersion} {GuestTitleId} {GuestArch}")]
|
Default = "{EmuVersion}\n{GuestName} {GuestVersion} {GuestTitleId} {GuestArch}")]
|
||||||
public string RenderDocCaptureTitleFormat { get; set; }
|
public string RenderDocCaptureTitleFormat { get; set; }
|
||||||
|
|
||||||
[Option("install-firmware", Required = false, Default = null, HelpText = "Specify a file path containing Switch firmware to install immediately after starting. Must be a directory or a .zip or .xci file.")]
|
[Option("install-firmware", Required = false, Default = null,
|
||||||
|
HelpText =
|
||||||
|
"Specify a file path containing Switch firmware to install immediately after starting. Must be a directory or a .zip or .xci file.")]
|
||||||
public string FirmwareToInstallPathRaw { get; set; }
|
public string FirmwareToInstallPathRaw { get; set; }
|
||||||
|
|
||||||
[Option('p', "profile", Required = false, Default = null, HelpText = "The profile name to open the application with. Defaults to your last used profile.")]
|
[Option('p', "profile", Required = false, Default = null,
|
||||||
|
HelpText = "The profile name to open the application with. Defaults to your last used profile.")]
|
||||||
public string Profile { get; set; }
|
public string Profile { get; set; }
|
||||||
[Option('i', "application-id", Required = false, Default = null, HelpText = "Specify which application ID out of the specified content archive path to launch.")]
|
|
||||||
|
[Option('i', "application-id", Required = false, Default = null,
|
||||||
|
HelpText = "Specify which application ID out of the specified content archive path to launch.")]
|
||||||
public string LaunchApplicationId { get; set; }
|
public string LaunchApplicationId { get; set; }
|
||||||
[Option('f', "fullscreen", Required = false, Default = false, HelpText = "Start the emulator in fullscreen mode.")]
|
|
||||||
|
[Option('f', "fullscreen", Required = false, Default = false,
|
||||||
|
HelpText = "Start the emulator in fullscreen mode.")]
|
||||||
public bool StartFullscreen { get; set; }
|
public bool StartFullscreen { get; set; }
|
||||||
|
|
||||||
[Option("hide-updates", Required = false, Default = false, HelpText = "Hides update prompt/notification.")]
|
[Option("hide-updates", Required = false, Default = false, HelpText = "Hides update prompt/notification.")]
|
||||||
public bool HideAvailableUpdates { get; set; }
|
public bool HideAvailableUpdates { get; set; }
|
||||||
[Option("local-only-amiibo", Required = false, Default = false, HelpText = "Only use the local Amiibo cache; do not update it even if there is an update.")]
|
|
||||||
|
[Option("local-only-amiibo", Required = false, Default = false,
|
||||||
|
HelpText = "Only use the local Amiibo cache; do not update it even if there is an update.")]
|
||||||
public bool OnlyLocalAmiibo { get; set; }
|
public bool OnlyLocalAmiibo { get; set; }
|
||||||
|
|
||||||
|
[Option("core-dumps", Required = false, Default = false,
|
||||||
|
HelpText = "Enable coredumps on Linux platforms. They are disabled by default.")]
|
||||||
|
public bool CoreDumpsEnabled { get; set; }
|
||||||
|
|
||||||
[Value(0, Default = null, Required = false,
|
[Value(0, Default = null, Required = false,
|
||||||
HelpText =
|
HelpText =
|
||||||
"The Nintendo Switch application content archive to launch immediately after starting, if desired.")]
|
"The Nintendo Switch application content archive to launch immediately after starting, if desired.")]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue