예제 #1
0
        public void MasterListSync_AddMissingToEmpty()
        {
            WarmupOblivion.Init();
            using var folder = TestPathing.GetTempFolder(nameof(MasterSync_Tests));
            var obliv    = ModKey.FromNameAndExtension("Oblivion.esm");
            var knights  = ModKey.FromNameAndExtension("Knights.esm");
            var other    = ModKey.FromNameAndExtension("Other.esp");
            var mod      = new OblivionMod(obliv);
            var otherNpc = new Npc(new FormKey(other, 0x123456));

            mod.Potions.RecordCache.Set(new Potion(new FormKey(obliv, 0x123456)));
            mod.Npcs.RecordCache.Set(otherNpc);
            otherNpc.Race.FormKey = new FormKey(knights, 0x123456);
            var modPath = Path.Combine(folder.Dir.Path, obliv.ToString());

            mod.WriteToBinary(modPath,
                              new BinaryWriteParameters()
            {
                ModKey             = ModKeyOption.NoCheck,
                MastersListContent = MastersListContentOption.Iterate,
            });
            using var reimport = OblivionMod.CreateFromBinaryOverlay(modPath);
            Assert.Equal(2, reimport.MasterReferences.Count);
            Assert.Contains(knights, reimport.MasterReferences.Select(m => m.Master));
            Assert.Contains(other, reimport.MasterReferences.Select(m => m.Master));
        }
예제 #2
0
 public void TryFactory_ExtraPeriod()
 {
     Assert.True(ModKey.TryFromNameAndExtension("Obliv.ion.esm", out var modKey));
     Assert.Equal("Obliv.ion", modKey.Name);
     Assert.Equal("Obliv.ion.esm", modKey.FileName);
     Assert.Equal(ModType.Master, modKey.Type);
 }
예제 #3
0
        public void TryFactory_TypicalBothDuplicates()
        {
            Assert.True(ModKey.TryFromNameAndExtension("Oblivion.esm", out var masterKey));
            Assert.Equal("Oblivion", masterKey.Name);
            Assert.Equal("Oblivion.esm", masterKey.FileName);
            Assert.Equal(ModType.Master, masterKey.Type);

            Assert.True(ModKey.TryFromNameAndExtension("Oblivion.esp", out var modKey));
            Assert.Equal("Oblivion", modKey.Name);
            Assert.Equal("Oblivion.esp", modKey.FileName);
            Assert.Equal(ModType.Plugin, modKey.Type);

            Assert.True(ModKey.TryFromNameAndExtension("Oblivion.esm", out var masterKey2));
            Assert.Equal("Oblivion", masterKey2.Name);
            Assert.Equal("Oblivion.esm", masterKey2.FileName);
            Assert.Equal(ModType.Master, masterKey2.Type);

            Assert.True(ModKey.TryFromNameAndExtension("Oblivion.esp", out var modKey2));
            Assert.Equal("Oblivion", modKey2.Name);
            Assert.Equal("Oblivion.esp", modKey2.FileName);
            Assert.Equal(ModType.Plugin, modKey2.Type);

            Assert.Same(masterKey.Name, masterKey2.Name);
            Assert.Same(modKey.Name, modKey2.Name);
        }
예제 #4
0
 public void TryFactory_TypicalLightMaster()
 {
     Assert.True(ModKey.TryFromNameAndExtension("Oblivion.esl", out var modKey));
     Assert.Equal("Oblivion", modKey.Name);
     Assert.Equal("Oblivion.esl", modKey.FileName);
     Assert.Equal(ModType.LightMaster, modKey.Type);
 }
        public void ExceptionDisposesExistingMods()
        {
            var dataFolder = "C:/DataFolder";
            var modPaths   = new ModKey[]
            {
                TestConstants.MasterModKey,
                TestConstants.MasterModKey2,
            }
            .Select(x => ModPath.FromPath(Path.Combine(dataFolder, x.FileName)))
            .ToArray();
            var fs = Substitute.For <IFileSystem>();

            fs.File.Exists(Arg.Any <string>()).Returns(true);
            var importer = Substitute.For <IModImporter <IModDisposeGetter> >();
            var mod      = Substitute.For <IModDisposeGetter>();

            importer.Import(modPaths.First()).Returns(mod);
            importer.Import(modPaths.Last()).Throws(new ArgumentException());
            Assert.Throws <AggregateException>(() =>
            {
                new LoadOrderImporter <IModDisposeGetter>(
                    fs,
                    new DataDirectoryInjection(dataFolder),
                    new LoadOrderListingsInjection(modPaths.Select(x => x.ModKey).ToArray()),
                    importer)
                .Import();
            });
            mod.Received().Dispose();
        }
