public MainVM() { var env = GameEnvironment.Typical.Skyrim(SkyrimRelease.SkyrimSE, LinkCachePreferences.OnlyIdentifiers()) .DisposeWith(this); LinkCache = env.LinkCache; LoadOrder = env.LoadOrder; ScopedTypes = typeof(IArmorGetter).AsEnumerable(); LateSetPickerVM = new LateSetPickerVM(this); }
public MainVM() { var gameRelease = SkyrimRelease.SkyrimSE; var env = GameEnvironment.Typical.Skyrim(gameRelease, LinkCachePreferences.OnlyIdentifiers()) .DisposeWith(this); LinkCache = env.LinkCache; LoadOrder = env.LoadOrder; ScopedTypes = typeof(IArmorGetter).AsEnumerable(); LateSetPickerVM = new LateSetPickerVM(this); Reflection = new ReflectionSettingsVM( ReflectionSettingsParameters.CreateFrom( new TestSettings(), env.LoadOrder.ListedOrder, env.LinkCache)); LoadOrderVM = new FileSyncedLoadOrderVM(env.LoadOrderFilePath) { DataFolderPath = env.DataFolderPath.Path, CreationClubFilePath = env.CreationKitLoadOrderFilePath?.Path ?? string.Empty, GameRelease = gameRelease.ToGameRelease(), }; }
public ProfileSimpleLinkCacheVm( ILogger logger, IProfileLoadOrder loadOrder, IProfileDataFolderVm dataFolder, IProfileIdentifier ident) { _simpleLinkCache = Observable.CombineLatest( dataFolder.WhenAnyValue(x => x.Path), loadOrder.LoadOrder.Connect() .QueryWhenChanged() .Select(q => q.Where(x => x.Enabled).Select(x => x.ModKey).ToArray()) .StartWithEmpty(), (dataFolder, loadOrder) => (dataFolder, loadOrder)) .Throttle(TimeSpan.FromMilliseconds(100), RxApp.TaskpoolScheduler) .Select(x => { return(Observable.Create <(ILinkCache?Cache, IDisposable Disposable)>(obs => { try { var loadOrder = Mutagen.Bethesda.Plugins.Order.LoadOrder.Import( x.dataFolder, x.loadOrder, factory: (modPath) => ModInstantiator.Importer(modPath, ident.Release)); obs.OnNext( (loadOrder.ToUntypedImmutableLinkCache(LinkCachePreferences.OnlyIdentifiers()), loadOrder)); obs.OnCompleted(); // ToDo // Figure out why returning this is disposing too early. // Gets disposed undesirably, which makes formlink pickers fail // return loadOrder; } catch (Exception ex) { logger.Error(ex, "Error creating simple link cache for GUI lookups"); obs.OnNext((default, Disposable.Empty));
public MainVM(HostSettings host) { WindowName = $"{host.PatcherName} Settings"; WarmupAll.Init(); var loadOrderResult = Observable.Return(Unit.Default) .ObserveOn(RxApp.TaskpoolScheduler) .Select(_ => { System.Console.Error.WriteLine($"Getting live load order for {host.GameRelease} -> {host.DataFolderPath}"); var liveLo = Mutagen.Bethesda.LoadOrder.GetLiveLoadOrder(host.GameRelease, host.DataFolderPath, out IObservable <ErrorResponse> errors) .Transform(listing => new LoadOrderEntryVM(listing, host.DataFolderPath)) .DisposeMany(); return(Results: liveLo, State: errors); }) .StartWith((Results: Observable.Empty <IChangeSet <LoadOrderEntryVM> >(), State: Observable.Return(ErrorResponse.Fail("Load order uninitialized")))) .Replay(1) .RefCount(); loadOrderResult.Select(x => x.State) .Switch() .Subscribe(e => { Console.Error.WriteLine(e); }) .DisposeWith(this); var loadOrder = loadOrderResult .Select(x => x.Results) .Switch() .AsObservableList(); var linkCache = loadOrder.Connect() .QueryWhenChanged() .Select(q => q.Where(x => x.Listing.Enabled).Select(x => x.Listing.ModKey).ToArray()) .StartWithEmpty() .Throttle(TimeSpan.FromMilliseconds(100), RxApp.TaskpoolScheduler) .Select(x => { return(Observable.Create <ILinkCache>(obs => { var loadOrder = Mutagen.Bethesda.LoadOrder.Import( host.DataFolderPath, x, factory: (modPath) => ModInstantiator.Importer(modPath, host.GameRelease)); obs.OnNext(loadOrder.ToUntypedImmutableLinkCache(LinkCachePreferences.OnlyIdentifiers())); obs.OnCompleted(); return Disposable.Empty; })); }) .Switch() .Replay(1) .RefCount(); _AutogeneratedSettings = Observable.Return(Unit.Default) .ObserveOn(RxApp.TaskpoolScheduler) .SelectTask(async _ => { try { var config = await Synthesis.Bethesda.Execution.CLI.Commands.GetSettingsStyle( host.PatcherPath, directExe: false, cancel: CancellationToken.None, build: false, log: (s) => Console.WriteLine(s)); return(new AutogeneratedSettingsVM( config, projPath: host.PatcherPath, displayName: host.PatcherName, loadOrder: loadOrder.Connect(), linkCache: linkCache, log: (s) => Console.WriteLine(s))); } catch (Exception ex) { Console.WriteLine(ex); return(default(AutogeneratedSettingsVM?)); } }) .ToGuiProperty(this, nameof(AutogeneratedSettings), default); }