Пример #1
0
        public static IEnumerable <LoadOrderListing> GetLoadOrder(
            GameRelease release,
            string loadOrderFilePath,
            string dataFolderPath,
            PatcherPreferences?userPrefs = null)
        {
            // This call will impliticly get Creation Club entries, too, as the Synthesis systems should be merging
            // things into a singular load order file for consumption here
            var loadOrderListing =
                ImplicitListings.GetListings(release, dataFolderPath)
                .Select(x => new LoadOrderListing(x, enabled: true));

            if (!loadOrderFilePath.IsNullOrWhitespace())
            {
                loadOrderListing = loadOrderListing.Concat(PluginListings.RawListingsFromPath(loadOrderFilePath, release));
            }
            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);
        }
Пример #2
0
        public static GameEnvironmentState <TModSetter, TModGetter> Construct(
            GameRelease release,
            DirectoryPath dataFolder,
            LinkCachePreferences?linkCachePrefs = null)
        {
            var dataPath = Path.Combine(dataFolder.Path, "Data");

            var loadOrder = Mutagen.Bethesda.Plugins.Order.LoadOrder.Import <TModGetter>(
                dataPath,
                Mutagen.Bethesda.Plugins.Order.LoadOrder.GetListings(release, dataPath),
                release);

            if (!PluginListings.TryGetListingsFile(release, out var loadOrderFilePath))
            {
                throw new FileNotFoundException("Could not locate plugins file");
            }

            var ccPath = CreationClubListings.GetListingsPath(release.ToCategory(), dataPath);

            return(new GameEnvironmentState <TModSetter, TModGetter>(
                       dataFolderPath: dataFolder,
                       loadOrderFilePath: loadOrderFilePath.Path,
                       creationKitLoadOrderFilePath: ccPath,
                       loadOrder: loadOrder,
                       linkCache: loadOrder.ToImmutableLinkCache <TModSetter, TModGetter>(linkCachePrefs),
                       dispose: true));
        }
Пример #3
0
        public async Task Prep(GameRelease release, CancellationToken?cancel = null)
        {
            _output.OnNext("Cloning repository");
            var cloneResult = await CheckOrCloneRepo(GetResponse <string> .Succeed(_settings.RemoteRepoPath), _localDir, (x) => _output.OnNext(x), cancel ?? CancellationToken.None);

            if (cloneResult.Failed)
            {
                throw new SynthesisBuildFailure(cloneResult.Reason);
            }

            throw new NotImplementedException("Need to migrate in proper git checkouts");

            //_output.OnNext($"Locating path to solution based on local dir {_localDir}");
            //var pathToSln = GetPathToSolution(_localDir);
            //_output.OnNext($"Locating path to project based on {pathToSln} AND {_settings.SelectedProjectSubpath}");
            //var foundProjSubPath = SolutionPatcherRun.AvailableProject(pathToSln, _settings.SelectedProjectSubpath);
            //if (foundProjSubPath == null)
            //{
            //    throw new SynthesisBuildFailure("Could not locate project sub path");
            //}
            //var pathToProj = Path.Combine(_localDir, foundProjSubPath);
            //SolutionRun = new SolutionPatcherRun(
            //    _settings.Nickname,
            //    pathToSln: Path.Combine(_localDir, pathToSln),
            //    pathToProj: pathToProj);
            //using var outputSub = SolutionRun.Output.Subscribe(this._output);
            //using var errSub = SolutionRun.Error.Subscribe(this._error);
            //await SolutionRun.Prep(release, cancel).ConfigureAwait(false);
        }
