ADded a version field to the UI

This commit is contained in:
erri120 2020-04-16 17:16:49 +02:00
parent e8923a11f1
commit 50613fa438
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135
5 changed files with 26 additions and 1 deletions

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using Alphaleonis.Win32.Filesystem;
using Wabbajack.Common.IO;
@ -138,5 +139,7 @@ namespace Wabbajack.Common
public static RelativePath ModOrganizer2Exe = (RelativePath)"ModOrganizer.exe";
public static RelativePath ModOrganizer2Ini = (RelativePath)"ModOrganizer.ini";
public static string AuthorAPIKeyFile = "author-api-key.txt";
public static Regex VersionRegex = new Regex(@"^(\d{1,3}\.?){1,3}[^\.]$");
}
}

View File

@ -119,6 +119,7 @@ namespace Wabbajack
public class CompilationModlistSettings
{
public string ModListName { get; set; }
public string Version { get; set; }
public string Author { get; set; }
public string Description { get; set; }
public string Website { get; set; }

View File

@ -5,6 +5,7 @@ using DynamicData;
using Microsoft.WindowsAPICodePack.Dialogs;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Wabbajack.Common;
using Wabbajack.Lib;
namespace Wabbajack
@ -16,6 +17,9 @@ namespace Wabbajack
[Reactive]
public string ModListName { get; set; }
[Reactive]
public string VersionText { get; set; }
[Reactive]
public string AuthorText { get; set; }
@ -35,7 +39,7 @@ namespace Wabbajack
public ModlistSettingsEditorVM(CompilationModlistSettings settings)
{
_settings = settings;
ImagePath = new FilePickerVM()
ImagePath = new FilePickerVM
{
ExistCheckOption = FilePickerVM.CheckOptions.IfPathNotEmpty,
PathType = FilePickerVM.PathTypeOptions.File,
@ -44,6 +48,17 @@ namespace Wabbajack
InError = this.WhenAny(x => x.ImagePath.ErrorState)
.Select(err => err.Failed)
.CombineLatest(
this.WhenAny(x => x.VersionText)
.Select(x =>
{
if (string.IsNullOrWhiteSpace(x))
return false;
var match = Consts.VersionRegex.Match(x);
return match.Success;
}),
(image, version) => !image && !version)
.Publish()
.RefCount();
}
@ -59,10 +74,12 @@ namespace Wabbajack
Readme = _settings.Readme;
ImagePath.TargetPath = _settings.SplashScreen;
Website = _settings.Website;
VersionText = _settings.Version;
}
public void Save()
{
_settings.Version = VersionText;
_settings.Author = AuthorText;
_settings.ModListName = ModListName;
_settings.Description = Description;

View File

@ -121,6 +121,8 @@
</StackPanel.Resources>
<TextBlock Margin="{StaticResource TitleMargin}" Text="ModList Name" />
<TextBox x:Name="ModListNameSetting" Style="{StaticResource ValueStyle}" />
<TextBlock Margin="{StaticResource TitleMargin}" Text="Version" />
<TextBox x:Name="VersionSetting" Style="{StaticResource ValueStyle}" MaxLength="9" />
<TextBlock Margin="{StaticResource TitleMargin}" Text="Author" />
<TextBox x:Name="AuthorNameSetting" Style="{StaticResource ValueStyle}" />
<TextBlock Margin="{StaticResource TitleMargin}" Text="Description" />

View File

@ -63,6 +63,8 @@ namespace Wabbajack
.DisposeWith(dispose);
this.BindStrict(this.ViewModel, x => x.CurrentModlistSettings.ModListName, x => x.ModListNameSetting.Text)
.DisposeWith(dispose);
this.BindStrict(ViewModel, x => x.CurrentModlistSettings.VersionText, x => x.VersionSetting.Text)
.DisposeWith(dispose);
this.BindStrict(this.ViewModel, x => x.CurrentModlistSettings.AuthorText, x => x.AuthorNameSetting.Text)
.DisposeWith(dispose);
this.BindStrict(this.ViewModel, x => x.CurrentModlistSettings.Description, x => x.DescriptionSetting.Text)