mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
09349ebeb8
@ -10,7 +10,7 @@
|
||||
<PackageReference Include="Genbox.AlphaFS" Version="2.2.2.1" />
|
||||
<PackageReference Include="K4os.Compression.LZ4.Streams" Version="1.1.11" />
|
||||
<PackageReference Include="SharpZipLib" Version="1.2.0" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.7.0" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.7.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
|
@ -1,58 +1,65 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
public class IncludeThisProfile : ACompilationStep
|
||||
{
|
||||
private readonly IEnumerable<AbsolutePath> _correctProfiles;
|
||||
private MO2Compiler _mo2Compiler;
|
||||
|
||||
public IncludeThisProfile(ACompiler compiler) : base(compiler)
|
||||
{
|
||||
_mo2Compiler = (MO2Compiler) compiler;
|
||||
_correctProfiles = _mo2Compiler.SelectedProfiles.Select(p => _mo2Compiler.MO2ProfileDir.Parent.Combine(p)).ToList();
|
||||
}
|
||||
|
||||
public override async ValueTask<Directive?> Run(RawSourceFile source)
|
||||
{
|
||||
if (!_correctProfiles.Any(p => source.AbsolutePath.InFolder(p)))
|
||||
return null;
|
||||
|
||||
var data = source.Path.FileName == Consts.ModListTxt
|
||||
? await ReadAndCleanModlist(source.AbsolutePath)
|
||||
: await source.AbsolutePath.ReadAllBytesAsync();
|
||||
|
||||
var e = source.EvolveTo<InlineFile>();
|
||||
e.SourceDataID = await _compiler.IncludeFile(data);
|
||||
return e;
|
||||
|
||||
}
|
||||
|
||||
public override IState GetState()
|
||||
{
|
||||
return new State();
|
||||
}
|
||||
|
||||
private static async Task<byte[]> ReadAndCleanModlist(AbsolutePath absolutePath)
|
||||
{
|
||||
var lines = await absolutePath.ReadAllLinesAsync();
|
||||
lines = lines.Where(line => !(line.StartsWith("-") && !line.EndsWith("_separator"))).ToArray();
|
||||
return Encoding.UTF8.GetBytes(string.Join("\r\n", lines));
|
||||
}
|
||||
|
||||
[JsonObject("IncludeThisProfile")]
|
||||
public class State : IState
|
||||
{
|
||||
public ICompilationStep CreateStep(ACompiler compiler)
|
||||
{
|
||||
return new IncludeThisProfile(compiler);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
public class IncludeThisProfile : ACompilationStep
|
||||
{
|
||||
private readonly IEnumerable<AbsolutePath> _correctProfiles;
|
||||
private MO2Compiler _mo2Compiler;
|
||||
|
||||
public IncludeThisProfile(ACompiler compiler) : base(compiler)
|
||||
{
|
||||
_mo2Compiler = (MO2Compiler) compiler;
|
||||
_correctProfiles = _mo2Compiler.SelectedProfiles.Select(p => _mo2Compiler.MO2ProfileDir.Parent.Combine(p)).ToList();
|
||||
}
|
||||
|
||||
public override async ValueTask<Directive?> Run(RawSourceFile source)
|
||||
{
|
||||
if (!_correctProfiles.Any(p => source.AbsolutePath.InFolder(p)))
|
||||
return null;
|
||||
|
||||
var data = source.Path.FileName == Consts.ModListTxt
|
||||
? await ReadAndCleanModlist(source.AbsolutePath)
|
||||
: await source.AbsolutePath.ReadAllBytesAsync();
|
||||
|
||||
var e = source.EvolveTo<InlineFile>();
|
||||
e.SourceDataID = await _compiler.IncludeFile(data);
|
||||
return e;
|
||||
|
||||
}
|
||||
|
||||
public override IState GetState()
|
||||
{
|
||||
return new State();
|
||||
}
|
||||
|
||||
private async Task<byte[]> ReadAndCleanModlist(AbsolutePath absolutePath)
|
||||
{
|
||||
var alwaysEnabled = _mo2Compiler.ModInis.Where(f => IgnoreDisabledMods.IsAlwaysEnabled(f.Value))
|
||||
.Select(f => f.Key)
|
||||
.Distinct();
|
||||
var lines = (await absolutePath.ReadAllLinesAsync()).Where(l =>
|
||||
{
|
||||
return l.StartsWith("+")
|
||||
|| alwaysEnabled.Any(x => x.Equals(l.Substring(1)))
|
||||
|| l.EndsWith("_separator");
|
||||
}).ToArray();
|
||||
return Encoding.UTF8.GetBytes(string.Join("\r\n", lines));
|
||||
}
|
||||
|
||||
[JsonObject("IncludeThisProfile")]
|
||||
public class State : IState
|
||||
{
|
||||
public ICompilationStep CreateStep(ACompiler compiler)
|
||||
{
|
||||
return new IncludeThisProfile(compiler);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@
|
||||
<Version>0.25.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Collections.Immutable">
|
||||
<Version>1.7.0</Version>
|
||||
<Version>1.7.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Drawing.Common">
|
||||
<Version>4.7.0</Version>
|
||||
@ -65,7 +65,7 @@
|
||||
<Version>1.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="YoutubeExplode">
|
||||
<Version>5.0.3</Version>
|
||||
<Version>5.0.4</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -18,7 +18,7 @@
|
||||
<PackageReference Include="Dapper" Version="2.0.35" />
|
||||
<PackageReference Include="FluentFTP" Version="32.4.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Core" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
|
||||
<PackageReference Include="Nettle" Version="1.3.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.4.1" />
|
||||
|
@ -13,7 +13,7 @@
|
||||
<PackageReference Include="Genbox.AlphaFS" Version="2.2.2.1" />
|
||||
<PackageReference Include="K4os.Hash.Crc" Version="1.1.4" />
|
||||
<PackageReference Include="OMODFramework" Version="2.0.0" />
|
||||
<PackageReference Include="System.Collections.Immutable" Version="1.7.0" />
|
||||
<PackageReference Include="System.Collections.Immutable" Version="1.7.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Update="Extractors\7z.dll">
|
||||
|
@ -21,6 +21,7 @@ namespace Wabbajack
|
||||
public double Height { get; set; }
|
||||
public double Width { get; set; }
|
||||
public InstallerSettings Installer { get; set; } = new InstallerSettings();
|
||||
public FiltersSettings Filters { get; set; } = new FiltersSettings();
|
||||
public CompilerSettings Compiler { get; set; } = new CompilerSettings();
|
||||
public PerformanceSettings Performance { get; set; } = new PerformanceSettings();
|
||||
|
||||
@ -93,6 +94,18 @@ namespace Wabbajack
|
||||
public AbsolutePath OutputLocation { get; set; }
|
||||
public MO2CompilationSettings MO2Compilation { get; } = new MO2CompilationSettings();
|
||||
}
|
||||
|
||||
[JsonName("FiltersSettings")]
|
||||
[JsonObject(MemberSerialization.OptOut)]
|
||||
public class FiltersSettings : ViewModel
|
||||
{
|
||||
public bool ShowNSFW { get; set; }
|
||||
public bool OnlyInstalled { get; set; }
|
||||
public string Game { get; set; }
|
||||
public string Search { get; set; }
|
||||
private bool _isPersistent = true;
|
||||
public bool IsPersistent { get => _isPersistent; set => RaiseAndSetIfChanged(ref _isPersistent, value); }
|
||||
}
|
||||
|
||||
[JsonName("PerformanceSettings")]
|
||||
[JsonObject(MemberSerialization.OptOut)]
|
||||
|
@ -26,8 +26,6 @@ namespace Wabbajack
|
||||
|
||||
private const string ALL_GAME_TYPE = "All";
|
||||
|
||||
public ICommand OnlyInstalledCheckedCommand { get; }
|
||||
|
||||
[Reactive]
|
||||
public IErrorResponse Error { get; set; }
|
||||
|
||||
@ -46,6 +44,9 @@ namespace Wabbajack
|
||||
public List<string> GameTypeEntries { get { return GetGameTypeEntries(); } }
|
||||
|
||||
private readonly ObservableAsPropertyHelper<bool> _Loaded;
|
||||
|
||||
private FiltersSettings settings => MWVM.Settings.Filters;
|
||||
|
||||
public bool Loaded => _Loaded.Value;
|
||||
|
||||
public ICommand ClearFiltersCommand { get; }
|
||||
@ -54,7 +55,22 @@ namespace Wabbajack
|
||||
: base(mainWindowVM)
|
||||
{
|
||||
MWVM = mainWindowVM;
|
||||
GameType = ALL_GAME_TYPE;
|
||||
|
||||
// load persistent filter settings
|
||||
if (settings.IsPersistent)
|
||||
{
|
||||
GameType = !string.IsNullOrEmpty(settings.Game) ? settings.Game : ALL_GAME_TYPE;
|
||||
ShowNSFW = settings.ShowNSFW;
|
||||
OnlyInstalled = settings.OnlyInstalled;
|
||||
Search = settings.Search;
|
||||
}
|
||||
else
|
||||
GameType = ALL_GAME_TYPE;
|
||||
|
||||
// subscribe to save signal
|
||||
MWVM.Settings.SaveSignal
|
||||
.Subscribe(_ => UpdateFiltersSettings())
|
||||
.DisposeWith(this.CompositeDisposable);
|
||||
|
||||
ClearFiltersCommand = ReactiveCommand.Create(
|
||||
() =>
|
||||
@ -65,6 +81,15 @@ namespace Wabbajack
|
||||
GameType = ALL_GAME_TYPE;
|
||||
});
|
||||
|
||||
|
||||
this.WhenAny(x => x.OnlyInstalled)
|
||||
.Subscribe(val =>
|
||||
{
|
||||
if(val)
|
||||
GameType = ALL_GAME_TYPE;
|
||||
})
|
||||
.DisposeWith(CompositeDisposable);
|
||||
|
||||
var random = new Random();
|
||||
var sourceList = Observable.Return(Unit.Default)
|
||||
.ObserveOn(RxApp.TaskpoolScheduler)
|
||||
@ -98,11 +123,6 @@ namespace Wabbajack
|
||||
.Select(c => c > 0)
|
||||
.ToProperty(this, nameof(Loaded));
|
||||
|
||||
OnlyInstalledCheckedCommand = ReactiveCommand.Create(() =>
|
||||
{
|
||||
GameType = ALL_GAME_TYPE;
|
||||
});
|
||||
|
||||
// Convert to VM and bind to resulting list
|
||||
sourceList
|
||||
.ObserveOnGuiThread()
|
||||
@ -137,7 +157,11 @@ namespace Wabbajack
|
||||
{
|
||||
if (GameType == ALL_GAME_TYPE)
|
||||
return true;
|
||||
return GameType == EnumExtensions.GetDescription<Game>(vm.Metadata.Game).ToString();
|
||||
if (string.IsNullOrEmpty(GameType))
|
||||
return false;
|
||||
|
||||
return GameType == vm.Metadata.Game.GetDescription<Game>().ToString();
|
||||
|
||||
}))
|
||||
.Filter(this.WhenAny(x => x.ShowNSFW)
|
||||
.Select<bool, Func<ModListMetadataVM, bool>>(showNSFW => vm =>
|
||||
@ -171,11 +195,16 @@ namespace Wabbajack
|
||||
private List<string> GetGameTypeEntries()
|
||||
{
|
||||
List<string> gameEntries = new List<string> { ALL_GAME_TYPE };
|
||||
foreach (var gameType in EnumExtensions.GetAllItems<Game>() )
|
||||
{
|
||||
gameEntries.Add(EnumExtensions.GetDescription<Game>(gameType));
|
||||
}
|
||||
gameEntries.AddRange(EnumExtensions.GetAllItems<Game>().Select(gameType => gameType.GetDescription<Game>()));
|
||||
return gameEntries;
|
||||
}
|
||||
|
||||
private void UpdateFiltersSettings()
|
||||
{
|
||||
settings.Game = GameType;
|
||||
settings.Search = Search;
|
||||
settings.ShowNSFW = ShowNSFW;
|
||||
settings.OnlyInstalled = OnlyInstalled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace Wabbajack
|
||||
public MainWindowVM MWVM { get; }
|
||||
public LoginManagerVM Login { get; }
|
||||
public PerformanceSettings Performance { get; }
|
||||
|
||||
public FiltersSettings Filters { get; }
|
||||
public AuthorFilesVM AuthorFile { get; }
|
||||
|
||||
public SettingsVM(MainWindowVM mainWindowVM)
|
||||
@ -23,6 +23,7 @@ namespace Wabbajack
|
||||
Login = new LoginManagerVM(this);
|
||||
Performance = mainWindowVM.Settings.Performance;
|
||||
AuthorFile = new AuthorFilesVM(this);
|
||||
Filters = mainWindowVM.Settings.Filters;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -108,6 +108,7 @@
|
||||
ItemsSource="{Binding Path=GameTypeEntries}"
|
||||
SelectedItem="{Binding GameType, Mode=TwoWay}"
|
||||
ToolTip="Select a game"
|
||||
IsEnabled="{Binding OnlyInstalled, Converter={StaticResource InverseBooleanConverter}}"
|
||||
Width="130" />
|
||||
<TextBlock
|
||||
Margin="0,0,5,0"
|
||||
@ -129,7 +130,6 @@
|
||||
Margin="10,0,10,0"
|
||||
VerticalAlignment="Center"
|
||||
Content="Only Installed"
|
||||
Command="{Binding OnlyInstalledCheckedCommand}"
|
||||
Foreground="{StaticResource ForegroundBrush}" />
|
||||
<Button
|
||||
x:Name="ClearFiltersButton"
|
||||
|
65
Wabbajack/Views/Settings/ModlistGallerySettingsView.xaml
Normal file
65
Wabbajack/Views/Settings/ModlistGallerySettingsView.xaml
Normal file
@ -0,0 +1,65 @@
|
||||
<rxui:ReactiveUserControl
|
||||
x:Class="Wabbajack.ModlistGallerySettingsView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Wabbajack"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:rxui="http://reactiveui.net"
|
||||
xmlns:xwpf="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
x:TypeArguments="local:FiltersSettings"
|
||||
mc:Ignorable="d">
|
||||
<Border
|
||||
x:Name="PerformanceView"
|
||||
MinWidth="280"
|
||||
Margin="5"
|
||||
Background="{StaticResource BackgroundBrush}"
|
||||
BorderBrush="{StaticResource ButtonNormalBorder}"
|
||||
BorderThickness="1">
|
||||
<Grid Margin="15,10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="10" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="25" />
|
||||
<RowDefinition Height="25" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
FontFamily="Lucida Sans"
|
||||
FontSize="20"
|
||||
FontWeight="Bold"
|
||||
Text="Modlist Gallery" />
|
||||
<Grid
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="3">
|
||||
<Grid.Resources>
|
||||
<Style BasedOn="{StaticResource MainButtonStyle}" TargetType="Button">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
|
||||
<Setter Property="Background" Value="{StaticResource SecondaryBackgroundBrush}" />
|
||||
<Setter Property="BorderBrush" Value="{StaticResource DarkSecondaryBrush}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Grid.Resources>
|
||||
<CheckBox Name="FilterPersistCheckBox" Content="Filters are saved on exit" HorizontalAlignment="Left" Margin="0,5,0,0" VerticalAlignment="Top">
|
||||
<CheckBox.LayoutTransform>
|
||||
<ScaleTransform ScaleX="1.2" ScaleY="1.2" />
|
||||
</CheckBox.LayoutTransform>
|
||||
</CheckBox>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
</rxui:ReactiveUserControl>
|
39
Wabbajack/Views/Settings/ModlistGallerySettingsView.xaml.cs
Normal file
39
Wabbajack/Views/Settings/ModlistGallerySettingsView.xaml.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using ReactiveUI;
|
||||
using Wabbajack.Common;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ModlistGallerySettingsView.xaml
|
||||
/// </summary>
|
||||
public partial class ModlistGallerySettingsView : ReactiveUserControl<FiltersSettings>
|
||||
{
|
||||
public ModlistGallerySettingsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.WhenActivated(disposable =>
|
||||
{
|
||||
// Bind Values
|
||||
this.Bind(this.ViewModel, x => x.IsPersistent, x => x.FilterPersistCheckBox.IsChecked)
|
||||
.DisposeWith(disposable);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -47,6 +47,7 @@
|
||||
<WrapPanel>
|
||||
<local:LoginSettingsView x:Name="LoginView" />
|
||||
<local:PerformanceSettingsView x:Name="PerformanceView" />
|
||||
<local:ModlistGallerySettingsView x:Name="ModlistGalleryView" />
|
||||
<local:AuthorFilesView x:Name="AuthorFilesView"></local:AuthorFilesView>
|
||||
</WrapPanel>
|
||||
</ScrollViewer>
|
||||
|
@ -34,6 +34,8 @@ namespace Wabbajack
|
||||
.DisposeWith(disposable);
|
||||
this.OneWayBindStrict(this.ViewModel, x => x.Performance, x => x.PerformanceView.ViewModel)
|
||||
.DisposeWith(disposable);
|
||||
this.OneWayBindStrict(this.ViewModel, x => x.Filters, x => x.ModlistGalleryView.ViewModel)
|
||||
.DisposeWith(disposable);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0775" />
|
||||
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0821" />
|
||||
<PackageReference Include="MahApps.Metro.IconPacks" Version="4.0.0" />
|
||||
<PackageReference Include="PInvoke.Gdi32" Version="0.6.6" />
|
||||
<PackageReference Include="PInvoke.User32" Version="0.6.6" />
|
||||
|
Loading…
Reference in New Issue
Block a user