Пример #1
0
 /// <summary>
 ///   Handles the <see cref="Control.CLick" /> event of the set screenshot button.
 /// </summary>
 /// <remarks>
 ///   Sets the screenshot for the fomod.
 /// </remarks>
 /// <param name="sender">The object that raised the event.</param>
 /// <param name="e">An <see cref="EventArgs" /> describing the event arguments.</param>
 private void butSetScreenshot_Click(object sender, EventArgs e)
 {
   if (ofdScreenshot.ShowDialog() == DialogResult.OK)
   {
     m_shtScreenshot = new Screenshot(ofdScreenshot.FileName, File.ReadAllBytes(ofdScreenshot.FileName));
     pbxScreenshot.Image = m_shtScreenshot.Image;
   }
 }
Пример #2
0
 /// <summary>
 /// A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_strAuthor">The author of the mod.</param>
 /// <param name="p_strVersion">The version of the mod.</param>
 /// <param name="p_uriURL">The webpage of the mod.</param>
 /// <param name="p_sstScreenshot">The mod's screenshot.</param>
 public ModInfo(string p_strName, string p_strAuthor, string p_strVersion, Uri p_uriURL, Screenshot p_sstScreenshot)
 {
     ModName = p_strName;
     Author = p_strAuthor;
     Version = ModVersion.Parse(p_strVersion);
     URL = p_uriURL;
     Screenshot = p_sstScreenshot;
 }
Пример #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>
 ///   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;
 }
Пример #5
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 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;
 }
Пример #6
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;
 }
Пример #7
0
        internal void CommitInfo(bool SetScreenshot, Screenshot p_shtScreenshot)
        {
            XmlDocument xmlInfo = SaveInfo(this);
            hasInfo = true;

            MemoryStream ms = new MemoryStream();
            xmlInfo.Save(ms);
            ReplaceFile("fomod/info.xml", ms.ToArray());
            if (SetScreenshot)
            {
                if (p_shtScreenshot == null)
                {
                    if (HasScreenshot)
                    {
                        DeleteFile(m_strScreenshotPath);
                        m_strScreenshotPath = null;
                    }
                }
                else
                {
                    if (!HasScreenshot)
                        m_strScreenshotPath = "fomod/screenshot.jpg";
                    m_strScreenshotPath = Path.ChangeExtension(m_strScreenshotPath, p_shtScreenshot.Extension).ToLowerInvariant();
                    ReplaceFile(m_strScreenshotPath, p_shtScreenshot.Data);
                }
            }
        }
Пример #8
0
        public Screenshot GetScreenshot()
        {
            if (!HasScreenshot)
                return null;

            Screenshot shtScreenshot = new Screenshot(m_strScreenshotPath, GetFile(m_strScreenshotPath));
            return shtScreenshot;
        }
Пример #9
0
		/// <summary>
		/// Parse the mod info out of the mod's info page.
		/// </summary>
		/// <param name="p_strInfoPage">The info page of the mod whose information is being parsed.</param>
		/// <param name="p_booIncludeScreenshot">Whether or not to retrieve the mod's screenshot.</param>
		/// <returns>A <see cref="ModInfo"/> describing the mod's information.</returns>
		protected ModInfo ParseModInfo(Uri p_uriModUrl, string p_strInfoPage, bool p_booIncludeScreenshot)
		{
			string strName = ParseModName(p_strInfoPage);
			string strAuthor = ParseModAuthor(p_strInfoPage);
			string strVersion = ParseModVersion(p_strInfoPage);
			Screenshot sstScreenshot = null;
			if (p_booIncludeScreenshot)
			{
				Uri uriScreenshotUrl = ParseScreenshotUrl(p_strInfoPage);
				if (uriScreenshotUrl != null)
					sstScreenshot = new Screenshot(uriScreenshotUrl.ToString(), DownloadData(true, uriScreenshotUrl));
			}
			return new ModInfo(strName, strAuthor, strVersion, p_uriModUrl, sstScreenshot);
		}
