예제 #1
0
        /// <summary>
        /// Gets the editor to use to edit the <see cref="XmlScript"/> prerequisites.
        /// </summary>
        /// <param name="p_xscScript">The <see cref="XmlScript"/> whose prerequisites are to be edited.</param>
        /// <param name="p_lstModFiles">The list of files in the mod to which the <see cref="XmlScript"/>
        /// being edited belongs.</param>
        /// <returns>The editor to use to edit <see cref="XmlScript"/> prerequisites. <c>null</c> is returned if the
        /// current <see cref="XmlScript"/> does not support editing the prerequisites.</returns>
        public override NodeEditor GetPrerequisitesEditor(Nexus.Client.ModManagement.Scripting.XmlScript.XmlScript p_xscScript, IList <VirtualFileSystemItem> p_lstModFiles)
        {
            FO3CplConverter       cvtConverter           = new FO3CplConverter(ScriptType.GetCplParserFactory());
            CPLEditorVM           vmlCplEditor           = CreateCPLEditorVM(p_lstModFiles);
            PrerequisitesEditorVM vmlPrerequisitesEditor = new PrerequisitesEditorVM(vmlCplEditor, cvtConverter, p_xscScript);

            return(new ConditionEditor(vmlPrerequisitesEditor));
        }
        /// <summary>
        /// Installs and activates files are required. This method is used by the background worker.
        /// </summary>
        /// <param name="p_scpScript">The XMl Script to execute.</param>
        protected bool InstallFiles(XmlScript p_xscScript, ConditionStateManager p_csmStateManager, ICollection <InstallableFile> p_colFilesToInstall, ICollection <InstallableFile> p_colPluginsToActivate)
        {
            IList <InstallableFile> lstRequiredFiles = p_xscScript.RequiredInstallFiles;
            IList <ConditionallyInstalledFileSet> lstConditionallyInstalledFileSets = p_xscScript.ConditionallyInstalledFileSets;

            OverallProgressMaximum = lstRequiredFiles.Count + p_colFilesToInstall.Count + lstConditionallyInstalledFileSets.Count;

            foreach (InstallableFile iflRequiredFile in lstRequiredFiles)
            {
                if (Status == TaskStatus.Cancelling)
                {
                    return(false);
                }
                if (!InstallFile(iflRequiredFile, true))
                {
                    return(false);
                }
                StepOverallProgress();
            }

            foreach (InstallableFile ilfFile in p_colFilesToInstall)
            {
                if (Status == TaskStatus.Cancelling)
                {
                    return(false);
                }
                if (!InstallFile(ilfFile, p_colPluginsToActivate.Contains(ilfFile)))
                {
                    return(false);
                }
                StepOverallProgress();
            }

            foreach (ConditionallyInstalledFileSet cisFileSet in lstConditionallyInstalledFileSets)
            {
                if (cisFileSet.Condition.GetIsFulfilled(p_csmStateManager))
                {
                    foreach (InstallableFile ilfFile in cisFileSet.Files)
                    {
                        if (Status == TaskStatus.Cancelling)
                        {
                            return(false);
                        }
                        if (!InstallFile(ilfFile, true))
                        {
                            return(false);
                        }
                    }
                }
                StepOverallProgress();
            }
            return(true);
        }
        /// <summary>
        /// Gets the unparser to use to create an XML representation of the given <see cref="XmlScript"/>.
        /// </summary>
        /// <param name="p_xscScript">The <see cref="XmlScript"/> to unparse.</param>
        /// <returns>The unparser to use to unparse the given XML Script.</returns>
        protected override IUnparser GetUnparser(Nexus.Client.ModManagement.Scripting.XmlScript.XmlScript p_xscScript)
        {
            switch (p_xscScript.Version.ToString())
            {
            case "1.0":
            case "2.0":
            case "3.0":
            case "4.0":
                throw new ParserException(String.Format("XML Script version {0} does not support the current game mode. Use verion 5.0 or later.", p_xscScript.Version));

            case "5.0":
                return(new FalloutNVUnparser50(p_xscScript));
            }
            throw new ParserException("Unrecognized XML Script version (" + p_xscScript.Version + "). Perhaps a newer version of the mod manager is required.");
        }
        /// <summary>
        /// Gets a unparser for the given script.
        /// </summary>
        /// <param name="p_xscScript">The script for which to get an unparser.</param>
        /// <returns>An unparser for the given script.</returns>
        protected virtual IUnparser GetUnparser(XmlScript p_xscScript)
        {
            switch (p_xscScript.Version.ToString())
            {
            case "1.0":
                return(new Unparser10(p_xscScript));

            case "2.0":
                return(new Unparser20(p_xscScript));

            case "3.0":
                return(new Unparser30(p_xscScript));

            case "4.0":
                return(new Unparser40(p_xscScript));

            case "5.0":
                return(new Unparser50(p_xscScript));
            }
            throw new ParserException("Unrecognized XML Script version (" + p_xscScript.Version + "). Perhaps a newer version of the mod manager is required.");
        }
