Esempio n. 1
0
        /// <summary>
        /// Gets a message describing whether or not the condition is fulfilled.
        /// </summary>
        /// <remarks>
        /// If the condition is fulfilled the message is "Passed." If the condition is not fulfilled the
        /// message uses the pattern:
        ///		File '&lt;file>' is not &lt;state>.
        /// </remarks>
        /// <param name="coreDelegates">The Core delegates component.</param>
        /// <returns>A message describing whether or not the condition is fulfilled.</returns>
        /// <seealso cref="ICondition.GetMessage(CoreDelegates)"/>
		public string GetMessage(ConditionStateManager csmState, CoreDelegates coreDelegates)
		{
			StringBuilder stbMessage = new StringBuilder();
			if (m_dopOperator == ConditionOperator.Or)
				stbMessage.Append("(");

			bool booAllFulfilled = (m_dopOperator == ConditionOperator.And) ? true : false;
			bool booThisFulfilled = true;
			ICondition conCondition = null;
			for (Int32 i = 0; i < m_lstConditions.Count; i++)
			{
				conCondition = m_lstConditions[i];
				booThisFulfilled = conCondition.GetIsFulfilled(csmState, coreDelegates);
				if (!booThisFulfilled)
					stbMessage.Append(conCondition.GetMessage(csmState, coreDelegates));
				switch (m_dopOperator)
				{
					case ConditionOperator.And:
						if (i < m_lstConditions.Count - 1)
							stbMessage.AppendLine();
						booAllFulfilled &= booThisFulfilled;
						break;
					case ConditionOperator.Or:
						if (i < m_lstConditions.Count - 1)
							stbMessage.AppendLine(" OR");
						booAllFulfilled |= booThisFulfilled;
						break;
				}
			}
			if (m_dopOperator == ConditionOperator.Or)
				stbMessage.Append(")");
			return booAllFulfilled ? "Passed" : stbMessage.ToString();
		}
        /// <summary>
        /// Gets a message describing whether or not the condition is fulfilled.
        /// </summary>
        /// <remarks>
        /// If the condition is fulfilled the message is "Passed." If the condition is not fulfilled the
        /// message uses the pattern:
        ///		File '&lt;file>' is not &lt;state>.
        /// </remarks>
        /// <param name="coreDelegates">The Core delegates component.</param>
        /// <param name="invert">Invert the logic in the message, explaining why it passed instead of why not</param>
        /// <returns>A message describing whether or not the condition is fulfilled.</returns>
        /// <seealso cref="ICondition.GetMessage(CoreDelegates)"/>
        public string GetMessage(ConditionStateManager csmState, CoreDelegates coreDelegates, bool invert)
        {
            bool       booAllFulfilled  = (Operator == ConditionOperator.And) ? true : false;
            bool       booThisFulfilled = true;
            ICondition conCondition     = null;

            List <string> lines = new List <string>();

            for (Int32 i = 0; i < m_lstConditions.Count; i++)
            {
                conCondition     = m_lstConditions[i];
                booThisFulfilled = conCondition.GetIsFulfilled(csmState, coreDelegates);
                if (!booThisFulfilled)
                {
                    lines.Add(conCondition.GetMessage(csmState, coreDelegates, invert));
                }

                booAllFulfilled = Operator == ConditionOperator.And
          ? booAllFulfilled & booThisFulfilled
          : booAllFulfilled | booThisFulfilled;
            }

            string sep     = (Operator == ConditionOperator.Or) ? " OR\n" : "\n";
            string message = string.Join(sep, lines);

            return(booAllFulfilled && !invert ? "Passed" : message);
        }
 /// <summary>
 /// Gets whether this step is visible.
 /// </summary>
 /// <param name="coreDelegates">The Core delegates component.</param>
 /// <returns><c>true</c> if this step is visible, given the current state;
 /// <c>false</c> otherwise.</returns>
 public bool GetIsVisible(ConditionStateManager csmState, CoreDelegates coreDelegates)
 {
     if (VisibilityCondition == null)
     {
         return(true);
     }
     return(VisibilityCondition.GetIsFulfilled(csmState, coreDelegates));
 }
 /// <summary>
 /// Gets a message describing whether or not the condition is fulfilled.
 /// </summary>
 /// <remarks>
 /// If the condition is fulfilled the message is "Passed." If the condition is not fulfilled the
 /// message uses the pattern:
 ///		File '&lt;file>' is not &lt;state>.
 /// </remarks>
 /// <param name="coreDelegates">The Core delegates component.</param>
 /// <returns>A message describing whether or not the condition is fulfilled.</returns>
 /// <seealso cref="ICondition.GetMessage(CoreDelegates)"/>
 public string GetMessage(ConditionStateManager csmState, CoreDelegates coreDelegates)
 {
     if (GetIsFulfilled(csmState, coreDelegates))
     {
         return("Passed");
     }
     return(string.Format("File '{0}' is not {1}.", PluginPath, State.ToString()));
 }