Пример #10
0
 /// <summary>
 ///   This creates a screenshot file in the specified folder using the given <see cref="Screenshot" />
 ///   metadata.
 /// </summary>
 /// <remarks>
 ///   The file is only created if <paramref name="p_booSetScreenshot" /> is <lang langref="true" />. If
 ///   <paramref name="p_booSetScreenshot" /> is <lang langref="true" /> and <paramref name="p_shtScreenshot" />
 ///   is <lang langref="null" />, then any existing screenshot files will be deleted.
 /// </remarks>
 /// <param name="p_strFomodFomodFolder">The folder in which to create the screenshot file.</param>
 /// <param name="p_booSetScreenshot">Whether or not to create the file.</param>
 /// <param name="p_shtScreenshot">The metadata to use to create the file.</param>
 protected void CreateScreenshot(string p_strFomodFomodFolder, bool p_booSetScreenshot, Screenshot p_shtScreenshot)
 {
   ProgressDialog.ItemProgress = 0;
   ProgressDialog.ItemProgressMaximum = 1;
   ProgressDialog.ItemProgressStep = 1;
   ProgressDialog.ItemMessage = String.Format("Creating Screenshot...");
   if (p_booSetScreenshot)
   {
     var strScreenshots = Directory.GetFiles(p_strFomodFomodFolder, "screenshot.*",
                                             SearchOption.TopDirectoryOnly);
     foreach (var strScreenshot in strScreenshots)
     {
       FileUtil.ForceDelete(strScreenshot);
     }
     if (p_shtScreenshot != null)
     {
       File.WriteAllBytes(Path.Combine(p_strFomodFomodFolder, "screenshot" + p_shtScreenshot.Extension),
                          p_shtScreenshot.Data);
     }
   }
   ProgressDialog.StepItemProgress();
 }
Пример #11
0
 /// <summary>
 /// Handles the <see cref="Control.CLick"/> event of the clear screenshot button.
 /// </summary>
 /// <remarks>
 /// Removes the screenshot from the fomod.
 /// </remarks>
 /// <param name="sender">The object that raised the event.</param>
 /// <param name="e">An <see cref="EventArgs"/> describing the event arguments.</param>
 private void butClearScreenshot_Click(object sender, EventArgs e)
 {
     pbxScreenshot.Image = null;
     m_shtScreenshot = null;
 }
Пример #12
0
 /// <summary>
 ///   Loads the info from the given <see cref="fomod" /> into the edit form.
 /// </summary>
 /// <param name="p_fomodMod">The <see cref="fomod" /> whose info is to be edited.</param>
 public void LoadFomod(fomod p_fomodMod)
 {
   ModName = p_fomodMod.ModName;
   Author = p_fomodMod.Author;
   HumanReadableVersion = String.IsNullOrEmpty(p_fomodMod.HumanReadableVersion)
     ? p_fomodMod.MachineVersion.ToString()
     : p_fomodMod.HumanReadableVersion;
   MachineVersion = p_fomodMod.MachineVersion;
   Description = p_fomodMod.Description;
   Website = p_fomodMod.Website;
   Email = p_fomodMod.Email;
   MinFommVersion = p_fomodMod.MinFommVersion;
   Groups = p_fomodMod.Groups;
   Screenshot = p_fomodMod.GetScreenshot();
 }
Пример #13
0
 /// <summary>
 /// A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_strAuthor">The author of the mod.</param>
 /// <param name="p_strVersion">The version of the mod.</param>
 /// <param name="p_uriURL">The webpage of the mod.</param>
 /// <param name="p_sstScreenshot">The mod's screenshot.</param>
 public ModInfo(string p_strName, string p_strAuthor, string p_strVersion, Uri p_uriURL, Screenshot p_sstScreenshot)
 {
     ModName    = p_strName;
     Author     = p_strAuthor;
     Version    = p_strVersion;
     URL        = p_uriURL;
     Screenshot = p_sstScreenshot;
 }