Skip to content

Commit

Permalink
Revert "Add support for multi game XCIs (#5638)" (#5914)
Browse files Browse the repository at this point in the history
This reverts commit 5c3cfb8.
  • Loading branch information
gdkchan authored Nov 12, 2023
1 parent 6228331 commit 51065d9
Show file tree
Hide file tree
Showing 33 changed files with 764 additions and 1,116 deletions.
9 changes: 4 additions & 5 deletions src/Ryujinx.Ava/AppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
using static Ryujinx.Ava.UI.Helpers.Win32NativeInterop;
using AntiAliasing = Ryujinx.Common.Configuration.AntiAliasing;
using Image = SixLabors.ImageSharp.Image;
using InputManager = Ryujinx.Input.HLE.InputManager;
using IRenderer = Ryujinx.Graphics.GAL.IRenderer;
using Key = Ryujinx.Input.Key;
using MouseButton = Ryujinx.Input.MouseButton;
using ScalingFilter = Ryujinx.Common.Configuration.ScalingFilter;
Expand Down Expand Up @@ -121,14 +123,12 @@ internal class AppHost
public int Width { get; private set; }
public int Height { get; private set; }
public string ApplicationPath { get; private set; }
public ulong ApplicationId { get; private set; }
public bool ScreenshotRequested { get; set; }

public AppHost(
RendererHost renderer,
InputManager inputManager,
string applicationPath,
ulong applicationId,
VirtualFileSystem virtualFileSystem,
ContentManager contentManager,
AccountManager accountManager,
Expand All @@ -152,7 +152,6 @@ public AppHost(
NpadManager = _inputManager.CreateNpadManager();
TouchScreenManager = _inputManager.CreateTouchScreenManager();
ApplicationPath = applicationPath;
ApplicationId = applicationId;
VirtualFileSystem = virtualFileSystem;
ContentManager = contentManager;

Expand Down Expand Up @@ -642,7 +641,7 @@ await ContentDialogHelper.CreateInfoDialog(
{
Logger.Info?.Print(LogClass.Application, "Loading as XCI.");

if (!Device.LoadXci(ApplicationPath, ApplicationId))
if (!Device.LoadXci(ApplicationPath))
{
Device.Dispose();

Expand All @@ -669,7 +668,7 @@ await ContentDialogHelper.CreateInfoDialog(
{
Logger.Info?.Print(LogClass.Application, "Loading as NSP.");

if (!Device.LoadNsp(ApplicationPath, ApplicationId))
if (!Device.LoadNsp(ApplicationPath))
{
Device.Dispose();

Expand Down
2 changes: 0 additions & 2 deletions src/Ryujinx.Ava/Assets/Locales/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,6 @@
"OpenSetupGuideMessage": "Open the Setup Guide",
"NoUpdate": "No Update",
"TitleUpdateVersionLabel": "Version {0}",
"TitleBundledUpdateVersionLabel": "Bundled: Version {0}",
"TitleBundledDlcLabel": "Bundled:",
"RyujinxInfo": "Ryujinx - Info",
"RyujinxConfirm": "Ryujinx - Confirmation",
"FileDialogAllTypes": "All types",
Expand Down
9 changes: 2 additions & 7 deletions src/Ryujinx.Ava/Common/ApplicationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
using Ryujinx.Common.Logging;
using Ryujinx.HLE.FileSystem;
using Ryujinx.HLE.HOS.Services.Account.Acc;
using Ryujinx.HLE.Loaders.Processes.Extensions;
using Ryujinx.Ui.Common.Configuration;
using Ryujinx.Ui.App.Common;
using Ryujinx.Ui.Common.Helper;
using System;
using System.Buffers;
Expand Down Expand Up @@ -227,11 +226,7 @@ public static async Task ExtractSection(IStorageProvider storageProvider, NcaSec
return;
}
IntegrityCheckLevel checkLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks
? IntegrityCheckLevel.ErrorOnInvalid
: IntegrityCheckLevel.None;
(Nca updatePatchNca, _) = mainNca.GetUpdateData(_virtualFileSystem, checkLevel, programIndex, out _);
(Nca updatePatchNca, _) = ApplicationLibrary.GetGameUpdateData(_virtualFileSystem, mainNca.Header.TitleId.ToString("x16"), programIndex, out _);
if (updatePatchNca != null)
{
patchNca = updatePatchNca;
Expand Down
54 changes: 33 additions & 21 deletions src/Ryujinx.Ava/UI/Controls/ApplicationContextMenu.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.Threading;
using LibHac.Fs;
using LibHac.Tools.FsSystem.NcaUtils;
using Ryujinx.Ava.Common;
Expand All @@ -14,6 +15,7 @@
using Ryujinx.Ui.Common.Helper;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using Path = System.IO.Path;

Expand All @@ -39,7 +41,7 @@ public void ToggleFavorite_Click(object sender, RoutedEventArgs args)
{
viewModel.SelectedApplication.Favorite = !viewModel.SelectedApplication.Favorite;

ApplicationLibrary.LoadAndSaveMetaData(viewModel.SelectedApplication.IdString, appMetadata =>
ApplicationLibrary.LoadAndSaveMetaData(viewModel.SelectedApplication.TitleId, appMetadata =>
{
appMetadata.Favorite = viewModel.SelectedApplication.Favorite;
});
Expand Down Expand Up @@ -74,9 +76,19 @@ private static void OpenSaveDirectory(MainWindowViewModel viewModel, SaveDataTyp
{
if (viewModel?.SelectedApplication != null)
{
var saveDataFilter = SaveDataFilter.Make(viewModel.SelectedApplication.Id, saveDataType, userId, saveDataId: default, index: default);
if (!ulong.TryParse(viewModel.SelectedApplication.TitleId, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out ulong titleIdNumber))
{
Dispatcher.UIThread.InvokeAsync(async () =>
{
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogRyujinxErrorMessage], LocaleManager.Instance[LocaleKeys.DialogInvalidTitleIdErrorMessage]);
});

return;
}

var saveDataFilter = SaveDataFilter.Make(titleIdNumber, saveDataType, userId, saveDataId: default, index: default);

ApplicationHelper.OpenSaveDir(in saveDataFilter, viewModel.SelectedApplication.Id, viewModel.SelectedApplication.ControlHolder, viewModel.SelectedApplication.Name);
ApplicationHelper.OpenSaveDir(in saveDataFilter, titleIdNumber, viewModel.SelectedApplication.ControlHolder, viewModel.SelectedApplication.TitleName);
}
}

Expand All @@ -86,7 +98,7 @@ public async void OpenTitleUpdateManager_Click(object sender, RoutedEventArgs ar

if (viewModel?.SelectedApplication != null)
{
await TitleUpdateWindow.Show(viewModel.VirtualFileSystem, viewModel.SelectedApplication);
await TitleUpdateWindow.Show(viewModel.VirtualFileSystem, ulong.Parse(viewModel.SelectedApplication.TitleId, NumberStyles.HexNumber), viewModel.SelectedApplication.TitleName);
}
}

Expand All @@ -96,7 +108,7 @@ public async void OpenDownloadableContentManager_Click(object sender, RoutedEven

if (viewModel?.SelectedApplication != null)
{
await DownloadableContentManagerWindow.Show(viewModel.VirtualFileSystem, viewModel.SelectedApplication);
await DownloadableContentManagerWindow.Show(viewModel.VirtualFileSystem, ulong.Parse(viewModel.SelectedApplication.TitleId, NumberStyles.HexNumber), viewModel.SelectedApplication.TitleName);
}
}

Expand All @@ -108,8 +120,8 @@ public async void OpenCheatManager_Click(object sender, RoutedEventArgs args)
{
await new CheatWindow(
viewModel.VirtualFileSystem,
viewModel.SelectedApplication.IdString,
viewModel.SelectedApplication.Name,
viewModel.SelectedApplication.TitleId,
viewModel.SelectedApplication.TitleName,
viewModel.SelectedApplication.Path).ShowDialog(viewModel.TopLevel as Window);
}
}
Expand All @@ -121,7 +133,7 @@ public void OpenModsDirectory_Click(object sender, RoutedEventArgs args)
if (viewModel?.SelectedApplication != null)
{
string modsBasePath = ModLoader.GetModsBasePath();
string titleModsPath = ModLoader.GetTitleDir(modsBasePath, viewModel.SelectedApplication.IdString);
string titleModsPath = ModLoader.GetTitleDir(modsBasePath, viewModel.SelectedApplication.TitleId);

OpenHelper.OpenFolder(titleModsPath);
}
Expand All @@ -134,7 +146,7 @@ public void OpenSdModsDirectory_Click(object sender, RoutedEventArgs args)
if (viewModel?.SelectedApplication != null)
{
string sdModsBasePath = ModLoader.GetSdModsBasePath();
string titleModsPath = ModLoader.GetTitleDir(sdModsBasePath, viewModel.SelectedApplication.IdString);
string titleModsPath = ModLoader.GetTitleDir(sdModsBasePath, viewModel.SelectedApplication.TitleId);

OpenHelper.OpenFolder(titleModsPath);
}
Expand All @@ -148,15 +160,15 @@ public async void PurgePtcCache_Click(object sender, RoutedEventArgs args)
{
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(
LocaleManager.Instance[LocaleKeys.DialogWarning],
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogPPTCDeletionMessage, viewModel.SelectedApplication.Name),
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogPPTCDeletionMessage, viewModel.SelectedApplication.TitleName),
LocaleManager.Instance[LocaleKeys.InputDialogYes],
LocaleManager.Instance[LocaleKeys.InputDialogNo],
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);

if (result == UserResult.Yes)
{
DirectoryInfo mainDir = new(Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.IdString, "cache", "cpu", "0"));
DirectoryInfo backupDir = new(Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.IdString, "cache", "cpu", "1"));
DirectoryInfo mainDir = new(Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.TitleId, "cache", "cpu", "0"));
DirectoryInfo backupDir = new(Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.TitleId, "cache", "cpu", "1"));

List<FileInfo> cacheFiles = new();

Expand Down Expand Up @@ -196,14 +208,14 @@ public async void PurgeShaderCache_Click(object sender, RoutedEventArgs args)
{
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(
LocaleManager.Instance[LocaleKeys.DialogWarning],
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogShaderDeletionMessage, viewModel.SelectedApplication.Name),
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogShaderDeletionMessage, viewModel.SelectedApplication.TitleName),
LocaleManager.Instance[LocaleKeys.InputDialogYes],
LocaleManager.Instance[LocaleKeys.InputDialogNo],
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);

if (result == UserResult.Yes)
{
DirectoryInfo shaderCacheDir = new(Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.IdString, "cache", "shader"));
DirectoryInfo shaderCacheDir = new(Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.TitleId, "cache", "shader"));

List<DirectoryInfo> oldCacheDirectories = new();
List<FileInfo> newCacheFiles = new();
Expand Down Expand Up @@ -251,7 +263,7 @@ public void OpenPtcDirectory_Click(object sender, RoutedEventArgs args)

if (viewModel?.SelectedApplication != null)
{
string ptcDir = Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.IdString, "cache", "cpu");
string ptcDir = Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.TitleId, "cache", "cpu");
string mainDir = Path.Combine(ptcDir, "0");
string backupDir = Path.Combine(ptcDir, "1");

Expand All @@ -272,7 +284,7 @@ public void OpenShaderCacheDirectory_Click(object sender, RoutedEventArgs args)

if (viewModel?.SelectedApplication != null)
{
string shaderCacheDir = Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.IdString, "cache", "shader");
string shaderCacheDir = Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.TitleId, "cache", "shader");

if (!Directory.Exists(shaderCacheDir))
{
Expand All @@ -293,7 +305,7 @@ await ApplicationHelper.ExtractSection(
viewModel.StorageProvider,
NcaSectionType.Code,
viewModel.SelectedApplication.Path,
viewModel.SelectedApplication.Name);
viewModel.SelectedApplication.TitleName);
}
}

