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.
366 lines
No EOL
12 KiB
Text
366 lines
No EOL
12 KiB
Text
@using LANCommander.Launcher.Data.Models
|
|
@using LANCommander.Launcher.Models
|
|
@using System.Diagnostics
|
|
@using LANCommander.SDK
|
|
@using LANCommander.SDK.Helpers
|
|
@inject GameService GameService
|
|
@inject UserService UserService
|
|
@inject LibraryService LibraryService
|
|
@inject InstallService InstallService
|
|
@inject ModalService ModalService
|
|
@inject MessageBusService MessageBusService
|
|
@inject SDK.Client Client
|
|
@inject LocalizationService LocalizationService
|
|
|
|
@if (GameActions != null && GameActions.Count() > 0)
|
|
{
|
|
@foreach (var action in GameActions.OrderBy(a => a.SortOrder))
|
|
{
|
|
<MenuItem OnClick="() => Run(Game, action)" Class="@(action.IsPrimaryAction ? "primary-action" : "")">
|
|
@action.Name
|
|
</MenuItem>
|
|
}
|
|
|
|
<MenuDivider />
|
|
}
|
|
|
|
@if (Game.Installed)
|
|
{
|
|
if (Game.Media != null && Game.Media.Any(m => m.Type == SDK.Enums.MediaType.Manual))
|
|
{
|
|
foreach (var manual in Game.Media.Where(m => m.Type == SDK.Enums.MediaType.Manual))
|
|
{
|
|
<MenuItem OnClick="() => OpenManual(manual)">
|
|
@(String.IsNullOrWhiteSpace(manual.Name) ? LocalizationService.GetString("Manual") : manual.Name)
|
|
</MenuItem>
|
|
}
|
|
|
|
<MenuDivider />
|
|
}
|
|
|
|
<MenuItem OnClick="() => OpenSaveManager()" Disabled="ConnectionState.OfflineModeEnabled">
|
|
@LocalizationService.GetString("ManageSaves")
|
|
</MenuItem>
|
|
|
|
if (Settings.Games.InstallDirectories.Length > 1 || Game.DependentGames.Any(g => g.Type == Data.Enums.GameType.Expansion || g.Type == Data.Enums.GameType.Mod))
|
|
{
|
|
<MenuItem OnClick="() => Modify()" Disabled="ConnectionState.OfflineModeEnabled">
|
|
@LocalizationService.GetString("Modify")
|
|
</MenuItem>
|
|
}
|
|
|
|
<MenuItem OnClick="() => BrowseFiles()">
|
|
@LocalizationService.GetString("BrowseFiles")
|
|
</MenuItem>
|
|
<MenuItem OnClick="() => ValidateFiles()" Disabled="ConnectionState.OfflineModeEnabled">
|
|
@LocalizationService.GetString("ValidateFiles")
|
|
</MenuItem>
|
|
<MenuItem OnClick="() => RemoveFromLibrary()" Disabled="ConnectionState.OfflineModeEnabled">
|
|
@LocalizationService.GetString("Remove")
|
|
</MenuItem>
|
|
<MenuItem OnClick="() => Uninstall()">
|
|
@LocalizationService.GetString("Uninstall")
|
|
</MenuItem>
|
|
}
|
|
else
|
|
{
|
|
<MenuItem OnClick="() => Install()" Disabled="ConnectionState.OfflineModeEnabled">
|
|
@LocalizationService.GetString("Install")
|
|
</MenuItem>
|
|
<MenuItem OnClick="() => RemoveFromLibrary()" Disabled="ConnectionState.OfflineModeEnabled">
|
|
@LocalizationService.GetString("Remove")
|
|
</MenuItem>
|
|
}
|
|
|
|
@if (Settings.Debug.EnableScriptDebugging)
|
|
{
|
|
<MenuDivider />
|
|
|
|
<MenuItem OnClick="() => RunInstallScripts()">
|
|
@LocalizationService.GetString("RunInstallScripts")
|
|
</MenuItem>
|
|
|
|
<MenuItem OnClick="() => RunUninstallScripts()">
|
|
@LocalizationService.GetString("RunUninstallScripts")
|
|
</MenuItem>
|
|
|
|
<MenuItem OnClick="() => RunNameChangeScripts()">
|
|
@LocalizationService.GetString("RunNameChangeScripts")
|
|
</MenuItem>
|
|
|
|
<MenuItem OnClick="() => RunKeyChangeScripts()">
|
|
@LocalizationService.GetString("RunKeyChangeScripts")
|
|
</MenuItem>
|
|
}
|
|
|
|
<MenuDivider />
|
|
|
|
<MenuItem OnClick="() => ReportIssue()" Disabled="ConnectionState.OfflineModeEnabled">
|
|
@LocalizationService.GetString("ReportIssue")
|
|
</MenuItem>
|
|
|
|
@MenuExtra
|
|
|
|
@code {
|
|
[Parameter] public Models.ListItem Model { get; set; }
|
|
[Parameter] public RenderFragment MenuExtra { get; set; }
|
|
[Parameter] public bool ShowPrimaryActions { get; set; }
|
|
[CascadingParameter] public ConnectionState ConnectionState { get; set; }
|
|
|
|
Data.Models.Game Game { get; set; }
|
|
IEnumerable<SDK.Models.Action> GameActions { get; set; } = [];
|
|
|
|
Settings Settings;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
Settings = SettingService.GetSettings();
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
if (Model.DataItem is Game game)
|
|
{
|
|
Game = game;
|
|
List<SDK.Models.Action> actions = [];
|
|
|
|
if (Game.Installed)
|
|
{
|
|
var manifest = await ManifestHelper.ReadAsync<GameManifest>(Game.InstallDirectory, Game.Id);
|
|
|
|
if (manifest != null)
|
|
{
|
|
actions = manifest.Actions.Where(a => ShowPrimaryActions || !a.IsPrimaryAction).ToList();
|
|
}
|
|
}
|
|
|
|
GameActions = actions;
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
|
|
async Task Run(Game game, SDK.Models.Action action)
|
|
{
|
|
var task = GameService.Run(game, action);
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
|
|
await task;
|
|
}
|
|
|
|
async Task BrowseFiles()
|
|
{
|
|
Process.Start("explorer", Game.InstallDirectory);
|
|
}
|
|
|
|
async Task Install()
|
|
{
|
|
if (Settings.Games.InstallDirectories.Length > 1 || (Model.DataItem as Game).DependentGames.Any(g => g.Type == Data.Enums.GameType.Expansion || g.Type == Data.Enums.GameType.Mod))
|
|
{
|
|
var modalOptions = new ModalOptions()
|
|
{
|
|
Title = LocalizationService.GetString("InstallGame", Model.Name),
|
|
Maximizable = false,
|
|
DefaultMaximized = false,
|
|
Closable = true,
|
|
Draggable = true,
|
|
Centered = true,
|
|
WrapClassName = "ant-modal-wrap-no-padding",
|
|
Footer = null,
|
|
};
|
|
|
|
var modalRef = ModalService.CreateModal<InstallDialog, Models.ListItem, string>(modalOptions, Model);
|
|
}
|
|
else
|
|
{
|
|
var game = Model.DataItem as Game;
|
|
|
|
await InstallService.Add(game);
|
|
}
|
|
}
|
|
|
|
async Task Modify()
|
|
{
|
|
var modalOptions = new ModalOptions()
|
|
{
|
|
Title = LocalizationService.GetString("ModifyGame", Model.Name),
|
|
Maximizable = false,
|
|
DefaultMaximized = false,
|
|
Closable = true,
|
|
Draggable = true,
|
|
Centered = true,
|
|
WrapClassName = "ant-modal-wrap-no-padding",
|
|
Footer = null,
|
|
};
|
|
|
|
var modalRef = ModalService.CreateModal<InstallDialog, Models.ListItem, string>(modalOptions, Model);
|
|
}
|
|
|
|
async Task ValidateFiles()
|
|
{
|
|
var modalOptions = new ModalOptions()
|
|
{
|
|
Title = LocalizationService.GetString("FileConflicts"),
|
|
Maximizable = false,
|
|
DefaultMaximized = true,
|
|
Closable = true,
|
|
Draggable = true,
|
|
Centered = true,
|
|
OkText = LocalizationService.GetString("ReplaceSelected"),
|
|
};
|
|
|
|
var modalRef = ModalService.CreateModal<ValidateFilesDialog, Game>(modalOptions, Model.DataItem as Game);
|
|
}
|
|
|
|
async Task Uninstall()
|
|
{
|
|
var manifest = await ManifestHelper.ReadAsync<GameManifest>(Game.InstallDirectory, Game.Id);
|
|
|
|
string message;
|
|
if (manifest.SavePaths != null && manifest.SavePaths.Any())
|
|
message = LocalizationService.GetString("UninstallGameMessageWithSaves", Game.Title);
|
|
else
|
|
message = LocalizationService.GetString("UninstallGameMessageWithoutSaves", Game.Title);
|
|
|
|
var confirmed = await ModalService.ConfirmAsync(new ConfirmOptions
|
|
{
|
|
OkText = LocalizationService.GetString("UninstallGame"),
|
|
CancelText = LocalizationService.GetString("Cancel"),
|
|
Title = LocalizationService.GetString("UninstallGame"),
|
|
Content = message,
|
|
OkButtonProps = new ButtonProps()
|
|
{
|
|
Danger = true
|
|
},
|
|
Centered = true,
|
|
Icon = @<Icon Type="@IconType.Outline.Delete" />
|
|
});
|
|
|
|
if (confirmed)
|
|
await GameService.UninstallAsync(Game);
|
|
|
|
InstallService.Remove(Game.Id);
|
|
|
|
await LibraryService.LibraryChanged();
|
|
}
|
|
|
|
async Task RemoveFromLibrary()
|
|
{
|
|
var hasStandaloneDependent = Game.DependentGames?
|
|
.Where(g => g.Type != Data.Enums.GameType.Expansion && g.Type != Data.Enums.GameType.Mod)
|
|
.Any(g => LibraryService.IsInLibrary(g.Id)) ?? false;
|
|
|
|
if (!hasStandaloneDependent)
|
|
{
|
|
await LibraryService.RemoveFromLibraryAsync(Game.Id);
|
|
await LibraryService.RefreshItemsAsync(true);
|
|
return;
|
|
}
|
|
|
|
var modalOptions = new ModalOptions()
|
|
{
|
|
Title = LocalizationService.GetString("RemoveGameFromLibrary"),
|
|
Maximizable = false,
|
|
DefaultMaximized = false,
|
|
Closable = true,
|
|
Draggable = true,
|
|
Centered = true,
|
|
WrapClassName = "ant-modal-wrap-no-padding",
|
|
Footer = null,
|
|
};
|
|
|
|
var modalRef = ModalService.CreateModal<RemoveFromLibraryDialog, Models.ListItem, string>(modalOptions, Model);
|
|
}
|
|
|
|
async Task RunInstallScripts()
|
|
{
|
|
var manifests = await Client.Games.GetManifestsAsync(Game.InstallDirectory, Game.Id);
|
|
|
|
foreach (var manifest in manifests)
|
|
{
|
|
await Client.Scripts.RunInstallScriptAsync(Game.InstallDirectory, manifest.Id);
|
|
}
|
|
}
|
|
|
|
async Task RunUninstallScripts()
|
|
{
|
|
var manifests = await Client.Games.GetManifestsAsync(Game.InstallDirectory, Game.Id);
|
|
|
|
foreach (var manifest in manifests)
|
|
{
|
|
await Client.Scripts.RunUninstallScriptAsync(Game.InstallDirectory, manifest.Id);
|
|
}
|
|
}
|
|
|
|
async Task RunNameChangeScripts()
|
|
{
|
|
var user = await UserService.GetCurrentUser();
|
|
var manifests = await Client.Games.GetManifestsAsync(Game.InstallDirectory, Game.Id);
|
|
|
|
foreach (var manifest in manifests)
|
|
{
|
|
await Client.Scripts.RunNameChangeScriptAsync(Game.InstallDirectory, Game.Id, user.GetUserNameSafe ?? Settings.DEFAULT_GAME_USERNAME);
|
|
}
|
|
}
|
|
|
|
async Task RunKeyChangeScripts()
|
|
{
|
|
var manifests = await Client.Games.GetManifestsAsync(Game.InstallDirectory, Game.Id);
|
|
|
|
foreach (var manifest in manifests)
|
|
{
|
|
var key = Client.Games.GetAllocatedKey(manifest.Id);
|
|
|
|
await Client.Scripts.RunKeyChangeScriptAsync(Game.InstallDirectory, Game.Id, key);
|
|
}
|
|
}
|
|
|
|
async Task OpenManual(Media media)
|
|
{
|
|
var modalOptions = new ModalOptions()
|
|
{
|
|
Title = media.Name,
|
|
Maximizable = true,
|
|
DefaultMaximized = true,
|
|
Closable = true,
|
|
Footer = null,
|
|
Draggable = true,
|
|
Resizable = true,
|
|
WrapClassName = "pdf-reader-dialog",
|
|
};
|
|
|
|
var modalRef = await ModalService.CreateModalAsync<PdfReaderDialog, Media>(modalOptions, media);
|
|
}
|
|
|
|
async Task OpenSaveManager()
|
|
{
|
|
var modalOptions = new ModalOptions()
|
|
{
|
|
Title = LocalizationService.GetString("ManageSaves"),
|
|
Maximizable = false,
|
|
DefaultMaximized = false,
|
|
Closable = true,
|
|
Draggable = true,
|
|
Resizable = true,
|
|
WrapClassName = "ant-modal-wrap-no-padding",
|
|
Footer = null,
|
|
};
|
|
|
|
var modalRef = await ModalService.CreateModalAsync<SavesDialog, Game>(modalOptions, Game);
|
|
}
|
|
|
|
async Task ReportIssue()
|
|
{
|
|
var modalOptions = new ModalOptions()
|
|
{
|
|
Title = LocalizationService.GetString("ReportIssue"),
|
|
Maximizable = false,
|
|
DefaultMaximized = false,
|
|
Closable = true,
|
|
OkText = LocalizationService.GetString("Submit"),
|
|
Draggable = true
|
|
};
|
|
|
|
var modalRef = ModalService.CreateModal<ReportIssueDialog, Game, SDK.Models.Issue>(modalOptions, Game);
|
|
}
|
|
} |