public static void Write() { string buildPath = DataDirectory.GetBuildPath(); Build build = new Build(buildPath); BuildTarget qfBuildTarget = BuildTargetFactory.Construct(BuildTargetFactory.QFName, build); BuildTarget tifBuildTarget = BuildTargetFactory.Construct(BuildTargetFactory.TIFName, build); TES4Collection collection = TES4CollectionFactory.Create(DataDirectory.GetESMDirectoryPath(), DataDirectory.TES4GameFileName);//Needs the "full" collection for SCRO lookups. using (ESMAnalyzer esmAnalyzer = ESMAnalyzer.Load(collection)) { foreach (TES4Record record in collection.Where(r => r.RecordType == TES4RecordType.INFO)) { var scroRecords = esmAnalyzer.GetTypesFromSCROEnumerable(record, null); string[] aliases = scroRecords.Select(r => r.Key).ToArray(); Write(qfBuildTarget, tifBuildTarget, record, null, aliases); } foreach (TES4Record record in collection.GetGrupRecords(TES4RecordType.QUST)) { Dictionary <StageIndexAndLogIndex, List <string> > aliasesDictionary = new Dictionary <StageIndexAndLogIndex, List <string> >(); foreach (var subrecord in record.GetSubrecordsWithStageIndexAndLogIndex("SCRO")) { int formID = subrecord.Item1.Value.FirstFourBytesToInt(); string name = formID == TES5PlayerReference.FormID ? TES5PlayerReference.PlayerRefName : esmAnalyzer.GetEDIDByFormID(formID); aliasesDictionary.AddNewListIfNotContainsKeyAndAddValueToList(subrecord.Item2, name); } foreach (var aliases in aliasesDictionary) { Write(qfBuildTarget, tifBuildTarget, record, aliases.Key, aliases.Value); } } } }
public static TES4Collection CreateForScriptExporting(string dataFileDirectory, string dataFile) { TES4FileLoadScheme fileScheme = new TES4FileLoadScheme() { { TES4RecordType.SCPT, new TES4GrupLoadScheme() { { TES4RecordType.SCPT, new TES4RecordLoadScheme(new string[] { "EDID", "SCTX" }) } } }, { TES4RecordType.DIAL, new TES4GrupLoadScheme() { { TES4RecordType.DIAL, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) }, { TES4RecordType.INFO, new TES4RecordLoadScheme(new string[] { "EDID", "SCTX" }) } } }, { TES4RecordType.QUST, new TES4GrupLoadScheme() { { TES4RecordType.QUST, new TES4RecordLoadScheme(new string[] { "EDID", "INDX", "QSDT", "SCTX" }) } } } }; TES4Collection collection = new TES4Collection(dataFileDirectory); collection.Add(dataFile); collection.Load(fileScheme); return(collection); }
/* * Makes the adapter unusable by deallocating the esm object. * This really ought to be more clean, but until this class is used statically we have no other choice */ public static void Deallocate() { //Drop the ref esm = null; //Force the GC GC.Collect(); }
public static void Write() { TES4Collection collection = TES4CollectionFactory.CreateForScriptExporting(DataDirectory.GetESMDirectoryPath(), DataDirectory.TES4GameFileName); string buildTargetsPath = DataDirectory.GetBuildTargetsPath(); Write(collection, buildTargetsPath, "Standalone", "", false, null, true, TES4RecordType.SCPT); Write(collection, buildTargetsPath, "TIF", TES5ReferenceFactory.tif_Prefix, true, null, false, TES4RecordType.INFO); WriteWithIndexes(collection, buildTargetsPath, "QF", TES5ReferenceFactory.qf_Prefix, TES4RecordType.QUST); }
private static void WriteWithIndexes(TES4Collection collection, string buildTargetsPath, string scriptFolderName, string scriptNamePrefix, TES4RecordType recordType) { Write(collection, buildTargetsPath, scriptFolderName, recordType, (record, directory) => { foreach (var subrecord in record.GetSubrecordsWithStageIndexAndLogIndex("SCTX")) { string sctx = subrecord.Item1.Value.ToStringTrim(); Write(directory, scriptNamePrefix, record, true, subrecord.Item2, false, sctx); } }); }
public static void Write() { TES4Collection collection = TES4CollectionFactory.CreateForQUSTReferenceAliasExporting(DataDirectory.GetESMDirectoryPath(), DataDirectory.TES4GameFileName); BuildTarget qfBuildTarget = BuildTargetFactory.Construct(BuildTargetFactory.QFName, new Build(DataDirectory.GetBuildPath())); string sourcePath = qfBuildTarget.GetSourcePath(); IEnumerable <TES4Record> qustRecords = collection.GetGrupRecords(TES4RecordType.QUST); foreach (TES4Record qust in qustRecords) { Write(sourcePath, qust); } }
private static void Write(TES4Collection collection, string buildTargetsPath, string scriptFolderName, TES4RecordType recordType, Action <TES4Record, string> writeRecord) { string directory = buildTargetsPath + scriptFolderName + Path.DirectorySeparatorChar + "Source" + Path.DirectorySeparatorChar; Directory.CreateDirectory(directory); var records = recordType == TES4RecordType.INFO ? collection.Where(r => r.RecordType == recordType) : collection.GetGrupRecords(recordType); foreach (TES4Record record in records) { writeRecord(record, directory); } }
public static void Write() { BuildTarget qfBuildTarget = BuildTargetFactory.Construct(BuildTargetFactory.QFName, new Build(DataDirectory.GetBuildPath())); string sourcePath = qfBuildTarget.GetSourcePath(); TES4Collection collection = TES4CollectionFactory.CreateForQUSTStageMapExportingFromESM(DataDirectory.GetESMDirectoryPath(), DataDirectory.TES4GameFileName); IEnumerable <TES4Record> qusts = collection.GetGrupRecords(TES4RecordType.QUST); foreach (TES4Record qust in qusts) { string fileNameNoExt = BuildTargetsWriter.GetFileNameNoExt(TES5ReferenceFactory.qf_Prefix, qust, true, null); string fileName = fileNameNoExt + ".map"; string mapFilePath = sourcePath + Path.DirectorySeparatorChar + fileName; string contentsString = StageMapFromESMBuilder.BuildString(qust); FileWriter.WriteAllTextOrThrowIfExists(mapFilePath, contentsString); } }
public static TES4Collection CreateForQUSTStageMapExportingFromESM(string dataFileDirectory, string dataFile) { TES4FileLoadScheme fileScheme = new TES4FileLoadScheme { { TES4RecordType.QUST, new TES4GrupLoadScheme() { { TES4RecordType.QUST, new TES4RecordLoadScheme(new string[] { "EDID", "INDX", "QSTA", "CTDA" }) } } } }; TES4Collection collection = new TES4Collection(dataFileDirectory); collection.Add(dataFile); collection.Load(fileScheme); return(collection); }
public static TES4Collection CreateForQUSTReferenceAliasExporting(string dataFileDirectory, string dataFile) { TES4FileLoadScheme fileScheme = new TES4FileLoadScheme() { { TES4RecordType.QUST, new TES4GrupLoadScheme() { { TES4RecordType.QUST, new TES4RecordLoadScheme(new string[] { "EDID", "QSTA" }) } } } }; TES4Collection collection = new TES4Collection(dataFileDirectory); collection.Add(dataFile); collection.Load(fileScheme); return(collection); }
public static void Write() { BuildTarget qfBuildTarget = BuildTargetFactory.Construct(BuildTargetFactory.QFName, new Build(DataDirectory.GetBuildPath())); string transpiledPath = qfBuildTarget.GetTranspiledPath(); string sourcePath = qfBuildTarget.GetSourcePath(); foreach (string pscPath in Directory.EnumerateFiles(transpiledPath, "*.psc")) { Write(sourcePath, pscPath); } TES4Collection collection = TES4CollectionFactory.CreateForQUSTStageMapExportingFromPSCFiles(DataDirectory.GetESMDirectoryPath(), DataDirectory.TES4GameFileName); IEnumerable <TES4Record> qustRecords = collection.GetGrupRecords(TES4RecordType.QUST); foreach (TES4Record qust in qustRecords) { string path = sourcePath + BuildTargetsWriter.GetFileNameNoExt(TES5ReferenceFactory.qf_Prefix, qust, true, null) + ".map2"; FileWriter.WriteAllTextIfNotExists(path, ""); } }
private static void Write(TES4Collection collection, string buildTargetsPath, string scriptFolderName, string scriptNamePrefix, bool includeFormID, StageIndexAndLogIndex?stageIndexAndLogIndex, bool allowFixScriptName, TES4RecordType recordType) { Write(collection, buildTargetsPath, scriptFolderName, recordType, (record, directory) => { string[] sctxs = record.GetSubrecordsStrings("SCTX").ToArray(); if (sctxs.Any()) { if (sctxs.Length > 1) { throw new InvalidOperationException(nameof(sctxs) + ".Length > 1"); } #if !NEWBT if (recordType == TES4RecordType.SCPT && !ShouldWriteScript(record.GetEditorID())) { return; } #endif Write(directory, scriptNamePrefix, record, includeFormID, stageIndexAndLogIndex, allowFixScriptName, TES4Record.ReplaceSCTXSpecialCharacters(sctxs[0])); } }); }
/* * TES5Collection constructor. */ public TES5Collection(TES4Collection tes4Collection, string path) { this.tes4Collection = tes4Collection; this.path = path; }
public static ESMAnalyzer Load(TES4Collection tes4Collection) { return(new ESMAnalyzer(tes4Collection)); }
public ESMAnalyzer(string dataFile = DataDirectory.TES4GameFileName) { if (esm == null) { TES4Collection collection = new TES4Collection(DataDirectory.GetESMDirectoryPath()); collection.Add(dataFile); //NOTE - SCRI record load scheme is a copypasta, as in, i didnt check which records do actually might have SCRI //Doesnt really matter for other purposes than cleaniness TES4FileLoadScheme fileScheme = new TES4FileLoadScheme(); TES4GrupLoadScheme grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.GMST, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.GMST, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.GLOB, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.GLOB, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.CLAS, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.CLAS, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.FACT, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.FACT, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.HAIR, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.HAIR, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.EYES, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.EYES, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.RACE, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.RACE, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.SOUN, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.SOUN, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.SKIL, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.SKIL, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.MGEF, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.MGEF, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.SCPT, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI", "SCHR" })); fileScheme.add(TES4RecordType.SCPT, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.LTEX, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.LTEX, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.ENCH, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.ENCH, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.SPEL, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.SPEL, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.BSGN, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.BSGN, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.ACTI, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.ACTI, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.APPA, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.APPA, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.ARMO, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.ARMO, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.BOOK, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.BOOK, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.CLOT, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.CLOT, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.CONT, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.CONT, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.DOOR, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.DOOR, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.INGR, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.INGR, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.LIGH, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.LIGH, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.MISC, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.MISC, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.STAT, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.STAT, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.GRAS, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.GRAS, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.TREE, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.TREE, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.FLOR, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.FLOR, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.FURN, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.FURN, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.WEAP, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.WEAP, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.AMMO, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.AMMO, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.NPC_, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.NPC_, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.CREA, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.CREA, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.LVLC, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.LVLC, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.SLGM, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.SLGM, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.KEYM, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.KEYM, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.ALCH, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.ALCH, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.SBSP, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.SBSP, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.SGST, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.SGST, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.LVLI, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.LVLI, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.WTHR, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.WTHR, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.CLMT, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.CLMT, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.REGN, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.REGN, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.CELL, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI", "FULL" }));//WTM: Change: Added "Full" for use from GetInCellFactory.cs. grupScheme.Add(TES4RecordType.REFR, new TES4RecordLoadScheme(new string[] { "EDID", "NAME" })); grupScheme.Add(TES4RecordType.ACHR, new TES4RecordLoadScheme(new string[] { "EDID", "NAME" })); grupScheme.Add(TES4RecordType.ACRE, new TES4RecordLoadScheme(new string[] { "EDID", "NAME" })); fileScheme.add(TES4RecordType.CELL, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.WRLD, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); grupScheme.Add(TES4RecordType.CELL, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); grupScheme.Add(TES4RecordType.REFR, new TES4RecordLoadScheme(new string[] { "EDID", "NAME" })); grupScheme.Add(TES4RecordType.ACHR, new TES4RecordLoadScheme(new string[] { "EDID", "NAME" })); grupScheme.Add(TES4RecordType.ACRE, new TES4RecordLoadScheme(new string[] { "EDID", "NAME" })); fileScheme.add(TES4RecordType.WRLD, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.DIAL, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.DIAL, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.QUST, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.QUST, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.IDLE, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.IDLE, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.PACK, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.PACK, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.CSTY, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.CSTY, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.LSCR, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.LSCR, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.LVSP, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.LVSP, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.ANIO, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.ANIO, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.WATR, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.WATR, grupScheme); grupScheme = new TES4GrupLoadScheme(); grupScheme.Add(TES4RecordType.EFSH, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" })); fileScheme.add(TES4RecordType.EFSH, grupScheme); collection.Load(fileScheme); esm = collection; } if (this.scriptTypes == null) { this.scriptTypes = new Dictionary <string, ITES5Type>(); List <TES4Grup> scpts = esm.GetGrup(TES4RecordType.SCPT); foreach (ITES4Record scpt in scpts.SelectMany(s => s.Select(r => r))) { string schr = scpt.GetSubrecordString("SCHR"); string edid = scpt.GetSubrecordTrimLower("EDID"); if (string.IsNullOrWhiteSpace(schr) || string.IsNullOrWhiteSpace(edid)) { continue; } TES5BasicType scriptType; if (edid == "dark09skeletonsuicidescript" || edid == "xpebroccabossscript")//WTM: Change: Added special condition { scriptType = TES5BasicType.T_ACTOR; } else { bool isQuest = ((int)schr.Substring(16, 1)[0]) != 0; bool isActiveMagicEffect = ((int)schr.Substring(17, 1)[0]) != 0; if (isQuest) { scriptType = TES5BasicType.T_QUEST; } else if (isActiveMagicEffect) { scriptType = TES5BasicType.T_ACTIVEMAGICEFFECT; } else { scriptType = TES5BasicType.T_OBJECTREFERENCE; } } this.scriptTypes.Add(edid, scriptType); } } if (this.GlobalVariables == null) { List <TES4Grup> globals = esm.GetGrup(TES4RecordType.GLOB); List <TES5GlobalVariable> globalArray = new List <TES5GlobalVariable>(); foreach (ITES4Record global in globals.SelectMany(g => g.Select(r => r))) { string edid = global.GetSubrecordTrim("EDID"); if (string.IsNullOrWhiteSpace(edid)) { continue; } globalArray.Add(new TES5GlobalVariable(edid)); } /* * Hacky - add infamy into the globals array * Probably we should extract this from this class and put this into other place */ globalArray.Add(new TES5GlobalVariable("Infamy")); this.GlobalVariables = new TES5GlobalVariables(globalArray); } if (instance == null) { instance = this; } }
private ESMAnalyzer(TES4Collection tes4Collection) : this(() => tes4Collection, false) { }
public static TES4Collection Create(string dataFileDirectory, string dataFile) { //NOTE - SCRI record load scheme is a copypasta, as in, i didnt check which records do actually might have SCRI //Doesnt really matter for other purposes than cleaniness TES4FileLoadScheme fileScheme = new TES4FileLoadScheme { { TES4RecordType.GMST, new TES4GrupLoadScheme() { { TES4RecordType.GMST, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.GLOB, new TES4GrupLoadScheme() { { TES4RecordType.GLOB, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.CLAS, new TES4GrupLoadScheme() { { TES4RecordType.CLAS, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.FACT, new TES4GrupLoadScheme() { { TES4RecordType.FACT, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.HAIR, new TES4GrupLoadScheme() { { TES4RecordType.HAIR, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.EYES, new TES4GrupLoadScheme() { { TES4RecordType.EYES, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.RACE, new TES4GrupLoadScheme() { { TES4RecordType.RACE, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.SOUN, new TES4GrupLoadScheme() { { TES4RecordType.SOUN, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.SKIL, new TES4GrupLoadScheme() { { TES4RecordType.SKIL, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.MGEF, new TES4GrupLoadScheme() { { TES4RecordType.MGEF, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.SCPT, new TES4GrupLoadScheme() { { TES4RecordType.SCPT, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI", "SCHR", "SCRO" }) }//WTM: Change: Added SCRO for use by ESMAnalyzer.GetTypesFromSCRO. } }, { TES4RecordType.LTEX, new TES4GrupLoadScheme() { { TES4RecordType.LTEX, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.ENCH, new TES4GrupLoadScheme() { { TES4RecordType.ENCH, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.SPEL, new TES4GrupLoadScheme() { { TES4RecordType.SPEL, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.BSGN, new TES4GrupLoadScheme() { { TES4RecordType.BSGN, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.ACTI, new TES4GrupLoadScheme() { { TES4RecordType.ACTI, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.APPA, new TES4GrupLoadScheme() { { TES4RecordType.APPA, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.ARMO, new TES4GrupLoadScheme() { { TES4RecordType.ARMO, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.BOOK, new TES4GrupLoadScheme() { { TES4RecordType.BOOK, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.CLOT, new TES4GrupLoadScheme() { { TES4RecordType.CLOT, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.CONT, new TES4GrupLoadScheme() { { TES4RecordType.CONT, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.DOOR, new TES4GrupLoadScheme() { { TES4RecordType.DOOR, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.INGR, new TES4GrupLoadScheme() { { TES4RecordType.INGR, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.LIGH, new TES4GrupLoadScheme() { { TES4RecordType.LIGH, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.MISC, new TES4GrupLoadScheme() { { TES4RecordType.MISC, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.STAT, new TES4GrupLoadScheme() { { TES4RecordType.STAT, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.GRAS, new TES4GrupLoadScheme() { { TES4RecordType.GRAS, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.TREE, new TES4GrupLoadScheme() { { TES4RecordType.TREE, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.FLOR, new TES4GrupLoadScheme() { { TES4RecordType.FLOR, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.FURN, new TES4GrupLoadScheme() { { TES4RecordType.FURN, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.WEAP, new TES4GrupLoadScheme() { { TES4RecordType.WEAP, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.AMMO, new TES4GrupLoadScheme() { { TES4RecordType.AMMO, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.NPC_, new TES4GrupLoadScheme() { { TES4RecordType.NPC_, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.CREA, new TES4GrupLoadScheme() { { TES4RecordType.CREA, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.LVLC, new TES4GrupLoadScheme() { { TES4RecordType.LVLC, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.SLGM, new TES4GrupLoadScheme() { { TES4RecordType.SLGM, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.KEYM, new TES4GrupLoadScheme() { { TES4RecordType.KEYM, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.ALCH, new TES4GrupLoadScheme() { { TES4RecordType.ALCH, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.SBSP, new TES4GrupLoadScheme() { { TES4RecordType.SBSP, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.SGST, new TES4GrupLoadScheme() { { TES4RecordType.SGST, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.LVLI, new TES4GrupLoadScheme() { { TES4RecordType.LVLI, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.WTHR, new TES4GrupLoadScheme() { { TES4RecordType.WTHR, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.CLMT, new TES4GrupLoadScheme() { { TES4RecordType.CLMT, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.REGN, new TES4GrupLoadScheme() { { TES4RecordType.REGN, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.CELL, new TES4GrupLoadScheme() { { TES4RecordType.CELL, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI", "FULL" }) },//WTM: Change: Added FULL for use from GetInCellFactory.cs. { TES4RecordType.REFR, new TES4RecordLoadScheme(new string[] { "EDID", "NAME" }) }, { TES4RecordType.ACHR, new TES4RecordLoadScheme(new string[] { "EDID", "NAME" }) }, { TES4RecordType.ACRE, new TES4RecordLoadScheme(new string[] { "EDID", "NAME" }) } } }, { TES4RecordType.WRLD, new TES4GrupLoadScheme() { { TES4RecordType.WRLD, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) }, { TES4RecordType.CELL, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) }, { TES4RecordType.REFR, new TES4RecordLoadScheme(new string[] { "EDID", "NAME" }) }, { TES4RecordType.ACHR, new TES4RecordLoadScheme(new string[] { "EDID", "NAME" }) }, { TES4RecordType.ACRE, new TES4RecordLoadScheme(new string[] { "EDID", "NAME" }) } } }, { TES4RecordType.DIAL, new TES4GrupLoadScheme() { { TES4RecordType.DIAL, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) }, { TES4RecordType.INFO, new TES4RecordLoadScheme(new string[] { "NAME", "SCRO" }) }//WTM: Change: Added INFO line and SCRO argument for use by ESMAnalyzer.GetTypesFromSCRO. Added NAME argument for use by TranspileChunkJob.GenerateINFOAddTopicScripts. } }, { TES4RecordType.QUST, new TES4GrupLoadScheme() { { TES4RecordType.QUST, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI", "INDX", "SCRO", "QSTA", "QSDT", "CTDA" }) }//WTM: Change: Added INDX and SCRO for use by ESMAnalyzer.GetTypesFromSCRO. Added QSTA, QSDT, and CTDA to retrieve information previously retrieved from BuildTarget files. } }, { TES4RecordType.IDLE, new TES4GrupLoadScheme() { { TES4RecordType.IDLE, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.PACK, new TES4GrupLoadScheme() { { TES4RecordType.PACK, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.CSTY, new TES4GrupLoadScheme() { { TES4RecordType.CSTY, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.LSCR, new TES4GrupLoadScheme() { { TES4RecordType.LSCR, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.LVSP, new TES4GrupLoadScheme() { { TES4RecordType.LVSP, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.ANIO, new TES4GrupLoadScheme() { { TES4RecordType.ANIO, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.WATR, new TES4GrupLoadScheme() { { TES4RecordType.WATR, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } }, { TES4RecordType.EFSH, new TES4GrupLoadScheme() { { TES4RecordType.EFSH, new TES4RecordLoadScheme(new string[] { "EDID", "SCRI" }) } } } }; TES4Collection collection = new TES4Collection(dataFileDirectory); collection.Add(dataFile); collection.Load(fileScheme); return(collection); }