2022-01-15 06:29:44 +00:00
|
|
|
|
using System;
|
2022-01-16 13:46:16 +00:00
|
|
|
|
using System.Diagnostics;
|
2022-01-15 06:29:44 +00:00
|
|
|
|
using System.IO;
|
2022-01-16 13:46:16 +00:00
|
|
|
|
using System.Threading;
|
2022-01-15 06:29:44 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2022-01-16 13:46:16 +00:00
|
|
|
|
using System.Windows;
|
2022-01-15 06:29:44 +00:00
|
|
|
|
using Fluxor;
|
|
|
|
|
using Microsoft.AspNetCore.Components;
|
2022-01-16 13:46:16 +00:00
|
|
|
|
using Microsoft.WindowsAPICodePack.Dialogs;
|
2022-01-15 06:29:44 +00:00
|
|
|
|
using Wabbajack.App.Blazor.Store;
|
|
|
|
|
using Wabbajack.DTOs;
|
|
|
|
|
using Wabbajack.DTOs.JsonConverters;
|
|
|
|
|
using Wabbajack.Installer;
|
|
|
|
|
using Wabbajack.Paths;
|
2022-01-16 13:46:16 +00:00
|
|
|
|
using Ookii.Dialogs.Wpf;
|
|
|
|
|
using Wabbajack.App.Blazor.Utility;
|
2022-01-15 06:29:44 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack.App.Blazor.Pages
|
|
|
|
|
{
|
|
|
|
|
public partial class Configure
|
|
|
|
|
{
|
|
|
|
|
[Inject] private NavigationManager NavigationManager { get; set; }
|
|
|
|
|
[Inject] private IState<InstallState> _installState { get; set; }
|
|
|
|
|
[Inject] private DTOSerializer _dtos { get; set; }
|
|
|
|
|
[Inject] private IDispatcher _dispatcher { get; set; }
|
|
|
|
|
|
2022-01-16 13:46:16 +00:00
|
|
|
|
private string Name { get; set; } = "";
|
|
|
|
|
private string Author { get; set; } = "";
|
|
|
|
|
private string Description { get; set; } = "";
|
|
|
|
|
private Version Version { get; set; } = Version.Parse("0.0.0");
|
|
|
|
|
private string Image { get; set; } = "";
|
|
|
|
|
private ModList ModList { get; set; }
|
|
|
|
|
private AbsolutePath ModListPath { get; set; }
|
|
|
|
|
private AbsolutePath InstallPath { get; set; }
|
|
|
|
|
private AbsolutePath DownloadPath { get; set; }
|
2022-01-15 06:29:44 +00:00
|
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
2022-01-16 13:46:16 +00:00
|
|
|
|
// var Location = KnownFolders.EntryPoint.Combine("downloaded_mod_lists", machineURL).WithExtension(Ext.Wabbajack);
|
|
|
|
|
|
2022-01-15 06:29:44 +00:00
|
|
|
|
await CheckValidInstallPath();
|
|
|
|
|
|
|
|
|
|
await base.OnInitializedAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task CheckValidInstallPath()
|
|
|
|
|
{
|
2022-01-16 13:46:16 +00:00
|
|
|
|
if (_installState.Value.CurrentModListPath == null) return;
|
2022-01-15 06:29:44 +00:00
|
|
|
|
|
2022-01-16 13:46:16 +00:00
|
|
|
|
ModListPath = (AbsolutePath)_installState.Value.CurrentModListPath;
|
|
|
|
|
ModList = await StandardInstaller.LoadFromFile(_dtos, ModListPath);
|
|
|
|
|
_dispatcher.Dispatch(new UpdateInstallState(InstallState.InstallStateEnum.Configuration, ModList, ModListPath, null, null));
|
|
|
|
|
|
|
|
|
|
Name = _installState.Value.CurrentModList.Name;
|
|
|
|
|
Author = _installState.Value.CurrentModList.Author;
|
|
|
|
|
Description = _installState.Value.CurrentModList.Description;
|
|
|
|
|
Version = _installState.Value.CurrentModList.Version;
|
|
|
|
|
ModListPath = (AbsolutePath)_installState.Value.CurrentModListPath;
|
2022-01-15 06:29:44 +00:00
|
|
|
|
|
2022-01-16 13:46:16 +00:00
|
|
|
|
Stream image = await StandardInstaller.ModListImageStream(ModListPath);
|
2022-01-15 06:29:44 +00:00
|
|
|
|
await using var reader = new MemoryStream();
|
|
|
|
|
await image.CopyToAsync(reader);
|
|
|
|
|
Image = $"data:image/png;base64,{Convert.ToBase64String(reader.ToArray())}";
|
|
|
|
|
}
|
2022-01-16 13:46:16 +00:00
|
|
|
|
|
|
|
|
|
private async void SelectInstallFolder()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
AbsolutePath? thing = await Dialog.ShowDialogNonBlocking(true);
|
|
|
|
|
if (thing != null) InstallPath = (AbsolutePath)thing;
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Debug.Print(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void SelectDownloadFolder()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
AbsolutePath? thing = await Dialog.ShowDialogNonBlocking(true);
|
|
|
|
|
if (thing != null) DownloadPath = (AbsolutePath)thing;
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Debug.Print(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void NavigateInstall()
|
|
|
|
|
{
|
|
|
|
|
_dispatcher.Dispatch(new UpdateInstallState(InstallState.InstallStateEnum.Configuration, ModList, ModListPath, InstallPath, DownloadPath));
|
|
|
|
|
NavigationManager.NavigateTo("installing");
|
|
|
|
|
}
|
2022-01-15 06:29:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|