/// <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 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; }
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; }
public MetaReader(IStreamManager streamManager, uint baseOffset, ICacheFile cache, FieldChangeSet ignore) { _streamManager = streamManager; _baseOffset = baseOffset; _cache = cache; _ignoredFields = ignore; }
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; }
public BspEditor(TagEntry tag, ICacheFile cache, IStreamManager streamManager) { InitializeComponent(); _tag = tag; _cache = cache; _streamManager = streamManager; }
/// <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); } }
/// <summary> /// Save meta to the Blam Cache File /// </summary> public MetaWriter(IWriter writer, uint baseOffset, ICacheFile cache, SaveType type, FieldChangeSet changes) { _writer = writer; _baseOffset = baseOffset; _cache = cache; _type = type; _changes = changes; }
/// <summary> /// Obtains a stream which can be used to read and write a cache file's meta in realtime. /// The stream will be set up such that offsets in the stream correspond to meta pointers in the cache file. /// </summary> /// <param name="cacheFile">The cache file to get a stream for.</param> /// <returns>The stream if it was opened successfully, or null otherwise.</returns> public IStream GetMetaStream(ICacheFile cacheFile) { // Okay, so technically we should be checking to see if the cache file is actually loaded into memory first // But that's kinda hard to do... if (_xbdm.Connect()) return new EndianStream(_xbdm.MemoryStream, Endian.BigEndian); return null; }
/// <summary> /// Builds a Patch by comparing two cache files. /// </summary> /// <param name="originalFile">The original cache file.</param> /// <param name="originalReader">The stream to use to read from the original cache file.</param> /// <param name="newFile">The modified cache file.</param> /// <param name="newReader">The stream to use to read from the modified cache file.</param> /// <param name="output">The Patch to store differences to.</param> public static void BuildPatch(ICacheFile originalFile, IReader originalReader, ICacheFile newFile, IReader newReader, Patch output) { output.MapInternalName = originalFile.InternalName; output.MetaPokeBase = newFile.MetaArea.BasePointer; var segmentChanges = SegmentComparer.CompareSegments(originalFile.Segments, originalReader, newFile.Segments, newReader); output.SegmentChanges.AddRange(segmentChanges); output.MetaChangesIndex = FindMetaChanges(segmentChanges, newFile); }
/// <summary> /// Scans a list of segment changes to find the index of the change data related to a cache file's meta area. /// </summary> /// <param name="segmentChanges">The list of segment changes to scan.</param> /// <param name="newFile">The modified cache file.</param> /// <returns>The index of the meta change data in <paramref name="segmentChanges"/>, or -1 if not found.</returns> private static int FindMetaChanges(IList<SegmentChange> segmentChanges, ICacheFile newFile) { for (int i = 0; i < segmentChanges.Count; i++) { if (segmentChanges[i].NewOffset == newFile.MetaArea.Offset) return i; } return -1; }
/// <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="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, IStreamManager streamManager, IList<MetaField> fields, uint cacheOffset) { var valueAs = new ViewValueAs(cacheFile, streamManager, fields, cacheOffset) { Owner = Settings.homeWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner }; valueAs.Show(); }
/// <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 ScriptEditor(ICacheFile cache, string scriptDefsFile) { _cache = cache; _scriptDefsFile = scriptDefsFile; InitializeComponent(); Thread thrd = new Thread(new ThreadStart(DecompileScripts)); thrd.SetApartmentState(ApartmentState.STA); thrd.Start(); }
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"); }
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()); }
public static int? Show(ICacheFile cache, ReflexiveData data) { App.AssemblyStorage.AssemblySettings.HomeWindow.ShowMask(); var dialog = new TagBlockReallocator(data) { Owner = App.AssemblyStorage.AssemblySettings.HomeWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner }; dialog.ShowDialog(); App.AssemblyStorage.AssemblySettings.HomeWindow.HideMask(); return dialog.NewCount; }
/// <summary> /// Writes changes to a language in a cache file. /// Note that ICacheFile.SaveChanges() may need to be called after this. /// </summary> /// <param name="changes">The changes to make to the language.</param> /// <param name="cacheFile">The cache file to write changes to.</param> /// <param name="stream">The stream to write changes to.</param> public static void WriteLanguageChange(LanguageChange changes, ICacheFile cacheFile, IStream stream) { if (changes.LanguageIndex >= cacheFile.Languages.Count) throw new ArgumentException("Language changes cannot be applied to undefined languages in a cache file"); // Load the language table and apply the changes var language = cacheFile.Languages[changes.LanguageIndex]; var table = language.LoadStrings(stream); MakeLocaleChanges(changes.LocaleChanges, table); // Write the table back to the file language.SaveStrings(stream, table); }
/// <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>(); }
/// <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"); }
/// <summary> /// Compares the tag meta between two cache files and adds the results to a patch. /// </summary> /// <param name="originalFile">The unmodified cache file.</param> /// <param name="originalReader">A stream open on the unmodified cache file.</param> /// <param name="newFile">The modified cache file.</param> /// <param name="newReader">A stream open on the modified cache file.</param> /// <param name="output">The Patch to add results to.</param> public static void CompareMeta(ICacheFile originalFile, IReader originalReader, ICacheFile newFile, IReader newReader, Patch output) { // TODO: Handle files with expanded meta partitions uint address = originalFile.Info.MetaBase.AsAddress(); uint offset = originalFile.Info.MetaBase.AsOffset(); uint endOffset = offset + originalFile.Info.MetaSize; const int BufferSize = 0x1000; byte[] oldBuffer = new byte[BufferSize]; byte[] newBuffer = new byte[BufferSize]; int diffStart = 0; uint diffAddress = 0; int diffSize = 0; originalReader.SeekTo(offset); newReader.SeekTo(offset); while (offset < endOffset) { // Read the meta in large blocks and then compare the blocks originalReader.ReadBlock(oldBuffer, 0, BufferSize); newReader.ReadBlock(newBuffer, 0, BufferSize); for (int i = 0; i < oldBuffer.Length; i++) { if (oldBuffer[i] != newBuffer[i]) { if (diffSize == 0) { diffStart = i; diffAddress = (uint)(address + i); } diffSize++; } else if (diffSize > 0) { // Copy the differing bytes to a buffer byte[] diff = new byte[diffSize]; Array.Copy(newBuffer, diffStart, diff, 0, diffSize); // Export the change data MetaChange change = new MetaChange((uint)(address + i), diff); output.MetaChanges.Add(change); diffSize = 0; } } offset += BufferSize; address += BufferSize; } }
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 _tagBlockLayout = buildInfo.Layouts.GetLayout("tag block"); _tagRefLayout = buildInfo.Layouts.GetLayout("tag reference"); _dataRefLayout = buildInfo.Layouts.GetLayout("data reference"); }
/// <summary> /// Initializes a new instance of the <see cref="DataBlockBuilder" /> class. /// </summary> /// <param name="reader">The stream to read from.</param> /// <param name="tag">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, ITag tag, ICacheFile cacheFile, EngineDescription buildInfo) { _reader = reader; _tag = tag; _cacheFile = cacheFile; _languageCache = new CachedLanguagePackLoader(_cacheFile.Languages); _tagRefLayout = buildInfo.Layouts.GetLayout("tag reference"); _tagBlockLayout = buildInfo.Layouts.GetLayout("tag block"); _dataRefLayout = buildInfo.Layouts.GetLayout("data reference"); DataBlocks = new List<DataBlock>(); ReferencedTags = new HashSet<DatumIndex>(); ReferencedResources = new HashSet<DatumIndex>(); }
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(); }
public ThirdGenShaderStreamer(ICacheFile cacheFile, EngineDescription desc) { _cacheFile = cacheFile; if (desc.Layouts.HasLayout("pixel shader info")) _pixelShaderInfoLayout = desc.Layouts.GetLayout("pixel shader info"); if (desc.Layouts.HasLayout("vertex shader info")) _vertexShaderInfoLayout = desc.Layouts.GetLayout("vertex shader info"); if (desc.Layouts.HasLayout("shader debug info")) _debugInfoLayout = desc.Layouts.GetLayout("shader debug info"); if (desc.Layouts.HasLayout("updb pointer")) _updbPointerLayout = desc.Layouts.GetLayout("updb pointer"); if (desc.Layouts.HasLayout("code info")) _codeInfoLayout = desc.Layouts.GetLayout("code info"); }
/// <summary> /// Save meta to the Blam Cache File /// </summary> public MetaWriter(IWriter writer, uint baseOffset, ICacheFile cache, EngineDescription buildInfo, SaveType type, FieldChangeSet changes, Trie stringIdTrie) { _writer = writer; _baseOffset = baseOffset; _cache = cache; _type = type; _changes = changes; _stringIdTrie = stringIdTrie; // Load layouts _reflexiveLayout = buildInfo.Layouts.GetLayout("reflexive"); _tagRefLayout = buildInfo.Layouts.GetLayout("tag reference"); _dataRefLayout = buildInfo.Layouts.GetLayout("data reference"); }
/// <summary> /// Compares the locale data of two cache files and adds the results to a patch. /// </summary> /// <param name="originalFile">The unmodified cache file.</param> /// <param name="originalReader">A stream open on the unmodified cache file.</param> /// <param name="newFile">The modified cache file.</param> /// <param name="newReader">A stream open on the modified cache file.</param> /// <param name="output">The Patch to add results to.</param> public static void CompareLocales(ICacheFile originalFile, IReader originalReader, ICacheFile newFile, IReader newReader, Patch output) { if (originalFile.Languages.Count != newFile.Languages.Count) throw new InvalidOperationException("Cannot compare locales between cache files with different language counts."); // Compare each language for (int i = 0; i < originalFile.Languages.Count; i++) { // Compare the strings in the two language LanguageChange change = CompareLanguages((byte)i, originalFile.Languages[i], originalReader, newFile.Languages[i], newReader); // Only add the info if anything actually changed between the two languages if (change.LocaleChanges.Count > 0) output.LanguageChanges.Add(change); } }
/// <summary> /// Applies a patch to a cache file. /// </summary> /// <param name="patch">The patch to apply.</param> /// <param name="cacheFile">The cache file to apply the patch to. After the patch is applied, it may have to be reloaded.</param> /// <param name="stream">The stream to write changes to.</param> public static void ApplyPatch(Patch patch, ICacheFile cacheFile, IStream stream) { if (patch.MapInternalName != cacheFile.InternalName) throw new ArgumentException("The patch is for a different cache file. Expected \"" + patch.MapInternalName + "\" but got \"" + cacheFile.InternalName + "\"."); SegmentPatcher.PatchSegments(patch.SegmentChanges, stream); #region Deprecated DataPatcher.PatchData(patch.MetaChanges, (uint)-cacheFile.MetaArea.PointerMask, stream); if (patch.LanguageChanges.Count > 0) { LocalePatcher.WriteLanguageChanges(patch.LanguageChanges, cacheFile, stream); cacheFile.SaveChanges(stream); } #endregion }
public LocaleEditor(GameLanguage language, ICacheFile cache, IStreamManager streamManager, Trie stringIdTrie, LocaleSymbolCollection symbols) { InitializeComponent(); _currentLanguage = language; _cache = cache; _streamManager = streamManager; _symbols = symbols; StringIDTrie = stringIdTrie; // Thread the loading routine var thrd = new Thread(LoadAll); thrd.SetApartmentState(ApartmentState.STA); thrd.Start(); }
static void DetectAlignment(ICacheFile cacheFile, IReader reader, int baseOffset, XElement baseElement, Dictionary<XElement, int> alignsByElem, HashSet<uint> visitedTagBlocks) { // Loop through all tag blocks and data references foreach (var elem in baseElement.Elements()) { var isTagBlock = (elem.Name.LocalName == "reflexive"); var isDataRef = (elem.Name.LocalName == "dataRef"); if (!isTagBlock && !isDataRef) continue; // Read the address var offset = ParseInteger(elem.Attribute("offset").Value); var count = 0; var entrySize = 0; if (isTagBlock) { reader.SeekTo(baseOffset + offset); count = reader.ReadInt32(); entrySize = ParseInteger(elem.Attribute("entrySize").Value); } else { reader.SeekTo(baseOffset + offset + 0xC); } var addr = reader.ReadUInt32(); if (addr == 0) continue; if (isTagBlock && !cacheFile.MetaArea.ContainsBlockPointer(addr, count * entrySize)) continue; // Only update the alignment if it's less than the currently-guessed alignment int oldAlign; var newAlign = GetAlignment(addr); if (!alignsByElem.TryGetValue(elem, out oldAlign) || newAlign < oldAlign) alignsByElem[elem] = newAlign; // If it's a tag block, then recurse into it if (isTagBlock && !visitedTagBlocks.Contains(addr)) { visitedTagBlocks.Add(addr); var blockBaseOffset = cacheFile.MetaArea.PointerToOffset(addr); for (var i = 0; i < count; i++) DetectAlignment(cacheFile, reader, blockBaseOffset + i * entrySize, elem, alignsByElem, visitedTagBlocks); } } }
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 }; 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 }); } }
public MetaContainer(EngineDescription 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)App.AssemblyStorage.AssemblySettings.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; // Create Raw Tabs #region Models //if (_cache.ResourceMetaLoader.SupportsRenderModels && _tag.RawTag.Class.Magic == CharConstant.FromString("mode")) //{ // tabSound.Visibility = Visibility.Visible; // tabSound.Content = new SoundEditor(_tag, _cache, _streamManager); //} //else //{ // tabSound.Visibility = Visibility.Collapsed; // if (App.AssemblyStorage.AssemblySettings.halomapLastSelectedMetaEditor == App.AssemblyStorage.AssemblySettings.LastMetaEditorType.Model) // tbMetaEditors.SelectedIndex = (int)App.AssemblyStorage.AssemblySettings.LastMetaEditorType.MetaEditor; //} #endregion #region BSP /*if (true && _tag.RawTag.Class.Magic == CharConstant.FromString("sbsp")) // add some manual check here akarias, since you code isn't in blamite * { * tabBspEditor.Visibility = Visibility.Visible; * tabBspEditor.Content = new BspEditor(_tag, _cache, _streamManager); * } * else*/ { tabBspEditor.Visibility = Visibility.Collapsed; if (App.AssemblyStorage.AssemblySettings.HalomapLastSelectedMetaEditor == Settings.LastMetaEditorType.Bsp) { tbMetaEditors.SelectedIndex = (int)Settings.LastMetaEditorType.MetaEditor; } } #endregion #region Sound //if (_cache.ResourceMetaLoader.SupportsSounds && _tag.RawTag.Class.Magic == CharConstant.FromString("snd!")) //{ // tabSound.Visibility = Visibility.Visible; // tabSound.Content = new SoundEditor(_tag, _cache, _streamManager); //} //else //{ // tabSound.Visibility = Visibility.Collapsed; // if (App.AssemblyStorage.AssemblySettings.halomapLastSelectedMetaEditor == App.AssemblyStorage.AssemblySettings.LastMetaEditorType.Sound) // tbMetaEditors.SelectedIndex = (int)App.AssemblyStorage.AssemblySettings.LastMetaEditorType.MetaEditor; //} #endregion }
public MetaAllocator(ICacheFile cacheFile, int pageSize) { _cacheFile = cacheFile; _pageSize = pageSize; }
public SoundEditor(EngineDescription buildInfo, string cacheLocation, TagEntry tag, ICacheFile cache, IStreamManager streamManager) { InitializeComponent(); /* * This was been fixed up to support the changes that came from sound injection, but has not really been tested * but it still isn't great/complete and was mainly only done so I didn't leave in a control where most of its code has been commented out and broken * not to mention this is all moot with MCC using external proprietary files for sounds * if i had to complete it, id probably add extra methods to SoundResourceTable and SoundGestalt to grab pitch ranges on demand instead of loading in everything every time * -Zedd */ _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()) { // load gestalt if (_cache.SoundGestalt != null) { _soundResourceTable = _cache.SoundGestalt.LoadSoundResourceTable(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()); } for (int i = 0; i < _sound.PitchRangeCount; i++) { var pitchrange = _soundResourceTable.PitchRanges[_sound.FirstPitchRangeIndex + i]; foreach (var permutation in pitchrange.Permutations) { viewModel.Permutations.Add(new ViewModel.ViewPermutation { Name = _cache.StringIDs.GetString(permutation.Name), Index = i, SoundPermutation = permutation }); } } }
/// <summary> /// Obtains a stream which can be used to read and write a cache file's meta in realtime. /// The stream will be set up such that offsets in the stream correspond to meta pointers in the cache file. /// </summary> /// <param name="cacheFile">The cache file to get a stream for.</param> /// <returns>The stream if it was opened successfully, or null otherwise.</returns> public IStream GetMetaStream(ICacheFile cacheFile = null) { if (string.IsNullOrEmpty(_buildInfo.GameExecutable)) { throw new InvalidOperationException("No gameExecutable value found in Engines.xml for engine " + _buildInfo.Name + "."); } if (string.IsNullOrEmpty(_buildInfo.GameModule)) { throw new InvalidOperationException("No gameModule value found in Engines.xml for engine " + _buildInfo.Name + "."); } if (_buildInfo.Poking == null) { throw new InvalidOperationException("No poking definitions found in Engines.xml for engine " + _buildInfo.Name + "."); } Process gameProcess = FindGameProcess(); if (gameProcess == null) { return(null); } #if X86 throw new InvalidOperationException("Cannot access a 64bit process with a 32bit program."); #else //verify version, and check for anticheat at the same time string version = ""; long pointer = -1; try { version = gameProcess.MainModule.FileVersionInfo.FileVersion; //TODO: make winstore support not horrible if (version == null) { pointer = _buildInfo.Poking.RetrieveLastPointer(); } else { pointer = _buildInfo.Poking.RetrievePointer(version); } if (pointer == 0) { throw new InvalidOperationException("Game version " + version + " does not have a pointer defined in the Formats folder."); } } catch (System.ComponentModel.Win32Exception) { throw new InvalidOperationException("Cannot access game process. This could be due to Anti-Cheat or lack of admin privileges."); } var gameMemory = new ProcessModuleMemoryStream(gameProcess, _buildInfo.GameModule); if (gameMemory.BaseModule == null) { return(null); } long metaMagic = 0; using (EndianReader er = new EndianReader(gameMemory, BitConverter.IsLittleEndian ? Endian.LittleEndian : Endian.BigEndian)) { er.SeekTo(gameMemory.BaseModuleAddress + pointer); long point = er.ReadInt64(); if (point == 0) { return(null); } er.SeekTo(point + 0x10); if (er.ReadUInt32() != MapHeaderMagic) { return(null); } er.SeekTo(point + MemMagicOffset); metaMagic = er.ReadInt64(); } if (metaMagic == 0) { return(null); } var metaStream = new OffsetStream(gameMemory, metaMagic); return(new EndianStream(metaStream, BitConverter.IsLittleEndian ? Endian.LittleEndian : Endian.BigEndian)); #endif }
public static IEnumerable <GeometryMesh> GetMeshes(ICacheFile cache, ResourceIdentifier resourcePointer, IEnumerable <SectionBlock> sections, Action <SectionBlock, GeometryMesh> setProps, Func <int, int, int> mapNode = null) { VertexBufferInfo[] vertexBufferInfo; IndexBufferInfo[] indexBufferInfo; var resourceGestalt = cache.TagIndex.GetGlobalTag("zone").ReadMetadata <cache_file_resource_gestalt>(); var entry = resourceGestalt.ResourceEntries[resourcePointer.ResourceIndex]; using (var cacheReader = cache.CreateReader(cache.DefaultAddressTranslator)) using (var reader = cacheReader.CreateVirtualReader(resourceGestalt.FixupDataPointer.Address)) { var fixupOffset = entry.FixupOffsets.FirstOrDefault(); reader.Seek(fixupOffset + (entry.FixupSize - 24), SeekOrigin.Begin); var vertexBufferCount = reader.ReadInt32(); reader.Seek(8, SeekOrigin.Current); var indexBufferCount = reader.ReadInt32(); reader.Seek(fixupOffset, SeekOrigin.Begin); vertexBufferInfo = reader.ReadEnumerable <VertexBufferInfo>(vertexBufferCount).ToArray(); reader.Seek(12 * vertexBufferCount, SeekOrigin.Current); //12 byte struct here for each vertex buffer indexBufferInfo = reader.ReadEnumerable <IndexBufferInfo>(indexBufferCount).ToArray(); //12 byte struct here for each index buffer //4x 12 byte structs here } using (var ms = new MemoryStream(resourcePointer.ReadData(PageType.Auto))) using (var reader = new EndianReader(ms, cache.ByteOrder)) { var doc = new XmlDocument(); doc.LoadXml(cache.Metadata.IsMcc ? Resources.MccHalo4VertexBuffer : Resources.Halo4VertexBuffer); var lookup = doc.DocumentElement.ChildNodes.Cast <XmlNode>() .ToDictionary(n => Convert.ToInt32(n.Attributes[XmlVertexField.Type].Value, 16)); var sectionIndex = -1; foreach (var section in sections) { sectionIndex++; if (section.VertexBufferIndex < 0 || section.IndexBufferIndex < 0) { yield return(new GeometryMesh()); continue; } var node = lookup[section.VertexFormat]; var vInfo = vertexBufferInfo[section.VertexBufferIndex]; var iInfo = indexBufferInfo[section.IndexBufferIndex]; Func <XmlNode, string, bool> hasUsage = (n, u) => { return(n.ChildNodes.Cast <XmlNode>().Any(c => c.Attributes?[XmlVertexField.Usage]?.Value == u)); }; var skinType = VertexWeights.None; if (hasUsage(node, XmlVertexUsage.BlendIndices)) { skinType = hasUsage(node, XmlVertexUsage.BlendWeight) ? VertexWeights.Skinned : VertexWeights.Rigid; } else if (section.NodeIndex < byte.MaxValue) { skinType = VertexWeights.Rigid; } var mesh = new GeometryMesh { IndexFormat = iInfo.IndexFormat, Vertices = new IVertex[vInfo.VertexCount], VertexWeights = skinType, NodeIndex = section.NodeIndex == byte.MaxValue ? (byte?)null : section.NodeIndex }; setProps(section, mesh); mesh.Submeshes.AddRange( section.Submeshes.Select(s => new GeometrySubmesh { MaterialIndex = s.ShaderIndex, IndexStart = s.IndexStart, IndexLength = s.IndexLength }) ); var address = entry.ResourceFixups[section.VertexBufferIndex].Offset & 0x0FFFFFFF; reader.Seek(address, SeekOrigin.Begin); for (int i = 0; i < vInfo.VertexCount; i++) { var vert = new XmlVertex(reader, node); mesh.Vertices[i] = vert; } if (mapNode != null && (skinType == VertexWeights.Skinned || skinType == VertexWeights.Rigid)) { foreach (var v in mesh.Vertices) { foreach (var bi in v.BlendIndices) { bi.X = mapNode(sectionIndex, (int)bi.X); bi.Y = mapNode(sectionIndex, (int)bi.Y); bi.Z = mapNode(sectionIndex, (int)bi.Z); bi.W = mapNode(sectionIndex, (int)bi.W); } } } var totalIndices = section.Submeshes.Sum(s => s.IndexLength); address = entry.ResourceFixups[vertexBufferInfo.Length * 2 + section.IndexBufferIndex].Offset & 0x0FFFFFFF; reader.Seek(address, SeekOrigin.Begin); if (vInfo.VertexCount > ushort.MaxValue) { mesh.Indicies = reader.ReadEnumerable <int>(totalIndices).ToArray(); } else { mesh.Indicies = reader.ReadEnumerable <ushort>(totalIndices).Select(i => (int)i).ToArray(); } yield return(mesh); } } }
public TagBlock(DependencyReader reader, ICacheFile cache, IAddressTranslator translator) : this(reader, cache, translator, null) { }
public AddressTools(ICacheFile cache) { InitializeComponent(); _cache = cache; }
public bitmap(ICacheFile cache, IIndexItem item) { this.cache = cache; this.item = item; }
// Patch Creation private void btnCreatePatch_Click(object sender, RoutedEventArgs e) { try { // Check the user isn't completly retarded if (!CheckAllCreateMandatoryFields()) { return; } // Check the user isn't a skid if (!CheckAllCreateMetaFilesExists()) { return; } // Paths string cleanMapPath = txtCreatePatchUnModifiedMap.Text; string moddedMapPath = txtCreatePatchModifiedMap.Text; string outputPath = txtCreatePatchOutputPatch.Text; string previewImage = txtCreatePatchPreviewImage.Text; // Details string author = txtCreatePatchContentAuthor.Text; string desc = txtCreatePatchContentDescription.Text; string name = txtCreatePatchContentName.Text; string outputName = txtCreatePatchOutputName.Text; // Make dat patch var patch = new Patch { Author = author, Description = desc, Name = name, OutputName = outputName, Screenshot = String.IsNullOrEmpty(previewImage) ? null : File.ReadAllBytes(previewImage) }; EndianReader originalReader = null; EndianReader newReader = null; try { originalReader = new EndianReader(File.OpenRead(cleanMapPath), Endian.BigEndian); newReader = new EndianReader(File.OpenRead(moddedMapPath), Endian.BigEndian); ICacheFile originalFile = CacheFileLoader.LoadCacheFile(originalReader, App.AssemblyStorage.AssemblySettings.DefaultDatabase); ICacheFile newFile = CacheFileLoader.LoadCacheFile(newReader, App.AssemblyStorage.AssemblySettings.DefaultDatabase); if (cbCreatePatchHasCustomMeta.IsChecked != null && (bool)cbCreatePatchHasCustomMeta.IsChecked && cboxCreatePatchTargetGame.SelectedIndex < 4) { var targetGame = (TargetGame)cboxCreatePatchTargetGame.SelectedIndex; byte[] mapInfo = File.ReadAllBytes(txtCreatePatchMapInfo.Text); var mapInfoFileInfo = new FileInfo(txtCreatePatchMapInfo.Text); FileInfo blfFileInfo; patch.CustomBlfContent = new BlfContent(mapInfoFileInfo.FullName, mapInfo, targetGame); #region Blf Data if (PatchCreationBlfOption0.Visibility == Visibility.Visible) { blfFileInfo = new FileInfo(txtCreatePatchblf0.Text); patch.CustomBlfContent.BlfContainerEntries.Add(new BlfContainerEntry(blfFileInfo.Name, File.ReadAllBytes(blfFileInfo.FullName))); } if (PatchCreationBlfOption1.Visibility == Visibility.Visible) { blfFileInfo = new FileInfo(txtCreatePatchblf1.Text); patch.CustomBlfContent.BlfContainerEntries.Add(new BlfContainerEntry(blfFileInfo.Name, File.ReadAllBytes(blfFileInfo.FullName))); } if (PatchCreationBlfOption2.Visibility == Visibility.Visible) { blfFileInfo = new FileInfo(txtCreatePatchblf2.Text); patch.CustomBlfContent.BlfContainerEntries.Add(new BlfContainerEntry(blfFileInfo.Name, File.ReadAllBytes(blfFileInfo.FullName))); } if (PatchCreationBlfOption3.Visibility == Visibility.Visible) { blfFileInfo = new FileInfo(txtCreatePatchblf3.Text); patch.CustomBlfContent.BlfContainerEntries.Add(new BlfContainerEntry(blfFileInfo.Name, File.ReadAllBytes(blfFileInfo.FullName))); } #endregion } PatchBuilder.BuildPatch(originalFile, originalReader, newFile, newReader, patch); } finally { if (originalReader != null) { originalReader.Close(); } if (newReader != null) { newReader.Close(); } } IWriter output = new EndianWriter(File.Open(outputPath, FileMode.Create, FileAccess.Write), Endian.BigEndian); AssemblyPatchWriter.WritePatch(patch, output); output.Close(); MetroMessageBox.Show("Patch Created!", "Your patch has been created in the designated location. Happy sailing, modder!"); } catch (Exception ex) { MetroException.Show(ex); } }
/// <summary> /// Obtains a stream which can be used to read and write a cache file's meta in realtime. /// The stream will be set up such that offsets in the stream correspond to meta pointers in the cache file. /// </summary> /// <param name="cacheFile">The cache file to get a stream for.</param> /// <returns>The stream if it was opened successfully, or null otherwise.</returns> public IStream GetMetaStream(ICacheFile cacheFile) { if (string.IsNullOrEmpty(_buildInfo.GameExecutable)) { throw new InvalidOperationException("No gameExecutable value found in Engines.xml for engine " + _buildInfo.Name + "."); } if (_buildInfo.Poking == null) { throw new InvalidOperationException("No poking definitions found in Engines.xml for engine " + _buildInfo.Name + "."); } Process gameProcess = FindGameProcess(); if (gameProcess == null) { return(null); } string version = gameProcess.MainModule.FileVersionInfo.FileVersion; PokingInformation info = _buildInfo.Poking.RetrieveInformation(version); if (info == null) { throw new InvalidOperationException("Game version " + version + " does not have poking information defined in the Formats folder."); } if (!info.HeaderAddress.HasValue) { throw new NotImplementedException("Second Generation poking requires a HeaderAddress value."); } if (!info.MagicAddress.HasValue) { throw new NotImplementedException("Second Generation poking requires a MagicAddress value."); } if (!info.SharedMagicAddress.HasValue) { throw new NotImplementedException("Second Generation poking requires a SharedMagicAddress value."); } var gameMemory = new ProcessMemoryStream(gameProcess); var mapInfo = new SecondGenMapPointerReader(gameMemory, _buildInfo, info); long metaAddress; if (cacheFile.Type != CacheFileType.Shared) { metaAddress = mapInfo.CurrentCacheAddress; // The map isn't shared, so make sure the map names match if (mapInfo.MapName != cacheFile.InternalName) { gameMemory.Close(); return(null); } } else { metaAddress = mapInfo.SharedCacheAddress; // Make sure the shared and current map pointers are different, // or that the current map is the shared map if (mapInfo.MapType != CacheFileType.Shared && mapInfo.CurrentCacheAddress == mapInfo.SharedCacheAddress) { gameMemory.Close(); return(null); } } var metaStream = new OffsetStream(gameMemory, metaAddress - cacheFile.MetaArea.BasePointer); return(new EndianStream(metaStream, BitConverter.IsLittleEndian ? Endian.LittleEndian : Endian.BigEndian)); }
private void InitializeMemoryMap(ICacheFile cacheFile) { RecognizePartitionBoundaries(cacheFile); RecognizeTagBoundaries(cacheFile); }
public scenario_structure_bsp(ICacheFile cache, IIndexItem item) { this.cache = cache; this.item = item; }
public sound(ICacheFile cache, IIndexItem item) { this.cache = cache; this.item = item; }
private void worker_DoWork(object sender, DoWorkEventArgs e, IList <MapEntry> generatorMaps, string outputPath, BackgroundWorker worker, EngineDescription pickedEngine) { var globalMaps = new Dictionary <string, MetaMap>(); DateTime startTime = DateTime.Now; string gameIdentifier = ""; worker.ReportProgress(0); for (int i = 0; i < generatorMaps.Count; i++) { var tagMaps = new Dictionary <ITag, MetaMap>(); IReader reader; KeyValuePair <ICacheFile, EngineDescription> cacheData = LoadMap(generatorMaps[i].LocalMapPath, pickedEngine, out reader); ICacheFile cacheFile = cacheData.Key; if (cacheFile.MetaArea == null || cacheFile.Tags.Count == 0) { continue; } var analyzer = new MetaAnalyzer(cacheFile); if (gameIdentifier == "") { gameIdentifier = cacheData.Value.Settings.GetSetting <string>("shortName"); } var mapsToProcess = new Queue <MetaMap>(); foreach (ITag tag in cacheFile.Tags) { if (tag.MetaLocation == null) { continue; } var map = new MetaMap(); tagMaps[tag] = map; mapsToProcess.Enqueue(map); reader.SeekTo(tag.MetaLocation.AsOffset()); analyzer.AnalyzeArea(reader, tag.MetaLocation.AsPointer(), map); } GenerateSubMaps(mapsToProcess, analyzer, reader, cacheFile); var groupMaps = new Dictionary <string, MetaMap>(); foreach (ITag tag in cacheFile.Tags) { if (tag.MetaLocation == null) { continue; } MetaMap map = tagMaps[tag]; EstimateMapSize(map, tag.MetaLocation.AsPointer(), analyzer.GeneratedMemoryMap, 1); string magicStr = CharConstant.ToString(tag.Group.Magic); MetaMap oldGroupMap; if (groupMaps.TryGetValue(magicStr, out oldGroupMap)) { oldGroupMap.MergeWith(map); } else { groupMaps[magicStr] = map; } } foreach (var map in groupMaps) { MetaMap globalMap; if (globalMaps.TryGetValue(map.Key, out globalMap)) { globalMap.MergeWith(map.Value); } else { globalMaps[map.Key] = map.Value; } } reader.Dispose(); worker.ReportProgress(100 * (i + 1) / (generatorMaps.Count)); } string badChars = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars()); foreach (var map in globalMaps) { string filename = badChars.Aggregate(map.Key, (current, badChar) => current.Replace(badChar, '_')); filename = filename.Replace(" ", ""); filename += ".xml"; string path = Path.Combine(outputPath, filename); var settings = new XmlWriterSettings { Indent = true, IndentChars = "\t" }; using (XmlWriter writer = XmlWriter.Create(path, settings)) { var pluginWriter = new AssemblyPluginWriter(writer, gameIdentifier); int size = map.Value.GetBestSizeEstimate(); FoldSubMaps(map.Value); pluginWriter.EnterPlugin(size); pluginWriter.EnterRevisions(); pluginWriter.VisitRevision(new PluginRevision("Assembly", 1, "Generated plugin from scratch.")); pluginWriter.LeaveRevisions(); WritePlugin(map.Value, size, pluginWriter); pluginWriter.LeavePlugin(); } } DateTime endTime = DateTime.Now; e.Result = endTime.Subtract(startTime); }
public ScriptingContextCollection LoadContext(IReader reader, ICacheFile cache) { return(ScriptingContextGenerator.GenerateContext(reader, cache, _buildInfo)); }
public MetaAnalyzer(ICacheFile cacheFile) { _expander = cacheFile.PointerExpander; InitializeMemoryMap(cacheFile); RecognizeGroupIDs(cacheFile); }
public render_model(ICacheFile cache, IIndexItem item) { this.cache = cache; this.item = item; }
public IStream GetMetaStream(ICacheFile cacheFile) { return(new EndianStream(new SocketStream(_sessionManager, cacheFile.BuildString, cacheFile.InternalName), cacheFile.Endianness)); }
/// <summary> /// Obtains a stream which can be used to read and write a cache file's meta in realtime. /// The stream will be set up such that offsets in the stream correspond to meta pointers in the cache file. /// </summary> /// <param name="cacheFile">The cache file to get a stream for.</param> /// <returns>The stream if it was opened successfully, or null otherwise.</returns> public IStream GetMetaStream(ICacheFile cacheFile) { // Okay, so technically we should be checking to see if the cache file is actually loaded into memory first // But that's kinda hard to do... return(_xbdm.Connect() ? new EndianStream(_xbdm.MemoryStream, Endian.BigEndian) : null); }
public MetaContainer(EngineDescription buildInfo, string cacheLocation, TagEntry tag, TagHierarchy tags, ICacheFile cache, IStreamManager streamManager, IRTEProvider rteProvider, Trie stringIDTrie) { InitializeComponent(); _cacheLocation = cacheLocation; _tag = tag; _tags = tags; _buildInfo = buildInfo; _cache = cache; _streamManager = streamManager; _rteProvider = rteProvider; _stringIDTrie = stringIDTrie; tbMetaEditors.SelectedIndex = (int)App.AssemblyStorage.AssemblySettings.HalomapLastSelectedMetaEditor; // Create Meta Information Tab //_metaInformation = new MetaInformation(_buildInfo, _tag, _cache); //tabTagInfo.Content = _metaInformation; if (App.AssemblyStorage.AssemblySettings.HalomapLastSelectedMetaEditor == Settings.LastMetaEditorType.Info) { tbMetaEditors.SelectedIndex = (int)Settings.LastMetaEditorType.MetaEditor; } // Create Meta Editor Tab _metaEditor = new MetaEditor(_buildInfo, _tag, this, _tags, _cache, _streamManager, _rteProvider, _stringIDTrie); tabMetaEditor.Content = _metaEditor; // Create Plugin Editor Tab _pluginEditor = new PluginEditor(_buildInfo, _tag, this, _metaEditor); tabPluginEditor.Content = _pluginEditor; // Create Raw Tabs #region Models //if (_cache.ResourceMetaLoader.SupportsRenderModels && _tag.RawTag.Group.Magic == CharConstant.FromString("mode")) //{ // tabSound.Visibility = Visibility.Visible; // tabSound.Content = new SoundEditor(_tag, _cache, _streamManager); //} //else //{ // tabSound.Visibility = Visibility.Collapsed; // if (App.AssemblyStorage.AssemblySettings.halomapLastSelectedMetaEditor == App.AssemblyStorage.AssemblySettings.LastMetaEditorType.Model) // tbMetaEditors.SelectedIndex = (int)App.AssemblyStorage.AssemblySettings.LastMetaEditorType.MetaEditor; //} #endregion #region Sound if (_cache.ResourceMetaLoader.SupportsSounds && _tag.RawTag.Group.Magic == CharConstant.FromString("snd!")) { tabSoundEditor.Visibility = Visibility.Visible; tabSoundEditor.Content = new SoundEditor(_buildInfo, _cacheLocation, _tag, _cache, _streamManager); } else { tabSoundEditor.Visibility = Visibility.Collapsed; if (App.AssemblyStorage.AssemblySettings.HalomapLastSelectedMetaEditor == Settings.LastMetaEditorType.Sound) { tbMetaEditors.SelectedIndex = (int)Settings.LastMetaEditorType.MetaEditor; } } #endregion }
public CacheStructureReader(IReader reader, ICacheFile cache, EngineDescription buildInfo) : base(reader) { _cache = cache; _buildInfo = buildInfo; }
public StringEditor(ICacheFile cache) { InitializeComponent(); _cache = cache; }
private void GenerateSubMaps(Queue <MetaMap> maps, MetaAnalyzer analyzer, IReader reader, ICacheFile cacheFile) { var generatedMaps = new Dictionary <long, MetaMap>(); while (maps.Count > 0) { MetaMap map = maps.Dequeue(); foreach (MetaValueGuess guess in map.Guesses.Where(guess => guess.Type == MetaValueType.TagBlock)) { MetaMap subMap; if (!generatedMaps.TryGetValue(guess.Pointer, out subMap)) { subMap = new MetaMap(); reader.SeekTo(cacheFile.MetaArea.PointerToOffset(guess.Pointer)); analyzer.AnalyzeArea(reader, guess.Pointer, subMap); maps.Enqueue(subMap); generatedMaps[guess.Pointer] = subMap; } map.AssociateSubMap(guess.Offset, subMap); } } }
public MetaAnalyzer(ICacheFile cacheFile) { InitializeMemoryMap(cacheFile); RecognizeClassIDs(cacheFile); }
public abstract IStream GetMetaStream(ICacheFile cacheFile = null);
public ScriptingContextCollection LoadContext(IReader reader, ICacheFile cache) { throw new NotImplementedException(); }
public RTEStreamManager(IRTEProvider provider, ICacheFile cacheFile, ITag tag) { _provider = provider; _cacheFile = cacheFile; _tag = tag; }
// Patch Applying private void btnApplyPatch_Click(object sender, RoutedEventArgs e) { try { // Check the user isn't completly retarded if (!CheckAllApplyMandatoryFields() || currentPatch == null) { return; } // Check the output name if (currentPatch.OutputName != "") { if (Path.GetFileNameWithoutExtension(txtApplyPatchOutputMap.Text) != currentPatch.OutputName) { if (MetroMessageBox.Show("Warning", "This patch suggests to use the filename \"" + currentPatch.OutputName + ".map\" to save this map. This filename may be required in order for the map to work correctly.\r\n\r\nAre you sure you want to save this map as \"" + Path.GetFileName(txtApplyPatchOutputMap.Text) + "\"?", MetroMessageBox.MessageBoxButtons.OkCancel) != MetroMessageBox.MessageBoxResult.OK) { Close(); return; } } } // Paths string unmoddedMapPath = txtApplyPatchUnmodifiedMap.Text; string outputPath = txtApplyPatchOutputMap.Text; // Copy the original map to the destination path File.Copy(unmoddedMapPath, outputPath, true); // Open the destination map using (var stream = new EndianStream(File.Open(outputPath, FileMode.Open, FileAccess.ReadWrite), Endian.BigEndian)) { EngineDatabase engineDb = XMLEngineDatabaseLoader.LoadDatabase("Formats/Engines.xml"); ICacheFile cacheFile = CacheFileLoader.LoadCacheFile(stream, engineDb); if (currentPatch.MapInternalName != null && cacheFile.InternalName != currentPatch.MapInternalName) { MetroMessageBox.Show("Unable to apply patch", "Hold on there! That patch is for " + currentPatch.MapInternalName + ".map, and the unmodified map file you selected doesn't seem to match that. Find the correct file and try again."); return; } // Apply the patch! if (currentPatch.MapInternalName == null) { currentPatch.MapInternalName = cacheFile.InternalName; } // Because Ascension doesn't include this, and ApplyPatch() will complain otherwise PatchApplier.ApplyPatch(currentPatch, cacheFile, stream); // Check for blf snaps if (cbApplyPatchBlfExtraction.IsChecked != null && (PatchApplicationPatchExtra.Visibility == Visibility.Visible && (bool)cbApplyPatchBlfExtraction.IsChecked)) { string extractDir = Path.GetDirectoryName(outputPath); string blfDirectory = Path.Combine(extractDir, "images"); string infDirectory = Path.Combine(extractDir, "info"); if (!Directory.Exists(blfDirectory)) { Directory.CreateDirectory(blfDirectory); } if (!Directory.Exists(infDirectory)) { Directory.CreateDirectory(infDirectory); } string infPath = Path.Combine(infDirectory, Path.GetFileName(currentPatch.CustomBlfContent.MapInfoFileName)); File.WriteAllBytes(infPath, currentPatch.CustomBlfContent.MapInfo); foreach (BlfContainerEntry blfContainerEntry in currentPatch.CustomBlfContent.BlfContainerEntries) { string blfPath = Path.Combine(blfDirectory, Path.GetFileName(blfContainerEntry.FileName)); File.WriteAllBytes(blfPath, blfContainerEntry.BlfContainer); } } } MetroMessageBox.Show("Patch Applied!", "Your patch has been applied successfully. Have fun!"); } catch (Exception ex) { MetroException.Show(ex); } }
/// <summary> /// Reads the resource data for a sound from a stream and passes it back into the ISound. /// </summary> /// <param name="reader">The stream to read the sound data from.</param> /// <param name="sound">The sound's metadata.</param> /// <param name="resourceCacheFolder"> </param> /// <param name="buildInfo">Information about the cache file's target engine.</param> /// <param name="cacheFile"> </param> /// <param name="resourcePages"> </param> public static void ReadSoundData(IReader reader, ISound sound, ICacheFile cacheFile, ResourcePage[] resourcePages, string resourceCacheFolder, EngineDescription buildInfo) { // TODO: me }