2019-11-03 15:26:51 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2019-11-15 23:13:27 +00:00
|
|
|
|
using System.Reactive.Subjects;
|
2019-11-03 15:26:51 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2019-11-03 16:43:43 +00:00
|
|
|
|
using Wabbajack.Common;
|
2019-11-03 15:26:51 +00:00
|
|
|
|
using Wabbajack.Lib.CompilationSteps;
|
2019-11-15 13:06:34 +00:00
|
|
|
|
using Wabbajack.VirtualFileSystem;
|
2019-11-03 15:26:51 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack.Lib
|
|
|
|
|
{
|
|
|
|
|
public abstract class ACompiler
|
|
|
|
|
{
|
2019-11-15 23:13:27 +00:00
|
|
|
|
protected static string _vfsCacheName = "vfs_compile_cache.bin";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A stream of tuples of ("Update Title", 0.25) which represent the name of the current task
|
|
|
|
|
/// and the current progress.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public IObservable<(string, float)> ProgressUpdates => _progressUpdates;
|
|
|
|
|
protected readonly Subject<(string, float)> _progressUpdates = new Subject<(string, float)>();
|
|
|
|
|
|
2019-11-15 13:06:34 +00:00
|
|
|
|
public Context VFS { get; internal set; } = new Context();
|
2019-11-15 23:13:27 +00:00
|
|
|
|
|
2019-11-03 16:43:43 +00:00
|
|
|
|
public ModManager ModManager;
|
2019-11-03 15:26:51 +00:00
|
|
|
|
|
2019-11-03 16:43:43 +00:00
|
|
|
|
public string GamePath;
|
2019-11-03 15:26:51 +00:00
|
|
|
|
|
2019-11-03 16:43:43 +00:00
|
|
|
|
public string ModListOutputFolder;
|
|
|
|
|
public string ModListOutputFile;
|
|
|
|
|
|
2019-11-15 05:47:31 +00:00
|
|
|
|
public List<Archive> SelectedArchives = new List<Archive>();
|
|
|
|
|
public List<Directive> InstallDirectives = new List<Directive>();
|
2019-11-15 13:06:34 +00:00
|
|
|
|
public List<RawSourceFile> AllFiles = new List<RawSourceFile>();
|
2019-11-15 05:47:31 +00:00
|
|
|
|
public ModList ModList = new ModList();
|
2019-11-15 14:19:39 +00:00
|
|
|
|
|
2019-11-15 13:06:34 +00:00
|
|
|
|
public List<IndexedArchive> IndexedArchives = new List<IndexedArchive>();
|
|
|
|
|
public Dictionary<string, IEnumerable<VirtualFile>> IndexedFiles = new Dictionary<string, IEnumerable<VirtualFile>>();
|
2019-11-03 15:26:51 +00:00
|
|
|
|
|
|
|
|
|
public abstract void Info(string msg);
|
|
|
|
|
public abstract void Status(string msg);
|
|
|
|
|
public abstract void Error(string msg);
|
|
|
|
|
|
|
|
|
|
internal abstract string IncludeFile(byte[] data);
|
|
|
|
|
internal abstract string IncludeFile(string data);
|
|
|
|
|
|
|
|
|
|
public abstract bool Compile();
|
|
|
|
|
|
|
|
|
|
public abstract Directive RunStack(IEnumerable<ICompilationStep> stack, RawSourceFile source);
|
|
|
|
|
public abstract IEnumerable<ICompilationStep> GetStack();
|
|
|
|
|
public abstract IEnumerable<ICompilationStep> MakeStack();
|
2019-11-15 23:13:27 +00:00
|
|
|
|
|
|
|
|
|
protected ACompiler()
|
|
|
|
|
{
|
|
|
|
|
ProgressUpdates.Subscribe(itm => Utils.Log($"{itm.Item2} - {itm.Item1}"));
|
|
|
|
|
VFS.LogSpam.Subscribe(itm => Utils.Status(itm));
|
|
|
|
|
}
|
2019-11-03 15:26:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|