Pass default username with fallback to "Player" in NameChange script
This commit is contained in:
parent
cdcff1b022
commit
abd8c4cfd1
5 changed files with 11 additions and 4 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace LANCommander.Launcher.Data.Models;
|
||||
|
||||
|
|
@ -9,4 +10,8 @@ public class User : BaseModel
|
|||
public string? Alias { get; set; }
|
||||
public Media? Avatar { get; set; }
|
||||
public Library? Library { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
[NotMapped]
|
||||
public string? GetUserNameSafe => Alias ?? UserName;
|
||||
}
|
||||
|
|
@ -7,6 +7,8 @@ namespace LANCommander.Launcher.Models
|
|||
{
|
||||
public class Settings
|
||||
{
|
||||
public const string DEFAULT_GAME_USERNAME = "Player";
|
||||
|
||||
public int LaunchCount { get; set; } = 0;
|
||||
|
||||
public DatabaseSettings Database { get; set; } = new DatabaseSettings();
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ namespace LANCommander.Launcher.Services
|
|||
break;
|
||||
|
||||
case SDK.Enums.ScriptType.NameChange:
|
||||
await Client.Scripts.RunNameChangeScriptAsync(options.InstallDirectory, options.GameId, options.NewPlayerAlias);
|
||||
await Client.Scripts.RunNameChangeScriptAsync(options.InstallDirectory, options.GameId, options.NewPlayerAlias ?? Settings.DEFAULT_GAME_USERNAME);
|
||||
break;
|
||||
|
||||
case SDK.Enums.ScriptType.KeyChange:
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ else
|
|||
|
||||
foreach (var manifest in manifests)
|
||||
{
|
||||
await Client.Scripts.RunNameChangeScriptAsync(Game.InstallDirectory, Game.Id, user.Alias);
|
||||
await Client.Scripts.RunNameChangeScriptAsync(Game.InstallDirectory, Game.Id, user.GetUserNameSafe ?? Settings.DEFAULT_GAME_USERNAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
User User;
|
||||
Guid AvatarId = Guid.Empty;
|
||||
string Alias = "Player";
|
||||
string Alias = Settings.DEFAULT_GAME_USERNAME;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
User = await UserService.GetCurrentUser();
|
||||
|
||||
AvatarId = User?.Avatar?.Id ?? Guid.Empty;
|
||||
Alias = String.IsNullOrWhiteSpace(User?.Alias) ? User?.UserName ?? "Player" : User.Alias;
|
||||
Alias = String.IsNullOrWhiteSpace(User?.Alias) ? User?.UserName ?? Settings.DEFAULT_GAME_USERNAME : User.Alias;
|
||||
};
|
||||
|
||||
await ProfileService.DownloadProfileInfoAsync();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue