public static void Populate(CommandContext commandContext, GameCache cache, CachedTag tag, Sound sound)
        {
            commandContext.AddCommand(new ImportSoundCommand(cache, tag, sound));
            commandContext.AddCommand(new ExportSoundCommand(cache, tag, sound));

            if (cache.GetType() == typeof(GameCacheGen3))
            {
                var h3Cache = cache as GameCacheGen3;
                commandContext.AddCommand(new ExtractXMACommand(h3Cache, tag, sound));
            }
        }
Beispiel #2
0
        public static CommandContext Create(CommandContextStack contextStack, GameCache currentCache, GameCache portingCache)
        {
            var context = new CommandContext(contextStack.Context, portingCache.DisplayName + "\\tags");

            // only support gen3 to HO porting for now, add more later
            if (portingCache.GetType() == typeof(GameCacheGen3) && currentCache is GameCacheHaloOnlineBase)
            {
                Populate(contextStack, context, currentCache, portingCache);
            }

            // add tags command to the new cache
            TagCacheContextFactory.Populate(contextStack, context, currentCache);

            return(context);
        }
Beispiel #3
0
        public static BitmapTextureInteropResource CreateBitmapResourceFromDDS(GameCache cache, DDSFile file)
        {
            BitmapTextureInteropResource result = BitmapUtils.CreateEmptyBitmapTextureInteropResource();

            if (cache is GameCacheHaloOnlineBase)
            {
                // TODO: for cubemaps, fix mipmap order to d3d9 expected order
                result.Texture.Definition.PrimaryResourceData = new TagData(file.BitmapData);
                result.Texture.Definition.Bitmap = BitmapUtils.CreateBitmapTextureInteropDefinition(file.Header);
            }
            else if (cache.GetType() == typeof(GameCacheGen3))
            {
                // need to do some serious conversion, might be better to require an uncompressed input
                throw new NotImplementedException();
            }
            return(result);
        }
Beispiel #4
0
        public static byte[] ExtractBitmapData(GameCache cache, Bitmap bitmap, int imageIndex)
        {
            var resourceReference  = bitmap.Resources[imageIndex];
            var resourceDefinition = cache.ResourceCache.GetBitmapTextureInteropResource(resourceReference);

            if (cache is GameCacheHaloOnlineBase)
            {
                if (resourceDefinition != null)
                {
                    return(resourceDefinition.Texture.Definition.PrimaryResourceData.Data);
                }
                else
                {
                    Console.Error.WriteLine("No resource associated to this bitmap.");
                    return(null);
                }
            }
            else if (cache.GetType() == typeof(GameCacheGen3))
            {
                if (resourceDefinition != null)
                {
                    var bitmapTextureInteropDefinition = resourceDefinition.Texture.Definition.Bitmap;

                    if (bitmapTextureInteropDefinition.HighResInSecondaryResource == 1)
                    {
                        var result = new byte[resourceDefinition.Texture.Definition.PrimaryResourceData.Data.Length + resourceDefinition.Texture.Definition.SecondaryResourceData.Data.Length];
                        Array.Copy(resourceDefinition.Texture.Definition.PrimaryResourceData.Data, 0, result, 0, resourceDefinition.Texture.Definition.PrimaryResourceData.Data.Length);
                        Array.Copy(resourceDefinition.Texture.Definition.SecondaryResourceData.Data, 0, result, resourceDefinition.Texture.Definition.PrimaryResourceData.Data.Length, resourceDefinition.Texture.Definition.SecondaryResourceData.Data.Length);
                        return(result);
                    }
                    else
                    {
                        return(resourceDefinition.Texture.Definition.PrimaryResourceData.Data);
                    }
                }
                else
                {
                    Console.Error.WriteLine("No resource associated to this bitmap.");
                    return(null);
                }
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Beispiel #5
0
 public static DDSFile ExtractBitmap(GameCache cache, Bitmap bitmap, int imageIndex)
 {
     if (cache is GameCacheHaloOnlineBase)
     {
         byte[]    data   = ExtractBitmapData(cache, bitmap, imageIndex);
         DDSHeader header = new DDSHeader(bitmap.Images[imageIndex]);
         return(new DDSFile(header, data));
     }
     else if (cache.GetType() == typeof(GameCacheGen3))
     {
         var baseBitmap = BitmapConverter.ConvertGen3Bitmap(cache, bitmap, imageIndex, true);
         if (baseBitmap == null)
         {
             return(null);
         }
         return(new DDSFile(baseBitmap));
     }
     else
     {
         return(null);
     }
 }