/// <summary>
 /// Freezes the mods.
 /// </summary>
 public static void Freeze(ManagedMods mods, IEnumerable <int> indices)
 {
     foreach (int index in indices)
     {
         ModActions.Freeze(mods[index]);
     }
     mods.Save();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Used in the deployment chain to deploy a single mod with the SeparateBA2 method.
        /// Freezes a mod if necessary.
        /// </summary>
        private static void DeploySeparateArchive(ManagedMod mod, ResourceList resources)
        {
            LogFile.WriteLine($"   Installing mod '{mod.Title}' as SeparateBA2");

            // If mod is supposed to be deployed frozen...
            if (mod.Freeze)
            {
                // ... freeze if necessary ...
                if (!mod.Frozen)
                {
                    //LogFile.WriteLine($"      Freezing mod...");
                    ModActions.Freeze(mod);
                }

                LogFile.WriteLine($"      Copying frozen archive...");

                // ... and copy it to the Data folder.
                if (Configuration.bUseHardlinks)
                {
                    Utils.CreateHardLink(
                        mod.FrozenArchivePath,
                        mod.ArchivePath,
                        true);
                }
                else
                {
                    File.Copy(
                        mod.FrozenArchivePath,
                        mod.ArchivePath,
                        true);
                }
            }

            // If mod isn't supposed to be deployed frozen...
            else
            {
                // ... unfreeze mod if needed ...
                if (mod.Frozen)
                {
                    LogFile.WriteLine($"      Unfreezing mod...");
                    ModActions.Unfreeze(mod);
                }

                // Getting preset:
                Archive2.Preset preset = ModHelpers.GetArchive2Preset(mod);

                LogFile.WriteLine($"      Creating new archive...");
                LogFile.WriteLine($"         Format:      {preset.format}");
                LogFile.WriteLine($"         Compression: {preset.compression}");

                // ... and create a new archive.
                Archive2.Create(
                    mod.ArchivePath,
                    mod.ManagedFolderPath,
                    preset);
            }

            // Finally, update the disk state ...
            mod.CurrentArchiveName = mod.ArchiveName;
            mod.CurrentCompression = mod.Frozen ? mod.FrozenCompression : mod.Compression;
            mod.CurrentFormat      = mod.Frozen ? mod.FrozenFormat : mod.Format;
            mod.Deployed           = true;
            mod.PreviousMethod     = ManagedMod.DeploymentMethod.SeparateBA2;

            // ... and add the archive to the resource list.
            resources.Add(mod.ArchiveName);

            LogFile.WriteLine($"      Installed.");
        }
 /// <summary>
 /// Freezes the mod.
 /// </summary>
 public static void Freeze(ManagedMods mods, int index)
 {
     ModActions.Freeze(mods[index]);
     mods.Save();
 }