コード例 #1
0
        /// <summary>
        ///   Builds a premade fomod pack using the given information.
        /// </summary>
        /// <remarks>
        ///   This method uses a <see cref="BackgroundWorkerProgressDialog" /> to display progress and
        ///   allow cancellation.
        /// </remarks>
        /// <param name="p_strFileName">The name of the fomod file, excluding extension.</param>
        /// <param name="p_strVersion">The version of the fomod for which we are creating the PFP.</param>
        /// <param name="p_strMachineVersion">The machine version of the fomod for which we are creating the PFP.</param>
        /// <param name="p_lstCopyInstructions">The list of files to copy into the fomod.</param>
        /// <param name="p_lstSourceFiles">The list of source files.</param>
        /// <param name="p_rmeReadme">The fomod readme.</param>
        /// <param name="p_xmlInfo">The fomod info file.</param>
        /// <param name="p_booSetScreenshot">Whether or not to set the fomod's screenshot.</param>
        /// <param name="p_shtScreenshot">The fomod screenshot.</param>
        /// <param name="p_fscScript">The fomod install script.</param>
        /// <param name="p_strPFPPath">The path where the Premade Fomod Pack will be created.</param>
        /// <returns>The path to the new premade fomod pack if it was successfully built; <lang langref="null" /> otherwise.</returns>
        public string BuildPFP(string p_strFileName, string p_strVersion, string p_strMachineVersion,
                               IList <KeyValuePair <string, string> > p_lstCopyInstructions, IList <SourceFile> p_lstSourceFiles,
                               string p_strCustomHowToSteps, Readme p_rmeReadme, XmlDocument p_xmlInfo,
                               bool p_booSetScreenshot, Screenshot p_shtScreenshot, FomodScript p_fscScript,
                               string p_strPFPPath)
        {
            string strPFPExtension;

            switch (Settings.Default.pfpCompressionFormat)
            {
            case OutArchiveFormat.BZip2:
                strPFPExtension = ".bz2";
                break;

            case OutArchiveFormat.GZip:
                strPFPExtension = ".gz";
                break;

            case OutArchiveFormat.SevenZip:
                strPFPExtension = ".7z";
                break;

            case OutArchiveFormat.Tar:
                strPFPExtension = ".tar";
                break;

            case OutArchiveFormat.XZ:
                strPFPExtension = ".xz";
                break;

            case OutArchiveFormat.Zip:
                strPFPExtension = ".zip";
                break;

            default:
                throw new Exception("Unrecognized value for OutArchiveFormat enum.");
            }
            var strVersion = p_strVersion;

            if (strVersion.Length > 8)
            {
                strVersion = p_strMachineVersion;
            }
            var strPFPPath = Path.Combine(p_strPFPPath,
                                          String.Format("{0} {1}{2}", p_strFileName, strVersion, strPFPExtension));

            strPFPPath = GenerateFomod(new BuildPFPArgs(p_strFileName,
                                                        p_lstCopyInstructions,
                                                        p_lstSourceFiles,
                                                        p_strCustomHowToSteps,
                                                        p_rmeReadme,
                                                        p_xmlInfo,
                                                        p_booSetScreenshot,
                                                        p_shtScreenshot,
                                                        p_fscScript,
                                                        strPFPPath
                                                        ));
            return(strPFPPath);
        }
コード例 #2
0
 /// <summary>
 ///   A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_strFomodName">The value with which to initialize the <see cref="FomodName" /> property.</param>
 /// <param name="p_lstCopyInstructions">The value with which to initialize the <see cref="CopyInstructions" /> property.</param>
 /// <param name="p_lstSourceFiles">The value with which to initialize the <see cref="SourceFiles" /> property.</param>
 /// <param name="p_strCustomHowToSteps">Custom howto steps that should be included in the PFP HowTo.</param>
 /// <param name="p_rmeReadme">The value with which to initialize the <see cref="Readme" /> property.</param>
 /// <param name="p_xmlInfo">The value with which to initialize the <see cref="Info" /> property.</param>
 /// <param name="p_booSetScreenshot">The value with which to initialize the <see cref="SetScreenshot" /> property.</param>
 /// <param name="p_shtScreenshot">The value with which to initialize the <see cref="Screenshot" /> property.</param>
 /// <param name="p_fscScript">The value with which to initialize the <see cref="Script" /> property.</param>
 /// <param name="p_strPackedPath">The value with which to initialize the <see cref="PackedPath" /> property.</param>
 public BuildPFPArgs(string p_strFomodName, IList <KeyValuePair <string, string> > p_lstCopyInstructions,
                     IList <SourceFile> p_lstSourceFiles, string p_strCustomHowToSteps, Readme p_rmeReadme,
                     XmlDocument p_xmlInfo, bool p_booSetScreenshot, Screenshot p_shtScreenshot,
                     FomodScript p_fscScript, string p_strPackedPath)
     : base(
         p_strFomodName, p_lstCopyInstructions, p_rmeReadme, p_xmlInfo, p_booSetScreenshot, p_shtScreenshot,
         p_fscScript, p_strPackedPath)
 {
     SourceFiles      = p_lstSourceFiles;
     CustomHowToSteps = p_strCustomHowToSteps;
 }
