mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-15 07:00:32 +00:00
Make Ryujinx metadata user-specific
This commit is contained in:
parent
306f7e93a0
commit
d6d2b202d1
8 changed files with 32 additions and 15 deletions
|
@ -682,7 +682,7 @@ namespace Ryujinx.Ava
|
||||||
|
|
||||||
DiscordIntegrationModule.SwitchToPlayingState(Device.Processes.ActiveApplication.ProgramIdText, Device.Processes.ActiveApplication.Name);
|
DiscordIntegrationModule.SwitchToPlayingState(Device.Processes.ActiveApplication.ProgramIdText, Device.Processes.ActiveApplication.Name);
|
||||||
|
|
||||||
_viewModel.ApplicationLibrary.LoadAndSaveMetaData(Device.Processes.ActiveApplication.ProgramIdText, appMetadata =>
|
_viewModel.ApplicationLibrary.LoadAndSaveMetaData(_accountManager.LastOpenedUser.UserId.ToLibHacFsUid(), Device.Processes.ActiveApplication.ProgramIdText, appMetadata =>
|
||||||
{
|
{
|
||||||
appMetadata.LastPlayed = DateTime.UtcNow;
|
appMetadata.LastPlayed = DateTime.UtcNow;
|
||||||
});
|
});
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace Ryujinx.Ava.UI.Controls
|
||||||
{
|
{
|
||||||
viewModel.SelectedApplication.Favorite = !viewModel.SelectedApplication.Favorite;
|
viewModel.SelectedApplication.Favorite = !viewModel.SelectedApplication.Favorite;
|
||||||
|
|
||||||
viewModel.ApplicationLibrary.LoadAndSaveMetaData(viewModel.SelectedApplication.TitleId, appMetadata =>
|
viewModel.ApplicationLibrary.LoadAndSaveMetaData(viewModel.AccountManager.LastOpenedUser.UserId.ToLibHacFsUid(), viewModel.SelectedApplication.TitleId, appMetadata =>
|
||||||
{
|
{
|
||||||
appMetadata.Favorite = viewModel.SelectedApplication.Favorite;
|
appMetadata.Favorite = viewModel.SelectedApplication.Favorite;
|
||||||
});
|
});
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace Ryujinx.Ava.UI.Models
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var appMetadata = MainWindow.MainWindowViewModel.ApplicationLibrary.LoadAndSaveMetaData(TitleIdString);
|
var appMetadata = MainWindow.MainWindowViewModel.ApplicationLibrary.LoadAndSaveMetaData(UserId, TitleIdString);
|
||||||
Title = appMetadata.Title ?? TitleIdString;
|
Title = appMetadata.Title ?? TitleIdString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1523,7 +1523,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
|
|
||||||
public void UpdateGameMetadata(string titleId)
|
public void UpdateGameMetadata(string titleId)
|
||||||
{
|
{
|
||||||
ApplicationLibrary.LoadAndSaveMetaData(titleId, appMetadata =>
|
ApplicationLibrary.LoadAndSaveMetaData(AccountManager.LastOpenedUser.UserId.ToLibHacFsUid(), titleId, appMetadata =>
|
||||||
{
|
{
|
||||||
if (appMetadata.LastPlayed.HasValue)
|
if (appMetadata.LastPlayed.HasValue)
|
||||||
{
|
{
|
||||||
|
|
|
@ -554,7 +554,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
|
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
|
|
||||||
ApplicationLibrary.LoadApplications(ConfigurationState.Instance.Ui.GameDirs.Value, ConfigurationState.Instance.System.Language);
|
ApplicationLibrary.LoadApplications(ViewModel.AccountManager.LastOpenedUser.UserId.ToLibHacFsUid(), ConfigurationState.Instance.Ui.GameDirs.Value, ConfigurationState.Instance.System.Language);
|
||||||
|
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,11 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
||||||
return new Uid((ulong)High, (ulong)Low);
|
return new Uid((ulong)High, (ulong)Low);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LibHac.Fs.UserId ToLibHacFsUid()
|
||||||
|
{
|
||||||
|
return new LibHac.Fs.UserId((ulong)High, (ulong)Low);
|
||||||
|
}
|
||||||
|
|
||||||
public UInt128 ToUInt128()
|
public UInt128 ToUInt128()
|
||||||
{
|
{
|
||||||
return new UInt128((ulong)High, (ulong)Low);
|
return new UInt128((ulong)High, (ulong)Low);
|
||||||
|
|
|
@ -81,7 +81,7 @@ namespace Ryujinx.Ui.App.Common
|
||||||
controlFile.Get.Read(out _, 0, outProperty, ReadOption.None).ThrowIfFailure();
|
controlFile.Get.Read(out _, 0, outProperty, ReadOption.None).ThrowIfFailure();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadApplications(List<string> appDirs, Language desiredTitleLanguage)
|
public void LoadApplications(UserId userId, List<string> appDirs, Language desiredTitleLanguage)
|
||||||
{
|
{
|
||||||
int numApplicationsFound = 0;
|
int numApplicationsFound = 0;
|
||||||
int numApplicationsLoaded = 0;
|
int numApplicationsLoaded = 0;
|
||||||
|
@ -418,7 +418,7 @@ namespace Ryujinx.Ui.App.Common
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationMetadata appMetadata = LoadAndSaveMetaData(titleId, appMetadata =>
|
ApplicationMetadata appMetadata = LoadAndSaveMetaData(userId, titleId, appMetadata =>
|
||||||
{
|
{
|
||||||
appMetadata.Title = titleName;
|
appMetadata.Title = titleName;
|
||||||
|
|
||||||
|
@ -508,17 +508,29 @@ namespace Ryujinx.Ui.App.Common
|
||||||
titleId = controlNca?.Header.TitleId.ToString("x16");
|
titleId = controlNca?.Header.TitleId.ToString("x16");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationMetadata LoadAndSaveMetaData(string titleId, Action<ApplicationMetadata> modifyFunction = null)
|
public ApplicationMetadata LoadAndSaveMetaData(UserId userId, string titleId, Action<ApplicationMetadata> modifyFunction = null)
|
||||||
{
|
{
|
||||||
string metadataFolder = Path.Combine(AppDataManager.GamesDirPath, titleId, "gui");
|
string guiFolder = Path.Combine(AppDataManager.GamesDirPath, titleId, "gui");
|
||||||
|
string metadataFolder = Path.Combine(guiFolder, userId.ToString());
|
||||||
string metadataFile = Path.Combine(metadataFolder, "metadata.json");
|
string metadataFile = Path.Combine(metadataFolder, "metadata.json");
|
||||||
|
|
||||||
|
if (!Directory.Exists(metadataFolder))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(metadataFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle migration from old default to current user
|
||||||
|
string legacyFile = Path.Combine(guiFolder, "metadata.json");
|
||||||
|
if (File.Exists(legacyFile) && !File.Exists(metadataFile))
|
||||||
|
{
|
||||||
|
File.Move(legacyFile, metadataFile);
|
||||||
|
File.Delete(legacyFile);
|
||||||
|
}
|
||||||
|
|
||||||
ApplicationMetadata appMetadata;
|
ApplicationMetadata appMetadata;
|
||||||
|
|
||||||
if (!File.Exists(metadataFile))
|
if (!File.Exists(metadataFile))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(metadataFolder);
|
|
||||||
|
|
||||||
appMetadata = new ApplicationMetadata();
|
appMetadata = new ApplicationMetadata();
|
||||||
|
|
||||||
JsonHelper.SerializeToFile(metadataFile, appMetadata, SerializerContext.ApplicationMetadata);
|
JsonHelper.SerializeToFile(metadataFile, appMetadata, SerializerContext.ApplicationMetadata);
|
||||||
|
|
|
@ -657,7 +657,7 @@ namespace Ryujinx.Ui
|
||||||
|
|
||||||
Thread applicationLibraryThread = new Thread(() =>
|
Thread applicationLibraryThread = new Thread(() =>
|
||||||
{
|
{
|
||||||
_applicationLibrary.LoadApplications(ConfigurationState.Instance.Ui.GameDirs, ConfigurationState.Instance.System.Language);
|
_applicationLibrary.LoadApplications(_accountManager.LastOpenedUser.UserId.ToLibHacFsUid(), ConfigurationState.Instance.Ui.GameDirs, ConfigurationState.Instance.System.Language);
|
||||||
|
|
||||||
_updatingGameTable = false;
|
_updatingGameTable = false;
|
||||||
});
|
});
|
||||||
|
@ -874,7 +874,7 @@ namespace Ryujinx.Ui
|
||||||
DiscordIntegrationModule.SwitchToPlayingState(_emulationContext.Processes.ActiveApplication.ProgramIdText,
|
DiscordIntegrationModule.SwitchToPlayingState(_emulationContext.Processes.ActiveApplication.ProgramIdText,
|
||||||
_emulationContext.Processes.ActiveApplication.ApplicationControlProperties.Title[(int)_emulationContext.System.State.DesiredTitleLanguage].NameString.ToString());
|
_emulationContext.Processes.ActiveApplication.ApplicationControlProperties.Title[(int)_emulationContext.System.State.DesiredTitleLanguage].NameString.ToString());
|
||||||
|
|
||||||
_applicationLibrary.LoadAndSaveMetaData(_emulationContext.Processes.ActiveApplication.ProgramIdText, appMetadata =>
|
_applicationLibrary.LoadAndSaveMetaData(_accountManager.LastOpenedUser.UserId.ToLibHacFsUid(), _emulationContext.Processes.ActiveApplication.ProgramIdText, appMetadata =>
|
||||||
{
|
{
|
||||||
appMetadata.LastPlayed = DateTime.UtcNow;
|
appMetadata.LastPlayed = DateTime.UtcNow;
|
||||||
});
|
});
|
||||||
|
@ -1017,7 +1017,7 @@ namespace Ryujinx.Ui
|
||||||
{
|
{
|
||||||
if (_gameLoaded)
|
if (_gameLoaded)
|
||||||
{
|
{
|
||||||
_applicationLibrary.LoadAndSaveMetaData(titleId, appMetadata =>
|
_applicationLibrary.LoadAndSaveMetaData(_accountManager.LastOpenedUser.UserId.ToLibHacFsUid(), titleId, appMetadata =>
|
||||||
{
|
{
|
||||||
if (appMetadata.LastPlayed.HasValue)
|
if (appMetadata.LastPlayed.HasValue)
|
||||||
{
|
{
|
||||||
|
@ -1156,7 +1156,7 @@ namespace Ryujinx.Ui
|
||||||
|
|
||||||
_tableStore.SetValue(treeIter, 0, newToggleValue);
|
_tableStore.SetValue(treeIter, 0, newToggleValue);
|
||||||
|
|
||||||
_applicationLibrary.LoadAndSaveMetaData(titleId, appMetadata =>
|
_applicationLibrary.LoadAndSaveMetaData(_accountManager.LastOpenedUser.UserId.ToLibHacFsUid(), titleId, appMetadata =>
|
||||||
{
|
{
|
||||||
appMetadata.Favorite = newToggleValue;
|
appMetadata.Favorite = newToggleValue;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue