This commit is contained in:
dianyaa 2024-09-07 16:04:58 +02:00 committed by GitHub
commit 87b1f1e069
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 34 additions and 6 deletions

View file

@ -37,13 +37,16 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
_accountSaveDataManager = new AccountSaveDataManager(_profiles);
if (!_profiles.TryGetValue(DefaultUserId.ToString(), out _))
if (_profiles.IsEmpty)
{
byte[] defaultUserImage = EmbeddedResources.Read("Ryujinx.HLE/HOS/Services/Account/Acc/DefaultUserImage.jpg");
AddUser("RyuPlayer", defaultUserImage, DefaultUserId);
// Use a random UserId as default to avoid issues in multiplayer per #3396.
UserId userId = new UserId(Guid.NewGuid().ToString().Replace("-", ""));
OpenUser(DefaultUserId);
AddUser("RyuPlayer", defaultUserImage, userId);
OpenUser(userId);
}
else
{
@ -184,7 +187,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
_profiles.Remove(userId.ToString(), out _);
OpenUser(DefaultUserId);
OpenUser(new UserId(_profiles.First().Key));
_accountSaveDataManager.Save(_profiles);
}

View file

@ -129,6 +129,13 @@ namespace Ryujinx.Ava
}
}
// Check if we've made any profiles yet
if (!File.Exists(Path.Combine(AppDataManager.BaseDirPath, "system", "Profiles.json")))
{
MainWindow.ShowNewUserEditPrompt = true;
}
if (CommandLineState.LaunchPathArg != null)
{
MainWindow.DeferLoadApplication(CommandLineState.LaunchPathArg, CommandLineState.LaunchApplicationId, CommandLineState.StartFullscreenArg);

View file

@ -1,13 +1,13 @@
using Avalonia.Controls;
using Avalonia.Data;
using Avalonia.Interactivity;
using FluentAvalonia.Core;
using FluentAvalonia.UI.Controls;
using FluentAvalonia.UI.Navigation;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.Controls;
using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.Models;
using Ryujinx.HLE.HOS.Services.Account.Acc;
using System;
using UserProfile = Ryujinx.Ava.UI.Models.UserProfile;
@ -21,7 +21,9 @@ namespace Ryujinx.Ava.UI.Views.User
public TempProfile TempProfile { get; set; }
public static uint MaxProfileNameLength => 0x20;
public bool IsDeletable => _profile.UserId != AccountManager.DefaultUserId;
// Don't allow deletion if there is only one user
public bool IsDeletable => _parent.AccountManager.GetAllUsers().Count() != 1;
public UserEditorView()
{

View file

@ -58,6 +58,8 @@ namespace Ryujinx.Ava.UI.Windows
public SettingsWindow SettingsWindow { get; set; }
public static bool ShowKeyErrorOnLoad { get; set; }
public static bool ShowNewUserEditPrompt { get; set; }
public ApplicationLibrary ApplicationLibrary { get; set; }
public readonly double StatusBarHeight;
@ -361,6 +363,20 @@ namespace Ryujinx.Ava.UI.Windows
await Dispatcher.UIThread.InvokeAsync(async () => await UserErrorDialog.ShowUserErrorDialog(UserError.NoKeys));
}
if (ShowNewUserEditPrompt)
{
ShowNewUserEditPrompt = false;
await Dispatcher.UIThread.InvokeAsync(async () =>
{
UserResult result = await ContentDialogHelper.CreateInfoDialog("The default profile has been created.", "Would you like to manage profiles now?", "Yes", "No", "First Launch");
if (result == UserResult.Ok)
{
await ViewModel.ManageProfiles();
}
});
}
if (ConfigurationState.Instance.CheckUpdatesOnStart.Value && Updater.CanUpdate(false))
{
await Updater.BeginParse(this, false).ContinueWith(task =>