예제 #6
0
        public async Task TrimsAtypicalOutputFromLoadOrder()
        {
            using var tmpFolder  = Utility.GetTempFolder();
            using var dataFolder = Utility.SetupDataFolder(tmpFolder, GameRelease.SkyrimLE);
            ModKey atypicalKey = ModKey.FromNameAndExtension("Atypical.esp");
            var    output      = Path.Combine(tmpFolder.Dir.Path, atypicalKey.FileName);
            var    patcher     = new DummyPatcher();
            await Runner.Run(
                workingDirectory : tmpFolder.Dir.Path,
                outputPath : output,
                dataFolder : dataFolder.Dir.Path,
                release : GameRelease.SkyrimLE,
                loadOrder : Utility.TypicalLoadOrder(GameRelease.SkyrimLE, dataFolder.Dir)
                .And(new LoadOrderListing(Constants.SynthesisModKey, true))
                .And(new LoadOrderListing(atypicalKey, true))
                .And(new LoadOrderListing(Utility.RandomModKey, true)),
                patchers : patcher.AsEnumerable().ToList(),
                cancel : CancellationToken.None);

            Assert.Equal(
                new string[]
            {
                Utility.TestModKey.FileName,
                Utility.OverrideModKey.FileName,
                Constants.SynthesisModKey.FileName,
            }, File.ReadAllLines(Path.Combine(tmpFolder.Dir.Path, "Plugins.txt")));
        }
예제 #7
0
        public void MasterOrderSync_ByLoadOrder()
        {
            WarmupOblivion.Init();
            using var folder = TestPathing.GetTempFolder(nameof(MasterSync_Tests));
            var obliv  = ModKey.FromNameAndExtension("Oblivion.esm");
            var esm    = ModKey.FromNameAndExtension("First.esm");
            var esp    = ModKey.FromNameAndExtension("Second.esp");
            var mod    = new OblivionMod(obliv);
            var espNpc = new Npc(new FormKey(esp, 0x123456));

            mod.Npcs.RecordCache.Set(espNpc);
            var esmNpc = new Npc(new FormKey(esm, 0x123456));

            mod.Npcs.RecordCache.Set(esmNpc);
            var modPath   = Path.Combine(folder.Dir.Path, obliv.ToString());
            var loadOrder = new ModKey[]
            {
                esm,
                esp,
            };

            mod.WriteToBinary(modPath,
                              new BinaryWriteParameters()
            {
                ModKey              = ModKeyOption.NoCheck,
                MastersListContent  = MastersListContentOption.Iterate,
                MastersListOrdering = new MastersListOrderingByLoadOrder(loadOrder)
            });
            using var reimport = OblivionMod.CreateFromBinaryOverlay(modPath);
            Assert.Equal(
                loadOrder,
                reimport.ModHeader.MasterReferences.Select(m => m.Master));
        }
예제 #8
0
 public void TryFactory_TypicalMod()
 {
     Assert.True(ModKey.TryFromNameAndExtension("Knights.esp", out var modKey));
     Assert.Equal("Knights", modKey.Name);
     Assert.Equal("Knights.esp", modKey.FileName);
     Assert.Equal(ModType.Plugin, modKey.Type);
 }
