/// <summary> /// Reads the vertex buffers for a model from a stream and passes them to an IModelProcessor. /// </summary> /// <param name="reader">The stream to read the vertex 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 ReadVertexBuffers(IReader reader, IRenderModel model, BitArray sectionsToRead, EngineDescription buildInfo, IModelProcessor processor) { for (int i = 0; i < model.Sections.Length; i++) { ReadSectionVertices(reader, model.Sections[i], model.BoundingBoxes[0], buildInfo, sectionsToRead[i] ? processor : null); } }
public SecondGenCacheFile(IReader reader, EngineDescription buildInfo, string buildString) { _endianness = reader.Endianness; _buildInfo = buildInfo; _segmenter = new FileSegmenter(buildInfo.SegmentAlignment); _expander = new SecondGenPointerExpander(); Allocator = new MetaAllocator(this, 0x10000); Load(reader, buildInfo, buildString); }
public ThirdGenHeader(StructureValueCollection values, EngineDescription info, string buildString, FileSegmenter segmenter, IPointerExpander expander) { BuildString = buildString; HeaderSize = info.HeaderSize; cacheSegmentAlignment = info.SegmentAlignment; _expander = expander; Load(values, segmenter); }
public SoundEditor(EngineDescription buildInfo, string cacheLocation, TagEntry tag, ICacheFile cache, IStreamManager streamManager) { InitializeComponent(); _buildInfo = buildInfo; _cacheLocation = cacheLocation; _tag = tag; _cache = cache; _streamManager = streamManager; var viewModel = new ViewModel(); DataContext = viewModel; viewModel.TagName = _tag.TagFileName; viewModel.Sound = _sound; if (!_cache.ResourceMetaLoader.SupportsSounds) { IsEnabled = false; MetroMessageBox.Show("Unsupported", "Assembly doesn't support sounds on this build of Halo yet."); return; } using (var reader = _streamManager.OpenRead()) { _soundResourceGestalt = _cache.LoadSoundResourceGestaltData(reader); _sound = _cache.ResourceMetaLoader.LoadSoundMeta(_tag.RawTag, reader); var resourceTable = _cache.Resources.LoadResourceTable(reader); _soundResource = resourceTable.Resources.First(r => r.Index == _sound.ResourceIndex); _resourcePages = new [] { _soundResource.Location.PrimaryPage, _soundResource.Location.SecondaryPage, _soundResource.Location.TertiaryPage, }; viewModel.ResourcePages = new ObservableCollection <ResourcePage>(_resourcePages.ToList()); } var playback = _soundResourceGestalt.SoundPlaybacks[_sound.PlaybackIndex]; var soundPermutations = new ISoundPermutation[playback.EncodedPermutationCount]; for (var i = 0; i < playback.EncodedPermutationCount; i++) { var permutation = _soundResourceGestalt.SoundPermutations[i + playback.FirstPermutationIndex]; soundPermutations[i] = permutation; viewModel.Permutations.Add(new ViewModel.ViewPermutation { Name = _cache.StringIDs.GetString(permutation.SoundName), Index = i, SoundPermutation = permutation }); } }
/// <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()); }
/// <summary> /// Initializes a new instance of the <see cref="SoundResourceManager" /> class. /// </summary> /// <param name="gestalt">The cache file's sound 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 SoundResourceManager(SoundResourceGestalt gestalt, TagTable tags, FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo, IPointerExpander expander) { _gestalt = gestalt; _tags = tags; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; _expander = expander; }
protected void GetLayoutConstants(EngineDescription engineInfo) { MapHeaderSize = engineInfo.HeaderSize; var layout = engineInfo.Layouts.GetLayout("header"); MapTypeOffset = layout.GetFieldOffset("type"); MapNameOffset = layout.GetFieldOffset("internal name"); ScenarioNameOffset = layout.GetFieldOffset("scenario name"); }
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()); }
public NewThirdGenTagTable(IReader reader, SegmentPointer indexHeaderLocation, FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo) { _indexHeaderLocation = indexHeaderLocation; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; Load(reader); }
public ThirdGenCacheFile(IReader reader, EngineDescription buildInfo, string filePath) { FilePath = filePath; _endianness = reader.Endianness; _buildInfo = buildInfo; _segmenter = new FileSegmenter(buildInfo.SegmentAlignment); _expander = new ThirdGenPointerExpander(buildInfo.ExpandMagic); Allocator = new MetaAllocator(this, 0x10000); Load(reader); }
/// <summary> /// Initializes a new instance of the <see cref="FourthGenResourceManager" /> 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 FourthGenResourceManager(FourthGenResourceGestalt gestalt, FourthGenResourceLayoutTable layoutTable, TagTable tags, FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo) { _gestalt = gestalt; _layoutTable = layoutTable; _tags = tags; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; }
private List <SecondGenLanguage> LoadLanguages(StructureValueCollection values, FileSegmenter segmenter, EngineDescription buildInfo) { StructureValueCollection[] languageSet = values.GetArray("languages"); IEnumerable <SecondGenLanguage> result = languageSet.Select((l, i) => new SecondGenLanguage(LanguageRemaps.Keys.ElementAt(i), l, segmenter, LocaleArea, buildInfo)); return(result.ToList()); }
public ThirdGenZoneSetTable(ThirdGenResourceGestalt gestalt, IReader reader, FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo, IPointerExpander expander) { _gestalt = gestalt; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; _expander = expander; Load(reader); }
public ThirdGenLanguage(GameLanguage language, StructureValueCollection values, FileSegmenter segmenter, FileSegmentGroup localeArea, EngineDescription buildInfo) { Language = language; _pointerLayout = buildInfo.Layouts.GetLayout("locale index table element"); _encryptionKey = buildInfo.LocaleKey; _hashes = buildInfo.UsesStringHashes; _sizeAlign = (_encryptionKey != null) ? AES.BlockSize : 1; Load(values, segmenter, localeArea); }
/// <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 SecondGenTagTable(IReader reader, FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo) { _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; _metaHeaderLayout = _buildInfo.Layouts.GetLayout("meta header"); Load(reader); }
private IList <ScriptParameter> LoadParameters(IReader reader, StructureValueCollection values, FileSegmentGroup metaArea, EngineDescription buildInfo) { var count = (int)values.GetInteger("number of parameters"); uint address = values.GetInteger("address of parameter list"); StructureLayout layout = buildInfo.Layouts.GetLayout("script parameter entry"); StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea); return(entries.Select(e => new ScriptParameter(e)).ToList()); }
public FourthGenResourceGestalt(IReader reader, ITag zoneTag, FileSegmentGroup metaArea, MetaAllocator allocator, StringIDSource stringIDs, EngineDescription buildInfo) { _tag = zoneTag; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; Load(reader, stringIDs); }
public SecondGenSimulationDefinitionTable(ITag scenario, TagTable tags, IReader reader, FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo) { _scenario = scenario; _tags = tags; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; Load(reader); }
public ScriptEditor(EngineDescription buildInfo, IScriptFile scriptFile, IStreamManager streamManager, ICacheFile casheFile, Endian endian) { _endian = endian; _buildInfo = buildInfo; _opcodes = _buildInfo.ScriptInfo; _scriptFile = scriptFile; _streamManager = streamManager; _cashefile = casheFile; // If a game contains hsdt tags, it uses a newer Blam Script syntax. Currently the compiler only supports the old syntax. _hasNewSyntax = _buildInfo.Layouts.HasLayout("hsdt"); InitializeComponent(); // Disable user input. Enable it again when all background tasks have been completed. txtScript.IsReadOnly = true; // Enable code completion only if the compiler supports this game. if (!_hasNewSyntax) { txtScript.TextArea.GotFocus += EditorGotFocus; txtScript.TextArea.LostFocus += EditorLostFocus; txtScript.TextArea.TextEntering += EditorTextEntering; txtScript.TextArea.TextEntered += EditorTextEntered; txtScript.TextArea.Document.Changed += EditorTextChanged; } App.AssemblyStorage.AssemblySettings.PropertyChanged += Settings_SettingsChanged; SetHighlightColor(); SearchPanel srch = SearchPanel.Install(txtScript); var bconv = new System.Windows.Media.BrushConverter(); var srchbrsh = (System.Windows.Media.Brush)bconv.ConvertFromString("#40F0F0F0"); srch.MarkerBrush = srchbrsh; txtScript.SyntaxHighlighting = LoadSyntaxHighlighting(); // With syntax highlighting and HTML formatting, copying text takes ages. Disable the HTML formatting for copied text. DataObject.AddSettingDataHandler(txtScript, onTextViewSettingDataHandler); _progress = new Progress <int>(i => { progressBar.Value = i; }); itemShowInformation.IsChecked = App.AssemblyStorage.AssemblySettings.ShowScriptInfo; itemDebugData.IsChecked = App.AssemblyStorage.AssemblySettings.OutputCompilerDebugData; // Enable compilation only for supported games. if (_buildInfo.Name.Contains("Reach") || _buildInfo.Name.Contains("Halo 3") && _buildInfo.HeaderSize != 0x800 && !_buildInfo.Name.Contains("ODST")) { compileButton.Visibility = Visibility.Visible; progressReporter.Visibility = Visibility.Visible; } }
/// <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 ThirdGenResourceLayoutTable(ITag playTag, FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo, IPointerExpander expander) { _tag = playTag; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; _expander = expander; _zone = _tag.Group.Magic != 1886151033; //"play" }
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); }
private void Load(IReader reader, EngineDescription buildInfo, string buildString) { _header = LoadHeader(reader, buildInfo, buildString); _tags = LoadTagTable(reader, buildInfo); _fileNames = LoadFileNames(reader, buildInfo); _stringIDs = LoadStringIDs(reader, buildInfo); LoadLanguageGlobals(reader); LoadScriptFiles(); LoadSimulationDefinitions(reader); }
public ThirdGenResourceGestalt(IReader reader, ITag zoneTag, FileSegmentGroup metaArea, MetaAllocator allocator, StringIDSource stringIDs, EngineDescription buildInfo, IPointerExpander expander) { _tag = zoneTag; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; _expander = expander; Load(reader, stringIDs); }
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(); }
public ThirdGenSimulationDefinitionTable(ITag scenario, TagTable tags, IReader reader, FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo, IPointerExpander expander) { _scenario = scenario; _tags = tags; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; _expander = expander; Load(reader); }
private KeyValuePair <ICacheFile, EngineDescription> LoadMap(string path, out IReader reader) { reader = new EndianReader(File.OpenRead(path), Endian.BigEndian); var versionInfo = new CacheFileVersionInfo(reader); EngineDescription buildInfo = App.AssemblyStorage.AssemblySettings.DefaultDatabase.FindEngineByVersion(versionInfo.BuildString); return (new KeyValuePair <ICacheFile, EngineDescription>(new ThirdGenCacheFile(reader, buildInfo, versionInfo.BuildString), buildInfo)); }
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> /// Loads an engine database from an XML container. /// </summary> /// <param name="container">The container to read engine elements from.</param> /// <returns>The built engine database.</returns> public static EngineDatabase LoadDatabase(XContainer container) { XMLSettingsGroupLoader loader = CreateSettingsGroupLoader(); var result = new EngineDatabase(); foreach (XElement elem in container.Elements("engine")) { string name = XMLUtil.GetStringAttribute(elem, "name"); string version = XMLUtil.GetStringAttribute(elem, "version"); string inherits = XMLUtil.GetStringAttribute(elem, "inherits", null); SettingsGroup settings = loader.LoadSettingsGroup(elem); if (!string.IsNullOrWhiteSpace(inherits)) { // Clone the base engine's settings and then import the new settings on top of it SettingsGroup baseSettings = result.FindEngineByName(inherits).Settings.DeepClone(); baseSettings.Import(settings); settings = baseSettings; } var desc = new EngineDescription(name, version, settings); result.RegisterEngine(desc); } return result; }