Esempio n. 5
0
 /// <summary>
 /// Gets a message describing whether or not the condition is fulfilled.
 /// </summary>
 /// <remarks>
 /// If the condition is fulfilled the message is "Passed." If the condition is not fulfilled the
 /// message uses the pattern:
 ///		File '&lt;file>' is not &lt;state>.
 /// </remarks>
 /// <param name="coreDelegates">The Core delegates component.</param>
 /// <returns>A message describing whether or not the condition is fulfilled.</returns>
 /// <seealso cref="ICondition.GetMessage(CoreDelegates)"/>
 public string GetMessage(ConditionStateManager csmState, CoreDelegates coreDelegates, bool invert)
 {
     if (GetIsFulfilled(csmState, coreDelegates) && !invert)
     {
         return("Passed");
     }
     return(string.Format("Flag '{0}' is {2}{1}.", FlagName, Value, invert ? "" : "not "));
 }
 /// <summary>
 /// Gets a message describing whether or not the condition is fulfilled.
 /// </summary>
 /// <remarks>
 /// If the condition is fulfilled the message is "Passed." If the condition is not fulfilled the
 /// message uses the pattern:
 ///		File '&lt;file>' is not &lt;state>.
 /// </remarks>
 /// <param name="coreDelegates">The Core delegates component.</param>
 /// <returns>A message describing whether or not the condition is fulfilled.</returns>
 /// <seealso cref="ICondition.GetMessage(CoreDelegates)"/>
 public string GetMessage(ConditionStateManager csmState, CoreDelegates coreDelegates, bool invert)
 {
     if (GetIsFulfilled(csmState, coreDelegates) && !invert)
     {
         return("Passed");
     }
     return(string.Format("File '{0}' is {1}", PluginPath, State.ToString(), invert ? "" : "not "));
 }
 /// <summary>
 /// Gets a message describing whether or not the condition is fulfilled.
 /// </summary>
 /// <remarks>
 /// If the condition is fulfilled the message is "Passed." If the condition is not fulfilled the
 /// message uses the pattern:
 ///		File '&lt;file>' is not &lt;state>.
 /// </remarks>
 /// <param name="coreDelegates">The Core delegates component.</param>
 /// <returns>A message describing whether or not the condition is fulfilled.</returns>
 /// <seealso cref="ICondition.GetMessage(CoreDelegates)"/>
 public string GetMessage(ConditionStateManager csmState, CoreDelegates coreDelegates)
 {
     if (GetIsFulfilled(csmState, coreDelegates))
     {
         return("Passed");
     }
     return(string.Format("Flag '{0}' is not {1}.", FlagName, Value));
 }
Esempio n. 8
0
 /// <summary>
 /// Gets the plugin type.
 /// </summary>
 /// <remarks>
 /// The returned type is dependent upon external state. A list of patterns are matched
 /// against external state (e.g., installed files); the first pattern that is fulfilled
 /// determines the returned type.
 ///
 /// If no pattern is fulfilled, a default type if returned.
 /// </remarks>
 /// <param name="coreDelegates">The Core delegates component.</param>
 /// <returns>The option type.</returns>
 /// <seealso cref="IOptionTypeResolver.ResolveOptionType(CoreDelegates)"/>
 public OptionType ResolveOptionType(ConditionStateManager csmState, CoreDelegates coreDelegates)
 {
     foreach (ConditionalTypePattern ctpPattern in m_lstPatterns)
     {
         if (ctpPattern.Condition.GetIsFulfilled(csmState, coreDelegates))
         {
             return(ctpPattern.Type);
         }
     }
     return(m_ptpDefaultType);
 }
        /// <summary>
        /// Gets whether or not the condition is fulfilled.
        /// </summary>
        /// <remarks>
        /// The condition is fulfilled if the specified <see cref="File"/> is in the
        /// specified <see cref="State"/>.
        /// </remarks>
        /// <param name="coreDelegates">The Core delegates component.</param>
        /// <returns><c>true</c> if the condition is fulfilled;
        /// <c>false</c> otherwise.</returns>
        /// <seealso cref="ICondition.GetIsFulfilled(CoreDelegates)"/>
        public bool GetIsFulfilled(ConditionStateManager csmState, CoreDelegates coreDelegates)
        {
            string strValue = null;

            csmState.FlagValues.TryGetValue(FlagName, out strValue);
            if (string.IsNullOrEmpty(Value))
            {
                return(string.IsNullOrEmpty(strValue));
            }
            return(Value.Equals(strValue));
        }
