Exemplo n.º 1
0
 private async Task<Dictionary<string, object>> DeployVIGO (CoreDelegates core)
 {
     bool deployedBundle = false;
     string message = "Failed to deploy VIGO";
     try {
         string extensionPath = await core.context.GetExtensionPath ();
         string modLoaderPath = await core.context.GetModLoaderPath ();
         string [] uiFiles = new string [] {
         Path.Combine(extensionPath, Constants.UI_BUNDLE_FILENAME),
         Path.Combine(extensionPath, Constants.UI_BUNDLE_FILENAME + ".manifest"),
     };
         try {
             string bundledAssetsDest = Path.Combine (modLoaderPath, "VortexBundles", "UI");
             Directory.CreateDirectory (bundledAssetsDest);
             foreach (string file in uiFiles) {
                 string strDest = Path.Combine (bundledAssetsDest, Path.GetFileName (file));
                 File.Copy (file, strDest, true);
                 deployedBundle = true;
                 message = "VIGO deployed successfully";
             }
         } catch (Exception e) {
             // This is fine, some extensions might not provide bundled UI assets.
             //  all this means is that the in-game UI will not look that great.
             message = e.Message;
         }
     } catch (Exception e) {
         message = e.Message;
     }
     
     return PatchHelper.CreatePatchResult (deployedBundle, message);
 }
Exemplo n.º 2
0
        async public Task <Dictionary <string, object> > IsPatchApplicable(JObject data,
                                                                           CoreDelegates coreDelegates)
        {
            string      message;
            bool        result   = false;
            PatchConfig config   = new PatchConfig((JObject)data ["patchConfig"]);
            string      dataPath = await coreDelegates.context.GetDataPath();

            try {
                if (IsReflectionEnabled(dataPath))
                {
                    // Reflection already enabled - no need to do anything.
                    message = "Reflection is enabled";
                    result  = false;
                }
                else
                {
                    message = "Can be applied";
                    result  = true;
                }
            } catch (Exception exc) {
                result  = false;
                message = exc.Message;
            }
            var addendum = new Dictionary <string, object> ()
            {
                { "Source", config.SourceEntryPoint.ToString() },
                { "Targets", config.TargetEntryPoints.ToString() }
            };

            return(PatchHelper.CreatePatchResult(result, message, addendum));
        }
Exemplo n.º 3
0
        /// <summary>
        /// This will assign all files to the proper destination.
        /// </summary>
        /// <param name="fileList">The list of files inside the mod archive.</param>
        /// <param name="stopPatterns">patterns matching files or directories that should be at the top of the directory structure.</param>
        /// <param name="progressDelegate">A delegate to provide progress feedback.</param>
        /// <param name="coreDelegate">A delegate for all the interactions with the js core.</param>
        protected async Task <List <Instruction> > BasicModInstall(List <string> fileList,
                                                                   List <string> stopPatterns,
                                                                   ProgressDelegate progressDelegate,
                                                                   CoreDelegates coreDelegate)
        {
            List <Instruction> FilesToInstall = new List <Instruction>();
            string             prefix         = ArchiveStructure.FindPathPrefix(fileList, stopPatterns);

            await Task.Run(() =>
            {
                foreach (string ArchiveFile in fileList)
                {
                    if (ArchiveFile.EndsWith("" + Path.DirectorySeparatorChar))
                    {
                        // don't include directories, only files
                        continue;
                    }
                    string destination;
                    if (ArchiveFile.StartsWith(prefix))
                    {
                        destination = ArchiveFile.Substring(prefix.Length);
                    }
                    else
                    {
                        destination = ArchiveFile;
                    }
                    FilesToInstall.Add(Instruction.CreateCopy(ArchiveFile, destination));
                    // Progress should increase.
                }
            });

            return(FilesToInstall);
        }
Exemplo n.º 4
0
        public async Task <Dictionary <string, object> > ApplyPatch(JObject data,
                                                                    ProgressDelegate progress,
                                                                    CoreDelegates core)
        {
            Dictionary <string, object> res = await IsPatchApplicable(data, core);

            if (res ["Result"].ToString() == "False")
            {
                return(res);
            }

            res = await ReflectionPatch.Instance.ApplyPatch(data, progress, core);

            if (res ["Result"].ToString() == "False")
            {
                return(res);
            }

            if (await core.context.IsDeploymentRequired())
            {
                res = await DeployFiles(core);

                if (res ["Result"].ToString() == "False")
                {
                    return(res);
                }
            }

            return(await Injector.Instance.ApplyPatch(data, progress, core));
        }