Expand All @@ -307,7 +319,7 @@ await ApplicationHelper.ExtractSection(
viewModel.StorageProvider,
NcaSectionType.Data,
viewModel.SelectedApplication.Path,
viewModel.SelectedApplication.Name);
viewModel.SelectedApplication.TitleName);
}
}

Expand All @@ -321,7 +333,7 @@ await ApplicationHelper.ExtractSection(
viewModel.StorageProvider,
NcaSectionType.Logo,
viewModel.SelectedApplication.Path,
viewModel.SelectedApplication.Name);
viewModel.SelectedApplication.TitleName);
}
}

Expand All @@ -332,7 +344,7 @@ public void CreateApplicationShortcut_Click(object sender, RoutedEventArgs args)
if (viewModel?.SelectedApplication != null)
{
ApplicationData selectedApplication = viewModel.SelectedApplication;
ShortcutHelper.CreateAppShortcut(selectedApplication.Path, selectedApplication.Name, selectedApplication.IdString, selectedApplication.Icon);
ShortcutHelper.CreateAppShortcut(selectedApplication.Path, selectedApplication.TitleName, selectedApplication.TitleId, selectedApplication.Icon);
}
}

Expand All @@ -342,7 +354,7 @@ public async void RunApplication_Click(object sender, RoutedEventArgs args)