Esempio n. 10
0
 /// <summary>
 /// Performs the mod installation based on the XML script.
 /// </summary>
 /// <param name="xscScript">The script that is executing.</param>
 /// <param name="coreDelegates">The Core delegates component.</param>
 /// <param name="filesToInstall">The list of files to install.</param>
 /// <param name="pluginsToActivate">The list of plugins to activate.</param>
 /// <returns><c>true</c> if the installation succeeded;
 /// <c>false</c> otherwise.</returns>
 public IList<Instruction> Install(XmlScript xscScript, ConditionStateManager csmState, CoreDelegates coreDelegates, IEnumerable<InstallableFile> filesToInstall, ICollection<InstallableFile> pluginsToActivate)
 {
     try
     {
         InstallFiles(xscScript, csmState, coreDelegates, filesToInstall, pluginsToActivate);
     }
     catch (Exception ex)
     {
         modInstallInstructions.Add(Instruction.InstallError(ex.Message));
     }
     return modInstallInstructions;
 }
        /// <summary>
        /// Installs and activates files are required. This method is used by the background worker.
        /// </summary>
        /// <param name="xscScript">The script that is executing.</param>
        /// <param name="coreDelegates">The Core delegates component.</param>
        /// <param name="filesToInstall">The list of files to install.</param>
        /// <param name="pluginsToActivate">The list of plugins to activate.</param>
        protected bool InstallFiles(XmlScript xscScript, ConditionStateManager csmState, CoreDelegates coreDelegates, IEnumerable <InstallableFile> filesToInstall, ICollection <InstallableFile> pluginsToActivate)
        {
            bool HadIssues = false;
            IList <InstallableFile> lstRequiredFiles = xscScript.RequiredInstallFiles;
            IList <ConditionallyInstalledFileSet> lstConditionallyInstalledFileSets = xscScript.ConditionallyInstalledFileSets;

            int priorityOffset = (int)Math.Pow(10, 9);

            foreach (InstallableFile iflRequiredFile in lstRequiredFiles)
            {
                if (!InstallFile(iflRequiredFile, priorityOffset * -1))
                {
                    HadIssues = true;
                }
            }

            if (!HadIssues)
            {
                foreach (InstallableFile ilfFile in filesToInstall)
                {
                    if (!InstallFile(ilfFile, 0))
                    {
                        HadIssues = true;
                    }
                }
            }

            if (!HadIssues)
            {
                foreach (ConditionallyInstalledFileSet cisFileSet in lstConditionallyInstalledFileSets)
                {
                    if (cisFileSet.Condition.GetIsFulfilled(csmState, coreDelegates))
                    {
                        foreach (InstallableFile ilfFile in cisFileSet.Files)
                        {
                            if (!InstallFile(ilfFile, priorityOffset))
                            {
                                HadIssues = true;
                            }
                        }
                    }
                }
            }

            if (!HadIssues)
            {
                modInstallInstructions.Add(Instruction.EnableAllPlugins());
            }

            return(!HadIssues);
        }
