/// <summary> /// Initializes a new instance of the <see cref="ThirdGenLanguagePackLoader" /> class. /// </summary> /// <param name="cacheFile">The cache file.</param> /// <param name="languageGlobals">The language globals.</param> /// <param name="buildInfo">Information about the cache file's engine.</param> /// <param name="reader">The stream to read from.</param> public ThirdGenLanguagePackLoader(ICacheFile cacheFile, ThirdGenLanguageGlobals languageGlobals, EngineDescription buildInfo, IReader reader) { _languageGlobals = languageGlobals; _languages = languageGlobals.Languages.Where(l => l.StringCount != 0).Select(l => l.Language).ToList(); LoadGroups(reader, cacheFile, buildInfo); }
public SecondGenCacheFile(IReader reader, EngineDescription buildInfo, string buildString) { _buildInfo = buildInfo; _segmenter = new FileSegmenter(buildInfo.SegmentAlignment); Allocator = new MetaAllocator(this, 0x10000); Load(reader, buildInfo, buildString); }
private void Load(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, EngineDescription buildInfo) { Name = new StringID(values.GetInteger("name stringid")); LoadPermutations(values, reader, metaArea, buildInfo); }
public ThirdGenHeader(StructureValueCollection values, EngineDescription info, string buildString, FileSegmenter segmenter) { BuildString = buildString; HeaderSize = info.HeaderSize; Load(values, segmenter); }
public MetaEditor(EngineDescription buildInfo, TagEntry tag, MetaContainer parentContainer, TagHierarchy tags, ICacheFile cache, IStreamManager streamManager, IRTEProvider rteProvider, Trie stringIDTrie) { InitializeComponent(); _parentMetaContainer = parentContainer; _tag = tag; _tags = tags; _buildInfo = buildInfo; _cache = cache; _fileManager = streamManager; _rteProvider = rteProvider; _searchTimer = new Timer(SearchTimer); _stringIdTrie = stringIDTrie; // Load Plugin Path string className = VariousFunctions.SterilizeTagClassName(CharConstant.ToString(tag.RawTag.Class.Magic)).Trim(); _pluginPath = string.Format("{0}\\{1}\\{2}.xml", VariousFunctions.GetApplicationLocation() + @"Plugins", _buildInfo.Settings.GetSetting<string>("plugins"), className); // Set Option boxes cbShowInvisibles.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowInvisibles; cbShowComments.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowComments; cbShowEnumIndex.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowEnumIndex; cbShowInformation.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowInformation; // Load Meta RefreshEditor(MetaReader.LoadType.File); // Set init finished hasInitFinished = true; }
/// <summary> /// Loads a cache file from a stream. /// </summary> /// <param name="reader">The stream to read from.</param> /// <param name="engineDb">The engine database to use to process the cache file.</param> /// <param name="engineInfo">On output, this will contain the cache file's engine description.</param> /// <returns>The cache file that was loaded.</returns> /// <exception cref="ArgumentException">Thrown if the cache file is invalid.</exception> /// <exception cref="NotSupportedException">Thrown if the cache file's target engine is not supported.</exception> public static ICacheFile LoadCacheFile(IReader reader, EngineDatabase engineDb, out EngineDescription engineInfo) { // Set the reader's endianness based upon the file's header magic reader.SeekTo(0); byte[] headerMagic = reader.ReadBlock(4); reader.Endianness = DetermineCacheFileEndianness(headerMagic); // Load engine version info var version = new CacheFileVersionInfo(reader); if (version.Engine != EngineType.SecondGeneration && version.Engine != EngineType.ThirdGeneration) throw new NotSupportedException("Engine not supported"); // Load build info engineInfo = engineDb.FindEngineByVersion(version.BuildString); if (engineInfo == null) throw new NotSupportedException("Engine version \"" + version.BuildString + "\" not supported"); // Load the cache file depending upon the engine version switch (version.Engine) { case EngineType.SecondGeneration: return new SecondGenCacheFile(reader, engineInfo, version.BuildString); case EngineType.ThirdGeneration: return new ThirdGenCacheFile(reader, engineInfo, version.BuildString); default: throw new NotSupportedException("Engine not supported"); } }
public ThirdGenResourceLayoutTable(ITag playTag, FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo) { _tag = playTag; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; }
private void Load(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, EngineDescription buildInfo) { ModelResourceIndex = new DatumIndex(values.GetInteger("model resource datum index")); LoadSections(values, reader, metaArea, buildInfo); LoadBoundingBoxes(values, reader, metaArea, buildInfo); }
/// <summary> /// Loads group info from a cache file. /// </summary> /// <param name="reader">The stream to read from.</param> /// <param name="cacheFile">The cache file.</param> /// <param name="buildInfo">Information about the cache file's engine.</param> private void LoadGroups(IReader reader, ICacheFile cacheFile, EngineDescription buildInfo) { foreach (ITag tag in cacheFile.Tags.FindTagsByClass("unic")) { var group = new ThirdGenMultilingualStringList(reader, tag, buildInfo); _groups.Add(group); } }
public ThirdGenZoneSetTable(ThirdGenResourceGestalt gestalt, IReader reader, FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo) { _gestalt = gestalt; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; Load(reader); }
public ThirdGenLanguage(GameLanguage language, StructureValueCollection values, FileSegmenter segmenter, FileSegmentGroup localeArea, EngineDescription buildInfo) { Language = language; _pointerLayout = buildInfo.Layouts.GetLayout("locale index table entry"); _encryptionKey = buildInfo.LocaleKey; _sizeAlign = (_encryptionKey != null) ? AES.BlockSize : 1; Load(values, segmenter, localeArea); }
private List<ThirdGenLanguage> LoadLanguages(StructureValueCollection values, FileSegmenter segmenter, EngineDescription buildInfo) { StructureValueCollection[] languageSet = values.GetArray("languages"); IEnumerable<ThirdGenLanguage> result = languageSet.Select((l, i) => new ThirdGenLanguage((GameLanguage) i, l, segmenter, LocaleArea, buildInfo)); return result.ToList(); }
/// <summary> /// Reads all child objects of this reflexive. /// </summary> /// <param name="values">The values read from the parent.</param> /// <param name="reader">The stream to read from.</param> /// <param name="metaArea">The meta area of the cache file.</param> /// <param name="stringIDs">The string ID source for the cache file.</param> /// <param name="buildInfo">The build info for the cache file.</param> /// <returns>The objects that were read.</returns> public ScriptObject[] ReadObjects(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, StringIDSource stringIDs, EngineDescription buildInfo) { var count = (int) values.GetInteger(_countEntryName); uint address = values.GetInteger(_addressEntryName); StructureLayout layout = buildInfo.Layouts.GetLayout(_layoutName); StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea); return entries.Select(e => ReadScriptObject(e, reader, metaArea, stringIDs, buildInfo)).ToArray(); }
public ThirdGenTagTable(IReader reader, SegmentPointer indexHeaderLocation, FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo) { _indexHeaderLocation = indexHeaderLocation; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; Load(reader); }
/// <summary> /// Reads the resource data for a model from a stream and passes it to an IModelProcessor. /// </summary> /// <param name="reader">The stream to read the model data from.</param> /// <param name="model">The model's metadata.</param> /// <param name="sectionsToRead"> /// A BitArray controlling which sections to read. Indices which are set to to true will be /// read. /// </param> /// <param name="buildInfo">Information about the cache file's target engine.</param> /// <param name="processor">The IModelProcessor to pass the read model data to.</param> public static void ReadModelData(IReader reader, IRenderModel model, BitArray sectionsToRead, EngineDescription buildInfo, IModelProcessor processor) { processor.BeginModel(model); ReadVertexBuffers(reader, model, sectionsToRead, buildInfo, processor); ReadIndexBuffers(reader, model, sectionsToRead, buildInfo, processor); processor.EndModel(model); }
private void Load(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, EngineDescription buildInfo) { VertexFormat = (int) values.GetInteger("vertex format"); ExtraElementsPerVertex = (int) values.GetInteger("extra elements per vertex"); ExtraElementsType = (ExtraVertexElementType) values.GetInteger("extra element type"); LoadSubmeshes(values, reader, metaArea, buildInfo); LoadVertexGroups(values, reader, metaArea, buildInfo, Submeshes); }
public ScriptEditor(EngineDescription buildInfo, IScriptFile scriptFile, IStreamManager streamManager) { _buildInfo = buildInfo; _scriptFile = scriptFile; InitializeComponent(); var thrd = new Thread(DecompileScripts); thrd.SetApartmentState(ApartmentState.STA); thrd.Start(streamManager); }
/// <summary> /// Initializes a new instance of the <see cref="ThirdGenResourceManager" /> class. /// </summary> /// <param name="gestalt">The cache file's resource gestalt.</param> /// <param name="layoutTable">The cache file's resource layout table.</param> /// <param name="tags">The cache file's tag table.</param> /// <param name="metaArea">The cache file's meta area.</param> /// <param name="allocator">The cache file's tag data allocator.</param> /// <param name="buildInfo">The cache file's build information.</param> public ThirdGenResourceManager(ThirdGenResourceGestalt gestalt, ThirdGenResourceLayoutTable layoutTable, TagTable tags, FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo) { _gestalt = gestalt; _layoutTable = layoutTable; _tags = tags; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; }
/// <summary> /// View the selected offset as every meta value type. /// </summary> /// <param name="cacheFile">The cache file which is being read from.</param> /// <param name="buildInfo">Build information for the engine.</param> /// <param name="streamManager">The stream manager to open the file with.</param> /// <param name="fields">The fields to display in the viewer.</param> /// <param name="cacheOffset">The initial offset to display.</param> public static void Show(ICacheFile cacheFile, EngineDescription buildInfo, IStreamManager streamManager, IList<MetaField> fields, uint cacheOffset) { var valueAs = new ViewValueAs(cacheFile, buildInfo, streamManager, fields, cacheOffset) { Owner = App.AssemblyStorage.AssemblySettings.HomeWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner }; valueAs.Show(); }
public ThirdGenResourceGestalt(IReader reader, ITag zoneTag, FileSegmentGroup metaArea, MetaAllocator allocator, StringIDSource stringIDs, EngineDescription buildInfo) { _tag = zoneTag; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; Load(reader, stringIDs); }
private void LoadSections(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, EngineDescription buildInfo) { var count = (int) values.GetInteger("number of sections"); uint address = values.GetInteger("section table address"); StructureLayout layout = buildInfo.Layouts.GetLayout("model section"); StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea); Sections = (from entry in entries select new ThirdGenModelSection(entry, reader, metaArea, buildInfo)).ToArray(); }
private void LoadBoundingBoxes(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, EngineDescription buildInfo) { var count = (int) values.GetInteger("number of bounding boxes"); uint address = values.GetInteger("bounding box table address"); StructureLayout layout = buildInfo.Layouts.GetLayout("model bounding box"); StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, 1, address, layout, metaArea); BoundingBoxes = (from entry in entries select BoundingBox.Deserialize(entry)).ToArray(); }
public ThirdGenScenarioScriptFile(ITag scenarioTag, string scenarioName, FileSegmentGroup metaArea, StringIDSource stringIDs, EngineDescription buildInfo) { _tag = scenarioTag; _stringIDs = stringIDs; _metaArea = metaArea; _buildInfo = buildInfo; Name = scenarioName.Substring(scenarioName.LastIndexOf('\\') + 1) + ".hsc"; DefineScriptObjectReflexives(); }
private void LoadVertexGroups(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, EngineDescription buildInfo, IModelSubmesh[] submeshes) { var count = (int) values.GetInteger("number of vertex groups"); uint address = values.GetInteger("vertex group table address"); StructureLayout layout = buildInfo.Layouts.GetLayout("model vertex group"); StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea); VertexGroups = (from entry in entries select new ThirdGenModelVertexGroup(entry, submeshes)).ToArray(); }
public MetaInformation(EngineDescription buildInfo, TagEntry tag, ICacheFile cache) { InitializeComponent(); lblTagName.Text = tag.TagFileName != null ? tag.TagFileName + "." + tag.ClassName : "0x" + tag.RawTag.Index.Value.ToString("X"); lblDatum.Text = string.Format("Datum Index: {0}", tag.RawTag.Index); lblAddress.Text = string.Format("Memory Address: 0x{0:X8}", tag.RawTag.MetaLocation.AsPointer()); lblOffset.Text = string.Format("File Offset: 0x{0:X}", tag.RawTag.MetaLocation.AsOffset()); }
/// <summary> /// Reads the index buffers for a model from a stream and passes them to an IModelProcessor. /// </summary> /// <param name="reader">The stream to read the index buffers from.</param> /// <param name="model">The model's metadata.</param> /// <param name="sectionsToRead"> /// A BitArray controlling which sections to read. Indices which are set to to true will be /// read. /// </param> /// <param name="buildInfo">Information about the cache file's target engine.</param> /// <param name="processor">The IModelProcessor to pass the read model data to.</param> private static void ReadIndexBuffers(IReader reader, IRenderModel model, BitArray sectionsToRead, EngineDescription buildInfo, IModelProcessor processor) { int baseIndex = 0; for (int i = 0; i < model.Sections.Length; i++) { IModelSection section = model.Sections[i]; ReadSectionIndices(reader, section, baseIndex, buildInfo, sectionsToRead[i] ? processor : null); if (sectionsToRead[i]) baseIndex += CountVertices(section); } }
/// <summary> /// Initializes a new instance of the <see cref="DataBlockBuilder" /> class. /// </summary> /// <param name="reader">The stream to read from.</param> /// <param name="tagLocation">The location of the tag to load data blocks for.</param> /// <param name="cacheFile">The cache file.</param> /// <param name="buildInfo">The build info for the cache file.</param> public DataBlockBuilder(IReader reader, SegmentPointer tagLocation, ICacheFile cacheFile, EngineDescription buildInfo) { _reader = reader; _tagLocation = tagLocation; _cacheFile = cacheFile; _tagRefLayout = buildInfo.Layouts.GetLayout("tag reference"); _reflexiveLayout = buildInfo.Layouts.GetLayout("reflexive"); _dataRefLayout = buildInfo.Layouts.GetLayout("data reference"); DataBlocks = new List<DataBlock>(); ReferencedTags = new HashSet<DatumIndex>(); ReferencedResources = new HashSet<DatumIndex>(); }
public MetaReader(IStreamManager streamManager, uint baseOffset, ICacheFile cache, EngineDescription buildInfo, LoadType type, FieldChangeSet ignore) { _streamManager = streamManager; BaseOffset = baseOffset; _cache = cache; _ignoredFields = ignore; _type = type; // Load layouts _reflexiveLayout = buildInfo.Layouts.GetLayout("reflexive"); _tagRefLayout = buildInfo.Layouts.GetLayout("tag reference"); _dataRefLayout = buildInfo.Layouts.GetLayout("data reference"); }
private void Load(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, StringIDSource stringIDs, EngineDescription buildInfo) { Name = values.HasInteger("name index") ? stringIDs.GetString(new StringID(values.GetInteger("name index"))) : values.GetString("name"); ExecutionType = (short) values.GetInteger("execution type"); ReturnType = (short) values.GetInteger("return type"); RootExpressionIndex = new DatumIndex(values.GetInteger("first expression index")); if (Name == null) Name = "script_" + RootExpressionIndex.Value.ToString("X8"); Parameters = LoadParameters(reader, values, metaArea, buildInfo); }
private static List<ITagClass> ReadClasses(IReader reader, uint classTableOffset, int numClasses, EngineDescription buildInfo) { StructureLayout layout = buildInfo.Layouts.GetLayout("class entry"); var result = new List<ITagClass>(); reader.SeekTo(classTableOffset); for (int i = 0; i < numClasses; i++) { StructureValueCollection values = StructureReader.ReadStructure(reader, layout); result.Add(new SecondGenTagClass(values)); } return result; }