mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Bind the UI to AlwaysEnable
This commit is contained in:
parent
88cdebccda
commit
f4f4b80968
@ -30,14 +30,8 @@ public class LogViewModel : ViewModelBase, IActivatableViewModel
|
|||||||
.Bind(out _messagesFiltered)
|
.Bind(out _messagesFiltered)
|
||||||
.Subscribe();
|
.Subscribe();
|
||||||
|
|
||||||
this.WhenActivated(disposables =>
|
_provider.Messages
|
||||||
{
|
.Subscribe(m => _messages.AddOrUpdate(m));
|
||||||
_provider.Messages
|
|
||||||
.Subscribe(m => _messages.AddOrUpdate(m))
|
|
||||||
.DisposeWith(disposables);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
14
Wabbajack.App/Controls/RemovableListItem.axaml
Normal file
14
Wabbajack.App/Controls/RemovableListItem.axaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:i="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="Wabbajack.App.Controls.RemovableListItem">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<Button x:Name="DeleteButton">
|
||||||
|
<i:MaterialIcon Kind="MinusCircle"></i:MaterialIcon>
|
||||||
|
</Button>
|
||||||
|
<TextBlock x:Name="Text"></TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
</UserControl>
|
24
Wabbajack.App/Controls/RemovableListItem.axaml.cs
Normal file
24
Wabbajack.App/Controls/RemovableListItem.axaml.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using Avalonia.Controls.Mixins;
|
||||||
|
using Avalonia.ReactiveUI;
|
||||||
|
using ReactiveUI;
|
||||||
|
using Wabbajack.App.ViewModels;
|
||||||
|
|
||||||
|
namespace Wabbajack.App.Controls;
|
||||||
|
|
||||||
|
public partial class RemovableListItem : ReactiveUserControl<RemovableItemViewModel>, IActivatableView
|
||||||
|
{
|
||||||
|
public RemovableListItem()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.WhenActivated(disposables =>
|
||||||
|
{
|
||||||
|
this.OneWayBind(ViewModel, vm => vm.Text, view => view.Text.Text)
|
||||||
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
|
this.BindCommand(ViewModel, vm => vm.DeleteCommand, view => view.DeleteButton)
|
||||||
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
22
Wabbajack.App/Controls/RemovableListItemViewModel.cs
Normal file
22
Wabbajack.App/Controls/RemovableListItemViewModel.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Reactive;
|
||||||
|
using ReactiveUI;
|
||||||
|
using ReactiveUI.Fody.Helpers;
|
||||||
|
using Wabbajack.App.ViewModels;
|
||||||
|
|
||||||
|
namespace Wabbajack.App.Controls;
|
||||||
|
|
||||||
|
public class RemovableItemViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
[Reactive]
|
||||||
|
public string Text { get; set; }
|
||||||
|
|
||||||
|
[Reactive]
|
||||||
|
public ReactiveCommand<Unit, Unit> DeleteCommand { get; set; }
|
||||||
|
|
||||||
|
public RemovableItemViewModel()
|
||||||
|
{
|
||||||
|
Activator = new ViewModelActivator();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@
|
|||||||
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" 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"></TextBox>
|
||||||
<Label Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right">Settings File:</Label>
|
<Label Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right">Settings File:</Label>
|
||||||
@ -27,6 +27,29 @@
|
|||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ComboBox.ItemTemplate>
|
</ComboBox.ItemTemplate>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<Label Grid.Column="0" Grid.Row="6" HorizontalAlignment="Right" VerticalAlignment="Top">Always Enabled:</Label>
|
||||||
|
<StackPanel Grid.Column="1" Grid.Row="6" Orientation="Vertical">
|
||||||
|
<Button x:Name="AddAlwaysEnabled">
|
||||||
|
<i:MaterialIcon Kind="AddCircle"></i:MaterialIcon>
|
||||||
|
</Button>
|
||||||
|
<ItemsControl x:Name="AlwaysEnabledList">
|
||||||
|
<ItemsControl.ItemsPanel>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<StackPanel Orientation="Vertical"></StackPanel>
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</ItemsControl.ItemsPanel>
|
||||||
|
<ItemsControl.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<controls:RemovableListItem></controls:RemovableListItem>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
</ItemsControl>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid ColumnDefinitions="*, Auto" Grid.Row="2">
|
<Grid ColumnDefinitions="*, Auto" Grid.Row="2">
|
||||||
<Button Grid.Column="1" x:Name="StartCompilation">
|
<Button Grid.Column="1" x:Name="StartCompilation">
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
|
using System.Linq;
|
||||||
|
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
using Wabbajack.App.Controls;
|
||||||
using Wabbajack.App.Views;
|
using Wabbajack.App.Views;
|
||||||
|
using Wabbajack.Common;
|
||||||
|
using Wabbajack.Paths;
|
||||||
|
|
||||||
namespace Wabbajack.App.Screens
|
namespace Wabbajack.App.Screens
|
||||||
{
|
{
|
||||||
@ -12,18 +16,22 @@ namespace Wabbajack.App.Screens
|
|||||||
public CompilerConfigurationView()
|
public CompilerConfigurationView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
AddAlwaysEnabled.Command = ReactiveCommand.Create(() => AddAlwaysEnabled_Command().FireAndForget());
|
||||||
|
|
||||||
this.WhenActivated(disposables =>
|
this.WhenActivated(disposables =>
|
||||||
{
|
{
|
||||||
|
|
||||||
this.Bind(ViewModel, vm => vm.BasePath, view => view.BaseFolder.SelectedPath)
|
this.Bind(ViewModel, vm => vm.BasePath, view => view.BaseFolder.SelectedPath)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
this.Bind(ViewModel, vm => vm.SettingsFile, view => view.SettingsFile.SelectedPath)
|
this.Bind(ViewModel, vm => vm.SettingsFile, view => view.SettingsFile.SelectedPath)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
this.Bind(ViewModel, vm => vm.Downloads, view => view.DownloadsFolder.SelectedPath)
|
this.Bind(ViewModel, vm => vm.Downloads, view => view.DownloadsFolder.SelectedPath)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
|
this.Bind(ViewModel, vm => vm.OutputFolder, view => view.OutputFolder.SelectedPath)
|
||||||
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
this.OneWayBind(ViewModel, vm => vm.AllGames, view => view.BaseGame.Items)
|
this.OneWayBind(ViewModel, vm => vm.AllGames, view => view.BaseGame.Items)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
@ -33,8 +41,25 @@ namespace Wabbajack.App.Screens
|
|||||||
this.BindCommand(ViewModel, vm => vm.StartCompilation, view => view.StartCompilation)
|
this.BindCommand(ViewModel, vm => vm.StartCompilation, view => view.StartCompilation)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
|
|
||||||
|
this.OneWayBind(ViewModel, vm => vm.AlwaysEnabled, view => view.AlwaysEnabledList.Items,
|
||||||
|
d => d!.Select(itm => new RemovableItemViewModel()
|
||||||
|
{
|
||||||
|
Text = itm.ToString(),
|
||||||
|
DeleteCommand = ReactiveCommand.Create(() => { ViewModel?.RemoveAlwaysExcluded(itm); })
|
||||||
|
}))
|
||||||
|
.DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task AddAlwaysEnabled_Command()
|
||||||
|
{
|
||||||
|
var dialog = new OpenFolderDialog()
|
||||||
|
{
|
||||||
|
Title = "Select a folder",
|
||||||
|
};
|
||||||
|
var result = await dialog.ShowAsync(App.MainWindow);
|
||||||
|
if (!string.IsNullOrWhiteSpace(result))
|
||||||
|
ViewModel!.AddAlwaysExcluded(result.ToAbsolutePath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,14 +1,17 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Avalonia.Controls.Mixins;
|
using Avalonia.Controls.Mixins;
|
||||||
|
using DynamicData;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using Wabbajack.App.Extensions;
|
using Wabbajack.App.Extensions;
|
||||||
using Wabbajack.App.Messages;
|
using Wabbajack.App.Messages;
|
||||||
using Wabbajack.App.ViewModels;
|
using Wabbajack.App.ViewModels;
|
||||||
|
using Wabbajack.Common;
|
||||||
using Wabbajack.Compiler;
|
using Wabbajack.Compiler;
|
||||||
using Wabbajack.DTOs;
|
using Wabbajack.DTOs;
|
||||||
using Wabbajack.Installer;
|
using Wabbajack.Installer;
|
||||||
@ -38,12 +41,18 @@ public class CompilerConfigurationViewModel : ViewModelBase, IReceiverMarker
|
|||||||
[Reactive]
|
[Reactive]
|
||||||
public string SelectedProfile { get; set; }
|
public string SelectedProfile { get; set; }
|
||||||
|
|
||||||
|
[Reactive]
|
||||||
|
public AbsolutePath OutputFolder { get; set; }
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public IEnumerable<GameMetaData> AllGames { get; set; }
|
public IEnumerable<GameMetaData> AllGames { get; set; }
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public ReactiveCommand<Unit, Unit> StartCompilation { get; set; }
|
public ReactiveCommand<Unit, Unit> StartCompilation { get; set; }
|
||||||
|
|
||||||
|
[Reactive]
|
||||||
|
public IEnumerable<RelativePath> AlwaysEnabled { get; set; } = Array.Empty<RelativePath>();
|
||||||
|
|
||||||
|
|
||||||
public CompilerConfigurationViewModel()
|
public CompilerConfigurationViewModel()
|
||||||
{
|
{
|
||||||
@ -52,6 +61,8 @@ public class CompilerConfigurationViewModel : ViewModelBase, IReceiverMarker
|
|||||||
AllGames = GameRegistry.Games.Values.ToArray();
|
AllGames = GameRegistry.Games.Values.ToArray();
|
||||||
|
|
||||||
StartCompilation = ReactiveCommand.Create(() => BeginCompilation());
|
StartCompilation = ReactiveCommand.Create(() => BeginCompilation());
|
||||||
|
|
||||||
|
OutputFolder = KnownFolders.EntryPoint;
|
||||||
|
|
||||||
this.WhenActivated(disposables =>
|
this.WhenActivated(disposables =>
|
||||||
{
|
{
|
||||||
@ -88,7 +99,9 @@ public class CompilerConfigurationViewModel : ViewModelBase, IReceiverMarker
|
|||||||
Source = BasePath,
|
Source = BasePath,
|
||||||
Game = BaseGame.Game,
|
Game = BaseGame.Game,
|
||||||
Profile = SelectedProfile,
|
Profile = SelectedProfile,
|
||||||
UseGamePaths = true
|
UseGamePaths = true,
|
||||||
|
OutputFile = OutputFolder.Combine(SelectedProfile).WithExtension(Ext.Wabbajack),
|
||||||
|
AlwaysEnabled = AlwaysEnabled.ToArray()
|
||||||
};
|
};
|
||||||
|
|
||||||
MessageBus.Instance.Send(new StartCompilation(settings));
|
MessageBus.Instance.Send(new StartCompilation(settings));
|
||||||
@ -125,5 +138,18 @@ public class CompilerConfigurationViewModel : ViewModelBase, IReceiverMarker
|
|||||||
|
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool AddAlwaysExcluded(AbsolutePath path)
|
||||||
|
{
|
||||||
|
if (!path.InFolder(BasePath)) return false;
|
||||||
|
var relative = path.RelativeTo(BasePath);
|
||||||
|
AlwaysEnabled = AlwaysEnabled.Append(relative).Distinct().ToArray();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveAlwaysExcluded(RelativePath path)
|
||||||
|
{
|
||||||
|
AlwaysEnabled = AlwaysEnabled.Where(p => p != path).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -5,5 +5,6 @@ namespace Wabbajack.Compiler
|
|||||||
public class MO2CompilerSettings : CompilerSettings
|
public class MO2CompilerSettings : CompilerSettings
|
||||||
{
|
{
|
||||||
public string Profile { get; set; }
|
public string Profile { get; set; }
|
||||||
|
public RelativePath[] AlwaysEnabled { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user