예제 #5
0
        /// <summary>
        /// Performs the mod installation based on the XML script.
        /// </summary>
        /// <param name="p_strModName">The name of the mod whose script in executing.</param>
        /// <param name="p_xscScript">The script that is executing.</param>
        /// <param name="p_csmStateManager">The state manager managing the install state.</param>
        /// <param name="p_colFilesToInstall">The list of files to install.</param>
        /// <param name="p_colPluginsToActivate">The list of plugins to activate.</param>
        /// <returns><c>true</c> if the installation succeeded;
        /// <c>false</c> otherwise.</returns>
        public bool Install(string p_strModName, XmlScript p_xscScript, ConditionStateManager p_csmStateManager, ICollection <InstallableFile> p_colFilesToInstall, ICollection <InstallableFile> p_colPluginsToActivate)
        {
            OverallMessage          = String.Format("Installing {0}", p_strModName);
            OverallProgressStepSize = 1;
            ItemProgressStepSize    = 1;
            ShowItemProgress        = true;
            bool booSuccess = false;

            try
            {
                booSuccess = InstallFiles(p_xscScript, p_csmStateManager, p_colFilesToInstall, p_colPluginsToActivate);
                Status     = Status == TaskStatus.Cancelling ? TaskStatus.Cancelled : TaskStatus.Complete;
            }
            catch
            {
                booSuccess = false;
                Status     = TaskStatus.Error;
            }
            OnTaskEnded(booSuccess);
            return(booSuccess);
        }
        /// <summary>
        /// Gets the editor to use to edit the <see cref="XmlScript"/> prerequisites.
        /// </summary>
        /// <param name="p_xscScript">The <see cref="XmlScript"/> whose prerequisites are to be edited.</param>
        /// <param name="p_lstModFiles">The list of files in the mod to which the <see cref="XmlScript"/>
        /// being edited belongs.</param>
        /// <returns>The editor to use to edit <see cref="XmlScript"/> prerequisites. <c>null</c> is returned if the
        /// current <see cref="XmlScript"/> does not support editing the prerequisites.</returns>
        public virtual NodeEditor GetPrerequisitesEditor(Nexus.Client.ModManagement.Scripting.XmlScript.XmlScript p_xscScript, IList <VirtualFileSystemItem> p_lstModFiles)
        {
            CPLTextEditorVM vmlCplTextEditor = new CPLTextEditorVM(new FO3CplHighlightingStrategy(ScriptType.GetCplParserFactory()), ScriptType.GetCplParserFactory());

            List <KeyValuePair <string, string> > lstVersionNames = new List <KeyValuePair <string, string> >();

            lstVersionNames.Add(new KeyValuePair <string, string>("FOSE Version", "foseVersion"));
            lstVersionNames.Add(new KeyValuePair <string, string>("Game Version", "gameVersion"));
            lstVersionNames.Add(new KeyValuePair <string, string>("Mod Manager Version", "managerVersion"));

            List <CplConditionEditor> lstConditionEditors = new List <CplConditionEditor>();

            lstConditionEditors.Add(new CplPluginConditionEditor(p_lstModFiles));
            lstConditionEditors.Add(new CplVersionConditionEditor(lstVersionNames));
            CPLEditorVM vmlCplEditor = new CPLEditorVM(vmlCplTextEditor, lstConditionEditors, ConditionOperator.And);

            FO3CplConverter       cvtConverter           = new FO3CplConverter(ScriptType.GetCplParserFactory());
            PrerequisitesEditorVM vmlPrerequisitesEditor = new PrerequisitesEditorVM(vmlCplEditor, cvtConverter, p_xscScript);

            return(new ConditionEditor(vmlPrerequisitesEditor));
        }
        /// <summary>
        /// Gets the unparser to use to create an XML representation of the given <see cref="XmlScript"/>.
        /// </summary>
        /// <param name="p_xscScript">The <see cref="XmlScript"/> to unparse.</param>
        /// <returns>The unparser to use to unparse the given XML Script.</returns>
        protected override IUnparser GetUnparser(Nexus.Client.ModManagement.Scripting.XmlScript.XmlScript p_xscScript)
        {
            switch (p_xscScript.Version.ToString())
            {
            case "1.0":
                return(new Fallout3Unparser10(p_xscScript));

            case "2.0":
                return(new Fallout3Unparser20(p_xscScript));

            case "3.0":
                return(new Fallout3Unparser30(p_xscScript));

            case "4.0":
                return(new Fallout3Unparser40(p_xscScript));

            case "5.0":
                return(new Fallout3Unparser50(p_xscScript));
            }
            throw new ParserException("Unrecognized XML Script version (" + p_xscScript.Version + "). Perhaps a newer version of the mod manager is required.");
        }
 /// <summary>
 /// A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_xscScript">The script to unparse.</param>
 public Fallout4Unparser50(Nexus.Client.ModManagement.Scripting.XmlScript.XmlScript p_xscScript)
     : base(p_xscScript)
 {
 }
        /// <summary>
        /// Gets the editor to use to edit the <see cref="XmlScript"/>'s install step order.
        /// </summary>
        /// <param name="p_xscScript">The <see cref="XmlScript"/> whose install step order is to be edited.</param>
        /// <param name="p_lstModFiles">The list of files in the mod to which the <see cref="XmlScript"/>
        /// being edited belongs.</param>
        /// <returns>The editor to use to edit the <see cref="XmlScript"/>'s install step order. <c>null</c> is returned if the
        /// current <see cref="XmlScript"/> does not support editing the install step order.</returns>
        public override NodeEditor GetInstallStepOrderEditor(Nexus.Client.ModManagement.Scripting.XmlScript.XmlScript p_xscScript, IList <VirtualFileSystemItem> p_lstModFiles)
        {
            InstallStepsEditorVM vmlStepsEditor = new InstallStepsEditorVM(p_xscScript);

            return(new InstallStepsEditor(vmlStepsEditor));
        }