コード例 #3
0
 /// <summary>
 ///   A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_strFomodName">The value with which to initialize the <see cref="FomodName" /> property.</param>
 /// <param name="p_lstCopyInstructions">The value with which to initialize the <see cref="CopyInstructions" /> property.</param>
 /// <param name="p_lstSourceFiles">The value with which to initialize the <see cref="SourceFiles" /> property.</param>
 /// <param name="p_strCustomHowToSteps">Custom howto steps that should be included in the PFP HowTo.</param>
 /// <param name="p_rmeReadme">The value with which to initialize the <see cref="Readme" /> property.</param>
 /// <param name="p_xmlInfo">The value with which to initialize the <see cref="Info" /> property.</param>
 /// <param name="p_booSetScreenshot">The value with which to initialize the <see cref="SetScreenshot" /> property.</param>
 /// <param name="p_shtScreenshot">The value with which to initialize the <see cref="Screenshot" /> property.</param>
 /// <param name="p_fscScript">The value with which to initialize the <see cref="Script" /> property.</param>
 /// <param name="p_strPackedPath">The value with which to initialize the <see cref="PackedPath" /> property.</param>
 public BuildPFPArgs(string p_strFomodName, IList<KeyValuePair<string, string>> p_lstCopyInstructions,
                     IList<SourceFile> p_lstSourceFiles, string p_strCustomHowToSteps, Readme p_rmeReadme,
                     XmlDocument p_xmlInfo, bool p_booSetScreenshot, Screenshot p_shtScreenshot,
                     FomodScript p_fscScript, string p_strPackedPath)
   : base(
     p_strFomodName, p_lstCopyInstructions, p_rmeReadme, p_xmlInfo, p_booSetScreenshot, p_shtScreenshot,
     p_fscScript, p_strPackedPath)
 {
   SourceFiles = p_lstSourceFiles;
   CustomHowToSteps = p_strCustomHowToSteps;
 }
コード例 #4
0
 /// <summary>
 ///   This creates a script file in the specified folder using the given <see cref="FomodScript" />
 ///   metadata.
 /// </summary>
 /// <param name="p_strFomodFomodFolder">The folder in which to create the script file.</param>
 /// <param name="p_fscScript">The metadata to use to create the file.</param>
 protected void CreateScriptFile(string p_strFomodFomodFolder, FomodScript p_fscScript)
 {
     ProgressDialog.ItemProgress        = 0;
     ProgressDialog.ItemProgressMaximum = 1;
     ProgressDialog.ItemProgressStep    = 1;
     ProgressDialog.ItemMessage         = String.Format("Creating Script File...");
     if ((p_fscScript != null) && !String.IsNullOrEmpty(p_fscScript.Text))
     {
         File.WriteAllText(Path.Combine(p_strFomodFomodFolder, p_fscScript.FileName), p_fscScript.Text);
     }
     ProgressDialog.StepItemProgress();
 }
コード例 #5
0
ファイル: NewFomodBuilder.cs プロジェクト: IntegralLee/fomm
 /// <summary>
 ///   A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_strFomodName">The value with which to initialize the <see cref="FomodName" /> property.</param>
 /// <param name="p_lstCopyPaths">The value with which to initialize the <see cref="CopyPaths" /> property.</param>
 /// <param name="p_rmeReadme">The value with which to initialize the <see cref="Readme" /> property.</param>
 /// <param name="p_xmlInfo">The value with which to initialize the <see cref="Info" /> property.</param>
 /// <param name="p_booSetScreenshot">The value with which to initialize the <see cref="SetScreenshot" /> property.</param>
 /// <param name="p_shtScreenshot">The value with which to initialize the <see cref="Screenshot" /> property.</param>
 /// <param name="p_fscScript">The value with which to initialize the <see cref="Script" /> property.</param>
 /// <param name="p_strPackedPath">The value with which to initialize the <see cref="PackedPath" /> property.</param>
 public BuildFomodArgs(string p_strFomodName, IList<KeyValuePair<string, string>> p_lstCopyPaths,
                       Readme p_rmeReadme, XmlDocument p_xmlInfo, bool p_booSetScreenshot,
                       Screenshot p_shtScreenshot, FomodScript p_fscScript, string p_strPackedPath)
   : base(p_strPackedPath)
 {
   FomodName = p_strFomodName;
   CopyInstructions = p_lstCopyPaths;
   Readme = p_rmeReadme;
   InfoFile = p_xmlInfo;
   SetScreenshot = p_booSetScreenshot;
   Screenshot = p_shtScreenshot;
   Script = p_fscScript;
 }
コード例 #6
0
 /// <summary>
 ///   A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_strFomodName">The value with which to initialize the <see cref="FomodName" /> property.</param>
 /// <param name="p_lstCopyPaths">The value with which to initialize the <see cref="CopyPaths" /> property.</param>
 /// <param name="p_rmeReadme">The value with which to initialize the <see cref="Readme" /> property.</param>
 /// <param name="p_xmlInfo">The value with which to initialize the <see cref="Info" /> property.</param>
 /// <param name="p_booSetScreenshot">The value with which to initialize the <see cref="SetScreenshot" /> property.</param>
 /// <param name="p_shtScreenshot">The value with which to initialize the <see cref="Screenshot" /> property.</param>
 /// <param name="p_fscScript">The value with which to initialize the <see cref="Script" /> property.</param>
 /// <param name="p_strPackedPath">The value with which to initialize the <see cref="PackedPath" /> property.</param>
 public BuildFomodArgs(string p_strFomodName, IList <KeyValuePair <string, string> > p_lstCopyPaths,
                       Readme p_rmeReadme, XmlDocument p_xmlInfo, bool p_booSetScreenshot,
                       Screenshot p_shtScreenshot, FomodScript p_fscScript, string p_strPackedPath)
     : base(p_strPackedPath)
 {
     FomodName        = p_strFomodName;
     CopyInstructions = p_lstCopyPaths;
     Readme           = p_rmeReadme;
     InfoFile         = p_xmlInfo;
     SetScreenshot    = p_booSetScreenshot;
     Screenshot       = p_shtScreenshot;
     Script           = p_fscScript;
 }
