2019-11-16 23:10:17 +00:00
|
|
|
|
using Newtonsoft.Json;
|
2019-11-06 03:22:38 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Reactive;
|
|
|
|
|
using System.Reactive.Subjects;
|
2019-11-14 05:28:27 +00:00
|
|
|
|
using Wabbajack.Common;
|
2019-11-06 03:22:38 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack
|
|
|
|
|
{
|
|
|
|
|
[JsonObject(MemberSerialization.OptOut)]
|
|
|
|
|
public class MainSettings
|
|
|
|
|
{
|
2019-11-21 15:45:00 +00:00
|
|
|
|
private static string _filename = "settings.json";
|
2019-11-06 03:22:38 +00:00
|
|
|
|
|
|
|
|
|
public double PosX { get; set; }
|
|
|
|
|
public double PosY { get; set; }
|
|
|
|
|
public double Height { get; set; }
|
|
|
|
|
public double Width { get; set; }
|
2019-11-14 05:28:27 +00:00
|
|
|
|
public InstallerSettings Installer { get; set; } = new InstallerSettings();
|
|
|
|
|
public CompilerSettings Compiler { get; set; } = new CompilerSettings();
|
2019-11-06 03:22:38 +00:00
|
|
|
|
|
|
|
|
|
private Subject<Unit> _saveSignal = new Subject<Unit>();
|
2019-12-11 00:16:48 +00:00
|
|
|
|
[JsonIgnoreAttribute]
|
2019-11-06 03:22:38 +00:00
|
|
|
|
public IObservable<Unit> SaveSignal => _saveSignal;
|
|
|
|
|
|
2019-12-01 22:20:26 +00:00
|
|
|
|
public static bool TryLoadTypicalSettings(out MainSettings settings)
|
2019-11-06 03:22:38 +00:00
|
|
|
|
{
|
2019-12-01 22:20:26 +00:00
|
|
|
|
if (!File.Exists(_filename))
|
|
|
|
|
{
|
|
|
|
|
settings = default;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
settings = JsonConvert.DeserializeObject<MainSettings>(File.ReadAllText(_filename));
|
|
|
|
|
return true;
|
2019-11-06 03:22:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SaveSettings(MainSettings settings)
|
|
|
|
|
{
|
|
|
|
|
settings._saveSignal.OnNext(Unit.Default);
|
|
|
|
|
|
|
|
|
|
// Might add this if people are putting save work on other threads or other
|
|
|
|
|
// things that delay the operation.
|
|
|
|
|
//settings._saveSignal.OnCompleted();
|
|
|
|
|
//await settings._saveSignal;
|
|
|
|
|
|
2019-11-21 15:45:00 +00:00
|
|
|
|
File.WriteAllText(_filename, JsonConvert.SerializeObject(settings, Formatting.Indented));
|
2019-11-06 03:22:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-14 05:28:27 +00:00
|
|
|
|
public class InstallerSettings
|
|
|
|
|
{
|
|
|
|
|
public string LastInstalledListLocation { get; set; }
|
2019-12-03 02:38:33 +00:00
|
|
|
|
public Dictionary<string, Mo2ModlistInstallationSettings> Mo2ModlistSettings { get; } = new Dictionary<string, Mo2ModlistInstallationSettings>();
|
2019-11-14 05:28:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-03 02:38:33 +00:00
|
|
|
|
public class Mo2ModlistInstallationSettings
|
2019-11-06 03:22:38 +00:00
|
|
|
|
{
|
|
|
|
|
public string InstallationLocation { get; set; }
|
|
|
|
|
public string DownloadLocation { get; set; }
|
2019-12-10 00:46:44 +00:00
|
|
|
|
public bool AutomaticallyOverrideExistingInstall { get; set; }
|
2019-11-06 03:22:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-14 05:28:27 +00:00
|
|
|
|
public class CompilerSettings
|
|
|
|
|
{
|
|
|
|
|
public ModManager LastCompiledModManager { get; set; }
|
2019-11-24 00:53:04 +00:00
|
|
|
|
public string OutputLocation { get; set; }
|
2019-11-14 05:28:27 +00:00
|
|
|
|
public MO2CompilationSettings MO2Compilation { get; } = new MO2CompilationSettings();
|
|
|
|
|
public VortexCompilationSettings VortexCompilation { get; } = new VortexCompilationSettings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class CompilationModlistSettings
|
2019-11-06 03:22:38 +00:00
|
|
|
|
{
|
|
|
|
|
public string ModListName { get; set; }
|
|
|
|
|
public string Author { get; set; }
|
|
|
|
|
public string Description { get; set; }
|
|
|
|
|
public string Website { get; set; }
|
2019-12-20 07:14:43 +00:00
|
|
|
|
public bool ReadmeIsWebsite { get; set; }
|
2019-11-06 03:22:38 +00:00
|
|
|
|
public string Readme { get; set; }
|
|
|
|
|
public string SplashScreen { get; set; }
|
2019-11-14 05:28:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class MO2CompilationSettings
|
|
|
|
|
{
|
2019-11-06 03:22:38 +00:00
|
|
|
|
public string DownloadLocation { get; set; }
|
2019-11-14 05:28:27 +00:00
|
|
|
|
public string LastCompiledProfileLocation { get; set; }
|
|
|
|
|
public Dictionary<string, CompilationModlistSettings> ModlistSettings { get; } = new Dictionary<string, CompilationModlistSettings>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class VortexCompilationSettings
|
|
|
|
|
{
|
|
|
|
|
public Game LastCompiledGame { get; set; }
|
2019-11-16 23:10:17 +00:00
|
|
|
|
public Dictionary<Game, VortexGameSettings> ModlistSettings { get; } = new Dictionary<Game, VortexGameSettings>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class VortexGameSettings
|
|
|
|
|
{
|
|
|
|
|
public string GameLocation { get; set; }
|
2019-11-17 03:09:46 +00:00
|
|
|
|
public string DownloadLocation { get; set; }
|
|
|
|
|
public string StagingLocation { get; set; }
|
2019-11-16 23:10:17 +00:00
|
|
|
|
public CompilationModlistSettings ModlistSettings { get; } = new CompilationModlistSettings();
|
2019-11-06 03:22:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|