Example #1
0
        private void AddFomod(string modpath, bool addToList)
        {
            fomod mod;

            try
            {
                mod = new fomod(modpath);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error loading '" + Path.GetFileName(modpath) + "'\n" + ex.Message);
                return;
            }
            for (var i = mods.Count - 1; i >= 0; i--)
            {
                if (mods[i].filepath.Equals(mod.filepath))
                {
                    mods.RemoveAt(i);
                    break;
                }
            }
            mods.Add(mod);
            if (addToList)
            {
                AddFomodToList(mod);
            }
        }
Example #2
0
        /// <summary>
        ///   Activates, Reactivates, or Deactivates the selected mod as appropriate.
        /// </summary>
        /// <param name="mod">The mod to act upon.</param>
        /// <param name="p_booReactivate">If this is a reativation request.</param>
        private void ToggleActivation(fomod mod, bool p_booReactivate)
        {
            if (!mod.IsActive)
            {
                ActivateFomod(mod);
            }
            else if (p_booReactivate)
            {
                var mraReactivator = new ModReactivator(mod);
                mraReactivator.Upgrade();
            }
            else
            {
                var mduUninstaller = new ModUninstaller(mod);
                mduUninstaller.Uninstall();
            }
            if (cbGroups.Checked)
            {
                foreach (ListViewItem lvi in lvModList.Items)
                {
                    if (lvi.Tag == mod)
                    {
                        lvi.Checked = mod.IsActive;
                    }
                }
            }
            else
            {
                lvModList.SelectedItems[0].Checked = mod.IsActive;
            }
            butDeactivate.Enabled = mod.IsActive;
            bActivate.Text        = !mod.IsActive ? "Activate" : "Reactivate";

            mf.RefreshPluginList();
        }
Example #3
0
        /// <summary>
        ///   Saves the edited info to the given fomod.
        /// </summary>
        /// <param name="p_fomodMod">The <see cref="fomod" /> to which to save the info.</param>
        /// <returns>
        ///   <lang langref="false" /> if the info failed validation and was not saved;
        ///   <lang langref="true" /> otherwise.
        /// </returns>
        public bool SaveFomod(fomod p_fomodMod)
        {
            if (!ValidateChildren())
            {
                return(false);
            }

            if (!String.IsNullOrEmpty(tbVersion.Text) && String.IsNullOrEmpty(tbMVersion.Text))
            {
                erpErrors.SetError(tbMVersion, "Machine must be specified if Version is specified.");
                return(false);
            }

            p_fomodMod.ModName = ModName;
            p_fomodMod.Author  = Author;
            p_fomodMod.HumanReadableVersion = String.IsNullOrEmpty(HumanReadableVersion)
        ? MachineVersion.ToString()
        : HumanReadableVersion;
            p_fomodMod.MachineVersion = MachineVersion;
            p_fomodMod.Description    = Description;
            p_fomodMod.Website        = Website;
            p_fomodMod.Email          = Email;
            p_fomodMod.MinFommVersion = MinFommVersion;
            p_fomodMod.Groups         = Groups;
            p_fomodMod.CommitInfo(true, Screenshot);

            return(true);
        }
 /// <summary>
 ///   A simple constructor that initializes the object.
 /// </summary>
 /// <param name="p_fomodMod">The <see cref="fomod" /> against which to run the script.</param>
 public Fallout3ModInstallScript(fomod p_fomodMod, ModInstallerBase p_mibInstaller)
   : base(p_fomodMod, p_mibInstaller)
 {
   //m_misScript = new ModInstallScript(p_fomodMod);
   BsaManager = new BsaManager();
   TextureManager = new TextureManager();
 }
Example #5
0
        public InfoEditor(fomod p_fomodMod)
        {
            InitializeComponent();
            this.Icon = Fomm.Properties.Resources.fomm02;
            Properties.Settings.Default.windowPositions.GetWindowPosition("InfoEditor", this);

            m_fomodMod = p_fomodMod;
            finInfo.LoadFomod(m_fomodMod);
        }
Example #6
0
        private void AddFomodToList(fomod mod)
        {
            string strWebVersion;

            m_dicWebVersions.TryGetValue(mod.BaseName, out strWebVersion);

            if (lvModList.Items.ContainsKey(mod.BaseName))
            {
                lvModList.Items.RemoveByKey(mod.BaseName);
            }

            if (!cbGroups.Checked)
            {
                var lvi = new ListViewItem(new[]
                {
                    mod.ModName, mod.HumanReadableVersion, strWebVersion, mod.Author
                });
                lvi.Tag              = mod;
                lvi.Name             = mod.BaseName;
                lvi.Checked          = mod.IsActive;
                lvi.SubItems[2].Name = "WebVersion";
                lvModList.Items.Add(lvi);
                return;
            }
            var added = false;

            for (var i = 0; i < groups.Count; i++)
            {
                if (Array.IndexOf(mod.Groups, lgroups[i]) != -1)
                {
                    added = true;
                    var lvi = new ListViewItem(new[]
                    {
                        mod.ModName, mod.HumanReadableVersion, strWebVersion, mod.Author
                    });
                    lvi.Tag              = mod;
                    lvi.Name             = mod.BaseName;
                    lvi.Checked          = mod.IsActive;
                    lvi.SubItems[2].Name = "WebVersion";
                    lvModList.Items.Add(lvi);
                    lvModList.Groups[i + 1].Items.Add(lvi);
                }
            }
            if (!added)
            {
                var lvi = new ListViewItem(new[]
                {
                    mod.ModName, mod.HumanReadableVersion, strWebVersion, mod.Author
                });
                lvi.Tag              = mod;
                lvi.Name             = mod.BaseName;
                lvi.Checked          = mod.IsActive;
                lvi.SubItems[2].Name = "WebVersion";
                lvModList.Items.Add(lvi);
                lvModList.Groups[0].Items.Add(lvi);
            }
        }