Пример #4
0
        private static IEnumerable <FilePath> GetApplicableArchivePathsInternal(GameRelease release, DirectoryPath dataFolderPath, ModKey?modKey, IComparer <FileName>?archiveOrdering)
        {
            if (modKey.HasValue && modKey.Value.IsNull)
            {
                return(Enumerable.Empty <FilePath>());
            }

            var ret = dataFolderPath.EnumerateFiles(searchPattern: $"*{GetExtension(release)}");

            if (modKey != null)
            {
                var iniListedArchives = GetIniListings(release).ToHashSet();
                ret = ret
                      .Where(archive =>
                {
                    if (iniListedArchives.Contains(archive.Name))
                    {
                        return(true);
                    }
                    return(IsApplicable(release, modKey.Value, archive.Name));
                });
            }
            if (archiveOrdering != null)
            {
                return(ret.OrderBy(x => x.Name, archiveOrdering));
            }
            return(ret);
        }
Пример #5
0
 /// <inheritdoc cref="IPluginListingsProvider"/>
 public static IEnumerable <IModListingGetter> RawListingsFromPath(
     FilePath pluginTextPath,
     GameRelease game)
 {
     using var fs = new FileStream(pluginTextPath.Path, FileMode.Open, FileAccess.Read, FileShare.Read);
     return(ListingsFromStream(fs, game).ToList());
 }
Пример #6
0
 private AItem(
     FormKey formKey,
     GameRelease gameRelease)
 {
     this.FormKey = formKey;
     CustomCtor();
 }
Пример #7
0
 /// <summary>
 /// Creates an Archive reader object from the given path, for the given Game Release.
 /// </summary>
 /// <param name="release">GameRelease the archive is for</param>
 /// <param name="path">Path to create archive reader from</param>
 /// <returns>Archive reader object</returns>
 public static IArchiveReader CreateReader(GameRelease release, FilePath path)
 {
     return(new ArchiveReaderProvider(
                IFileSystemExt.DefaultFilesystem,
                new GameReleaseInjection(release))
            .Create(path));
 }
Пример #8
0
 /// <summary>
 /// Analyzes whether an Archive would typically apply to a given ModKey. <br />
 ///  <br />
 /// - Is extension of the proper type <br />
 /// - Does the name match <br />
 /// - Does the name match, with an extra ` - AssetType` suffix considered
 /// </summary>
 /// <param name="release">Game Release of mod</param>
 /// <param name="modKey">ModKey to check applicability for</param>
 /// <param name="archiveFileName">Filename of the Archive, with extension</param>
 /// <returns>True if Archive is typically applicable to the given ModKey</returns>
 public static bool IsApplicable(GameRelease release, ModKey modKey, FileName archiveFileName)
 {
     return(new CheckArchiveApplicability(
                new ArchiveExtensionProvider(
                    new GameReleaseInjection(release)))
            .IsApplicable(modKey, archiveFileName));
 }