예제 #9
0
        public void MasterOrderSync_EsmFirst()
        {
            WarmupOblivion.Init();
            using var folder = Utility.GetTempFolder(nameof(MasterSync_Tests));
            var obliv     = ModKey.FromNameAndExtension("Oblivion.esm");
            var first     = ModKey.FromNameAndExtension("First.esp");
            var second    = ModKey.FromNameAndExtension("Second.esp");
            var mod       = new OblivionMod(obliv);
            var secondNpc = new Npc(new FormKey(second, 0x123456));

            mod.Npcs.RecordCache.Set(secondNpc);
            var firstNpc = new Npc(new FormKey(first, 0x123456));

            mod.Npcs.RecordCache.Set(firstNpc);
            var modPath = Path.Combine(folder.Dir.Path, obliv.ToString());

            mod.WriteToBinary(modPath,
                              new BinaryWriteParameters()
            {
                ModKey              = BinaryWriteParameters.ModKeyOption.NoCheck,
                MastersListContent  = BinaryWriteParameters.MastersListContentOption.Iterate,
                MastersListOrdering = BinaryWriteParameters.MastersListOrderingOption.MastersFirst,
            });
            using var reimport = OblivionMod.CreateFromBinaryOverlay(modPath);
            Assert.Equal(
                new ModKey[]
            {
                first,
                second,
            },
                reimport.ModHeader.MasterReferences.Select(m => m.Master));
        }
예제 #10
0
        public void MasterOrderSync_Typical()
        {
            WarmupOblivion.Init();
            using var folder = Utility.GetTempFolder(nameof(MasterSync_Tests));
            var obliv      = ModKey.FromNameAndExtension("Oblivion.esm");
            var knights    = ModKey.FromNameAndExtension("Knights.esm");
            var other      = ModKey.FromNameAndExtension("Other.esp");
            var mod        = new OblivionMod(obliv);
            var knightsNpc = new Npc(new FormKey(knights, 0x123456));

            mod.Npcs.RecordCache.Set(knightsNpc);
            var otherNpc = new Npc(new FormKey(other, 0x123456));

            mod.Npcs.RecordCache.Set(otherNpc);
            var modPath = Path.Combine(folder.Dir.Path, obliv.ToString());

            mod.WriteToBinary(modPath,
                              new BinaryWriteParameters()
            {
                ModKey             = BinaryWriteParameters.ModKeyOption.NoCheck,
                MastersListContent = BinaryWriteParameters.MastersListContentOption.Iterate,
            });
            using var reimport = OblivionMod.CreateFromBinaryOverlay(modPath);
            Assert.Equal(
                new ModKey[]
            {
                knights,
                other,
            },
                reimport.ModHeader.MasterReferences.Select(m => m.Master));
        }
예제 #11
0
        static async Task Main(string[] args)
        {
            var settingsFilePath = new FilePath($"{args[0]}/MutagenPatcherSettings/DynamicLeveledLists.xml");

            // Eventually refactor to use XML copy in call
            // /w singleton settings object as its own defaults
            if (settingsFilePath.Exists)
            {
                settings = ModSettings.Create_Xml(settingsFilePath.Path);
            }
            else
            {
                settings.CopyFieldsFrom(defaults);
            }
            await OblivionPipeline.TypicalPatch(
                mainArgs : args,
                outputMod : ModKey.Factory("DynamicLeveledLists.esp"),
                importMask : new GroupMask(false)
            {
                Creatures        = true,
                NPCs             = true,
                LeveledCreatures = true,
            },
                processor : CreateMod);
        }
예제 #12
0
 /// <summary>
 /// Analyzes whether an Archive would typically apply to a given ModKey. <br />
 ///  <br />
 /// - Is extension of the proper type <br />
 /// - Does the name match <br />
 /// - Does the name match, with an extra ` - AssetType` suffix considered
 /// </summary>
 /// <param name="release">Game Release of mod</param>
 /// <param name="modKey">ModKey to check applicability for</param>
 /// <param name="archiveFileName">Filename of the Archive, with extension</param>
 /// <returns>True if Archive is typically applicable to the given ModKey</returns>
 public static bool IsApplicable(GameRelease release, ModKey modKey, FileName archiveFileName)
 {
     return(new CheckArchiveApplicability(
                new ArchiveExtensionProvider(
                    new GameReleaseInjection(release)))
            .IsApplicable(modKey, archiveFileName));
 }
