A few compiler fixes

This commit is contained in:
Timothy Baldridge 2021-11-05 05:47:14 -06:00
parent 8e792e6092
commit b12d927839
4 changed files with 31 additions and 10 deletions

View File

@ -6,6 +6,8 @@ using System.Reactive.Subjects;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using ReactiveUI;
using Wabbajack.App.Controls;
using Wabbajack.Paths;
namespace Wabbajack.App.Extensions;
@ -40,4 +42,22 @@ public static class IObservableExtensions
return Disposable.Create(() => d.Dispose());
}
public static IDisposable BindFileSelectionBox<TViewModel>(this FileSelectionBox box, TViewModel viewModel,
Expression<Func<TViewModel, AbsolutePath>> vmProperty)
where TViewModel: class?
{
var disposables = new CompositeDisposable();
box.WhenAnyValue(view => view.SelectedPath)
.BindTo(viewModel, vmProperty)
.DisposeWith(disposables);
viewModel.WhenAnyValue(vmProperty)
.Where(p => p != default)
.Subscribe(box.Load)
.DisposeWith(disposables);
return disposables;
}
}

View File

@ -6,7 +6,7 @@
xmlns:i="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:controls="clr-namespace:Wabbajack.App.Controls"
x:Class="Wabbajack.App.Screens.CompilerConfigurationView">
<Grid RowDefinitions="40, *, 40">
<Grid RowDefinitions="40, *, 40" Margin="8">
<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">

View File

@ -7,6 +7,7 @@ using Avalonia.Interactivity;
using Avalonia.Threading;
using ReactiveUI;
using Wabbajack.App.Controls;
using Wabbajack.App.Extensions;
using Wabbajack.App.Views;
using Wabbajack.Common;
using Wabbajack.Paths;
@ -22,22 +23,19 @@ public partial class CompilerConfigurationView : ScreenBase<CompilerConfiguratio
this.WhenActivated(disposables =>
{
this.Bind(ViewModel, vm => vm.SettingsFile, view => view.SettingsFile.SelectedPath)
.DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Title, view => view.Title.Text)
.DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SettingsFile, view => view.SettingsFile.SelectedPath)
SettingsFile.BindFileSelectionBox(ViewModel, vm => vm.SettingsFile)
.DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Source, view => view.Source.SelectedPath)
Source.BindFileSelectionBox(ViewModel, vm => vm.Source)
.DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Downloads, view => view.DownloadsFolder.SelectedPath)
DownloadsFolder.BindFileSelectionBox(ViewModel, vm => vm.Downloads)
.DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.OutputFolder, view => view.OutputFolder.SelectedPath)
OutputFolder.BindFileSelectionBox(ViewModel, vm => vm.OutputFolder)
.DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.AllGames, view => view.BaseGame.Items)

View File

@ -102,6 +102,7 @@ public class CompilerConfigurationViewModel : ViewModelBase
{
return new MO2CompilerSettings
{
ModListName = Title,
Downloads = Downloads,
Source = Source,
Game = BaseGame.Game,
@ -157,6 +158,7 @@ public class CompilerConfigurationViewModel : ViewModelBase
var data = iniFile.LoadIniFile();
var generalModData = data["General"];
AlwaysEnabled = Array.Empty<RelativePath>();
if ((generalModData["notes"]?.Contains("WABBAJACK_ALWAYS_ENABLE") ?? false) ||
(generalModData["comments"]?.Contains("WABBAJACK_ALWAYS_ENABLE") ?? false))
AlwaysEnabled = AlwaysEnabled.Append(modFolder.RelativeTo(mo2Folder)).ToArray();
@ -195,6 +197,7 @@ public class CompilerConfigurationViewModel : ViewModelBase
throw new NotImplementedException();
}
Title = s.ModListName;
Source = s.Source;
Downloads = s.Downloads;
OutputFolder = s.OutputFile.Depth > 1 ? s.OutputFile.Parent : s.OutputFile;