Пример #9
0
 public static async Task <bool> Run <TKey>(
     string workingDirectory,
     ModPath outputPath,
     string dataFolder,
     IEnumerable <LoadOrderListing> loadOrder,
     GameRelease release,
     IEnumerable <(TKey Key, IPatcherRun Run)> patchers,
Пример #10
0
        private IEnumerable <DirectoryPath> InternalGetGameFolders(GameRelease release)
        {
            if (TryGetGameDirectoryFromRegistry(release, out var regisPath) &&
                regisPath.Exists)
            {
                yield return(regisPath);
            }

            var steamHandler = _steamHandler.Value;

            if (steamHandler.Succeeded)
            {
                foreach (var game in steamHandler.Value.Games.Where(x => x.ID.Equals(Games[release].SteamId)))
                {
                    yield return(game.Path);
                }
            }

            var gogHandler = _gogHandler.Value;

            if (gogHandler.Succeeded)
            {
                foreach (var game in gogHandler.Value.Games.Where(x => x.GameID.Equals(Games[release].GogId)))
                {
                    yield return(game.Path);
                }
            }
        }
Пример #11
0
 private GameSetting(
     FormKey formKey,
     GameRelease gameRelease)
 {
     this.FormKey = formKey;
     CustomCtor();
 }
Пример #12
0
        public static TempFolder SetupDataFolder(TempFolder tempFolder, GameRelease release, string?loadOrderPath = null)
        {
            var dataFolder = new TempFolder(Path.Combine(tempFolder.Dir.Path, "Data"));

            loadOrderPath ??= PathToLoadOrderFile;
            string testPath, overridePath;

            switch (release)
            {
            case GameRelease.Oblivion:
                testPath     = OblivionPathToTestFile;
                overridePath = OblivionPathToOverrideFile;
                break;

            case GameRelease.SkyrimLE:
            case GameRelease.SkyrimSE:
                testPath     = LePathToTestFile;
                overridePath = LePathToOverrideFile;
                break;

            default:
                throw new NotImplementedException();
            }
            File.Copy(testPath, Path.Combine(dataFolder.Dir.Path, TestFileName));
            File.Copy(overridePath, Path.Combine(dataFolder.Dir.Path, OverrideFileName));
            var loadOrderListing = LoadOrder.FromPath(loadOrderPath, release, dataFolder.Dir);

            LoadOrder.AlignTimestamps(loadOrderListing.OnlyEnabled().Select(m => m.ModKey), dataFolder.Dir.Path);
            return(dataFolder);
        }
Пример #13
0
 /// <summary>
 /// Queries the related ini file and looks for Archive ordering information
 /// </summary>
 /// <param name="release">GameRelease ini is for</param>
 /// <param name="iniStream">Stream containing INI data</param>
 /// <returns>Any Archive ordering info retrieved from the ini definition</returns>
 public static IEnumerable <FileName> GetIniListings(GameRelease release, Stream iniStream)
 {
     return(new GetArchiveIniListings(
                IFileSystemExt.DefaultFilesystem,
                new GameReleaseInjection(release))
            .Get(iniStream));
 }
Пример #14
0
 public AlignmentSubRule(
     GameRelease release,
     params RecordType[] types)
 {
     this.SubTypes    = types.ToList();
     this.GameRelease = release;
 }
Пример #15
0
 private ANpcSpawn(
     FormKey formKey,
     GameRelease gameRelease)
 {
     this.FormKey = formKey;
     CustomCtor();
 }
Пример #16
0
        public void AddPassthroughGroup()
        {
            HashSet <GameRelease> games = new HashSet <GameRelease>()
            {
                EnumExt.GetValues <GameRelease>()
            };

            foreach (var group in Groups)
            {
                games.Remove(group.GameRelease);
            }
            GameRelease release = GameRelease.SkyrimSE;

            if (games.Count > 0)
            {
                release = games.First();
            }
            var groupVM = new PassthroughGroupVM(this)
            {
                GameRelease = release,
                Do          = true,
            };

            groupVM.Passthroughs.Add(new PassthroughVM(groupVM));
            Groups.Add(groupVM);
        }
Пример #17
0
 private Global(
     FormKey formKey,
     GameRelease gameRelease)
 {
     this.FormKey = formKey;
     CustomCtor();
 }
Пример #18
0
        public SubmitGame(GameInformation game)
            : this()
        {
            Debug.Assert(game != null);
            if (game == null)
            {
                throw new ArgumentNullException("game");
            }
            _game = game;

            this.Icon   = IconUtilities.ConvertToIcon(Properties.Resources.ReportIcon);
            _googleIcon = Properties.Resources.Google;

            _service = new Service();
            _service.ListGamesCompleted  += new ListGamesCompletedEventHandler(ServiceListGamesCompleted);
            _service.AddGameCompleted    += new AddGameCompletedEventHandler(ServiceAddGameCompleted);
            _service.AddReleaseCompleted += new AddReleaseCompletedEventHandler(ServiceAddReleaseCompleted);

            if (_gameList == null)
            {
                _service.ListGamesAsync();
                _outstandingRefresh = true;
            }
            else
            {
                this.ServiceListGamesCompleted(null, null);
            }

            this.titleLabel.Text    = _game.Parameters.Title;
            this.discIdLabel.Text   = _game.Parameters.DiscID;
            this.firmwareLabel.Text = _game.Parameters.SystemVersion.ToString();
            this.regionLabel.Text   = _game.Parameters.Region.ToString();
            this.versionLabel.Text  = _game.Parameters.GameVersion.ToString();

            Image gameImage;

            if (_game.Icon != null)
            {
                _game.Icon.Position = 0;
                gameImage           = Image.FromStream(_game.Icon);
            }
            else
            {
                gameImage = Image.FromStream(new MemoryStream(Resources.InvalidIcon, false));
            }
            this.iconPictureBox.Image = gameImage;

            _release               = new GameRelease();
            _release.Title         = _game.Parameters.Title;
            _release.DiscID        = _game.Parameters.DiscID;
            _release.Region        = _game.Parameters.Region;
            _release.SystemVersion = VersionToSingle(_game.Parameters.SystemVersion);
            _release.GameVersion   = VersionToSingle(_game.Parameters.GameVersion);
            if (_game.Icon != null)
            {
                _game.Icon.Position = 0;
                using (BinaryReader reader = new BinaryReader(_game.Icon))
                    _iconBytes = reader.ReadBytes(( int )_game.Icon.Length);
            }
        }
 private SpellLeveled(
     FormKey formKey,
     GameRelease gameRelease)
 {
     this.FormKey = formKey;
     CustomCtor();
 }
Пример #20
0
        public static EmitResult Compile(GameRelease release, string assemblyName, string code, CancellationToken cancel, out MemoryStream assemblyStream)
        {
            var gameCategory = release.ToCategory();

            StringBuilder sb = new StringBuilder();

            sb.AppendLine($"using System;");
            sb.AppendLine($"using Noggog;");
            sb.AppendLine($"using System.Threading;");
            sb.AppendLine($"using System.Threading.Tasks;");
            sb.AppendLine($"using System.Linq;");
            sb.AppendLine($"using System.IO;");
            sb.AppendLine($"using System.Collections;");
            sb.AppendLine($"using System.Collections.Generic;");
            sb.AppendLine($"using Mutagen.Bethesda.Synthesis;");
            sb.AppendLine($"using Mutagen.Bethesda;");
            sb.AppendLine($"using Mutagen.Bethesda.{release.ToCategory()};");

            sb.AppendLine($"public class {ClassName}");
            sb.AppendLine("{");
            sb.AppendLine($"public async Task Run(Mutagen.Bethesda.Synthesis.SynthesisState<Mutagen.Bethesda.{gameCategory}.I{gameCategory}Mod, Mutagen.Bethesda.{gameCategory}.I{gameCategory}ModGetter> state)");
            sb.AppendLine("{");
            sb.AppendLine(code);
            sb.AppendLine("}");
            sb.AppendLine("}");

            code = sb.ToString();

            SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(code);

            var options = new CSharpCompilationOptions(
                OutputKind.DynamicallyLinkedLibrary,
                optimizationLevel: OptimizationLevel.Release);

            Compilation compilation = CSharpCompilation.Create(assemblyName: assemblyName, options: options)
                                      .AddSyntaxTrees(syntaxTree)
                                      .AddReferences(new[]
            {
                MetadataReference.CreateFromFile(typeof(object).Assembly.Location),
                MetadataReference.CreateFromFile(typeof(Enumerable).Assembly.Location),
                MetadataReference.CreateFromFile(typeof(Task).Assembly.Location),
                MetadataReference.CreateFromFile(typeof(File).Assembly.Location),
                MetadataReference.CreateFromFile(Assembly.Load("netstandard").Location),
                MetadataReference.CreateFromFile(Assembly.Load("System.Runtime").Location),
                MetadataReference.CreateFromFile(Assembly.Load("Loqui").Location),
                MetadataReference.CreateFromFile(Assembly.Load("Noggog.CSharpExt").Location),
                MetadataReference.CreateFromFile(Assembly.Load("Mutagen.Bethesda.Kernel").Location),
                MetadataReference.CreateFromFile(Assembly.Load("Mutagen.Bethesda.Core").Location),
                MetadataReference.CreateFromFile(Assembly.Load("Mutagen.Bethesda.Synthesis").Location),
            });

            foreach (var game in EnumExt.GetValues <GameCategory>())
            {
                compilation = compilation.AddReferences(MetadataReference.CreateFromFile(Assembly.Load($"Mutagen.Bethesda.{game}").Location));
            }

            assemblyStream = new MemoryStream();
            return(compilation.Emit(assemblyStream, cancellationToken: cancel));
        }
Пример #21
0
    public AddResult AddRelease( string username, string password, long? gameId, GameRelease release, byte[] icon )
    {
        if( username == null )
            throw new ArgumentNullException( "username" );
        if( password == null )
            throw new ArgumentNullException( "password" );
        if( ( gameId.HasValue == true ) && ( gameId <= 0 ) )
            throw new ArgumentOutOfRangeException( "gameId" );
        if( release == null )
            throw new ArgumentNullException( "release" );

        using( Database db = new Database() )
        {
            try
            {
                switch( db.Authenticate( username, password ) )
                {
                    case AuthenticationResult.Succeeded:
                        break;
                    case AuthenticationResult.InvalidCredentials:
                    case AuthenticationResult.AccountDisabled:
                        return AddResult.PermissionDenied;
                }

                if( gameId.HasValue == false )
                {
                    gameId = db.AddGame( release.Title, null );
                    if( gameId < 0 )
                        return AddResult.Failed;
                    else if( gameId == 0 )
                        return AddResult.Redundant;
                }

                long releaseId = db.AddGameRelease( gameId.Value, release );
                if( releaseId < 0 )
                    return AddResult.Failed;
                else if( releaseId == 0 )
                    return AddResult.Redundant;

                if( ( icon != null ) &&
                    ( icon.Length > 0 ) )
                {
                    UpdateResult iconResult = db.SetGameIcon( gameId.Value, releaseId, icon );
                    if( iconResult != UpdateResult.Succeeded )
                        return AddResult.Failed;
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                db.Logout();
            }

            return AddResult.Succeeded;
        }
    }
Пример #22
0
 public async Task Prep(GameRelease release, CancellationToken cancel)
 {
     WasPrepped = true;
     if (ThrowInPrep)
     {
         throw new NotImplementedException();
     }
 }
Пример #23
0
 private ImpactDataSet(
     FormKey formKey,
     GameRelease gameRelease)
 {
     this.FormKey     = formKey;
     this.FormVersion = gameRelease.GetDefaultFormVersion() !.Value;
     CustomCtor();
 }
Пример #24
0
 private AnimationSoundTagSet(
     FormKey formKey,
     GameRelease gameRelease)
 {
     this.FormKey     = formKey;
     this.FormVersion = gameRelease.GetDefaultFormVersion() !.Value;
     CustomCtor();
 }
Пример #25
0
 public static Test RunTest(string name, GameRelease release, Target target, Func <Subject <string>, Task> toDo, bool parallel = true)
 {
     return(new Test(name,
                     parallel: parallel,
                     toDo: toDo,
                     release: release,
                     filePath: target.Path));
 }
Пример #26
0
 private SoundDescriptor(
     FormKey formKey,
     GameRelease gameRelease)
 {
     this.FormKey     = formKey;
     this.FormVersion = gameRelease.GetDefaultFormVersion() !.Value;
     CustomCtor();
 }
Пример #27
0
 public static IEnumerable <ModKey> GetListings(GameRelease release)
 {
     return(release switch
     {
         GameRelease.SkyrimSE => _sseImplicitMods,
         GameRelease.SkyrimVR => _sseImplicitMods,
         _ => Enumerable.Empty <ModKey>(),
     });
Пример #28
0
 private AttractionRule(
     FormKey formKey,
     GameRelease gameRelease)
 {
     this.FormKey     = formKey;
     this.FormVersion = gameRelease.GetDefaultFormVersion() !.Value;
     CustomCtor();
 }
Пример #29
0
 private Global(
     FormKey formKey,
     GameRelease gameRelease)
 {
     this.FormKey     = formKey;
     this.FormVersion = gameRelease.GetDefaultFormVersion() !.Value;
     CustomCtor();
 }
Пример #30
0
 /// <summary>
 /// Given a release, tries to retrieve the preferred data directory
 /// </summary>
 /// <param name="release">Release to query</param>
 /// <exception cref="System.IO.DirectoryNotFoundException">Thrown if the data folder could not be located</exception>
 /// <returns>The data folder provider</returns>
 public DirectoryPath GetDataDirectory(GameRelease release)
 {
     if (TryGetDataDirectory(release, out var path))
     {
         return(path);
     }
     throw new DirectoryNotFoundException($"Data folder for {release} cannot be found automatically");
 }
 private ActorValueInformation(
     FormKey formKey,
     GameRelease gameRelease)
 {
     this.FormKey     = formKey;
     this.FormVersion = gameRelease.GetDefaultFormVersion() !.Value;
     CustomCtor();
 }
Пример #32
0
        public SubmitGame( GameInformation game )
            : this()
        {
            Debug.Assert( game != null );
            if( game == null )
                throw new ArgumentNullException( "game" );
            _game = game;

            this.Icon = IconUtilities.ConvertToIcon( Properties.Resources.ReportIcon );
            _googleIcon = Properties.Resources.Google;

            _service = new Service();
            _service.ListGamesCompleted += new ListGamesCompletedEventHandler( ServiceListGamesCompleted );
            _service.AddGameCompleted += new AddGameCompletedEventHandler( ServiceAddGameCompleted );
            _service.AddReleaseCompleted += new AddReleaseCompletedEventHandler( ServiceAddReleaseCompleted );

            if( _gameList == null )
            {
                _service.ListGamesAsync();
                _outstandingRefresh = true;
            }
            else
            {
                this.ServiceListGamesCompleted( null, null );
            }

            this.titleLabel.Text = _game.Parameters.Title;
            this.discIdLabel.Text = _game.Parameters.DiscID;
            this.firmwareLabel.Text = _game.Parameters.SystemVersion.ToString();
            this.regionLabel.Text = _game.Parameters.Region.ToString();
            this.versionLabel.Text = _game.Parameters.GameVersion.ToString();

            Image gameImage;
            if( _game.Icon != null )
            {
                _game.Icon.Position = 0;
                gameImage = Image.FromStream( _game.Icon );
            }
            else
                gameImage = Image.FromStream( new MemoryStream( Resources.InvalidIcon, false ) );
            this.iconPictureBox.Image = gameImage;

            _release = new GameRelease();
            _release.Title = _game.Parameters.Title;
            _release.DiscID = _game.Parameters.DiscID;
            _release.Region = _game.Parameters.Region;
            _release.SystemVersion = VersionToSingle( _game.Parameters.SystemVersion );
            _release.GameVersion = VersionToSingle( _game.Parameters.GameVersion );
            if( _game.Icon != null )
            {
                _game.Icon.Position = 0;
                using( BinaryReader reader = new BinaryReader( _game.Icon ) )
                    _iconBytes = reader.ReadBytes( ( int )_game.Icon.Length );
            }
        }
Пример #33
0
 public AddResult AddGame( string username, string password, GameRelease release, byte[] icon )
 {
     return this.AddRelease( username, password, null, release, icon );
 }