Exemplo n.º 5
0
        public async Task <object> Install(dynamic input)
        {
            object[] files        = (object[])input.files;
            object[] stopPatterns = (object[])input.stopPatterns;
            object   pluginPath   = input.pluginPath;
            // this is actually the temporary path where the files requested in TestSupported
            // were put.
            string  destinationPath = (string)input.scriptPath;
            var     progressCB      = (Func <object, Task <object> >)input.progressDelegate;
            dynamic choices         = null;

            try
            {
                choices = input.choices;
            }
            catch (RuntimeBinderException) {
            }
            CoreDelegates coreDelegates = new CoreDelegates(input.coreDelegates);

            return(await mInstaller.Install(
                       new List <string>(files.Cast <string>()),
                       new List <string>(stopPatterns.Cast <string>()),
                       (string)pluginPath,
                       destinationPath,
                       choices,
                       (ProgressDelegate)((int percent) => progressCB(percent)),
                       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>
        /// <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);
        }
Exemplo n.º 7
0
 /// <summary>
 /// This will simulate the mod installation and decide installation choices and files final paths.
 /// </summary>
 /// <param name="modArchiveFileList">The list of files inside the mod archive.</param>
 /// <param name="stopPatterns">patterns matching files or directories that should be at the top of the directory structure.</param>
 /// <param name="pluginPath">skip as the first path component in installer destinations</param>
 /// <param name="destinationPath">The file install destination folder.</param>
 /// <param name="progressDelegate">A delegate to provide progress feedback.</param>
 /// <param name="coreDelegate">A delegate for all the interactions with the js core.</param>
 public abstract Task <Dictionary <string, object> > Install(List <string> modArchiveFileList,
                                                             List <string> stopPatterns,
                                                             string pluginPath,
                                                             string destinationPath,
                                                             dynamic preset,
                                                             ProgressDelegate progressDelegate,
                                                             CoreDelegates coreDelegate);
Exemplo n.º 8
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>
 /// <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()));
 }
Exemplo n.º 10
0
 /// <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));
 }
Exemplo n.º 11
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 "));
 }
Exemplo n.º 12
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("File '{0}' is {1}", PluginPath, State.ToString(), invert ? "" : "not "));
 }
Exemplo n.º 13
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)
 {
     if (GetIsFulfilled(csmState, coreDelegates))
     {
         return("Passed");
     }
     return(string.Format("Flag '{0}' is not {1}.", FlagName, Value));
 }
Exemplo n.º 14
0
        public async Task<Dictionary<string, object>> IsPatchApplicable (JObject data,
                                                                   CoreDelegates core)
        {
            PatchConfig config = new PatchConfig ((JObject)data ["patchConfig"]);
            Dictionary<string, object> res = await ReflectionPatch.Instance.IsPatchApplicable (data, core);
            if (res ["Result"].ToString () == "false")
                return res;

            return await Injector.Instance.IsPatchApplicable (data, (ProgressDelegate)((int progress) => { }), core);
        }
Exemplo n.º 15
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)
        {
            string strValue = null;

            csmState.FlagValues.TryGetValue(FlagName, out strValue);
            if (string.IsNullOrEmpty(Value))
            {
                return(string.IsNullOrEmpty(strValue));
            }
            return(Value.Equals(strValue));
        }
Exemplo n.º 16
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);
 }
Exemplo n.º 17
0
        public async Task<Dictionary<string, object>> RemovePatch (JObject data,
                                                                   ProgressDelegate progress,
                                                                   CoreDelegates coreDelegates)
        {
            try {
                string modLoaderPath = await coreDelegates.context.GetModLoaderPath ();
                string bundledAssetsDest = Path.Combine (modLoaderPath, "VortexBundles");
                PurgeVIGO (bundledAssetsDest);
            } catch (Exception) {
                // Failed to purge VIGO, not a big deal
            }

            return await Injector.Instance.RemovePatch (data, progress, coreDelegates);
        }
Exemplo n.º 18
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));
        }
