wabbajack/Wabbajack/View Models/Compilers/ModlistSettingsEditorVM.cs

70 lines
2.0 KiB
C#
Raw Normal View History

using Microsoft.WindowsAPICodePack.Dialogs;
using ReactiveUI.Fody.Helpers;
using Wabbajack.Lib;
namespace Wabbajack
{
public class ModlistSettingsEditorVM : ViewModel
{
2019-11-21 15:45:00 +00:00
private CompilationModlistSettings _settings;
[Reactive]
public string ModListName { get; set; }
[Reactive]
public string AuthorText { get; set; }
[Reactive]
public string Description { get; set; }
public FilePickerVM ImagePath { get; }
public FilePickerVM ReadMeText { get; }
[Reactive]
public string Website { get; set; }
public ModlistSettingsEditorVM(CompilationModlistSettings settings)
{
2019-11-21 15:45:00 +00:00
this._settings = settings;
2019-11-21 15:04:33 +00:00
ImagePath = new FilePickerVM()
{
ExistCheckOption = FilePickerVM.ExistCheckOptions.IfNotEmpty,
PathType = FilePickerVM.PathTypeOptions.File,
Filters =
{
new CommonFileDialogFilter("Banner image", "*.png")
}
};
2019-11-21 15:04:33 +00:00
ReadMeText = new FilePickerVM()
{
PathType = FilePickerVM.PathTypeOptions.File,
ExistCheckOption = FilePickerVM.ExistCheckOptions.IfNotEmpty,
};
}
public void Init()
{
2019-11-21 15:45:00 +00:00
AuthorText = _settings.Author;
if (!string.IsNullOrWhiteSpace(_settings.ModListName))
{
2019-11-21 15:45:00 +00:00
ModListName = _settings.ModListName;
}
2019-11-21 15:45:00 +00:00
Description = _settings.Description;
ReadMeText.TargetPath = _settings.Readme;
ImagePath.TargetPath = _settings.SplashScreen;
Website = _settings.Website;
}
public void Save()
{
2019-11-21 15:45:00 +00:00
_settings.Author = AuthorText;
_settings.ModListName = ModListName;
_settings.Description = Description;
_settings.Readme = ReadMeText.TargetPath;
_settings.SplashScreen = ImagePath.TargetPath;
_settings.Website = Website;
}
}
}