private void Allocate(TagIdent ident, int size) { //create virtual stream to write into var tagCacheStream = new VirtualStream(Index[Index.GlobalsIdent].VirtualAddress); var binaryWriter = new BinaryWriter(tagCacheStream); for (var i = 0; i < Index.Count; ++i) { var datum = Index[i]; // is this address affected by the shift? if (datum.Identifier == ident) { var alignment = Guerilla.Guerilla.AlignmentOf(Halo2.GetTypeOf(Index[ident].Class)); datum.VirtualAddress = binaryWriter.BaseStream.Align(alignment); binaryWriter.Write(new byte[size]); datum.Length = size; Index.Update(datum.Identifier, datum); } else { var data = Deserialize(datum.Identifier); var length = binaryWriter.BaseStream.Length; binaryWriter.Write(data); binaryWriter.Seek(0, SeekOrigin.End); length = (int)binaryWriter.BaseStream.Length - length; datum.Length = (int)length; Index.Update(datum.Identifier, datum); } } binaryWriter.WritePadding(512); }
/// <summary>Close the resources used by this library</summary> public static void Close() { if (isInitialized) { Stubbs.Close(); #if NO_HALO4 Halo4.Close(); #endif #if NO_HALO_REACH HaloReach.Close(); #endif #if NO_HALO_ODST HaloOdst.Close(); #endif #if NO_HALO3 Halo3.Close(); #endif #if !NO_HALO2 Halo2.Close(); #endif Halo1.Close(); Debug.Exceptions.Dispose(); Debug.Trace.Close(); Debug.LogFile.CloseLog(); isInitialized = false; } }
public MapNames() { InitializeComponent(); listH1c.ItemsSource = Halo1.Where(e => e.Type == MapType.Campaign); listH1m.ItemsSource = Halo1.Where(e => e.Type == MapType.Multiplayer); listH2c.ItemsSource = Halo2.Where(e => e.Type == MapType.Campaign); listH2m.ItemsSource = Halo2.Where(e => e.Type == MapType.Multiplayer); listH2a.ItemsSource = Halo2A; listH3c.ItemsSource = Halo3.Where(e => e.Type == MapType.Campaign); listH3m.ItemsSource = Halo3.Where(e => e.Type == MapType.Multiplayer); listOdstc.ItemsSource = HaloODST.Where(e => e.Type == MapType.Campaign); listOdsts.ItemsSource = HaloODST.Where(e => e.Type == MapType.Survival); listReachc.ItemsSource = HaloReach.Where(e => e.Type == MapType.Campaign); listReachs.ItemsSource = HaloReach.Where(e => e.Type == MapType.Survival); listReachm.ItemsSource = HaloReach.Where(e => e.Type == MapType.Multiplayer); listH4c.ItemsSource = Halo4.Where(e => e.Type == MapType.Campaign); listH4s.ItemsSource = Halo4.Where(e => e.Type == MapType.Survival); listH4m.ItemsSource = Halo4.Where(e => e.Type == MapType.Multiplayer); }
static void DeserializeTag(this BinaryReader sourceReader, object item, FieldInfo field) { var reference = sourceReader.ReadTagReference(); Source.Position = Source[reference.Ident].Meta.VirtualAddress; field.SetValue(item, Deserialize(sourceReader, Halo2.GetTypeOf(reference.Class))); }
internal override StructureBspClusterDataBlockNew[] ReadStructureBspClusterDataBlockNewArray(BinaryReader binaryReader) { binaryReader.ReadBytes(8); using (binaryReader.BaseStream.Pin( )) { ResourceStream source = Halo2.GetResourceBlock(this.geometryBlockInfo); BinaryReader reader = new BinaryReader(source); return(new[] { new StructureBspClusterDataBlockNew(reader) }); } }
/// <summary> /// Loads geometry data into the tagblock from resource stream /// </summary> /// <param name="binaryReader"></param> /// <returns></returns> internal override RenderModelSectionDataBlock[] ReadRenderModelSectionDataBlockArray(BinaryReader binaryReader) { binaryReader.ReadBytes(8); using (binaryReader.BaseStream.Pin( )) { var geometryBlockInfo = new GlobalGeometryBlockInfoStructBlock(binaryReader); ResourceStream source = Halo2.GetResourceBlock(geometryBlockInfo); BinaryReader reader = new BinaryReader(source); return(new[] { new RenderModelSectionDataBlock(reader) }); } }
internal void LanguagePacksReadFromCache(Halo2.CacheFile c) { if (!English.IsLoaded) English.ReadFromCache(c); if (!Japanese.IsLoaded) Japanese.ReadFromCache(c); if (!German.IsLoaded) German.ReadFromCache(c); if (!French.IsLoaded) French.ReadFromCache(c); if (!Spanish.IsLoaded) Spanish.ReadFromCache(c); if (!Italian.IsLoaded) Italian.ReadFromCache(c); if (!Korean.IsLoaded) Korean.ReadFromCache(c); if (!Chinese.IsLoaded) Chinese.ReadFromCache(c); if (!Portuguese.IsLoaded) Portuguese.ReadFromCache(c); }
public void Draw(TagIdent item) { if (objectInstances.ContainsKey(item)) { //IRenderable @object = objects[item] as IRenderable; //@object.Render( new[] { program, systemProgram } ); } else { var data = Halo2.GetReferenceObject(item); //objects[item] = new ScenarioObject( (ModelBlock)data ); } }
internal void LanguagePackHeadersReadFromCache(Halo2.CacheFile cf) { const int k_expected_size = s_cache_language_pack.kSizeOf * (int)LanguageType.kMax; if (LanguagePacksOffset != -1 && LanguagePacksSizeOf == (uint)k_expected_size) { cf.InputStream.Seek(LanguagePacksOffset); languagePacks = new s_cache_language_pack[(int)LanguageType.kMax]; for (int x = 0; x < languagePacks.Length; x++) (languagePacks[x] = new s_cache_language_pack(null)).Read(cf.InputStream); } else throw new Debug.ExceptionLog("Tried to read a custom language pack header with unexpected data! @{0} size: {1}", LanguagePacksOffset.ToString("X8"), LanguagePacksSizeOf.ToString("X8")); }
private void LoadInstances(List <IH2ObjectInstance> instances, List <IH2ObjectPalette> objectPalette) { var join = (from instance in instances join palette in objectPalette on(int) instance.PaletteIndex equals objectPalette.IndexOf(palette) into gj from items in gj.DefaultIfEmpty() select new { instance, Object = items.ObjectReference }).ToArray(); foreach (var item in join) { Add(item.Object.Ident, new ScenarioObject( Halo2.GetReferenceObject <ModelBlock>(Halo2.GetReferenceObject <ObjectBlock>(item.Object).model)) { WorldMatrix = item.instance.WorldMatrix } ); } }
public static void Initialize() { if (!isInitialized) { //if(System.Diagnostics.Debugger.IsAttached) /*{ // HACK: to make the LoaderLock message appear as soon as possible. * // This is only needed during VS debugging. Won't get it during non-debug runtime. * // SlimDX doesn't have these issues. * var t = typeof(Microsoft.DirectX.UnsafeNativeMethods); * t = typeof(Microsoft.DirectX.Direct3D.Device); * t = null; * }*/ Debug.Exceptions.Initialize(); System.Windows.Forms.Application.ApplicationExit += new EventHandler(Application_ApplicationExit); Halo1.Initialize(); #if !NO_HALO2 Halo2.Initialize(); #endif #if NO_HALO3 Halo3.Initialize(); #endif #if NO_HALO_ODST HaloOdst.Initialize(); #endif #if NO_HALO_REACH HaloReach.Initialize(); #endif #if NO_HALO4 Halo4.Initialize(); #endif Stubbs.Initialize(); TagInterface.DefinitionStatePool.PostProcess(); isInitialized = true; } }
void glControl1_Load(object sender, EventArgs e) { Scene = new Graphics.Scene(); Application.Idle += HandleApplicationIdle; Scene.OnFrameReady += Scene_OnFrameReady; glControl1.Resize += glControl1_Resize; glControl1.MouseDown += Scene.Camera.OnMouseDown; glControl1.MouseMove += Scene.Camera.OnMouseMove; glControl1.MouseUp += Scene.Camera.OnMouseUp; glControl1.MouseCaptureChanged += Scene.Camera.OnMouseCaptureChanged; var fileName = @"C:\Users\seed\Documents\Halo 2 Modding\mainmenu.map"; var directory = Path.GetDirectoryName(fileName); var maps = Directory.GetFiles(directory, "*.map", SearchOption.TopDirectoryOnly); var resourceMaps = maps.GroupBy( x => { return(Halo2.CheckMapType(x)); } ).Where(x => x.Key == MapType.MainMenu || x.Key == MapType.Shared || x.Key == MapType.SinglePlayerShared) .Select(g => g.First()).ToList(); resourceMaps.ForEach(x => Halo2.LoadResource(new MapStream(x))); Map = new MapStream(fileName); Scene.ObjectManager.Add(Map["hlmt", "masterchief"].Meta.Identifier, new ScenarioObject((ModelBlock)(Map["hlmt", "masterchief"].Deserialize()))); var shaderTags = Map.Tags.Where(x => x.Type.ToString() == "shad").ToArray(); listBox1.Items.AddRange(shaderTags); listBox1.DisplayMember = "Path"; // firing this method is meant to load the view-projection matrix values into // the shader uniforms, and initalizes the camera glControl1_Resize(this, new EventArgs()); }
public T Deserialize <T>(TagIdent ident) where T : GuerillaBlock { GuerillaBlock deserializedTag; if (_deserializedTagCache.TryGetValue(ident, out deserializedTag)) { return(( T )deserializedTag); } var type = Halo2.GetTypeOf(Index[ident].Class); if (type == null) { return(null); } Seek(ident); _deserializedTagCache[ident] = Deserialize(type); _tagHashDictionary[ident] = CalculateHash(ident); return(( T )_deserializedTagCache[ident]); }
private void LoadNetgameEquipment(List <ScenarioNetgameEquipmentBlock> list) { foreach (var item in list.Where(x => !TagIdent.IsNull(x.itemVehicleCollection.Ident) && (x.itemVehicleCollection.Class.ToString() == "vehc" || x.itemVehicleCollection.Class.ToString() == "itmc"))) { try { Add(item.itemVehicleCollection.Ident, new ScenarioObject(Halo2.GetReferenceObject <ModelBlock>( Halo2.GetReferenceObject <ObjectBlock>( item.itemVehicleCollection.Class.ToString() == "itmc" ? Halo2.GetReferenceObject <ItemCollectionBlock>(item.itemVehicleCollection).itemPermutations.First().item : Halo2.GetReferenceObject <VehicleCollectionBlock>(item.itemVehicleCollection).vehiclePermutations.First().vehicle).model)) { WorldMatrix = item.WorldMatrix } ); } catch (NullReferenceException) { } } }
public void Read(Halo2.CacheFile c) { }
public ClassTreeNode(TagClass @class) { Text = Halo2.GetTypeOf(@class).Name; Class = @class; }
internal void LanguagePacksReadFromCache(Halo2.CacheFile cf) { foreach (var lp in languagePacks) lp.ReadFromCache(cf); }
public void Add(TagIdent item) { var data = Halo2.GetReferenceObject(item); //objects[item] = new ScenarioObject( (ModelBlock)data ); }
internal void TagDependencyGraphReadFromCache(Halo2.CacheFile cf) { TagDependencyGraph = new SharedDependencyGraph(); TagDependencyGraph.Read(cf.InputStream); }
public void FromCache(Halo2.CacheFile c, cache_file_sound_group snd) { var icti = c.TagIndexManager as InternalCacheTagIndex; var ugh_ = icti[icti.SoundGestaltTagIndex].TagDefinition as sound_cache_file_gestalt_group; Reconstruct(ugh_, snd); }