Ejemplo n.º 1
0
			/// <summary>Loads the Halo2_Xbox files needed to fully run this library</summary>
			/// <remarks>
			/// Path[0] = Mainmenu
			/// Path[1] = Shared
			/// Path[2] = Single Player Shared
			/// </remarks>
			/// <param name="paths"></param>
			public static void LoadXbox(params string[] paths)
			{
				Blam.DatumIndex di;

				if (paths.Length >= 1 && System.IO.File.Exists(paths[0]))
				{
					di = manager.OpenCacheFile(BlamVersion.Halo2_Xbox, XboxMainmenuPath = paths[0]);
					XboxMainmenu = manager.GetCacheFile(di) as BlamLib.Blam.Halo2.CacheFile;
					XboxMainmenu.Read();
				}

				if (paths.Length >= 2 && System.IO.File.Exists(paths[1]))
				{
					di = manager.OpenCacheFile(BlamVersion.Halo2_Xbox, XboxSharedPath = paths[1]);
					XboxShared = manager.GetCacheFile(di) as BlamLib.Blam.Halo2.CacheFile;
					XboxShared.Read();
				}

				if (paths.Length >= 3 && System.IO.File.Exists(paths[2]))
				{
					di = manager.OpenCacheFile(BlamVersion.Halo2_Xbox, XboxCampaignPath = paths[2]);
					XboxCampaign = manager.GetCacheFile(di) as BlamLib.Blam.Halo2.CacheFile;
					XboxCampaign.Read();
				}
			}
Ejemplo n.º 2
0
            /// <summary>Loads the Halo2_Xbox files needed to fully run this library</summary>
            /// <remarks>
            /// Path[0] = Mainmenu
            /// Path[1] = Shared
            /// Path[2] = Single Player Shared
            /// </remarks>
            /// <param name="paths"></param>
            public static void LoadXbox(params string[] paths)
            {
                Blam.DatumIndex di;

                if (paths.Length >= 1 && System.IO.File.Exists(paths[0]))
                {
                    di           = manager.OpenCacheFile(BlamVersion.Halo2_Xbox, XboxMainmenuPath = paths[0]);
                    XboxMainmenu = manager.GetCacheFile(di) as BlamLib.Blam.Halo2.CacheFile;
                    XboxMainmenu.Read();
                }

                if (paths.Length >= 2 && System.IO.File.Exists(paths[1]))
                {
                    di         = manager.OpenCacheFile(BlamVersion.Halo2_Xbox, XboxSharedPath = paths[1]);
                    XboxShared = manager.GetCacheFile(di) as BlamLib.Blam.Halo2.CacheFile;
                    XboxShared.Read();
                }

                if (paths.Length >= 3 && System.IO.File.Exists(paths[2]))
                {
                    di           = manager.OpenCacheFile(BlamVersion.Halo2_Xbox, XboxCampaignPath = paths[2]);
                    XboxCampaign = manager.GetCacheFile(di) as BlamLib.Blam.Halo2.CacheFile;
                    XboxCampaign.Read();
                }
            }
Ejemplo n.º 3
0
            /// <summary>Returns a CacheFile object based on a ResourcePtr</summary>
            /// <param name="cf">Halo2 cache housing the <paramref name="ptr"/> value</param>
            /// <param name="ptr">ResourcePtr to use</param>
            /// <returns>The CacheFile <paramref name="ptr"/> references</returns>
            /// <remarks>Returns null if <paramref name="ptr"/> doesn't point to anything</remarks>
            public static Blam.Halo2.CacheFile FromLocation(Blam.Halo2.CacheFile cf, Blam.ResourcePtr ptr)
            {
                if (ptr.Offset == -1)
                {
                    return(null);
                }

                var ver = cf.EngineVersion;

                if (ptr.Map == BlamLib.Blam.ResourcePtr.Location.Internal)
                {
                    return(cf);
                }

                if (ver == BlamVersion.Halo2_Xbox)
                {
                    switch (ptr.Map)
                    {
                    case BlamLib.Blam.ResourcePtr.Location.MainMenu: return(XboxMainmenu);

                    case BlamLib.Blam.ResourcePtr.Location.Shared:  return(XboxShared);

                    case BlamLib.Blam.ResourcePtr.Location.Campaign: return(XboxCampaign);
                    }
                }
                else if (ver == BlamVersion.Halo2_Alpha)
                {
                    switch (ptr.Map)
                    {
                    case BlamLib.Blam.ResourcePtr.Location.MainMenu: return(AlphaMainmenu);

                    case BlamLib.Blam.ResourcePtr.Location.Shared:  return(AlphaShared);

                    case BlamLib.Blam.ResourcePtr.Location.Campaign: throw new Debug.Exceptions.UnreachableException();
                    }
                }
                else if (ver == BlamVersion.Halo2_PC)
                {
                    switch (ptr.Map)
                    {
                    case BlamLib.Blam.ResourcePtr.Location.MainMenu: return(PcMainmenu);

                    case BlamLib.Blam.ResourcePtr.Location.Shared:  return(PcShared);

                    case BlamLib.Blam.ResourcePtr.Location.Campaign: return(PcCampaign);
                    }
                }

                return(null);
            }