Example #7
0
        public InfoEditor(fomod p_fomodMod)
        {
            InitializeComponent();
            Icon = Resources.fomm02;
            Settings.Default.windowPositions.GetWindowPosition("InfoEditor", this);

            m_fomodMod = p_fomodMod;
            finInfo.LoadFomod(m_fomodMod);
        }
Example #8
0
 private void ReaddFomodToList(fomod mod)
 {
     lvModList.SuspendLayout();
     for (var i = 0; i < lvModList.Items.Count; i++)
     {
         if (lvModList.Items[i].Tag == mod)
         {
             lvModList.Items.RemoveAt(i--);
         }
     }
     AddFomodToList(mod);
     lvModList.ResumeLayout();
 }
Example #9
0
        /// <summary>
        /// A simple constructor that initializes the object.
        /// </summary>
        /// <param name="p_fomodMod">The <see cref="fomod"/> to be installed or uninstalled.</param>
        public ModInstallScript(fomod p_fomodMod, ModInstallerBase p_mibInstaller)
        {
            m_fomodMod = p_fomodMod;

            //make sure the permissions manager is initialized.
            // static members are (usually) only loaded upon first access.
            // this can cause a problem for our permissions manager as if
            // the first time it is called is in a domain with limited access
            // to the machine then the initialization will fail.
            // to prevent this, we call it now to make sure it is ready when we need it.
            object objIgnore = PermissionsManager.CurrentPermissions;

            m_mibInstaller = p_mibInstaller;
            //m_tfmFileManager = new TxFileManager();
        }
Example #10
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();
 }
Example #11
0
    /// <summary>
    ///   Upgrades the Install Log to the current version from version 0.1.0.0.
    /// </summary>
    /// <remarks>
    ///   This method is called by a background worker to perform the actual upgrade.
    /// </remarks>
    protected override void DoUpgrade()
    {
      var xmlInstallLog = new XmlDocument();
      xmlInstallLog.LoadXml(InstallLog.Current.InstallLogPath);

      var xndRoot = xmlInstallLog.SelectSingleNode("installLog");
      var xndSdpEdits = xndRoot.SelectSingleNode("sdpEdits");
      var lstMods = InstallLog.Current.GetModList();

      ProgressWorker.OverallProgressStep = 1;
      ProgressWorker.OverallProgressMaximum = lstMods.Count + xndSdpEdits.ChildNodes.Count;
      ProgressWorker.ShowItemProgress = false;

      //remove the sdp edit node...
      xndSdpEdits.ParentNode.RemoveChild(xndSdpEdits);
      //...and replace it with the game-specific edits node
      var xndGameSpecificsValueEdits = xndRoot.AppendChild(xmlInstallLog.CreateElement("gameSpecificEdits"));
      foreach (XmlNode xndSdpEdit in xndSdpEdits.ChildNodes)
      {
        ProgressWorker.StepOverallProgress();
        var xndGameSpecificsValueEdit = xndGameSpecificsValueEdits.AppendChild(xmlInstallLog.CreateElement("edit"));
        var strValueKey = String.Format("sdp:{0}/{1}", xndGameSpecificsValueEdits.Attributes["package"].Value,
                                        xndGameSpecificsValueEdits.Attributes["shader"].Value);
        xndGameSpecificsValueEdit.Attributes.Append(xmlInstallLog.CreateAttribute("key")).Value = strValueKey;
        xndGameSpecificsValueEdit.AppendChild(xndSdpEdit.FirstChild.Clone());
      }
      xmlInstallLog.Save(InstallLog.Current.InstallLogPath);

      //now update the mod info
      foreach (var strMod in lstMods)
      {
        ProgressWorker.StepOverallProgress();
        if (strMod.Equals(InstallLog.ORIGINAL_VALUES) || strMod.Equals(InstallLog.FOMM))
        {
          continue;
        }
        var strModPath = Path.Combine(Program.GameMode.ModDirectory, strMod + ".fomod");
        var fomodMod = new fomod(strModPath);
        InstallLog.Current.UpdateMod(fomodMod);
      }

      InstallLog.Current.SetInstallLogVersion(InstallLog.CURRENT_VERSION);
      InstallLog.Current.Save();
    }