コード例 #7
0
ファイル: NewFomodBuilder.cs プロジェクト: BioBrainX/fomm
 /// <summary>
 /// Builds a fomod using the given information.
 /// </summary>
 /// <remarks>
 /// This method uses a <see cref="BackgroundWorkerProgressDialog"/> to display progress and
 /// allow cancellation.
 /// </remarks>
 /// <param name="p_strFileName">The name of the fomod file, excluding extension.</param>
 /// <param name="p_lstCopyInstructions">The list of files to copy into the fomod.</param>
 /// <param name="p_rmeReadme">The fomod readme.</param>
 /// <param name="p_xmlInfo">The fomod info file.</param>
 /// <param name="p_booSetScreenshot">Whether or not to set the fomod's screenshot.</param>
 /// <param name="p_shtScreenshot">The fomod screenshot.</param>
 /// <param name="p_fscScript">The fomod install script.</param>
 /// <returns>The path to the new fomod if it was successfully built; <lang cref="null"/> otherwise.</returns>
 public string BuildFomod(string p_strFileName, IList<KeyValuePair<string, string>> p_lstCopyInstructions, Readme p_rmeReadme, XmlDocument p_xmlInfo, bool p_booSetScreenshot, Screenshot p_shtScreenshot, FomodScript p_fscScript)
 {
     string strFomodPath = Path.Combine(Program.GameMode.ModDirectory, p_strFileName + ".fomod");
     strFomodPath = GenerateFomod(new BuildFomodArgs(p_strFileName,
                                                         p_lstCopyInstructions,
                                                         p_rmeReadme,
                                                         p_xmlInfo,
                                                         p_booSetScreenshot,
                                                         p_shtScreenshot,
                                                         p_fscScript,
                                                         strFomodPath
                                                         ));
     return strFomodPath;
 }
コード例 #8
0
        /// <summary>
        ///   Builds a fomod using the given information.
        /// </summary>
        /// <remarks>
        ///   This method uses a <see cref="BackgroundWorkerProgressDialog" /> to display progress and
        ///   allow cancellation.
        /// </remarks>
        /// <param name="p_strFileName">The name of the fomod file, excluding extension.</param>
        /// <param name="p_lstCopyInstructions">The list of files to copy into the fomod.</param>
        /// <param name="p_rmeReadme">The fomod readme.</param>
        /// <param name="p_xmlInfo">The fomod info file.</param>
        /// <param name="p_booSetScreenshot">Whether or not to set the fomod's screenshot.</param>
        /// <param name="p_shtScreenshot">The fomod screenshot.</param>
        /// <param name="p_fscScript">The fomod install script.</param>
        /// <returns>The path to the new fomod if it was successfully built; <lang langref="null" /> otherwise.</returns>
        public string BuildFomod(string p_strFileName, IList <KeyValuePair <string, string> > p_lstCopyInstructions,
                                 Readme p_rmeReadme, XmlDocument p_xmlInfo, bool p_booSetScreenshot,
                                 Screenshot p_shtScreenshot, FomodScript p_fscScript)
        {
            var strFomodPath = Path.Combine(Program.GameMode.ModDirectory, p_strFileName + ".fomod");

            strFomodPath = GenerateFomod(new BuildFomodArgs(p_strFileName,
                                                            p_lstCopyInstructions,
                                                            p_rmeReadme,
                                                            p_xmlInfo,
                                                            p_booSetScreenshot,
                                                            p_shtScreenshot,
                                                            p_fscScript,
                                                            strFomodPath
                                                            ));
            return(strFomodPath);
        }
コード例 #9
0
ファイル: FomodBuilderForm.cs プロジェクト: vjmira/fomm
        /// <summary>
        ///   If no script has been entered, this method looks for a script file in the selected
        ///   files, and, if one is found, uses it to populate the script editor. If one is not found,
        ///   the script is populated with the default value.
        /// </summary>
        protected void SetScriptDefault()
        {
            if (fseScriptEditor.Script == null)
            {
                FomodScript fscInstallScript = null;
                string      strScriptPath    = null;
                foreach (var strScriptName in FomodScript.ScriptNames)
                {
                    strScriptPath = Path.Combine("fomod", strScriptName);
                    IList <KeyValuePair <string, string> > lstFiles = ffsFileStructure.FindFomodFiles(strScriptPath);
                    if (lstFiles.Count > 0)
                    {
                        fscInstallScript = new FomodScript(strScriptName, null);
                        strScriptPath    = lstFiles[0].Value;
                        break;
                    }
                }

                if (fscInstallScript == null)
                {
                    if (cbxUseScript.Checked)
                    {
                        fscInstallScript = new FomodScript(FomodScriptType.CSharp, Program.GameMode.DefaultCSharpScript);
                    }
                }
                else
                {
                    cbxUseScript.Checked = true;
                    if (strScriptPath.StartsWith(Archive.ARCHIVE_PREFIX))
                    {
                        var kvpArchiveInfo = Archive.ParseArchivePath(strScriptPath);
                        var arcArchive     = new Archive(kvpArchiveInfo.Key);
                        fscInstallScript.Text = TextUtil.ByteToString(arcArchive.GetFileContents(kvpArchiveInfo.Value));
                    }
                    else if (File.Exists(strScriptPath))
                    {
                        fscInstallScript.Text = File.ReadAllText(strScriptPath);
                    }
                }

                fseScriptEditor.Script = fscInstallScript;
            }
        }
