Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
112 lines
No EOL
3.3 KiB
Text
112 lines
No EOL
3.3 KiB
Text
@using LANCommander.Launcher.Data.Models
|
|
@using LANCommander.Launcher.Models
|
|
@inject UserService UserService
|
|
@inject ProfileService ProfileService
|
|
@inject AuthenticationService AuthenticationService
|
|
@inject NavigationManager NavigationManager
|
|
@inject ModalService ModalService
|
|
@inject LocalizationService LocalizationService
|
|
|
|
<Dropdown>
|
|
<Overlay>
|
|
<Menu>
|
|
<MenuItem OnClick="ChangeAlias" Disabled="ConnectionState.OfflineModeEnabled">
|
|
@LocalizationService.GetString("ChangeName")
|
|
</MenuItem>
|
|
<MenuItem OnClick="@(() => NavigationManager.NavigateTo("/Settings"))">
|
|
@LocalizationService.GetString("Settings")
|
|
</MenuItem>
|
|
|
|
@if (!Settings.Authentication.OfflineMode)
|
|
{
|
|
<MenuItem OnClick="SwitchToOfflineMode">
|
|
@LocalizationService.GetString("SwitchToOfflineMode")
|
|
</MenuItem>
|
|
}
|
|
|
|
<MenuItem OnClick="Logout">
|
|
@LocalizationService.GetString("Logout")
|
|
</MenuItem>
|
|
</Menu>
|
|
</Overlay>
|
|
|
|
<ChildContent>
|
|
<Button Type="ButtonType.Primary" Class="appbar-profile-button">
|
|
@if (AvatarId != Guid.Empty)
|
|
{
|
|
<MediaImage Id="AvatarId" />
|
|
}
|
|
|
|
<span>@Alias</span>
|
|
</Button>
|
|
</ChildContent>
|
|
</Dropdown>
|
|
|
|
@code {
|
|
[CascadingParameter] public ConnectionState ConnectionState { get; set; }
|
|
Models.Settings Settings = SettingService.GetSettings();
|
|
|
|
User User;
|
|
Guid AvatarId = Guid.Empty;
|
|
string Alias = Settings.DEFAULT_GAME_USERNAME;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
ProfileService.OnProfileDownloaded += async (sender, args) =>
|
|
{
|
|
User = await UserService.GetCurrentUser();
|
|
|
|
AvatarId = User?.Avatar?.Id ?? Guid.Empty;
|
|
Alias = String.IsNullOrWhiteSpace(User?.Alias) ? User?.UserName ?? Settings.DEFAULT_GAME_USERNAME : User.Alias;
|
|
};
|
|
|
|
if (ConnectionState.OfflineModeEnabled)
|
|
{
|
|
string userName = AuthenticationService.GetCurrentUserName();
|
|
Alias = string.IsNullOrEmpty(userName) ? Alias : userName;
|
|
}
|
|
else
|
|
{
|
|
await ProfileService.DownloadProfileInfoAsync();
|
|
}
|
|
}
|
|
|
|
|
|
async Task ChangeAlias()
|
|
{
|
|
var modalOptions = new ModalOptions()
|
|
{
|
|
Title = LocalizationService.GetString("ChangeName"),
|
|
Maximizable = false,
|
|
DefaultMaximized = false,
|
|
Closable = true,
|
|
Centered = true
|
|
};
|
|
|
|
var modalRef = ModalService.CreateModal<ChangeAliasDialog, string, string>(modalOptions, User.Alias);
|
|
|
|
modalRef.OnOk = async (newName) =>
|
|
{
|
|
await ProfileService.ChangeAlias(newName);
|
|
await ProfileService.DownloadProfileInfoAsync();
|
|
|
|
Settings = SettingService.GetSettings();
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
};
|
|
}
|
|
|
|
async Task Logout()
|
|
{
|
|
await AuthenticationService.Logout();
|
|
|
|
NavigationManager.NavigateTo("/Authenticate");
|
|
}
|
|
|
|
void SwitchToOfflineMode()
|
|
{
|
|
AuthenticationService.SetOfflineMode(true);
|
|
|
|
NavigationManager.NavigateTo("/", forceLoad: true);
|
|
}
|
|
} |