public KartInfo(XElement xml) { KartName = xml.Attribute(NAME).Value; OriginalKart = bool.Parse(xml.Attribute(ORIGINAL).Value); XElement imagePoolElement = xml.Element(KartImagePool.KART_IMAGE_POOL); if (imagePoolElement != null) { KartImages = new KartImagePool(imagePoolElement); } else { KartImages = new KartImagePool(); } KartAnimations = new List <KartAnimationSeries>(); KartPortraits = new List <MK64Image>(); XElement animations = xml.Element(ANIMATIONS); foreach (XElement animation in animations.Elements()) { string name = animation.Attribute(NAME).Value; KartAnimationSeries newAnim = new KartAnimationSeries(name); newAnim.KartAnimationType = int.Parse(animation.Attribute(ANIMATION_TYPE).Value); foreach (XElement image in animation.Elements()) { newAnim.OrderedImageNames.Add(image.Attribute(IMAGE_NAME).Value); } KartAnimations.Add(newAnim); } XElement portraits = xml.Element(PORTRAITS); foreach (XElement portrait in portraits.Elements()) { KartPortraits.Add(new MK64Image(portrait)); } XElement namePlate = xml.Element(NAME_PLATE); //byte[] namePlateData = Convert.FromBase64String(namePlate.Value); //ushort namePlateAlpha = ushort.Parse(namePlate.Attribute(NAME_PLATE_ALPHA).Value); KartNamePlate = new MK64Image(namePlate.Elements().First()); //if (RomProject.Instance.Files[0].HasElementExactlyAt(namePlateOffset)) //{ // N64DataElement element = RomProject.Instance.Files[0].GetElementAt(namePlateOffset); // if (element is TKMK00Block) // { // KartNamePlate = (TKMK00Block)element; // } //} }
//Duplicate copy public KartInfo(string kartName, KartInfo baseKart) { KartName = kartName; KartImages = new KartImagePool(baseKart.KartImages.ImagePalette); foreach (string key in baseKart.KartImages.Images.Keys) { KartImages.Images.Add(key, baseKart.KartImages.Images[key]); } KartAnimations = new List <KartAnimationSeries>(); foreach (KartAnimationSeries anim in baseKart.KartAnimations) { KartAnimationSeries newAnim = new KartAnimationSeries(anim.Name); newAnim.KartAnimationType = anim.KartAnimationType; newAnim.OrderedImageNames.AddRange(anim.OrderedImageNames); KartAnimations.Add(newAnim); } KartPortraits = new List <MK64Image>(); foreach (MK64Image block in baseKart.KartPortraits) { KartPortraits.Add(block); } KartNamePlate = baseKart.KartNamePlate; OriginalKart = false; }