2025-01-20 12:10:30 -06:00
|
|
|
@using LANCommander.Launcher.Data.Models
|
2025-12-31 20:01:04 -06:00
|
|
|
@namespace LANCommander.Launcher.UI
|
2025-01-20 12:10:30 -06:00
|
|
|
@inject UserService UserService
|
2025-01-18 20:25:39 -06:00
|
|
|
@inject ProfileService ProfileService
|
|
|
|
|
@inject AuthenticationService AuthenticationService
|
2024-10-06 17:11:35 -05:00
|
|
|
@inject NavigationManager NavigationManager
|
|
|
|
|
@inject ModalService ModalService
|
Add localization support to launcher
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.
2025-08-18 21:29:38 -05:00
|
|
|
@inject LocalizationService LocalizationService
|
2025-12-31 20:01:04 -06:00
|
|
|
@inject ISettingsProvider SettingsProvider
|
2025-10-05 17:13:47 -05:00
|
|
|
@inject IConnectionClient ConnectionClient
|
2025-11-03 23:24:47 -06:00
|
|
|
@inject ILogger<ProfileButton> Logger
|
2024-10-06 17:11:35 -05:00
|
|
|
|
|
|
|
|
<Dropdown>
|
|
|
|
|
<Overlay>
|
|
|
|
|
<Menu>
|
2025-10-05 17:13:47 -05:00
|
|
|
<MenuItem OnClick="ChangeAlias" Disabled="@ConnectionClient.IsOfflineMode()">
|
Add localization support to launcher
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.
2025-08-18 21:29:38 -05:00
|
|
|
@LocalizationService.GetString("ChangeName")
|
2024-10-06 17:11:35 -05:00
|
|
|
</MenuItem>
|
|
|
|
|
<MenuItem OnClick="@(() => NavigationManager.NavigateTo("/Settings"))">
|
Add localization support to launcher
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.
2025-08-18 21:29:38 -05:00
|
|
|
@LocalizationService.GetString("Settings")
|
2024-10-06 17:11:35 -05:00
|
|
|
</MenuItem>
|
|
|
|
|
|
2025-12-31 20:01:04 -06:00
|
|
|
@if (!SettingsProvider.CurrentValue.Authentication.OfflineModeEnabled)
|
2025-06-10 01:53:02 +02:00
|
|
|
{
|
|
|
|
|
<MenuItem OnClick="SwitchToOfflineMode">
|
Add localization support to launcher
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.
2025-08-18 21:29:38 -05:00
|
|
|
@LocalizationService.GetString("SwitchToOfflineMode")
|
2025-06-10 01:53:02 +02:00
|
|
|
</MenuItem>
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-15 22:25:58 +02:00
|
|
|
<MenuItem OnClick="Logout">
|
Add localization support to launcher
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.
2025-08-18 21:29:38 -05:00
|
|
|
@LocalizationService.GetString("Logout")
|
2025-06-15 22:25:58 +02:00
|
|
|
</MenuItem>
|
2024-10-06 17:11:35 -05:00
|
|
|
</Menu>
|
|
|
|
|
</Overlay>
|
|
|
|
|
|
|
|
|
|
<ChildContent>
|
2024-12-31 18:21:41 -06:00
|
|
|
<Button Type="ButtonType.Primary" Class="appbar-profile-button">
|
2025-01-25 15:22:25 -06:00
|
|
|
@if (AvatarId != Guid.Empty)
|
2024-10-06 17:11:35 -05:00
|
|
|
{
|
2025-01-25 15:22:25 -06:00
|
|
|
<MediaImage Id="AvatarId" />
|
2024-10-06 17:11:35 -05:00
|
|
|
}
|
|
|
|
|
|
2025-01-25 15:22:25 -06:00
|
|
|
<span>@Alias</span>
|
2024-10-06 17:11:35 -05:00
|
|
|
</Button>
|
|
|
|
|
</ChildContent>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
|
|
|
|
|
@code {
|
2025-01-20 12:10:30 -06:00
|
|
|
User User;
|
2025-01-25 15:22:25 -06:00
|
|
|
Guid AvatarId = Guid.Empty;
|
2025-12-31 20:01:04 -06:00
|
|
|
string Alias = SDK.Models.Settings.DEFAULT_GAME_USERNAME;
|
2025-01-20 12:10:30 -06:00
|
|
|
|
2024-10-06 17:11:35 -05:00
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
2025-11-03 23:24:47 -06:00
|
|
|
Console.WriteLine(NavigationManager.Uri);
|
|
|
|
|
Console.WriteLine(NavigationManager.BaseUri);
|
|
|
|
|
|
2025-02-16 16:46:31 -06:00
|
|
|
ProfileService.OnProfileDownloaded += async (sender, args) =>
|
|
|
|
|
{
|
|
|
|
|
User = await UserService.GetCurrentUser();
|
2025-01-25 15:22:25 -06:00
|
|
|
|
2025-02-16 16:46:31 -06:00
|
|
|
AvatarId = User?.Avatar?.Id ?? Guid.Empty;
|
2025-12-31 20:01:04 -06:00
|
|
|
Alias = String.IsNullOrWhiteSpace(User?.Alias) ? User?.UserName ?? SDK.Models.Settings.DEFAULT_GAME_USERNAME : User.Alias;
|
2026-03-04 19:03:57 -06:00
|
|
|
|
|
|
|
|
await InvokeAsync(StateHasChanged);
|
2025-02-16 16:46:31 -06:00
|
|
|
};
|
2025-06-09 20:07:39 +02:00
|
|
|
|
2025-10-05 17:13:47 -05:00
|
|
|
if (ConnectionClient.IsOfflineMode())
|
2025-06-09 20:07:39 +02:00
|
|
|
{
|
|
|
|
|
string userName = AuthenticationService.GetCurrentUserName();
|
|
|
|
|
Alias = string.IsNullOrEmpty(userName) ? Alias : userName;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2025-11-03 23:24:47 -06:00
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
await ProfileService.DownloadProfileInfoAsync();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.LogError(ex, "Could not download profile info");
|
|
|
|
|
}
|
2025-06-09 20:07:39 +02:00
|
|
|
}
|
2024-10-06 17:11:35 -05:00
|
|
|
}
|
2025-02-16 16:46:31 -06:00
|
|
|
|
2024-10-06 17:11:35 -05:00
|
|
|
|
|
|
|
|
async Task ChangeAlias()
|
|
|
|
|
{
|
|
|
|
|
var modalOptions = new ModalOptions()
|
|
|
|
|
{
|
Add localization support to launcher
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.
2025-08-18 21:29:38 -05:00
|
|
|
Title = LocalizationService.GetString("ChangeName"),
|
2024-10-06 17:11:35 -05:00
|
|
|
Maximizable = false,
|
|
|
|
|
DefaultMaximized = false,
|
|
|
|
|
Closable = true,
|
|
|
|
|
Centered = true
|
|
|
|
|
};
|
|
|
|
|
|
2025-01-20 12:10:30 -06:00
|
|
|
var modalRef = ModalService.CreateModal<ChangeAliasDialog, string, string>(modalOptions, User.Alias);
|
2024-10-06 17:11:35 -05:00
|
|
|
|
|
|
|
|
modalRef.OnOk = async (newName) =>
|
|
|
|
|
{
|
|
|
|
|
await ProfileService.ChangeAlias(newName);
|
2025-01-25 02:58:10 -06:00
|
|
|
await ProfileService.DownloadProfileInfoAsync();
|
2024-10-06 17:11:35 -05:00
|
|
|
|
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async Task Logout()
|
|
|
|
|
{
|
2025-01-18 20:25:39 -06:00
|
|
|
await AuthenticationService.Logout();
|
2024-10-06 17:11:35 -05:00
|
|
|
|
|
|
|
|
NavigationManager.NavigateTo("/Authenticate");
|
|
|
|
|
}
|
2025-06-10 01:53:02 +02:00
|
|
|
|
2025-09-24 20:58:23 -05:00
|
|
|
async Task SwitchToOfflineMode()
|
2025-06-10 01:53:02 +02:00
|
|
|
{
|
2025-09-24 20:58:23 -05:00
|
|
|
await AuthenticationService.SetOfflineModeAsync(true);
|
2025-06-10 01:53:02 +02:00
|
|
|
|
|
|
|
|
NavigationManager.NavigateTo("/", forceLoad: true);
|
|
|
|
|
}
|
2024-10-06 17:11:35 -05:00
|
|
|
}
|