wabbajack/Wabbajack.Lib/ACompiler.cs

60 lines
2.2 KiB
C#
Raw Normal View History

2019-11-03 15:26:51 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Subjects;
2019-11-03 15:26:51 +00:00
using System.Text;
using System.Threading.Tasks;
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
{
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();
public ModManager ModManager;
2019-11-03 15:26:51 +00:00
public string GamePath;
2019-11-03 15:26:51 +00:00
public string ModListOutputFolder;
public string ModListOutputFile;
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>();
public ModList ModList = new ModList();
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();
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
}
}