public ThirdGenLanguageGlobals(StructureValueCollection values, FileSegmenter segmenter, IPointerConverter localePointerConverter, BuildInformation buildInfo)
        {
            LocaleArea = new FileSegmentGroup(localePointerConverter);

            _languages = LoadLanguages(values, segmenter, buildInfo);
            _alignment = buildInfo.SegmentAlignment;
        }
Пример #2
0
        public MetaEditor(BuildInformation 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;
            _streamManager = 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.PluginFolder, className);

            // Set Invisibility box
            cbShowInvisibles.IsChecked = Settings.pluginsShowInvisibles;

            // Load Meta
            RefreshEditor();

            // Set init finished
            hasInitFinished = true;
        }
Пример #3
0
        public MetaContainer(BuildInformation buildInfo, TagEntry tag, TagHierarchy tags, ICacheFile cache, IStreamManager streamManager, IRTEProvider rteProvider, Trie stringIDTrie)
        {
            InitializeComponent();

            _tag = tag;
            _tags = tags;
            _buildInfo = buildInfo;
            _cache = cache;
            _streamManager = streamManager;
            _rteProvider = rteProvider;
            _stringIDTrie = stringIDTrie;

            tbMetaEditors.SelectedIndex = (int)Settings.halomapLastSelectedMetaEditor;

            // Create Meta Information Tab
            _metaInformation = new MetaInformation(_buildInfo, _tag, _cache);
            tabTagInfo.Content = _metaInformation;

            // Create Meta Editor Tab
            _metaEditor = new MetaEditor(_buildInfo, _tag, this, _tags, _cache, _streamManager, _rteProvider, _stringIDTrie)
                              {
                                  Padding = new Thickness(0)
                              };
            tabMetaEditor.Content = _metaEditor;

            // Create Plugin Editor Tab
            _pluginEditor = new PluginEditor(_buildInfo, _tag, this, _metaEditor);
            tabPluginEditor.Content = _pluginEditor;
        }
Пример #4
0
 public ThirdGenCacheFile(IReader reader, BuildInformation buildInfo, string buildString)
 {
     _buildInfo = buildInfo;
     _segmenter = new FileSegmenter(buildInfo.SegmentAlignment);
     Allocator = new MetaAllocator(this, 0x10000);
     Load(reader, buildString);
 }
Пример #5
0
        /// <summary>
        /// Loads a cache file from a stream.
        /// </summary>
        /// <param name="reader">The stream to read from.</param>
        /// <param name="infoLoader">The BuildInfoLoader responsible for loading build information for the cache file.</param>
        /// <param name="buildInfo">The variable to store build information to.</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, BuildInfoLoader infoLoader, out BuildInformation buildInfo)
        {
            // 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
            CacheFileVersionInfo version = new CacheFileVersionInfo(reader);
            if (version.Engine != EngineType.SecondGeneration && version.Engine != EngineType.ThirdGeneration)
                throw new NotSupportedException("Engine not supported");

            // Load build info
            buildInfo = infoLoader.LoadBuild(version.BuildString);
            if (buildInfo == 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, buildInfo, version.BuildString);

                case EngineType.ThirdGeneration:
                    return new ThirdGenCacheFile(reader, buildInfo, version.BuildString);

                default:
                    throw new NotSupportedException("Engine not supported");
            }
        }
Пример #6
0
        private void Load(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, BuildInformation buildInfo)
        {
            ResourceIndex = new DatumIndex(values.GetInteger("resource datum index"));

            LoadRegions(values, reader, metaArea, buildInfo);
            LoadSections(values, reader, metaArea, buildInfo);
            LoadBoundingBox(values, reader, metaArea, buildInfo);
        }
        private List<ThirdGenLanguage> LoadLanguages(StructureValueCollection values, FileSegmenter segmenter, BuildInformation buildInfo)
        {
            StructureValueCollection[] languageSet = values.GetArray("languages");

            var result = from language in languageSet
                         select new ThirdGenLanguage(language, segmenter, LocaleArea, buildInfo);
            return result.ToList<ThirdGenLanguage>();
        }
Пример #8
0
 /// <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, BuildInformation buildInfo)
 {
     int count = (int)values.GetInteger(_countEntryName);
     uint address = (uint)values.GetInteger(_addressEntryName);
     var layout = buildInfo.GetLayout(_layoutName);
     var entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea);
     return entries.Select(e => ReadScriptObject(e, reader, metaArea, stringIDs, buildInfo)).ToArray();
 }
Пример #9
0
        private void Load(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, BuildInformation 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);
        }
Пример #10
0
 public ThirdGenLanguage(StructureValueCollection values, FileSegmenter segmenter, FileSegmentGroup localeArea, BuildInformation buildInfo)
 {
     _pointerLayout = buildInfo.GetLayout("locale index table entry");
     _encryptionKey = buildInfo.LocaleKey;
     _symbols = buildInfo.LocaleSymbols;
     _localeArea = localeArea;
     _sizeAlign = (_encryptionKey != null) ? AES.BlockSize : 1;
     Load(values, segmenter, localeArea);
 }