if (viewModel?.SelectedApplication != null)
{
await viewModel.LoadApplication(viewModel.SelectedApplication);
await viewModel.LoadApplication(viewModel.SelectedApplication.Path);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Ryujinx.Ava/UI/Controls/ApplicationGridView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding Name}"
Text="{Binding TitleName}"
TextAlignment="Center"
TextWrapping="Wrap" />
</Panel>
Expand Down
4 changes: 2 additions & 2 deletions src/Ryujinx.Ava/UI/Controls/ApplicationListView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<TextBlock
HorizontalAlignment="Stretch"
FontWeight="Bold"
Text="{Binding Name}"
Text="{Binding TitleName}"
TextAlignment="Left"
TextWrapping="Wrap" />
<TextBlock
Expand All @@ -109,7 +109,7 @@
Spacing="5">
<TextBlock
HorizontalAlignment="Stretch"
Text="{Binding Id, StringFormat=X16}"
Text="{Binding TitleId}"
TextAlignment="Left"
TextWrapping="Wrap" />
<TextBlock
Expand Down
6 changes: 1 addition & 5 deletions src/Ryujinx.Ava/UI/Models/DownloadableContentModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Ava.UI.ViewModels;
using System.IO;

namespace Ryujinx.Ava.UI.Models
Expand All @@ -25,9 +24,6 @@ public bool Enabled