예제 #13
0
    private void bind(StateManager.View v, ModKey newKey, List <ActionType> group)
    {
        if (!group[0].modular)
        {
            if (keyMap[(int)v].ContainsKey(group[0].currentKey))
            {
                keyMap[(int)v].Remove(group[0].currentKey);
            }


            if (keyMap[(int)v].ContainsKey(newKey))
            {
                keyMap[(int)v][newKey][0].currentKey = ModKey.none;
                keyMap[(int)v].Remove(newKey);
            }
            group[0].currentKey    = newKey;
            keyMap[(int)v][newKey] = group;
            endBind();
        }
        else
        {
            ModKey[] oldKeys = group[0].currentKey.ModularCopy();
            ModKey[] newKeys = newKey.ModularCopy();

            if (keyMap[(int)v].ContainsKey(oldKeys[0]))
            {
                keyMap[(int)v].Remove(oldKeys[0]);
            }


            if (keyMap[(int)v].ContainsKey(newKeys[0]))
            {
                keyMap[(int)v][newKeys[0]][0].currentKey = ModKey.none;
                keyMap[(int)v].Remove(newKeys[0]);
            }

            keyMap[(int)v][newKeys[0]] = group;

            for (int i = 0; i < oldKeys.Length; ++i)
            {
                if (keyMap[(int)v].ContainsKey(oldKeys[i]))
                {
                    keyMap[(int)v].Remove(oldKeys[i]);
                }


                if (keyMap[(int)v].ContainsKey(newKeys[i]))
                {
                    keyMap[(int)v][newKeys[i]][0].currentKey = ModKey.none;
                    keyMap[(int)v].Remove(newKeys[i]);
                }

                keyMap[(int)v][newKeys[i]] = group;
            }

            group[0].currentKey = newKeys[0];
            endBind();
        }
    }
예제 #14
0
        public void Comparer_Alphabetical_ByNameGreater()
        {
            ModKey k1      = ModKey.FromNameAndExtension("Knights.esm");
            ModKey k2      = ModKey.FromNameAndExtension("Oblivion.esm");
            var    compare = ModKey.AlphabeticalAndMastersFirst;

            Assert.True(compare.Compare(k2, k1) > 0);
        }
예제 #15
0
        public void Comparer_Alphabetical_ByMaster()
        {
            ModKey k1      = ModKey.FromNameAndExtension("Oblivion.esm");
            ModKey k2      = ModKey.FromNameAndExtension("Oblivion.esp");
            var    compare = ModKey.AlphabeticalAndMastersFirst;

            Assert.True(compare.Compare(k1, k2) < 0);
        }
예제 #16
0
        public void CaseEquality()
        {
            ModKey modKey  = new ModKey("Oblivion", ModType.Master);
            ModKey modKey2 = new ModKey("OblivioN", ModType.Master);

            Assert.Equal(modKey, modKey2);
            Assert.Equal(modKey.GetHashCode(), modKey2.GetHashCode());
        }
예제 #17
0
 void Update()
 {
     if (!binding)
     {
         key           = group[0].currentKey;
         keyLabel.text = key.ToString();
     }
 }
예제 #18
0
 public static string GetFileName(
     StringsLanguageFormat languageFormat,
     ModKey modKey,
     Language language,
     StringsSource source)
 {
     return($"{modKey.Name}_{GetLanguageString(languageFormat, language)}.{GetSourceString(source)}");
 }
예제 #19
0
        static void CopyOverSource(ModList <OblivionMod> modList)
        {
            var source = GetSourceMod(modList);

            sourceRecords = dynamicLeveledLists.CopyInDuplicate(source);
            sourceModKey  = source.ModKey;
            sourceEdidRecords.Set(sourceRecords.Values.Select(m => new KeyValuePair <StringCaseAgnostic, IMajorRecordCommon>(m.EditorID, m)));
        }
예제 #20
0
        public void Comparer_Alphabetical_Equal()
        {
            ModKey k1      = ModKey.FromNameAndExtension("Oblivion.esm");
            ModKey k2      = ModKey.FromNameAndExtension("Oblivion.esm");
            var    compare = ModKey.AlphabeticalAndMastersFirst;

            Assert.Equal(0, compare.Compare(k2, k1));
        }
예제 #21
0
        public IMod GetMod(ModKey modKey)
        {
            var ret = Substitute.For <IMod>();

            ret.ModKey.Returns(modKey);
            ret.GameRelease.Returns(_release);
            ret.NextFormID = 0x800;;
            return(ret);
        }