コード例 #10
0
 /// <summary>
 /// Builds a premade fomod pack using the given information.
 /// </summary>
 /// <remarks>
 /// This method uses a <see cref="BackgroundWorkerProgressDialog"/> to display progress and
 /// allow cancellation.
 /// </remarks>
 /// <param name="p_strFileName">The name of the fomod file, excluding extension.</param>
 /// <param name="p_strVersion">The version of the fomod for which we are creating the PFP.</param>
 /// <param name="p_strMachineVersion">The machine version of the fomod for which we are creating the PFP.</param>
 /// <param name="p_lstCopyInstructions">The list of files to copy into the fomod.</param>
 /// <param name="p_lstSourceFiles">The list of source files.</param>
 /// <param name="p_rmeReadme">The fomod readme.</param>
 /// <param name="p_xmlInfo">The fomod info file.</param>
 /// <param name="p_booSetScreenshot">Whether or not to set the fomod's screenshot.</param>
 /// <param name="p_shtScreenshot">The fomod screenshot.</param>
 /// <param name="p_fscScript">The fomod install script.</param>
 /// <param name="p_strPFPPath">The path where the Premade Fomod Pack will be created.</param>
 /// <returns>The path to the new premade fomod pack if it was successfully built; <lang cref="null"/> otherwise.</returns>
 public string BuildPFP(string p_strFileName, string p_strVersion, string p_strMachineVersion, IList<KeyValuePair<string, string>> p_lstCopyInstructions, IList<SourceFile> p_lstSourceFiles, string p_strCustomHowToSteps, Readme p_rmeReadme, XmlDocument p_xmlInfo, bool p_booSetScreenshot, Screenshot p_shtScreenshot, FomodScript p_fscScript, string p_strPFPPath)
 {
     string strPFPExtension = null;
     switch (Properties.Settings.Default.pfpCompressionFormat)
     {
         case OutArchiveFormat.BZip2:
             strPFPExtension = ".bz2";
             break;
         case OutArchiveFormat.GZip:
             strPFPExtension = ".gz";
             break;
         case OutArchiveFormat.SevenZip:
             strPFPExtension = ".7z";
             break;
         case OutArchiveFormat.Tar:
             strPFPExtension = ".tar";
             break;
         case OutArchiveFormat.XZ:
             strPFPExtension = ".xz";
             break;
         case OutArchiveFormat.Zip:
             strPFPExtension = ".zip";
             break;
         default:
             throw new Exception("Unrecognized value for OutArchiveFormat enum.");
     }
     string strVersion = p_strVersion;
     if (strVersion.Length > 8)
         strVersion = p_strMachineVersion;
     string strPFPPath = Path.Combine(p_strPFPPath, String.Format("{0} {1}{2}", p_strFileName, strVersion, strPFPExtension));
     strPFPPath = GenerateFomod(new BuildPFPArgs(p_strFileName,
                                                         p_lstCopyInstructions,
                                                         p_lstSourceFiles,
                                                         p_strCustomHowToSteps,
                                                         p_rmeReadme,
                                                         p_xmlInfo,
                                                         p_booSetScreenshot,
                                                         p_shtScreenshot,
                                                         p_fscScript,
                                                         strPFPPath
                                                         ));
     return strPFPPath;
 }