예제 #10
0
        /// <summary>
        /// Executes the script.
        /// </summary>
        /// <param name="p_scpScript">The XMl Script to execute.</param>
        /// <returns><c>true</c> if the script completes successfully;
        /// <c>false</c> otherwise.</returns>
        /// <exception cref="ArgumentException">Thrown if <paramref name="p_scpScript"/> is not an
        /// <see cref="XmlScript"/>.</exception>
        public override bool DoExecute(IScript p_scpScript)
        {
            if (!(p_scpScript is XmlScript))
            {
                throw new ArgumentException("The given script must be of type XmlScript.", "p_scpScript");
            }

            XmlScript xscScript = (XmlScript)p_scpScript;

            ConditionStateManager csmStateManager = ((XmlScriptType)xscScript.Type).CreateConditionStateManager(Mod, GameMode, Installers.PluginManager, EnvironmentInfo);

            if ((xscScript.ModPrerequisites != null) && !xscScript.ModPrerequisites.GetIsFulfilled(csmStateManager))
            {
                throw new DependencyException(xscScript.ModPrerequisites.GetMessage(csmStateManager));
            }

            IList <InstallStep> lstSteps      = xscScript.InstallSteps;
            HeaderInfo          hifHeaderInfo = xscScript.HeaderInfo;

            if (String.IsNullOrEmpty(hifHeaderInfo.ImagePath))
            {
                hifHeaderInfo.ImagePath = Mod.ScreenshotPath;
            }
            if ((hifHeaderInfo.Height < 0) && hifHeaderInfo.ShowImage)
            {
                hifHeaderInfo.Height = 75;
            }
            OptionsForm ofmOptions = null;

            if (m_scxSyncContext == null)
            {
                ofmOptions = new OptionsForm(xscScript, hifHeaderInfo, csmStateManager, lstSteps);
            }
            else
            {
                m_scxSyncContext.Send(x => ofmOptions = new OptionsForm(xscScript, hifHeaderInfo, csmStateManager, lstSteps), null);
            }
            ofmOptions.Name = "OptionForm";
            bool booPerformInstall = false;

            if (lstSteps.Count == 0)
            {
                booPerformInstall = true;
            }
            else
            {
                if (m_scxSyncContext == null)
                {
                    booPerformInstall = (ofmOptions.ShowDialog() == DialogResult.OK);
                }
                else
                {
                    m_scxSyncContext.Send(x => booPerformInstall = (ofmOptions.ShowDialog() == DialogResult.OK), null);
                }
            }

            if (booPerformInstall)
            {
                XmlScriptInstaller xsiInstaller = new XmlScriptInstaller(Mod, GameMode, Installers);
                OnTaskStarted(xsiInstaller);
                return(xsiInstaller.Install(hifHeaderInfo.Title, xscScript, csmStateManager, ofmOptions.FilesToInstall, ofmOptions.PluginsToActivate));
            }
            return(false);
        }
 /// <summary>
 /// Gets the editor to use to edit the <see cref="XmlScript"/>'s install step order.
 /// </summary>
 /// <param name="p_xscScript">The <see cref="XmlScript"/> whose install step order is to be edited.</param>
 /// <param name="p_lstModFiles">The list of files in the mod to which the <see cref="XmlScript"/>
 /// being edited belongs.</param>
 /// <returns>The editor to use to edit the <see cref="XmlScript"/>'s install step order. <c>null</c> is returned if the
 /// current <see cref="XmlScript"/> does not support editing the install step order.</returns>
 public virtual NodeEditor GetInstallStepOrderEditor(Nexus.Client.ModManagement.Scripting.XmlScript.XmlScript p_xscScript, IList <VirtualFileSystemItem> p_lstModFiles)
 {
     return(null);
 }
 /// <summary>
 /// A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_xscScript">The script to unparse.</param>
 public SkyrimSEUnparser50(Nexus.Client.ModManagement.Scripting.XmlScript.XmlScript p_xscScript)
     : base(p_xscScript)
 {
 }