예제 #22
0
    public void IteratesContainedFormLinks()
    {
        var mod = new SkyrimMod(ModKey.FromNameAndExtension("Test.esp"), SkyrimRelease.SkyrimSE);
        var npc = mod.Npcs.AddNew();
        var key = FormKey.Factory("123456:Skyrim.esm");

        npc.Class.SetTo(key);
        mod.ContainedFormLinks.Select(x => x.FormKey).Should().Contain(key);
    }
예제 #23
0
 public void QueriesContextForDataDirectory(
     ISpecimenContext context,
     ModKey modKey,
     MakeModExist sut)
 {
     context.MockToReturn <IDataDirectoryProvider>();
     sut.MakeExist(modKey, context);
     context.ShouldHaveCreated <IDataDirectoryProvider>();
 }
        public void UninterestingNameReturnsParameterNameAsModKey(
            ISpecimenContext context,
            ModKeyParameterBuilder sut)
        {
            var    param = typeof(NonInterestingClass).Methods().First().GetParameters().First();
            ModKey mk    = (ModKey)sut.Create(param, context);

            mk.Name.Should().StartWith(param.Name);
        }
예제 #25
0
 private ModHeaderWriteLogic(
     BinaryWriteParameters?param,
     IModGetter mod,
     IModHeaderCommon modHeader)
 {
     _params     = param ?? BinaryWriteParameters.Default;
     _modKey     = mod.ModKey;
     _nextFormID = modHeader.MinimumCustomFormID;
 }
예제 #26
0
        public void OrderListings()
        {
            ModKey baseEsm  = new ModKey("Base", ModType.Master);
            ModKey baseEsm2 = new ModKey("Base2", ModType.Master);
            ModKey ccEsm    = new ModKey("CC", ModType.Master);
            ModKey ccEsm2   = new ModKey("CC2", ModType.Master);
            ModKey ccEsl    = new ModKey("CC", ModType.LightMaster);
            ModKey ccEsl2   = new ModKey("CC2", ModType.LightMaster);
            ModKey esm      = new ModKey("Normal", ModType.Master);
            ModKey esm2     = new ModKey("Normal2", ModType.Master);
            ModKey esl      = new ModKey("Normal", ModType.LightMaster);
            ModKey esl2     = new ModKey("Normal2", ModType.LightMaster);
            ModKey esp      = new ModKey("Normal", ModType.Plugin);
            ModKey esp2     = new ModKey("Normal2", ModType.Plugin);

            var ordered = LoadOrder.OrderListings(
                implicitListings: new ModKey[]
            {
                baseEsm,
                baseEsm2,
            },
                creationClubListings: new ModKey[]
            {
                ccEsl,
                ccEsl2,
                ccEsm,
                ccEsm2,
            },
                pluginsListings: new ModKey[]
            {
                esm,
                esm2,
                esl,
                esl2,
                esp,
                esp2,
            },
                selector: m => m)
                          .ToList();

            ordered.Should().Equal(new ModKey[]
            {
                baseEsm,
                baseEsm2,
                ccEsm,
                ccEsm2,
                ccEsl,
                ccEsl2,
                esm,
                esm2,
                esl,
                esl2,
                esp,
                esp2,
            });
        }
    public void StreamModKeyCtorDoesNotDisposeStream()
    {
        var stream     = new DisposeTesterWrapStream(File.OpenRead(TestDataPathing.SkyrimOverrideMod));
        var mutaStream = new MutagenBinaryReadStream(
            stream,
            ModKey.FromNameAndExtension("Skyrim.esm"),
            GameRelease.SkyrimSE);

        stream.Disposed.Should().BeFalse();
    }
예제 #28
0
        public static IEnumerable <Keys> ToKeysList(this ModKey flagsEnumValue)
        {
            Keys ToKey(ModKey keymod)
            {
                return(Keys.None);
            }

            return(Enum.GetValues(typeof(ModKey)).Cast <ModKey>().Where(e => flagsEnumValue.HasFlag(e))
                   .Select(ToKey));
        }
예제 #29
0
        public Merger(string dataFolderPath, List <ModKey> plugins, ModKey outputKey)
        {
            _loadOrder = LoadOrder.Import(
                dataFolderPath,
                plugins,
                path => ModInstantiator <ISkyrimModGetter> .Importer(path, GameRelease.SkyrimSE));

            _outputMod  = new SkyrimMod(outputKey, SkyrimRelease.SkyrimSE);
            _outputPath = Path.Combine(dataFolderPath, outputKey.FileName);
        }