コード例 #11
0
        /// <summary>
        ///   Creates the howto file explaining how to use the PFP.
        /// </summary>
        /// <param name="p_strPFPFolder">The folder in which to create the howto file.</param>
        /// <param name="p_strModBaseName">The base name of the FOMod for which we are creating a PFP.</param>
        /// <param name="p_lstSourceFiles">
        ///   The list of source files. It is expected that this
        ///   list only contains sources used by the given instructions.
        /// </param>
        /// <param name="p_lstCopyInstructions">
        ///   The list of copy instructions to execute to create the fomod.
        ///   This list should not include copy instructions for files included in the PFP.
        /// </param>
        /// <param name="p_strCustomHowToSteps">Custom howto steps that should be included in the PFP HowTo.</param>
        /// <param name="p_fscScript">The FOMod script.</param>
        protected void CreatePFPHowTo(string p_strPFPFolder, string p_strModBaseName, IList <SourceFile> p_lstSourceFiles,
                                      IList <KeyValuePair <string, string> > p_lstCopyInstructions,
                                      string p_strCustomHowToSteps, FomodScript p_fscScript)
        {
            var dicSources = new Dictionary <string, Set <string> >();

            foreach (var sflSource in p_lstSourceFiles)
            {
                if (sflSource.Generated)
                {
                    continue;
                }
                if (!dicSources.ContainsKey(sflSource.URL))
                {
                    dicSources[sflSource.URL] = new Set <string>(StringComparer.InvariantCultureIgnoreCase);
                }
                dicSources[sflSource.URL].Add(sflSource.SourceFileName);
            }

            var stbHowTo       = new StringBuilder();
            var intStepCounter = 1;

            stbHowTo.AppendLine("Instructions");
            stbHowTo.AppendLine("------------").AppendLine();
            var intDownloadStep = intStepCounter;

            AppendWrappedFormat(stbHowTo, "{0}) Download the files required to build the FOMod:", intStepCounter++)
            .AppendLine();
            foreach (var kvpSource in dicSources)
            {
                stbHowTo.AppendLine(kvpSource.Value.Count > 1 ? "\tThese files:" : "\tThis file:");
                foreach (var strSource in kvpSource.Value)
                {
                    stbHowTo.Append("\t\t").AppendLine(strSource);
                }
                stbHowTo.AppendLine("\tcan be downloaded from:");
                stbHowTo.Append("\t\t").AppendLine(kvpSource.Key).AppendLine();
            }

            //insert any custom steps
            string strCollateStepFormat;

            if (!String.IsNullOrEmpty(p_strCustomHowToSteps))
            {
                var strCustomSteps = p_strCustomHowToSteps.Split(new[]
                {
                    Environment.NewLine
                }, StringSplitOptions.RemoveEmptyEntries);
                stbHowTo.AppendLine();
                var intCustomStartStep = intStepCounter;
                foreach (var strCustomStep in strCustomSteps)
                {
                    if (strCustomStep.Contains("#)"))
                    {
                        AppendWrappedFormat(stbHowTo, strCustomStep.Replace("#)", "{0})"), intStepCounter++).AppendLine();
                    }
                    else
                    {
                        AppendWrappedFormat(stbHowTo, strCustomStep).AppendLine();
                    }
                }
                stbHowTo.AppendLine();
                strCollateStepFormat =
                    String.Format(
                        "{{0}}) Put all the files you downloaded in Step {{1}}, as well as any files or folders you created in Steps {0}-{1}, into the same folder.",
                        intCustomStartStep, intStepCounter - 1);
            }
            else
            {
                strCollateStepFormat = "{0}) Put all the files you downloaded in Step {1} into the same folder.";
            }

            //decide if you are using manual or auto install
            AppendWrappedFormat(stbHowTo,
                                "{0}) If you are using FOMM 0.12.0 or newer, proceed to Step {1}, otherwise proceed to Step {2}.",
                                intStepCounter++, intStepCounter, intStepCounter + 8).AppendLine().AppendLine();

            //auto install
            var intSourceFolderStep = intStepCounter;

            AppendWrappedFormat(stbHowTo, strCollateStepFormat, intStepCounter++, intDownloadStep).AppendLine();
            AppendWrappedFormat(stbHowTo, "{0}) Start FOMM.", intStepCounter++).AppendLine();
            AppendWrappedFormat(stbHowTo, "{0}) Click the 'Package Manager' button.", intStepCounter++).AppendLine();
            AppendWrappedFormat(stbHowTo,
                                "{0}) Click the arrow on the top button in the 'Package Manager' window. Select 'Add PFP' from the menu.",
                                intStepCounter++).AppendLine();
            AppendWrappedFormat(stbHowTo,
                                "{0}) Enter the path to the Premade FOMod Pack (PFP) in the 'Premade FOMod Pack' textbox. You can click the '...' button next to the textbox to select the file, if desired. The PFP file is the archive containing this HowTo file.",
                                intStepCounter++).AppendLine();
            AppendWrappedFormat(stbHowTo,
                                "{0}) Enter the path you put all of the downloaded files into in Step {1} into the 'Source Files Folder' textbox. You can click the '...' button next to the textbox to select the folder, if desired.",
                                intStepCounter++, intSourceFolderStep).AppendLine();
            AppendWrappedFormat(stbHowTo, "{0}) Click OK.", intStepCounter++).AppendLine();
            AppendWrappedFormat(stbHowTo, "{0}) Enjoy!", intStepCounter++).AppendLine();
            stbHowTo.AppendLine();

            //manual install
            var stbExtractions = new StringBuilder();
            var stbCopies      = new StringBuilder();
            var lstExtracted   = new List <string>();

            foreach (var kvpInstruction in p_lstCopyInstructions)
            {
                var strSource = kvpInstruction.Key;
                if (strSource.StartsWith(Archive.ARCHIVE_PREFIX))
                {
                    var kvpSource   = Archive.ParseArchivePath(strSource);
                    var stkArchives = new Stack <string>();
                    var kvpArchive  = kvpSource;
                    while (kvpArchive.Key.StartsWith(Archive.ARCHIVE_PREFIX))
                    {
                        kvpArchive = Archive.ParseArchivePath(kvpArchive.Key);
                        stkArchives.Push(kvpArchive.Value);
                    }
                    stkArchives.Push(Path.GetFileName(kvpArchive.Key));
                    strSource = "";
                    while (stkArchives.Count > 0)
                    {
                        var strArchive = Path.Combine(strSource, stkArchives.Peek());
                        strSource = Path.Combine(strSource, Path.ChangeExtension(stkArchives.Pop(), null));
                        if (!lstExtracted.Contains(strArchive))
                        {
                            stbExtractions.AppendFormat("\tExtract '{0}'", strArchive).AppendLine();
                            stbExtractions.AppendFormat("\t\tto a folder named '{0}'.", strSource).AppendLine();
                            lstExtracted.Add(strArchive);
                        }
                    }
                    strSource = Path.Combine(strSource, kvpSource.Value);
                }
                else
                {
                    foreach (var sflSource in p_lstSourceFiles)
                    {
                        if (strSource.StartsWith(sflSource.Source))
                        {
                            strSource = strSource.Substring(Path.GetDirectoryName(sflSource.Source).Length + 1);
                            break;
                        }
                    }
                }
                stbCopies.AppendFormat("\tCopy '{0}'", strSource).AppendLine();
                stbCopies.AppendFormat("\t\tto '{0}'.", Path.Combine(p_strModBaseName, kvpInstruction.Value)).AppendLine();
            }

            if (stbExtractions.Length > 0)
            {
                AppendWrappedFormat(stbHowTo, "{0}) Extract the source files to the following folders:", intStepCounter++)
                .AppendLine();
                stbHowTo.Append(stbExtractions);
            }

            var intCreateFomodFolderStep = intStepCounter;

            AppendWrappedFormat(stbHowTo, "{0}) Create a folder named '{1}'.", intStepCounter++, p_strModBaseName)
            .AppendLine();
            AppendWrappedFormat(stbHowTo, "{0}) Make the following copies:", intStepCounter++).AppendLine();
            stbHowTo.Append(stbCopies);

            AppendWrappedFormat(stbHowTo,
                                "{0}) Copy the files in the included 'Premade {1}' folder into the '{1}' folder you created in Step {2}.",
                                intStepCounter++, p_strModBaseName, intCreateFomodFolderStep).AppendLine();
            if ((p_fscScript != null) && (p_fscScript.Type == FomodScriptType.XMLConfig))
            {
                var    strXMLVersion     = Parser.GetConfigVersion(p_fscScript.Text);
                string strMinFOMMVersion = null;
                switch (strXMLVersion)
                {
                case "1.0":
                    strMinFOMMVersion = "0.11.5";
                    break;

                case "2.0":
                    strMinFOMMVersion = "0.11.7";
                    break;

                case "3.0":
                    strMinFOMMVersion = "0.11.9";
                    break;

                case "4.0":
                    strMinFOMMVersion = "0.12.4";
                    break;

                case "5.0":
                    strMinFOMMVersion = "0.13.0";
                    break;
                }
                AppendWrappedFormat(stbHowTo,
                                    "{0}) If you are using FOMM {1} or newer, proceed to Step {2}, otherwise proceed to Step {3}.",
                                    intStepCounter++, strMinFOMMVersion, intStepCounter + 2, intStepCounter).AppendLine();
                stbHowTo.AppendLine();
                AppendWrappedFormat(stbHowTo, "{0}) Download the 'Old FOMM Compatibility' file.", intStepCounter++).AppendLine();
                AppendWrappedFormat(stbHowTo,
                                    "{0}) In the file you downloaded in Step {1} is a 'fomod' folder. Copy the contents of that folder into the '{2}/fomod' folder you created in Step {3}.",
                                    intStepCounter++, intStepCounter - 2, p_strModBaseName, intCreateFomodFolderStep)
                .AppendLine();
                stbHowTo.AppendLine();
            }
            AppendWrappedFormat(stbHowTo, "{0}) Start FOMM.", intStepCounter++).AppendLine();
            AppendWrappedFormat(stbHowTo, "{0}) Click the 'Package Manager' button.", intStepCounter++).AppendLine();
            AppendWrappedFormat(stbHowTo,
                                "{0}) Click the arrow on the top button in the 'Package Manager' window. Select 'Create From Folder' from the menu.",
                                intStepCounter++).AppendLine();
            AppendWrappedFormat(stbHowTo, "{0}) Select the '{1}' folder you created in Step {2}.", intStepCounter++,
                                p_strModBaseName, intCreateFomodFolderStep).AppendLine();
            AppendWrappedFormat(stbHowTo, "{0}) Click OK.", intStepCounter++).AppendLine();
            AppendWrappedFormat(stbHowTo, "{0}) Enjoy!", intStepCounter).AppendLine();

            File.WriteAllText(Path.Combine(p_strPFPFolder, "howto.txt"), stbHowTo.ToString().Replace("\t", "    "));
        }
