aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx/Ui/MainWindow.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx/Ui/MainWindow.cs')
-rw-r--r--Ryujinx/Ui/MainWindow.cs249
1 files changed, 118 insertions, 131 deletions
diff --git a/Ryujinx/Ui/MainWindow.cs b/Ryujinx/Ui/MainWindow.cs
index 6d3d4aad..e0252016 100644
--- a/Ryujinx/Ui/MainWindow.cs
+++ b/Ryujinx/Ui/MainWindow.cs
@@ -590,10 +590,10 @@ namespace Ryujinx.Ui
private void SetupProgressUiHandlers()
{
- if (_emulationContext.Application.DiskCacheLoadState != null)
+ if (_emulationContext.Processes.ActiveApplication.DiskCacheLoadState != null)
{
- _emulationContext.Application.DiskCacheLoadState.StateChanged -= ProgressHandler;
- _emulationContext.Application.DiskCacheLoadState.StateChanged += ProgressHandler;
+ _emulationContext.Processes.ActiveApplication.DiskCacheLoadState.StateChanged -= ProgressHandler;
+ _emulationContext.Processes.ActiveApplication.DiskCacheLoadState.StateChanged += ProgressHandler;
}
_emulationContext.Gpu.ShaderCacheStateChanged -= ProgressHandler;
@@ -690,156 +690,143 @@ namespace Ryujinx.Ui
}
}
- public void LoadApplication(string path, bool startFullscreen = false)
+ private bool LoadApplication(string path, bool isFirmwareTitle)
{
- if (_gameLoaded)
- {
- GtkDialog.CreateInfoDialog("A game has already been loaded", "Please stop emulation or close the emulator before launching another game.");
- }
- else
+ SystemVersion firmwareVersion = _contentManager.GetCurrentFirmwareVersion();
+
+ if (!SetupValidator.CanStartApplication(_contentManager, path, out UserError userError))
{
- PerformanceCheck();
+ if (SetupValidator.CanFixStartApplication(_contentManager, path, userError, out firmwareVersion))
+ {
+ string message = $"Would you like to install the firmware embedded in this game? (Firmware {firmwareVersion.VersionString})";
- Logger.RestartTime();
+ ResponseType responseDialog = (ResponseType)GtkDialog.CreateConfirmationDialog("No Firmware Installed", message).Run();
- RendererWidget = CreateRendererWidget();
+ if (responseDialog != ResponseType.Yes || !SetupValidator.TryFixStartApplication(_contentManager, path, userError, out _))
+ {
+ UserErrorDialog.CreateUserErrorDialog(userError);
- SwitchToRenderWidget(startFullscreen);
+ return false;
+ }
- InitializeSwitchInstance();
+ // Tell the user that we installed a firmware for them.
- UpdateGraphicsConfig();
+ firmwareVersion = _contentManager.GetCurrentFirmwareVersion();
- SystemVersion firmwareVersion = _contentManager.GetCurrentFirmwareVersion();
+ RefreshFirmwareLabel();
- bool isDirectory = Directory.Exists(path);
- bool isFirmwareTitle = false;
+ message = $"No installed firmware was found but Ryujinx was able to install firmware {firmwareVersion.VersionString} from the provided game.\nThe emulator will now start.";
- if (path.StartsWith("@SystemContent"))
+ GtkDialog.CreateInfoDialog($"Firmware {firmwareVersion.VersionString} was installed", message);
+ }
+ else
{
- path = _virtualFileSystem.SwitchPathToSystemPath(path);
+ UserErrorDialog.CreateUserErrorDialog(userError);
- isFirmwareTitle = true;
+ return false;
}
+ }
- if (!SetupValidator.CanStartApplication(_contentManager, path, out UserError userError))
- {
- if (SetupValidator.CanFixStartApplication(_contentManager, path, userError, out firmwareVersion))
- {
- if (userError == UserError.NoFirmware)
- {
- string message = $"Would you like to install the firmware embedded in this game? (Firmware {firmwareVersion.VersionString})";
+ Logger.Notice.Print(LogClass.Application, $"Using Firmware Version: {firmwareVersion?.VersionString}");
- ResponseType responseDialog = (ResponseType)GtkDialog.CreateConfirmationDialog("No Firmware Installed", message).Run();
+ if (isFirmwareTitle)
+ {
+ Logger.Info?.Print(LogClass.Application, "Loading as Firmware Title (NCA).");
- if (responseDialog != ResponseType.Yes)
- {
- UserErrorDialog.CreateUserErrorDialog(userError);
+ return _emulationContext.LoadNca(path);
+ }
- _emulationContext.Dispose();
- SwitchToGameTable();
+ if (Directory.Exists(path))
+ {
+ string[] romFsFiles = Directory.GetFiles(path, "*.istorage");
- return;
- }
- }
+ if (romFsFiles.Length == 0)
+ {
+ romFsFiles = Directory.GetFiles(path, "*.romfs");
+ }
- if (!SetupValidator.TryFixStartApplication(_contentManager, path, userError, out _))
- {
- UserErrorDialog.CreateUserErrorDialog(userError);
+ if (romFsFiles.Length > 0)
+ {
+ Logger.Info?.Print(LogClass.Application, "Loading as cart with RomFS.");
+
+ return _emulationContext.LoadCart(path, romFsFiles[0]);
+ }
- _emulationContext.Dispose();
- SwitchToGameTable();
+ Logger.Info?.Print(LogClass.Application, "Loading as cart WITHOUT RomFS.");
- return;
- }
+ return _emulationContext.LoadCart(path);
+ }
- // Tell the user that we installed a firmware for them.
- if (userError == UserError.NoFirmware)
+ if (File.Exists(path))
+ {
+ switch (System.IO.Path.GetExtension(path).ToLowerInvariant())
+ {
+ case ".xci":
+ Logger.Info?.Print(LogClass.Application, "Loading as XCI.");
+
+ return _emulationContext.LoadXci(path);
+ case ".nca":
+ Logger.Info?.Print(LogClass.Application, "Loading as NCA.");
+
+ return _emulationContext.LoadNca(path);
+ case ".nsp":
+ case ".pfs0":
+ Logger.Info?.Print(LogClass.Application, "Loading as NSP.");
+
+ return _emulationContext.LoadNsp(path);
+ default:
+ Logger.Info?.Print(LogClass.Application, "Loading as Homebrew.");
+ try
+ {
+ return _emulationContext.LoadProgram(path);
+ }
+ catch (ArgumentOutOfRangeException)
{
- firmwareVersion = _contentManager.GetCurrentFirmwareVersion();
+ Logger.Error?.Print(LogClass.Application, "The specified file is not supported by Ryujinx.");
- RefreshFirmwareLabel();
+ return false;
+ }
+ }
+ }
- string message = $"No installed firmware was found but Ryujinx was able to install firmware {firmwareVersion.VersionString} from the provided game.\nThe emulator will now start.";
+ Logger.Warning?.Print(LogClass.Application, "Please specify a valid XCI/NCA/NSP/PFS0/NRO file.");
- GtkDialog.CreateInfoDialog($"Firmware {firmwareVersion.VersionString} was installed", message);
- }
- }
- else
- {
- UserErrorDialog.CreateUserErrorDialog(userError);
+ return false;
+ }
- _emulationContext.Dispose();
- SwitchToGameTable();
+ public void RunApplication(string path, bool startFullscreen = false)
+ {
+ if (_gameLoaded)
+ {
+ GtkDialog.CreateInfoDialog("A game has already been loaded", "Please stop emulation or close the emulator before launching another game.");
+ }
+ else
+ {
+ PerformanceCheck();
- return;
- }
- }
+ Logger.RestartTime();
- Logger.Notice.Print(LogClass.Application, $"Using Firmware Version: {firmwareVersion?.VersionString}");
+ RendererWidget = CreateRendererWidget();
- if (isFirmwareTitle)
- {
- Logger.Info?.Print(LogClass.Application, "Loading as Firmware Title (NCA).");
+ SwitchToRenderWidget(startFullscreen);
- _emulationContext.LoadNca(path);
- }
- else if (Directory.Exists(path))
- {
- string[] romFsFiles = Directory.GetFiles(path, "*.istorage");
+ InitializeSwitchInstance();
- if (romFsFiles.Length == 0)
- {
- romFsFiles = Directory.GetFiles(path, "*.romfs");
- }
+ UpdateGraphicsConfig();
- if (romFsFiles.Length > 0)
- {
- Logger.Info?.Print(LogClass.Application, "Loading as cart with RomFS.");
- _emulationContext.LoadCart(path, romFsFiles[0]);
- }
- else
- {
- Logger.Info?.Print(LogClass.Application, "Loading as cart WITHOUT RomFS.");
- _emulationContext.LoadCart(path);
- }
- }
- else if (File.Exists(path))
+ bool isFirmwareTitle = false;
+
+ if (path.StartsWith("@SystemContent"))
{
- switch (System.IO.Path.GetExtension(path).ToLowerInvariant())
- {
- case ".xci":
- Logger.Info?.Print(LogClass.Application, "Loading as XCI.");
- _emulationContext.LoadXci(path);
- break;
- case ".nca":
- Logger.Info?.Print(LogClass.Application, "Loading as NCA.");
- _emulationContext.LoadNca(path);
- break;
- case ".nsp":
- case ".pfs0":
- Logger.Info?.Print(LogClass.Application, "Loading as NSP.");
- _emulationContext.LoadNsp(path);
- break;
- default:
- Logger.Info?.Print(LogClass.Application, "Loading as Homebrew.");
- try
- {
- _emulationContext.LoadProgram(path);
- }
- catch (ArgumentOutOfRangeException)
- {
- Logger.Error?.Print(LogClass.Application, "The specified file is not supported by Ryujinx.");
- }
- break;
- }
+ path = _virtualFileSystem.SwitchPathToSystemPath(path);
+
+ isFirmwareTitle = true;
}
- else
- {
- Logger.Warning?.Print(LogClass.Application, "Please specify a valid XCI/NCA/NSP/PFS0/NRO file.");
+ if (!LoadApplication(path, isFirmwareTitle))
+ {
_emulationContext.Dispose();
- RendererWidget.Dispose();
+ SwitchToGameTable();
return;
}
@@ -852,10 +839,7 @@ namespace Ryujinx.Ui
Translator.IsReadyForTranslation.Reset();
- Thread windowThread = new Thread(() =>
- {
- CreateGameWindow();
- })
+ Thread windowThread = new(CreateGameWindow)
{
Name = "GUI.WindowThread"
};
@@ -871,9 +855,10 @@ namespace Ryujinx.Ui
_firmwareInstallFile.Sensitive = false;
_firmwareInstallDirectory.Sensitive = false;
- DiscordIntegrationModule.SwitchToPlayingState(_emulationContext.Application.TitleIdText, _emulationContext.Application.TitleName);
+ DiscordIntegrationModule.SwitchToPlayingState(_emulationContext.Processes.ActiveApplication.ProgramIdText,
+ _emulationContext.Processes.ActiveApplication.ApplicationControlProperties.Title[(int)_emulationContext.System.State.DesiredTitleLanguage].NameString.ToString());
- _applicationLibrary.LoadAndSaveMetaData(_emulationContext.Application.TitleIdText, appMetadata =>
+ _applicationLibrary.LoadAndSaveMetaData(_emulationContext.Processes.ActiveApplication.ProgramIdText, appMetadata =>
{
appMetadata.LastPlayed = DateTime.UtcNow.ToString();
});
@@ -1055,7 +1040,7 @@ namespace Ryujinx.Ui
if (_emulationContext != null)
{
- UpdateGameMetadata(_emulationContext.Application.TitleIdText);
+ UpdateGameMetadata(_emulationContext.Processes.ActiveApplication.ProgramIdText);
if (RendererWidget != null)
{
@@ -1174,7 +1159,7 @@ namespace Ryujinx.Ui
string path = (string)_tableStore.GetValue(treeIter, 9);
- LoadApplication(path);
+ RunApplication(path);
}
private void VSyncStatus_Clicked(object sender, ButtonReleaseEventArgs args)
@@ -1260,7 +1245,7 @@ namespace Ryujinx.Ui
if (fileChooser.Run() == (int)ResponseType.Accept)
{
- LoadApplication(fileChooser.Filename);
+ RunApplication(fileChooser.Filename);
}
}
}
@@ -1271,7 +1256,7 @@ namespace Ryujinx.Ui
{
if (fileChooser.Run() == (int)ResponseType.Accept)
{
- LoadApplication(fileChooser.Filename);
+ RunApplication(fileChooser.Filename);
}
}
}
@@ -1287,7 +1272,7 @@ namespace Ryujinx.Ui
{
string contentPath = _contentManager.GetInstalledContentPath(0x0100000000001009, StorageId.BuiltInSystem, NcaContentType.Program);
- LoadApplication(contentPath);
+ RunApplication(contentPath);
}
private void Open_Ryu_Folder(object sender, EventArgs args)
@@ -1328,7 +1313,7 @@ namespace Ryujinx.Ui
{
if (_emulationContext != null)
{
- UpdateGameMetadata(_emulationContext.Application.TitleIdText);
+ UpdateGameMetadata(_emulationContext.Processes.ActiveApplication.ProgramIdText);
}
_pauseEmulation.Sensitive = false;
@@ -1533,7 +1518,7 @@ namespace Ryujinx.Ui
{
_userChannelPersistence.ShouldRestart = false;
- LoadApplication(_currentEmulatedGamePath);
+ RunApplication(_currentEmulatedGamePath);
}
else
{
@@ -1596,7 +1581,9 @@ namespace Ryujinx.Ui
private void ManageCheats_Pressed(object sender, EventArgs args)
{
- var window = new CheatWindow(_virtualFileSystem, _emulationContext.Application.TitleId, _emulationContext.Application.TitleName);
+ var window = new CheatWindow(_virtualFileSystem,
+ _emulationContext.Processes.ActiveApplication.ProgramId,
+ _emulationContext.Processes.ActiveApplication.ApplicationControlProperties.Title[(int)_emulationContext.System.State.DesiredTitleLanguage].NameString.ToString());
window.Destroyed += CheatWindow_Destroyed;
window.Show();
@@ -1639,7 +1626,7 @@ namespace Ryujinx.Ui
LastScannedAmiiboShowAll = _lastScannedAmiiboShowAll,
LastScannedAmiiboId = _lastScannedAmiiboId,
DeviceId = deviceId,
- TitleId = _emulationContext.Application.TitleIdText.ToUpper()
+ TitleId = _emulationContext.Processes.ActiveApplication.ProgramIdText.ToUpper()
};
amiiboWindow.DeleteEvent += AmiiboWindow_DeleteEvent;