Exemplo n.º 19
0
        async public Task <Dictionary <string, object> > ApplyPatch(JObject data,
                                                                    ProgressDelegate progress,
                                                                    CoreDelegates coreDelegates)
        {
            PatchConfig config   = new PatchConfig((JObject)data ["patchConfig"]);
            string      dataPath = await coreDelegates.context.GetDataPath();

            string modLoaderPath = await coreDelegates.context.GetModLoaderPath();

            // We know this is a dictionary, but I'm too lazy to type.
            var result = await EnableReflection(dataPath, modLoaderPath);

            result.Add("Source", config.SourceEntryPoint.ToString());
            result.Add("Targets", config.TargetEntryPoints.ToString());
            return(result);
        }
Exemplo n.º 20
0
        public async Task <Dictionary <string, object> > RemovePatch(JObject data,
                                                                     ProgressDelegate progress,
                                                                     CoreDelegates coreDelegates)
        {
            // We're not going to remove the reflection patch. It might still be needed.
            try {
                string dataPath = await coreDelegates.context.GetDataPath();

                PurgeFiles(dataPath);
            } catch (Exception) {
                // We failed to delete some of the dependency assemblies...
                //  that's arguably fine.
            }

            return(await Injector.Instance.RemovePatch(data, progress, coreDelegates));
        }
        /// <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));
        }
Exemplo n.º 22
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;
		}
Exemplo n.º 23
0
        /// <summary>
        /// Creates the folder structure inside the game's
        ///  folder.
        /// </summary>
        private async Task <Dictionary <string, object> > DeployFiles(CoreDelegates core)
        {
            bool   result  = true;
            string message = "VML dependencies deployed";

            try {
                string dataPath = await core.context.GetDataPath();

                if (!Directory.Exists(dataPath))
                {
                    throw new DirectoryNotFoundException(string.Format("Datapath {0} does not exist", dataPath));
                }

                string libPath = await core.context.GetVMLDepsPath();

                string modsPath = await core.context.GetModsPath();

                string modLoaderPath = await core.context.GetModLoaderPath();

                Directory.CreateDirectory(modsPath);
                string [] files = Directory.GetFiles(libPath, "*", SearchOption.TopDirectoryOnly)
                                  .Where(file => _LIB_FILES.Contains(Path.GetFileName(file)))
                                  .ToArray();

                foreach (string file in files)
                {
                    string dataPathDest      = Path.Combine(dataPath, Path.GetFileName(file));
                    string modLoaderPathDest = Path.Combine(modLoaderPath, Path.GetFileName(file));

                    if (!File.Exists(dataPathDest) || !File.Exists(modLoaderPathDest))
                    {
                        File.Copy(file, modLoaderPathDest);
                    }
                }
            } catch (Exception exc) {
                result  = false;
                message = exc.Message;
            }

            return(PatchHelper.CreatePatchResult(result, message));
        }
        /// <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);
        }
Exemplo n.º 25
0
        private async Task <object> DispatchInstall(string id, JObject data)
        {
            var files        = new List <string>(data["files"].Children().ToList().Select(input => input.ToString()));
            var stopPatterns = new List <string>(data["stopPatterns"].Children().ToList().Select(input => input.ToString()));
            var pluginPath   = data["pluginPath"].ToString();
            var scriptPath   = data["scriptPath"].ToString();

            dynamic choices;

            try
            {
                choices = data["fomodChoices"];
            }
            catch (RuntimeBinderException) {
                choices = null;
            }

            DeferContext  context       = new DeferContext(id, (targetId, targetType, name, args) => ContextIPC(targetId, targetType, name, args));
            CoreDelegates coreDelegates = new CoreDelegates(ToExpando(context));

            return(await mInstaller.Install(files, stopPatterns, pluginPath, scriptPath, choices, (ProgressDelegate)((int progress) => { }), coreDelegates));
        }
Exemplo n.º 26
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");
            }
        }
        /// <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");
        }
Exemplo n.º 28
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));
        }
Exemplo n.º 30
0
 /// <summary>
 /// A simple constructor that initializes the object with the required dependencies.
 /// </summary>
 /// <param name="modArchive">The mod object containing the file list in the mod archive.</param>
 /// <param name="UserInteractionDelegate">The utility class to use to install the mod items.</param>
 /// <param name="scxUIContext">The <see cref="SynchronizationContext"/> to use to marshall UI interactions to the UI thread.</param>
 public XmlScriptExecutor(Mod modArchive, CoreDelegates coreDelegates)
 {
     ModArchive  = modArchive;
     m_Delegates = coreDelegates;
 }