mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Code cleanup and fix test running
This commit is contained in:
parent
2b5662a15b
commit
f99f4a7538
2
.github/workflows/tests.yaml
vendored
2
.github/workflows/tests.yaml
vendored
@ -43,7 +43,7 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: dotnet build --configuration Release --no-restore
|
run: dotnet build --configuration Release --no-restore
|
||||||
- name: Test
|
- name: Test
|
||||||
run: dotnet test --no-restore --filter "Category=!FlakeyNetwork"
|
run: dotnet test --no-restore --filter "Category!=FlakeyNetwork"
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
name: Publish Projects
|
name: Publish Projects
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using ReactiveUI;
|
|
||||||
using Wabbajack.App.Models;
|
using Wabbajack.App.Models;
|
||||||
|
|
||||||
namespace Wabbajack.App.Test;
|
namespace Wabbajack.App.Test;
|
||||||
@ -28,6 +27,7 @@ public static class Extensions
|
|||||||
await Task.Delay(100);
|
await Task.Delay(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task WaitForUnlock(this LoadingLock l)
|
public static async Task WaitForUnlock(this LoadingLock l)
|
||||||
{
|
{
|
||||||
Dispatcher.UIThread.RunJobs();
|
Dispatcher.UIThread.RunJobs();
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Data;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Wabbajack.App.Controls;
|
using Wabbajack.App.Controls;
|
||||||
@ -15,8 +14,8 @@ namespace Wabbajack.App.Test;
|
|||||||
|
|
||||||
public class GalleryItemTests
|
public class GalleryItemTests
|
||||||
{
|
{
|
||||||
private readonly BrowseViewModel _gallery;
|
|
||||||
private readonly Configuration _config;
|
private readonly Configuration _config;
|
||||||
|
private readonly BrowseViewModel _gallery;
|
||||||
|
|
||||||
public GalleryItemTests(BrowseViewModel bvm, Configuration config)
|
public GalleryItemTests(BrowseViewModel bvm, Configuration config)
|
||||||
{
|
{
|
||||||
@ -28,9 +27,7 @@ public class GalleryItemTests
|
|||||||
public async Task CanDownloadGalleryItem()
|
public async Task CanDownloadGalleryItem()
|
||||||
{
|
{
|
||||||
foreach (var file in _config.ModListsDownloadLocation.EnumerateFiles().Where(f => f.Extension == Ext.Wabbajack))
|
foreach (var file in _config.ModListsDownloadLocation.EnumerateFiles().Where(f => f.Extension == Ext.Wabbajack))
|
||||||
{
|
|
||||||
file.Delete();
|
file.Delete();
|
||||||
}
|
|
||||||
|
|
||||||
using var _ = _gallery.Activator.Activate();
|
using var _ = _gallery.Activator.Activate();
|
||||||
await _gallery.LoadingLock.WaitForLock();
|
await _gallery.LoadingLock.WaitForLock();
|
||||||
|
@ -1,17 +1,13 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Avalonia.Threading;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Wabbajack.App;
|
|
||||||
using Wabbajack.Networking.WabbajackClientApi;
|
|
||||||
using Wabbajack.Services.OSIntegrated;
|
|
||||||
using Xunit.DependencyInjection;
|
using Xunit.DependencyInjection;
|
||||||
using Xunit.DependencyInjection.Logging;
|
using Xunit.DependencyInjection.Logging;
|
||||||
|
|
||||||
namespace Wabbajack.App.Test
|
namespace Wabbajack.App.Test;
|
||||||
|
|
||||||
|
public class Startup
|
||||||
{
|
{
|
||||||
public class Startup
|
|
||||||
{
|
|
||||||
public void ConfigureServices(IServiceCollection service)
|
public void ConfigureServices(IServiceCollection service)
|
||||||
{
|
{
|
||||||
service.AddAppServices();
|
service.AddAppServices();
|
||||||
@ -22,14 +18,14 @@ namespace Wabbajack.App.Test
|
|||||||
loggerFactory.AddProvider(new XunitTestOutputLoggerProvider(accessor, delegate { return true; }));
|
loggerFactory.AddProvider(new XunitTestOutputLoggerProvider(accessor, delegate { return true; }));
|
||||||
MessageBus.Instance = new SimpleMessageBus();
|
MessageBus.Instance = new SimpleMessageBus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SimpleMessageBus : IMessageBus
|
public class SimpleMessageBus : IMessageBus
|
||||||
{
|
{
|
||||||
public List<object> Messages { get; } = new();
|
public List<object> Messages { get; } = new();
|
||||||
|
|
||||||
public void Send<T>(T message)
|
public void Send<T>(T message)
|
||||||
{
|
{
|
||||||
Messages.Add(message);
|
Messages.Add(message);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -7,21 +7,21 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0"/>
|
||||||
<PackageReference Include="xunit" Version="2.4.1" />
|
<PackageReference Include="xunit" Version="2.4.1"/>
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Xunit.DependencyInjection" Version="7.7.0" />
|
<PackageReference Include="Xunit.DependencyInjection" Version="7.7.0"/>
|
||||||
<PackageReference Include="Xunit.DependencyInjection.Logging" Version="7.5.1" />
|
<PackageReference Include="Xunit.DependencyInjection.Logging" Version="7.5.1"/>
|
||||||
<PackageReference Include="coverlet.collector" Version="3.1.0">
|
<PackageReference Include="coverlet.collector" Version="3.1.0">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Wabbajack.App\Wabbajack.App.csproj" />
|
<ProjectReference Include="..\Wabbajack.App\Wabbajack.App.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,25 +1,24 @@
|
|||||||
<Application xmlns="https://github.com/avaloniaui"
|
<Application xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:local="using:Wabbajack.App"
|
xmlns:local="using:Wabbajack.App"
|
||||||
xmlns:i="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
|
||||||
x:Class="Wabbajack.App.App">
|
x:Class="Wabbajack.App.App">
|
||||||
<Application.DataTemplates>
|
<Application.DataTemplates>
|
||||||
<local:ViewLocator/>
|
<local:ViewLocator />
|
||||||
</Application.DataTemplates>
|
</Application.DataTemplates>
|
||||||
|
|
||||||
<Application.Styles>
|
<Application.Styles>
|
||||||
<StyleInclude Source="avares://Material.Icons.Avalonia/App.xaml"></StyleInclude>
|
<StyleInclude Source="avares://Material.Icons.Avalonia/App.xaml" />
|
||||||
<FluentTheme Mode="Dark"/>
|
<FluentTheme Mode="Dark" />
|
||||||
<StyleInclude Source="avares://Wabbajack.App/Assets/Wabbajack.axaml"></StyleInclude>
|
<StyleInclude Source="avares://Wabbajack.App/Assets/Wabbajack.axaml" />
|
||||||
<Style Selector="Button:not(:pointerover) /template/ ContentPresenter">
|
<Style Selector="Button:not(:pointerover) /template/ ContentPresenter">
|
||||||
<Setter Property="Background" Value="Transparent"></Setter>
|
<Setter Property="Background" Value="Transparent" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
|
||||||
<Style Selector="Button:pointerover /template/ ContentPresenter">
|
<Style Selector="Button:pointerover /template/ ContentPresenter">
|
||||||
<Setter Property="Background" Value="Transparent"></Setter>
|
<Setter Property="Background" Value="Transparent" />
|
||||||
<Setter Property="BorderBrush" Value="LightGray"></Setter>
|
<Setter Property="BorderBrush" Value="LightGray" />
|
||||||
<Setter Property="CornerRadius" Value="5"></Setter>
|
<Setter Property="CornerRadius" Value="5" />
|
||||||
</Style>
|
</Style>
|
||||||
</Application.Styles>
|
</Application.Styles>
|
||||||
</Application>
|
</Application>
|
@ -3,32 +3,25 @@ using Avalonia;
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using CefNet;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Splat;
|
using Splat;
|
||||||
using Wabbajack.App.Controls;
|
|
||||||
using Wabbajack.App.Converters;
|
using Wabbajack.App.Converters;
|
||||||
using Wabbajack.App.Interfaces;
|
|
||||||
using Wabbajack.App.Models;
|
|
||||||
using Wabbajack.App.Utilities;
|
using Wabbajack.App.Utilities;
|
||||||
using Wabbajack.App.ViewModels;
|
|
||||||
using Wabbajack.App.Views;
|
using Wabbajack.App.Views;
|
||||||
using Wabbajack.DTOs.JsonConverters;
|
|
||||||
using Wabbajack.Networking.NexusApi;
|
|
||||||
using Wabbajack.Services.OSIntegrated;
|
|
||||||
|
|
||||||
namespace Wabbajack.App
|
namespace Wabbajack.App;
|
||||||
|
|
||||||
|
public class App : Application
|
||||||
{
|
{
|
||||||
public class App : Application
|
public static IServiceProvider Services { get; private set; } = null!;
|
||||||
{
|
public static Window? MainWindow { get; set; }
|
||||||
|
|
||||||
public static event EventHandler FrameworkInitialized;
|
public static event EventHandler FrameworkInitialized;
|
||||||
public static event EventHandler FrameworkShutdown;
|
public static event EventHandler FrameworkShutdown;
|
||||||
public static IServiceProvider Services { get; private set; } = null!;
|
|
||||||
public static Window? MainWindow { get; set; }
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
AvaloniaXamlLoader.Load(this);
|
AvaloniaXamlLoader.Load(this);
|
||||||
@ -37,14 +30,8 @@ namespace Wabbajack.App
|
|||||||
public override void OnFrameworkInitializationCompleted()
|
public override void OnFrameworkInitializationCompleted()
|
||||||
{
|
{
|
||||||
var host = Host.CreateDefaultBuilder(Array.Empty<string>())
|
var host = Host.CreateDefaultBuilder(Array.Empty<string>())
|
||||||
.ConfigureLogging(c =>
|
.ConfigureLogging(c => { c.ClearProviders(); })
|
||||||
{
|
.ConfigureServices((host, services) => { services.AddAppServices(); }).Build();
|
||||||
c.ClearProviders();
|
|
||||||
})
|
|
||||||
.ConfigureServices((host, services) =>
|
|
||||||
{
|
|
||||||
services.AddAppServices();
|
|
||||||
}).Build();
|
|
||||||
Services = host.Services;
|
Services = host.Services;
|
||||||
|
|
||||||
SetupConverters();
|
SetupConverters();
|
||||||
@ -78,5 +65,4 @@ namespace Wabbajack.App
|
|||||||
{
|
{
|
||||||
Locator.CurrentMutable.RegisterConstant<IBindingTypeConverter>(new AbsoultePathBindingConverter());
|
Locator.CurrentMutable.RegisterConstant<IBindingTypeConverter>(new AbsoultePathBindingConverter());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -9,34 +9,31 @@
|
|||||||
|
|
||||||
|
|
||||||
<Style Selector="controls|TagView Border">
|
<Style Selector="controls|TagView Border">
|
||||||
<Setter Property="BorderThickness" Value="1"></Setter>
|
<Setter Property="BorderThickness" Value="1" />
|
||||||
<Setter Property="BorderBrush" Value="#121212"></Setter>
|
<Setter Property="BorderBrush" Value="#121212" />
|
||||||
<Setter Property="CornerRadius" Value="5"></Setter>
|
<Setter Property="CornerRadius" Value="5" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
|
||||||
<Style Selector="controls|TagView.ModList Border">
|
<Style Selector="controls|TagView.ModList Border">
|
||||||
<Setter Property="Background" Value="#868CFC"></Setter>
|
<Setter Property="Background" Value="#868CFC" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style Selector="controls|TagView.Game Border">
|
<Style Selector="controls|TagView.Game Border">
|
||||||
<Setter Property="Background" Value="#F686FC"></Setter>
|
<Setter Property="Background" Value="#F686FC" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style Selector="controls|TagView.GameNotInstalled Border">
|
<Style Selector="controls|TagView.GameNotInstalled Border">
|
||||||
<Setter Property="Background" Value="#FCBB86"></Setter>
|
<Setter Property="Background" Value="#FCBB86" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style Selector="controls|TagView.GameNotInstalled Border">
|
<Style Selector="controls|TagView.GameNotInstalled Border">
|
||||||
<Setter Property="Background" Value="#FCBB86"></Setter>
|
<Setter Property="Background" Value="#FCBB86" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style Selector="controls|TagView TextBlock">
|
<Style Selector="controls|TagView TextBlock">
|
||||||
<Setter Property="Foreground" Value="#121212"></Setter>
|
<Setter Property="Foreground" Value="#121212" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</Styles>
|
</Styles>
|
@ -1 +1,6 @@
|
|||||||
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="cloud-download-alt" class="svg-inline--fa fa-cloud-download-alt fa-w-20" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path fill="currentColor" d="M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zm-132.9 88.7L299.3 420.7c-6.2 6.2-16.4 6.2-22.6 0L171.3 315.3c-10.1-10.1-2.9-27.3 11.3-27.3H248V176c0-8.8 7.2-16 16-16h48c8.8 0 16 7.2 16 16v112h65.4c14.2 0 21.4 17.2 11.3 27.3z"></path></svg>
|
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="cloud-download-alt"
|
||||||
|
class="svg-inline--fa fa-cloud-download-alt fa-w-20" role="img" xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 640 512">
|
||||||
|
<path fill="currentColor"
|
||||||
|
d="M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zm-132.9 88.7L299.3 420.7c-6.2 6.2-16.4 6.2-22.6 0L171.3 315.3c-10.1-10.1-2.9-27.3 11.3-27.3H248V176c0-8.8 7.2-16 16-16h48c8.8 0 16 7.2 16 16v112h65.4c14.2 0 21.4 17.2 11.3 27.3z"></path>
|
||||||
|
</svg>
|
Before Width: | Height: | Size: 687 B After Width: | Height: | Size: 713 B |
@ -1,14 +1,13 @@
|
|||||||
using Wabbajack.Paths;
|
using Wabbajack.Paths;
|
||||||
|
|
||||||
namespace Wabbajack.App
|
namespace Wabbajack.App;
|
||||||
|
|
||||||
|
public class Configuration
|
||||||
{
|
{
|
||||||
public class Configuration
|
|
||||||
{
|
|
||||||
public AbsolutePath ModListsDownloadLocation { get; set; }
|
public AbsolutePath ModListsDownloadLocation { get; set; }
|
||||||
public AbsolutePath SavedSettingsLocation { get; set; }
|
public AbsolutePath SavedSettingsLocation { get; set; }
|
||||||
|
|
||||||
public AbsolutePath EncryptedDataLocation { get; set; }
|
public AbsolutePath EncryptedDataLocation { get; set; }
|
||||||
|
|
||||||
public AbsolutePath LogLocation { get; set; }
|
public AbsolutePath LogLocation { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
@ -42,12 +42,12 @@
|
|||||||
<ItemsControl Grid.Row="2" x:Name="TagsList">
|
<ItemsControl Grid.Row="2" x:Name="TagsList">
|
||||||
<ItemsControl.ItemsPanel>
|
<ItemsControl.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<WrapPanel/>
|
<WrapPanel />
|
||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
</ItemsControl.ItemsPanel>
|
</ItemsControl.ItemsPanel>
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<controls:TagView></controls:TagView>
|
<controls:TagView />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ItemsControl.ItemTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
@ -89,7 +89,7 @@
|
|||||||
<avalonia:MaterialIcon
|
<avalonia:MaterialIcon
|
||||||
Width="20"
|
Width="20"
|
||||||
Height="20"
|
Height="20"
|
||||||
x:Name="ExecuteIcon"/>
|
x:Name="ExecuteIcon" />
|
||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -1,17 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
using Material.Icons;
|
using Material.Icons;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Wabbajack.App.Views;
|
|
||||||
|
|
||||||
namespace Wabbajack.App.Controls
|
namespace Wabbajack.App.Controls;
|
||||||
|
|
||||||
|
public partial class BrowseItemView : ReactiveUserControl<BrowseItemViewModel>
|
||||||
{
|
{
|
||||||
public partial class BrowseItemView : ReactiveUserControl<BrowseItemViewModel>
|
|
||||||
{
|
|
||||||
public BrowseItemView()
|
public BrowseItemView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -52,5 +48,4 @@ namespace Wabbajack.App.Controls
|
|||||||
_ => throw new ArgumentOutOfRangeException(nameof(modListState), modListState, null)
|
_ => throw new ArgumentOutOfRangeException(nameof(modListState), modListState, null)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -4,13 +4,10 @@ using System.Linq;
|
|||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using System.Text.Json;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Avalonia.Media.Imaging;
|
using Avalonia.Media.Imaging;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.VisualBasic.CompilerServices;
|
|
||||||
using Octokit;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using Wabbajack.App.Messages;
|
using Wabbajack.App.Messages;
|
||||||
@ -20,64 +17,37 @@ using Wabbajack.Downloaders;
|
|||||||
using Wabbajack.Downloaders.GameFile;
|
using Wabbajack.Downloaders.GameFile;
|
||||||
using Wabbajack.DTOs;
|
using Wabbajack.DTOs;
|
||||||
using Wabbajack.DTOs.JsonConverters;
|
using Wabbajack.DTOs.JsonConverters;
|
||||||
using Wabbajack.Installer;
|
|
||||||
using Wabbajack.Paths;
|
using Wabbajack.Paths;
|
||||||
using Wabbajack.Paths.IO;
|
using Wabbajack.Paths.IO;
|
||||||
using Wabbajack.RateLimiter;
|
using Wabbajack.RateLimiter;
|
||||||
using Wabbajack.VFS;
|
using Wabbajack.VFS;
|
||||||
|
|
||||||
namespace Wabbajack.App.Controls
|
namespace Wabbajack.App.Controls;
|
||||||
|
|
||||||
|
public enum ModListState
|
||||||
{
|
{
|
||||||
public enum ModListState
|
|
||||||
{
|
|
||||||
Downloaded,
|
Downloaded,
|
||||||
NotDownloaded,
|
NotDownloaded,
|
||||||
Downloading
|
Downloading
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BrowseItemViewModel : ViewModelBase, IActivatableViewModel
|
public class BrowseItemViewModel : ViewModelBase, IActivatableViewModel
|
||||||
{
|
{
|
||||||
private readonly ModlistMetadata _metadata;
|
|
||||||
private readonly ModListSummary _summary;
|
|
||||||
private readonly HttpClient _client;
|
private readonly HttpClient _client;
|
||||||
private readonly IResource<HttpClient> _limiter;
|
|
||||||
private readonly FileHashCache _hashCache;
|
|
||||||
private readonly Configuration _configuration;
|
private readonly Configuration _configuration;
|
||||||
private readonly DownloadDispatcher _dispatcher;
|
private readonly DownloadDispatcher _dispatcher;
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IResource<DownloadDispatcher> _downloadLimiter;
|
private readonly IResource<DownloadDispatcher> _downloadLimiter;
|
||||||
private readonly DTOSerializer _dtos;
|
private readonly DTOSerializer _dtos;
|
||||||
|
private readonly FileHashCache _hashCache;
|
||||||
|
private readonly IResource<HttpClient> _limiter;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly ModlistMetadata _metadata;
|
||||||
|
private readonly ModListSummary _summary;
|
||||||
|
|
||||||
public string Title => _metadata.ImageContainsTitle ? "" : _metadata.Title;
|
public BrowseItemViewModel(ModlistMetadata metadata, ModListSummary summary, HttpClient client,
|
||||||
public string MachineURL => _metadata.Links.MachineURL;
|
IResource<HttpClient> limiter,
|
||||||
public string Description => _metadata.Description;
|
FileHashCache hashCache, Configuration configuration, DownloadDispatcher dispatcher,
|
||||||
|
IResource<DownloadDispatcher> downloadLimiter, GameLocator gameLocator,
|
||||||
public Uri ImageUri => new(_metadata.Links.ImageUri);
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public IBitmap Image { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public ModListState State { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public ReactiveCommand<Unit,Unit> ExecuteCommand { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public Percent Progress { get; set; }
|
|
||||||
|
|
||||||
public AbsolutePath ModListLocation => _configuration.ModListsDownloadLocation.Combine(_metadata.Links.MachineURL).WithExtension(Ext.Wabbajack);
|
|
||||||
|
|
||||||
public Game Game => _metadata.Game;
|
|
||||||
|
|
||||||
public bool IsUtilityList => _metadata.UtilityList;
|
|
||||||
public bool IsNSFW => _metadata.NSFW;
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public TagViewModel[] Tags { get; set; }
|
|
||||||
|
|
||||||
public BrowseItemViewModel(ModlistMetadata metadata, ModListSummary summary, HttpClient client, IResource<HttpClient> limiter,
|
|
||||||
FileHashCache hashCache, Configuration configuration, DownloadDispatcher dispatcher, IResource<DownloadDispatcher> downloadLimiter, GameLocator gameLocator,
|
|
||||||
DTOSerializer dtos, ILogger logger)
|
DTOSerializer dtos, ILogger logger)
|
||||||
{
|
{
|
||||||
Activator = new ViewModelActivator();
|
Activator = new ViewModelActivator();
|
||||||
@ -95,7 +65,8 @@ namespace Wabbajack.App.Controls
|
|||||||
var haveGame = gameLocator.IsInstalled(_metadata.Game);
|
var haveGame = gameLocator.IsInstalled(_metadata.Game);
|
||||||
Tags = metadata.tags
|
Tags = metadata.tags
|
||||||
.Select(t => new TagViewModel(t, "ModList"))
|
.Select(t => new TagViewModel(t, "ModList"))
|
||||||
.Prepend(new TagViewModel(_metadata.Game.MetaData().HumanFriendlyGameName, haveGame ? "Game" : "GameNotInstalled"))
|
.Prepend(new TagViewModel(_metadata.Game.MetaData().HumanFriendlyGameName,
|
||||||
|
haveGame ? "Game" : "GameNotInstalled"))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
OpenWebsiteCommand = ReactiveCommand.Create(() =>
|
OpenWebsiteCommand = ReactiveCommand.Create(() =>
|
||||||
@ -114,7 +85,6 @@ namespace Wabbajack.App.Controls
|
|||||||
{
|
{
|
||||||
DownloadModList().FireAndForget();
|
DownloadModList().FireAndForget();
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
this.ObservableForProperty(t => t.State)
|
this.ObservableForProperty(t => t.State)
|
||||||
.Select(c => c.Value != ModListState.Downloading)
|
.Select(c => c.Value != ModListState.Downloading)
|
||||||
@ -124,6 +94,33 @@ namespace Wabbajack.App.Controls
|
|||||||
UpdateState().FireAndForget();
|
UpdateState().FireAndForget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string Title => _metadata.ImageContainsTitle ? "" : _metadata.Title;
|
||||||
|
public string MachineURL => _metadata.Links.MachineURL;
|
||||||
|
public string Description => _metadata.Description;
|
||||||
|
|
||||||
|
public Uri ImageUri => new(_metadata.Links.ImageUri);
|
||||||
|
|
||||||
|
[Reactive] public IBitmap Image { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public ModListState State { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public ReactiveCommand<Unit, Unit> ExecuteCommand { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public Percent Progress { get; set; }
|
||||||
|
|
||||||
|
public AbsolutePath ModListLocation => _configuration.ModListsDownloadLocation.Combine(_metadata.Links.MachineURL)
|
||||||
|
.WithExtension(Ext.Wabbajack);
|
||||||
|
|
||||||
|
public Game Game => _metadata.Game;
|
||||||
|
|
||||||
|
public bool IsUtilityList => _metadata.UtilityList;
|
||||||
|
public bool IsNSFW => _metadata.NSFW;
|
||||||
|
|
||||||
|
[Reactive] public TagViewModel[] Tags { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public ReactiveCommand<Unit, Unit> OpenWebsiteCommand { get; set; }
|
||||||
|
|
||||||
private async Task DownloadModList()
|
private async Task DownloadModList()
|
||||||
{
|
{
|
||||||
State = ModListState.Downloading;
|
State = ModListState.Downloading;
|
||||||
@ -164,9 +161,6 @@ namespace Wabbajack.App.Controls
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ReactiveCommand<Unit,Unit> OpenWebsiteCommand { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
public async Task LoadListImage()
|
public async Task LoadListImage()
|
||||||
{
|
{
|
||||||
using var job = await _limiter.Begin("Loading modlist image", 0, CancellationToken.None);
|
using var job = await _limiter.Begin("Loading modlist image", 0, CancellationToken.None);
|
||||||
@ -180,14 +174,14 @@ namespace Wabbajack.App.Controls
|
|||||||
if (!file.FileExists())
|
if (!file.FileExists())
|
||||||
return ModListState.NotDownloaded;
|
return ModListState.NotDownloaded;
|
||||||
|
|
||||||
return (await _hashCache.FileHashCachedAsync(file, CancellationToken.None)) !=
|
return await _hashCache.FileHashCachedAsync(file, CancellationToken.None) !=
|
||||||
_metadata.DownloadMetadata?.Hash ? ModListState.NotDownloaded : ModListState.Downloaded;
|
_metadata.DownloadMetadata?.Hash
|
||||||
|
? ModListState.NotDownloaded
|
||||||
|
: ModListState.Downloaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateState()
|
public async Task UpdateState()
|
||||||
{
|
{
|
||||||
State = await GetState();
|
State = await GetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -8,34 +8,34 @@
|
|||||||
|
|
||||||
<UserControl.Styles>
|
<UserControl.Styles>
|
||||||
<Style Selector="Button:not(:pointerover) /template/ ContentPresenter">
|
<Style Selector="Button:not(:pointerover) /template/ ContentPresenter">
|
||||||
<Setter Property="Background" Value="Transparent"></Setter>
|
<Setter Property="Background" Value="Transparent" />
|
||||||
<Setter Property="BorderBrush" Value="LightGray"></Setter>
|
<Setter Property="BorderBrush" Value="LightGray" />
|
||||||
<Setter Property="CornerRadius" Value="0, 5, 5, 0"></Setter>
|
<Setter Property="CornerRadius" Value="0, 5, 5, 0" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style Selector="Button:pointerover /template/ ContentPresenter">
|
<Style Selector="Button:pointerover /template/ ContentPresenter">
|
||||||
<Setter Property="Background" Value="Transparent"></Setter>
|
<Setter Property="Background" Value="Transparent" />
|
||||||
<Setter Property="BorderBrush" Value="LightGray"></Setter>
|
<Setter Property="BorderBrush" Value="LightGray" />
|
||||||
<Setter Property="CornerRadius" Value="0, 5, 5, 0"></Setter>
|
<Setter Property="CornerRadius" Value="0, 5, 5, 0" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style Selector="TextBox:not(:focus) /template/ ContentPresenter">
|
<Style Selector="TextBox:not(:focus) /template/ ContentPresenter">
|
||||||
<Setter Property="Background" Value="Transparent"></Setter>
|
<Setter Property="Background" Value="Transparent" />
|
||||||
<Setter Property="BorderBrush" Value="LightGray"></Setter>
|
<Setter Property="BorderBrush" Value="LightGray" />
|
||||||
<Setter Property="CornerRadius" Value="5, 0, 0, 5"></Setter>
|
<Setter Property="CornerRadius" Value="5, 0, 0, 5" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style Selector="TextBox:focus /template/ ContentPresenter">
|
<Style Selector="TextBox:focus /template/ ContentPresenter">
|
||||||
<Setter Property="Background" Value="Transparent"></Setter>
|
<Setter Property="Background" Value="Transparent" />
|
||||||
<Setter Property="BorderBrush" Value="LightGray"></Setter>
|
<Setter Property="BorderBrush" Value="LightGray" />
|
||||||
<Setter Property="CornerRadius" Value="5, 0, 0, 5"></Setter>
|
<Setter Property="CornerRadius" Value="5, 0, 0, 5" />
|
||||||
</Style>
|
</Style>
|
||||||
</UserControl.Styles>
|
</UserControl.Styles>
|
||||||
|
|
||||||
<Grid ColumnDefinitions="*, 30" Height="30">
|
<Grid ColumnDefinitions="*, 30" Height="30">
|
||||||
<TextBox Grid.Column="0" Name="Path" Height="30" x:Name="TextBox" IsEnabled="False"></TextBox>
|
<TextBox Grid.Column="0" Name="Path" Height="30" x:Name="TextBox" IsEnabled="False" />
|
||||||
<Button Grid.Column="1" Name="SelectButton" Height="30">
|
<Button Grid.Column="1" Name="SelectButton" Height="30">
|
||||||
<i:MaterialIcon Kind="Search"></i:MaterialIcon>
|
<i:MaterialIcon Kind="Search" />
|
||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
@ -1,21 +1,28 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reactive;
|
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Wabbajack.Paths;
|
using Wabbajack.Paths;
|
||||||
|
|
||||||
namespace Wabbajack.App.Controls
|
namespace Wabbajack.App.Controls;
|
||||||
|
|
||||||
|
public partial class FileSelectionBox : ReactiveUserControl<FileSelectionBoxViewModel>
|
||||||
{
|
{
|
||||||
public partial class FileSelectionBox : ReactiveUserControl<FileSelectionBoxViewModel>
|
public static readonly DirectProperty<FileSelectionBox, AbsolutePath> SelectedPathProperty =
|
||||||
{
|
AvaloniaProperty.RegisterDirect<FileSelectionBox, AbsolutePath>(nameof(SelectedPath), o => o.SelectedPath);
|
||||||
|
|
||||||
|
public static readonly StyledProperty<string> AllowedExtensionsProperty =
|
||||||
|
AvaloniaProperty.Register<FileSelectionBox, string>(nameof(AllowedExtensions));
|
||||||
|
|
||||||
|
public static readonly StyledProperty<bool> SelectFolderProperty =
|
||||||
|
AvaloniaProperty.Register<FileSelectionBox, bool>(nameof(SelectFolder));
|
||||||
|
|
||||||
|
private AbsolutePath _selectedPath;
|
||||||
|
|
||||||
public FileSelectionBox()
|
public FileSelectionBox()
|
||||||
{
|
{
|
||||||
DataContext = App.Services.GetService<FileSelectionBoxViewModel>()!;
|
DataContext = App.Services.GetService<FileSelectionBoxViewModel>()!;
|
||||||
@ -43,31 +50,21 @@ namespace Wabbajack.App.Controls
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DirectProperty<FileSelectionBox, AbsolutePath> SelectedPathProperty =
|
|
||||||
AvaloniaProperty.RegisterDirect<FileSelectionBox, AbsolutePath>(nameof(SelectedPath), o => o.SelectedPath);
|
|
||||||
|
|
||||||
private AbsolutePath _selectedPath;
|
|
||||||
public AbsolutePath SelectedPath
|
public AbsolutePath SelectedPath
|
||||||
{
|
{
|
||||||
get => _selectedPath;
|
get => _selectedPath;
|
||||||
set => SetAndRaise(SelectedPathProperty, ref _selectedPath, value);
|
set => SetAndRaise(SelectedPathProperty, ref _selectedPath, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly StyledProperty<string> AllowedExtensionsProperty =
|
|
||||||
AvaloniaProperty.Register<FileSelectionBox, string>(nameof(AllowedExtensions));
|
|
||||||
public string AllowedExtensions
|
public string AllowedExtensions
|
||||||
{
|
{
|
||||||
get => GetValue(AllowedExtensionsProperty);
|
get => GetValue(AllowedExtensionsProperty);
|
||||||
set => SetValue(AllowedExtensionsProperty, value);
|
set => SetValue(AllowedExtensionsProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly StyledProperty<bool> SelectFolderProperty =
|
|
||||||
AvaloniaProperty.Register<FileSelectionBox, bool>(nameof(SelectFolder));
|
|
||||||
|
|
||||||
public bool SelectFolder
|
public bool SelectFolder
|
||||||
{
|
{
|
||||||
get => GetValue(SelectFolderProperty);
|
get => GetValue(SelectFolderProperty);
|
||||||
set => SetValue(SelectFolderProperty, value);
|
set => SetValue(SelectFolderProperty, value);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
@ -9,22 +10,12 @@ using ReactiveUI.Fody.Helpers;
|
|||||||
using Wabbajack.App.ViewModels;
|
using Wabbajack.App.ViewModels;
|
||||||
using Wabbajack.Paths;
|
using Wabbajack.Paths;
|
||||||
|
|
||||||
namespace Wabbajack.App.Controls
|
namespace Wabbajack.App.Controls;
|
||||||
|
|
||||||
|
public class FileSelectionBoxViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
public class FileSelectionBoxViewModel : ViewModelBase
|
|
||||||
{
|
|
||||||
[Reactive] public AbsolutePath Path { get; set; }
|
|
||||||
|
|
||||||
[Reactive] public Extension[] Extensions { get; set; } = Array.Empty<Extension>();
|
|
||||||
|
|
||||||
[Reactive] public bool SelectFolder { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public ReactiveCommand<Unit, Task> BrowseCommand { get; set; } = null!;
|
|
||||||
|
|
||||||
public FileSelectionBoxViewModel()
|
public FileSelectionBoxViewModel()
|
||||||
{
|
{
|
||||||
|
|
||||||
Activator = new ViewModelActivator();
|
Activator = new ViewModelActivator();
|
||||||
this.WhenActivated(disposables =>
|
this.WhenActivated(disposables =>
|
||||||
{
|
{
|
||||||
@ -32,9 +23,9 @@ namespace Wabbajack.App.Controls
|
|||||||
{
|
{
|
||||||
if (SelectFolder)
|
if (SelectFolder)
|
||||||
{
|
{
|
||||||
var dialog = new OpenFolderDialog()
|
var dialog = new OpenFolderDialog
|
||||||
{
|
{
|
||||||
Title = "Select a folder",
|
Title = "Select a folder"
|
||||||
};
|
};
|
||||||
var result = await dialog.ShowAsync(App.MainWindow);
|
var result = await dialog.ShowAsync(App.MainWindow);
|
||||||
if (result != null)
|
if (result != null)
|
||||||
@ -47,9 +38,9 @@ namespace Wabbajack.App.Controls
|
|||||||
{
|
{
|
||||||
AllowMultiple = false,
|
AllowMultiple = false,
|
||||||
Title = "Select a file",
|
Title = "Select a file",
|
||||||
Filters = new()
|
Filters = new List<FileDialogFilter>
|
||||||
{
|
{
|
||||||
new FileDialogFilter { Extensions = extensions, Name = "*" }
|
new FileDialogFilter {Extensions = extensions, Name = "*"}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var results = await dialog.ShowAsync(App.MainWindow);
|
var results = await dialog.ShowAsync(App.MainWindow);
|
||||||
@ -58,8 +49,13 @@ namespace Wabbajack.App.Controls
|
|||||||
}
|
}
|
||||||
}).DisposeWith(disposables);
|
}).DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
[Reactive] public AbsolutePath Path { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public Extension[] Extensions { get; set; } = Array.Empty<Extension>();
|
||||||
|
|
||||||
|
[Reactive] public bool SelectFolder { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public ReactiveCommand<Unit, Task> BrowseCommand { get; set; } = null!;
|
||||||
}
|
}
|
@ -4,5 +4,5 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Wabbajack.App.Controls.GameSelectorItemView">
|
x:Class="Wabbajack.App.Controls.GameSelectorItemView">
|
||||||
<TextBlock x:Name="GameName"></TextBlock>
|
<TextBlock x:Name="GameName" />
|
||||||
</UserControl>
|
</UserControl>
|
@ -1,14 +1,11 @@
|
|||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace Wabbajack.App.Controls
|
namespace Wabbajack.App.Controls;
|
||||||
|
|
||||||
|
public partial class GameSelectorItemView : ReactiveUserControl<GameSelectorItemViewModel>
|
||||||
{
|
{
|
||||||
public partial class GameSelectorItemView : ReactiveUserControl<GameSelectorItemViewModel>
|
|
||||||
{
|
|
||||||
public GameSelectorItemView()
|
public GameSelectorItemView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -19,6 +16,4 @@ namespace Wabbajack.App.Controls
|
|||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -3,21 +3,18 @@ using ReactiveUI.Fody.Helpers;
|
|||||||
using Wabbajack.App.ViewModels;
|
using Wabbajack.App.ViewModels;
|
||||||
using Wabbajack.DTOs;
|
using Wabbajack.DTOs;
|
||||||
|
|
||||||
namespace Wabbajack.App.Controls
|
namespace Wabbajack.App.Controls;
|
||||||
|
|
||||||
|
public class GameSelectorItemViewModel : ViewModelBase, IActivatableViewModel
|
||||||
{
|
{
|
||||||
public class GameSelectorItemViewModel : ViewModelBase, IActivatableViewModel
|
|
||||||
{
|
|
||||||
[Reactive]
|
|
||||||
public Game Game { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
public GameSelectorItemViewModel(Game game)
|
public GameSelectorItemViewModel(Game game)
|
||||||
{
|
{
|
||||||
Activator = new ViewModelActivator();
|
Activator = new ViewModelActivator();
|
||||||
Game = game;
|
Game = game;
|
||||||
Name = game.MetaData().HumanFriendlyGameName;
|
Name = game.MetaData().HumanFriendlyGameName;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
[Reactive] public Game Game { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public string Name { get; set; }
|
||||||
}
|
}
|
@ -6,10 +6,10 @@
|
|||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Wabbajack.App.Controls.InstalledListView">
|
x:Class="Wabbajack.App.Controls.InstalledListView">
|
||||||
<Grid RowDefinitions="Auto, Auto" ColumnDefinitions="*, Auto">
|
<Grid RowDefinitions="Auto, Auto" ColumnDefinitions="*, Auto">
|
||||||
<TextBlock Grid.Row="0" Grid.Column="0" x:Name="Title"></TextBlock>
|
<TextBlock Grid.Row="0" Grid.Column="0" x:Name="Title" />
|
||||||
<TextBlock Grid.Row="1" Grid.Column="0" x:Name="InstallationPath"></TextBlock>
|
<TextBlock Grid.Row="1" Grid.Column="0" x:Name="InstallationPath" />
|
||||||
<Button Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" x:Name="PlayButton">
|
<Button Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" x:Name="PlayButton">
|
||||||
<i:MaterialIcon Kind="PlayArrow"></i:MaterialIcon>
|
<i:MaterialIcon Kind="PlayArrow" />
|
||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
@ -1,7 +1,6 @@
|
|||||||
using Avalonia.Controls.Mixins;
|
using Avalonia.Controls.Mixins;
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Wabbajack.App.Utilities;
|
|
||||||
|
|
||||||
namespace Wabbajack.App.Controls;
|
namespace Wabbajack.App.Controls;
|
||||||
|
|
||||||
@ -24,5 +23,4 @@ public partial class InstalledListView : ReactiveUserControl<InstalledListViewMo
|
|||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
|
||||||
using Wabbajack.App.Messages;
|
using Wabbajack.App.Messages;
|
||||||
using Wabbajack.App.Screens;
|
using Wabbajack.App.Screens;
|
||||||
using Wabbajack.App.ViewModels;
|
using Wabbajack.App.ViewModels;
|
||||||
@ -12,10 +11,6 @@ namespace Wabbajack.App.Controls;
|
|||||||
public class InstalledListViewModel : ViewModelBase
|
public class InstalledListViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
private readonly InstallationConfigurationSetting _setting;
|
private readonly InstallationConfigurationSetting _setting;
|
||||||
public AbsolutePath InstallPath => _setting.Install;
|
|
||||||
|
|
||||||
public string Name => _setting.Metadata?.Title ?? "";
|
|
||||||
public ReactiveCommand<Unit, Unit> Play { get; }
|
|
||||||
|
|
||||||
public InstalledListViewModel(InstallationConfigurationSetting setting)
|
public InstalledListViewModel(InstallationConfigurationSetting setting)
|
||||||
{
|
{
|
||||||
@ -29,4 +24,8 @@ public class InstalledListViewModel : ViewModelBase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AbsolutePath InstallPath => _setting.Install;
|
||||||
|
|
||||||
|
public string Name => _setting.Metadata?.Title ?? "";
|
||||||
|
public ReactiveCommand<Unit, Unit> Play { get; }
|
||||||
}
|
}
|
@ -7,8 +7,8 @@
|
|||||||
x:Class="Wabbajack.App.Controls.LargeIconButton">
|
x:Class="Wabbajack.App.Controls.LargeIconButton">
|
||||||
<Button x:Name="Button">
|
<Button x:Name="Button">
|
||||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
|
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||||
<i:MaterialIcon x:Name="IconControl" Width="140" Height="140"></i:MaterialIcon>
|
<i:MaterialIcon x:Name="IconControl" Width="140" Height="140" />
|
||||||
<TextBlock x:Name="TextBlock" HorizontalAlignment="Center" FontSize="28" FontWeight="Bold"></TextBlock>
|
<TextBlock x:Name="TextBlock" HorizontalAlignment="Center" FontSize="28" FontWeight="Bold" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
@ -2,34 +2,20 @@ using System.Reactive.Disposables;
|
|||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Material.Icons;
|
using Material.Icons;
|
||||||
using Material.Icons.Avalonia;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace Wabbajack.App.Controls
|
namespace Wabbajack.App.Controls;
|
||||||
|
|
||||||
|
public partial class LargeIconButton : UserControl, IActivatableView
|
||||||
{
|
{
|
||||||
public partial class LargeIconButton : UserControl, IActivatableView
|
|
||||||
{
|
|
||||||
public static readonly StyledProperty<string> TextProperty =
|
public static readonly StyledProperty<string> TextProperty =
|
||||||
AvaloniaProperty.Register<LargeIconButton, string>(nameof(Text));
|
AvaloniaProperty.Register<LargeIconButton, string>(nameof(Text));
|
||||||
|
|
||||||
public string Text
|
|
||||||
{
|
|
||||||
get => GetValue(TextProperty);
|
|
||||||
set => SetValue(TextProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static readonly StyledProperty<MaterialIconKind> IconProperty =
|
public static readonly StyledProperty<MaterialIconKind> IconProperty =
|
||||||
AvaloniaProperty.Register<LargeIconButton, MaterialIconKind>(nameof(IconProperty));
|
AvaloniaProperty.Register<LargeIconButton, MaterialIconKind>(nameof(IconProperty));
|
||||||
|
|
||||||
public MaterialIconKind Icon
|
|
||||||
{
|
|
||||||
get => GetValue(IconProperty);
|
|
||||||
set => SetValue(IconProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LargeIconButton()
|
public LargeIconButton()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -45,9 +31,17 @@ namespace Wabbajack.App.Controls
|
|||||||
.BindTo(TextBlock, x => x.Text)
|
.BindTo(TextBlock, x => x.Text)
|
||||||
.DisposeWith(dispose);
|
.DisposeWith(dispose);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string Text
|
||||||
|
{
|
||||||
|
get => GetValue(TextProperty);
|
||||||
|
set => SetValue(TextProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MaterialIconKind Icon
|
||||||
|
{
|
||||||
|
get => GetValue(IconProperty);
|
||||||
|
set => SetValue(IconProperty, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,22 +13,22 @@
|
|||||||
<ItemsControl x:Name="Messages">
|
<ItemsControl x:Name="Messages">
|
||||||
<ItemsControl.ItemsPanel>
|
<ItemsControl.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<StackPanel></StackPanel>
|
<StackPanel />
|
||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
</ItemsControl.ItemsPanel>
|
</ItemsControl.ItemsPanel>
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<controls:LogViewItem></controls:LogViewItem>
|
<controls:LogViewItem />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ItemsControl.ItemTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
|
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||||
<Button x:Name="CopyLog">
|
<Button x:Name="CopyLog">
|
||||||
<avalonia:MaterialIcon Kind="ContentCopy"></avalonia:MaterialIcon>
|
<avalonia:MaterialIcon Kind="ContentCopy" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button x:Name="OpenFolder">
|
<Button x:Name="OpenFolder">
|
||||||
<avalonia:MaterialIcon Kind="Folder"></avalonia:MaterialIcon>
|
<avalonia:MaterialIcon Kind="Folder" />
|
||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -3,7 +3,6 @@ using Avalonia.Controls.Mixins;
|
|||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Wabbajack.App.Utilities;
|
|
||||||
|
|
||||||
namespace Wabbajack.App.Controls;
|
namespace Wabbajack.App.Controls;
|
||||||
|
|
||||||
|
@ -4,5 +4,5 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Wabbajack.App.Controls.LogViewItem">
|
x:Class="Wabbajack.App.Controls.LogViewItem">
|
||||||
<TextBlock x:Name="Message" FontSize="10"></TextBlock>
|
<TextBlock x:Name="Message" FontSize="10" />
|
||||||
</UserControl>
|
</UserControl>
|
@ -16,5 +16,4 @@ public partial class LogViewItem : ReactiveUserControl<LoggerProvider.ILogMessag
|
|||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,13 +1,8 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using System.Reactive.Disposables;
|
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls.Mixins;
|
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using DynamicData;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using Wabbajack.App.Utilities;
|
using Wabbajack.App.Utilities;
|
||||||
@ -18,10 +13,6 @@ namespace Wabbajack.App.Controls;
|
|||||||
public class LogViewModel : ViewModelBase, IActivatableViewModel
|
public class LogViewModel : ViewModelBase, IActivatableViewModel
|
||||||
{
|
{
|
||||||
private readonly LoggerProvider _provider;
|
private readonly LoggerProvider _provider;
|
||||||
public ReadOnlyObservableCollection<LoggerProvider.ILogMessage> Messages => _provider.MessageLog;
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public ReactiveCommand<Unit, Unit> CopyLogFile { get; set; }
|
|
||||||
|
|
||||||
public LogViewModel(LoggerProvider provider)
|
public LogViewModel(LoggerProvider provider)
|
||||||
{
|
{
|
||||||
@ -35,4 +26,8 @@ public class LogViewModel : ViewModelBase, IActivatableViewModel
|
|||||||
Application.Current.Clipboard.SetDataObjectAsync(obj);
|
Application.Current.Clipboard.SetDataObjectAsync(obj);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ReadOnlyObservableCollection<LoggerProvider.ILogMessage> Messages => _provider.MessageLog;
|
||||||
|
|
||||||
|
[Reactive] public ReactiveCommand<Unit, Unit> CopyLogFile { get; set; }
|
||||||
}
|
}
|
@ -7,8 +7,8 @@
|
|||||||
x:Class="Wabbajack.App.Controls.RemovableListItem">
|
x:Class="Wabbajack.App.Controls.RemovableListItem">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<Button x:Name="DeleteButton">
|
<Button x:Name="DeleteButton">
|
||||||
<i:MaterialIcon Kind="MinusCircle"></i:MaterialIcon>
|
<i:MaterialIcon Kind="MinusCircle" />
|
||||||
</Button>
|
</Button>
|
||||||
<TextBlock x:Name="Text" VerticalAlignment="Center"></TextBlock>
|
<TextBlock x:Name="Text" VerticalAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
@ -1,7 +1,6 @@
|
|||||||
using Avalonia.Controls.Mixins;
|
using Avalonia.Controls.Mixins;
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Wabbajack.App.ViewModels;
|
|
||||||
|
|
||||||
namespace Wabbajack.App.Controls;
|
namespace Wabbajack.App.Controls;
|
||||||
|
|
||||||
@ -17,8 +16,6 @@ public partial class RemovableListItem : ReactiveUserControl<RemovableItemViewMo
|
|||||||
|
|
||||||
this.BindCommand(ViewModel, vm => vm.DeleteCommand, view => view.DeleteButton)
|
this.BindCommand(ViewModel, vm => vm.DeleteCommand, view => view.DeleteButton)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,4 +1,3 @@
|
|||||||
using System;
|
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
@ -8,15 +7,12 @@ namespace Wabbajack.App.Controls;
|
|||||||
|
|
||||||
public class RemovableItemViewModel : ViewModelBase
|
public class RemovableItemViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
[Reactive]
|
|
||||||
public string Text { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public ReactiveCommand<Unit, Unit> DeleteCommand { get; set; }
|
|
||||||
|
|
||||||
public RemovableItemViewModel()
|
public RemovableItemViewModel()
|
||||||
{
|
{
|
||||||
Activator = new ViewModelActivator();
|
Activator = new ViewModelActivator();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Reactive] public string Text { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public ReactiveCommand<Unit, Unit> DeleteCommand { get; set; }
|
||||||
}
|
}
|
@ -5,12 +5,12 @@
|
|||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Wabbajack.App.Controls.ResourceView">
|
x:Class="Wabbajack.App.Controls.ResourceView">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBlock x:Name="ResourceName" Width="100" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
|
<TextBlock x:Name="ResourceName" Width="100" HorizontalAlignment="Left" VerticalAlignment="Center" />
|
||||||
<Label Width="100" HorizontalContentAlignment="Right" VerticalAlignment="Center">Tasks:</Label>
|
<Label Width="100" HorizontalContentAlignment="Right" VerticalAlignment="Center">Tasks:</Label>
|
||||||
<TextBox x:Name="MaxTasks" Width="20" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBox>
|
<TextBox x:Name="MaxTasks" Width="20" HorizontalAlignment="Left" VerticalAlignment="Center" />
|
||||||
<Label Width="100" HorizontalContentAlignment="Right" VerticalAlignment="Center">Throughput:</Label>
|
<Label Width="100" HorizontalContentAlignment="Right" VerticalAlignment="Center">Throughput:</Label>
|
||||||
<TextBox x:Name="MaxThroughput" Width="20" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBox>
|
<TextBox x:Name="MaxThroughput" Width="20" HorizontalAlignment="Left" VerticalAlignment="Center" />
|
||||||
<Label Width="100" HorizontalContentAlignment="Right" VerticalAlignment="Center">Status:</Label>
|
<Label Width="100" HorizontalContentAlignment="Right" VerticalAlignment="Center">Status:</Label>
|
||||||
<TextBlock x:Name="CurrentThrougput" Width="50" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
|
<TextBlock x:Name="CurrentThrougput" Width="50" HorizontalAlignment="Left" VerticalAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
using FluentFTP.Helpers;
|
using FluentFTP.Helpers;
|
||||||
@ -25,8 +23,6 @@ public partial class ResourceView : ReactiveUserControl<ResourceViewModel>, IAct
|
|||||||
this.OneWayBind(ViewModel, vm => vm.CurrentThroughput, view => view.CurrentThrougput.Text,
|
this.OneWayBind(ViewModel, vm => vm.CurrentThroughput, view => view.CurrentThrougput.Text,
|
||||||
val => val.FileSizeToString())
|
val => val.FileSizeToString())
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,7 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using System.Timers;using ReactiveUI;
|
using System.Timers;
|
||||||
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using Wabbajack.App.ViewModels;
|
using Wabbajack.App.ViewModels;
|
||||||
using Wabbajack.RateLimiter;
|
using Wabbajack.RateLimiter;
|
||||||
@ -13,18 +14,6 @@ public class ResourceViewModel : ViewModelBase, IActivatableViewModel, IDisposab
|
|||||||
private readonly IResource _resource;
|
private readonly IResource _resource;
|
||||||
private readonly Timer _timer;
|
private readonly Timer _timer;
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public int MaxTasks { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public long MaxThroughput { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public long CurrentThroughput { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
public ResourceViewModel(IResource resource)
|
public ResourceViewModel(IResource resource)
|
||||||
{
|
{
|
||||||
Activator = new ViewModelActivator();
|
Activator = new ViewModelActivator();
|
||||||
@ -46,31 +35,32 @@ public class ResourceViewModel : ViewModelBase, IActivatableViewModel, IDisposab
|
|||||||
|
|
||||||
this.WhenAnyValue(vm => vm.MaxThroughput)
|
this.WhenAnyValue(vm => vm.MaxThroughput)
|
||||||
.Skip(1)
|
.Skip(1)
|
||||||
.Subscribe(v =>
|
.Subscribe(v => { _resource.MaxThroughput = MaxThroughput; }).DisposeWith(disposables);
|
||||||
{
|
|
||||||
_resource.MaxThroughput = MaxThroughput;
|
|
||||||
}).DisposeWith(disposables);
|
|
||||||
|
|
||||||
this.WhenAnyValue(vm => vm.MaxTasks)
|
this.WhenAnyValue(vm => vm.MaxTasks)
|
||||||
.Skip(1)
|
.Skip(1)
|
||||||
.Subscribe(v =>
|
.Subscribe(v => { _resource.MaxTasks = MaxTasks; }).DisposeWith(disposables);
|
||||||
{
|
|
||||||
_resource.MaxTasks = MaxTasks;
|
|
||||||
}).DisposeWith(disposables);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Reactive] public int MaxTasks { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public long MaxThroughput { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public long CurrentThroughput { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public string Name { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_timer.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
private void TimerElapsed(object? sender, ElapsedEventArgs e)
|
private void TimerElapsed(object? sender, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
MaxTasks = _resource.MaxTasks;
|
MaxTasks = _resource.MaxTasks;
|
||||||
MaxThroughput = _resource.MaxThroughput;
|
MaxThroughput = _resource.MaxThroughput;
|
||||||
CurrentThroughput = _resource.StatusReport.Transferred;
|
CurrentThroughput = _resource.StatusReport.Transferred;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
_timer.Dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -4,7 +4,7 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Wabbajack.App.Controls.TagView">
|
x:Class="Wabbajack.App.Controls.TagView">
|
||||||
<Border x:Name = "Border"
|
<Border x:Name="Border"
|
||||||
Margin="5,5,0,5"
|
Margin="5,5,0,5"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
CornerRadius="7,7,7,7"
|
CornerRadius="7,7,7,7"
|
||||||
@ -13,6 +13,6 @@
|
|||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="Text"
|
x:Name="Text"
|
||||||
Margin="5,5,5,5"
|
Margin="5,5,5,5"
|
||||||
FontSize="10"/>
|
FontSize="10" />
|
||||||
</Border>
|
</Border>
|
||||||
</UserControl>
|
</UserControl>
|
@ -1,15 +1,12 @@
|
|||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
using DynamicData;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace Wabbajack.App.Controls
|
namespace Wabbajack.App.Controls;
|
||||||
|
|
||||||
|
public partial class TagView : ReactiveUserControl<TagViewModel>
|
||||||
{
|
{
|
||||||
public partial class TagView : ReactiveUserControl<TagViewModel>
|
|
||||||
{
|
|
||||||
public TagView()
|
public TagView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -22,5 +19,4 @@ namespace Wabbajack.App.Controls
|
|||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -2,16 +2,10 @@ using ReactiveUI;
|
|||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using Wabbajack.App.ViewModels;
|
using Wabbajack.App.ViewModels;
|
||||||
|
|
||||||
namespace Wabbajack.App.Controls
|
namespace Wabbajack.App.Controls;
|
||||||
|
|
||||||
|
public class TagViewModel : ViewModelBase, IActivatableViewModel
|
||||||
{
|
{
|
||||||
public class TagViewModel : ViewModelBase, IActivatableViewModel
|
|
||||||
{
|
|
||||||
[Reactive]
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public string Tag { get; set; }
|
|
||||||
|
|
||||||
public TagViewModel(string name, string tag)
|
public TagViewModel(string name, string tag)
|
||||||
{
|
{
|
||||||
Activator = new ViewModelActivator();
|
Activator = new ViewModelActivator();
|
||||||
@ -19,5 +13,7 @@ namespace Wabbajack.App.Controls
|
|||||||
Tag = tag;
|
Tag = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
[Reactive] public string Name { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public string Tag { get; set; }
|
||||||
}
|
}
|
@ -2,10 +2,10 @@ using System;
|
|||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Wabbajack.Paths;
|
using Wabbajack.Paths;
|
||||||
|
|
||||||
namespace Wabbajack.App.Converters
|
namespace Wabbajack.App.Converters;
|
||||||
|
|
||||||
|
public class AbsoultePathBindingConverter : IBindingTypeConverter
|
||||||
{
|
{
|
||||||
public class AbsoultePathBindingConverter : IBindingTypeConverter
|
|
||||||
{
|
|
||||||
public int GetAffinityForObjects(Type fromType, Type toType)
|
public int GetAffinityForObjects(Type fromType, Type toType)
|
||||||
{
|
{
|
||||||
if (fromType == typeof(string) && toType == typeof(AbsolutePath) ||
|
if (fromType == typeof(string) && toType == typeof(AbsolutePath) ||
|
||||||
@ -14,12 +14,12 @@ namespace Wabbajack.App.Converters
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryConvert(object? @from, Type toType, object? conversionHint, out object? result)
|
public bool TryConvert(object? from, Type toType, object? conversionHint, out object? result)
|
||||||
{
|
{
|
||||||
switch (@from)
|
switch (from)
|
||||||
{
|
{
|
||||||
case string s:
|
case string s:
|
||||||
result = (AbsolutePath)s;
|
result = (AbsolutePath) s;
|
||||||
return true;
|
return true;
|
||||||
case AbsolutePath ap:
|
case AbsolutePath ap:
|
||||||
result = ap.ToString();
|
result = ap.ToString();
|
||||||
@ -29,5 +29,4 @@ namespace Wabbajack.App.Converters
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -3,10 +3,10 @@ using System.Reactive.Disposables;
|
|||||||
using System.Reactive.Subjects;
|
using System.Reactive.Subjects;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Wabbajack.App.Extensions
|
namespace Wabbajack.App.Extensions;
|
||||||
|
|
||||||
|
public static class IObservableExtensions
|
||||||
{
|
{
|
||||||
public static class IObservableExtensions
|
|
||||||
{
|
|
||||||
public static IObservable<TOut> SelectAsync<TIn, TOut>(this IObservable<TIn> input,
|
public static IObservable<TOut> SelectAsync<TIn, TOut>(this IObservable<TIn> input,
|
||||||
CompositeDisposable disposable,
|
CompositeDisposable disposable,
|
||||||
Func<TIn, ValueTask<TOut>> func)
|
Func<TIn, ValueTask<TOut>> func)
|
||||||
@ -21,6 +21,4 @@ namespace Wabbajack.App.Extensions
|
|||||||
|
|
||||||
return returnObs;
|
return returnObs;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,12 +1,5 @@
|
|||||||
using System;
|
namespace Wabbajack.App.Extensions;
|
||||||
using System.Linq.Expressions;
|
|
||||||
using System.Reactive.Linq;
|
|
||||||
using ReactiveUI;
|
|
||||||
|
|
||||||
namespace Wabbajack.App.Extensions
|
public static class ReactiveUIExtensions
|
||||||
{
|
{
|
||||||
public static class ReactiveUIExtensions
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -7,16 +7,13 @@ using CefNet.Avalonia;
|
|||||||
using HtmlAgilityPack;
|
using HtmlAgilityPack;
|
||||||
using Wabbajack.DTOs.Logins;
|
using Wabbajack.DTOs.Logins;
|
||||||
|
|
||||||
namespace Wabbajack.App.Extensions
|
namespace Wabbajack.App.Extensions;
|
||||||
|
|
||||||
|
public static class WebViewExtensions
|
||||||
{
|
{
|
||||||
public static class WebViewExtensions
|
|
||||||
{
|
|
||||||
public static async Task WaitForReady(this WebView view)
|
public static async Task WaitForReady(this WebView view)
|
||||||
{
|
{
|
||||||
while (view.BrowserObject == null)
|
while (view.BrowserObject == null) await Task.Delay(200);
|
||||||
{
|
|
||||||
await Task.Delay(200);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -27,10 +24,7 @@ namespace Wabbajack.App.Extensions
|
|||||||
public static async Task NavigateTo(this WebView view, Uri uri)
|
public static async Task NavigateTo(this WebView view, Uri uri)
|
||||||
{
|
{
|
||||||
view.Navigate(uri.ToString());
|
view.Navigate(uri.ToString());
|
||||||
while (view.IsBusy)
|
while (view.IsBusy) await Task.Delay(200);
|
||||||
{
|
|
||||||
await Task.Delay(200);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<Cookie[]> Cookies(this WebView view, string domainEnding, CancellationToken token)
|
public static async Task<Cookie[]> Cookies(this WebView view, string domainEnding, CancellationToken token)
|
||||||
@ -42,7 +36,7 @@ namespace Wabbajack.App.Extensions
|
|||||||
Domain = c.Domain,
|
Domain = c.Domain,
|
||||||
Name = c.Name,
|
Name = c.Name,
|
||||||
Path = c.Path,
|
Path = c.Path,
|
||||||
Value = c.Value,
|
Value = c.Value
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,6 +52,4 @@ namespace Wabbajack.App.Extensions
|
|||||||
doc.LoadHtml(source);
|
doc.LoadHtml(source);
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -5,12 +5,10 @@ using Avalonia.Controls.Primitives;
|
|||||||
using Avalonia.Platform;
|
using Avalonia.Platform;
|
||||||
using Avalonia.Styling;
|
using Avalonia.Styling;
|
||||||
|
|
||||||
namespace Wabbajack.App
|
namespace Wabbajack.App;
|
||||||
{
|
|
||||||
public class FluentWindow : Window, IStyleable
|
|
||||||
{
|
|
||||||
Type IStyleable.StyleKey => typeof(Window);
|
|
||||||
|
|
||||||
|
public class FluentWindow : Window, IStyleable
|
||||||
|
{
|
||||||
public FluentWindow()
|
public FluentWindow()
|
||||||
{
|
{
|
||||||
ExtendClientAreaToDecorationsHint = true;
|
ExtendClientAreaToDecorationsHint = true;
|
||||||
@ -36,6 +34,8 @@ namespace Wabbajack.App
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Type IStyleable.StyleKey => typeof(Window);
|
||||||
|
|
||||||
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnApplyTemplate(e);
|
base.OnApplyTemplate(e);
|
||||||
@ -43,5 +43,4 @@ namespace Wabbajack.App
|
|||||||
ExtendClientAreaChromeHints.PreferSystemChrome |
|
ExtendClientAreaChromeHints.PreferSystemChrome |
|
||||||
ExtendClientAreaChromeHints.OSXThickTitleBar;
|
ExtendClientAreaChromeHints.OSXThickTitleBar;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,3 +1,3 @@
|
|||||||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||||
<ReactiveUI />
|
<ReactiveUI/>
|
||||||
</Weavers>
|
</Weavers>
|
@ -1,9 +1,8 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Wabbajack.App.Interfaces
|
namespace Wabbajack.App.Interfaces;
|
||||||
|
|
||||||
|
public interface INavigationParameter<T>
|
||||||
{
|
{
|
||||||
public interface INavigationParameter<T>
|
|
||||||
{
|
|
||||||
public Task NavigatedTo(T param);
|
public Task NavigatedTo(T param);
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,10 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Wabbajack.App.Interfaces
|
namespace Wabbajack.App.Interfaces;
|
||||||
{
|
|
||||||
public interface IScreenView
|
|
||||||
{
|
|
||||||
public Type ViewModelType { get; }
|
|
||||||
|
|
||||||
}
|
public interface IScreenView
|
||||||
|
{
|
||||||
|
public Type ViewModelType { get; }
|
||||||
}
|
}
|
@ -2,23 +2,21 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Wabbajack.App.Messages;
|
using Wabbajack.App.Messages;
|
||||||
|
|
||||||
namespace Wabbajack.App
|
namespace Wabbajack.App;
|
||||||
{
|
|
||||||
public interface IMessageBus
|
|
||||||
{
|
|
||||||
public void Send<T>(T message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MessageBus : IMessageBus
|
public interface IMessageBus
|
||||||
{
|
{
|
||||||
public static IMessageBus Instance { get; set; }
|
public void Send<T>(T message);
|
||||||
private readonly IReceiverMarker[] _receivers;
|
}
|
||||||
|
|
||||||
|
public class MessageBus : IMessageBus
|
||||||
|
{
|
||||||
private readonly ILogger<MessageBus> _logger;
|
private readonly ILogger<MessageBus> _logger;
|
||||||
|
private readonly IReceiverMarker[] _receivers;
|
||||||
|
|
||||||
public MessageBus(ILogger<MessageBus> logger, IEnumerable<IReceiverMarker> receivers)
|
public MessageBus(ILogger<MessageBus> logger, IEnumerable<IReceiverMarker> receivers)
|
||||||
{
|
{
|
||||||
@ -27,6 +25,8 @@ namespace Wabbajack.App
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IMessageBus Instance { get; set; }
|
||||||
|
|
||||||
public void Send<T>(T message)
|
public void Send<T>(T message)
|
||||||
{
|
{
|
||||||
AvaloniaScheduler.Instance.Schedule(message, TimeSpan.FromMilliseconds(200), (_, msg) =>
|
AvaloniaScheduler.Instance.Schedule(message, TimeSpan.FromMilliseconds(200), (_, msg) =>
|
||||||
@ -47,5 +47,4 @@ namespace Wabbajack.App
|
|||||||
return Disposable.Empty;
|
return Disposable.Empty;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,9 +1,7 @@
|
|||||||
using Wabbajack.Paths;
|
using Wabbajack.Paths;
|
||||||
|
|
||||||
namespace Wabbajack.App.Messages
|
namespace Wabbajack.App.Messages;
|
||||||
{
|
|
||||||
public record ConfigureLauncher(AbsolutePath InstallFolder)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
public record ConfigureLauncher(AbsolutePath InstallFolder)
|
||||||
|
{
|
||||||
}
|
}
|
@ -4,5 +4,4 @@ namespace Wabbajack.App.Messages;
|
|||||||
|
|
||||||
public record Error(string Prefix, Exception Exception)
|
public record Error(string Prefix, Exception Exception)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
namespace Wabbajack.App.Messages
|
namespace Wabbajack.App.Messages;
|
||||||
|
|
||||||
|
public interface IReceiverMarker
|
||||||
{
|
{
|
||||||
public interface IReceiverMarker
|
}
|
||||||
{
|
|
||||||
}
|
public interface IReceiver<in T> : IReceiverMarker
|
||||||
public interface IReceiver<in T> : IReceiverMarker
|
{
|
||||||
{
|
public void Receive(T val);
|
||||||
public void Receive(T val);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,10 +1,5 @@
|
|||||||
namespace Wabbajack.App.Messages
|
namespace Wabbajack.App.Messages;
|
||||||
{
|
|
||||||
public class NavigateBack
|
|
||||||
{
|
|
||||||
public NavigateBack()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
public class NavigateBack
|
||||||
}
|
{
|
||||||
}
|
}
|
@ -1,10 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Wabbajack.App.ViewModels;
|
|
||||||
|
|
||||||
namespace Wabbajack.App.Messages
|
namespace Wabbajack.App.Messages;
|
||||||
|
|
||||||
|
public record NavigateTo(Type ViewModel)
|
||||||
{
|
{
|
||||||
public record NavigateTo(Type ViewModel)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -4,5 +4,4 @@ namespace Wabbajack.App.Messages;
|
|||||||
|
|
||||||
public record StartCompilation(CompilerSettings Settings)
|
public record StartCompilation(CompilerSettings Settings)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
@ -1,8 +1,7 @@
|
|||||||
using Wabbajack.Paths;
|
using Wabbajack.Paths;
|
||||||
|
|
||||||
namespace Wabbajack.App.Messages
|
namespace Wabbajack.App.Messages;
|
||||||
|
|
||||||
|
public record StartInstallConfiguration(AbsolutePath ModList)
|
||||||
{
|
{
|
||||||
public record StartInstallConfiguration(AbsolutePath ModList)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
using Wabbajack.DTOs;
|
using Wabbajack.DTOs;
|
||||||
using Wabbajack.Paths;
|
using Wabbajack.Paths;
|
||||||
|
|
||||||
namespace Wabbajack.App.Messages
|
namespace Wabbajack.App.Messages;
|
||||||
|
|
||||||
|
public record StartInstallation(AbsolutePath ModListPath, AbsolutePath Install, AbsolutePath Download,
|
||||||
|
ModlistMetadata? Metadata)
|
||||||
{
|
{
|
||||||
public record StartInstallation(AbsolutePath ModListPath, AbsolutePath Install, AbsolutePath Download, ModlistMetadata? Metadata)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -8,11 +8,10 @@ using Wabbajack.DTOs.SavedSettings;
|
|||||||
using Wabbajack.Paths;
|
using Wabbajack.Paths;
|
||||||
using Wabbajack.Paths.IO;
|
using Wabbajack.Paths.IO;
|
||||||
|
|
||||||
namespace Wabbajack.App.Models
|
namespace Wabbajack.App.Models;
|
||||||
|
|
||||||
|
public class InstallationStateManager
|
||||||
{
|
{
|
||||||
public class InstallationStateManager
|
|
||||||
{
|
|
||||||
private static AbsolutePath Path => KnownFolders.WabbajackAppLocal.Combine("install-configuration-state.json");
|
|
||||||
private readonly DTOSerializer _dtos;
|
private readonly DTOSerializer _dtos;
|
||||||
private readonly ILogger<InstallationStateManager> _logger;
|
private readonly ILogger<InstallationStateManager> _logger;
|
||||||
|
|
||||||
@ -22,6 +21,8 @@ namespace Wabbajack.App.Models
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static AbsolutePath Path => KnownFolders.WabbajackAppLocal.Combine("install-configuration-state.json");
|
||||||
|
|
||||||
public async Task<InstallationConfigurationSetting> GetLastState()
|
public async Task<InstallationConfigurationSetting> GetLastState()
|
||||||
{
|
{
|
||||||
var state = await GetAll();
|
var state = await GetAll();
|
||||||
@ -66,7 +67,6 @@ namespace Wabbajack.App.Models
|
|||||||
_logger.LogError(ex, "While loading json");
|
_logger.LogError(ex, "While loading json");
|
||||||
return new InstallConfigurationState();
|
return new InstallConfigurationState();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<InstallationConfigurationSetting?> Get(AbsolutePath modListPath)
|
public async Task<InstallationConfigurationSetting?> Get(AbsolutePath modListPath)
|
||||||
@ -78,5 +78,4 @@ namespace Wabbajack.App.Models
|
|||||||
{
|
{
|
||||||
return (await GetAll()).Settings.FirstOrDefault(f => f.Install == folder);
|
return (await GetAll()).Settings.FirstOrDefault(f => f.Install == folder);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,10 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Reactive.Linq;
|
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using Wabbajack.App.ViewModels;
|
|
||||||
|
|
||||||
namespace Wabbajack.App.Models;
|
namespace Wabbajack.App.Models;
|
||||||
|
|
||||||
@ -12,12 +10,6 @@ public class LoadingLock : ReactiveObject, IDisposable
|
|||||||
{
|
{
|
||||||
private readonly CompositeDisposable _disposable;
|
private readonly CompositeDisposable _disposable;
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public int LoadLevel { get; private set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public bool IsLoading { get; private set; }
|
|
||||||
|
|
||||||
public LoadingLock()
|
public LoadingLock()
|
||||||
{
|
{
|
||||||
_disposable = new CompositeDisposable();
|
_disposable = new CompositeDisposable();
|
||||||
@ -25,21 +17,24 @@ public class LoadingLock : ReactiveObject, IDisposable
|
|||||||
this.WhenAnyValue(vm => vm.LoadLevel)
|
this.WhenAnyValue(vm => vm.LoadLevel)
|
||||||
.Subscribe(v => IsLoading = v > 0)
|
.Subscribe(v => IsLoading = v > 0)
|
||||||
.DisposeWith(_disposable);
|
.DisposeWith(_disposable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDisposable WithLoading()
|
[Reactive] public int LoadLevel { get; private set; }
|
||||||
{
|
|
||||||
Dispatcher.UIThread.Post(() => { LoadLevel++;}, DispatcherPriority.Background);
|
[Reactive] public bool IsLoading { get; private set; }
|
||||||
return Disposable.Create(() =>
|
|
||||||
{
|
|
||||||
Dispatcher.UIThread.Post(() => { LoadLevel--;}, DispatcherPriority.Background);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
_disposable.Dispose();
|
_disposable.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IDisposable WithLoading()
|
||||||
|
{
|
||||||
|
Dispatcher.UIThread.Post(() => { LoadLevel++; }, DispatcherPriority.Background);
|
||||||
|
return Disposable.Create(() =>
|
||||||
|
{
|
||||||
|
Dispatcher.UIThread.Post(() => { LoadLevel--; }, DispatcherPriority.Background);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
@ -3,7 +3,6 @@ using System.IO;
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Wabbajack.Common;
|
using Wabbajack.Common;
|
||||||
using Wabbajack.DTOs.JsonConverters;
|
using Wabbajack.DTOs.JsonConverters;
|
||||||
@ -26,7 +25,10 @@ public class SettingsManager
|
|||||||
_configuration.SavedSettingsLocation.CreateDirectory();
|
_configuration.SavedSettingsLocation.CreateDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
private AbsolutePath GetPath(string key) => _configuration.SavedSettingsLocation.Combine(key).WithExtension(Ext.Json);
|
private AbsolutePath GetPath(string key)
|
||||||
|
{
|
||||||
|
return _configuration.SavedSettingsLocation.Combine(key).WithExtension(Ext.Json);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task Save<T>(string key, T value)
|
public async Task Save<T>(string key, T value)
|
||||||
{
|
{
|
||||||
@ -35,6 +37,7 @@ public class SettingsManager
|
|||||||
{
|
{
|
||||||
await JsonSerializer.SerializeAsync(s, value, _dtos.Options);
|
await JsonSerializer.SerializeAsync(s, value, _dtos.Options);
|
||||||
}
|
}
|
||||||
|
|
||||||
await tmp.MoveToAsync(GetPath(key), true, CancellationToken.None);
|
await tmp.MoveToAsync(GetPath(key), true, CancellationToken.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,13 +48,11 @@ public class SettingsManager
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (path.FileExists())
|
if (path.FileExists())
|
||||||
{
|
|
||||||
await using (var s = path.Open(FileMode.Open))
|
await using (var s = path.Open(FileMode.Open))
|
||||||
{
|
{
|
||||||
return (await JsonSerializer.DeserializeAsync<T>(s, _dtos.Options))!;
|
return (await JsonSerializer.DeserializeAsync<T>(s, _dtos.Options))!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogWarning(ex, "Loading settings {Key}", key);
|
_logger.LogWarning(ex, "Loading settings {Key}", key);
|
||||||
|
@ -3,28 +3,31 @@ using Avalonia;
|
|||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
using CefNet;
|
using CefNet;
|
||||||
|
|
||||||
namespace Wabbajack.App
|
namespace Wabbajack.App;
|
||||||
{
|
|
||||||
|
|
||||||
class Program
|
internal class Program
|
||||||
{
|
{
|
||||||
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
||||||
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
||||||
// yet and stuff might break.
|
// yet and stuff might break.
|
||||||
[STAThread]
|
[STAThread]
|
||||||
public static void Main(string[] args) => BuildAvaloniaApp()
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
BuildAvaloniaApp()
|
||||||
.StartWithCefNetApplicationLifetime(args);
|
.StartWithCefNetApplicationLifetime(args);
|
||||||
|
}
|
||||||
|
|
||||||
// Avalonia configuration, don't remove; also used by visual designer.
|
// Avalonia configuration, don't remove; also used by visual designer.
|
||||||
public static AppBuilder BuildAvaloniaApp()
|
public static AppBuilder BuildAvaloniaApp()
|
||||||
=> AppBuilder.Configure<App>()
|
{
|
||||||
|
return AppBuilder.Configure<App>()
|
||||||
.UsePlatformDetect()
|
.UsePlatformDetect()
|
||||||
.AfterSetup(AfterSetupCallback)
|
.AfterSetup(AfterSetupCallback)
|
||||||
.LogToTrace()
|
.LogToTrace()
|
||||||
.UseReactiveUI();
|
.UseReactiveUI();
|
||||||
|
}
|
||||||
|
|
||||||
private static void AfterSetupCallback(AppBuilder obj)
|
private static void AfterSetupCallback(AppBuilder obj)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -54,7 +54,7 @@
|
|||||||
x:Name="OnlyInstalledCheckbox"
|
x:Name="OnlyInstalledCheckbox"
|
||||||
Margin="10,0,10,0"
|
Margin="10,0,10,0"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Content="Only Installed"/>
|
Content="Only Installed" />
|
||||||
<Button
|
<Button
|
||||||
x:Name="ClearFiltersButton"
|
x:Name="ClearFiltersButton"
|
||||||
Margin="0,0,10,0">
|
Margin="0,0,10,0">
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Wabbajack.App.ViewModels;
|
|
||||||
using Wabbajack.App.Views;
|
using Wabbajack.App.Views;
|
||||||
|
|
||||||
namespace Wabbajack.App.Screens
|
namespace Wabbajack.App.Screens;
|
||||||
|
|
||||||
|
public partial class BrowseView : ScreenBase<BrowseViewModel>
|
||||||
{
|
{
|
||||||
public partial class BrowseView : ScreenBase<BrowseViewModel>
|
|
||||||
{
|
|
||||||
public BrowseView()
|
public BrowseView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -40,5 +36,4 @@ namespace Wabbajack.App.Screens
|
|||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -8,74 +8,51 @@ using System.Reactive;
|
|||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Avalonia.Threading;
|
|
||||||
using DynamicData;
|
using DynamicData;
|
||||||
using DynamicData.Binding;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using Wabbajack.App.Controls;
|
using Wabbajack.App.Controls;
|
||||||
|
using Wabbajack.App.Models;
|
||||||
using Wabbajack.App.ViewModels;
|
using Wabbajack.App.ViewModels;
|
||||||
using Wabbajack.Common;
|
using Wabbajack.Common;
|
||||||
using Wabbajack.DTOs;
|
|
||||||
using Wabbajack.Networking.WabbajackClientApi;
|
|
||||||
using DynamicData.Binding;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Wabbajack.App.Models;
|
|
||||||
using Wabbajack.Downloaders;
|
using Wabbajack.Downloaders;
|
||||||
using Wabbajack.Downloaders.GameFile;
|
using Wabbajack.Downloaders.GameFile;
|
||||||
|
using Wabbajack.DTOs;
|
||||||
using Wabbajack.DTOs.JsonConverters;
|
using Wabbajack.DTOs.JsonConverters;
|
||||||
using Wabbajack.Installer;
|
using Wabbajack.Networking.WabbajackClientApi;
|
||||||
using Wabbajack.Paths;
|
using Wabbajack.Paths;
|
||||||
using Wabbajack.Paths.IO;
|
using Wabbajack.Paths.IO;
|
||||||
using Wabbajack.RateLimiter;
|
using Wabbajack.RateLimiter;
|
||||||
using Wabbajack.VFS;
|
using Wabbajack.VFS;
|
||||||
|
|
||||||
namespace Wabbajack.App.Screens
|
namespace Wabbajack.App.Screens;
|
||||||
|
|
||||||
|
public class BrowseViewModel : ViewModelBase, IActivatableViewModel
|
||||||
{
|
{
|
||||||
public class BrowseViewModel : ViewModelBase, IActivatableViewModel
|
|
||||||
{
|
|
||||||
private readonly Client _wjClient;
|
|
||||||
private readonly ILogger<BrowseViewModel> _logger;
|
|
||||||
private readonly HttpClient _httpClient;
|
|
||||||
private readonly IResource<HttpClient> _limiter;
|
|
||||||
private readonly FileHashCache _hashCache;
|
|
||||||
private readonly Configuration _configuration;
|
private readonly Configuration _configuration;
|
||||||
private readonly DownloadDispatcher _dispatcher;
|
private readonly DownloadDispatcher _dispatcher;
|
||||||
private readonly IResource<DownloadDispatcher> _dispatcherLimiter;
|
private readonly IResource<DownloadDispatcher> _dispatcherLimiter;
|
||||||
|
private readonly DTOSerializer _dtos;
|
||||||
private SourceCache<BrowseItemViewModel, string> _modLists = new(x => x.MachineURL);
|
public readonly ReadOnlyObservableCollection<GameSelectorItemViewModel> _filteredGamesList;
|
||||||
|
|
||||||
public readonly ReadOnlyObservableCollection<BrowseItemViewModel> _filteredModLists;
|
public readonly ReadOnlyObservableCollection<BrowseItemViewModel> _filteredModLists;
|
||||||
public ReadOnlyObservableCollection<BrowseItemViewModel> ModLists => _filteredModLists;
|
|
||||||
|
|
||||||
private SourceCache<GameSelectorItemViewModel, string> _gamesList = new(x => x.Name);
|
|
||||||
public readonly ReadOnlyObservableCollection<GameSelectorItemViewModel> _filteredGamesList;
|
|
||||||
private readonly GameLocator _gameLocator;
|
private readonly GameLocator _gameLocator;
|
||||||
private readonly DTOSerializer _dtos;
|
private readonly FileHashCache _hashCache;
|
||||||
public ReadOnlyObservableCollection<GameSelectorItemViewModel> GamesList => _filteredGamesList;
|
private readonly HttpClient _httpClient;
|
||||||
|
private readonly IResource<HttpClient> _limiter;
|
||||||
|
private readonly ILogger<BrowseViewModel> _logger;
|
||||||
|
private readonly Client _wjClient;
|
||||||
|
|
||||||
[Reactive]
|
private readonly SourceCache<GameSelectorItemViewModel, string> _gamesList = new(x => x.Name);
|
||||||
public GameSelectorItemViewModel? SelectedGame { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
private readonly SourceCache<BrowseItemViewModel, string> _modLists = new(x => x.MachineURL);
|
||||||
public string SearchText { get; set; }
|
|
||||||
|
|
||||||
[Reactive] public bool OnlyInstalledGames { get; set; } = false;
|
public BrowseViewModel(ILogger<BrowseViewModel> logger, Client wjClient, HttpClient httpClient,
|
||||||
|
IResource<HttpClient> limiter, FileHashCache hashCache,
|
||||||
[Reactive] public bool OnlyUtilityLists { get; set; } = false;
|
IResource<DownloadDispatcher> dispatcherLimiter, DownloadDispatcher dispatcher, GameLocator gameLocator,
|
||||||
|
DTOSerializer dtos, Configuration configuration)
|
||||||
[Reactive] public bool ShowNSFW { get; set; } = false;
|
|
||||||
|
|
||||||
[Reactive] public bool IsLoading { get; set; } = false;
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public LoadingLock LoadingLock { get; set; }
|
|
||||||
|
|
||||||
public BrowseViewModel(ILogger<BrowseViewModel> logger, Client wjClient, HttpClient httpClient, IResource<HttpClient> limiter, FileHashCache hashCache,
|
|
||||||
IResource<DownloadDispatcher> dispatcherLimiter, DownloadDispatcher dispatcher, GameLocator gameLocator, DTOSerializer dtos, Configuration configuration)
|
|
||||||
{
|
{
|
||||||
LoadingLock = new LoadingLock();
|
LoadingLock = new LoadingLock();
|
||||||
Activator = new ViewModelActivator();
|
Activator = new ViewModelActivator();
|
||||||
@ -91,7 +68,7 @@ namespace Wabbajack.App.Screens
|
|||||||
_dtos = dtos;
|
_dtos = dtos;
|
||||||
|
|
||||||
|
|
||||||
IObservable<Func<BrowseItemViewModel, bool>> searchTextPredicates = this.ObservableForProperty(vm => vm.SearchText)
|
var searchTextPredicates = this.ObservableForProperty(vm => vm.SearchText)
|
||||||
.Select(change => change.Value)
|
.Select(change => change.Value)
|
||||||
.StartWith("")
|
.StartWith("")
|
||||||
.Select<string, Func<BrowseItemViewModel, bool>>(txt =>
|
.Select<string, Func<BrowseItemViewModel, bool>>(txt =>
|
||||||
@ -102,14 +79,10 @@ namespace Wabbajack.App.Screens
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_gamesList.Edit(e =>
|
_gamesList.Edit(e =>
|
||||||
{
|
{
|
||||||
e.Clear();
|
e.Clear();
|
||||||
foreach (var game in GameRegistry.Games.Keys)
|
foreach (var game in GameRegistry.Games.Keys) e.AddOrUpdate(new GameSelectorItemViewModel(game));
|
||||||
{
|
|
||||||
e.AddOrUpdate(new GameSelectorItemViewModel(game));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
_gamesList.Connect()
|
_gamesList.Connect()
|
||||||
@ -118,7 +91,7 @@ namespace Wabbajack.App.Screens
|
|||||||
.Bind(out _filteredGamesList)
|
.Bind(out _filteredGamesList)
|
||||||
.Subscribe();
|
.Subscribe();
|
||||||
|
|
||||||
IObservable<Func<BrowseItemViewModel, bool>> gameFilter = this.ObservableForProperty(vm => vm.SelectedGame)
|
var gameFilter = this.ObservableForProperty(vm => vm.SelectedGame)
|
||||||
.Select(v => v.Value)
|
.Select(v => v.Value)
|
||||||
.Select<GameSelectorItemViewModel?, Func<BrowseItemViewModel, bool>>(selected =>
|
.Select<GameSelectorItemViewModel?, Func<BrowseItemViewModel, bool>>(selected =>
|
||||||
{
|
{
|
||||||
@ -127,7 +100,7 @@ namespace Wabbajack.App.Screens
|
|||||||
})
|
})
|
||||||
.StartWith(_ => true);
|
.StartWith(_ => true);
|
||||||
|
|
||||||
IObservable<Func<BrowseItemViewModel, bool>> onlyInstalledGamesFilter = this.ObservableForProperty(vm => vm.OnlyInstalledGames)
|
var onlyInstalledGamesFilter = this.ObservableForProperty(vm => vm.OnlyInstalledGames)
|
||||||
.Select(v => v.Value)
|
.Select(v => v.Value)
|
||||||
.Select<bool, Func<BrowseItemViewModel, bool>>(onlyInstalled =>
|
.Select<bool, Func<BrowseItemViewModel, bool>>(onlyInstalled =>
|
||||||
{
|
{
|
||||||
@ -136,25 +109,21 @@ namespace Wabbajack.App.Screens
|
|||||||
})
|
})
|
||||||
.StartWith(_ => true);
|
.StartWith(_ => true);
|
||||||
|
|
||||||
IObservable<Func<BrowseItemViewModel, bool>> onlyUtilityListsFilter = this.ObservableForProperty(vm => vm.OnlyUtilityLists)
|
var onlyUtilityListsFilter = this.ObservableForProperty(vm => vm.OnlyUtilityLists)
|
||||||
.Select(v => v.Value)
|
.Select(v => v.Value)
|
||||||
.Select<bool, Func<BrowseItemViewModel, bool>>(utility =>
|
.Select<bool, Func<BrowseItemViewModel, bool>>(utility =>
|
||||||
{
|
{
|
||||||
if (utility == false) return item => item.IsUtilityList == false ;
|
if (utility == false) return item => item.IsUtilityList == false;
|
||||||
return item => item.IsUtilityList;
|
return item => item.IsUtilityList;
|
||||||
})
|
})
|
||||||
.StartWith(item => item.IsUtilityList == false);
|
.StartWith(item => item.IsUtilityList == false);
|
||||||
|
|
||||||
IObservable<Func<BrowseItemViewModel, bool>> showNSFWFilter = this.ObservableForProperty(vm => vm.ShowNSFW)
|
var showNSFWFilter = this.ObservableForProperty(vm => vm.ShowNSFW)
|
||||||
.Select(v => v.Value)
|
.Select(v => v.Value)
|
||||||
.Select<bool, Func<BrowseItemViewModel, bool>>(showNSFW =>
|
.Select<bool, Func<BrowseItemViewModel, bool>>(showNSFW => { return item => item.IsNSFW == showNSFW; })
|
||||||
{
|
|
||||||
return item => item.IsNSFW == showNSFW;
|
|
||||||
})
|
|
||||||
.StartWith(item => item.IsNSFW == false);
|
.StartWith(item => item.IsNSFW == false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_modLists.Connect()
|
_modLists.Connect()
|
||||||
.ObserveOn(RxApp.MainThreadScheduler)
|
.ObserveOn(RxApp.MainThreadScheduler)
|
||||||
.Filter(searchTextPredicates)
|
.Filter(searchTextPredicates)
|
||||||
@ -177,10 +146,7 @@ namespace Wabbajack.App.Screens
|
|||||||
LoadSettings().FireAndForget();
|
LoadSettings().FireAndForget();
|
||||||
LoadData().FireAndForget();
|
LoadData().FireAndForget();
|
||||||
|
|
||||||
Disposable.Create(() =>
|
Disposable.Create(() => { SaveSettings().FireAndForget(); }).DisposeWith(disposables);
|
||||||
{
|
|
||||||
SaveSettings().FireAndForget();
|
|
||||||
}).DisposeWith(disposables);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
var searchTextFilter = this.ObservableForProperty(view => view.SearchText)
|
var searchTextFilter = this.ObservableForProperty(view => view.SearchText)
|
||||||
@ -190,13 +156,30 @@ namespace Wabbajack.App.Screens
|
|||||||
return lst => true;
|
return lst => true;
|
||||||
return
|
return
|
||||||
})*/
|
})*/
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ReadOnlyObservableCollection<BrowseItemViewModel> ModLists => _filteredModLists;
|
||||||
|
public ReadOnlyObservableCollection<GameSelectorItemViewModel> GamesList => _filteredGamesList;
|
||||||
|
|
||||||
[Reactive]
|
[Reactive] public GameSelectorItemViewModel? SelectedGame { get; set; }
|
||||||
public ReactiveCommand<Unit, Unit> ResetFiltersCommand { get; set; }
|
|
||||||
|
[Reactive] public string SearchText { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public bool OnlyInstalledGames { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public bool OnlyUtilityLists { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public bool ShowNSFW { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public bool IsLoading { get; set; } = false;
|
||||||
|
|
||||||
|
[Reactive] public LoadingLock LoadingLock { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
[Reactive] public ReactiveCommand<Unit, Unit> ResetFiltersCommand { get; set; }
|
||||||
|
|
||||||
|
private AbsolutePath SavedSettingsLocation => _configuration.SavedSettingsLocation.Combine("browse_view.json");
|
||||||
|
|
||||||
private async Task LoadData()
|
private async Task LoadData()
|
||||||
{
|
{
|
||||||
@ -205,12 +188,10 @@ namespace Wabbajack.App.Screens
|
|||||||
var summaries = (await _wjClient.GetListStatuses()).ToDictionary(m => m.MachineURL);
|
var summaries = (await _wjClient.GetListStatuses()).ToDictionary(m => m.MachineURL);
|
||||||
var vms = modlists.Select(m =>
|
var vms = modlists.Select(m =>
|
||||||
{
|
{
|
||||||
if (!summaries.TryGetValue(m.Links.MachineURL, out var summary))
|
if (!summaries.TryGetValue(m.Links.MachineURL, out var summary)) summary = new ModListSummary();
|
||||||
{
|
|
||||||
summary = new ModListSummary();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new BrowseItemViewModel(m, summary, _httpClient, _limiter, _hashCache, _configuration, _dispatcher, _dispatcherLimiter, _gameLocator, _dtos, _logger);
|
return new BrowseItemViewModel(m, summary, _httpClient, _limiter, _hashCache, _configuration, _dispatcher,
|
||||||
|
_dispatcherLimiter, _gameLocator, _dtos, _logger);
|
||||||
});
|
});
|
||||||
|
|
||||||
_modLists.Edit(lsts =>
|
_modLists.Edit(lsts =>
|
||||||
@ -233,7 +214,9 @@ namespace Wabbajack.App.Screens
|
|||||||
var data = (await JsonSerializer.DeserializeAsync<SavedSettings>(stream))!;
|
var data = (await JsonSerializer.DeserializeAsync<SavedSettings>(stream))!;
|
||||||
SearchText = data.SearchText;
|
SearchText = data.SearchText;
|
||||||
|
|
||||||
SelectedGame = data.SelectedGame == null ? null : _gamesList.Lookup(data.SelectedGame.Value.MetaData().HumanFriendlyGameName).Value;
|
SelectedGame = data.SelectedGame == null
|
||||||
|
? null
|
||||||
|
: _gamesList.Lookup(data.SelectedGame.Value.MetaData().HumanFriendlyGameName).Value;
|
||||||
|
|
||||||
ShowNSFW = data.ShowNSFW;
|
ShowNSFW = data.ShowNSFW;
|
||||||
OnlyUtilityLists = data.OnlyUtility;
|
OnlyUtilityLists = data.OnlyUtility;
|
||||||
@ -268,8 +251,6 @@ namespace Wabbajack.App.Screens
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private AbsolutePath SavedSettingsLocation => _configuration.SavedSettingsLocation.Combine("browse_view.json");
|
|
||||||
|
|
||||||
private class SavedSettings
|
private class SavedSettings
|
||||||
{
|
{
|
||||||
public string SearchText { get; set; }
|
public string SearchText { get; set; }
|
||||||
@ -278,5 +259,4 @@ namespace Wabbajack.App.Screens
|
|||||||
public bool OnlyInstalled { get; set; }
|
public bool OnlyInstalled { get; set; }
|
||||||
public Game? SelectedGame { get; set; }
|
public Game? SelectedGame { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -3,13 +3,12 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
xmlns:i="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
|
||||||
xmlns:controls="clr-namespace:Wabbajack.App.Controls"
|
xmlns:controls="clr-namespace:Wabbajack.App.Controls"
|
||||||
x:Class="Wabbajack.App.Screens.CompilationView">
|
x:Class="Wabbajack.App.Screens.CompilationView">
|
||||||
<Grid RowDefinitions="40, 5, 5, *, 40">
|
<Grid RowDefinitions="40, 5, 5, *, 40">
|
||||||
<TextBlock Grid.Row="0" x:Name="StatusText" FontSize="20" FontWeight="Bold">[20/30] Installing Files</TextBlock>
|
<TextBlock Grid.Row="0" x:Name="StatusText" FontSize="20" FontWeight="Bold">[20/30] Installing Files</TextBlock>
|
||||||
<ProgressBar Grid.Row="1" x:Name="StepsProgress" Maximum="1000" Value="40"></ProgressBar>
|
<ProgressBar Grid.Row="1" x:Name="StepsProgress" Maximum="1000" Value="40" />
|
||||||
<ProgressBar Grid.Row="2" x:Name="StepProgress" Maximum="10000" Value="30"></ProgressBar>
|
<ProgressBar Grid.Row="2" x:Name="StepProgress" Maximum="10000" Value="30" />
|
||||||
<controls:LogView Grid.Row="3" x:Name="LogView"></controls:LogView>
|
<controls:LogView Grid.Row="3" x:Name="LogView" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
@ -1,6 +1,5 @@
|
|||||||
using Avalonia.Controls.Mixins;
|
using Avalonia.Controls.Mixins;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Wabbajack.App.ViewModels;
|
|
||||||
using Wabbajack.App.Views;
|
using Wabbajack.App.Views;
|
||||||
|
|
||||||
namespace Wabbajack.App.Screens;
|
namespace Wabbajack.App.Screens;
|
||||||
|
@ -16,13 +16,9 @@ namespace Wabbajack.App.Screens;
|
|||||||
|
|
||||||
public class CompilationViewModel : ViewModelBase, IReceiverMarker, IReceiver<StartCompilation>
|
public class CompilationViewModel : ViewModelBase, IReceiverMarker, IReceiver<StartCompilation>
|
||||||
{
|
{
|
||||||
|
private readonly ILogger<CompilationViewModel> _logger;
|
||||||
private readonly IServiceProvider _provider;
|
private readonly IServiceProvider _provider;
|
||||||
private ACompiler _compiler;
|
private ACompiler _compiler;
|
||||||
private readonly ILogger<CompilationViewModel> _logger;
|
|
||||||
|
|
||||||
[Reactive] public string StatusText { get; set; } = "";
|
|
||||||
[Reactive] public Percent StepsProgress { get; set; } = Percent.Zero;
|
|
||||||
[Reactive] public Percent StepProgress { get; set; } = Percent.Zero;
|
|
||||||
|
|
||||||
|
|
||||||
public CompilationViewModel(ILogger<CompilationViewModel> logger, IServiceProvider provider)
|
public CompilationViewModel(ILogger<CompilationViewModel> logger, IServiceProvider provider)
|
||||||
@ -30,9 +26,12 @@ public class CompilationViewModel : ViewModelBase, IReceiverMarker, IReceiver<St
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
_provider = provider;
|
_provider = provider;
|
||||||
Activator = new ViewModelActivator();
|
Activator = new ViewModelActivator();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Reactive] public string StatusText { get; set; } = "";
|
||||||
|
[Reactive] public Percent StepsProgress { get; set; } = Percent.Zero;
|
||||||
|
[Reactive] public Percent StepProgress { get; set; } = Percent.Zero;
|
||||||
|
|
||||||
public void Receive(StartCompilation val)
|
public void Receive(StartCompilation val)
|
||||||
{
|
{
|
||||||
if (val.Settings is MO2CompilerSettings mo2)
|
if (val.Settings is MO2CompilerSettings mo2)
|
||||||
@ -50,6 +49,7 @@ public class CompilationViewModel : ViewModelBase, IReceiverMarker, IReceiver<St
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Compile().FireAndForget();
|
Compile().FireAndForget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,42 +8,42 @@
|
|||||||
x:Class="Wabbajack.App.Screens.CompilerConfigurationView">
|
x:Class="Wabbajack.App.Screens.CompilerConfigurationView">
|
||||||
<Grid RowDefinitions="40, *, 40">
|
<Grid RowDefinitions="40, *, 40">
|
||||||
<TextBlock Grid.Row="0" x:Name="StatusText" FontSize="20" FontWeight="Bold">Compiler Configuration</TextBlock>
|
<TextBlock Grid.Row="0" x:Name="StatusText" FontSize="20" FontWeight="Bold">Compiler Configuration</TextBlock>
|
||||||
<Grid Grid.Row="1" ColumnDefinitions="Auto, *" RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto, Auto" Margin="4">
|
<Grid Grid.Row="1" ColumnDefinitions="Auto, *" RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto, Auto"
|
||||||
|
Margin="4">
|
||||||
<Label Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right">Title:</Label>
|
<Label Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right">Title:</Label>
|
||||||
<TextBox Grid.Column="1" Grid.Row="0" x:Name="Title"></TextBox>
|
<TextBox Grid.Column="1" Grid.Row="0" x:Name="Title" />
|
||||||
<Label Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right">Settings File:</Label>
|
<Label Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right">Settings File:</Label>
|
||||||
<controls:FileSelectionBox Grid.Column="1" Grid.Row="1" x:Name="SettingsFile"
|
<controls:FileSelectionBox Grid.Column="1" Grid.Row="1" x:Name="SettingsFile"
|
||||||
AllowedExtensions=".txt|.json">
|
AllowedExtensions=".txt|.json" />
|
||||||
</controls:FileSelectionBox>
|
|
||||||
<Label Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right">Source:</Label>
|
<Label Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right">Source:</Label>
|
||||||
<controls:FileSelectionBox Grid.Column="1" Grid.Row="2" x:Name="Source" SelectFolder="True"></controls:FileSelectionBox>
|
<controls:FileSelectionBox Grid.Column="1" Grid.Row="2" x:Name="Source" SelectFolder="True" />
|
||||||
<Label Grid.Column="0" Grid.Row="3" HorizontalAlignment="Right">Downloads Folder:</Label>
|
<Label Grid.Column="0" Grid.Row="3" HorizontalAlignment="Right">Downloads Folder:</Label>
|
||||||
<controls:FileSelectionBox Grid.Column="1" Grid.Row="3" x:Name="DownloadsFolder" SelectFolder="True"></controls:FileSelectionBox>
|
<controls:FileSelectionBox Grid.Column="1" Grid.Row="3" x:Name="DownloadsFolder" SelectFolder="True" />
|
||||||
<Label Grid.Column="0" Grid.Row="4" HorizontalAlignment="Right">Base Game:</Label>
|
<Label Grid.Column="0" Grid.Row="4" HorizontalAlignment="Right">Base Game:</Label>
|
||||||
<ComboBox Grid.Column="1" Grid.Row="4" x:Name="BaseGame">
|
<ComboBox Grid.Column="1" Grid.Row="4" x:Name="BaseGame">
|
||||||
<ComboBox.ItemTemplate>
|
<ComboBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<TextBlock Text="{Binding Path=HumanFriendlyGameName}"></TextBlock>
|
<TextBlock Text="{Binding Path=HumanFriendlyGameName}" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ComboBox.ItemTemplate>
|
</ComboBox.ItemTemplate>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
<Label Grid.Column="0" Grid.Row="5" HorizontalAlignment="Right">Output Folder:</Label>
|
<Label Grid.Column="0" Grid.Row="5" HorizontalAlignment="Right">Output Folder:</Label>
|
||||||
<controls:FileSelectionBox Grid.Column="1" Grid.Row="5" x:Name="OutputFolder" SelectFolder="True"></controls:FileSelectionBox>
|
<controls:FileSelectionBox Grid.Column="1" Grid.Row="5" x:Name="OutputFolder" SelectFolder="True" />
|
||||||
|
|
||||||
<Label Grid.Column="0" Grid.Row="6" HorizontalAlignment="Right" VerticalAlignment="Top">Always Enabled:</Label>
|
<Label Grid.Column="0" Grid.Row="6" HorizontalAlignment="Right" VerticalAlignment="Top">Always Enabled:</Label>
|
||||||
<StackPanel Grid.Column="1" Grid.Row="6" Orientation="Vertical">
|
<StackPanel Grid.Column="1" Grid.Row="6" Orientation="Vertical">
|
||||||
<Button x:Name="AddAlwaysEnabled">
|
<Button x:Name="AddAlwaysEnabled">
|
||||||
<i:MaterialIcon Kind="AddCircle"></i:MaterialIcon>
|
<i:MaterialIcon Kind="AddCircle" />
|
||||||
</Button>
|
</Button>
|
||||||
<ItemsControl x:Name="AlwaysEnabledList">
|
<ItemsControl x:Name="AlwaysEnabledList">
|
||||||
<ItemsControl.ItemsPanel>
|
<ItemsControl.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<StackPanel Orientation="Vertical"></StackPanel>
|
<StackPanel Orientation="Vertical" />
|
||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
</ItemsControl.ItemsPanel>
|
</ItemsControl.ItemsPanel>
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<controls:RemovableListItem></controls:RemovableListItem>
|
<controls:RemovableListItem />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ItemsControl.ItemTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
|
@ -2,7 +2,6 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
@ -12,10 +11,10 @@ using Wabbajack.App.Views;
|
|||||||
using Wabbajack.Common;
|
using Wabbajack.Common;
|
||||||
using Wabbajack.Paths;
|
using Wabbajack.Paths;
|
||||||
|
|
||||||
namespace Wabbajack.App.Screens
|
namespace Wabbajack.App.Screens;
|
||||||
|
|
||||||
|
public partial class CompilerConfigurationView : ScreenBase<CompilerConfigurationViewModel>
|
||||||
{
|
{
|
||||||
public partial class CompilerConfigurationView : ScreenBase<CompilerConfigurationViewModel>
|
|
||||||
{
|
|
||||||
public CompilerConfigurationView()
|
public CompilerConfigurationView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -51,7 +50,7 @@ namespace Wabbajack.App.Screens
|
|||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
this.OneWayBind(ViewModel, vm => vm.AlwaysEnabled, view => view.AlwaysEnabledList.Items,
|
this.OneWayBind(ViewModel, vm => vm.AlwaysEnabled, view => view.AlwaysEnabledList.Items,
|
||||||
d => d!.Select(itm => new RemovableItemViewModel()
|
d => d!.Select(itm => new RemovableItemViewModel
|
||||||
{
|
{
|
||||||
Text = itm.ToString(),
|
Text = itm.ToString(),
|
||||||
DeleteCommand = ReactiveCommand.Create(() => { ViewModel?.RemoveAlwaysExcluded(itm); })
|
DeleteCommand = ReactiveCommand.Create(() => { ViewModel?.RemoveAlwaysExcluded(itm); })
|
||||||
@ -62,9 +61,9 @@ namespace Wabbajack.App.Screens
|
|||||||
|
|
||||||
private async Task AddAlwaysEnabled_Command()
|
private async Task AddAlwaysEnabled_Command()
|
||||||
{
|
{
|
||||||
var dialog = new OpenFolderDialog()
|
var dialog = new OpenFolderDialog
|
||||||
{
|
{
|
||||||
Title = "Select a folder",
|
Title = "Select a folder"
|
||||||
};
|
};
|
||||||
var result = await dialog.ShowAsync(App.MainWindow);
|
var result = await dialog.ShowAsync(App.MainWindow);
|
||||||
if (!string.IsNullOrWhiteSpace(result))
|
if (!string.IsNullOrWhiteSpace(result))
|
||||||
@ -75,16 +74,16 @@ namespace Wabbajack.App.Screens
|
|||||||
{
|
{
|
||||||
Dispatcher.UIThread.InvokeAsync(async () =>
|
Dispatcher.UIThread.InvokeAsync(async () =>
|
||||||
{
|
{
|
||||||
var dialog = new OpenFileDialog()
|
var dialog = new OpenFileDialog
|
||||||
{
|
{
|
||||||
Title = "Select a modlist.txt file",
|
Title = "Select a modlist.txt file",
|
||||||
Filters = new List<FileDialogFilter> { new() {Extensions = new List<string> {"txt"}, Name = "modlist.txt"}},
|
Filters = new List<FileDialogFilter>
|
||||||
|
{new() {Extensions = new List<string> {"txt"}, Name = "modlist.txt"}},
|
||||||
AllowMultiple = false
|
AllowMultiple = false
|
||||||
};
|
};
|
||||||
var result = await dialog.ShowAsync(App.MainWindow);
|
var result = await dialog.ShowAsync(App.MainWindow);
|
||||||
if (result is { Length: > 0 })
|
if (result is {Length: > 0})
|
||||||
await ViewModel!.InferSettingsFromModlistTxt(result.First().ToAbsolutePath());
|
await ViewModel!.InferSettingsFromModlistTxt(result.First().ToAbsolutePath());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -27,44 +27,6 @@ public class CompilerConfigurationViewModel : ViewModelBase, IReceiverMarker
|
|||||||
private readonly DTOSerializer _dtos;
|
private readonly DTOSerializer _dtos;
|
||||||
private readonly SettingsManager _settingsManager;
|
private readonly SettingsManager _settingsManager;
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public string Title { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public AbsolutePath SettingsFile { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public AbsolutePath Downloads { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public GameMetaData BaseGame { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public AbsolutePath Source { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public AbsolutePath GamePath { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public string SelectedProfile { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public AbsolutePath OutputFolder { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public IEnumerable<GameMetaData> AllGames { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public ReactiveCommand<Unit, Unit> StartCompilation { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public IEnumerable<RelativePath> AlwaysEnabled { get; set; } = Array.Empty<RelativePath>();
|
|
||||||
|
|
||||||
public AbsolutePath SettingsOutputLocation => Source.Combine(Title).WithExtension(IsMO2Compilation ? Ext.MO2CompilerSettings : Ext.CompilerSettings);
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public bool IsMO2Compilation { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
public CompilerConfigurationViewModel(DTOSerializer dtos, SettingsManager settingsManager)
|
public CompilerConfigurationViewModel(DTOSerializer dtos, SettingsManager settingsManager)
|
||||||
{
|
{
|
||||||
@ -82,15 +44,38 @@ public class CompilerConfigurationViewModel : ViewModelBase, IReceiverMarker
|
|||||||
{
|
{
|
||||||
LoadLastCompilation().FireAndForget();
|
LoadLastCompilation().FireAndForget();
|
||||||
this.WhenAnyValue(v => v.SettingsFile)
|
this.WhenAnyValue(v => v.SettingsFile)
|
||||||
.Subscribe( location =>
|
.Subscribe(location => { LoadNewSettingsFile(location).FireAndForget(); })
|
||||||
{
|
|
||||||
LoadNewSettingsFile(location).FireAndForget();
|
|
||||||
})
|
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Reactive] public string Title { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public AbsolutePath SettingsFile { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public AbsolutePath Downloads { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public GameMetaData BaseGame { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public AbsolutePath Source { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public AbsolutePath GamePath { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public string SelectedProfile { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public AbsolutePath OutputFolder { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public IEnumerable<GameMetaData> AllGames { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public ReactiveCommand<Unit, Unit> StartCompilation { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public IEnumerable<RelativePath> AlwaysEnabled { get; set; } = Array.Empty<RelativePath>();
|
||||||
|
|
||||||
|
public AbsolutePath SettingsOutputLocation => Source.Combine(Title)
|
||||||
|
.WithExtension(IsMO2Compilation ? Ext.MO2CompilerSettings : Ext.CompilerSettings);
|
||||||
|
|
||||||
|
[Reactive] public bool IsMO2Compilation { get; set; }
|
||||||
|
|
||||||
private async Task LoadNewSettingsFile(AbsolutePath location)
|
private async Task LoadNewSettingsFile(AbsolutePath location)
|
||||||
{
|
{
|
||||||
if (location == default) return;
|
if (location == default) return;
|
||||||
@ -174,19 +159,15 @@ public class CompilerConfigurationViewModel : ViewModelBase, IReceiverMarker
|
|||||||
var generalModData = data["General"];
|
var generalModData = data["General"];
|
||||||
if ((generalModData["notes"]?.Contains("WABBAJACK_ALWAYS_ENABLE") ?? false) ||
|
if ((generalModData["notes"]?.Contains("WABBAJACK_ALWAYS_ENABLE") ?? false) ||
|
||||||
(generalModData["comments"]?.Contains("WABBAJACK_ALWAYS_ENABLE") ?? false))
|
(generalModData["comments"]?.Contains("WABBAJACK_ALWAYS_ENABLE") ?? false))
|
||||||
{
|
|
||||||
AlwaysEnabled = AlwaysEnabled.Append(modFolder.RelativeTo(mo2Folder)).ToArray();
|
AlwaysEnabled = AlwaysEnabled.Append(modFolder.RelativeTo(mo2Folder)).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mo2Folder.Depth > 1)
|
if (mo2Folder.Depth > 1)
|
||||||
OutputFolder = mo2Folder.Parent;
|
OutputFolder = mo2Folder.Parent;
|
||||||
|
|
||||||
await SaveSettingsFile();
|
await SaveSettingsFile();
|
||||||
SettingsFile = SettingsOutputLocation;
|
SettingsFile = SettingsOutputLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +175,7 @@ public class CompilerConfigurationViewModel : ViewModelBase, IReceiverMarker
|
|||||||
{
|
{
|
||||||
await using var st = SettingsOutputLocation.Open(FileMode.Create, FileAccess.Write, FileShare.None);
|
await using var st = SettingsOutputLocation.Open(FileMode.Create, FileAccess.Write, FileShare.None);
|
||||||
if (IsMO2Compilation)
|
if (IsMO2Compilation)
|
||||||
await JsonSerializer.SerializeAsync(st, (MO2CompilerSettings)GetSettings(), _dtos.Options);
|
await JsonSerializer.SerializeAsync(st, (MO2CompilerSettings) GetSettings(), _dtos.Options);
|
||||||
else
|
else
|
||||||
await JsonSerializer.SerializeAsync(st, GetSettings(), _dtos.Options);
|
await JsonSerializer.SerializeAsync(st, GetSettings(), _dtos.Options);
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Wabbajack.App.Screens.ErrorPageView">
|
x:Class="Wabbajack.App.Screens.ErrorPageView">
|
||||||
<Grid RowDefinitions="Auto, Auto, *">
|
<Grid RowDefinitions="Auto, Auto, *">
|
||||||
<TextBlock Grid.Row="0" x:Name="Prefix"></TextBlock>
|
<TextBlock Grid.Row="0" x:Name="Prefix" />
|
||||||
<TextBlock Grid.Row="1" x:Name="Message"></TextBlock>
|
<TextBlock Grid.Row="1" x:Name="Message" />
|
||||||
<controls:LogView Grid.Row="3"></controls:LogView>
|
<controls:LogView Grid.Row="3" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
@ -1,24 +1,22 @@
|
|||||||
using System;
|
using System;
|
||||||
using DynamicData.Kernel;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using Wabbajack.App.Messages;
|
using Wabbajack.App.Messages;
|
||||||
using Wabbajack.App.ViewModels;
|
using Wabbajack.App.ViewModels;
|
||||||
|
|
||||||
namespace Wabbajack.App.Screens
|
namespace Wabbajack.App.Screens;
|
||||||
|
|
||||||
|
public class ErrorPageViewModel : ViewModelBase, IActivatableViewModel, IReceiver<Error>
|
||||||
{
|
{
|
||||||
public class ErrorPageViewModel : ViewModelBase, IActivatableViewModel, IReceiver<Error>
|
|
||||||
{
|
|
||||||
[Reactive]
|
|
||||||
public string ShortMessage { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public string Prefix { get; set; }
|
|
||||||
|
|
||||||
public ErrorPageViewModel()
|
public ErrorPageViewModel()
|
||||||
{
|
{
|
||||||
Activator = new ViewModelActivator();
|
Activator = new ViewModelActivator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Reactive] public string ShortMessage { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public string Prefix { get; set; }
|
||||||
|
|
||||||
public void Receive(Error val)
|
public void Receive(Error val)
|
||||||
{
|
{
|
||||||
Prefix = val.Prefix;
|
Prefix = val.Prefix;
|
||||||
@ -30,5 +28,4 @@ namespace Wabbajack.App.Screens
|
|||||||
MessageBus.Instance.Send(new Error(prefix, ex));
|
MessageBus.Instance.Send(new Error(prefix, ex));
|
||||||
MessageBus.Instance.Send(new NavigateTo(typeof(ErrorPageViewModel)));
|
MessageBus.Instance.Send(new NavigateTo(typeof(ErrorPageViewModel)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -14,14 +14,14 @@
|
|||||||
<Image x:Name="ModListImage" Margin="0,0,0,0" Source="../Assets/Wabba_Mouth.png" />
|
<Image x:Name="ModListImage" Margin="0,0,0,0" Source="../Assets/Wabba_Mouth.png" />
|
||||||
</Viewbox>
|
</Viewbox>
|
||||||
<Grid Grid.Row="0" RowDefinitions="40, 40" HorizontalAlignment="Left" VerticalAlignment="Bottom">
|
<Grid Grid.Row="0" RowDefinitions="40, 40" HorizontalAlignment="Left" VerticalAlignment="Bottom">
|
||||||
<TextBlock x:Name="ModListName"></TextBlock>
|
<TextBlock x:Name="ModListName" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Margin="40" RowDefinitions="40, 40, 40, *" ColumnDefinitions="100, *, 200" Grid.Row="1">
|
<Grid Margin="40" RowDefinitions="40, 40, 40, *" ColumnDefinitions="100, *, 200" Grid.Row="1">
|
||||||
<Label Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Center">ModList:</Label>
|
<Label Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Center">ModList:</Label>
|
||||||
<TextBox Grid.Column="1" Grid.Row="0" IsEnabled="False" Height="20" x:Name="ModList"></TextBox>
|
<TextBox Grid.Column="1" Grid.Row="0" IsEnabled="False" Height="20" x:Name="ModList" />
|
||||||
|
|
||||||
<Label Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center">Location:</Label>
|
<Label Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center">Location:</Label>
|
||||||
<TextBox Grid.Column="1" Grid.Row="1" IsEnabled="False" Height="20" x:Name="InstallPath"></TextBox>
|
<TextBox Grid.Column="1" Grid.Row="1" IsEnabled="False" Height="20" x:Name="InstallPath" />
|
||||||
|
|
||||||
<Grid Grid.Column="1" Grid.Row="3" Grid.ColumnDefinitions="*, *, *" HorizontalAlignment="Center">
|
<Grid Grid.Column="1" Grid.Row="3" Grid.ColumnDefinitions="*, *, *" HorizontalAlignment="Center">
|
||||||
<Button Grid.Column="0" x:Name="WebsiteButton">Website</Button>
|
<Button Grid.Column="0" x:Name="WebsiteButton">Website</Button>
|
||||||
@ -29,9 +29,8 @@
|
|||||||
<Button Grid.Column="2" x:Name="LocalFilesButton">Local Files</Button>
|
<Button Grid.Column="2" x:Name="LocalFilesButton">Local Files</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<controls:LargeIconButton x:Name="PlayGame" Margin="40, 0, 0, 0" Grid.Row="0" Grid.Column="2" Grid.RowSpan="4" Icon="PlayCircle" Text="Play">
|
<controls:LargeIconButton x:Name="PlayGame" Margin="40, 0, 0, 0" Grid.Row="0" Grid.Column="2"
|
||||||
|
Grid.RowSpan="4" Icon="PlayCircle" Text="Play" />
|
||||||
</controls:LargeIconButton>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
@ -1,14 +1,11 @@
|
|||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Wabbajack.App.Views;
|
using Wabbajack.App.Views;
|
||||||
|
|
||||||
namespace Wabbajack.App.Screens
|
namespace Wabbajack.App.Screens;
|
||||||
|
|
||||||
|
public partial class LauncherView : ScreenBase<LauncherViewModel>
|
||||||
{
|
{
|
||||||
public partial class LauncherView : ScreenBase<LauncherViewModel>
|
|
||||||
{
|
|
||||||
public LauncherView()
|
public LauncherView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -28,6 +25,4 @@ namespace Wabbajack.App.Screens
|
|||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -5,8 +5,6 @@ using System.Reactive.Disposables;
|
|||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Avalonia.Media.Imaging;
|
using Avalonia.Media.Imaging;
|
||||||
using GameFinder.StoreHandlers.Origin.DTO;
|
|
||||||
using Microsoft.CodeAnalysis;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
@ -20,33 +18,18 @@ using Wabbajack.DTOs.SavedSettings;
|
|||||||
using Wabbajack.Paths;
|
using Wabbajack.Paths;
|
||||||
using Wabbajack.Paths.IO;
|
using Wabbajack.Paths.IO;
|
||||||
|
|
||||||
namespace Wabbajack.App.Screens
|
namespace Wabbajack.App.Screens;
|
||||||
|
|
||||||
|
public class LauncherViewModel : ViewModelBase, IActivatableViewModel, IReceiver<ConfigureLauncher>
|
||||||
{
|
{
|
||||||
public class LauncherViewModel : ViewModelBase, IActivatableViewModel, IReceiver<ConfigureLauncher>
|
private readonly ILogger<LauncherViewModel> _logger;
|
||||||
{
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public AbsolutePath InstallFolder { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public IBitmap Image { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public InstallationConfigurationSetting? Setting { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public string Title { get; set; }
|
|
||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> PlayButton;
|
public ReactiveCommand<Unit, Unit> PlayButton;
|
||||||
private readonly ILogger<LauncherViewModel> _logger;
|
|
||||||
|
|
||||||
public LauncherViewModel(ILogger<LauncherViewModel> logger, InstallationStateManager manager)
|
public LauncherViewModel(ILogger<LauncherViewModel> logger, InstallationStateManager manager)
|
||||||
{
|
{
|
||||||
Activator = new ViewModelActivator();
|
Activator = new ViewModelActivator();
|
||||||
PlayButton = ReactiveCommand.Create(() =>
|
PlayButton = ReactiveCommand.Create(() => { StartGame().FireAndForget(); });
|
||||||
{
|
|
||||||
StartGame().FireAndForget();
|
|
||||||
});
|
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
|
||||||
this.WhenActivated(disposables =>
|
this.WhenActivated(disposables =>
|
||||||
@ -60,19 +43,31 @@ namespace Wabbajack.App.Screens
|
|||||||
|
|
||||||
this.WhenAnyValue(v => v.Setting)
|
this.WhenAnyValue(v => v.Setting)
|
||||||
.Where(v => v != default)
|
.Where(v => v != default)
|
||||||
.Select(v => new Bitmap((v!.Image).ToString()))
|
.Select(v => new Bitmap(v!.Image.ToString()))
|
||||||
.BindTo(this, vm => vm.Image)
|
.BindTo(this, vm => vm.Image)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
this.WhenAnyValue(v => v.Setting)
|
this.WhenAnyValue(v => v.Setting)
|
||||||
.Where(v => v is { Metadata: { } })
|
.Where(v => v is {Metadata: { }})
|
||||||
.Select(v => $"{v!.Metadata!.Title} v{v!.Metadata.Version}")
|
.Select(v => $"{v!.Metadata!.Title} v{v!.Metadata.Version}")
|
||||||
.BindTo(this, vm => vm.Title)
|
.BindTo(this, vm => vm.Title)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Reactive] public AbsolutePath InstallFolder { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public IBitmap Image { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public InstallationConfigurationSetting? Setting { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public string Title { get; set; }
|
||||||
|
|
||||||
|
public void Receive(ConfigureLauncher val)
|
||||||
|
{
|
||||||
|
InstallFolder = val.InstallFolder;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task StartGame()
|
private async Task StartGame()
|
||||||
{
|
{
|
||||||
var mo2Path = InstallFolder.Combine("ModOrganizer.exe");
|
var mo2Path = InstallFolder.Combine("ModOrganizer.exe");
|
||||||
@ -81,22 +76,10 @@ namespace Wabbajack.App.Screens
|
|||||||
.Select(ge => InstallFolder.Combine(ge!))
|
.Select(ge => InstallFolder.Combine(ge!))
|
||||||
.FirstOrDefault(ge => ge.FileExists());
|
.FirstOrDefault(ge => ge.FileExists());
|
||||||
if (mo2Path.FileExists())
|
if (mo2Path.FileExists())
|
||||||
{
|
|
||||||
Process.Start(mo2Path.ToString());
|
Process.Start(mo2Path.ToString());
|
||||||
}
|
|
||||||
else if (gamePath.FileExists())
|
else if (gamePath.FileExists())
|
||||||
{
|
|
||||||
Process.Start(gamePath.ToString());
|
Process.Start(gamePath.ToString());
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
_logger.LogError("No way to launch game, no acceptable executable found");
|
_logger.LogError("No way to launch game, no acceptable executable found");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void Receive(ConfigureLauncher val)
|
|
||||||
{
|
|
||||||
InstallFolder = val.InstallFolder;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -6,6 +6,6 @@
|
|||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Wabbajack.App.Screens.LogScreenView">
|
x:Class="Wabbajack.App.Screens.LogScreenView">
|
||||||
<Grid RowDefinitions="*">
|
<Grid RowDefinitions="*">
|
||||||
<controls:LogView></controls:LogView>
|
<controls:LogView />
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
@ -1,4 +1,3 @@
|
|||||||
using ReactiveUI;
|
|
||||||
using Wabbajack.App.Views;
|
using Wabbajack.App.Views;
|
||||||
|
|
||||||
namespace Wabbajack.App.Screens;
|
namespace Wabbajack.App.Screens;
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
using System.Reactive;
|
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Input;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
|
||||||
using Wabbajack.App.Utilities;
|
using Wabbajack.App.Utilities;
|
||||||
using Wabbajack.App.ViewModels;
|
using Wabbajack.App.ViewModels;
|
||||||
|
|
||||||
@ -11,11 +7,10 @@ namespace Wabbajack.App.Screens;
|
|||||||
public class LogScreenViewModel : ViewModelBase, IActivatableViewModel
|
public class LogScreenViewModel : ViewModelBase, IActivatableViewModel
|
||||||
{
|
{
|
||||||
private readonly LoggerProvider _provider;
|
private readonly LoggerProvider _provider;
|
||||||
|
|
||||||
public LogScreenViewModel(LoggerProvider provider)
|
public LogScreenViewModel(LoggerProvider provider)
|
||||||
{
|
{
|
||||||
_provider = provider;
|
_provider = provider;
|
||||||
Activator = new ViewModelActivator();
|
Activator = new ViewModelActivator();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -9,12 +9,12 @@
|
|||||||
<ItemsControl x:Name="Lists">
|
<ItemsControl x:Name="Lists">
|
||||||
<ItemsControl.ItemsPanel>
|
<ItemsControl.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<StackPanel></StackPanel>
|
<StackPanel />
|
||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
</ItemsControl.ItemsPanel>
|
</ItemsControl.ItemsPanel>
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<controls:InstalledListView></controls:InstalledListView>
|
<controls:InstalledListView />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ItemsControl.ItemTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
|
@ -15,5 +15,4 @@ public partial class PlaySelectView : ScreenBase<PlaySelectViewModel>
|
|||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -8,7 +8,6 @@ using Wabbajack.App.Controls;
|
|||||||
using Wabbajack.App.Models;
|
using Wabbajack.App.Models;
|
||||||
using Wabbajack.App.ViewModels;
|
using Wabbajack.App.ViewModels;
|
||||||
using Wabbajack.Common;
|
using Wabbajack.Common;
|
||||||
using Wabbajack.DTOs.SavedSettings;
|
|
||||||
|
|
||||||
namespace Wabbajack.App.Screens;
|
namespace Wabbajack.App.Screens;
|
||||||
|
|
||||||
@ -16,9 +15,6 @@ public class PlaySelectViewModel : ViewModelBase, IActivatableViewModel
|
|||||||
{
|
{
|
||||||
private readonly InstallationStateManager _manager;
|
private readonly InstallationStateManager _manager;
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public IEnumerable<InstalledListViewModel> Items { get; set; }
|
|
||||||
|
|
||||||
public PlaySelectViewModel(InstallationStateManager manager)
|
public PlaySelectViewModel(InstallationStateManager manager)
|
||||||
{
|
{
|
||||||
_manager = manager;
|
_manager = manager;
|
||||||
@ -31,10 +27,11 @@ public class PlaySelectViewModel : ViewModelBase, IActivatableViewModel
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Reactive] public IEnumerable<InstalledListViewModel> Items { get; set; }
|
||||||
|
|
||||||
public async Task LoadAndSetItems()
|
public async Task LoadAndSetItems()
|
||||||
{
|
{
|
||||||
var items = await _manager.GetAll();
|
var items = await _manager.GetAll();
|
||||||
Items = items.Settings.Select(a => new InstalledListViewModel(a)).ToArray();
|
Items = items.Settings.Select(a => new InstalledListViewModel(a)).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -10,18 +10,24 @@
|
|||||||
<Grid RowDefinitions="Auto, Auto, Auto, Auto" ColumnDefinitions="20, 100, Auto, Auto">
|
<Grid RowDefinitions="Auto, Auto, Auto, Auto" ColumnDefinitions="20, 100, Auto, Auto">
|
||||||
<TextBlock FontSize="20" Grid.ColumnSpan="4">Logins</TextBlock>
|
<TextBlock FontSize="20" Grid.ColumnSpan="4">Logins</TextBlock>
|
||||||
|
|
||||||
<Image Grid.Row="1" Grid.Column="0" Width="16" Height="16" Margin="4" Source="../Assets/Downloaders/nexus.ico" HorizontalAlignment="Right"></Image>
|
<Image Grid.Row="1" Grid.Column="0" Width="16" Height="16" Margin="4"
|
||||||
<TextBlock Grid.Row="1" Grid.Column="1" Text="Nexus" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBlock>
|
Source="../Assets/Downloaders/nexus.ico" HorizontalAlignment="Right" />
|
||||||
|
<TextBlock Grid.Row="1" Grid.Column="1" Text="Nexus" VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Left" />
|
||||||
<Button Grid.Row="1" Grid.Column="2" x:Name="NexusLogIn">Log In</Button>
|
<Button Grid.Row="1" Grid.Column="2" x:Name="NexusLogIn">Log In</Button>
|
||||||
<Button Grid.Row="1" Grid.Column="3" x:Name="NexusLogOut">Log Out</Button>
|
<Button Grid.Row="1" Grid.Column="3" x:Name="NexusLogOut">Log Out</Button>
|
||||||
|
|
||||||
<Image Grid.Row="2" Grid.Column="0" Width="16" Height="16" Margin="4" Source="../Assets/Downloaders/loverslab.ico" HorizontalAlignment="Right"></Image>
|
<Image Grid.Row="2" Grid.Column="0" Width="16" Height="16" Margin="4"
|
||||||
<TextBlock Grid.Row="2" Grid.Column="1" Text="Lovers Lab" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBlock>
|
Source="../Assets/Downloaders/loverslab.ico" HorizontalAlignment="Right" />
|
||||||
|
<TextBlock Grid.Row="2" Grid.Column="1" Text="Lovers Lab" VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Left" />
|
||||||
<Button Grid.Row="2" Grid.Column="2" x:Name="LoversLabLogIn">Log In</Button>
|
<Button Grid.Row="2" Grid.Column="2" x:Name="LoversLabLogIn">Log In</Button>
|
||||||
<Button Grid.Row="2" Grid.Column="3" x:Name="LoversLabLogOut">Log Out</Button>
|
<Button Grid.Row="2" Grid.Column="3" x:Name="LoversLabLogOut">Log Out</Button>
|
||||||
|
|
||||||
<Image Grid.Row="3" Grid.Column="0" Width="16" Height="16" Margin="4" Source="../Assets/Downloaders/vectorplexus.ico" HorizontalAlignment="Right"></Image>
|
<Image Grid.Row="3" Grid.Column="0" Width="16" Height="16" Margin="4"
|
||||||
<TextBlock Grid.Row="3" Grid.Column="1" Text="Vector Plexus" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBlock>
|
Source="../Assets/Downloaders/vectorplexus.ico" HorizontalAlignment="Right" />
|
||||||
|
<TextBlock Grid.Row="3" Grid.Column="1" Text="Vector Plexus" VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Left" />
|
||||||
<Button Grid.Row="3" Grid.Column="2" x:Name="VectorPlexusLogIn">Log In</Button>
|
<Button Grid.Row="3" Grid.Column="2" x:Name="VectorPlexusLogIn">Log In</Button>
|
||||||
<Button Grid.Row="3" Grid.Column="3" x:Name="VectorPlexusLogOut">Log Out</Button>
|
<Button Grid.Row="3" Grid.Column="3" x:Name="VectorPlexusLogOut">Log Out</Button>
|
||||||
|
|
||||||
@ -35,12 +41,12 @@
|
|||||||
<ItemsControl Grid.Row="1" x:Name="ResourceList">
|
<ItemsControl Grid.Row="1" x:Name="ResourceList">
|
||||||
<ItemsControl.ItemsPanel>
|
<ItemsControl.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<StackPanel Orientation="Vertical"></StackPanel>
|
<StackPanel Orientation="Vertical" />
|
||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
</ItemsControl.ItemsPanel>
|
</ItemsControl.ItemsPanel>
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<controls:ResourceView></controls:ResourceView>
|
<controls:ResourceView />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ItemsControl.ItemTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Wabbajack.App.ViewModels;
|
|
||||||
using Wabbajack.App.Views;
|
using Wabbajack.App.Views;
|
||||||
|
|
||||||
namespace Wabbajack.App.Screens
|
namespace Wabbajack.App.Screens;
|
||||||
|
|
||||||
|
public partial class SettingsView : ScreenBase<SettingsViewModel>
|
||||||
{
|
{
|
||||||
public partial class SettingsView : ScreenBase<SettingsViewModel>
|
|
||||||
{
|
|
||||||
public SettingsView()
|
public SettingsView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -18,9 +17,6 @@ namespace Wabbajack.App.Screens
|
|||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
this.OneWayBind(ViewModel, vm => vm.Resources, view => view.ResourceList.Items)
|
this.OneWayBind(ViewModel, vm => vm.Resources, view => view.ResourceList.Items)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -15,21 +15,16 @@ using Wabbajack.Paths.IO;
|
|||||||
using Wabbajack.RateLimiter;
|
using Wabbajack.RateLimiter;
|
||||||
using Wabbajack.Services.OSIntegrated.TokenProviders;
|
using Wabbajack.Services.OSIntegrated.TokenProviders;
|
||||||
|
|
||||||
namespace Wabbajack.App.Screens
|
namespace Wabbajack.App.Screens;
|
||||||
|
|
||||||
|
public class SettingsViewModel : ViewModelBase, IReceiverMarker
|
||||||
{
|
{
|
||||||
public class SettingsViewModel : ViewModelBase, IReceiverMarker
|
|
||||||
{
|
|
||||||
private readonly ILogger<SettingsViewModel> _logger;
|
|
||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> NexusLogin { get; set; }
|
|
||||||
public ReactiveCommand<Unit, Unit> NexusLogout { get; set; }
|
|
||||||
|
|
||||||
public FileSystemWatcher Watcher { get; set; }
|
|
||||||
|
|
||||||
private readonly Subject<AbsolutePath> _fileSystemEvents = new();
|
private readonly Subject<AbsolutePath> _fileSystemEvents = new();
|
||||||
|
private readonly ILogger<SettingsViewModel> _logger;
|
||||||
public readonly IEnumerable<ResourceViewModel> Resources;
|
public readonly IEnumerable<ResourceViewModel> Resources;
|
||||||
|
|
||||||
public SettingsViewModel(ILogger<SettingsViewModel> logger, Configuration configuration, NexusApiTokenProvider nexusProvider, IEnumerable<IResource> resources)
|
public SettingsViewModel(ILogger<SettingsViewModel> logger, Configuration configuration,
|
||||||
|
NexusApiTokenProvider nexusProvider, IEnumerable<IResource> resources)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
Resources = resources.Select(r => new ResourceViewModel(r)).ToArray();
|
Resources = resources.Select(r => new ResourceViewModel(r)).ToArray();
|
||||||
@ -47,24 +42,24 @@ namespace Wabbajack.App.Screens
|
|||||||
|
|
||||||
Watcher.EnableRaisingEvents = true;
|
Watcher.EnableRaisingEvents = true;
|
||||||
|
|
||||||
var haveNexusToken = this._fileSystemEvents
|
var haveNexusToken = _fileSystemEvents
|
||||||
.StartWith(AbsolutePath.Empty)
|
.StartWith(AbsolutePath.Empty)
|
||||||
.Select(_ => nexusProvider.HaveToken());
|
.Select(_ => nexusProvider.HaveToken());
|
||||||
|
|
||||||
NexusLogin = ReactiveCommand.Create(() =>
|
NexusLogin =
|
||||||
{
|
ReactiveCommand.Create(() => { MessageBus.Instance.Send(new NavigateTo(typeof(NexusLoginViewModel))); },
|
||||||
MessageBus.Instance.Send(new NavigateTo(typeof(NexusLoginViewModel)));
|
haveNexusToken.Select(x => !x));
|
||||||
}, haveNexusToken.Select(x => !x));
|
|
||||||
NexusLogout = ReactiveCommand.Create(nexusProvider.DeleteToken, haveNexusToken.Select(x => x));
|
NexusLogout = ReactiveCommand.Create(nexusProvider.DeleteToken, haveNexusToken.Select(x => x));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ReactiveCommand<Unit, Unit> NexusLogin { get; set; }
|
||||||
|
public ReactiveCommand<Unit, Unit> NexusLogout { get; set; }
|
||||||
|
|
||||||
|
public FileSystemWatcher Watcher { get; set; }
|
||||||
|
|
||||||
private void Pulse(object sender, FileSystemEventArgs e)
|
private void Pulse(object sender, FileSystemEventArgs e)
|
||||||
{
|
{
|
||||||
_fileSystemEvents.OnNext(e.FullPath?.ToAbsolutePath() ?? default);
|
_fileSystemEvents.OnNext(e.FullPath?.ToAbsolutePath() ?? default);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -7,18 +7,26 @@
|
|||||||
x:Class="Wabbajack.App.Views.StandardInstallationView">
|
x:Class="Wabbajack.App.Views.StandardInstallationView">
|
||||||
<Grid RowDefinitions="40, 5, 5, *, 40">
|
<Grid RowDefinitions="40, 5, 5, *, 40">
|
||||||
<TextBlock Grid.Row="0" x:Name="StatusText" FontSize="20" FontWeight="Bold">[20/30] Installing Files</TextBlock>
|
<TextBlock Grid.Row="0" x:Name="StatusText" FontSize="20" FontWeight="Bold">[20/30] Installing Files</TextBlock>
|
||||||
<ProgressBar Grid.Row="1" x:Name="StepsProgress" Maximum="1000" Value="40"></ProgressBar>
|
<ProgressBar Grid.Row="1" x:Name="StepsProgress" Maximum="1000" Value="40" />
|
||||||
<ProgressBar Grid.Row="2" x:Name="StepProgress" Maximum="10000" Value="30"></ProgressBar>
|
<ProgressBar Grid.Row="2" x:Name="StepProgress" Maximum="10000" Value="30" />
|
||||||
<Viewbox Grid.Row="3" HorizontalAlignment="Center"
|
<Viewbox Grid.Row="3" HorizontalAlignment="Center"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Stretch="Uniform">
|
Stretch="Uniform">
|
||||||
<Image x:Name="SlideImage"></Image>
|
<Image x:Name="SlideImage" />
|
||||||
</Viewbox>
|
</Viewbox>
|
||||||
<Grid Grid.Row="4" HorizontalAlignment="Center" ColumnDefinitions="40, 40, 40, 40">
|
<Grid Grid.Row="4" HorizontalAlignment="Center" ColumnDefinitions="40, 40, 40, 40">
|
||||||
<Button Grid.Column="0" x:Name="PrevSlide"><i:MaterialIcon Kind="ArrowLeft"></i:MaterialIcon></Button>
|
<Button Grid.Column="0" x:Name="PrevSlide">
|
||||||
<Button Grid.Column="1" x:Name="PauseSlides"><i:MaterialIcon Kind="Pause"></i:MaterialIcon></Button>
|
<i:MaterialIcon Kind="ArrowLeft" />
|
||||||
<Button Grid.Column="2" x:Name="PlaySlides"><i:MaterialIcon Kind="PlayArrow"></i:MaterialIcon></Button>
|
</Button>
|
||||||
<Button Grid.Column="3" x:Name="NextSlide"><i:MaterialIcon Kind="ArrowRight"></i:MaterialIcon></Button>
|
<Button Grid.Column="1" x:Name="PauseSlides">
|
||||||
|
<i:MaterialIcon Kind="Pause" />
|
||||||
|
</Button>
|
||||||
|
<Button Grid.Column="2" x:Name="PlaySlides">
|
||||||
|
<i:MaterialIcon Kind="PlayArrow" />
|
||||||
|
</Button>
|
||||||
|
<Button Grid.Column="3" x:Name="NextSlide">
|
||||||
|
<i:MaterialIcon Kind="ArrowRight" />
|
||||||
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
@ -2,10 +2,10 @@ using System.Reactive.Disposables;
|
|||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Wabbajack.App.ViewModels;
|
using Wabbajack.App.ViewModels;
|
||||||
|
|
||||||
namespace Wabbajack.App.Views
|
namespace Wabbajack.App.Views;
|
||||||
|
|
||||||
|
public partial class StandardInstallationView : ScreenBase<StandardInstallationViewModel>
|
||||||
{
|
{
|
||||||
public partial class StandardInstallationView : ScreenBase<StandardInstallationViewModel>
|
|
||||||
{
|
|
||||||
public StandardInstallationView()
|
public StandardInstallationView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -35,9 +35,6 @@ namespace Wabbajack.App.Views
|
|||||||
|
|
||||||
this.OneWayBind(ViewModel, vm => vm.StepProgress, view => view.StepProgress.Value, p => p.Value * 10000)
|
this.OneWayBind(ViewModel, vm => vm.StepProgress, view => view.StepProgress.Value, p => p.Value * 10000)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -8,7 +8,6 @@ using System.Reactive.Disposables;
|
|||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Avalonia.Media;
|
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -29,45 +28,25 @@ using Wabbajack.Installer;
|
|||||||
using Wabbajack.Paths.IO;
|
using Wabbajack.Paths.IO;
|
||||||
using Wabbajack.RateLimiter;
|
using Wabbajack.RateLimiter;
|
||||||
|
|
||||||
namespace Wabbajack.App.ViewModels
|
namespace Wabbajack.App.ViewModels;
|
||||||
|
|
||||||
|
public class StandardInstallationViewModel : ViewModelBase, IReceiver<StartInstallation>
|
||||||
{
|
{
|
||||||
public class StandardInstallationViewModel : ViewModelBase, IReceiver<StartInstallation>
|
|
||||||
{
|
|
||||||
private readonly IServiceProvider _provider;
|
|
||||||
private readonly GameLocator _locator;
|
|
||||||
private IServiceScope _scope;
|
|
||||||
private InstallerConfiguration _config;
|
|
||||||
private StandardInstaller _installer;
|
|
||||||
private readonly ILogger<StandardInstallationViewModel> _logger;
|
|
||||||
private readonly DTOSerializer _dtos;
|
private readonly DTOSerializer _dtos;
|
||||||
private SlideViewModel[] _slides = Array.Empty<SlideViewModel>();
|
|
||||||
private readonly HttpClient _httpClient;
|
private readonly HttpClient _httpClient;
|
||||||
private Timer _slideTimer;
|
|
||||||
private int _currentSlideIndex;
|
|
||||||
private readonly InstallationStateManager _installStateManager;
|
private readonly InstallationStateManager _installStateManager;
|
||||||
|
private readonly GameLocator _locator;
|
||||||
|
private readonly ILogger<StandardInstallationViewModel> _logger;
|
||||||
|
private readonly IServiceProvider _provider;
|
||||||
|
private InstallerConfiguration _config;
|
||||||
|
private int _currentSlideIndex;
|
||||||
|
private StandardInstaller _installer;
|
||||||
|
private IServiceScope _scope;
|
||||||
|
private SlideViewModel[] _slides = Array.Empty<SlideViewModel>();
|
||||||
|
private Timer _slideTimer;
|
||||||
|
|
||||||
[Reactive]
|
public StandardInstallationViewModel(ILogger<StandardInstallationViewModel> logger, IServiceProvider provider,
|
||||||
public SlideViewModel Slide { get; set; }
|
GameLocator locator, DTOSerializer dtos,
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public ReactiveCommand<Unit,Unit> NextCommand { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public ReactiveCommand<Unit, Unit> PrevCommand { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public ReactiveCommand<Unit, bool> PauseCommand { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public ReactiveCommand<Unit, bool> PlayCommand { get; set; }
|
|
||||||
|
|
||||||
[Reactive] public bool IsPlaying { get; set; } = true;
|
|
||||||
|
|
||||||
[Reactive] public string StatusText { get; set; } = "";
|
|
||||||
[Reactive] public Percent StepsProgress { get; set; } = Percent.Zero;
|
|
||||||
[Reactive] public Percent StepProgress { get; set; } = Percent.Zero;
|
|
||||||
|
|
||||||
public StandardInstallationViewModel(ILogger<StandardInstallationViewModel> logger, IServiceProvider provider, GameLocator locator, DTOSerializer dtos,
|
|
||||||
HttpClient httpClient, InstallationStateManager manager)
|
HttpClient httpClient, InstallationStateManager manager)
|
||||||
{
|
{
|
||||||
_provider = provider;
|
_provider = provider;
|
||||||
@ -78,7 +57,8 @@ namespace Wabbajack.App.ViewModels
|
|||||||
_installStateManager = manager;
|
_installStateManager = manager;
|
||||||
Activator = new ViewModelActivator();
|
Activator = new ViewModelActivator();
|
||||||
|
|
||||||
this.WhenActivated(disposables => {
|
this.WhenActivated(disposables =>
|
||||||
|
{
|
||||||
_slideTimer = new Timer(_ =>
|
_slideTimer = new Timer(_ =>
|
||||||
{
|
{
|
||||||
if (IsPlaying) NextSlide(1);
|
if (IsPlaying) NextSlide(1);
|
||||||
@ -92,18 +72,37 @@ namespace Wabbajack.App.ViewModels
|
|||||||
PrevCommand = ReactiveCommand.Create(() => NextSlide(-1))
|
PrevCommand = ReactiveCommand.Create(() => NextSlide(-1))
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
PauseCommand = ReactiveCommand.Create(() => IsPlaying = false,
|
PauseCommand = ReactiveCommand.Create(() => IsPlaying = false,
|
||||||
this.ObservableForProperty(vm => vm.IsPlaying, skipInitial:false)
|
this.ObservableForProperty(vm => vm.IsPlaying, skipInitial: false)
|
||||||
.Select(v => v.Value))
|
.Select(v => v.Value))
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
PlayCommand = ReactiveCommand.Create(() => IsPlaying = true,
|
PlayCommand = ReactiveCommand.Create(() => IsPlaying = true,
|
||||||
this.ObservableForProperty(vm => vm.IsPlaying, skipInitial:false)
|
this.ObservableForProperty(vm => vm.IsPlaying, skipInitial: false)
|
||||||
.Select(v => !v.Value))
|
.Select(v => !v.Value))
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Reactive] public SlideViewModel Slide { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public ReactiveCommand<Unit, Unit> NextCommand { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public ReactiveCommand<Unit, Unit> PrevCommand { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public ReactiveCommand<Unit, bool> PauseCommand { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public ReactiveCommand<Unit, bool> PlayCommand { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public bool IsPlaying { get; set; } = true;
|
||||||
|
|
||||||
|
[Reactive] public string StatusText { get; set; } = "";
|
||||||
|
[Reactive] public Percent StepsProgress { get; set; } = Percent.Zero;
|
||||||
|
[Reactive] public Percent StepProgress { get; set; } = Percent.Zero;
|
||||||
|
|
||||||
|
public void Receive(StartInstallation msg)
|
||||||
|
{
|
||||||
|
Install(msg).FireAndForget();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void NextSlide(int direction)
|
private void NextSlide(int direction)
|
||||||
@ -123,10 +122,7 @@ namespace Wabbajack.App.ViewModels
|
|||||||
//if (prevSlide.Image != null)
|
//if (prevSlide.Image != null)
|
||||||
// prevSlide.Image = null;
|
// prevSlide.Image = null;
|
||||||
|
|
||||||
Dispatcher.UIThread.InvokeAsync(() =>
|
Dispatcher.UIThread.InvokeAsync(() => { Slide = thisSlide; });
|
||||||
{
|
|
||||||
Slide = thisSlide;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int InSlideRange(int i)
|
private int InSlideRange(int i)
|
||||||
@ -140,12 +136,6 @@ namespace Wabbajack.App.ViewModels
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Receive(StartInstallation msg)
|
|
||||||
{
|
|
||||||
|
|
||||||
Install(msg).FireAndForget();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Install(StartInstallation msg)
|
private async Task Install(StartInstallation msg)
|
||||||
{
|
{
|
||||||
_scope = _provider.CreateScope();
|
_scope = _provider.CreateScope();
|
||||||
@ -160,7 +150,7 @@ namespace Wabbajack.App.ViewModels
|
|||||||
_config.Game = _config.ModList.GameType;
|
_config.Game = _config.ModList.GameType;
|
||||||
|
|
||||||
_slides = _config.ModList.Archives.Select(a => a.State).OfType<IMetaState>()
|
_slides = _config.ModList.Archives.Select(a => a.State).OfType<IMetaState>()
|
||||||
.Select(m => new SlideViewModel { MetaState = m })
|
.Select(m => new SlideViewModel {MetaState = m})
|
||||||
.Shuffle()
|
.Shuffle()
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
@ -198,10 +188,7 @@ namespace Wabbajack.App.ViewModels
|
|||||||
var result = await _installer.Begin(CancellationToken.None);
|
var result = await _installer.Begin(CancellationToken.None);
|
||||||
if (!result) throw new Exception("Installation failed");
|
if (!result) throw new Exception("Installation failed");
|
||||||
|
|
||||||
if (result)
|
if (result) await SaveConfigAndContinue(_config);
|
||||||
{
|
|
||||||
await SaveConfigAndContinue(_config);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -230,5 +217,4 @@ namespace Wabbajack.App.ViewModels
|
|||||||
MessageBus.Instance.Send(new ConfigureLauncher(config.Install));
|
MessageBus.Instance.Send(new ConfigureLauncher(config.Install));
|
||||||
MessageBus.Instance.Send(new NavigateTo(typeof(LauncherViewModel)));
|
MessageBus.Instance.Send(new NavigateTo(typeof(LauncherViewModel)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Reactive.Disposables;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
@ -20,16 +19,19 @@ using Wabbajack.Downloaders.Interfaces;
|
|||||||
using Wabbajack.DTOs;
|
using Wabbajack.DTOs;
|
||||||
using Wabbajack.DTOs.DownloadStates;
|
using Wabbajack.DTOs.DownloadStates;
|
||||||
using Wabbajack.DTOs.JsonConverters;
|
using Wabbajack.DTOs.JsonConverters;
|
||||||
using Wabbajack.Networking.NexusApi;
|
|
||||||
using Wabbajack.Paths;
|
|
||||||
using Wabbajack.Paths.IO;
|
using Wabbajack.Paths.IO;
|
||||||
using Wabbajack.Services.OSIntegrated;
|
using Wabbajack.Services.OSIntegrated;
|
||||||
using SettingsView = Wabbajack.App.Screens.SettingsView;
|
|
||||||
|
|
||||||
namespace Wabbajack.App
|
namespace Wabbajack.App;
|
||||||
|
|
||||||
|
public static class ServiceExtensions
|
||||||
{
|
{
|
||||||
public static class ServiceExtensions
|
private const int messagePumpDelay = 10;
|
||||||
{
|
|
||||||
|
|
||||||
|
private static CefAppImpl app;
|
||||||
|
private static Timer messagePump;
|
||||||
|
|
||||||
public static IServiceCollection AddAppServices(this IServiceCollection services)
|
public static IServiceCollection AddAppServices(this IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddAllSingleton<ILoggerProvider, LoggerProvider>();
|
services.AddAllSingleton<ILoggerProvider, LoggerProvider>();
|
||||||
@ -78,7 +80,7 @@ namespace Wabbajack.App
|
|||||||
services.AddAllSingleton<IDownloader, IDownloader<Manual>, ManualDownloader>();
|
services.AddAllSingleton<IDownloader, IDownloader<Manual>, ManualDownloader>();
|
||||||
|
|
||||||
var resources = KnownFolders.EntryPoint;
|
var resources = KnownFolders.EntryPoint;
|
||||||
services.AddSingleton(s => new CefSettings()
|
services.AddSingleton(s => new CefSettings
|
||||||
{
|
{
|
||||||
NoSandbox = true,
|
NoSandbox = true,
|
||||||
PersistSessionCookies = true,
|
PersistSessionCookies = true,
|
||||||
@ -121,26 +123,19 @@ namespace Wabbajack.App
|
|||||||
|
|
||||||
private static async void OnScheduleMessagePumpWork(long delayMs)
|
private static async void OnScheduleMessagePumpWork(long delayMs)
|
||||||
{
|
{
|
||||||
await Task.Delay((int)delayMs);
|
await Task.Delay((int) delayMs);
|
||||||
Dispatcher.UIThread.Post(CefApi.DoMessageLoopWork);
|
Dispatcher.UIThread.Post(CefApi.DoMessageLoopWork);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void App_CefProcessMessageReceived(object? sender, CefProcessMessageReceivedEventArgs e)
|
private static void App_CefProcessMessageReceived(object? sender, CefProcessMessageReceivedEventArgs e)
|
||||||
{
|
{
|
||||||
var msg = e.Name;
|
var msg = e.Name;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static CefAppImpl app;
|
|
||||||
private static Timer messagePump;
|
|
||||||
private const int messagePumpDelay = 10;
|
|
||||||
private static void App_FrameworkInitialized(object? sender, EventArgs e)
|
private static void App_FrameworkInitialized(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (CefNetApplication.Instance.UsesExternalMessageLoop)
|
if (CefNetApplication.Instance.UsesExternalMessageLoop)
|
||||||
{
|
messagePump = new Timer(_ => Dispatcher.UIThread.Post(CefApi.DoMessageLoopWork), null, messagePumpDelay,
|
||||||
messagePump = new Timer(_ => Dispatcher.UIThread.Post(CefApi.DoMessageLoopWork), null, messagePumpDelay, messagePumpDelay);
|
messagePumpDelay);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,13 +11,16 @@ using Wabbajack.Hashing.xxHash64;
|
|||||||
using Wabbajack.Paths;
|
using Wabbajack.Paths;
|
||||||
using Wabbajack.RateLimiter;
|
using Wabbajack.RateLimiter;
|
||||||
|
|
||||||
namespace Wabbajack.App.Services
|
namespace Wabbajack.App.Services;
|
||||||
|
|
||||||
|
public class ManualDownloader : ADownloader<Manual>
|
||||||
{
|
{
|
||||||
public class ManualDownloader : ADownloader<Manual>
|
public override Priority Priority { get; }
|
||||||
|
|
||||||
|
public override Task<Hash> Download(Archive archive, Manual state, AbsolutePath destination, IJob job,
|
||||||
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
public override Task<Hash> Download(Archive archive, Manual state, AbsolutePath destination, IJob job, CancellationToken token)
|
throw new NotImplementedException();
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Prepare()
|
public override Task<bool> Prepare()
|
||||||
@ -27,20 +30,16 @@ namespace Wabbajack.App.Services
|
|||||||
|
|
||||||
public override bool IsAllowed(ServerAllowList allowList, IDownloadState state)
|
public override bool IsAllowed(ServerAllowList allowList, IDownloadState state)
|
||||||
{
|
{
|
||||||
var manual = (Manual)state;
|
var manual = (Manual) state;
|
||||||
return allowList.AllowedPrefixes.Any(p => manual.Url.ToString().StartsWith(p));
|
return allowList.AllowedPrefixes.Any(p => manual.Url.ToString().StartsWith(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IDownloadState? Resolve(IReadOnlyDictionary<string, string> iniData)
|
public override IDownloadState? Resolve(IReadOnlyDictionary<string, string> iniData)
|
||||||
{
|
{
|
||||||
if (iniData.TryGetValue("manualURL", out var manual))
|
if (iniData.TryGetValue("manualURL", out var manual)) return new Manual {Url = new Uri(manual)};
|
||||||
{
|
|
||||||
return new Manual { Url = new Uri(manual) };
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Priority Priority { get; }
|
|
||||||
public override Task<bool> Verify(Archive archive, Manual archiveState, IJob job, CancellationToken token)
|
public override Task<bool> Verify(Archive archive, Manual archiveState, IJob job, CancellationToken token)
|
||||||
{
|
{
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
@ -48,7 +47,6 @@ namespace Wabbajack.App.Services
|
|||||||
|
|
||||||
public override IEnumerable<string> MetaIni(Archive a, Manual state)
|
public override IEnumerable<string> MetaIni(Archive a, Manual state)
|
||||||
{
|
{
|
||||||
return new[] { $"manualURL={state.Url}" };
|
return new[] {$"manualURL={state.Url}"};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,10 +2,12 @@ using System;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using CefNet;
|
using CefNet;
|
||||||
|
|
||||||
namespace Wabbajack.App.Utilities
|
namespace Wabbajack.App.Utilities;
|
||||||
|
|
||||||
|
internal class CefAppImpl : CefNetApplication
|
||||||
{
|
{
|
||||||
class CefAppImpl : CefNetApplication
|
public Action<long> ScheduleMessagePumpWorkCallback { get; set; }
|
||||||
{
|
|
||||||
protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
|
protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
|
||||||
{
|
{
|
||||||
base.OnBeforeCommandLineProcessing(processType, commandLine);
|
base.OnBeforeCommandLineProcessing(processType, commandLine);
|
||||||
@ -50,7 +52,6 @@ const newProto = navigator.__proto__;
|
|||||||
delete newProto.webdriver;
|
delete newProto.webdriver;
|
||||||
navigator.__proto__ = newProto;
|
navigator.__proto__ = newProto;
|
||||||
}", frame.Url, 0);
|
}", frame.Url, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnCefProcessMessageReceived(CefProcessMessageReceivedEventArgs e)
|
protected override void OnCefProcessMessageReceived(CefProcessMessageReceivedEventArgs e)
|
||||||
@ -58,8 +59,6 @@ navigator.__proto__ = newProto;
|
|||||||
base.OnCefProcessMessageReceived(e);
|
base.OnCefProcessMessageReceived(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action<long> ScheduleMessagePumpWorkCallback { get; set; }
|
|
||||||
|
|
||||||
protected override CefRenderProcessHandler GetRenderProcessHandler()
|
protected override CefRenderProcessHandler GetRenderProcessHandler()
|
||||||
{
|
{
|
||||||
return base.GetRenderProcessHandler();
|
return base.GetRenderProcessHandler();
|
||||||
@ -69,5 +68,4 @@ navigator.__proto__ = newProto;
|
|||||||
{
|
{
|
||||||
ScheduleMessagePumpWorkCallback(delayMs);
|
ScheduleMessagePumpWorkCallback(delayMs);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -8,7 +8,6 @@ using System.Text;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using DynamicData;
|
using DynamicData;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Primitives;
|
|
||||||
using Wabbajack.Paths;
|
using Wabbajack.Paths;
|
||||||
using Wabbajack.Paths.IO;
|
using Wabbajack.Paths.IO;
|
||||||
|
|
||||||
@ -16,21 +15,18 @@ namespace Wabbajack.App.Utilities;
|
|||||||
|
|
||||||
public class LoggerProvider : ILoggerProvider
|
public class LoggerProvider : ILoggerProvider
|
||||||
{
|
{
|
||||||
private Subject<ILogMessage> _messages = new();
|
|
||||||
public IObservable<ILogMessage> Messages => _messages;
|
|
||||||
|
|
||||||
private long _messageId = 0;
|
|
||||||
private SourceCache<ILogMessage, long> _messageLog = new(m => m.MessageId);
|
|
||||||
|
|
||||||
public readonly ReadOnlyObservableCollection<ILogMessage> _messagesFiltered;
|
|
||||||
private readonly CompositeDisposable _disposables;
|
|
||||||
private readonly Configuration _configuration;
|
|
||||||
private readonly DateTime _startupTime;
|
|
||||||
private readonly RelativePath _appName;
|
private readonly RelativePath _appName;
|
||||||
public AbsolutePath LogPath { get; }
|
private readonly Configuration _configuration;
|
||||||
|
private readonly CompositeDisposable _disposables;
|
||||||
private readonly Stream _logFile;
|
private readonly Stream _logFile;
|
||||||
private readonly StreamWriter _logStream;
|
private readonly StreamWriter _logStream;
|
||||||
public ReadOnlyObservableCollection<ILogMessage> MessageLog => _messagesFiltered;
|
|
||||||
|
public readonly ReadOnlyObservableCollection<ILogMessage> _messagesFiltered;
|
||||||
|
private readonly DateTime _startupTime;
|
||||||
|
|
||||||
|
private long _messageId;
|
||||||
|
private readonly SourceCache<ILogMessage, long> _messageLog = new(m => m.MessageId);
|
||||||
|
private readonly Subject<ILogMessage> _messages = new();
|
||||||
|
|
||||||
public LoggerProvider(Configuration configuration)
|
public LoggerProvider(Configuration configuration)
|
||||||
{
|
{
|
||||||
@ -55,11 +51,24 @@ public class LoggerProvider : ILoggerProvider
|
|||||||
|
|
||||||
_appName = typeof(LoggerProvider).Assembly.Location.ToAbsolutePath().FileName;
|
_appName = typeof(LoggerProvider).Assembly.Location.ToAbsolutePath().FileName;
|
||||||
LogPath = _configuration.LogLocation.Combine($"{_appName}.current.log");
|
LogPath = _configuration.LogLocation.Combine($"{_appName}.current.log");
|
||||||
_logFile = LogPath.Open(FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
|
_logFile = LogPath.Open(FileMode.Append, FileAccess.Write);
|
||||||
_logFile.DisposeWith(_disposables);
|
_logFile.DisposeWith(_disposables);
|
||||||
|
|
||||||
_logStream = new StreamWriter(_logFile, Encoding.UTF8);
|
_logStream = new StreamWriter(_logFile, Encoding.UTF8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IObservable<ILogMessage> Messages => _messages;
|
||||||
|
public AbsolutePath LogPath { get; }
|
||||||
|
public ReadOnlyObservableCollection<ILogMessage> MessageLog => _messagesFiltered;
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_disposables.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ILogger CreateLogger(string categoryName)
|
||||||
|
{
|
||||||
|
return new Logger(this, categoryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LogToFile(ILogMessage logMessage)
|
private void LogToFile(ILogMessage logMessage)
|
||||||
@ -77,21 +86,11 @@ public class LoggerProvider : ILoggerProvider
|
|||||||
return Interlocked.Increment(ref _messageId);
|
return Interlocked.Increment(ref _messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
_disposables.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ILogger CreateLogger(string categoryName)
|
|
||||||
{
|
|
||||||
return new Logger(this, categoryName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Logger : ILogger
|
public class Logger : ILogger
|
||||||
{
|
{
|
||||||
|
private readonly string _categoryName;
|
||||||
private readonly LoggerProvider _provider;
|
private readonly LoggerProvider _provider;
|
||||||
private ImmutableList<object> Scopes = ImmutableList<object>.Empty;
|
private ImmutableList<object> Scopes = ImmutableList<object>.Empty;
|
||||||
private readonly string _categoryName;
|
|
||||||
|
|
||||||
public Logger(LoggerProvider provider, string categoryName)
|
public Logger(LoggerProvider provider, string categoryName)
|
||||||
{
|
{
|
||||||
@ -99,9 +98,11 @@ public class LoggerProvider : ILoggerProvider
|
|||||||
_provider = provider;
|
_provider = provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
|
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception,
|
||||||
|
Func<TState, Exception?, string> formatter)
|
||||||
{
|
{
|
||||||
_provider._messages.OnNext(new LogMessage<TState>(DateTime.UtcNow, _provider.NextMessageId(), logLevel, eventId, state, exception, formatter));
|
_provider._messages.OnNext(new LogMessage<TState>(DateTime.UtcNow, _provider.NextMessageId(), logLevel,
|
||||||
|
eventId, state, exception, formatter));
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsEnabled(LogLevel logLevel)
|
public bool IsEnabled(LogLevel logLevel)
|
||||||
@ -125,7 +126,8 @@ public class LoggerProvider : ILoggerProvider
|
|||||||
string LongMessage { get; }
|
string LongMessage { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
record LogMessage<TState>(DateTime TimeStamp, long MessageId, LogLevel LogLevel, EventId EventId, TState State, Exception? Exception, Func<TState, Exception?, string> Formatter) : ILogMessage
|
private record LogMessage<TState>(DateTime TimeStamp, long MessageId, LogLevel LogLevel, EventId EventId,
|
||||||
|
TState State, Exception? Exception, Func<TState, Exception?, string> Formatter) : ILogMessage
|
||||||
{
|
{
|
||||||
public string ShortMessage => Formatter(State, Exception);
|
public string ShortMessage => Formatter(State, Exception);
|
||||||
|
|
||||||
|
@ -5,10 +5,10 @@ using Wabbajack.Common;
|
|||||||
using Wabbajack.Paths;
|
using Wabbajack.Paths;
|
||||||
using Wabbajack.Paths.IO;
|
using Wabbajack.Paths.IO;
|
||||||
|
|
||||||
namespace Wabbajack.App.Utilities
|
namespace Wabbajack.App.Utilities;
|
||||||
|
|
||||||
|
public class ModListUtilities
|
||||||
{
|
{
|
||||||
public class ModListUtilities
|
|
||||||
{
|
|
||||||
public static async Task<MemoryStream> GetModListImageStream(AbsolutePath modList)
|
public static async Task<MemoryStream> GetModListImageStream(AbsolutePath modList)
|
||||||
{
|
{
|
||||||
await using var fs = modList.Open(FileMode.Open, FileAccess.Read, FileShare.Read);
|
await using var fs = modList.Open(FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||||
@ -17,5 +17,4 @@ namespace Wabbajack.App.Utilities
|
|||||||
await using var stream = entry!.Open();
|
await using var stream = entry!.Open();
|
||||||
return new MemoryStream(await stream.ReadAllAsync());
|
return new MemoryStream(await stream.ReadAllAsync());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,13 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using Wabbajack.Common;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Wabbajack.App
|
namespace Wabbajack.App;
|
||||||
|
|
||||||
|
public static class Utils
|
||||||
{
|
{
|
||||||
public static class Utils
|
|
||||||
{
|
|
||||||
public static void OpenWebsiteInExternalBrowser(Uri uri)
|
public static void OpenWebsiteInExternalBrowser(Uri uri)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Process.Start(uri.ToString());
|
Process.Start(uri.ToString());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,10 +3,10 @@ using Avalonia.Controls;
|
|||||||
using Avalonia.Controls.Templates;
|
using Avalonia.Controls.Templates;
|
||||||
using Wabbajack.App.ViewModels;
|
using Wabbajack.App.ViewModels;
|
||||||
|
|
||||||
namespace Wabbajack.App
|
namespace Wabbajack.App;
|
||||||
|
|
||||||
|
public class ViewLocator : IDataTemplate
|
||||||
{
|
{
|
||||||
public class ViewLocator : IDataTemplate
|
|
||||||
{
|
|
||||||
public bool SupportsRecycling => false;
|
public bool SupportsRecycling => false;
|
||||||
|
|
||||||
public IControl Build(object data)
|
public IControl Build(object data)
|
||||||
@ -15,18 +15,12 @@ namespace Wabbajack.App
|
|||||||
var type = Type.GetType(name);
|
var type = Type.GetType(name);
|
||||||
|
|
||||||
if (type != null)
|
if (type != null)
|
||||||
{
|
return (Control) Activator.CreateInstance(type)!;
|
||||||
return (Control)Activator.CreateInstance(type)!;
|
return new TextBlock {Text = "Not Found: " + name};
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new TextBlock { Text = "Not Found: " + name };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Match(object data)
|
public bool Match(object data)
|
||||||
{
|
{
|
||||||
return data is ViewModelBase;
|
return data is ViewModelBase;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,36 +1,29 @@
|
|||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CefNet;
|
|
||||||
using CefNet.Avalonia;
|
using CefNet.Avalonia;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using Wabbajack.App.Messages;
|
using Wabbajack.App.Messages;
|
||||||
using Wabbajack.Common;
|
|
||||||
|
|
||||||
namespace Wabbajack.App.ViewModels
|
namespace Wabbajack.App.ViewModels;
|
||||||
|
|
||||||
|
public abstract class GuidedWebViewModel : ViewModelBase, IReceiverMarker
|
||||||
{
|
{
|
||||||
public abstract class GuidedWebViewModel : ViewModelBase, IReceiverMarker
|
|
||||||
{
|
|
||||||
protected ILogger _logger;
|
protected ILogger _logger;
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public string Instructions { get; set; }
|
|
||||||
|
|
||||||
public GuidedWebViewModel(ILogger logger)
|
public GuidedWebViewModel(ILogger logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
Activator = new ViewModelActivator();
|
Activator = new ViewModelActivator();
|
||||||
|
|
||||||
this.WhenActivated(disposables =>
|
this.WhenActivated(disposables => { Disposable.Empty.DisposeWith(disposables); });
|
||||||
{
|
|
||||||
Disposable.Empty.DisposeWith(disposables);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Reactive] public string Instructions { get; set; }
|
||||||
|
|
||||||
public WebView Browser { get; set; }
|
public WebView Browser { get; set; }
|
||||||
|
|
||||||
public abstract Task Run(CancellationToken token);
|
public abstract Task Run(CancellationToken token);
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,5 +1,3 @@
|
|||||||
using System.IO;
|
|
||||||
using System.IO.Compression;
|
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
@ -21,35 +19,13 @@ using Wabbajack.Installer;
|
|||||||
using Wabbajack.Paths;
|
using Wabbajack.Paths;
|
||||||
using Wabbajack.Paths.IO;
|
using Wabbajack.Paths.IO;
|
||||||
|
|
||||||
namespace Wabbajack.App.ViewModels
|
namespace Wabbajack.App.ViewModels;
|
||||||
|
|
||||||
|
public class InstallConfigurationViewModel : ViewModelBase, IActivatableViewModel, IReceiver<StartInstallConfiguration>
|
||||||
{
|
{
|
||||||
public class InstallConfigurationViewModel : ViewModelBase, IActivatableViewModel, IReceiver<StartInstallConfiguration>
|
|
||||||
{
|
|
||||||
private readonly DTOSerializer _dtos;
|
private readonly DTOSerializer _dtos;
|
||||||
private readonly InstallationStateManager _stateManager;
|
private readonly InstallationStateManager _stateManager;
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public AbsolutePath ModListPath { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public AbsolutePath Install { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public AbsolutePath Download { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public ModList? ModList { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public IBitmap? ModListImage { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public bool IsReady { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public ReactiveCommand<Unit, Unit> BeginCommand { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public InstallConfigurationViewModel(DTOSerializer dtos, InstallationStateManager stateManager)
|
public InstallConfigurationViewModel(DTOSerializer dtos, InstallationStateManager stateManager)
|
||||||
{
|
{
|
||||||
@ -59,12 +35,11 @@ namespace Wabbajack.App.ViewModels
|
|||||||
Activator = new ViewModelActivator();
|
Activator = new ViewModelActivator();
|
||||||
this.WhenActivated(disposables =>
|
this.WhenActivated(disposables =>
|
||||||
{
|
{
|
||||||
|
|
||||||
this.ValidationRule(x => x.ModListPath, p => p.FileExists(), "Wabbajack file must exist");
|
this.ValidationRule(x => x.ModListPath, p => p.FileExists(), "Wabbajack file must exist");
|
||||||
this.ValidationRule(x => x.Install, p => p.DirectoryExists(), "Install folder file must exist");
|
this.ValidationRule(x => x.Install, p => p.DirectoryExists(), "Install folder file must exist");
|
||||||
this.ValidationRule(x => x.Download, p => p != default, "Download folder must be set");
|
this.ValidationRule(x => x.Download, p => p != default, "Download folder must be set");
|
||||||
|
|
||||||
BeginCommand = ReactiveCommand.Create(() => {StartInstall().FireAndForget();}, this.IsValid());
|
BeginCommand = ReactiveCommand.Create(() => { StartInstall().FireAndForget(); }, this.IsValid());
|
||||||
|
|
||||||
|
|
||||||
this.WhenAnyValue(t => t.ModListPath)
|
this.WhenAnyValue(t => t.ModListPath)
|
||||||
@ -95,8 +70,27 @@ namespace Wabbajack.App.ViewModels
|
|||||||
.BindTo(this, vm => vm.Download)
|
.BindTo(this, vm => vm.Download)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Reactive] public AbsolutePath ModListPath { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public AbsolutePath Install { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public AbsolutePath Download { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public ModList? ModList { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public IBitmap? ModListImage { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public bool IsReady { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public ReactiveCommand<Unit, Unit> BeginCommand { get; set; }
|
||||||
|
|
||||||
|
public ViewModelActivator Activator { get; }
|
||||||
|
|
||||||
|
public void Receive(StartInstallConfiguration val)
|
||||||
|
{
|
||||||
|
ModListPath = val.ModList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task StartInstall()
|
private async Task StartInstall()
|
||||||
@ -104,9 +98,7 @@ namespace Wabbajack.App.ViewModels
|
|||||||
ModlistMetadata? metadata = null;
|
ModlistMetadata? metadata = null;
|
||||||
var metadataPath = ModListPath.WithExtension(Ext.MetaData);
|
var metadataPath = ModListPath.WithExtension(Ext.MetaData);
|
||||||
if (metadataPath.FileExists())
|
if (metadataPath.FileExists())
|
||||||
{
|
|
||||||
metadata = _dtos.Deserialize<ModlistMetadata>(await metadataPath.ReadAllTextAsync());
|
metadata = _dtos.Deserialize<ModlistMetadata>(await metadataPath.ReadAllTextAsync());
|
||||||
}
|
|
||||||
|
|
||||||
_stateManager.SetLastState(new InstallationConfigurationSetting
|
_stateManager.SetLastState(new InstallationConfigurationSetting
|
||||||
{
|
{
|
||||||
@ -127,15 +119,7 @@ namespace Wabbajack.App.ViewModels
|
|||||||
|
|
||||||
private async Task<ModList> LoadModList(AbsolutePath modlist)
|
private async Task<ModList> LoadModList(AbsolutePath modlist)
|
||||||
{
|
{
|
||||||
var definition= await StandardInstaller.LoadFromFile(_dtos, modlist);
|
var definition = await StandardInstaller.LoadFromFile(_dtos, modlist);
|
||||||
return definition;
|
return definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ViewModelActivator Activator { get; }
|
|
||||||
|
|
||||||
public void Receive(StartInstallConfiguration val)
|
|
||||||
{
|
|
||||||
ModListPath = val.ModList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,20 +1,15 @@
|
|||||||
using System;
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using CefNet;
|
|
||||||
using JetBrains.Annotations;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Wabbajack.DTOs.Logins;
|
using Wabbajack.DTOs.Logins;
|
||||||
using Wabbajack.Services.OSIntegrated;
|
|
||||||
using Wabbajack.Services.OSIntegrated.TokenProviders;
|
using Wabbajack.Services.OSIntegrated.TokenProviders;
|
||||||
|
|
||||||
namespace Wabbajack.App.ViewModels
|
namespace Wabbajack.App.ViewModels;
|
||||||
|
|
||||||
|
public class LoversLabOAuthLoginViewModel : OAuthLoginViewModel<LoversLabLoginState>
|
||||||
{
|
{
|
||||||
public class LoversLabOAuthLoginViewModel : OAuthLoginViewModel<LoversLabLoginState>
|
|
||||||
{
|
|
||||||
public LoversLabOAuthLoginViewModel(ILogger<LoversLabOAuthLoginViewModel> logger, HttpClient client,
|
public LoversLabOAuthLoginViewModel(ILogger<LoversLabOAuthLoginViewModel> logger, HttpClient client,
|
||||||
LoversLabTokenProvider tokenProvider)
|
LoversLabTokenProvider tokenProvider)
|
||||||
: base(logger, client, tokenProvider)
|
: base(logger, client, tokenProvider)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -8,7 +8,6 @@ using System.Reactive.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using ReactiveUI.Validation.Helpers;
|
using ReactiveUI.Validation.Helpers;
|
||||||
@ -21,36 +20,20 @@ using Wabbajack.Common;
|
|||||||
using Wabbajack.Paths.IO;
|
using Wabbajack.Paths.IO;
|
||||||
using Wabbajack.RateLimiter;
|
using Wabbajack.RateLimiter;
|
||||||
|
|
||||||
namespace Wabbajack.App.ViewModels
|
namespace Wabbajack.App.ViewModels;
|
||||||
|
|
||||||
|
public class MainWindowViewModel : ReactiveValidationObject, IActivatableViewModel, IReceiver<NavigateTo>,
|
||||||
|
IReceiver<NavigateBack>
|
||||||
{
|
{
|
||||||
public class MainWindowViewModel : ReactiveValidationObject, IActivatableViewModel, IReceiver<NavigateTo>, IReceiver<NavigateBack>
|
|
||||||
{
|
|
||||||
private readonly IEnumerable<IScreenView> _screens;
|
|
||||||
private readonly IServiceProvider _provider;
|
|
||||||
private readonly IResource[] _resources;
|
|
||||||
private StatusReport[] _prevReport;
|
|
||||||
private readonly Task _resourcePoller;
|
|
||||||
private readonly InstallationStateManager _manager;
|
private readonly InstallationStateManager _manager;
|
||||||
|
private readonly IServiceProvider _provider;
|
||||||
|
private readonly Task _resourcePoller;
|
||||||
|
private readonly IResource[] _resources;
|
||||||
|
private readonly IEnumerable<IScreenView> _screens;
|
||||||
|
private StatusReport[] _prevReport;
|
||||||
|
|
||||||
[Reactive]
|
public MainWindowViewModel(IEnumerable<IScreenView> screens, IEnumerable<IResource> resources,
|
||||||
public Control CurrentScreen { get; set; }
|
IServiceProvider provider,
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
private ImmutableStack<Control> BreadCrumbs { get; set; } = ImmutableStack<Control>.Empty;
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public ReactiveCommand<Unit, Unit> BackButton { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public ReactiveCommand<Unit, Unit> SettingsButton { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public ReactiveCommand<Unit, Unit> LogViewButton { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public string ResourceStatus { get; set; }
|
|
||||||
|
|
||||||
public MainWindowViewModel(IEnumerable<IScreenView> screens, IEnumerable<IResource> resources, IServiceProvider provider,
|
|
||||||
InstallationStateManager manager)
|
InstallationStateManager manager)
|
||||||
{
|
{
|
||||||
_provider = provider;
|
_provider = provider;
|
||||||
@ -66,31 +49,50 @@ namespace Wabbajack.App.ViewModels
|
|||||||
|
|
||||||
this.WhenActivated(disposables =>
|
this.WhenActivated(disposables =>
|
||||||
{
|
{
|
||||||
BackButton = ReactiveCommand.Create(() =>
|
BackButton = ReactiveCommand.Create(() => { Receive(new NavigateBack()); },
|
||||||
{
|
|
||||||
Receive(new NavigateBack());
|
|
||||||
},
|
|
||||||
this.ObservableForProperty(vm => vm.BreadCrumbs)
|
this.ObservableForProperty(vm => vm.BreadCrumbs)
|
||||||
.Select(bc => bc.Value.Count() > 1))
|
.Select(bc => bc.Value.Count() > 1))
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
SettingsButton = ReactiveCommand.Create(() =>
|
SettingsButton = ReactiveCommand.Create(() => { Receive(new NavigateTo(typeof(SettingsViewModel))); })
|
||||||
{
|
|
||||||
Receive(new NavigateTo(typeof(SettingsViewModel)));
|
|
||||||
})
|
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
LogViewButton = ReactiveCommand.Create(() =>
|
LogViewButton = ReactiveCommand.Create(() => { Receive(new NavigateTo(typeof(LogScreenViewModel))); })
|
||||||
{
|
|
||||||
Receive(new NavigateTo(typeof(LogScreenViewModel)));
|
|
||||||
})
|
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
});
|
});
|
||||||
CurrentScreen = (Control)_screens.First(s => s.ViewModelType == typeof(ModeSelectionViewModel));
|
CurrentScreen = (Control) _screens.First(s => s.ViewModelType == typeof(ModeSelectionViewModel));
|
||||||
|
|
||||||
LoadFirstScreen().FireAndForget();
|
LoadFirstScreen().FireAndForget();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Reactive] public Control CurrentScreen { get; set; }
|
||||||
|
|
||||||
|
[Reactive] private ImmutableStack<Control> BreadCrumbs { get; set; } = ImmutableStack<Control>.Empty;
|
||||||
|
|
||||||
|
[Reactive] public ReactiveCommand<Unit, Unit> BackButton { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public ReactiveCommand<Unit, Unit> SettingsButton { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public ReactiveCommand<Unit, Unit> LogViewButton { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public string ResourceStatus { get; set; }
|
||||||
|
|
||||||
|
public ViewModelActivator Activator { get; }
|
||||||
|
|
||||||
|
public void Receive(NavigateBack val)
|
||||||
|
{
|
||||||
|
CurrentScreen = BreadCrumbs.Peek();
|
||||||
|
BreadCrumbs = BreadCrumbs.Pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Receive(NavigateTo val)
|
||||||
|
{
|
||||||
|
BreadCrumbs = BreadCrumbs.Push(CurrentScreen);
|
||||||
|
|
||||||
|
if (val.ViewModel.IsAssignableTo(typeof(GuidedWebViewModel)))
|
||||||
|
CurrentScreen = new GuidedWebView {ViewModel = (GuidedWebViewModel) _provider.GetService(val.ViewModel)!};
|
||||||
|
else
|
||||||
|
CurrentScreen = (Control) _screens.First(s => s.ViewModelType == val.ViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task LoadFirstScreen()
|
private async Task LoadFirstScreen()
|
||||||
@ -99,7 +101,7 @@ namespace Wabbajack.App.ViewModels
|
|||||||
if (setting.Install != default && setting.Install.DirectoryExists())
|
if (setting.Install != default && setting.Install.DirectoryExists())
|
||||||
{
|
{
|
||||||
BreadCrumbs =
|
BreadCrumbs =
|
||||||
BreadCrumbs.Push((Control)_screens.First(s => s.ViewModelType == typeof(ModeSelectionViewModel)));
|
BreadCrumbs.Push((Control) _screens.First(s => s.ViewModelType == typeof(ModeSelectionViewModel)));
|
||||||
|
|
||||||
MessageBus.Instance.Send(new ConfigureLauncher(setting.Install));
|
MessageBus.Instance.Send(new ConfigureLauncher(setting.Install));
|
||||||
Receive(new NavigateTo(typeof(LauncherViewModel)));
|
Receive(new NavigateTo(typeof(LauncherViewModel)));
|
||||||
@ -125,11 +127,9 @@ namespace Wabbajack.App.ViewModels
|
|||||||
{
|
{
|
||||||
var throughput = next.Transferred - prev.Transferred;
|
var throughput = next.Transferred - prev.Transferred;
|
||||||
if (throughput != 0)
|
if (throughput != 0)
|
||||||
{
|
|
||||||
sb.Append(
|
sb.Append(
|
||||||
$"{limiter.Name}: [{next.Running}/{next.Pending + next.Running}] {throughput.ToFileSizeString()}/sec ");
|
$"{limiter.Name}: [{next.Running}/{next.Pending + next.Running}] {throughput.ToFileSizeString()}/sec ");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ResourceStatus = sb.ToString();
|
ResourceStatus = sb.ToString();
|
||||||
_prevReport = report;
|
_prevReport = report;
|
||||||
@ -137,26 +137,4 @@ namespace Wabbajack.App.ViewModels
|
|||||||
await Task.Delay(TimeSpan.FromSeconds(0.5));
|
await Task.Delay(TimeSpan.FromSeconds(0.5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ViewModelActivator Activator { get; }
|
|
||||||
public void Receive(NavigateTo val)
|
|
||||||
{
|
|
||||||
BreadCrumbs = BreadCrumbs.Push(CurrentScreen);
|
|
||||||
|
|
||||||
if (val.ViewModel.IsAssignableTo(typeof(GuidedWebViewModel)))
|
|
||||||
{
|
|
||||||
CurrentScreen = new GuidedWebView() { ViewModel = (GuidedWebViewModel)_provider.GetService(val.ViewModel)! };
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CurrentScreen = (Control)_screens.First(s => s.ViewModelType == val.ViewModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Receive(NavigateBack val)
|
|
||||||
{
|
|
||||||
CurrentScreen = BreadCrumbs.Peek();
|
|
||||||
BreadCrumbs = BreadCrumbs.Pop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,14 +1,11 @@
|
|||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
|
||||||
|
|
||||||
namespace Wabbajack.App.ViewModels
|
namespace Wabbajack.App.ViewModels;
|
||||||
|
|
||||||
|
public class ModeSelectionViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
public class ModeSelectionViewModel : ViewModelBase
|
|
||||||
{
|
|
||||||
public ModeSelectionViewModel()
|
public ModeSelectionViewModel()
|
||||||
{
|
{
|
||||||
Activator = new ViewModelActivator();
|
Activator = new ViewModelActivator();
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,10 +9,10 @@ using Wabbajack.App.Messages;
|
|||||||
using Wabbajack.DTOs.Logins;
|
using Wabbajack.DTOs.Logins;
|
||||||
using Wabbajack.Services.OSIntegrated.TokenProviders;
|
using Wabbajack.Services.OSIntegrated.TokenProviders;
|
||||||
|
|
||||||
namespace Wabbajack.App.ViewModels
|
namespace Wabbajack.App.ViewModels;
|
||||||
|
|
||||||
|
public class NexusLoginViewModel : GuidedWebViewModel
|
||||||
{
|
{
|
||||||
public class NexusLoginViewModel : GuidedWebViewModel
|
|
||||||
{
|
|
||||||
private readonly NexusApiTokenProvider _tokenProvider;
|
private readonly NexusApiTokenProvider _tokenProvider;
|
||||||
|
|
||||||
public NexusLoginViewModel(ILogger<NexusLoginViewModel> logger, NexusApiTokenProvider tokenProvider) : base(logger)
|
public NexusLoginViewModel(ILogger<NexusLoginViewModel> logger, NexusApiTokenProvider tokenProvider) : base(logger)
|
||||||
@ -28,10 +28,11 @@ namespace Wabbajack.App.ViewModels
|
|||||||
|
|
||||||
await Browser.WaitForReady();
|
await Browser.WaitForReady();
|
||||||
|
|
||||||
await Browser.NavigateTo(new Uri("https://users.nexusmods.com/auth/continue?client_id=nexus&redirect_uri=https://www.nexusmods.com/oauth/callback&response_type=code&referrer=//www.nexusmods.com"));
|
await Browser.NavigateTo(new Uri(
|
||||||
|
"https://users.nexusmods.com/auth/continue?client_id=nexus&redirect_uri=https://www.nexusmods.com/oauth/callback&response_type=code&referrer=//www.nexusmods.com"));
|
||||||
|
|
||||||
|
|
||||||
Cookie[] cookies = {};
|
Cookie[] cookies = { };
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
cookies = await Browser.Cookies("nexusmods.com", token);
|
cookies = await Browser.Cookies("nexusmods.com", token);
|
||||||
@ -50,7 +51,6 @@ namespace Wabbajack.App.ViewModels
|
|||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
key = (await Browser.GetDom(token))
|
key = (await Browser.GetDom(token))
|
||||||
@ -78,8 +78,6 @@ namespace Wabbajack.App.ViewModels
|
|||||||
"found.remove(); found = undefined;"
|
"found.remove(); found = undefined;"
|
||||||
);
|
);
|
||||||
Instructions = "Generating API Key, Please Wait...";
|
Instructions = "Generating API Key, Please Wait...";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@ -90,7 +88,6 @@ namespace Wabbajack.App.ViewModels
|
|||||||
await Task.Delay(500, token);
|
await Task.Delay(500, token);
|
||||||
|
|
||||||
MessageBus.Instance.Send(new NavigateBack());
|
MessageBus.Instance.Send(new NavigateBack());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Instructions = "Success, saving information...";
|
Instructions = "Success, saving information...";
|
||||||
@ -99,7 +96,5 @@ namespace Wabbajack.App.ViewModels
|
|||||||
Cookies = cookies,
|
Cookies = cookies,
|
||||||
ApiKey = key
|
ApiKey = key
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,53 +12,20 @@ using Wabbajack.App.Extensions;
|
|||||||
using Wabbajack.DTOs.Logins;
|
using Wabbajack.DTOs.Logins;
|
||||||
using Wabbajack.Services.OSIntegrated;
|
using Wabbajack.Services.OSIntegrated;
|
||||||
|
|
||||||
namespace Wabbajack.App.ViewModels
|
namespace Wabbajack.App.ViewModels;
|
||||||
{
|
|
||||||
public abstract class OAuthLoginViewModel<TLoginType> : GuidedWebViewModel
|
public abstract class OAuthLoginViewModel<TLoginType> : GuidedWebViewModel
|
||||||
where TLoginType : OAuth2LoginState, new()
|
where TLoginType : OAuth2LoginState, new()
|
||||||
{
|
{
|
||||||
private readonly HttpClient _httpClient;
|
private readonly HttpClient _httpClient;
|
||||||
private readonly EncryptedJsonTokenProvider<TLoginType> _tokenProvider;
|
private readonly EncryptedJsonTokenProvider<TLoginType> _tokenProvider;
|
||||||
|
|
||||||
public OAuthLoginViewModel(ILogger logger, HttpClient httpClient, EncryptedJsonTokenProvider<TLoginType> tokenProvider) : base(logger)
|
public OAuthLoginViewModel(ILogger logger, HttpClient httpClient,
|
||||||
|
EncryptedJsonTokenProvider<TLoginType> tokenProvider) : base(logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
_tokenProvider = tokenProvider;
|
_tokenProvider = tokenProvider;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class AsyncSchemeHandler : CefSchemeHandlerFactory
|
|
||||||
{
|
|
||||||
private TaskCompletionSource<Uri> _tcs = new();
|
|
||||||
public Task<Uri> Task => _tcs.Task;
|
|
||||||
|
|
||||||
public AsyncSchemeHandler()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override CefResourceHandler Create(CefBrowser browser, CefFrame frame, string schemeName,
|
|
||||||
CefRequest request)
|
|
||||||
{
|
|
||||||
return new Handler(_tcs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class Handler : CefResourceHandler
|
|
||||||
{
|
|
||||||
private readonly TaskCompletionSource<Uri> _tcs;
|
|
||||||
|
|
||||||
public Handler(TaskCompletionSource<Uri> tcs)
|
|
||||||
{
|
|
||||||
_tcs = tcs;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool ProcessRequest(CefRequest request, CefCallback callback)
|
|
||||||
{
|
|
||||||
_tcs.TrySetResult(new Uri(request.Url));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task Run(CancellationToken token)
|
public override async Task Run(CancellationToken token)
|
||||||
@ -107,7 +74,8 @@ namespace Wabbajack.App.ViewModels
|
|||||||
var msg = new HttpRequestMessage();
|
var msg = new HttpRequestMessage();
|
||||||
msg.Method = HttpMethod.Post;
|
msg.Method = HttpMethod.Post;
|
||||||
msg.RequestUri = tlogin.TokenEndpoint;
|
msg.RequestUri = tlogin.TokenEndpoint;
|
||||||
msg.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36");
|
msg.Headers.Add("User-Agent",
|
||||||
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36");
|
||||||
msg.Headers.Add("Cookie", string.Join(";", cookies.Select(c => $"{c.Name}={c.Value}")));
|
msg.Headers.Add("Cookie", string.Join(";", cookies.Select(c => $"{c.Name}={c.Value}")));
|
||||||
msg.Content = new FormUrlEncodedContent(formData.ToList());
|
msg.Content = new FormUrlEncodedContent(formData.ToList());
|
||||||
|
|
||||||
@ -119,11 +87,34 @@ namespace Wabbajack.App.ViewModels
|
|||||||
Cookies = cookies,
|
Cookies = cookies,
|
||||||
ResultState = data!
|
ResultState = data!
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class AsyncSchemeHandler : CefSchemeHandlerFactory
|
||||||
|
{
|
||||||
|
private readonly TaskCompletionSource<Uri> _tcs = new();
|
||||||
|
|
||||||
|
public Task<Uri> Task => _tcs.Task;
|
||||||
|
|
||||||
|
protected override CefResourceHandler Create(CefBrowser browser, CefFrame frame, string schemeName,
|
||||||
|
CefRequest request)
|
||||||
|
{
|
||||||
|
return new Handler(_tcs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class Handler : CefResourceHandler
|
||||||
|
{
|
||||||
|
private readonly TaskCompletionSource<Uri> _tcs;
|
||||||
|
|
||||||
|
public Handler(TaskCompletionSource<Uri> tcs)
|
||||||
|
{
|
||||||
|
_tcs = tcs;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool ProcessRequest(CefRequest request, CefCallback callback)
|
||||||
|
{
|
||||||
|
_tcs.TrySetResult(new Uri(request.Url));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -8,37 +8,30 @@ using ReactiveUI;
|
|||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using Wabbajack.DTOs.DownloadStates;
|
using Wabbajack.DTOs.DownloadStates;
|
||||||
|
|
||||||
namespace Wabbajack.App.ViewModels.SubViewModels
|
namespace Wabbajack.App.ViewModels.SubViewModels;
|
||||||
|
|
||||||
|
public class SlideViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
public class SlideViewModel : ViewModelBase
|
|
||||||
{
|
|
||||||
[Reactive]
|
|
||||||
public IMetaState MetaState { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
|
||||||
public IImage? Image { get; set; }
|
|
||||||
|
|
||||||
public bool Loading { get; set; } = false;
|
|
||||||
|
|
||||||
public SlideViewModel()
|
public SlideViewModel()
|
||||||
{
|
{
|
||||||
Activator = new ViewModelActivator();
|
Activator = new ViewModelActivator();
|
||||||
Image = null;
|
Image = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Reactive] public IMetaState MetaState { get; set; }
|
||||||
|
|
||||||
|
[Reactive] public IImage? Image { get; set; }
|
||||||
|
|
||||||
|
public bool Loading { get; set; }
|
||||||
|
|
||||||
public async Task PreCache(HttpClient client)
|
public async Task PreCache(HttpClient client)
|
||||||
{
|
{
|
||||||
Loading = true;
|
Loading = true;
|
||||||
var url = await client.GetByteArrayAsync(MetaState.ImageURL);
|
var url = await client.GetByteArrayAsync(MetaState.ImageURL);
|
||||||
var img = new Bitmap(new MemoryStream(url));
|
var img = new Bitmap(new MemoryStream(url));
|
||||||
|
|
||||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
await Dispatcher.UIThread.InvokeAsync(() => { Image = img; });
|
||||||
{
|
|
||||||
Image = img;
|
|
||||||
});
|
|
||||||
|
|
||||||
Loading = false;
|
Loading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user