public string FileName => Path.GetFileName(ContainerPath);

public string Label =>
Path.GetExtension(FileName)?.ToLower() == ".xci" ? $"{LocaleManager.Instance[LocaleKeys.TitleBundledDlcLabel]} {FileName}" : FileName;

public DownloadableContentModel(string titleId, string containerPath, string fullPath, bool enabled)
{
TitleId = titleId;
Expand Down
4 changes: 2 additions & 2 deletions src/Ryujinx.Ava/UI/Models/SaveModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ public SaveModel(SaveDataInfo info)
TitleId = info.ProgramId;
UserId = info.UserId;

var appData = MainWindow.MainWindowViewModel.Applications.FirstOrDefault(x => x.IdString.ToUpper() == TitleIdString);
var appData = MainWindow.MainWindowViewModel.Applications.FirstOrDefault(x => x.TitleId.ToUpper() == TitleIdString);

InGameList = appData != null;

if (InGameList)
{
Icon = appData.Icon;
Title = appData.Name;
Title = appData.TitleName;
}
else
{
Expand Down
5 changes: 1 addition & 4 deletions src/Ryujinx.Ava/UI/Models/TitleUpdateModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ public class TitleUpdateModel
public ApplicationControlProperty Control { get; }
public string Path { get; }

public string Label => LocaleManager.Instance.UpdateAndGetDynamicValue(
System.IO.Path.GetExtension(Path)?.ToLower() == ".xci" ? LocaleKeys.TitleBundledUpdateVersionLabel : LocaleKeys.TitleUpdateVersionLabel,
Control.DisplayVersionString.ToString()
);
public string Label => LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.TitleUpdateVersionLabel, Control.DisplayVersionString.ToString());

public TitleUpdateModel(ApplicationControlProperty control, string path)
{
Expand Down
Loading

0 comments on commit 51065d9

Please sign in to comment.