예제 #30
0
 public static RecordException Create(string message, ModKey modKey, Exception?innerException = null)
 {
     return(new RecordException(
                formKey: null,
                modKey: modKey,
                edid: null,
                recordType: null,
                message: message,
                innerException: innerException));
 }
예제 #31
0
        private static List<VirtualKeyCode> getVirtualKeyCodes_byModkey(ModKey modkey)
        {
            List<VirtualKeyCode> Buffer = new List<VirtualKeyCode>();

            switch (modkey)
            {
                    case ModKey.Alt:
                    Buffer.Add(VirtualKeyCode.LMENU);
                    break;

                    case ModKey.Alt_Shift:
                    Buffer.Add(VirtualKeyCode.LMENU);
                    Buffer.Add(VirtualKeyCode.LSHIFT);
                    break;

                    case ModKey.Ctrl:
                    Buffer.Add(VirtualKeyCode.LCONTROL);
                    break;

                    case ModKey.Ctrl_Alt:
                    Buffer.Add(VirtualKeyCode.LCONTROL);
                    Buffer.Add(VirtualKeyCode.LMENU);
                    break;

                    case ModKey.Ctrl_Alt_Shift:
                    Buffer.Add(VirtualKeyCode.LCONTROL);
                    Buffer.Add(VirtualKeyCode.LMENU);
                    Buffer.Add(VirtualKeyCode.LSHIFT);
                    break;

                    case ModKey.Ctrl_Shift:
                    Buffer.Add(VirtualKeyCode.LCONTROL);
                    Buffer.Add(VirtualKeyCode.LSHIFT);
                    break;

                    case ModKey.Shift:
                    Buffer.Add(VirtualKeyCode.LSHIFT);
                    break;

                default:
                    break;

            }

            return Buffer;
        } 
예제 #32
0
        private static void ReleaseModKey(ModKey ModKey)
        {
            if (ModKey == ModKey.Undefined || ModKey == ModKey.None)
                return;

            //-- log action
            if (Properties.Settings.Default.Logger_extendedLog)
                lock (A_Handler.Log.Exception.HandlerLog) A_Handler.Log.Exception.HandlerLog.Add(new LogEntry(DateTime.Now, "Released ModKey(" + ModKey + ")"));
            //

            switch (ModKey)
            {
                case ModKey.Alt:
                    WindowsInput.InputSimulator.SimulateKeyUp(VirtualKeyCode.MENU);
                    return;

                case ModKey.Alt_Shift:
                    WindowsInput.InputSimulator.SimulateKeyUp(VirtualKeyCode.MENU);
                    WindowsInput.InputSimulator.SimulateKeyUp(VirtualKeyCode.SHIFT);
                    return;

                case ModKey.Ctrl:
                    WindowsInput.InputSimulator.SimulateKeyUp(VirtualKeyCode.CONTROL);
                    return;

                case ModKey.Ctrl_Alt:
                    WindowsInput.InputSimulator.SimulateKeyUp(VirtualKeyCode.MENU);
                    WindowsInput.InputSimulator.SimulateKeyUp(VirtualKeyCode.CONTROL);
                    return;

                case ModKey.Ctrl_Alt_Shift:
                    WindowsInput.InputSimulator.SimulateKeyUp(VirtualKeyCode.MENU);
                    WindowsInput.InputSimulator.SimulateKeyUp(VirtualKeyCode.CONTROL);
                    WindowsInput.InputSimulator.SimulateKeyUp(VirtualKeyCode.SHIFT);
                    return;

                case ModKey.Ctrl_Shift:
                    WindowsInput.InputSimulator.SimulateKeyUp(VirtualKeyCode.CONTROL);
                    WindowsInput.InputSimulator.SimulateKeyUp(VirtualKeyCode.SHIFT);
                    return;

                case ModKey.Shift:
                    WindowsInput.InputSimulator.SimulateKeyUp(VirtualKeyCode.SHIFT);
                    return;

                case ModKey.Undefined:
                case ModKey.None:
                    return;
            }
        }