コード例 #12
0
ファイル: FomodGenerator.cs プロジェクト: IntegralLee/fomm
 /// <summary>
 ///   This creates a script file in the specified folder using the given <see cref="FomodScript" />
 ///   metadata.
 /// </summary>
 /// <param name="p_strFomodFomodFolder">The folder in which to create the script file.</param>
 /// <param name="p_fscScript">The metadata to use to create the file.</param>
 protected void CreateScriptFile(string p_strFomodFomodFolder, FomodScript p_fscScript)
 {
   ProgressDialog.ItemProgress = 0;
   ProgressDialog.ItemProgressMaximum = 1;
   ProgressDialog.ItemProgressStep = 1;
   ProgressDialog.ItemMessage = String.Format("Creating Script File...");
   if ((p_fscScript != null) && !String.IsNullOrEmpty(p_fscScript.Text))
   {
     File.WriteAllText(Path.Combine(p_strFomodFomodFolder, p_fscScript.FileName), p_fscScript.Text);
   }
   ProgressDialog.StepItemProgress();
 }
コード例 #13
0
ファイル: FomodBuilderForm.cs プロジェクト: IntegralLee/fomm
    /// <summary>
    ///   If no script has been entered, this method looks for a script file in the selected
    ///   files, and, if one is found, uses it to populate the script editor. If one is not found,
    ///   the script is populated with the default value.
    /// </summary>
    protected void SetScriptDefault()
    {
      if (fseScriptEditor.Script == null)
      {
        FomodScript fscInstallScript = null;
        string strScriptPath = null;
        foreach (var strScriptName in FomodScript.ScriptNames)
        {
          strScriptPath = Path.Combine("fomod", strScriptName);
          IList<KeyValuePair<string, string>> lstFiles = ffsFileStructure.FindFomodFiles(strScriptPath);
          if (lstFiles.Count > 0)
          {
            fscInstallScript = new FomodScript(strScriptName, null);
            strScriptPath = lstFiles[0].Value;
            break;
          }
        }

        if (fscInstallScript == null)
        {
          if (cbxUseScript.Checked)
          {
            fscInstallScript = new FomodScript(FomodScriptType.CSharp, Program.GameMode.DefaultCSharpScript);
          }
        }
        else
        {
          cbxUseScript.Checked = true;
          if (strScriptPath.StartsWith(Archive.ARCHIVE_PREFIX))
          {
            var kvpArchiveInfo = Archive.ParseArchivePath(strScriptPath);
            var arcArchive = new Archive(kvpArchiveInfo.Key);
            fscInstallScript.Text = TextUtil.ByteToString(arcArchive.GetFileContents(kvpArchiveInfo.Value));
          }
          else if (File.Exists(strScriptPath))
          {
            fscInstallScript.Text = File.ReadAllText(strScriptPath);
          }
        }

        fseScriptEditor.Script = fscInstallScript;
      }
    }