Пример #11
0
        /// <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, BuildInformation buildInfo, IModelProcessor processor)
        {
            processor.BeginModel(model);

            ReadVertexBuffers(reader, model, sectionsToRead, buildInfo, processor);
            ReadIndexBuffers(reader, model, sectionsToRead, buildInfo, processor);

            processor.EndModel(model);
        }
Пример #12
0
 /// <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, BuildInformation buildInfo, IStreamManager streamManager, IList<MetaField> fields, uint cacheOffset)
 {
     var valueAs = new ViewValueAs(cacheFile, buildInfo, streamManager, fields, cacheOffset)
                       {
                           Owner = Settings.homeWindow,
                           WindowStartupLocation = WindowStartupLocation.CenterOwner
                       };
     valueAs.Show();
 }
Пример #13
0
        private void LoadSubmeshes(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, BuildInformation buildInfo)
        {
            int count = (int)values.GetInteger("number of submeshes");
            uint address = values.GetInteger("submesh table address");
            var layout = buildInfo.GetLayout("model submesh");
            var entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea);

            Submeshes = (from entry in entries
                         select new ThirdGenModelSubmesh(entry)).ToArray();
        }
Пример #14
0
        private void LoadVertexGroups(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, BuildInformation buildInfo, IModelSubmesh[] submeshes)
        {
            int count = (int)values.GetInteger("number of vertex groups");
            uint address = values.GetInteger("vertex group table address");
            var layout = buildInfo.GetLayout("model vertex group");
            var entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea);

            VertexGroups = (from entry in entries
                            select new ThirdGenModelVertexGroup(entry, submeshes)).ToArray();
        }
        private void LoadSegments(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, BuildInformation buildInfo, ThirdGenResourcePage[] pages)
        {
            int count = (int)values.GetInteger("number of raw segments");
            uint address = values.GetInteger("raw segment table address");
            var layout = buildInfo.GetLayout("raw segment table entry");
            var entries = ReflexiveReader.ReadReflexive(count, address, reader, layout, metaArea);

            Segments = (from entry in entries
                        select new ThirdGenResourceSegment(entry, pages)).ToArray();
        }
        private void LoadFileReferences(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, BuildInformation buildInfo)
        {
            int count = (int)values.GetInteger("number of external cache files");
            uint address = values.GetInteger("external cache file table address");
            var layout = buildInfo.GetLayout("external cache file table entry");
            var entries = ReflexiveReader.ReadReflexive(count, address, reader, layout, metaArea);

            FileReferences = (from entry in entries
                              select new ThirdGenCacheFileReference(entry)).ToArray();
        }
Пример #17
0
        private void LoadPermutations(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, BuildInformation buildInfo)
        {
            int count = (int)values.GetInteger("number of permutations");
            uint address = values.GetInteger("permutation table address");
            var layout = buildInfo.GetLayout("model permutation");
            var entries = ReflexiveReader.ReadReflexive(count, address, reader, layout, metaArea);

            Permutations = (from entry in entries
                            select new ThirdGenModelPermutation(entry)).ToArray();
        }
        public ThirdGenScenarioScriptFile(ITag scenarioTag, string scenarioName, FileSegmentGroup metaArea, StringIDSource stringIDs, BuildInformation buildInfo)
        {
            _tag = scenarioTag;
            _stringIDs = stringIDs;
            _metaArea = metaArea;
            _buildInfo = buildInfo;
            Name = scenarioName.Substring(scenarioName.LastIndexOf('\\') + 1) + ".hsc";

            DefineScriptObjectReflexives();
        }
Пример #19
0
        private void Load(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, StringIDSource stringIDs, BuildInformation 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);
        }
Пример #20
0
        private void LoadResources(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, BuildInformation buildInfo, ThirdGenTagTable tags, ThirdGenResourceLayoutTable layoutInfo)
        {
            int count = (int)values.GetInteger("number of resources");
            uint address = values.GetInteger("resource table address");
            var layout = buildInfo.GetLayout("resource table entry");
            var entries = ReflexiveReader.ReadReflexive(count, address, reader, layout, metaArea);

            _resources = new ThirdGenResource[entries.Length];
            for (ushort i = 0; i < entries.Length; i++)
                _resources[i] = new ThirdGenResource(entries[i], i, tags, layoutInfo);
        }
Пример #21
0
        public MetaInformation(BuildInformation buildInfo, TagEntry tag, ICacheFile cache)
        {
            InitializeComponent();

            lblTagName.Text = tag.TagFileName != null ?
                tag.TagFileName :
                "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());
        }