Example #12
0
        /// <summary>
        ///   A simple constructor that initializes the object.
        /// </summary>
        /// <param name="p_fomodMod">The <see cref="fomod" /> to be installed or uninstalled.</param>
        public ModInstallScript(fomod p_fomodMod, ModInstallerBase p_mibInstaller)
        {
            Fomod = p_fomodMod;

            //make sure the permissions manager is initialized.
            // static members are (usually) only loaded upon first access.
            // this can cause a problem for our permissions manager as if
            // the first time it is called is in a domain with limited access
            // to the machine then the initialization will fail.
            // to prevent this, we call it now to make sure it is ready when we need it.

            // ReSharper disable once UnusedVariable
            object objIgnore = PermissionsManager.CurrentPermissions;

            // ReSharper restore UnusedVariable

            Installer = p_mibInstaller;
            //m_tfmFileManager = new TxFileManager();
        }
Example #13
0
        /// <summary>
        ///   Activates the given fomod.
        /// </summary>
        /// <remarks>
        ///   This method checks to see if the given fomod could be an upgrade for another fomod.
        /// </remarks>
        /// <param name="mod">The fomod to activate.</param>
        private void ActivateFomod(fomod mod)
        {
            var booFound = false;

            foreach (ListViewItem lviFomod in lvModList.Items)
            {
                var fomodMod = (fomod)lviFomod.Tag;
                if (fomodMod.ModName.Equals(mod.ModName) && fomodMod.IsActive && !fomodMod.BaseName.Equals(mod.BaseName))
                {
                    //ask to do upgrade
                    var strUpgradeMessage =
                        "A different version of {0} has been detected. The installed version is {1}, the new version is {2}. Would you like to upgrade?" +
                        Environment.NewLine + "Selecting No will install the new FOMod normally.";
                    switch (
                        MessageBox.Show(
                            String.Format(strUpgradeMessage, fomodMod.ModName, fomodMod.HumanReadableVersion, mod.HumanReadableVersion),
                            "Upgrade", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    {
                    case DialogResult.Yes:
                        var mduUpgrader = new ModUpgrader(mod, fomodMod.BaseName);
                        mduUpgrader.Upgrade();
                        if (mod.IsActive)
                        {
                            fomodMod.IsActive = false;
                            lviFomod.Checked  = false;
                        }
                        return;

                    case DialogResult.No:
                        booFound = true;
                        break;
                    }
                }
                if (booFound)
                {
                    break;
                }
            }
            var mdiInstaller = new ModInstaller(mod);

            mdiInstaller.Install();
        }
Example #14
0
    /// <summary>
    ///   Upgrades the Install Log to the current version from version 0.0.0.0.
    /// </summary>
    /// <remarks>
    ///   This method is called by a background worker to perform the actual upgrade.
    /// </remarks>
    protected override void DoUpgrade()
    {
      InstallLog.Current.Reset();

      var strModInstallFiles = Directory.GetFiles(Program.GameMode.ModDirectory, "*.XMl",
                                                  SearchOption.TopDirectoryOnly);
      ProgressWorker.OverallProgressStep = 1;
      ProgressWorker.OverallProgressMaximum = strModInstallFiles.Length;
      ProgressWorker.ItemProgressStep = 1;

      foreach (var strModInstallLog in strModInstallFiles)
      {
        if (ProgressWorker.Cancelled())
        {
          return;
        }

        var strFomodPath = Path.ChangeExtension(strModInstallLog, ".fomod");
        if (File.Exists(strFomodPath))
        {
          var xmlModInstallLog = new XmlDocument();
          xmlModInstallLog.Load(strModInstallLog);
          //figure out how much work we need to do for this mod
          var xnlFiles = xmlModInstallLog.SelectNodes("descendant::installedFiles/*");
          var xnlIniEdits = xmlModInstallLog.SelectNodes("descendant::iniEdits/*");
          var xnlSdpEdits = xmlModInstallLog.SelectNodes("descendant::sdpEdits/*");
          var intItemCount = xnlFiles.Count + xnlIniEdits.Count + xnlSdpEdits.Count;
          ProgressWorker.ItemMessage = Path.GetFileNameWithoutExtension(strModInstallLog);
          ProgressWorker.ItemProgress = 0;
          ProgressWorker.ItemProgressMaximum = intItemCount;

          var fomodMod = new fomod(strFomodPath);
          var strModBaseName = fomodMod.BaseName;
          InstallLog.Current.AddMod(fomodMod);

          m_dicDefaultFileOwners = new Dictionary<string, string>();
          UpgradeInstalledFiles(xmlModInstallLog, fomodMod, strModBaseName);
          //we now have to tell all the remaining default owners that are are indeed
          // the owners
          foreach (var kvpOwner in m_dicDefaultFileOwners)
          {
            MakeOverwrittenModOwner(kvpOwner.Value, kvpOwner.Key);
          }
          if (ProgressWorker.Cancelled())
          {
            return;
          }

          UpgradeIniEdits(xmlModInstallLog, strModBaseName);
          if (ProgressWorker.Cancelled())
          {
            return;
          }

          UpgradeSdpEdits(xmlModInstallLog, strModBaseName);
          if (ProgressWorker.Cancelled())
          {
            return;
          }

          if (File.Exists(strModInstallLog + ".bak"))
          {
            FileManager.Delete(strModInstallLog + ".bak");
          }
          FileManager.Move(strModInstallLog, strModInstallLog + ".bak");
        }
        ProgressWorker.StepOverallProgress();
      }
      InstallLog.Current.SetInstallLogVersion(InstallLog.CURRENT_VERSION);
      InstallLog.Current.Save();
    }
Example #15
0
 /// <summary>
 ///   A simple constructor that initializes the object.
 /// </summary>
 /// <param name="p_fomodMod">The <see cref="fomod" /> to be installed.</param>
 internal ModInstaller(fomod p_fomodMod)
   : base(p_fomodMod) {}
Example #16
0
 /// <summary>
 /// Creates a mod upgrade script for the given <see cref="fomod"/>.
 /// </summary>
 /// <param name="p_fomodMod">The mod for which to create an installer script.</param>
 /// <param name="p_mibInstaller">The installer for which the script is being created.</param>
 /// <returns>A mod upgrade script for the given <see cref="fomod"/>.</returns>
 public abstract ModInstallScript CreateUpgradeScript(fomod p_fomodMod, ModInstallerBase p_mibInstaller);
Example #17
0
 /// <summary>
 /// Activates the given fomod.
 /// </summary>
 /// <remarks>
 /// This method checks to see if the given fomod could be an upgrade for another fomod.
 /// </remarks>
 /// <param name="mod">The fomod to activate.</param>
 private void ActivateFomod(fomod mod)
 {
     bool booFound = false;
     fomod fomodMod = null;
     foreach (ListViewItem lviFomod in lvModList.Items)
     {
         fomodMod = (fomod)lviFomod.Tag;
         if (fomodMod.ModName.Equals(mod.ModName) && fomodMod.IsActive && !fomodMod.BaseName.Equals(mod.BaseName))
         {
             //ask to do upgrade
             string strUpgradeMessage = "A different version of {0} has been detected. The installed version is {1}, the new version is {2}. Would you like to upgrade?" + Environment.NewLine + "Selecting No will install the new FOMod normally.";
             switch (MessageBox.Show(String.Format(strUpgradeMessage, fomodMod.ModName, fomodMod.HumanReadableVersion, mod.HumanReadableVersion), "Upgrade", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
             {
                 case DialogResult.Yes:
                     ModUpgrader mduUpgrader = new ModUpgrader(mod, fomodMod.BaseName);
                     mduUpgrader.Upgrade();
                     if (mod.IsActive)
                     {
                         fomodMod.IsActive = false;
                         lviFomod.Checked = false;
                     }
                     return;
                 case DialogResult.No:
                     booFound = true;
                     break;
             }
         }
         if (booFound)
             break;
     }
     ModInstaller mdiInstaller = new ModInstaller(mod);
     mdiInstaller.Install();
 }
Example #18
0
 private void AddFomod(string modpath, bool addToList)
 {
     fomod mod;
     try
     {
         mod = new fomod(modpath);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error loading '" + Path.GetFileName(modpath) + "'\n" + ex.Message);
         return;
     }
     for (Int32 i = mods.Count - 1; i >= 0; i--)
         if (mods[i].filepath.Equals(mod.filepath))
         {
             mods.RemoveAt(i);
             break;
         }
     mods.Add(mod);
     if (addToList) AddFomodToList(mod);
 }
Example #19
0
        /// <summary>
        /// Activates, Reactivates, or Deactivates the selected mod as appropriate.
        /// </summary>
        /// <param name="mod">The mod to act upon.</param>
        /// <param name="p_booReactivate">If this is a reativation request.</param>
        private void ToggleActivation(fomod mod, bool p_booReactivate)
        {
            if (!mod.IsActive)
            {
                ActivateFomod(mod);
            }
            else if (p_booReactivate)
            {
                ModReactivator mraReactivator = new ModReactivator(mod);
                mraReactivator.Upgrade();
            }
            else
            {
                ModUninstaller mduUninstaller = new ModUninstaller(mod);
                mduUninstaller.Uninstall();
            }
            if (cbGroups.Checked)
            {
                foreach (ListViewItem lvi in lvModList.Items)
                {
                    if (lvi.Tag == mod) lvi.Checked = mod.IsActive;
                }
            }
            else
            {
                lvModList.SelectedItems[0].Checked = mod.IsActive;
            }
            butDeactivate.Enabled = mod.IsActive;
            if (!mod.IsActive) bActivate.Text = "Activate";
            else bActivate.Text = "Reactivate";

            mf.RefreshPluginList();
        }
Example #20
0
 /// <summary>
 ///   A simple constructor that initializes the object.
 /// </summary>
 /// <param name="p_fomodMod">The <see cref="fomod" /> to be installed or uninstalled.</param>
 public ModInstallerBase(fomod p_fomodMod)
 {
   Fomod = p_fomodMod;
 }
Example #21
0
 private void ReaddFomodToList(fomod mod)
 {
     lvModList.SuspendLayout();
     for (int i = 0; i < lvModList.Items.Count; i++) if (lvModList.Items[i].Tag == mod) lvModList.Items.RemoveAt(i--);
     AddFomodToList(mod);
     lvModList.ResumeLayout();
 }
Example #22
0
        /// <summary>
        /// Upgrades the Install Log to the current version from version 0.0.0.0.
        /// </summary>
        /// <remarks>
        /// This method is called by a background worker to perform the actual upgrade.
        /// </remarks>
        protected override void DoUpgrade()
        {
            #if TRACE
            Trace.WriteLine("Upgrading from 0.0.0.0");
            #endif
            InstallLog.Current.Reset();

            string[] strModInstallFiles = Directory.GetFiles(Program.GameMode.ModDirectory, "*.XMl", SearchOption.TopDirectoryOnly);
            ProgressWorker.OverallProgressStep = 1;
            ProgressWorker.OverallProgressMaximum = strModInstallFiles.Length;
            ProgressWorker.ItemProgressStep = 1;

            XmlDocument xmlModInstallLog = null;
            string strModBaseName = null;
            fomod fomodMod = null;
            foreach (string strModInstallLog in strModInstallFiles)
            {
            #if TRACE
                Trace.WriteLine("Upgrading: " + strModInstallLog);
                Trace.Indent();
            #endif
                if (ProgressWorker.Cancelled())
                    return;

                string strFomodPath = Path.ChangeExtension(strModInstallLog, ".fomod");
                if (File.Exists(strFomodPath))
                {
                    xmlModInstallLog = new XmlDocument();
                    xmlModInstallLog.Load(strModInstallLog);
            #if TRACE
                Trace.WriteLine("Parsed");
            #endif
                    //figure out how much work we need to do for this mod
                    XmlNodeList xnlFiles = xmlModInstallLog.SelectNodes("descendant::installedFiles/*");
                    XmlNodeList xnlIniEdits = xmlModInstallLog.SelectNodes("descendant::iniEdits/*");
                    XmlNodeList xnlSdpEdits = xmlModInstallLog.SelectNodes("descendant::sdpEdits/*");
                    Int32 intItemCount = xnlFiles.Count + xnlIniEdits.Count + xnlSdpEdits.Count;
                    ProgressWorker.ItemMessage = Path.GetFileNameWithoutExtension(strModInstallLog);
                    ProgressWorker.ItemProgress = 0;
                    ProgressWorker.ItemProgressMaximum = intItemCount;

                    fomodMod = new fomod(strFomodPath);
                    strModBaseName = fomodMod.BaseName;
                    InstallLog.Current.AddMod(fomodMod);

            #if TRACE
                Trace.Write("Upgrading files...");
            #endif
                    m_dicDefaultFileOwners = new Dictionary<string, string>();
                    UpgradeInstalledFiles(xmlModInstallLog, fomodMod, strModBaseName);
                    //we now have to tell all the remaining default owners that are are indeed
                    // the owners
                    foreach (KeyValuePair<string, string> kvpOwner in m_dicDefaultFileOwners)
                        MakeOverwrittenModOwner(kvpOwner.Value, kvpOwner.Key);
            #if TRACE
                Trace.WriteLine("Done.");
            #endif
                    if (ProgressWorker.Cancelled())
                        return;

            #if TRACE
                Trace.Write("Upgrading INI edits...");
            #endif
                    UpgradeIniEdits(xmlModInstallLog, strModBaseName);
            #if TRACE
                Trace.WriteLine("Done.");
            #endif
                    if (ProgressWorker.Cancelled())
                        return;

            #if TRACE
                Trace.Write("Upgrading SDP edits...");
            #endif
                    UpgradeSdpEdits(xmlModInstallLog, strModBaseName);
            #if TRACE
                Trace.WriteLine("Done.");
            #endif
                    if (ProgressWorker.Cancelled())
                        return;

                    if (File.Exists(strModInstallLog + ".bak"))
                        FileManager.Delete(strModInstallLog + ".bak");
                    FileManager.Move(strModInstallLog, strModInstallLog + ".bak");
                }
                ProgressWorker.StepOverallProgress();
            #if TRACE
                Trace.Unindent();
                Trace.WriteLine("Done: " + strModInstallLog);
            #endif
            }
            InstallLog.Current.SetInstallLogVersion(InstallLog.CURRENT_VERSION);
            InstallLog.Current.Save();
        }
Example #23
0
 /// <summary>
 ///   A simple constructor that initializes the object.
 /// </summary>
 /// <param name="p_fomodMod">The <see cref="fomod" /> to be installed or uninstalled.</param>
 public ModInstallerBase(fomod p_fomodMod)
 {
     Fomod = p_fomodMod;
 }
Example #24
0
 /// <summary>
 ///   A simple constructor that initializes the object.
 /// </summary>
 /// <param name="p_fomodMod">The <see cref="fomod" /> to be uninstalled.</param>
 public ModUninstaller(fomod p_fomodMod)
     : base(p_fomodMod)
 {
 }
 /// <summary>
 ///   A simple constructor that initializes the object.
 /// </summary>
 /// <param name="p_fomodMod">The <see cref="fomod" /> against which to run the script.</param>
 public FalloutNewVegasModUpgradeScript(fomod p_fomodMod, ModInstallerBase p_mibInstaller)
   : base(p_fomodMod, p_mibInstaller) {}
Example #26
0
        private void AddFomodToList(fomod mod)
        {
            if ((m_nxaNexus != null) && !String.IsNullOrEmpty(mod.Website) && m_nxaNexus.IsNexusMod(mod.Website) != -1)
            {
                if (!m_dicWebVersions.ContainsKey(mod.BaseName))
                {
                    Int32 intFileId = m_nxaNexus.IsNexusMod(mod.Website);
                    try
                    {
                        m_nxaNexus.GetModInfoAsync(intFileId, false, Nexus_GotFileVersion, mod.BaseName);
                    }
                    catch (Exception e)
                    {
            #if TRACE
                        Trace.WriteLine("Couldn't get version from " + mod.Website);
                        Program.TraceException(e);
                        Trace.Flush();
            #endif
                    }
                }
            }

            string strWebVersion = "NA";
            m_dicWebVersions.TryGetValue(mod.BaseName, out strWebVersion);

            if (lvModList.Items.ContainsKey(mod.BaseName))
                lvModList.Items.RemoveByKey(mod.BaseName);

            if (!cbGroups.Checked)
            {
                ListViewItem lvi = new ListViewItem(new string[] { mod.ModName, mod.HumanReadableVersion, strWebVersion, mod.Author });
                lvi.Tag = mod;
                lvi.Name = mod.BaseName;
                lvi.Checked = mod.IsActive;
                lvi.SubItems[2].Name = "WebVersion";
                lvModList.Items.Add(lvi);
                return;
            }
            bool added = false;
            for (int i = 0; i < groups.Count; i++)
            {
                if (Array.IndexOf<string>(mod.Groups, lgroups[i]) != -1)
                {
                    added = true;
                    ListViewItem lvi = new ListViewItem(new string[] { mod.ModName, mod.HumanReadableVersion, strWebVersion, mod.Author });
                    lvi.Tag = mod;
                    lvi.Name = mod.BaseName;
                    lvi.Checked = mod.IsActive;
                    lvi.SubItems[2].Name = "WebVersion";
                    lvModList.Items.Add(lvi);
                    lvModList.Groups[i + 1].Items.Add(lvi);
                }
            }
            if (!added)
            {
                ListViewItem lvi = new ListViewItem(new string[] { mod.ModName, mod.HumanReadableVersion, strWebVersion, mod.Author });
                lvi.Tag = mod;
                lvi.Name = mod.BaseName;
                lvi.Checked = mod.IsActive;
                lvi.SubItems[2].Name = "WebVersion";
                lvModList.Items.Add(lvi);
                lvModList.Groups[0].Items.Add(lvi);
            }
        }
Example #27
0
 /// <summary>
 ///   A simple constructor that initializes the object.
 /// </summary>
 /// <param name="p_fomodMod">The <see cref="fomod" /> to be installed.</param>
 internal ModInstaller(fomod p_fomodMod)
     : base(p_fomodMod)
 {
 }
Example #28
0
 /// <summary>
 /// A simple constructor that initializes the object.
 /// </summary>
 /// <param name="p_fomodMod">The <see cref="fomod"/> to be reactivated.</param>
 internal ModReactivator(fomod p_fomodMod)
     : base(p_fomodMod)
 {
 }
Example #29
0
        /// <summary>
        /// Upgrades the installed files log entries.
        /// </summary>
        /// <remarks>
        /// This analyses the mods and determines, as best as possible, who owns which files, and attempts
        /// to reconstruct the install order. It populates the overwrites folder with the files that, as far
        /// as can be determined, belong there. This resulting information is then put in the new install log.
        /// </remarks>
        /// <param name="p_xmlModInstallLog">The current mod install log we are parsing to upgrade.</param>
        /// <param name="p_strModInstallLogPath">The path to the current mod install log.</param>
        /// <param name="p_strModBaseName">The base name of the mod whose install log is being parsed.</param>
        private void UpgradeInstalledFiles(XmlDocument p_xmlModInstallLog, fomod p_fomodMod, string p_strModBaseName)
        {
            Int32 intDataPathStartPos = Program.GameMode.PluginsPath.Trim(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar).Length + 1;
            XmlNodeList xnlFiles = p_xmlModInstallLog.SelectNodes("descendant::installedFiles/*");
            foreach (XmlNode xndFile in xnlFiles)
            {
                string strFile = xndFile.InnerText;
                if (!File.Exists(strFile))
                    continue;
                string strDataRelativePath = strFile.Substring(intDataPathStartPos);

                Crc32 crcDiskFile = new Crc32();
                Crc32 crcFomodFile = new Crc32();
                crcDiskFile.Update(File.ReadAllBytes(strFile));
                if (!p_fomodMod.ContainsFile(strDataRelativePath))
                {
                    //we don't know if this mod owns the file, so let's assume
                    // it doesn't
                    //put this mod's file into the overwrites directory.
                    // we can't get the original file from the fomod,
                    // so we'll use the existing file instead. this isn't
                    // strictly correct, but it is inline with the behaviour
                    // of the fomm version we are upgrading from
                    string strDirectory = Path.GetDirectoryName(strDataRelativePath);
                    string strBackupPath = Path.Combine(Program.GameMode.OverwriteDirectory, strDirectory);
                    string strModKey = InstallLog.Current.GetModKey(p_strModBaseName);
                    if (!Directory.Exists(strBackupPath))
                        FileManager.CreateDirectory(strBackupPath);
                    strBackupPath = Path.Combine(strBackupPath, strModKey + "_" + Path.GetFileName(strDataRelativePath));
                    FileManager.Copy(Path.Combine(Program.GameMode.PluginsPath, strDataRelativePath), strBackupPath, true);
                    InstallLog.Current.PrependDataFile(p_strModBaseName, strDataRelativePath);

                    //however, it may own the file, so let's make it the default owner for now
                    // unless we already know who the owner is
                    if (!FileOwnerIsKnown(strDataRelativePath))
                        m_dicDefaultFileOwners[strDataRelativePath] = p_strModBaseName;
                    continue;
                }
                byte[] bteFomodFile = p_fomodMod.GetFile(strDataRelativePath);
                crcFomodFile.Update(bteFomodFile);
                if (!crcDiskFile.Value.Equals(crcFomodFile.Value) || FileOwnerIsKnown(strDataRelativePath))
                {
                    //either:
                    // 1) another mod owns the file
                    // 2) according to the crc we own this file, however we have already found
                    //    an owner. this could happen beacue two mods use the same version
                    //    of a file, or there is a crc collision.
                    //either way, put this mod's file into
                    // the overwrites directory
                    string strDirectory = Path.GetDirectoryName(strDataRelativePath);
                    string strBackupPath = Path.Combine(Program.GameMode.OverwriteDirectory, strDirectory);
                    string strModKey = InstallLog.Current.GetModKey(p_strModBaseName);
                    if (!Directory.Exists(strBackupPath))
                        FileManager.CreateDirectory(strBackupPath);
                    strBackupPath = Path.Combine(strBackupPath, strModKey + "_" + Path.GetFileName(strDataRelativePath));
                    FileManager.WriteAllBytes(strBackupPath, bteFomodFile);
                    InstallLog.Current.PrependDataFile(p_strModBaseName, strDataRelativePath);
                }
                else
                {
                    //this mod owns the file, so append it to the list of installing mods
                    InstallLog.Current.AddDataFile(p_strModBaseName, strDataRelativePath);

                    //we also have to displace the mod that is currently the default owner
                    if (m_dicDefaultFileOwners.ContainsKey(strDataRelativePath))
                        m_dicDefaultFileOwners.Remove(strDataRelativePath);
                }

                if (ProgressWorker.Cancelled())
                    return;
                ProgressWorker.StepItemProgress();
            }
        }
    /// <summary>
    ///   Called when the conflict detector has found a conflict.
    /// </summary>
    /// <remarks>
    ///   This adds a message to the appropriate plugin's info box, and changes the plugin's
    ///   node's background colour as appropriate.
    /// </remarks>
    /// <param name="sender">The object that trigger the event.</param>
    /// <param name="e">A <see cref="ConflictDetectedEventArgs" /> describing the event arguments.</param>
    private void cdrDetector_ConflictDetected(object sender, ConflictDetectedEventArgs e)
    {
      var stbMessage = new StringBuilder();
      var lstBackgroundColours = new List<Color>
      {
        Color.LightSkyBlue,
        Color.Yellow,
        Color.Red
      };
      var intColourIndex = 0;
      switch (e.ConflictInfo.Severity)
      {
        case CriticalRecordInfo.ConflictSeverity.Conflict:
          stbMessage.Append(@"\b \cf1 CONFLICT\cf0 :\b0  ");
          intColourIndex = 2;
          break;
        case CriticalRecordInfo.ConflictSeverity.Warning:
          stbMessage.Append(@"\b \cf2 WARNING\cf0 :\b0  ");
          intColourIndex = 1;
          break;
        case CriticalRecordInfo.ConflictSeverity.Info:
          stbMessage.Append(@"\b \cf3 INFO\cf0 :\b0  ");
          intColourIndex = 0;
          break;
      }
      var clrHighlight = lstBackgroundColours[intColourIndex];
      if (m_pfpFormatProvider.HasFormat(e.ConflictedPlugin.Name))
      {
        var pftFormat = m_pfpFormatProvider.GetFormat(e.ConflictedPlugin.Name);
        if (pftFormat.Highlight.HasValue && (lstBackgroundColours.IndexOf(pftFormat.Highlight.Value) > intColourIndex))
        {
          clrHighlight = pftFormat.Highlight.Value;
        }
      }

      if (InstallLog.Current.GetCurrentFileOwnerName(e.ConflictingPlugin.Name) == null)
      {
        stbMessage.AppendFormat(
          "Form Id \\b {0:x8}\\b0  is overridden by \\b {1}\\b0 .\\par \\pard\\li720\\sl240\\slmult1 {2}\\par \\pard\\sl240\\slmult1 ",
          e.FormId, e.ConflictingPlugin.Name, e.ConflictInfo.Reason);
      }
      else
      {
        var fomodMod =
          new fomod(Path.Combine(Program.GameMode.ModDirectory,
                                 InstallLog.Current.GetCurrentFileOwnerName(e.ConflictingPlugin.Name) + ".fomod"));
        stbMessage.AppendFormat(
          "Form Id \\b {0:x8}\\b0  is overridden by \\b {1}\\b0  in \\b {2}\\b0 .\\par \\pard\\li720\\sl240\\slmult1 {3}\\par \\pard\\sl240\\slmult1 ",
          e.FormId, e.ConflictingPlugin.Name, fomodMod.ModName, e.ConflictInfo.Reason);
      }
      m_pfpFormatProvider.AddFormat(e.ConflictedPlugin.Name, clrHighlight, stbMessage.ToString());
    }
Example #31
0
 /// <summary>
 ///   Creates a mod upgrade script for the given <see cref="fomod" />.
 /// </summary>
 /// <param name="p_fomodMod">The mod for which to create an installer script.</param>
 /// <param name="p_mibInstaller">The installer for which the script is being created.</param>
 /// <returns>A mod upgrade script for the given <see cref="fomod" />.</returns>
 public override ModInstallScript CreateUpgradeScript(fomod p_fomodMod, ModInstallerBase p_mibInstaller)
 {
     return new FalloutNewVegasModUpgradeScript(p_fomodMod, p_mibInstaller);
 }
Example #32
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();
 }
Example #33
0
 /// <summary>
 ///   A simple constructor that initializes the object.
 /// </summary>
 /// <param name="p_fomodMod">The <see cref="fomod" /> to be uninstalled.</param>
 public ModUninstaller(fomod p_fomodMod)
   : base(p_fomodMod) {}
Example #34
0
        /// <summary>
        /// Saves the edited info to the given fomod.
        /// </summary>
        /// <param name="p_fomodMod">The <see cref="fomod"/> to which to save the info.</param>
        /// <returns><lang cref="false"/> if the info failed validation and was not saved;
        /// <lang cref="true"/> otherwise.</returns>
        public bool SaveFomod(fomod p_fomodMod)
        {
            if (!this.ValidateChildren())
                return false;

            if (!String.IsNullOrEmpty(tbVersion.Text) && String.IsNullOrEmpty(tbMVersion.Text))
            {
                erpErrors.SetError(tbMVersion, "Machine must be specified if Version is specified.");
                return false;
            }

            p_fomodMod.ModName = ModName;
            p_fomodMod.Author = Author;
            p_fomodMod.HumanReadableVersion = String.IsNullOrEmpty(HumanReadableVersion) ? MachineVersion.ToString() : HumanReadableVersion;
            p_fomodMod.MachineVersion = MachineVersion;
            p_fomodMod.Description = Description;
            p_fomodMod.Website = Website;
            p_fomodMod.Email = Email;
            p_fomodMod.MinFommVersion = MinFommVersion;
            p_fomodMod.Groups = Groups;
            p_fomodMod.CommitInfo(true, Screenshot);

            return true;
        }
Example #35
0
 /// <summary>
 ///   A simple constructor that initializes the object.
 /// </summary>
 /// <param name="p_fomodMod">The <see cref="fomod" /> to be reactivated.</param>
 internal ModReactivator(fomod p_fomodMod)
     : base(p_fomodMod)
 {
 }
Example #36
0
    private void AddFomodToList(fomod mod)
    {
      string strWebVersion;
      m_dicWebVersions.TryGetValue(mod.BaseName, out strWebVersion);

      if (lvModList.Items.ContainsKey(mod.BaseName))
      {
        lvModList.Items.RemoveByKey(mod.BaseName);
      }

      if (!cbGroups.Checked)
      {
        var lvi = new ListViewItem(new[]
        {
          mod.ModName, mod.HumanReadableVersion, strWebVersion, mod.Author
        });
        lvi.Tag = mod;
        lvi.Name = mod.BaseName;
        lvi.Checked = mod.IsActive;
        lvi.SubItems[2].Name = "WebVersion";
        lvModList.Items.Add(lvi);
        return;
      }
      var added = false;
      for (var i = 0; i < groups.Count; i++)
      {
        if (Array.IndexOf(mod.Groups, lgroups[i]) != -1)
        {
          added = true;
          var lvi = new ListViewItem(new[]
          {
            mod.ModName, mod.HumanReadableVersion, strWebVersion, mod.Author
          });
          lvi.Tag = mod;
          lvi.Name = mod.BaseName;
          lvi.Checked = mod.IsActive;
          lvi.SubItems[2].Name = "WebVersion";
          lvModList.Items.Add(lvi);
          lvModList.Groups[i + 1].Items.Add(lvi);
        }
      }
      if (!added)
      {
        var lvi = new ListViewItem(new[]
        {
          mod.ModName, mod.HumanReadableVersion, strWebVersion, mod.Author
        });
        lvi.Tag = mod;
        lvi.Name = mod.BaseName;
        lvi.Checked = mod.IsActive;
        lvi.SubItems[2].Name = "WebVersion";
        lvModList.Items.Add(lvi);
        lvModList.Groups[0].Items.Add(lvi);
      }
    }