Esempio n. 12
0
        /// <summary>
        /// Gets whether or not the condition is fulfilled.
        /// </summary>
        /// <remarks>
        /// The dependency is fulfilled if the specified minimum version of
        /// NVSE is installed.
        /// </remarks>
        /// <param name="p_csmStateManager">The manager that tracks the currect install state.</param>
        /// <returns><c>true</c> if the condition is fulfilled;
        /// <c>false</c> otherwise.</returns>
        /// <seealso cref="ICondition.GetIsFulfilled(ConditionStateManager)"/>
        public override bool GetIsFulfilled(ConditionStateManager p_csmStateManager, CoreDelegates coreDelegates)
        {
            Version verInstalledVersion = null;

            Task.Run(async() =>
            {
                string versionString = await coreDelegates.context.GetExtenderVersion(m_strExtender);
                verInstalledVersion  = versionString != null
          ? new Version(versionString)
          : null;
            }).Wait();

            return((verInstalledVersion != null) && (verInstalledVersion >= MinimumVersion));
        }
        /// <summary>
        /// Gets whether or not the condition is fulfilled.
        /// </summary>
        /// <remarks>
        /// The condition is fulfilled if the specified <see cref="File"/> is in the
        /// specified <see cref="State"/>.
        /// </remarks>
        /// <param name="coreDelegates">The Core delegates component.</param>
        /// <returns><c>true</c> if the condition is fulfilled;
        /// <c>false</c> otherwise.</returns>
        /// <seealso cref="ICondition.GetIsFulfilled(CoreDelegates)"/>
        public override bool GetIsFulfilled(ConditionStateManager csmState, CoreDelegates coreDelegates)
        {
            Version GameVersion = new Version("0.0.0.0");

            Task.Run(async() => {
                string VersionString = await coreDelegates.context.GetCurrentGameVersion();

                if (!string.IsNullOrEmpty(VersionString))
                {
                    GameVersion = new Version(VersionString);
                }
                else
                {
                    GameVersion = new Version("0.0.0.0");
                }
            }).Wait();

            return((GameVersion != null) && (GameVersion >= MinimumVersion));
        }
Esempio n. 14
0
        /// <summary>
        /// Gets whether or not the condition is fulfilled.
        /// </summary>
        /// <remarks>
        /// The condition is fulfilled if the specified <see cref="File"/> is in the
        /// specified <see cref="State"/>.
        /// </remarks>
        /// <param name="coreDelegates">The Core delegates component.</param>
        /// <returns><c>true</c> if the condition is fulfilled;
        /// <c>false</c> otherwise.</returns>
        /// <seealso cref="ICondition.GetIsFulfilled(CoreDelegates)"/>
        public bool GetIsFulfilled(ConditionStateManager csmState, CoreDelegates coreDelegates)
		{
			bool booAllFulfilled = (m_dopOperator == ConditionOperator.And) ? true : false;
			bool booThisFulfilled = true;
			foreach (ICondition conCondition in m_lstConditions)
			{
				booThisFulfilled = conCondition.GetIsFulfilled(csmState, coreDelegates);
				switch (m_dopOperator)
				{
					case ConditionOperator.And:
						booAllFulfilled &= booThisFulfilled;
						break;
					case ConditionOperator.Or:
						booAllFulfilled |= booThisFulfilled;
						break;
				}
			}
			return booAllFulfilled;
		}
        /// <summary>
        /// Gets whether or not the condition is fulfilled.
        /// </summary>
        /// <remarks>
        /// The condition is fulfilled if the specified <see cref="File"/> is in the
        /// specified <see cref="State"/>.
        /// </remarks>
        /// <param name="coreDelegates">The Core delegates component.</param>
        /// <returns><c>true</c> if the condition is fulfilled;
        /// <c>false</c> otherwise.</returns>
        /// <seealso cref="ICondition.GetIsFulfilled(CoreDelegates)"/>
        public bool GetIsFulfilled(ConditionStateManager csmState, CoreDelegates coreDelegates)
        {
            string PluginPath = m_strPluginPath;

            if (coreDelegates != null)
            {
                switch (m_pnsState)
                {
                case PluginState.Active:
                    return(coreDelegates.plugin.IsActive(PluginPath).Result);

                case PluginState.Inactive:
                    return(coreDelegates.plugin.IsPresent(PluginPath).Result &&
                           !coreDelegates.plugin.IsActive(PluginPath).Result);

                case PluginState.Missing:
                    return(!coreDelegates.plugin.IsPresent(PluginPath).Result);
                }
            }
            return(false);
        }
