internal override bool Reconstruct(BlamLib.Blam.CacheFile c) { //int index = BitmapGroup.Value & 0xFFFF; //if (index != -1) System.Diagnostics.Debug.WriteLine(string.Format( // "BitmapGroup: {0} {1}", index, c.Index.Tags[index].FileName)); return(true); }
internal override bool Reconstruct(BlamLib.Blam.CacheFile c) { dead_sphere_shapes.DeleteAll(); pill_shapes.DeleteAll(); sphere_shapes.DeleteAll(); return(true); }
/// <summary> /// Process the reference data to the cache file /// </summary> /// <param name="c">Cache file</param> public override void WriteHeader(BlamLib.Blam.CacheFile c) { if ((c.EngineVersion & BlamVersion.Halo1) != 0 || (c.EngineVersion & BlamVersion.Stubbs) != 0) { c.OutputStream.Write(elements.Count); headerOffset = c.OutputStream.PositionUnsigned; c.OutputStream.Write(0); c.OutputStream.Write(0); } else if (c.EngineVersion == BlamVersion.Halo2_Alpha || c.EngineVersion == BlamVersion.Halo2_Epsilon) { c.OutputStream.Write(elements.Count); headerOffset = c.OutputStream.PositionUnsigned; c.OutputStream.Write(0); c.OutputStream.Write(0); } else if ((c.EngineVersion & BlamVersion.Halo2) != 0) { c.OutputStream.Write(elements.Count); headerOffset = c.OutputStream.PositionUnsigned; c.OutputStream.Write(0); } else if ((c.EngineVersion & BlamVersion.Halo3) != 0 || (c.EngineVersion & BlamVersion.HaloOdst) != 0 || (c.EngineVersion & BlamVersion.HaloReach) != 0 || (c.EngineVersion & BlamVersion.Halo4) != 0) { c.OutputStream.Write(elements.Count); headerOffset = c.OutputStream.PositionUnsigned; c.OutputStream.Write(0); c.OutputStream.Write(0); } }
internal override bool Reconstruct(BlamLib.Blam.CacheFile c) { Invert_Value(ref acceleration_range.I); Invert_Value(ref acceleration_range.J); Invert_Value(ref acceleration_range.K); return(true); }
// TODO: I believe useless pad was added after alpha halo, so we should check for that and read\write if in a cache\tag #region Cache /// <summary> /// Seek the stream ahead however many bytes the size of this pad is /// </summary> /// <param name="c"></param> public override void Read(BlamLib.Blam.CacheFile c) { if (c.EngineVersion == BlamVersion.Halo2_Alpha || c.EngineVersion == BlamVersion.Halo2_Epsilon) { c.InputStream.Seek(Value, System.IO.SeekOrigin.Current); } }
/// <summary> /// Process the struct field from a cache file /// </summary> /// <param name="c">Cache file</param> /// <param name="iop">Processing method</param> public void Read(BlamLib.Blam.CacheFile c, IOProcess iop) { VersionCtorAttribute upgrade_parameters; if (c.EngineVersion == BlamVersion.Halo2_Alpha || c.EngineVersion == BlamVersion.Halo2_Epsilon || c.EngineVersion == BlamVersion.Halo3_Beta) { if ((upgrade_parameters = kState.VersionForEngine(c.EngineVersion)) != null) { // It is ASSUMED that the group tag won't ever be needed for version construction Value = (T)kState.NewInstance(this, upgrade_parameters.Major, upgrade_parameters.Minor); NeedsUpgrading = true; } else { NeedsUpgrading = false; } } Value.Read(c, iop); if (NeedsUpgrading) #if DEBUG { Debug.Assert.If(Value.Upgrade(), "Failed to upgrade struct. {0} {1}", typeof(T).Name, Value.ToVersionString()); } #else { Value.Upgrade(); } #endif }
/// <summary> /// Process the reference data from the cache file /// </summary> /// <param name="c">Cache file</param> public override void ReadHeader(BlamLib.Blam.CacheFile c) { #if DEBUG relativeOffset = c.InputStream.PositionUnsigned; #endif VersionCtorAttribute upgrade_parameters; if ((c.EngineVersion & BlamVersion.Halo1) != 0 || (c.EngineVersion & BlamVersion.Stubbs) != 0) { Resize(c.InputStream.ReadInt32()); // element count relativeOffset = c.InputStream.ReadPointer(); c.InputStream.ReadUInt32(); } #region Halo 2 Betas else if (c.EngineVersion == BlamVersion.Halo2_Alpha || c.EngineVersion == BlamVersion.Halo2_Epsilon) { if ((upgrade_parameters = kState.VersionForEngine(c.EngineVersion)) != null) { NeedsUpgrading = true; Resize(c.InputStream.ReadInt32(), upgrade_parameters.Major, upgrade_parameters.Minor); } else { NeedsUpgrading = false; Resize(c.InputStream.ReadInt32()); // element count } relativeOffset = c.InputStream.ReadPointer(); c.InputStream.ReadUInt32(); } #endregion else if ((c.EngineVersion & BlamVersion.Halo2) != 0) { Resize(c.InputStream.ReadInt32()); // element count relativeOffset = c.InputStream.ReadPointer(); } #region Halo 3 Betas else if (c.EngineVersion == BlamVersion.Halo3_Beta) { if ((upgrade_parameters = kState.VersionForEngine(c.EngineVersion)) != null) { NeedsUpgrading = true; Resize(c.InputStream.ReadInt32(), upgrade_parameters.Major, upgrade_parameters.Minor); } else { NeedsUpgrading = false; Resize(c.InputStream.ReadInt32()); // element count } relativeOffset = c.InputStream.ReadPointer(); c.InputStream.ReadUInt32(); } #endregion else if ((c.EngineVersion & BlamVersion.Halo3) != 0 || (c.EngineVersion & BlamVersion.HaloOdst) != 0 || (c.EngineVersion & BlamVersion.HaloReach) != 0 || (c.EngineVersion & BlamVersion.Halo4) != 0) { Resize(c.InputStream.ReadInt32()); // element count relativeOffset = c.InputStream.ReadPointer(); c.InputStream.ReadUInt32(); } }
/// <summary> /// Stream the field to a cache /// </summary> /// <param name="c"></param> public override void WriteHeader(BlamLib.Blam.CacheFile c) { if (c.EngineVersion == BlamVersion.Halo2_Alpha) // old string id { c.OutputStream.Write(NullPreviewString); } Handle.Write(c.OutputStream); }
internal override bool Reconstruct(BlamLib.Blam.CacheFile c) { //ReconstructRigidBodyShapeData(); int Object_Count = Spheres.Count + MultiSpheres.Count + Pills.Count + Boxes.Count + Triangles.Count + Polyhedra.Count; MassDistributions.Resize(Object_Count); //TODO: Find a proper way to generate values for this. This fix will only go so far. return(true); }
/// <summary> /// Stream the field from a buffer /// </summary> /// <param name="c"></param> public override void ReadHeader(BlamLib.Blam.CacheFile c) { OwnerId = c.TagIndexManager.IndexId; if (c.EngineVersion == BlamVersion.Halo2_Alpha) // old string id { c.InputStream.Seek(28, System.IO.SeekOrigin.Current); // preview string } Handle.Read(c.InputStream, c.StringIds.Definition.Description); }
/// <summary>Ran whenever the UI says it's time to close the cache</summary> void OnCacheClosed() { PopulateTagInstanceProperties(null); m_cache = null; ToggleUserInterfaceForCacheState(false); SetCacheViewerPath("No File Loaded"); PopulateCacheProperties(); TagTreeViewClear(); }
internal override bool Reconstruct(BlamLib.Blam.CacheFile c) { //PredictedResources.DeleteAll(); //EditorScenarioData.Delete(); LevelData.DeleteAll(); //SharedReferences.DeleteAll(); //SimulationDefinitionTable.DeleteAll(); return(true); }
internal override bool Reconstruct(BlamLib.Blam.CacheFile c) { Invert_Value(ref power_transition_time.Value); Invert_Value(ref power_acceleration_time.Value); Invert_Value(ref position_transition_time.Value); Invert_Value(ref position_acceleration_time.Value); Invert_Value(ref depowered_position_transition_time.Value); Invert_Value(ref depowered_position_acceleration_time.Value); PredictedResources.DeleteAll(); return(true); }
internal override bool Reconstruct(BlamLib.Blam.CacheFile c) { bool result = true; if (RawPcaData.Count == 0) { result = ReconstructRawPcaData(c, GeometryBlockInfo.Value); } GeometryBlockInfo.Value.ClearPostReconstruction(); return(result); }
public CacheView(BlamLib.BlamVersion engine) { InitializeComponent(); MainMenu.Renderer = MainForm.kOpenSauceIDEToolStripRenderer; MenuTagInstance.Renderer = MainForm.kOpenSauceIDEToolStripRenderer; m_tagTreeEditorMode = TagTreeEditorMode.TagExtraction; m_engine = engine; m_cache = null; bool tag_extraction_supported = (engine & kAllowedPlatforms) != 0; ViewUpdateExtractionSupportedState(tag_extraction_supported, false); }
/// <summary> /// Process the block from the cache file /// </summary> /// <param name="c">Cache file</param> public override void Read(BlamLib.Blam.CacheFile c) { if (relativeOffset == 0) { return; } c.InputStream.Seek(relativeOffset, System.IO.SeekOrigin.Begin); elements.Read(c); if (NeedsUpgrading) { elements.Upgrade(); } }
public CacheView(BlamLib.BlamVersion engine) { InitializeComponent(); MainMenu.Renderer = MainForm.kOpenSauceIDEToolStripRenderer; MenuTagInstance.Renderer = MainForm.kOpenSauceIDEToolStripRenderer; m_tagTreeEditorMode = TagTreeEditorMode.TagExtraction; m_engine = engine; m_cache = null; bool tag_extraction_supported = (engine & kAllowedPlatforms) != 0; ViewUpdateExtractionSupportedState(tag_extraction_supported, false); }
internal override bool Reconstruct(BlamLib.Blam.CacheFile c) { bool result = true; if (EncodedPermutationSection.Count != 1) { sound_encoded_dialogue_section_block section; EncodedPermutationSection.Add(out section); result = section.Reconstruct(GeometryBlockInfo.Value); } GeometryBlockInfo.Value.ClearPostReconstruction(); return(result); }
internal byte[] CacheRead(BlamLib.Blam.CacheFile c) { // read the cache block... byte[] bytes; if (!CacheRead(c, out bytes)) { return(null); } if (c.EngineVersion == BlamVersion.Halo2_PC) // ...and perform zlib decompression { bytes = Util.ZLibBufferFromBytes(bytes, 0, GetPixelDataSize(c.EngineVersion)); } return(bytes); }
internal override bool Reconstruct(BlamLib.Blam.CacheFile c) { bool result = true; if (ParticleSystemData.Count != 1) { particle_system_lite_data_block data; ParticleSystemData.Add(out data); result = data.Reconstruct(GeometryBlockInfo.Value); } GeometryBlockInfo.Value.ClearPostReconstruction(); return(result); }
internal override bool Reconstruct(BlamLib.Blam.CacheFile c) { bool result = true; if (CacheData.Count != 1) { lightmap_geometry_section_cache_data_block cache_data; CacheData.Add(out cache_data); result = cache_data.Reconstruct(c, GeometryInfo.Value, GeometryBlockInfo.Value); } GeometryBlockInfo.Value.ClearPostReconstruction(); return(result); }
internal override bool Reconstruct(BlamLib.Blam.CacheFile c) { bool result = true; // recreate the section data if (Section.Count != 1) { water_geometry_section_block section; Section.Add(out section); result = section.Section.Value.Reconstruct(c, null, GeometryBlockInfo.Value); } GeometryBlockInfo.Value.ClearPostReconstruction(); return(result); }
internal override bool Reconstruct(BlamLib.Blam.CacheFile c) { bool result = true; // recreate the section data if (CacheBlockData.Count != 1) { decorator_cache_block_data_block cdata; CacheBlockData.Add(out cdata); result = cdata.Reconstruct(GeometryBlockInfo.Value); } GeometryBlockInfo.Value.ClearPostReconstruction(); return(result); }
internal override bool Reconstruct(BlamLib.Blam.CacheFile c) { bool result = true; // recreate the section data if (RenderData.Count != 1) { structure_bsp_cluster_data_block_new cdata; RenderData.Add(out cdata); result = cdata.Section.Value.Reconstruct(c, SectionInfo.Value, GeometryBlockInfo.Value); } GeometryBlockInfo.Value.ClearPostReconstruction(); return(result); }
internal override Item AddFeignItem(BlamLib.Blam.CacheFile cf, string tag_name, BlamLib.TagInterface.TagGroup group_tag) { var last_item = items[items.Length - 1]; CacheItem item = new CacheItem(); item.InitializeForFeigning(last_item.Datum, group_tag); // We don't use the optimized version item.ReferenceName = cf.References.Add(group_tag, tag_name); if (item.ReferenceName == DatumIndex.Null) { throw new Debug.ExceptionLog("Unable to create feign item's name reference!"); } Array.Resize(ref items, items.Length + 1); return(items[items.Length - 1] = item); }
internal override bool Reconstruct(BlamLib.Blam.CacheFile c) { PredictedResources.DeleteAll(); EditorScenarioData.Delete(); LevelData.DeleteAll(); SharedReferences.DeleteAll(); SimulationDefinitionTable.DeleteAll(); DeleteCompiledScripts(); if (ScenarioResources.Count >= 1) { var scenario_resources = ScenarioResources[0]; scenario_resources.references.DeleteAll(); scenario_resources.ai_resources.DeleteAll(); } return(true); }
internal override bool Reconstruct(BlamLib.Blam.CacheFile c) { if (c.EngineVersion.IsXbox1()) { var rsrc_ptr = GetOffset(); var rsrc_cache = Program.Halo2.FromLocation(c as Halo2.CacheFile, rsrc_ptr); // the shared cache isn't loaded, break if (rsrc_cache == null) { return(false); } c.InputStream.Seek(rsrc_ptr.Offset); Data = c.InputStream.ReadBytes(GetSizeOf()); Stream = new System.IO.MemoryStream(Data, false); } return(true); }
/// <summary> /// Process the block to the cache file /// </summary> /// <param name="c">Cache file</param> public override void Write(BlamLib.Blam.CacheFile c) { relativeOffset = c.OutputStream.PositionUnsigned; // store offset c.OutputStream.Seek(headerOffset, System.IO.SeekOrigin.Begin); // go to the reflexive header c.OutputStream.WritePointer(relativeOffset); // write offset c.OutputStream.Seek(relativeOffset, System.IO.SeekOrigin.Begin); // go back to where we were if ((c.EngineVersion & BlamVersion.Halo1) != 0 || (c.EngineVersion & BlamVersion.Stubbs) != 0) { elements.Write(c); } else if ((c.EngineVersion & BlamVersion.Halo2) != 0) { elements.Write(c); } else if ((c.EngineVersion & BlamVersion.Halo3) != 0 || (c.EngineVersion & BlamVersion.HaloOdst) != 0 || (c.EngineVersion & BlamVersion.HaloReach) != 0) { elements.Write(c); } }
internal override bool Reconstruct(BlamLib.Blam.CacheFile c) { var clpi = c.TagIndexManager as ICacheLanguagePackContainer; if (clpi != null) { var h2_cache = c as Halo2.CacheFile; var interop = new s_language_cache_interop[(int)LanguageType.kMax]; int total_string_buffer_size = 0; // For each language, get the string data referenced by this tag for (LanguageType lang = LanguageType.English; lang < LanguageType.kMax; lang++) { total_string_buffer_size = interop[(int)lang].Initialize(clpi.LanguagePackGet(lang), total_string_buffer_size, LanguageHandles[(int)lang]); } // Resize the string data container to have enough memory for all of our language strings this.StringData.Value = new byte[total_string_buffer_size]; // For each language, copy the string data and initialize the reference blocks for (LanguageType lang = LanguageType.English; lang < LanguageType.kMax; lang++) { interop[(int)lang].ReconstructTagData(this, lang); } // Null the handles for the extracted tag foreach (var handle in LanguageHandles) { handle.Value = 0; } return(true); } return(false); }
internal override bool Reconstruct(BlamLib.Blam.CacheFile c) { bool result = true; if (c.EngineVersion.IsXbox1()) { animation_graph_cache_block cache; byte[] temp; foreach (animation_graph_resources_struct.animation_pool_block anim in Resources.Value.Animations) { cache = CacheBlocks[anim.ParentGraphBlockIndex]; temp = new byte[anim.GetTotalSize()]; if (cache.Stream == null) { result = false; } cache.Stream.Position = anim.ParentGraphBlockOffset.Value; cache.Stream.Read(temp, 0, temp.Length); anim.AnimationData.Reset(temp); temp = null; cache = null; } foreach (animation_graph_cache_block cb in CacheBlocks) { cb.Close(); // clean up resources } //CacheBlocks.DeleteAll(); //CacheUnknown.DeleteAll(); } return(result); }
bool CacheRead(BlamLib.Blam.CacheFile c, out byte[] data) { data = null; ResourcePtr offset = GetOffset(0); int size = GetSize(0); var rsrc_cache = Program.Halo2.FromLocation(c as Halo2.CacheFile, offset); // the shared cache isn't loaded, break if (rsrc_cache == null) { return(false); } // get the input stream we need IO.EndianReader er = rsrc_cache.InputStream; // read the bitmap er.Seek(offset.Offset); data = er.ReadBytes(size); return(true); }
/// <summary>Ran whenever the UI says it's time to close the cache</summary> void OnCacheClosed() { PopulateTagInstanceProperties(null); m_cache = null; ToggleUserInterfaceForCacheState(false); SetCacheViewerPath("No File Loaded"); PopulateCacheProperties(); TagTreeViewClear(); }