Exemplo n.º 1
0
        /// <summary>
        ///   Installs the mod and activates it.
        /// </summary>
        protected override bool DoScript()
        {
            foreach (var strSettingsFile in Program.GameMode.SettingsFiles.Values)
            {
                TransactionalFileManager.Snapshot(strSettingsFile);
            }
            foreach (var strAdditionalFile in Program.GameMode.AdditionalPaths.Values)
            {
                if (File.Exists(strAdditionalFile))
                {
                    TransactionalFileManager.Snapshot(strAdditionalFile);
                }
            }
            TransactionalFileManager.Snapshot(InstallLog.Current.InstallLogPath);

            try
            {
                MergeModule = new InstallLogMergeModule();
                if (Fomod.HasInstallScript)
                {
                    var fscInstallScript = Fomod.GetInstallScript();
                    switch (fscInstallScript.Type)
                    {
                    case FomodScriptType.CSharp:
                        Fomod.IsActive = RunCustomInstallScript();
                        break;

                    case FomodScriptType.XMLConfig:
                        Fomod.IsActive = RunXmlInstallScript();
                        break;
                    }
                }
                else
                {
                    Fomod.IsActive = RunBasicInstallScript("Installing Fomod");
                }

                if (Fomod.IsActive)
                {
                    InstallLog.Current.Merge(Fomod, MergeModule);
                    Script.CommitActivePlugins();
                }
            }
            catch (Exception e)
            {
                Fomod.IsActive = false;
                throw e;
            }
            if (!Fomod.IsActive)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        ///   Performs an in-place upgrade of the <see cref="fomod" />.
        /// </summary>
        protected override bool DoScript()
        {
            foreach (var strSettingsFile in Program.GameMode.SettingsFiles.Values)
            {
                TransactionalFileManager.Snapshot(strSettingsFile);
            }
            foreach (var strAdditionalFile in Program.GameMode.AdditionalPaths.Values)
            {
                if (File.Exists(strAdditionalFile))
                {
                    TransactionalFileManager.Snapshot(strAdditionalFile);
                }
            }
            TransactionalFileManager.Snapshot(InstallLog.Current.InstallLogPath);

            var booUpgraded = false;

            try
            {
                MergeModule = new InstallLogMergeModule();
                if (Fomod.HasInstallScript)
                {
                    var fscInstallScript = Fomod.GetInstallScript();
                    switch (fscInstallScript.Type)
                    {
                    case FomodScriptType.CSharp:
                        booUpgraded = RunCustomInstallScript();
                        break;

                    case FomodScriptType.XMLConfig:
                        booUpgraded = RunXmlInstallScript();
                        break;
                    }
                }
                else
                {
                    booUpgraded = RunBasicInstallScript(ProgressMessage);
                }
                if (booUpgraded)
                {
                    using (m_bwdProgress = new BackgroundWorkerProgressDialog(ReconcileDifferences))
                    {
                        m_bwdProgress.OverallMessage      = "Finalizing Upgrade";
                        m_bwdProgress.ItemProgressStep    = 1;
                        m_bwdProgress.OverallProgressStep = 1;
                        if (m_bwdProgress.ShowDialog() == DialogResult.Cancel)
                        {
                            return(false);
                        }
                    }
                    var strOldBaseName = Fomod.BaseName;
                    ((UpgradeFomod)Fomod).SetBaseName(((UpgradeFomod)Fomod).OriginalBaseName);
                    InstallLog.Current.MergeUpgrade(Fomod, strOldBaseName, MergeModule);
                    ((UpgradeFomod)Fomod).SetBaseName(strOldBaseName);
                    Script.CommitActivePlugins();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            m_fomodOriginalMod.IsActive = DetermineFomodActiveStatus(booUpgraded);
            return(booUpgraded);
        }
Exemplo n.º 3
0
    /// <summary>
    ///   Runs the install script.
    /// </summary>
    /// <remarks>
    ///   This contains the boilerplate code that needs to be done for all install-type
    ///   scripts. Implementers must override the <see cref="DoScript()" /> method to
    ///   implement their script-specific functionality.
    /// </remarks>
    /// <param name="p_booSuppressSuccessMessage">
    ///   Indicates whether to
    ///   supress the success message. This is useful for batch installs.
    /// </param>
    /// <seealso cref="DoScript()" />
    protected bool Run(bool p_booSuppressSuccessMessage, bool p_booSetFOModReadOnly)
    {
      var booSuccess = false;
      if (CheckAlreadyDone())
      {
        booSuccess = true;
      }

      if (!booSuccess)
      {
        try
        {
          //the install process modifies INI and config files.
          // if multiple sources (i.e., installs) try to modify
          // these files simultaneously the outcome is not well known
          // (e.g., one install changes SETTING1 in a config file to valueA
          // while simultaneously another install changes SETTING1 in the
          // file to value2 - after each install commits its changes it is
          // not clear what the value of SETTING1 will be).
          // as a result, we only allow one mod to be installed at a time,
          // hence the lock.
          lock (objInstallLock)
          {
            using (var tsTransaction = new TransactionScope())
            {
              m_tfmFileManager = new TxFileManager();
              using (Script = CreateInstallScript())
              {
                var booCancelled = false;
                if (p_booSetFOModReadOnly && (Fomod != null))
                {
                  if (Fomod.ReadOnlyInitStepCount > 1)
                  {
                    using (m_bwdProgress = new BackgroundWorkerProgressDialog(BeginFOModReadOnlyTransaction))
                    {
                      m_bwdProgress.OverallMessage = "Preparing FOMod...";
                      m_bwdProgress.ShowItemProgress = false;
                      m_bwdProgress.OverallProgressMaximum = Fomod.ReadOnlyInitStepCount;
                      m_bwdProgress.OverallProgressStep = 1;
                      try
                      {
                        Fomod.ReadOnlyInitStepStarted += Fomod_ReadOnlyInitStepStarted;
                        Fomod.ReadOnlyInitStepFinished += Fomod_ReadOnlyInitStepFinished;
                        if (m_bwdProgress.ShowDialog() == DialogResult.Cancel)
                        {
                          booCancelled = true;
                        }
                      }
                      finally
                      {
                        Fomod.ReadOnlyInitStepStarted -= Fomod_ReadOnlyInitStepStarted;
                        Fomod.ReadOnlyInitStepFinished -= Fomod_ReadOnlyInitStepFinished;
                      }
                    }
                  }
                  else
                  {
                    Fomod.BeginReadOnlyTransaction();
                  }
                }
                if (!booCancelled)
                {
                  booSuccess = DoScript();
                  if (booSuccess)
                  {
                    tsTransaction.Complete();
                  }
                }
              }
            }
          }
        }
        catch (Exception e)
        {
          var stbError = new StringBuilder(e.Message);
          if (e is FileNotFoundException)
          {
            stbError.Append(" (" + ((FileNotFoundException) e).FileName + ")");
          }
          if (e is IllegalFilePathException)
          {
            stbError.Append(" (" + ((IllegalFilePathException) e).Path + ")");
          }
          if (e.InnerException != null)
          {
            stbError.AppendLine().AppendLine(e.InnerException.Message);
          }
          if (e is RollbackException)
          {
            foreach (var erm in ((RollbackException) e).ExceptedResourceManagers)
            {
              stbError.AppendLine(erm.ResourceManager.ToString());
              stbError.AppendLine(erm.Exception.Message);
              if (erm.Exception.InnerException != null)
              {
                stbError.AppendLine(erm.Exception.InnerException.Message);
              }
            }
          }
          var strMessage = String.Format(ExceptionMessage, stbError);
          MessageBox.Show(strMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
          return false;
        }
        finally
        {
          m_tfmFileManager = null;
          m_ilmModInstallLog = null;
          if (Fomod != null)
          {
            Fomod.EndReadOnlyTransaction();
          }
        }
      }
      if (booSuccess && !p_booSuppressSuccessMessage && !String.IsNullOrEmpty(SuccessMessage))
      {
        MessageBox.Show(SuccessMessage, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
      }
      else if (!booSuccess && !String.IsNullOrEmpty(FailMessage))
      {
        MessageBox.Show(FailMessage, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
      }
      return booSuccess;
    }
Exemplo n.º 4
0
        /// <summary>
        ///   Runs the install script.
        /// </summary>
        /// <remarks>
        ///   This contains the boilerplate code that needs to be done for all install-type
        ///   scripts. Implementers must override the <see cref="DoScript()" /> method to
        ///   implement their script-specific functionality.
        /// </remarks>
        /// <param name="p_booSuppressSuccessMessage">
        ///   Indicates whether to
        ///   supress the success message. This is useful for batch installs.
        /// </param>
        /// <seealso cref="DoScript()" />
        protected bool Run(bool p_booSuppressSuccessMessage, bool p_booSetFOModReadOnly)
        {
            var booSuccess = false;

            if (CheckAlreadyDone())
            {
                booSuccess = true;
            }

            if (!booSuccess)
            {
                try
                {
                    //the install process modifies INI and config files.
                    // if multiple sources (i.e., installs) try to modify
                    // these files simultaneously the outcome is not well known
                    // (e.g., one install changes SETTING1 in a config file to valueA
                    // while simultaneously another install changes SETTING1 in the
                    // file to value2 - after each install commits its changes it is
                    // not clear what the value of SETTING1 will be).
                    // as a result, we only allow one mod to be installed at a time,
                    // hence the lock.
                    lock (objInstallLock)
                    {
                        using (var tsTransaction = new TransactionScope())
                        {
                            m_tfmFileManager = new TxFileManager();
                            using (Script = CreateInstallScript())
                            {
                                var booCancelled = false;
                                if (p_booSetFOModReadOnly && (Fomod != null))
                                {
                                    if (Fomod.ReadOnlyInitStepCount > 1)
                                    {
                                        using (m_bwdProgress = new BackgroundWorkerProgressDialog(BeginFOModReadOnlyTransaction))
                                        {
                                            m_bwdProgress.OverallMessage         = "Preparing FOMod...";
                                            m_bwdProgress.ShowItemProgress       = false;
                                            m_bwdProgress.OverallProgressMaximum = Fomod.ReadOnlyInitStepCount;
                                            m_bwdProgress.OverallProgressStep    = 1;
                                            try
                                            {
                                                Fomod.ReadOnlyInitStepStarted  += Fomod_ReadOnlyInitStepStarted;
                                                Fomod.ReadOnlyInitStepFinished += Fomod_ReadOnlyInitStepFinished;
                                                if (m_bwdProgress.ShowDialog() == DialogResult.Cancel)
                                                {
                                                    booCancelled = true;
                                                }
                                            }
                                            finally
                                            {
                                                Fomod.ReadOnlyInitStepStarted  -= Fomod_ReadOnlyInitStepStarted;
                                                Fomod.ReadOnlyInitStepFinished -= Fomod_ReadOnlyInitStepFinished;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Fomod.BeginReadOnlyTransaction();
                                    }
                                }
                                if (!booCancelled)
                                {
                                    booSuccess = DoScript();
                                    if (booSuccess)
                                    {
                                        tsTransaction.Complete();
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    var stbError = new StringBuilder(e.Message);
                    if (e is FileNotFoundException)
                    {
                        stbError.Append(" (" + ((FileNotFoundException)e).FileName + ")");
                    }
                    if (e is IllegalFilePathException)
                    {
                        stbError.Append(" (" + ((IllegalFilePathException)e).Path + ")");
                    }
                    if (e.InnerException != null)
                    {
                        stbError.AppendLine().AppendLine(e.InnerException.Message);
                    }
                    if (e is RollbackException)
                    {
                        foreach (var erm in ((RollbackException)e).ExceptedResourceManagers)
                        {
                            stbError.AppendLine(erm.ResourceManager.ToString());
                            stbError.AppendLine(erm.Exception.Message);
                            if (erm.Exception.InnerException != null)
                            {
                                stbError.AppendLine(erm.Exception.InnerException.Message);
                            }
                        }
                    }
                    var strMessage = String.Format(ExceptionMessage, stbError);
                    MessageBox.Show(strMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
                finally
                {
                    m_tfmFileManager   = null;
                    m_ilmModInstallLog = null;
                    if (Fomod != null)
                    {
                        Fomod.EndReadOnlyTransaction();
                    }
                }
            }
            if (booSuccess && !p_booSuppressSuccessMessage && !String.IsNullOrEmpty(SuccessMessage))
            {
                MessageBox.Show(SuccessMessage, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (!booSuccess && !String.IsNullOrEmpty(FailMessage))
            {
                MessageBox.Show(FailMessage, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(booSuccess);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Merges the installed and edited components in the given <see cref="InstallLogMergeModule"/>
 /// into the install log for the specified mod.
 /// </summary>
 /// <param name="p_strModName">The base name of the unversioned <see cref="fomod"/> for which the
 /// installs and edits where made.</param>
 /// <param name="p_ilmMergeModule">The installs and edits that where made as part of the
 /// <see cref="fomod"/>'s installation.</param>
 internal void UnversionedFomodMerge(string p_strModName, InstallLogMergeModule p_ilmMergeModule)
 {
     AddMod(p_strModName);
     processMergeModule(p_strModName, p_ilmMergeModule);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Removes the log entries for the components that were installed and edited during
 /// the installation of the specified <see cref="fomod"/>.
 /// </summary>
 /// <param name="p_strModName">The base name of the <see cref="fomod"/> for which to remove
 /// the log entries for the components that were installed and edited.</param>
 internal void UnmergeModule(string p_strModName)
 {
     InstallLogMergeModule ilmMergeModule = new InstallLogMergeModule();
     XmlNode xndComponent = null;
     XmlNode xndInstallingMods = null;
     XmlNodeList xnlComponentMods = null;
     lock (dataFilesNode)
     {
         xnlComponentMods = dataFilesNode.SelectNodes("descendant::mod[@key=\"" + m_dicModList[p_strModName] + "\"]");
         foreach (XmlNode xndFile in xnlComponentMods)
         {
             xndInstallingMods = xndFile.ParentNode;
             xndComponent = xndInstallingMods.ParentNode;
             xndInstallingMods.RemoveChild(xndFile);
             if ((xndInstallingMods.ChildNodes.Count == 0) || (xndInstallingMods.LastChild.Attributes["key"].InnerText.Equals(GetModKey(ORIGINAL_VALUES))))
                 xndComponent.ParentNode.RemoveChild(xndComponent);
         }
     }
     lock (iniEditsNode)
     {
         xnlComponentMods = iniEditsNode.SelectNodes("descendant::mod[@key=\"" + m_dicModList[p_strModName] + "\"]");
         foreach (XmlNode xndIniEdit in xnlComponentMods)
         {
             xndInstallingMods = xndIniEdit.ParentNode;
             xndComponent = xndInstallingMods.ParentNode;
             xndInstallingMods.RemoveChild(xndIniEdit);
             if ((xndInstallingMods.ChildNodes.Count == 0) || (xndInstallingMods.LastChild.Attributes["key"].InnerText.Equals(GetModKey(ORIGINAL_VALUES))))
                 xndComponent.ParentNode.RemoveChild(xndComponent);
         }
     }
     lock (gameSpecificValueEditsNode)
     {
         xnlComponentMods = gameSpecificValueEditsNode.SelectNodes("descendant::mod[@key=\"" + m_dicModList[p_strModName] + "\"]");
         foreach (XmlNode xndSdpEdit in xnlComponentMods)
         {
             xndInstallingMods = xndSdpEdit.ParentNode;
             xndComponent = xndInstallingMods.ParentNode;
             xndInstallingMods.RemoveChild(xndSdpEdit);
             if ((xndInstallingMods.ChildNodes.Count == 0) || (xndInstallingMods.LastChild.Attributes["key"].InnerText.Equals(GetModKey(ORIGINAL_VALUES))))
                 xndComponent.ParentNode.RemoveChild(xndComponent);
         }
     }
     RemoveMod(p_strModName);
     Save();
 }
Exemplo n.º 7
0
        /// <summary>
        /// Creates an <see cref="InstallLogMergeModule"/> that describes the components that were
        /// installed and edited during the installation of the specified <see cref="fomod"/>.
        /// </summary>
        /// <param name="p_strModName">The base name of the <see cref="fomod"/> for which to retrieve
        /// the components that were installed and edited.</param>
        /// <returns>An <see cref="InstallLogMergeModule"/> that describes the components that were
        /// installed and edited during the installation of the specified <see cref="fomod"/>.</returns>
        internal InstallLogMergeModule GetMergeModule(string p_strModName)
        {
            InstallLogMergeModule ilmMergeModule = new InstallLogMergeModule();
            XmlNode xndComponent = null;
            XmlNodeList xnlComponentMods = dataFilesNode.SelectNodes("descendant::mod[@key=\"" + m_dicModList[p_strModName] + "\"]");
            foreach (XmlNode xndFile in xnlComponentMods)
            {
                xndComponent = xndFile.ParentNode.ParentNode;
                ilmMergeModule.AddFile(xndComponent.Attributes["path"].InnerText);
            }
            xnlComponentMods = iniEditsNode.SelectNodes("descendant::mod[@key=\"" + m_dicModList[p_strModName] + "\"]");
            foreach (XmlNode xndIniEdit in xnlComponentMods)
            {
                xndComponent = xndIniEdit.ParentNode.ParentNode;
                ilmMergeModule.AddIniEdit(xndComponent.Attributes["file"].InnerText,
                                            xndComponent.Attributes["section"].InnerText,
                                            xndComponent.Attributes["key"].InnerText,
                                            xndIniEdit.InnerText);
            }
            xnlComponentMods = gameSpecificValueEditsNode.SelectNodes("descendant::mod[@key=\"" + m_dicModList[p_strModName] + "\"]");
            foreach (XmlNode xndGameSpecificValueEdit in xnlComponentMods)
            {
                xndComponent = xndGameSpecificValueEdit.ParentNode.ParentNode;

                string strData = xndGameSpecificValueEdit.InnerText;
                byte[] bteData = new byte[strData.Length / 2];
                for (int i = 0; i < bteData.Length; i++)
                    bteData[i] = byte.Parse("" + strData[i * 2] + strData[i * 2 + 1], System.Globalization.NumberStyles.AllowHexSpecifier);

                ilmMergeModule.AddGameSpecificValueEdit(xndComponent.Attributes["key"].InnerText, bteData);
            }

            return ilmMergeModule;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Merges the installed and edited components in the given <see cref="InstallLogMergeModule"/>
        /// into the install log for the specified mod, as an in-place upgrade.
        /// </summary>
        /// <remarks>
        /// When a <see cref="InstallLogMergeModule"/> is merged as an in-place upgrade, any files/changes
        /// that exist in the install log for the given fomod are replaced where they are in the install
        /// order, rather than being made the file/change owner (unless they already where the file/change
        /// owner). Note, however, that if the merge module contains new files/changes that the previous fomod
        /// version did not contain the fomods will become the owner of the new files/changes.
        /// 
        /// Also, changes that are logged for the speicifed fomod that are not in the given
        /// <see cref="InstallLogMergeModule"/> are removed from the install log.
        /// </remarks>
        /// <param name="p_fomodMod">The <see cref="fomod"/> for which the
        /// installs and edits where made.</param>
        /// <param name="p_strOldBaseName">The old base name of the fomod that is being upgraded. This is the
        /// base name that will be replaced with the base name of the given fomod.</param>
        /// <param name="p_ilmMergeModule">The installs and edits that where made as part of the
        /// <see cref="fomod"/>'s upgrade.</param>
        public void MergeUpgrade(fomod p_fomodMod, string p_strOldBaseName, InstallLogMergeModule p_ilmMergeModule)
        {
            if (!UpdateMod(p_strOldBaseName, p_fomodMod))
                AddMod(p_fomodMod);

            //remove changes that were not made in the upgrade
            InstallLogMergeModule ilmPreviousChanges = GetMergeModule(p_fomodMod.BaseName);
            foreach (string strFile in ilmPreviousChanges.DataFiles)
                if (!p_ilmMergeModule.ContainsFile(strFile))
                    RemoveDataFile(p_fomodMod.BaseName, strFile);
            foreach (InstallLogMergeModule.IniEdit iniEdit in ilmPreviousChanges.IniEdits)
                if (!p_ilmMergeModule.IniEdits.Contains(iniEdit))
                    RemoveIniEdit(p_fomodMod.BaseName, iniEdit.File, iniEdit.Section, iniEdit.Key);
            foreach (InstallLogMergeModule.GameSpecificValueEdit gsvEdit in ilmPreviousChanges.GameSpecificValueEdits)
                if (!p_ilmMergeModule.GameSpecificValueEdits.Contains(gsvEdit))
                    RemoveGameSpecificValueEdit(p_fomodMod.BaseName, gsvEdit.Key);

            //add/replace changes
            foreach (string strFile in p_ilmMergeModule.ReplacedOriginalDataFiles)
                AddDataFile(ORIGINAL_VALUES, strFile);
            foreach (string strFile in p_ilmMergeModule.DataFiles)
                ReplaceDataFile(p_fomodMod.BaseName, strFile);
            foreach (InstallLogMergeModule.IniEdit iniEdit in p_ilmMergeModule.ReplacedOriginalIniValues)
                AddIniEdit(iniEdit.File, iniEdit.Section, iniEdit.Key, ORIGINAL_VALUES, iniEdit.Value);
            foreach (InstallLogMergeModule.IniEdit iniEdit in p_ilmMergeModule.IniEdits)
                ReplaceIniEdit(iniEdit.File, iniEdit.Section, iniEdit.Key, p_fomodMod.BaseName, iniEdit.Value);
            foreach (InstallLogMergeModule.GameSpecificValueEdit gsvEdit in p_ilmMergeModule.ReplacedGameSpecificValueData)
                AddGameSpecificValueEdit(ORIGINAL_VALUES, gsvEdit.Key, gsvEdit.Data);
            foreach (InstallLogMergeModule.GameSpecificValueEdit gsvEdit in p_ilmMergeModule.GameSpecificValueEdits)
                ReplaceGameSpecificValueEdit(p_fomodMod.BaseName, gsvEdit.Key, gsvEdit.Data);

            Save();
        }
Exemplo n.º 9
0
 /// <summary>
 /// Merges the installed and edited components in the given <see cref="InstallLogMergeModule"/>
 /// into the install log for the specified mod.
 /// </summary>
 /// <param name="p_fomodMod">The <see cref="fomod"/> for which the
 /// installs and edits where made.</param>
 /// <param name="p_ilmMergeModule">The installs and edits that where made as part of the
 /// <see cref="fomod"/>'s installation.</param>
 public void Merge(fomod p_fomodMod, InstallLogMergeModule p_ilmMergeModule)
 {
     AddMod(p_fomodMod);
     processMergeModule(p_fomodMod.BaseName, p_ilmMergeModule);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Merges the installed and edited components in the given <see cref="InstallLogMergeModule"/>
 /// into the install log for the specified mod.
 /// </summary>
 /// <param name="p_strModName">The base name of the unversioned <see cref="fomod"/> for which the
 /// installs and edits where made.</param>
 /// <param name="p_ilmMergeModule">The installs and edits that where made as part of the
 /// <see cref="fomod"/>'s installation.</param>
 private void processMergeModule(string p_strModName, InstallLogMergeModule p_ilmMergeModule)
 {
     foreach (string strFile in p_ilmMergeModule.ReplacedOriginalDataFiles)
         AddDataFile(ORIGINAL_VALUES, strFile);
     foreach (string strFile in p_ilmMergeModule.DataFiles)
         AddDataFile(p_strModName, strFile);
     foreach (InstallLogMergeModule.IniEdit iniEdit in p_ilmMergeModule.ReplacedOriginalIniValues)
         AddIniEdit(iniEdit.File, iniEdit.Section, iniEdit.Key, ORIGINAL_VALUES, iniEdit.Value);
     foreach (InstallLogMergeModule.IniEdit iniEdit in p_ilmMergeModule.IniEdits)
         AddIniEdit(iniEdit.File, iniEdit.Section, iniEdit.Key, p_strModName, iniEdit.Value);
     foreach (InstallLogMergeModule.GameSpecificValueEdit gsvEdit in p_ilmMergeModule.ReplacedGameSpecificValueData)
         AddGameSpecificValueEdit(ORIGINAL_VALUES, gsvEdit.Key, gsvEdit.Data);
     foreach (InstallLogMergeModule.GameSpecificValueEdit gsvEdit in p_ilmMergeModule.GameSpecificValueEdits)
         AddGameSpecificValueEdit(p_strModName, gsvEdit.Key, gsvEdit.Data);
     Save();
 }
Exemplo n.º 11
0
    /// <summary>
    ///   Installs the mod and activates it.
    /// </summary>
    protected override bool DoScript()
    {
      foreach (var strSettingsFile in Program.GameMode.SettingsFiles.Values)
      {
        TransactionalFileManager.Snapshot(strSettingsFile);
      }
      foreach (var strAdditionalFile in Program.GameMode.AdditionalPaths.Values)
      {
        if (File.Exists(strAdditionalFile))
        {
          TransactionalFileManager.Snapshot(strAdditionalFile);
        }
      }
      TransactionalFileManager.Snapshot(InstallLog.Current.InstallLogPath);

      try
      {
        MergeModule = new InstallLogMergeModule();
        if (Fomod.HasInstallScript)
        {
          var fscInstallScript = Fomod.GetInstallScript();
          switch (fscInstallScript.Type)
          {
            case FomodScriptType.CSharp:
              Fomod.IsActive = RunCustomInstallScript();
              break;
            case FomodScriptType.XMLConfig:
              Fomod.IsActive = RunXmlInstallScript();
              break;
          }
        }
        else
        {
          Fomod.IsActive = RunBasicInstallScript("Installing Fomod");
        }

        if (Fomod.IsActive)
        {
          InstallLog.Current.Merge(Fomod, MergeModule);
          Script.CommitActivePlugins();
        }
      }
      catch (Exception e)
      {
        Fomod.IsActive = false;
        throw e;
      }
      if (!Fomod.IsActive)
      {
        return false;
      }
      return true;
    }
Exemplo n.º 12
0
    /// <summary>
    ///   Performs an in-place upgrade of the <see cref="fomod" />.
    /// </summary>
    protected override bool DoScript()
    {
      foreach (var strSettingsFile in Program.GameMode.SettingsFiles.Values)
      {
        TransactionalFileManager.Snapshot(strSettingsFile);
      }
      foreach (var strAdditionalFile in Program.GameMode.AdditionalPaths.Values)
      {
        if (File.Exists(strAdditionalFile))
        {
          TransactionalFileManager.Snapshot(strAdditionalFile);
        }
      }
      TransactionalFileManager.Snapshot(InstallLog.Current.InstallLogPath);

      var booUpgraded = false;
      try
      {
        MergeModule = new InstallLogMergeModule();
        if (Fomod.HasInstallScript)
        {
          var fscInstallScript = Fomod.GetInstallScript();
          switch (fscInstallScript.Type)
          {
            case FomodScriptType.CSharp:
              booUpgraded = RunCustomInstallScript();
              break;
            case FomodScriptType.XMLConfig:
              booUpgraded = RunXmlInstallScript();
              break;
          }
        }
        else
        {
          booUpgraded = RunBasicInstallScript(ProgressMessage);
        }
        if (booUpgraded)
        {
          using (m_bwdProgress = new BackgroundWorkerProgressDialog(ReconcileDifferences))
          {
            m_bwdProgress.OverallMessage = "Finalizing Upgrade";
            m_bwdProgress.ItemProgressStep = 1;
            m_bwdProgress.OverallProgressStep = 1;
            if (m_bwdProgress.ShowDialog() == DialogResult.Cancel)
            {
              return false;
            }
          }
          var strOldBaseName = Fomod.BaseName;
          ((UpgradeFomod) Fomod).SetBaseName(((UpgradeFomod) Fomod).OriginalBaseName);
          InstallLog.Current.MergeUpgrade(Fomod, strOldBaseName, MergeModule);
          ((UpgradeFomod) Fomod).SetBaseName(strOldBaseName);
          Script.CommitActivePlugins();
        }
      }
      catch (Exception e)
      {
        throw e;
      }
      m_fomodOriginalMod.IsActive = DetermineFomodActiveStatus(booUpgraded);
      return booUpgraded;
    }