Ejemplo n.º 4
0
            /// <summary>Loads the Halo2_Alpha files needed to fully run this library</summary>
            /// <remarks>
            /// Path[0] = Mainmenu
            /// Path[1] = Shared
            /// </remarks>
            /// <param name="paths"></param>
            public static void LoadAlpha(params string[] paths)
            {
                Blam.DatumIndex di;

                if (paths.Length >= 1 && System.IO.File.Exists(paths[0]))
                {
                    di            = manager.OpenCacheFile(BlamVersion.Halo2_Alpha, AlphaMainmenuPath = paths[0]);
                    AlphaMainmenu = manager.GetCacheFile(di) as BlamLib.Blam.Halo2.CacheFile;
                    AlphaMainmenu.Read();
                }

                if (paths.Length >= 2 && System.IO.File.Exists(paths[1]))
                {
                    di          = manager.OpenCacheFile(BlamVersion.Halo2_Alpha, AlphaSharedPath = paths[1]);
                    AlphaShared = manager.GetCacheFile(di) as BlamLib.Blam.Halo2.CacheFile;
                    AlphaShared.Read();
                }
            }
Ejemplo n.º 5
0
            /// <summary>Returns a CacheFile object based on a ResourcePtr</summary>
            /// <remarks>
            /// If the resource is internal then <paramref name="is_internal"/> gets set to true
            /// and <paramref name="cf"/> is returned. If null and <paramref name="is_internal"/> is not set,
            /// the CacheFile is either not loaded or the location was invalid.
            ///
            /// Returns null if <paramref name="ptr"/> doesn't point to anything
            /// </remarks>
            /// <param name="cf">Halo2 cache housing the <paramref name="ptr"/> value</param>
            /// <param name="ptr">ResourcePtr to use</param>
            /// <param name="is_internal">bool reference to set if <paramref name="ptr"/> is internal</param>
            /// <returns>The CacheFile <paramref name="ptr"/> references</returns>
            public static Blam.Halo2.CacheFile FromLocation(Blam.Halo2.CacheFile cf, Blam.ResourcePtr ptr, out bool is_internal)
            {
                var ver = cf.EngineVersion;

                is_internal = false;

                if (ptr.Offset == -1)
                {
                    return(null);
                }

                if (ptr.Map == BlamLib.Blam.ResourcePtr.Location.Internal)
                {
                    is_internal = true;
                    return(cf);
                }

                return(FromLocation(cf, ptr));
            }
Ejemplo n.º 6
0
        public void ReadFromCache(Blam.Halo2.CacheFile cf)
        {
            int count = this.Count.Value;

            if (count > 0)
            {
                #region Read the string references
                var rsrc_offset = GetOffsetReferences();
                var rsrc_cache  = Program.Halo2.FromLocation(cf, rsrc_offset);

                if (rsrc_cache != null)
                {
                    rsrc_cache.InputStream.Seek(rsrc_offset.Offset);
                    stringReferences = new s_cache_unicode_string_reference[count];
                    for (int x = 0; x < stringReferences.Length; x++)
                    {
                        stringReferences[x].Read(cf.InputStream);
                    }
                }
                #endregion

                #region Read the string data buffer
                rsrc_offset = GetOffsetStrings();
                rsrc_cache  = Program.Halo2.FromLocation(cf, rsrc_offset);

                if (rsrc_cache != null)
                {
                    rsrc_cache.InputStream.Seek(rsrc_offset.Offset);
                    stringData = rsrc_cache.InputStream.ReadBytes(Size.Value);
                }
                else                 // just in case references was valid but somehow the string data buffer wasn't, can't have one without the other
                {
                    stringReferences = null;
                }
                #endregion
            }
        }
Ejemplo n.º 7
0
			/// <summary>Loads the Halo2_Alpha files needed to fully run this library</summary>
			/// <remarks>
			/// Path[0] = Mainmenu
			/// Path[1] = Shared
			/// </remarks>
			/// <param name="paths"></param>
			public static void LoadAlpha(params string[] paths)
			{
				Blam.DatumIndex di;

				if (paths.Length >= 1 && System.IO.File.Exists(paths[0]))
				{
					di = manager.OpenCacheFile(BlamVersion.Halo2_Alpha, AlphaMainmenuPath = paths[0]);
					AlphaMainmenu = manager.GetCacheFile(di) as BlamLib.Blam.Halo2.CacheFile;
					AlphaMainmenu.Read();
				}

				if (paths.Length >= 2 && System.IO.File.Exists(paths[1]))
				{
					di = manager.OpenCacheFile(BlamVersion.Halo2_Alpha, AlphaSharedPath = paths[1]);
					AlphaShared = manager.GetCacheFile(di) as BlamLib.Blam.Halo2.CacheFile;
					AlphaShared.Read();
				}
			}