Пример #22
0
        public MetaReader(IStreamManager streamManager, uint baseOffset, ICacheFile cache, BuildInformation buildInfo, FieldChangeSet ignore)
        {
            _streamManager = streamManager;
            BaseOffset = baseOffset;
            _cache = cache;
            _ignoredFields = ignore;

            // Load layouts
            _reflexiveLayout = buildInfo.GetLayout("reflexive");
            _tagRefLayout = buildInfo.GetLayout("tag reference");
            _dataRefLayout = buildInfo.GetLayout("data reference");
        }
Пример #23
0
        /// <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, BuildInformation 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);
            }
        }
Пример #24
0
        private void Load(IReader reader, StructureValueCollection values, FileSegmentGroup metaArea, StringIDSource stringIDs, ExpressionTable expressions, BuildInformation buildInfo)
        {
            Name = stringIDs.GetString(new StringID((int)values.GetInteger("name index")));
            ExecutionType = (short)values.GetInteger("execution type");
            ReturnType = (short)values.GetInteger("return type");
            DatumIndex rootExpr = new DatumIndex(values.GetInteger("first expression index"));
            if (rootExpr.IsValid)
                RootExpression = expressions.FindExpression(rootExpr);
            if (Name == null)
                Name = "script_" + rootExpr.Value.ToString("X8");

            Parameters = LoadParameters(reader, values, metaArea, buildInfo);
        }
Пример #25
0
        private static List<ITagClass> ReadClasses(IReader reader, uint classTableOffset, int numClasses, BuildInformation buildInfo)
        {
            StructureLayout layout = buildInfo.GetLayout("class entry");

            List<ITagClass> 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;
        }
Пример #26
0
        /// <summary>
        /// Save meta to the Blam Cache File
        /// </summary>
        public MetaWriter(IWriter writer, uint baseOffset, ICacheFile cache, BuildInformation buildInfo, SaveType type, FieldChangeSet changes)
        {
            _writer = writer;
            _baseOffset = baseOffset;
            _cache = cache;
            _type = type;
            _changes = changes;

            // Load layouts
            _reflexiveLayout = buildInfo.GetLayout("reflexive");
            _tagRefLayout = buildInfo.GetLayout("tag reference");
            _dataRefLayout = buildInfo.GetLayout("data reference");
        }
Пример #27
0
        public LocaleEditor(ICacheFile cache, IStreamManager streamManager, int index, BuildInformation buildInfo)
        {
            InitializeComponent();

            _cache = cache;
            _streamManager = streamManager;
            _languageIndex = index;
            _currentLanguage = cache.Languages[index];
            _buildInfo = buildInfo;

            Thread thrd = new Thread(new ThreadStart(LoadLanguage));
            thrd.SetApartmentState(ApartmentState.STA);
            thrd.Start();
        }
Пример #28
0
        private void LoadBoundingBox(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, BuildInformation buildInfo)
        {
            int count = (int)values.GetInteger("number of bounding boxes");
            if (count < 1)
                return;

            uint address = values.GetInteger("bounding box table address");
            var layout = buildInfo.GetLayout("model bounding box");
            var entries = ReflexiveReader.ReadReflexive(reader, 1, address, layout, metaArea);

            // Just take the first bounding box
            // Is it even possible for models to have more than one?
            BoundingBox = new ThirdGenModelBoundingBox(entries.First());
        }
Пример #29
0
        private void Load(IReader reader, StructureValueCollection values, FileSegmentGroup metaArea, BuildInformation buildInfo)
        {
            if (values.GetInteger("magic") != CharConstant.FromString("tags"))
                throw new ArgumentException("Invalid index table header magic");

            // Classes
            int numClasses = (int)values.GetInteger("number of classes");
            SegmentPointer classTableLocation = SegmentPointer.FromPointer(values.GetInteger("class table address"), metaArea);
            _classes = ReadClasses(reader, classTableLocation, numClasses, buildInfo);

            // Tags
            int numTags = (int)values.GetInteger("number of tags");
            SegmentPointer tagTableLocation = SegmentPointer.FromPointer(values.GetInteger("tag table address"), metaArea);
            _tags = ReadTags(reader, tagTableLocation, numTags, buildInfo, metaArea);
        }
Пример #30
0
 /// <summary>
 /// Reads the index buffer for a section in a model.
 /// </summary>
 /// <param name="reader">The stream to read the index buffer from.</param>
 /// <param name="section">The model section that the index buffer belongs to.</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, or null if the index buffer should be skipped over.</param>
 private static void ReadSectionIndices(IReader reader, IModelSection section, int baseIndex, BuildInformation buildInfo, IModelProcessor processor)
 {
     foreach (IModelSubmesh submesh in section.Submeshes)
     {
         if (processor != null)
         {
             ushort[] indices = IndexBufferReader.ReadIndexBuffer(reader, submesh.IndexBufferCount);
             processor.ProcessSubmeshIndices(submesh, indices, baseIndex);
         }
         else
         {
             IndexBufferReader.SkipIndexBuffer(reader, submesh.IndexBufferCount);
         }
     }
     reader.SeekTo((reader.Position + 3) & ~3); // Align 4
 }