Esempio n. 16
0
        /// <summary>
        /// Gets a message describing whether or not the condition is fulfilled.
        /// </summary>
        /// If the dependency is fulfilled the message is "Passed." If the dependency is not fulfilled the
        /// message informs the user of the installed version.
        /// <param name="p_csmStateManager">The manager that tracks the currect install state.</param>
        /// <returns>A message describing whether or not the condition is fulfilled.</returns>
        /// <seealso cref="ICondition.GetMessage(ConditionStateManager)"/>
        public override string GetMessage(ConditionStateManager p_csmStateManager, CoreDelegates coreDelegates, bool invert)
        {
            Version verInstalledVersion = null;

            Task.Run(async() =>
            {
                verInstalledVersion = new Version(await coreDelegates.context.GetExtenderVersion(m_strExtender));
            }).Wait();

            if ((verInstalledVersion == null) && !invert)
            {
                return(String.Format("This mod requires {0} v{1} or higher. Please download from http://{0}.silverlock.org", m_strExtender, MinimumVersion));
            }
            else if (verInstalledVersion < MinimumVersion)
            {
                return(String.Format("This mod requires {0} v{1} or higher. You have {2}. Please update from http://{0}.silverlock.org", m_strExtender, MinimumVersion, verInstalledVersion));
            }
            else
            {
                return("Passed");
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Installs and activates files are required. This method is used by the background worker.
        /// </summary>
        /// <param name="xscScript">The script that is executing.</param>
        /// <param name="coreDelegates">The Core delegates component.</param>
        /// <param name="filesToInstall">The list of files to install.</param>
        /// <param name="pluginsToActivate">The list of plugins to activate.</param>
        protected bool InstallFiles(XmlScript xscScript, ConditionStateManager csmState, CoreDelegates coreDelegates, IEnumerable<InstallableFile> filesToInstall, ICollection<InstallableFile> pluginsToActivate)
        {
            bool HadIssues = false;
            IList<InstallableFile> lstRequiredFiles = xscScript.RequiredInstallFiles;
            IList<ConditionallyInstalledFileSet> lstConditionallyInstalledFileSets = xscScript.ConditionallyInstalledFileSets;

            foreach (InstallableFile iflRequiredFile in lstRequiredFiles)
            {
                if (!InstallFile(iflRequiredFile))
                    HadIssues = true;
            }

            if (!HadIssues)
            {
                foreach (InstallableFile ilfFile in filesToInstall)
                {
                    if (!InstallFile(ilfFile)) // ??? , pluginsToActivate.Contains(ilfFile)))
                        HadIssues = true;
                }
            }

            if (!HadIssues)
            {
                foreach (ConditionallyInstalledFileSet cisFileSet in lstConditionallyInstalledFileSets)
                {
                    if (cisFileSet.Condition.GetIsFulfilled(csmState, coreDelegates))
                        foreach (InstallableFile ilfFile in cisFileSet.Files)
                        {
                            if (!InstallFile(ilfFile))
                                HadIssues = true;
                        }
                }
            }

            if (!HadIssues)
                modInstallInstructions.Add(Instruction.EnableAllPlugins());

            return !HadIssues;
        }
        /// <summary>
        /// Gets a message describing whether or not the condition is fulfilled.
        /// </summary>
        /// <remarks>
        /// If the condition is fulfilled the message is "Passed." If the condition is not fulfilled the
        /// message uses the pattern:
        ///		File '&lt;file>' is not &lt;state>.
        /// </remarks>
        /// <param name="coreDelegates">The Core delegates component.</param>
        /// <returns>A message describing whether or not the condition is fulfilled.</returns>
        /// <seealso cref="ICondition.GetMessage(CoreDelegates)"/>
        public override string GetMessage(ConditionStateManager csmState, CoreDelegates coreDelegates, bool invert)
        {
            Version GameVersion = new Version("0.0.0.0");

            Task.Run(async() => {
                string VersionString = await coreDelegates.context.GetCurrentGameVersion();

                if (!string.IsNullOrEmpty(VersionString))
                {
                    GameVersion = new Version(VersionString);
                }
                else
                {
                    GameVersion = new Version("0.0.0.0");
                }
            }).Wait();

            if ((GameVersion < MinimumVersion) && !invert)
            {
                return(string.Format("This mod requires v{0} or higher of the game. You have {1}. Please update your game.", MinimumVersion, GameVersion));
            }
            return("Passed");
        }
Esempio n. 19
0
        /// <summary>
        /// Gets a message describing whether or not the condition is fulfilled.
        /// </summary>
        /// <remarks>
        /// If the condition is fulfilled the message is "Passed." If the condition is not fulfilled the
        /// message uses the pattern:
        ///		File '&lt;file>' is not &lt;state>.
        /// </remarks>
        /// <param name="coreDelegates">The Core delegates component.</param>
        /// <returns>A message describing whether or not the condition is fulfilled.</returns>
        /// <seealso cref="ICondition.GetMessage(CoreDelegates)"/>
        public override string GetMessage(ConditionStateManager csmState, CoreDelegates coreDelegates)
        {
            Version AppVersion = new Version("0.0.0.0");

            Task.Run(async() => {
                string VersionString = await coreDelegates.context.GetAppVersion();

                if (!string.IsNullOrEmpty(VersionString))
                {
                    AppVersion = new Version(VersionString);
                }
                else
                {
                    AppVersion = new Version("0.0.0.0");
                }
            }).Wait();

            if (AppVersion < MinimumVersion)
            {
                return(string.Format("This mod requires v{0} or higher.", MinimumVersion));
            }
            return("Passed");
        }
        public string ResolveConditionMessage(ConditionStateManager csmState, CoreDelegates coreDelegates)
        {
            List <string> unmatched = new List <string>();

            foreach (ConditionalTypePattern ctpPattern in m_lstPatterns)
            {
                if (ctpPattern.Condition.GetIsFulfilled(csmState, coreDelegates))
                {
                    if (ctpPattern.Type == OptionType.NotUsable)
                    {
                        return(ctpPattern.Condition.GetMessage(csmState, coreDelegates, true));
                    }
                    else
                    {
                        return(null);
                    }
                }
                else if (ctpPattern.Type != OptionType.NotUsable)
                {
                    unmatched.Add("Not: " + ctpPattern.Condition.GetMessage(csmState, coreDelegates, true));
                }
            }
            return(unmatched.Aggregate((i, j) => i + "\n" + j));
        }
Esempio n. 21
0
        /// <summary>
        /// Executes the script.
        /// </summary>
        /// <param name="scpScript">The XML Script to execute.</param>
        /// <param name="dataPath">path where data files for the script are stored</param>
        /// <returns><c>true</c> if the script completes successfully;
        /// <c>false</c> otherwise.</returns>
        /// <exception cref="ArgumentException">Thrown if <paramref name="scpScript"/> is not an
        /// <see cref="XmlScript"/>.</exception>
        public async override Task <IList <Instruction> > DoExecute(IScript scpScript, string dataPath)
        {
            TaskCompletionSource <IList <Instruction> > Source = new TaskCompletionSource <IList <Instruction> >();
            List <InstallableFile> PluginsToActivate           = new List <InstallableFile>();

            m_csmState = new ConditionStateManager();

            if (!(scpScript is XmlScript))
            {
                throw new ArgumentException("The given script must be of type XmlScript.", scpScript.Type.TypeName);
            }

            XmlScript xscScript = (XmlScript)scpScript;

            if ((xscScript.ModPrerequisites != null) && !xscScript.ModPrerequisites.GetIsFulfilled(m_csmState, m_Delegates))
            {
                throw new Exception(xscScript.ModPrerequisites.GetMessage(m_csmState, m_Delegates));
            }

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

            if (string.IsNullOrEmpty(hifHeaderInfo.ImagePath))
            {
                hifHeaderInfo.ImagePath = string.IsNullOrEmpty(ModArchive.ScreenshotPath) ? null : Path.Combine(ModArchive.Prefix, ModArchive.ScreenshotPath);
            }
            if ((hifHeaderInfo.Height < 0) && hifHeaderInfo.ShowImage)
            {
                hifHeaderInfo.Height = 75;
            }

            m_SelectedOptions = new HashSet <Option>();

            int stepIdx = findNextIdx(lstSteps, -1);

            Action <int, int, int[]> select = (int stepId, int groupId, int[] optionIds) =>
            {
                // this needs to happen asynchronously so that this call returns to javascript and js can
                // return to its main loop and respond to delegated requests, otherwise we could dead-lock
                Task.Run(() =>
                {
                    ISet <int> selectedIds = new HashSet <int>(optionIds);
                    IList <Option> options = lstSteps[stepId].OptionGroups[groupId].Options;
                    for (int i = 0; i < options.Count; ++i)
                    {
                        if (selectedIds.Contains(i) || (resolveOptionType(options[i]) == OptionType.Required))
                        {
                            enableOption(options[i]);
                        }
                        else
                        {
                            disableOption(options[i]);
                        }
                    }

                    fixSelected(lstSteps[stepIdx]);
                    sendState(lstSteps, ModArchive.Prefix, stepIdx);
                });
            };

            Action <bool> cont = (bool forward) => {
                // this needs to happen asynchronously, see above
                Task.Run(() =>
                {
                    if (forward)
                    {
                        stepIdx = findNextIdx(lstSteps, stepIdx);
                    }
                    else
                    {
                        stepIdx = findPrevIdx(lstSteps, stepIdx);
                    }

                    processStep(lstSteps, stepIdx, Source, xscScript, PluginsToActivate);
                });
            };
            Action cancel = () => {
                // this needs to happen asynchronously, see above
                Task.Run(() =>
                {
                    Source.SetCanceled();
                });
            };

            string bannerPath = string.IsNullOrEmpty(hifHeaderInfo.ImagePath)
                ? null
                : Path.Combine(ModArchive.Prefix, hifHeaderInfo.ImagePath);

            m_Delegates.ui.StartDialog(hifHeaderInfo.Title,
                                       new HeaderImage(bannerPath, hifHeaderInfo.ShowFade, hifHeaderInfo.Height),
                                       select, cont, cancel);

            processStep(lstSteps, stepIdx, Source, xscScript, PluginsToActivate);

            return(await Source.Task);
        }
Esempio n. 22
0
 /// <summary>
 /// Gets the <see cref="OptionType"/> of the option.
 /// </summary>
 /// <param name="coreDelegates">The Core delegates component.</param>
 /// <returns>The <see cref="OptionType"/> of the option.</returns>
 public OptionType GetOptionType(ConditionStateManager csmState, CoreDelegates coreDelegates)
 {
     return(m_otrTypeResolver.ResolveOptionType(csmState, coreDelegates));
 }
 /// <summary>
 /// Gets a message describing whether or not the condition is fulfilled.
 /// </summary>
 /// <remarks>
 /// If the condition is fulfilled the message is "Passed." If the condition is not fulfilled the
 /// message uses the pattern:
 ///		File '&lt;file>' is not &lt;state>.
 /// </remarks>
 /// <param name="coreDelegates">The Core delegates component.</param>
 /// <returns>A message describing whether or not the condition is fulfilled.</returns>
 /// <seealso cref="ICondition.GetMessage(CoreDelegates)"/>
 public abstract string GetMessage(ConditionStateManager csmState, CoreDelegates coreDelegates, bool invert);
 /// <summary>
 /// Gets whether or not the condition is fulfilled.
 /// </summary>
 /// <remarks>
 /// The condition is fulfilled if the specified <see cref="File"/> is in the
 /// specified <see cref="State"/>.
 /// </remarks>
 /// <param name="coreDelegates">The Core delegates component.</param>
 /// <returns><c>true</c> if the condition is fulfilled;
 /// <c>false</c> otherwise.</returns>
 /// <seealso cref="ICondition.GetIsFulfilled(CoreDelegates)"/>
 public abstract bool GetIsFulfilled(ConditionStateManager csmState, CoreDelegates coreDelegates);
Esempio n. 25
0
 public string GetConditionMessage(ConditionStateManager csmState, CoreDelegates coreDelegates)
 {
     return(m_otrTypeResolver.ResolveConditionMessage(csmState, coreDelegates));
 }
 public string ResolveConditionMessage(ConditionStateManager csmState, CoreDelegates coreDelegates)
 {
     return(m_ptpType == OptionType.NotUsable
 ? "hardcoded"
 : null);
 }
 /// <summary>
 /// Gets the option type.
 /// </summary>
 /// <returns>The option type.</returns>
 /// <param name="coreDelegates">The Core delegates component.</param>
 public OptionType ResolveOptionType(ConditionStateManager csmState, CoreDelegates coreDelegates)
 {
     return(m_ptpType);
 }