コード例 #14
0
    /// <summary>
    ///   Creates the howto file explaining how to use the PFP.
    /// </summary>
    /// <param name="p_strPFPFolder">The folder in which to create the howto file.</param>
    /// <param name="p_strModBaseName">The base name of the FOMod for which we are creating a PFP.</param>
    /// <param name="p_lstSourceFiles">
    ///   The list of source files. It is expected that this
    ///   list only contains sources used by the given instructions.
    /// </param>
    /// <param name="p_lstCopyInstructions">
    ///   The list of copy instructions to execute to create the fomod.
    ///   This list should not include copy instructions for files included in the PFP.
    /// </param>
    /// <param name="p_strCustomHowToSteps">Custom howto steps that should be included in the PFP HowTo.</param>
    /// <param name="p_fscScript">The FOMod script.</param>
    protected void CreatePFPHowTo(string p_strPFPFolder, string p_strModBaseName, IList<SourceFile> p_lstSourceFiles,
                                  IList<KeyValuePair<string, string>> p_lstCopyInstructions,
                                  string p_strCustomHowToSteps, FomodScript p_fscScript)
    {
      var dicSources = new Dictionary<string, Set<string>>();
      foreach (var sflSource in p_lstSourceFiles)
      {
        if (sflSource.Generated)
        {
          continue;
        }
        if (!dicSources.ContainsKey(sflSource.URL))
        {
          dicSources[sflSource.URL] = new Set<string>(StringComparer.InvariantCultureIgnoreCase);
        }
        dicSources[sflSource.URL].Add(sflSource.SourceFileName);
      }

      var stbHowTo = new StringBuilder();
      var intStepCounter = 1;
      stbHowTo.AppendLine("Instructions");
      stbHowTo.AppendLine("------------").AppendLine();
      var intDownloadStep = intStepCounter;
      AppendWrappedFormat(stbHowTo, "{0}) Download the files required to build the FOMod:", intStepCounter++)
        .AppendLine();
      foreach (var kvpSource in dicSources)
      {
        stbHowTo.AppendLine(kvpSource.Value.Count > 1 ? "\tThese files:" : "\tThis file:");
        foreach (var strSource in kvpSource.Value)
        {
          stbHowTo.Append("\t\t").AppendLine(strSource);
        }
        stbHowTo.AppendLine("\tcan be downloaded from:");
        stbHowTo.Append("\t\t").AppendLine(kvpSource.Key).AppendLine();
      }

      //insert any custom steps
      string strCollateStepFormat;
      if (!String.IsNullOrEmpty(p_strCustomHowToSteps))
      {
        var strCustomSteps = p_strCustomHowToSteps.Split(new[]
        {
          Environment.NewLine
        }, StringSplitOptions.RemoveEmptyEntries);
        stbHowTo.AppendLine();
        var intCustomStartStep = intStepCounter;
        foreach (var strCustomStep in strCustomSteps)
        {
          if (strCustomStep.Contains("#)"))
          {
            AppendWrappedFormat(stbHowTo, strCustomStep.Replace("#)", "{0})"), intStepCounter++).AppendLine();
          }
          else
          {
            AppendWrappedFormat(stbHowTo, strCustomStep).AppendLine();
          }
        }
        stbHowTo.AppendLine();
        strCollateStepFormat =
          String.Format(
            "{{0}}) Put all the files you downloaded in Step {{1}}, as well as any files or folders you created in Steps {0}-{1}, into the same folder.",
            intCustomStartStep, intStepCounter - 1);
      }
      else
      {
        strCollateStepFormat = "{0}) Put all the files you downloaded in Step {1} into the same folder.";
      }

      //decide if you are using manual or auto install
      AppendWrappedFormat(stbHowTo,
                          "{0}) If you are using FOMM 0.12.0 or newer, proceed to Step {1}, otherwise proceed to Step {2}.",
                          intStepCounter++, intStepCounter, intStepCounter + 8).AppendLine().AppendLine();

      //auto install
      var intSourceFolderStep = intStepCounter;
      AppendWrappedFormat(stbHowTo, strCollateStepFormat, intStepCounter++, intDownloadStep).AppendLine();
      AppendWrappedFormat(stbHowTo, "{0}) Start FOMM.", intStepCounter++).AppendLine();
      AppendWrappedFormat(stbHowTo, "{0}) Click the 'Package Manager' button.", intStepCounter++).AppendLine();
      AppendWrappedFormat(stbHowTo,
                          "{0}) Click the arrow on the top button in the 'Package Manager' window. Select 'Add PFP' from the menu.",
                          intStepCounter++).AppendLine();
      AppendWrappedFormat(stbHowTo,
                          "{0}) Enter the path to the Premade FOMod Pack (PFP) in the 'Premade FOMod Pack' textbox. You can click the '...' button next to the textbox to select the file, if desired. The PFP file is the archive containing this HowTo file.",
                          intStepCounter++).AppendLine();
      AppendWrappedFormat(stbHowTo,
                          "{0}) Enter the path you put all of the downloaded files into in Step {1} into the 'Source Files Folder' textbox. You can click the '...' button next to the textbox to select the folder, if desired.",
                          intStepCounter++, intSourceFolderStep).AppendLine();
      AppendWrappedFormat(stbHowTo, "{0}) Click OK.", intStepCounter++).AppendLine();
      AppendWrappedFormat(stbHowTo, "{0}) Enjoy!", intStepCounter++).AppendLine();
      stbHowTo.AppendLine();

      //manual install
      var stbExtractions = new StringBuilder();
      var stbCopies = new StringBuilder();
      var lstExtracted = new List<string>();
      foreach (var kvpInstruction in p_lstCopyInstructions)
      {
        var strSource = kvpInstruction.Key;
        if (strSource.StartsWith(Archive.ARCHIVE_PREFIX))
        {
          var kvpSource = Archive.ParseArchivePath(strSource);
          var stkArchives = new Stack<string>();
          var kvpArchive = kvpSource;
          while (kvpArchive.Key.StartsWith(Archive.ARCHIVE_PREFIX))
          {
            kvpArchive = Archive.ParseArchivePath(kvpArchive.Key);
            stkArchives.Push(kvpArchive.Value);
          }
          stkArchives.Push(Path.GetFileName(kvpArchive.Key));
          strSource = "";
          while (stkArchives.Count > 0)
          {
            var strArchive = Path.Combine(strSource, stkArchives.Peek());
            strSource = Path.Combine(strSource, Path.ChangeExtension(stkArchives.Pop(), null));
            if (!lstExtracted.Contains(strArchive))
            {
              stbExtractions.AppendFormat("\tExtract '{0}'", strArchive).AppendLine();
              stbExtractions.AppendFormat("\t\tto a folder named '{0}'.", strSource).AppendLine();
              lstExtracted.Add(strArchive);
            }
          }
          strSource = Path.Combine(strSource, kvpSource.Value);
        }
        else
        {
          foreach (var sflSource in p_lstSourceFiles)
          {
            if (strSource.StartsWith(sflSource.Source))
            {
              strSource = strSource.Substring(Path.GetDirectoryName(sflSource.Source).Length + 1);
              break;
            }
          }
        }
        stbCopies.AppendFormat("\tCopy '{0}'", strSource).AppendLine();
        stbCopies.AppendFormat("\t\tto '{0}'.", Path.Combine(p_strModBaseName, kvpInstruction.Value)).AppendLine();
      }

      if (stbExtractions.Length > 0)
      {
        AppendWrappedFormat(stbHowTo, "{0}) Extract the source files to the following folders:", intStepCounter++)
          .AppendLine();
        stbHowTo.Append(stbExtractions);
      }

      var intCreateFomodFolderStep = intStepCounter;
      AppendWrappedFormat(stbHowTo, "{0}) Create a folder named '{1}'.", intStepCounter++, p_strModBaseName)
        .AppendLine();
      AppendWrappedFormat(stbHowTo, "{0}) Make the following copies:", intStepCounter++).AppendLine();
      stbHowTo.Append(stbCopies);

      AppendWrappedFormat(stbHowTo,
                          "{0}) Copy the files in the included 'Premade {1}' folder into the '{1}' folder you created in Step {2}.",
                          intStepCounter++, p_strModBaseName, intCreateFomodFolderStep).AppendLine();
      if ((p_fscScript != null) && (p_fscScript.Type == FomodScriptType.XMLConfig))
      {
        var strXMLVersion = Parser.GetConfigVersion(p_fscScript.Text);
        string strMinFOMMVersion = null;
        switch (strXMLVersion)
        {
          case "1.0":
            strMinFOMMVersion = "0.11.5";
            break;
          case "2.0":
            strMinFOMMVersion = "0.11.7";
            break;
          case "3.0":
            strMinFOMMVersion = "0.11.9";
            break;
          case "4.0":
            strMinFOMMVersion = "0.12.4";
            break;
          case "5.0":
            strMinFOMMVersion = "0.13.0";
            break;
        }
        AppendWrappedFormat(stbHowTo,
                            "{0}) If you are using FOMM {1} or newer, proceed to Step {2}, otherwise proceed to Step {3}.",
                            intStepCounter++, strMinFOMMVersion, intStepCounter + 2, intStepCounter).AppendLine();
        stbHowTo.AppendLine();
        AppendWrappedFormat(stbHowTo, "{0}) Download the 'Old FOMM Compatibility' file.", intStepCounter++).AppendLine();
        AppendWrappedFormat(stbHowTo,
                            "{0}) In the file you downloaded in Step {1} is a 'fomod' folder. Copy the contents of that folder into the '{2}/fomod' folder you created in Step {3}.",
                            intStepCounter++, intStepCounter - 2, p_strModBaseName, intCreateFomodFolderStep)
          .AppendLine();
        stbHowTo.AppendLine();
      }
      AppendWrappedFormat(stbHowTo, "{0}) Start FOMM.", intStepCounter++).AppendLine();
      AppendWrappedFormat(stbHowTo, "{0}) Click the 'Package Manager' button.", intStepCounter++).AppendLine();
      AppendWrappedFormat(stbHowTo,
                          "{0}) Click the arrow on the top button in the 'Package Manager' window. Select 'Create From Folder' from the menu.",
                          intStepCounter++).AppendLine();
      AppendWrappedFormat(stbHowTo, "{0}) Select the '{1}' folder you created in Step {2}.", intStepCounter++,
                          p_strModBaseName, intCreateFomodFolderStep).AppendLine();
      AppendWrappedFormat(stbHowTo, "{0}) Click OK.", intStepCounter++).AppendLine();
      AppendWrappedFormat(stbHowTo, "{0}) Enjoy!", intStepCounter).AppendLine();

      File.WriteAllText(Path.Combine(p_strPFPFolder, "howto.txt"), stbHowTo.ToString().Replace("\t", "    "));
    }