コード例 #1
0
 public PatcherVm Get(PatcherSettings settings)
 {
     return(settings switch
     {
         GithubPatcherSettings git => GetGitPatcher(git),
         SolutionPatcherSettings soln => GetSolutionPatcher(soln),
         CliPatcherSettings cli => GetCliPatcher(cli),
         _ => throw new NotImplementedException(),
     });
コード例 #2
0
        public override PatcherSettings Save()
        {
            var ret = new SolutionPatcherSettings();

            CopyOverSave(ret);
            ret.SolutionPath   = this.SolutionPath.TargetPath;
            ret.ProjectSubpath = this.ProjectSubpath;
            PatcherSettings.Persist(Logger.Information);
            return(ret);
        }
コード例 #3
0
 public override PatcherRunVM ToRunner(PatchersRunVM parent)
 {
     PatcherSettings.Persist(Logger.Information);
     return(new PatcherRunVM(
                parent,
                this,
                new SolutionPatcherRun(
                    name: DisplayName,
                    pathToSln: SolutionPath.TargetPath,
                    pathToExtraDataBaseFolder: Execution.Paths.TypicalExtraData,
                    pathToProj: SelectedProjectPath.TargetPath)));
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: alsa64/NPC-Plugin-Chooser
        public static Npc addNPCtoPatch(INpcGetter userSelectedNPC, PatcherSettings settings, IPatcherState <ISkyrimMod, ISkyrimModGetter> state)
        {
            switch (settings.ForwardConflictWinnerData)
            {
            case false: return(state.PatchMod.Npcs.GetOrAddAsOverride(userSelectedNPC));

            case true:
                var allContexts = state.LinkCache.ResolveAllContexts <INpc, INpcGetter>(userSelectedNPC.FormKey)
                                  .Take(2)
                                  .ToList();
                if (allContexts.Count < 2)
                {
                    return(state.PatchMod.Npcs.GetOrAddAsOverride(userSelectedNPC));
                }
                else
                {
                    var winningOR   = allContexts[^ 2].Record;
コード例 #5
0
        public IPatcherRun Convert(PatcherSettings patcherSettings)
        {
            switch (patcherSettings)
            {
            case CliPatcherSettings cliPatcherSettings:
            {
                var scope = _scope.BeginLifetimeScope(c =>
                    {
                        c.RegisterModule <PatcherModule>();
                        c.RegisterInstance(cliPatcherSettings)
                        .AsSelf()
                        .AsImplementedInterfaces();
                    });
                return(scope.Resolve <ICliPatcherRun>());
            }

            case GithubPatcherSettings githubPatcherSettings:
            {
                var scope = _scope.BeginLifetimeScope(c =>
                    {
                        c.RegisterModule <GitPatcherModule>();
                        c.RegisterInstance(githubPatcherSettings)
                        .AsSelf()
                        .AsImplementedInterfaces();
                    });
                return(scope.Resolve <IGitPatcherRun>());
            }

            case SolutionPatcherSettings solutionPatcherSettings:
            {
                var scope = _scope.BeginLifetimeScope(c =>
                    {
                        c.RegisterModule <SolutionPatcherModule>();
                        c.RegisterInstance(solutionPatcherSettings)
                        .AsSelf()
                        .AsImplementedInterfaces();
                    });
                return(scope.Resolve <ISolutionPatcherRun>());
            }

            default:
                throw new NotImplementedException();
            }
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: alsa64/NPC-Plugin-Chooser
        private static void CanRunPatch(IRunnabilityState state)
        {
            PatcherSettings settings = Settings.Value;

            if (settings.AssetOutputDirectory != "" && !Directory.Exists(settings.AssetOutputDirectory))
            {
                throw new Exception("Cannot find output directory specified in settings: " + settings.AssetOutputDirectory);
            }

            if (settings.Mode != Mode.Simple && settings.MO2DataPath == "")
            {
                throw new Exception("MO2 Data Path must be set for any mode other than Simple.");
            }

            if (settings.MO2DataPath != "" && !Directory.Exists(settings.MO2DataPath))
            {
                throw new Exception("Cannot find the Mod Organizer 2 Mods folder specified in settings: " + settings.MO2DataPath);
            }
        }
コード例 #7
0
ファイル: GitPatcherVm.cs プロジェクト: sharpsteve/Synthesis
        public override PatcherSettings Save()
        {
            var ret = new GithubPatcherSettings
            {
                RemoteRepoPath         = RemoteRepoPathInput.RemoteRepoPath,
                ID                     = this.ID,
                SelectedProjectSubpath = this.SelectedProjectInput.ProjectSubpath,
                PatcherVersioning      = this.PatcherTargeting.PatcherVersioning,
                MutagenVersionType     = this.NugetTargeting.MutagenVersioning,
                ManualMutagenVersion   = this.NugetTargeting.ManualMutagenVersion,
                SynthesisVersionType   = this.NugetTargeting.SynthesisVersioning,
                ManualSynthesisVersion = this.NugetTargeting.ManualSynthesisVersion,
                TargetTag              = this.PatcherTargeting.TargetTag,
                TargetCommit           = this.PatcherTargeting.TargetCommit,
                LatestTag              = this.PatcherTargeting.TagAutoUpdate,
                FollowDefaultBranch    = this.PatcherTargeting.BranchFollowMain,
                AutoUpdateToBranchTip  = this.PatcherTargeting.BranchAutoUpdate,
                TargetBranch           = this.PatcherTargeting.TargetBranchName,
                LastSuccessfulRun      = this.LastSuccessfulRun,
            };

            CopyOverSave(ret);
            try
            {
                _copyOverExtraData.Copy();
            }
            catch (Exception e)
            {
                _logger.Error(e, "Failed to copy in extra data");
            }
            try
            {
                PatcherSettings.Persist();
            }
            catch (Exception e)
            {
                _logger.Error(e, "Failed to save patcher settings");
            }
            return(ret);
        }
コード例 #8
0
ファイル: PatcherVM.cs プロジェクト: tr4wzified/Synthesis
 protected void CopyOverSave(PatcherSettings settings)
 {
     settings.On       = IsOn;
     settings.Nickname = Nickname;
 }
コード例 #9
0
ファイル: GitPatcherVm.cs プロジェクト: sharpsteve/Synthesis
 public override void PrepForRun()
 {
     base.PrepForRun();
     _copyOverExtraData.Copy();
     PatcherSettings.Persist();
 }
コード例 #10
0
ファイル: PatcherVm.cs プロジェクト: sharpsteve/Synthesis
 protected void CopyInSettings(PatcherSettings settings)
 {
     IsOn            = settings.On;
     NameVm.Nickname = settings.Nickname;
 }
コード例 #11
0
ファイル: Program.cs プロジェクト: alsa64/NPC-Plugin-Chooser
        public static void RunPatch(IPatcherState <ISkyrimMod, ISkyrimModGetter> state)
        {
            PatcherSettings settings = Settings.Value;

            PatcherSettings outputSettings = new PatcherSettings(); // only used if Mode == SettingsGen

            Dictionary <ModKey, string> PluginDirectoryDict = initPluginDirectoryDict(settings, state);

            getWarningsToSuppress(settings, state);
            getPathstoIgnore(settings, state);

            if (settings.AssetOutputDirectory != "" && Directory.Exists(settings.AssetOutputDirectory) && settings.ClearAssetOutputDirectory && settings.Mode != Mode.SettingsGen)
            {
                clearOuptutDir(settings);
            }

            if (settings.Mode == Mode.SettingsGen)
            {
                string settingsDirName = "NPC Settings";
                outputSettings.AssetOutputDirectory      = settings.AssetOutputDirectory;
                outputSettings.ClearAssetOutputDirectory = settings.ClearAssetOutputDirectory;
                outputSettings.CopyExtraAssets           = settings.CopyExtraAssets;
                outputSettings.MO2DataPath = settings.MO2DataPath;
                outputSettings.Mode        = Mode.Deep;
                outputSettings.SuppressKnownMissingFileWarnings = settings.SuppressKnownMissingFileWarnings;

                int counter = 0;
                foreach (var npcCO in state.LoadOrder.PriorityOrder.Npc().WinningContextOverrides())
                {
                    if (npcCO.Record.FaceMorph == null)
                    {
                        continue; // skip creatures
                    }
                    generateSettingsForNPC(npcCO, settings, outputSettings, PluginDirectoryDict, state);
                    counter++;
                    if (counter % 100 == 0)
                    {
                        Console.WriteLine("Processed {0} humanoid NPCs", counter++);
                    }
                }

                // write output settings here

                var jsonSettings = new JsonSerializerSettings();
                jsonSettings.Converters.Add(new StringEnumConverter());
                jsonSettings.AddMutagenConverters();
                jsonSettings.ObjectCreationHandling = ObjectCreationHandling.Replace;
                jsonSettings.Formatting             = Formatting.Indented;

                var outputPath = Path.Combine(settings.AssetOutputDirectory, settingsDirName, string.Format("settings_{0:yyyy-MM-dd_hh-mm-ss-tt}.json", DateTime.Now));
                try
                {
                    if (Directory.Exists(settings.AssetOutputDirectory) == false)
                    {
                        Directory.CreateDirectory(settings.AssetOutputDirectory);
                    }
                    if (Directory.Exists(Path.Combine(settings.AssetOutputDirectory, settingsDirName)) == false)
                    {
                        Directory.CreateDirectory(Path.Combine(settings.AssetOutputDirectory, settingsDirName));
                    }

                    string jsonStr = JsonConvert.SerializeObject(outputSettings, jsonSettings);
                    File.WriteAllText(outputPath, jsonStr);
                    Console.WriteLine("Wrote current settings to {0}. Use this file as a backup of your current settings by renaming it to \"settings.json\" and placing it into your Synthesis\\Data\\NPC-Plugin-Chooser folder.", outputPath);
                }
                catch
                {
                    throw new Exception("Could not write the generated settings object to " + outputPath);
                }
            }

            else
            {
                foreach (var PPS in settings.PluginsToForward)
                {
                    Console.WriteLine("Processing {0}", PPS.Plugin.ToString());

                    if (PluginDirectoryDict.ContainsKey(PPS.Plugin) == false)
                    {
                        throw new Exception("Plugin -> Folder dictionary does not contain an entry for plugin " + PPS.Plugin.ToString());
                    }
                    string currentDataDir = PluginDirectoryDict[PPS.Plugin];

                    state.LoadOrder.TryGetValue(PPS.Plugin, out var currentModContext);
                    if (currentModContext != null && currentModContext.Mod != null)
                    {
                        foreach (var npc in currentModContext.Mod.Npcs)
                        {
                            if ((PPS.InvertSelection == false && PPS.NPCs.Contains(npc.AsLinkGetter())) || (PPS.InvertSelection == true && !PPS.NPCs.Contains(npc.AsLinkGetter())))
                            {
                                string NPCdispStr = npc.Name + " | " + npc.EditorID + " | " + npc.FormKey.ToString();
                                Console.WriteLine("Forwarding appearance of {0}", NPCdispStr);
                                if (faceGenExists(npc.FormKey, currentModContext.ModKey, currentDataDir, PPS.ExtraDataDirectories, settings.HandleBSAFiles_Patching, state, out var BSAfiles) == false)
                                {
                                    if (settings.AbortIfMissingFaceGen)
                                    {
                                        throw new Exception("Missing expected FaceGen for NPC " + NPCdispStr + " in folder " + currentDataDir + " (obtained based on plugin " + PPS.Plugin.ToString() + ")");
                                    }
                                    else
                                    {
                                        Console.WriteLine("WARNING: " + "Missing expected FaceGen for NPC " + NPCdispStr + " in folder " + currentDataDir + " (obtained based on plugin " + PPS.Plugin.ToString() + ")");
                                    }
                                }

                                var NPCoverride = addNPCtoPatch(npc, settings, state);
                                copyAssets(NPCoverride, currentModContext.ModKey, settings, currentDataDir, PPS, state);
                            }
                        }
                    }

                    //remap dependencies
                    if (settings.BaseGamePlugins.Contains(PPS.Plugin) == false)
                    {
                        Console.WriteLine("Remapping Dependencies from {0}.", PPS.Plugin.ToString());
                        state.PatchMod.DuplicateFromOnlyReferenced(state.LinkCache, PPS.Plugin, out var _);
                    }
                }
            }
        }