Example #1
0
        /// <summary>
        /// Checks if there's an XML with the list of files to install for the current mod, if present the list of files will be returned.
        /// </summary>
        protected List <KeyValuePair <string, string> > LoadXMLModFilesToInstall()
        {
            string strModFilesPath = String.Empty;

            if (ProfileManager != null)
            {
                strModFilesPath = ProfileManager.IsScriptedLogPresent(Mod.Filename) ?? Path.Combine(Path.Combine(GameMode.GameModeEnvironmentInfo.InstallInfoDirectory, "Scripted"), Path.GetFileNameWithoutExtension(Mod.Filename)) + ".xml";
            }
            else
            {
                strModFilesPath = Path.Combine(Path.Combine(GameMode.GameModeEnvironmentInfo.InstallInfoDirectory, "Scripted"), Path.GetFileNameWithoutExtension(Mod.Filename)) + ".xml";
            }

            if (File.Exists(strModFilesPath))
            {
                XDocument docScripted = XDocument.Load(strModFilesPath);
                List <KeyValuePair <string, string> > dicFiles = new List <KeyValuePair <string, string> >();

                try
                {
                    XElement xelFileList = docScripted.Descendants("FileList").FirstOrDefault();
                    if ((xelFileList != null) && xelFileList.HasElements)
                    {
                        foreach (XElement xelModFile in xelFileList.Elements("File"))
                        {
                            string strFileFrom = xelModFile.Attribute("FileFrom").Value;
                            string strFileTo   = xelModFile.Attribute("FileTo").Value;
                            if (!String.IsNullOrWhiteSpace(strFileFrom))
                            {
                                dicFiles.Add(new KeyValuePair <string, string>(strFileFrom, strFileTo));
                            }
                        }

                        if (dicFiles.Count > 0)
                        {
                            return(dicFiles);
                        }
                    }
                }
                catch (Exception e)
                {
                    string prova = e.Message;
                    if (String.IsNullOrEmpty(prova))
                    {
                        if (dicFiles.Count > 0)
                        {
                            return(dicFiles);
                        }
                    }
                }
            }

            return(null);
        }
Example #2
0
        /// <summary>
        /// Checks whether there's a log file for the current scripted installer.
        /// </summary>
        protected bool CheckScriptedModLog()
        {
            string strModFilesPath = Path.Combine(Path.Combine(GameMode.GameModeEnvironmentInfo.InstallInfoDirectory, "Scripted"), Path.GetFileNameWithoutExtension(Mod.Filename)) + ".xml";

            if ((ProfileManager != null) && !String.IsNullOrWhiteSpace(ProfileManager.IsScriptedLogPresent(Mod.Filename)))
            {
                return(true);
            }
            if (Directory.Exists(Path.Combine(GameMode.GameModeEnvironmentInfo.InstallInfoDirectory, "Scripted")) && File.Exists(strModFilesPath))
            {
                return(true);
            }

            return(false);
        }