コード例 #1
0
        /// <summary>
        ///   Upgrades the Install Log to the current version from version 0.1.1.0.
        /// </summary>
        /// <remarks>
        ///   This method is called by a background worker to perform the actual upgrade.
        /// </remarks>
        protected override void DoUpgrade()
        {
            InstallLog.Current.SetInstallLogVersion(InstallLog.CURRENT_VERSION);
            InstallLog.Current.Save();

            var xmlInstallLog = new XmlDocument();

            xmlInstallLog.Load(InstallLog.Current.InstallLogPath);

            var xndRoot     = xmlInstallLog.SelectSingleNode("installLog");
            var xndSdpEdits = xndRoot.SelectSingleNode("sdpEdits");

            ProgressWorker.OverallProgressStep    = 1;
            ProgressWorker.OverallProgressMaximum = 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);
        }
コード例 #2
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.Load(InstallLog.Current.InstallLogPath);

            var xndRoot = xmlInstallLog.SelectSingleNode("installLog");

            if (xndRoot == null)
            {
                return;
            }
            var lstMods     = InstallLog.Current.GetModList();
            var xndSdpEdits = xndRoot.SelectSingleNode("sdpEdits");

            if (xndSdpEdits != null)
            {
                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 = $"sdp:{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();
        }
コード例 #3
0
ファイル: Upgrader0000.cs プロジェクト: vjmira/fomm
        /// <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();
        }