2025-01-18 20:25:39 -06:00
|
|
|
@using System.Management.Automation.Remoting
|
|
|
|
|
@using LANCommander.Launcher.Models
|
|
|
|
|
@using LANCommander.SDK
|
2024-06-05 01:21:31 -05:00
|
|
|
@using Photino.Blazor.CustomWindow.Components
|
2025-01-18 20:25:39 -06:00
|
|
|
@using ConnectionState = LANCommander.Launcher.Models.ConnectionState
|
2024-06-05 01:21:31 -05:00
|
|
|
@inherits LayoutComponentBase
|
|
|
|
|
@inject ImportService ImportService
|
|
|
|
|
@inject ProfileService ProfileService
|
2025-01-18 20:25:39 -06:00
|
|
|
@inject AuthenticationService AuthenticationService
|
2025-06-10 01:37:15 +02:00
|
|
|
@inject KeepAliveService KeepAliveService
|
2024-06-05 01:21:31 -05:00
|
|
|
@inject IMessageService MessageService
|
|
|
|
|
@inject NavigationManager NavigationManager
|
2024-06-05 23:37:16 -05:00
|
|
|
@inject ModalService ModalService
|
2024-07-15 17:26:24 -05:00
|
|
|
@inject LANCommander.SDK.Client LANCommander
|
2024-06-11 02:05:15 -05:00
|
|
|
@inject IJSRuntime JS
|
2025-02-06 20:54:03 -06:00
|
|
|
@inject ILogger<MainLayout> Logger
|
|
|
|
|
@inject ImportManagerService ImportManagerService
|
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
|
2024-06-05 01:21:31 -05:00
|
|
|
|
2025-01-18 20:25:39 -06:00
|
|
|
<CustomWindow HeaderHeight="37">
|
|
|
|
|
<HeaderExtraControlsLayout>
|
|
|
|
|
<Space Direction="SpaceDirection.Horizontal">
|
2025-06-12 04:04:04 +02:00
|
|
|
<AuthenticatedView NoAutoValidate="true">
|
2025-01-20 12:10:30 -06:00
|
|
|
<Authenticated>
|
2025-01-18 20:25:39 -06:00
|
|
|
<SpaceItem>
|
2025-06-10 00:17:17 +02:00
|
|
|
@if (ImportStatus.IsActive)
|
2025-02-06 20:54:03 -06:00
|
|
|
{
|
|
|
|
|
<Popover Placement="Placement.BottomRight" IsButton Trigger="new[] { Trigger.Hover }">
|
|
|
|
|
<ChildContent>
|
2025-06-10 00:17:17 +02:00
|
|
|
<Button Type="@ButtonType.Text" Icon="@IconType.Outline.Sync" Loading="true"/>
|
2025-02-06 20:54:03 -06:00
|
|
|
</ChildContent>
|
|
|
|
|
<ContentTemplate>
|
|
|
|
|
<ImportProgressDisplay
|
2025-06-10 00:17:17 +02:00
|
|
|
Index="@ImportStatus.Index"
|
|
|
|
|
Total="@ImportStatus.Total"
|
2025-02-06 20:54:03 -06:00
|
|
|
CurrentItem="@(_importProgress?.CurrentItem)"
|
|
|
|
|
/>
|
|
|
|
|
</ContentTemplate>
|
|
|
|
|
</Popover>
|
|
|
|
|
}
|
2025-06-09 20:01:54 +02:00
|
|
|
else if (ConnectionState.IsConnected)
|
2025-02-06 20:54:03 -06:00
|
|
|
{
|
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
|
|
|
<Tooltip Title="@LocalizationService.GetString("ReimportLibrary")" MouseEnterDelay="0.5">
|
2025-06-10 00:17:17 +02:00
|
|
|
<Button Type="@ButtonType.Text" Icon="@IconType.Outline.Sync" OnClick="@ImportHandler.Import"/>
|
2025-06-09 20:01:54 +02:00
|
|
|
</Tooltip>
|
|
|
|
|
}
|
2025-06-10 02:07:08 +02:00
|
|
|
else if (!string.IsNullOrEmpty(Settings.Authentication.AccessToken))
|
2025-06-09 20:01:54 +02:00
|
|
|
{
|
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
|
|
|
<Tooltip Title="@LocalizationService.GetString("ReconnectToServer")" MouseEnterDelay="0.5">
|
2025-06-09 20:01:54 +02:00
|
|
|
<Button Type="@ButtonType.Text" Icon="@IconType.Outline.CloudSync" OnClick="Connect" Loading="@Connecting" Danger/>
|
|
|
|
|
</Tooltip>
|
2025-02-06 20:54:03 -06:00
|
|
|
}
|
2025-01-18 20:25:39 -06:00
|
|
|
</SpaceItem>
|
2025-01-20 12:10:30 -06:00
|
|
|
|
|
|
|
|
<SpaceItem>
|
|
|
|
|
<ProfileButton/>
|
|
|
|
|
</SpaceItem>
|
|
|
|
|
</Authenticated>
|
2025-06-12 04:04:04 +02:00
|
|
|
|
2025-01-20 12:10:30 -06:00
|
|
|
<NotAuthenticated>
|
2025-01-18 20:25:39 -06:00
|
|
|
<SpaceItem>
|
|
|
|
|
<Button Type="@ButtonType.Text" Icon="@IconType.Outline.CloudSync" OnClick="Connect" Loading="@Connecting" Danger/>
|
|
|
|
|
</SpaceItem>
|
2025-01-20 12:10:30 -06:00
|
|
|
</NotAuthenticated>
|
|
|
|
|
</AuthenticatedView>
|
2025-01-18 20:25:39 -06:00
|
|
|
</Space>
|
|
|
|
|
</HeaderExtraControlsLayout>
|
|
|
|
|
<WindowContent>
|
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
|
|
|
<ErrorHandler Title="@LocalizationService.GetString("LauncherCrashed")">
|
2025-01-21 20:42:39 -06:00
|
|
|
<Body>
|
2025-06-12 04:04:04 +02:00
|
|
|
<AuthenticatedView NoAutoValidate="false">
|
2025-01-21 20:42:39 -06:00
|
|
|
<Authenticated>
|
|
|
|
|
@Body
|
2025-01-20 12:10:30 -06:00
|
|
|
|
2025-01-21 20:42:39 -06:00
|
|
|
@if (Settings.Debug.EnableScriptDebugging)
|
|
|
|
|
{
|
2025-09-16 23:51:11 -05:00
|
|
|
<DebugConsole SessionId="Guid.Empty" />
|
2025-01-21 20:42:39 -06:00
|
|
|
}
|
2025-01-20 12:10:30 -06:00
|
|
|
|
2025-01-21 20:42:39 -06:00
|
|
|
<KeepAliveContainer/>
|
|
|
|
|
</Authenticated>
|
|
|
|
|
<NotAuthenticated>
|
|
|
|
|
<AuthenticationForm/>
|
|
|
|
|
</NotAuthenticated>
|
|
|
|
|
</AuthenticatedView>
|
2025-01-20 12:10:30 -06:00
|
|
|
|
2025-06-10 00:17:17 +02:00
|
|
|
<ImportHandler @ref="ImportHandler" Progress="OnImportProcess" />
|
2025-01-21 20:42:39 -06:00
|
|
|
<UpdateChecker/>
|
|
|
|
|
<AntContainer/>
|
|
|
|
|
</Body>
|
2025-06-10 00:17:17 +02:00
|
|
|
|
2025-01-21 20:42:39 -06:00
|
|
|
<Extra>
|
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
|
|
|
<Button Type="ButtonType.Primary" OnClick="@(() => NavigationManager.NavigateTo("/", true))">@LocalizationService.GetString("ViewLibrary")</Button>
|
2025-01-21 20:42:39 -06:00
|
|
|
</Extra>
|
2025-01-20 12:10:30 -06:00
|
|
|
</ErrorHandler>
|
2025-01-18 20:25:39 -06:00
|
|
|
</WindowContent>
|
|
|
|
|
</CustomWindow>
|
2024-06-05 01:21:31 -05:00
|
|
|
|
|
|
|
|
@code {
|
2024-07-07 20:28:03 -05:00
|
|
|
Models.Settings Settings = null;
|
2024-06-05 01:21:31 -05:00
|
|
|
|
2025-01-20 12:10:30 -06:00
|
|
|
public bool Importing;
|
|
|
|
|
public bool Connecting;
|
2025-01-18 20:25:39 -06:00
|
|
|
|
2025-06-10 01:37:15 +02:00
|
|
|
public ConnectionState ConnectionState = default!;
|
2025-06-10 00:17:17 +02:00
|
|
|
|
2024-06-11 02:05:15 -05:00
|
|
|
public IMessageService Messages { get; set; }
|
|
|
|
|
|
2025-06-10 00:17:17 +02:00
|
|
|
ImportHandler ImportHandler;
|
|
|
|
|
ImportHandler.ImportProgressEventArgs ImportStatus = new();
|
|
|
|
|
private ImportProgress _importProgress => ImportService.Progress;
|
|
|
|
|
|
2025-01-14 19:03:50 -06:00
|
|
|
string RandomQuip = "";
|
2025-06-10 00:17:17 +02:00
|
|
|
|
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
|
|
|
string[] _crashQuips;
|
2025-01-14 19:03:50 -06:00
|
|
|
|
2024-06-05 01:21:31 -05:00
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
|
|
|
|
Settings = SettingService.GetSettings();
|
2025-06-10 01:37:15 +02:00
|
|
|
ConnectionState = KeepAliveService.GetConnectionState();
|
2024-06-11 02:05:15 -05:00
|
|
|
Messages = MessageService;
|
|
|
|
|
|
2025-01-18 20:25:39 -06:00
|
|
|
AuthenticationService.OnOfflineModeChanged += OnOfflineModeChanged;
|
2025-02-16 16:46:31 -06:00
|
|
|
|
|
|
|
|
var token = new SDK.Models.AuthToken
|
|
|
|
|
{
|
|
|
|
|
AccessToken = Settings.Authentication.AccessToken,
|
|
|
|
|
RefreshToken = Settings.Authentication.RefreshToken
|
|
|
|
|
};
|
2025-06-10 00:17:17 +02:00
|
|
|
|
2025-02-16 16:46:31 -06:00
|
|
|
if (await LANCommander.ValidateTokenAsync(token))
|
|
|
|
|
{
|
2025-06-12 04:04:04 +02:00
|
|
|
ConnectionState.IsStartup = true;
|
2025-02-16 16:46:31 -06:00
|
|
|
await AuthenticationService.Login();
|
|
|
|
|
await ProfileService.DownloadProfileInfoAsync();
|
2025-06-10 00:17:17 +02:00
|
|
|
|
2025-02-16 16:46:31 -06:00
|
|
|
ConnectionState.IsConnected = true;
|
|
|
|
|
ConnectionState.OfflineModeEnabled = false;
|
2025-06-12 04:04:04 +02:00
|
|
|
ConnectionState.IsStartup = false;
|
2025-02-16 16:46:31 -06:00
|
|
|
|
2025-06-11 22:02:41 +02:00
|
|
|
await ImportManagerService.RequestImport();
|
2025-02-16 16:46:31 -06:00
|
|
|
await InvokeAsync(StateHasChanged);
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
_crashQuips = new[]
|
|
|
|
|
{
|
|
|
|
|
LocalizationService.GetString("CrashQuip_YouDied"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_Snake"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_Wasted"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_MajorFracture"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_PastIsGapingHole"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_TownCenterDestroyed"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_ForcesUnderAttack"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_LostLead"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_TerroristsWin"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_WarNeverChanges"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_DiedOfDysentery"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_FailedToRestoreBooks"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_PlayerSplattered"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_BlameISP"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_BabaNoMore"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_GuestsLost"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_DarknessOvercome"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_GordonFreemanTerminated"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_MissionFailedSpotted"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_CriticalDamageEject"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_MinionsUnhappy"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_EmpireTriumphed"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_QuestEndedFailure"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_EatenByGrue"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_NoMessWithLoWang"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_SamKilled"),
|
|
|
|
|
LocalizationService.GetString("CrashQuip_AlienBastardsPay")
|
|
|
|
|
};
|
2025-06-10 00:17:17 +02:00
|
|
|
|
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
|
|
|
var randIndex = new Random().Next(0, _crashQuips.Length - 1);
|
|
|
|
|
RandomQuip = _crashQuips[randIndex];
|
2024-07-13 12:55:42 -05:00
|
|
|
}
|
|
|
|
|
|
2025-02-06 20:54:03 -06:00
|
|
|
public void Dispose()
|
2024-07-13 12:55:42 -05:00
|
|
|
{
|
2025-02-06 20:54:03 -06:00
|
|
|
if (AuthenticationService != null)
|
|
|
|
|
{
|
|
|
|
|
AuthenticationService.OnOfflineModeChanged -= OnOfflineModeChanged;
|
|
|
|
|
}
|
2025-01-12 02:54:41 -06:00
|
|
|
}
|
|
|
|
|
|
2025-01-18 20:25:39 -06:00
|
|
|
async void OnOfflineModeChanged(bool state)
|
|
|
|
|
{
|
2025-02-06 20:54:03 -06:00
|
|
|
ConnectionState.OfflineModeEnabled = state;
|
|
|
|
|
ConnectionState.IsConnected = LANCommander.IsConnected();
|
|
|
|
|
await InvokeAsync(StateHasChanged);
|
2025-01-18 20:25:39 -06:00
|
|
|
}
|
|
|
|
|
|
2025-06-10 00:17:17 +02:00
|
|
|
async void OnImportProcess(ImportHandler.ImportProgressEventArgs importProgress)
|
|
|
|
|
{
|
|
|
|
|
ImportStatus = importProgress;
|
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-14 19:03:50 -06:00
|
|
|
async Task CopyError(Exception ex)
|
|
|
|
|
{
|
2025-01-15 00:32:42 -06:00
|
|
|
await JS.InvokeVoidAsync("navigator.clipboard.writeText", ex.Message + "\n" + ex.StackTrace);
|
2025-01-14 19:03:50 -06:00
|
|
|
|
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
|
|
|
MessageService.Info(LocalizationService.GetString("ErrorCopiedToClipboard"));
|
2025-01-14 19:03:50 -06:00
|
|
|
}
|
|
|
|
|
|
2024-07-15 17:26:24 -05:00
|
|
|
async Task Connect()
|
|
|
|
|
{
|
|
|
|
|
Connecting = true;
|
|
|
|
|
|
|
|
|
|
Settings = SettingService.GetSettings();
|
|
|
|
|
|
|
|
|
|
var token = new SDK.Models.AuthToken
|
|
|
|
|
{
|
|
|
|
|
AccessToken = Settings.Authentication.AccessToken,
|
|
|
|
|
RefreshToken = Settings.Authentication.RefreshToken
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (await LANCommander.ValidateTokenAsync(token))
|
|
|
|
|
{
|
2025-01-18 20:25:39 -06:00
|
|
|
await AuthenticationService.Login();
|
2025-02-16 16:46:31 -06:00
|
|
|
await ProfileService.DownloadProfileInfoAsync();
|
2025-01-18 20:25:39 -06:00
|
|
|
|
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
|
|
|
MessageService.Success(LocalizationService.GetString("BackOnline"));
|
2025-06-10 00:17:17 +02:00
|
|
|
|
2025-01-18 20:25:39 -06:00
|
|
|
ConnectionState.IsConnected = true;
|
|
|
|
|
ConnectionState.OfflineModeEnabled = false;
|
|
|
|
|
|
|
|
|
|
await InvokeAsync(StateHasChanged);
|
2024-07-15 17:26:24 -05:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (await LANCommander.PingAsync())
|
|
|
|
|
{
|
|
|
|
|
await Logout();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
await ModalService.ConfirmAsync(new ConfirmOptions()
|
|
|
|
|
{
|
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("CouldNotReconnect"),
|
2024-07-15 17:26:24 -05:00
|
|
|
Icon = @<Icon Type="@IconType.Outline.ExclamationCircle"></Icon>,
|
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
|
|
|
Content = LocalizationService.GetString("CouldNotReconnectMessage"),
|
|
|
|
|
OkText = LocalizationService.GetString("Logout"),
|
|
|
|
|
CancelText = LocalizationService.GetString("StayOffline"),
|
2024-07-15 17:26:24 -05:00
|
|
|
Centered = true,
|
|
|
|
|
OnOk = async (e) =>
|
|
|
|
|
{
|
|
|
|
|
await Logout();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Connecting = false;
|
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-06 17:11:35 -05:00
|
|
|
async Task Logout()
|
|
|
|
|
{
|
2025-01-18 20:25:39 -06:00
|
|
|
await AuthenticationService.Logout();
|
2025-06-10 00:17:17 +02:00
|
|
|
|
2025-01-18 20:25:39 -06:00
|
|
|
ConnectionState.IsConnected = false;
|
|
|
|
|
ConnectionState.OfflineModeEnabled = false;
|
2024-10-06 17:11:35 -05:00
|
|
|
|
|
|
|
|
NavigationManager.NavigateTo("/Authenticate");
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-06 20:54:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.import-progress {
|
|
|
|
|
width: 300px; /* Fixed width */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.import-progress .downloader-current-upper-status {
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
max-width: 100%;
|
2024-06-05 01:21:31 -05:00
|
|
|
}
|
2025-02-06 20:54:03 -06:00
|
|
|
</style>
|