Ejemplo n.º 1
0
        public IEnumerable <IModListingGetter> GetLoadOrder(bool addCcMods, PatcherPreferences?userPrefs = null)
        {
            if (addCcMods)
            {
                var implicitMods = _implicitListing.Get();

                var ccMods = _ccListingsProvider.Get();

                var loadOrderListing = _pluginListings.Get();
                loadOrderListing = loadOrderListing.Distinct(x => x.ModKey);
                if (userPrefs?.InclusionMods != null)
                {
                    var inclusions = userPrefs.InclusionMods.ToHashSet();
                    loadOrderListing = loadOrderListing
                                       .Where(m => inclusions.Contains(m.ModKey));
                }
                if (userPrefs?.ExclusionMods != null)
                {
                    var exclusions = userPrefs.ExclusionMods.ToHashSet();
                    loadOrderListing = loadOrderListing
                                       .Where(m => !exclusions.Contains(m.ModKey));
                }

                return(_orderListings.Order(
                           implicitListings: implicitMods,
                           pluginsListings: loadOrderListing,
                           creationClubListings: ccMods,
                           selector: x => x.ModKey));
            }
            else
            {
                // This call will implicitly get Creation Club entries, too, as the Synthesis systems should be merging
                // things into a singular load order file for consumption here
                var loadOrderListing = _implicitListing.Get();
                loadOrderListing = loadOrderListing.Concat(_pluginListings.Get());
                loadOrderListing = loadOrderListing.Distinct(x => x.ModKey);
                if (userPrefs?.InclusionMods != null)
                {
                    var inclusions = userPrefs.InclusionMods.ToHashSet();
                    loadOrderListing = loadOrderListing
                                       .Where(m => inclusions.Contains(m.ModKey));
                }
                if (userPrefs?.ExclusionMods != null)
                {
                    var exclusions = userPrefs.ExclusionMods.ToHashSet();
                    loadOrderListing = loadOrderListing
                                       .Where(m => !exclusions.Contains(m.ModKey));
                }
                return(loadOrderListing);
            }
        }
Ejemplo n.º 2
0
        public IObservable <IChangeSet <IModListingGetter> > Get(out IObservable <ErrorResponse> state, IScheduler?scheduler = null)
        {
            var results = ObservableExt.WatchFile(_pluginListingsFilePath.Path, fileWatcherFactory: _fileSystem.FileSystemWatcher)
                          .StartWith(Unit.Default)
                          .Select(_ =>
            {
                try
                {
                    return(GetResponse <IObservable <IChangeSet <IModListingGetter> > > .Succeed(
                               _listingsProvider.Get()
                               .AsObservableChangeSet()));
                }
                catch (Exception ex)
                {
                    return(GetResponse <IObservable <IChangeSet <IModListingGetter> > > .Fail(ex));
                }
            })
                          .Replay(1)
                          .RefCount();

            state = results
                    .Select(r => (ErrorResponse)r);
            return(results
                   .Select(r =>
            {
                return r.Value ?? Observable.Empty <IChangeSet <IModListingGetter> >();
            })
                   .Switch()
                   .ObserveOnIfApplicable(scheduler));
        }
        /// <inheritdoc />
        public IEnumerable <IModListingGetter> Get()
        {
            var implicitListings = _implicitListingsProvider.Get().ToArray();

            return(_orderListings.Order(
                       implicitListings: implicitListings,
                       pluginsListings: _pluginListingsProvider.Get().Except(implicitListings),
                       creationClubListings: _cccListingsProvider.Get(throwIfMissing: false),
                       selector: x => x.ModKey));
        }