Ejemplo n.º 1
0
        /// <summary>
        ///   Handles the <see cref="Control.Click" /> event of the OK button.
        /// </summary>
        /// <remarks>
        ///   This ensures that the information is valid before creating the FOMod/Premade FOMod Pack.
        /// </remarks>
        /// <param name="sender">The object that raised the event.</param>
        /// <param name="e">A <see cref="EventArgs" /> describing the event arguments.</param>
        private void butOK_Click(object sender, EventArgs e)
        {
            switch (PerformValidation())
            {
            case ValidationState.Errors:
                MessageBox.Show(this, "You must correct the errors before saving.", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;

            case ValidationState.Warnings:
                if (
                    MessageBox.Show(this,
                                    "There are warnings." + Environment.NewLine +
                                    "Warnings can be ignored, but they can indicate missing information that you meant to enter." +
                                    Environment.NewLine + "Would you like to continue?", "Warning", MessageBoxButtons.OKCancel,
                                    MessageBoxIcon.Warning) == DialogResult.Cancel)
                {
                    return;
                }
                break;

            case ValidationState.Passed:
                break;

            default:
                throw new InvalidEnumArgumentException("Unexpected value for ValidationState enum.");
            }

            var rmeReadme = redReadmeEditor.Readme;
            var fscScript = fseScriptEditor.Script;
            var xmlInfo   = m_booInfoEntered ? fomod.SaveInfo(finInfo) : null;

            var crsOldCursor = Cursor;

            Cursor = Cursors.WaitCursor;
            var lstCopyInstructions = ffsFileStructure.GetCopyInstructions();

            Cursor = crsOldCursor;

            if (cbxFomod.Checked)
            {
                var fgnGenerator = new NewFomodBuilder();
                FomodPath = fgnGenerator.BuildFomod(tbxFomodFileName.Text, lstCopyInstructions, rmeReadme, xmlInfo,
                                                    m_booInfoEntered, finInfo.Screenshot, fscScript);
                if (String.IsNullOrEmpty(FomodPath))
                {
                    return;
                }
            }
            if (cbxPFP.Checked)
            {
                Settings.Default.pfpOutputPath = tbxPFPPath.Text;
                Settings.Default.Save();

                var strVersion        = "1.0";
                var strMachineVersion = "1.0";
                var xmlInfoTmp        = fomod.SaveInfo(finInfo);
                if (xmlInfoTmp != null)
                {
                    var xndVersion = xmlInfoTmp.SelectSingleNode("/fomod/Version");
                    if (xndVersion != null)
                    {
                        strVersion = xndVersion.InnerText;
                        var xatVersion = xndVersion.Attributes["MachineVersion"];
                        if (xatVersion != null)
                        {
                            strMachineVersion = xatVersion.Value;
                        }
                    }
                }
                var fpbPackBuilder = new PremadeFomodPackBuilder();
                var strPFPPAth     = fpbPackBuilder.BuildPFP(tbxFomodFileName.Text, strVersion, strMachineVersion,
                                                             lstCopyInstructions, sdsDownloadLocations.DataSource, tbxHowTo.Text,
                                                             rmeReadme, xmlInfo, m_booInfoEntered, finInfo.Screenshot, fscScript,
                                                             tbxPFPPath.Text);
                if (String.IsNullOrEmpty(strPFPPAth))
                {
                    return;
                }
            }
            DialogResult = DialogResult.OK;
        }
Ejemplo n.º 2
0
    /// <summary>
    ///   Handles the <see cref="Control.Click" /> event of the OK button.
    /// </summary>
    /// <remarks>
    ///   This ensures that the information is valid before creating the FOMod/Premade FOMod Pack.
    /// </remarks>
    /// <param name="sender">The object that raised the event.</param>
    /// <param name="e">A <see cref="EventArgs" /> describing the event arguments.</param>
    private void butOK_Click(object sender, EventArgs e)
    {
      switch (PerformValidation())
      {
        case ValidationState.Errors:
          MessageBox.Show(this, "You must correct the errors before saving.", "Error", MessageBoxButtons.OK,
                          MessageBoxIcon.Error);
          return;
        case ValidationState.Warnings:
          if (
            MessageBox.Show(this,
                            "There are warnings." + Environment.NewLine +
                            "Warnings can be ignored, but they can indicate missing information that you meant to enter." +
                            Environment.NewLine + "Would you like to continue?", "Warning", MessageBoxButtons.OKCancel,
                            MessageBoxIcon.Warning) == DialogResult.Cancel)
          {
            return;
          }
          break;
        case ValidationState.Passed:
          break;
        default:
          throw new InvalidEnumArgumentException("Unexpected value for ValidationState enum.");
      }

      var rmeReadme = redReadmeEditor.Readme;
      var fscScript = fseScriptEditor.Script;
      var xmlInfo = m_booInfoEntered ? fomod.SaveInfo(finInfo) : null;

      var crsOldCursor = Cursor;
      Cursor = Cursors.WaitCursor;
      var lstCopyInstructions = ffsFileStructure.GetCopyInstructions();
      Cursor = crsOldCursor;

      if (cbxFomod.Checked)
      {
        var fgnGenerator = new NewFomodBuilder();
        FomodPath = fgnGenerator.BuildFomod(tbxFomodFileName.Text, lstCopyInstructions, rmeReadme, xmlInfo,
                                            m_booInfoEntered, finInfo.Screenshot, fscScript);
        if (String.IsNullOrEmpty(FomodPath))
        {
          return;
        }
      }
      if (cbxPFP.Checked)
      {
        Settings.Default.pfpOutputPath = tbxPFPPath.Text;
        Settings.Default.Save();

        var strVersion = "1.0";
        var strMachineVersion = "1.0";
        var xmlInfoTmp = fomod.SaveInfo(finInfo);
        if (xmlInfoTmp != null)
        {
          var xndVersion = xmlInfoTmp.SelectSingleNode("/fomod/Version");
          if (xndVersion != null)
          {
            strVersion = xndVersion.InnerText;
            var xatVersion = xndVersion.Attributes["MachineVersion"];
            if (xatVersion != null)
            {
              strMachineVersion = xatVersion.Value;
            }
          }
        }
        var fpbPackBuilder = new PremadeFomodPackBuilder();
        var strPFPPAth = fpbPackBuilder.BuildPFP(tbxFomodFileName.Text, strVersion, strMachineVersion,
                                                 lstCopyInstructions, sdsDownloadLocations.DataSource, tbxHowTo.Text,
                                                 rmeReadme, xmlInfo, m_booInfoEntered, finInfo.Screenshot, fscScript,
                                                 tbxPFPPath.Text);
        if (String.IsNullOrEmpty(strPFPPAth))
        {
          return;
        }
      }
      DialogResult = DialogResult.OK;
    }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the <see cref="Control.Click"/> event of the add pfp button.
        /// </summary>
        /// <remarks>
        /// Creates a FOMod from a PFP.
        /// </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 addPFPToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PremadeFomodPackForm pkfPFPForm = new PremadeFomodPackForm(PremadeFomodPackForm.OpenPFPMode.Install);
            if (pkfPFPForm.ShowDialog(this) == DialogResult.Cancel)
                return;

            PremadeFomodPack pfpPack = new PremadeFomodPack(pkfPFPForm.PFPPath);
            List<KeyValuePair<string, string>> lstCopyInstructions = pfpPack.GetCopyInstructions(pkfPFPForm.SourcesPath);
            string strPremadeSource = Archive.GenerateArchivePath(pkfPFPForm.PFPPath, pfpPack.PremadePath);
            lstCopyInstructions.Add(new KeyValuePair<string, string>(strPremadeSource, "/"));

            NewFomodBuilder fgnGenerator = new NewFomodBuilder();
            string strNewFomodPath = fgnGenerator.BuildFomod(pfpPack.FomodName, lstCopyInstructions, null, null, false, null, null);
            if (!String.IsNullOrEmpty(strNewFomodPath))
                AddFomod(strNewFomodPath, true);
        }