Exemple #1
0
        public byte[] GenerateKartAnimationPaletteData(KartImagePool images, bool isTurnAnim)
        {
            //Generate the palettes
            int paletteCount;

            if (isTurnAnim)
            {
                paletteCount = 21;
            }
            else
            {
                paletteCount = 20;
            }

            List <byte> bytes = new List <byte>();

            for (int i = 0; i < paletteCount; i++)
            {
                int imageIndex;
                if (IsTurnAnim)
                {
                    imageIndex = GetImageIndexForTurnFrame(i);
                }
                else //if (IsSpinAnim)
                {
                    imageIndex = GetImageIndexForSpinFrame(i);
                }

                KartImage image = images.Images[OrderedImageNames[imageIndex]];

                if (image.IsAnimated)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        bytes.AddRange(image.Images[j].ImageReference.BasePalettes[1].RawData);
                    }
                }
                else
                {
                    for (int j = 0; j < 4; j++)
                    {
                        bytes.AddRange(image.Images[0].ImageReference.BasePalettes[1].RawData);
                    }
                }
            }

            return(bytes.ToArray());
        }
Exemple #2
0
        public KartImagePool(XElement xml)
        {
            if (xml.Element(PALETTE) != null)
            {
                if (xml.Element(PALETTE).Attribute(OFFSET) != null)
                {
                    int            offset = int.Parse(xml.Element(PALETTE).Attribute(OFFSET).Value);
                    N64DataElement element;
                    if (offset != -1 && RomProject.Instance.Files[0].HasElementExactlyAt(offset, out element) &&
                        element is Palette)
                    {
                        ImagePalette = (Palette)element;
                    }
                    else
                    {
                        ImagePalette = new Palette(-1, Convert.FromBase64String(xml.Element(PALETTE).Value));
                    }
                }
                else
                {
                    ImagePalette = new Palette(-1, Convert.FromBase64String(xml.Element(PALETTE).Value));
                }
            }
            else
            {
                ImagePalette = null;
            }

            Images = new Dictionary <string, KartImage>();

            XElement images = xml.Element(IMAGES);

            foreach (XElement image in images.Elements())
            {
                string           name        = image.Attribute(IMAGE_NAME).Value.ToString();
                List <MK64Image> mkImages    = new List <MK64Image>();
                XElement         innerImages = image.Element(IMAGES);
                foreach (XElement innerImage in innerImages.Elements())
                {
                    mkImages.Add(new MK64Image(innerImage, ImagePalette));
                }
                KartImage kartImage = new KartImage(mkImages);

                Images.Add(name, kartImage);
            }
        }