2025-01-12 02:54:41 -06:00
|
|
|
@using LANCommander.Launcher.Data.Models
|
|
|
|
|
@using LANCommander.SDK.Extensions
|
2025-12-31 20:01:04 -06:00
|
|
|
@namespace LANCommander.Launcher.UI
|
2024-11-09 17:15:04 -06:00
|
|
|
@inherits FeedbackComponent<Models.ListItem, string>
|
2024-10-26 15:48:47 -05:00
|
|
|
@inject InstallService InstallService
|
2026-02-10 18:04:49 -06:00
|
|
|
@inject ToolService ToolService
|
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 GameClient GameClient
|
|
|
|
|
@inject ISettingsProvider SettingsProvider
|
2024-10-12 12:04:00 -05:00
|
|
|
|
2024-10-26 15:48:47 -05:00
|
|
|
<div style="padding: 16px;">
|
|
|
|
|
<Row Gutter="16">
|
|
|
|
|
<Col Span="12">
|
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
|
|
|
<Statistic Title="@LocalizationService.GetString("DownloadSize")" Value="@ByteSizeLib.ByteSize.FromBytes(GetDownloadSize()).ToString()" Style="text-align: center;"/>
|
2024-10-26 15:48:47 -05:00
|
|
|
</Col>
|
|
|
|
|
<Col Span="12">
|
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
|
|
|
<Statistic Title="@LocalizationService.GetString("SpaceRequired")" Value="@ByteSizeLib.ByteSize.FromBytes(GetSpaceRequired()).ToString()" Style="text-align: center;"/>
|
2024-10-26 15:48:47 -05:00
|
|
|
</Col>
|
|
|
|
|
</Row>
|
2024-09-12 19:09:13 -05:00
|
|
|
|
2024-10-25 20:46:54 -05:00
|
|
|
|
2024-10-26 15:48:47 -05:00
|
|
|
@if (Addons.Any())
|
|
|
|
|
{
|
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
|
|
|
<Divider Text="@LocalizationService.GetString("Addons")" />
|
2024-10-25 20:46:54 -05:00
|
|
|
|
2025-01-27 02:46:05 -06:00
|
|
|
<CheckboxButtonGroup @bind-Selected="SelectedAddons" DataSource="Addons" KeySelector="a => a.Id" LabelSelector="a => a.Title" Direction="SpaceDirection.Vertical" />
|
2024-10-26 15:48:47 -05:00
|
|
|
}
|
2026-02-10 18:04:49 -06:00
|
|
|
|
|
|
|
|
@if (Tools.Any())
|
|
|
|
|
{
|
|
|
|
|
<Divider Text="@LocalizationService.GetString("Tools")" />
|
|
|
|
|
|
|
|
|
|
<CheckboxButtonGroup @bind-Selected="SelectedTools" DataSource="Tools" KeySelector="t => t.Id" LabelSelector="t => t.Name" Direction="SpaceDirection.Vertical" />
|
|
|
|
|
}
|
2024-10-09 19:23:42 -05:00
|
|
|
|
2025-12-31 20:01:04 -06:00
|
|
|
@if (SettingsProvider.CurrentValue.Games.InstallDirectories.Length > 1)
|
2024-10-26 15:48:47 -05: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
|
|
|
<Divider Text="@LocalizationService.GetString("InstallLocation")" />
|
2024-12-31 18:21:41 -06:00
|
|
|
<RadioGroup @bind-Value="SelectedDirectory" ButtonStyle="RadioButtonStyle.Solid" Size="InputSize.Large" Class="install-dialog-directory-selector radio-group-vertical radio-group-block">
|
2025-12-31 20:01:04 -06:00
|
|
|
@foreach (var directory in SettingsProvider.CurrentValue.Games.InstallDirectories)
|
2024-10-25 20:46:54 -05:00
|
|
|
{
|
|
|
|
|
<Radio RadioButton Value="@directory">
|
|
|
|
|
<GridRow>
|
|
|
|
|
<GridCol Flex="@("auto")">
|
|
|
|
|
@directory
|
|
|
|
|
</GridCol>
|
|
|
|
|
<GridCol>
|
2025-01-29 23:02:59 -06:00
|
|
|
<ByteSize Value="GetFreeSpace(directory)" />
|
2024-10-25 20:46:54 -05:00
|
|
|
</GridCol>
|
|
|
|
|
</GridRow>
|
|
|
|
|
</Radio>
|
|
|
|
|
}
|
|
|
|
|
</RadioGroup>
|
2024-10-26 15:48:47 -05:00
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
2024-12-31 18:21:41 -06:00
|
|
|
<Flex Gap="FlexGap.Middle" Style="padding: 16px; padding-top: 0px" Justify="FlexJustify.FlexEnd">
|
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
|
|
|
@if (GetOperation() != "None")
|
2024-10-26 15:48:47 -05: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
|
|
|
<Button Type="ButtonType.Primary" OnClick="Install">@LocalizationService.GetString(GetOperation())</Button>
|
2024-10-26 15:48:47 -05: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
|
|
|
<Button OnClick="() => Close()">@LocalizationService.GetString("Close")</Button>
|
2024-10-26 15:48:47 -05:00
|
|
|
</Flex>
|
2024-09-12 19:09:13 -05:00
|
|
|
|
|
|
|
|
@code {
|
|
|
|
|
string SelectedDirectory = "";
|
2024-10-26 15:48:47 -05:00
|
|
|
|
2024-10-12 12:04:00 -05:00
|
|
|
SDK.Models.Game RemoteGame;
|
2024-10-26 15:48:47 -05:00
|
|
|
Data.Models.Game Game;
|
2024-10-09 19:23:42 -05:00
|
|
|
|
2025-05-15 03:04:48 +02:00
|
|
|
List<SDK.Models.Game> Addons = new();
|
2025-01-27 02:46:05 -06:00
|
|
|
IEnumerable<SDK.Models.Game> SelectedAddons = new List<SDK.Models.Game>();
|
2024-09-12 19:09:13 -05:00
|
|
|
|
2026-02-10 18:04:49 -06:00
|
|
|
List<SDK.Models.Tool> Tools = new();
|
|
|
|
|
IEnumerable<SDK.Models.Tool> SelectedTools = new List<SDK.Models.Tool>();
|
2024-10-26 15:48:47 -05:00
|
|
|
|
2024-10-12 12:04:00 -05:00
|
|
|
protected override async Task OnInitializedAsync()
|
2024-09-12 19:09:13 -05:00
|
|
|
{
|
2024-10-26 15:48:47 -05:00
|
|
|
Game = Options.DataItem as Game;
|
2025-05-15 03:04:48 +02:00
|
|
|
|
2024-10-26 15:48:47 -05:00
|
|
|
if (Game.Installed)
|
2025-12-31 20:01:04 -06:00
|
|
|
SelectedDirectory = SettingsProvider.CurrentValue.Games.InstallDirectories.FirstOrDefault(d => Game.InstallDirectory.StartsWith(d));
|
2024-10-26 15:48:47 -05:00
|
|
|
|
|
|
|
|
if (String.IsNullOrWhiteSpace(SelectedDirectory))
|
2025-12-31 20:01:04 -06:00
|
|
|
SelectedDirectory = SettingsProvider.CurrentValue.Games.InstallDirectories.First();
|
2024-10-09 19:23:42 -05:00
|
|
|
|
2025-12-31 20:01:04 -06:00
|
|
|
RemoteGame = await GameClient.GetAsync(Options.Key);
|
2026-02-10 18:04:49 -06:00
|
|
|
|
|
|
|
|
await LoadAddons();
|
|
|
|
|
await LoadTools();
|
2025-05-15 03:04:48 +02:00
|
|
|
|
|
|
|
|
var localAddons = Game?.DependentGames.Where(g => g.Installed).Select(addon => addon.Id).ToArray() ?? [];
|
|
|
|
|
SelectedAddons = Addons?.Where(addon => localAddons.Contains(addon.Id)).ToList() ?? [];
|
2026-02-10 18:04:49 -06:00
|
|
|
|
|
|
|
|
var localTools = Game?.Tools.Where(t => t.Installed).Select(tool => tool.Id).ToArray() ?? [];
|
|
|
|
|
SelectedTools = Tools?.Where(tool => localTools.Contains(tool.Id)).ToList() ?? [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async Task LoadAddons()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Addons = (await GameClient.GetAddonsAsync(Options.Key)).OrderByTitle(g => g.SortTitle ?? g.Title).ToList();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
// TODO: Add logging
|
|
|
|
|
Addons = [];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async Task LoadTools()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Tools = (await GameClient.GetToolsAsync(Options.Key)).OrderByTitle(t => t.Name).ToList();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
// TODO: Add logging
|
|
|
|
|
Tools = [];
|
|
|
|
|
}
|
2024-09-12 19:09:13 -05:00
|
|
|
}
|
|
|
|
|
|
2024-10-26 15:48:47 -05:00
|
|
|
async Task Close()
|
2024-09-12 19:09:13 -05:00
|
|
|
{
|
2024-10-26 15:48:47 -05:00
|
|
|
await CloseFeedbackAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async Task Install()
|
|
|
|
|
{
|
|
|
|
|
var game = Options.DataItem as Game;
|
2026-03-04 19:03:10 -06:00
|
|
|
|
|
|
|
|
await CloseFeedbackAsync();
|
2024-10-26 15:48:47 -05:00
|
|
|
|
2026-02-10 18:04:49 -06:00
|
|
|
await InstallService.Add(game, SelectedDirectory, SelectedAddons.ToArray());
|
|
|
|
|
|
|
|
|
|
foreach (var tool in SelectedTools)
|
|
|
|
|
await InstallService.Add(tool, SelectedDirectory);
|
2024-10-26 15:48:47 -05: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 GetOperation()
|
2024-10-26 15:48:47 -05:00
|
|
|
{
|
|
|
|
|
if (!Game.Installed)
|
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
|
|
|
return "Install";
|
2024-10-26 15:48:47 -05:00
|
|
|
|
2025-05-16 01:04:03 +02:00
|
|
|
if (Game.DependentGames.Any(g => g.Installed ^ SelectedAddons.Any(a => a.Id == g.Id)))
|
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
|
|
|
return "Modify";
|
2024-10-26 15:48:47 -05:00
|
|
|
|
|
|
|
|
if (!Game.InstallDirectory.StartsWith(SelectedDirectory))
|
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
|
|
|
return "Move";
|
2024-10-26 15:48:47 -05: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
|
|
|
return string.Empty;
|
2024-10-09 19:23:42 -05:00
|
|
|
}
|
|
|
|
|
|
2024-10-12 12:04:00 -05:00
|
|
|
long GetDownloadSize()
|
|
|
|
|
{
|
|
|
|
|
long size = 0;
|
|
|
|
|
|
|
|
|
|
if (RemoteGame != null && RemoteGame.Archives.Any())
|
|
|
|
|
{
|
|
|
|
|
size += RemoteGame.Archives.OrderByDescending(a => a.CreatedOn).First().CompressedSize;
|
|
|
|
|
|
2025-01-27 21:07:38 -06:00
|
|
|
size += SelectedAddons.Sum(a => a.Archives.OrderByDescending(arc => arc.CreatedOn).First().CompressedSize);
|
2026-02-10 18:04:49 -06:00
|
|
|
|
|
|
|
|
size += SelectedTools.Sum(t => t.Archives.OrderByDescending(arc => arc.CreatedOn).First().CompressedSize);
|
2024-10-12 12:04:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long GetSpaceRequired()
|
|
|
|
|
{
|
|
|
|
|
long size = 0;
|
|
|
|
|
|
|
|
|
|
if (RemoteGame != null && RemoteGame.Archives.Any())
|
|
|
|
|
{
|
|
|
|
|
size += RemoteGame.Archives.OrderByDescending(a => a.CreatedOn).First().UncompressedSize;
|
|
|
|
|
|
2025-01-27 21:07:38 -06:00
|
|
|
size += SelectedAddons.Sum(a => a.Archives.OrderByDescending(arc => arc.CreatedOn).First().UncompressedSize);
|
2026-02-10 18:04:49 -06:00
|
|
|
|
|
|
|
|
size += SelectedTools.Sum(t => t.Archives.OrderByDescending(arc => arc.CreatedOn).First().UncompressedSize);
|
2024-10-12 12:04:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-12 19:09:13 -05:00
|
|
|
long GetFreeSpace(string path)
|
|
|
|
|
{
|
|
|
|
|
var root = Path.GetPathRoot(path);
|
|
|
|
|
var drive = new DriveInfo(path);
|
|
|
|
|
|
|
|
|
|
return drive.AvailableFreeSpace;
|
|
|
|
|
}
|
|
|
|
|
}
|