Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        /// <param name="hle"></param>
        protected virtual void LoadHighSprites(XmlElement e, XmlElement hle)
        {
            Picture pic = GetPicture(hle, "HL");

            if (pic == null || hle.Attributes["src"] == null)
            {
                throw new FormatException("highlight picture not found.");
            }
            string baseFileName = XmlUtil.Resolve(hle, hle.Attributes["src"].Value).LocalPath;

            using (Bitmap bit = new Bitmap(baseFileName))
            {
                for (int i = 0; i < hl_patterns; i++)
                {
                    hilights[i] = new SpriteSet(8);
                }

                XmlNode cn = e.FirstChild;
                while (cn != null)
                {
                    if (cn.Name.Equals("pattern"))
                    {
                        SideStored ss   = ParseSide(cn);
                        Direction  d    = ParseDirection(cn);
                        Point      orgn = XmlUtil.ParsePoint(cn.Attributes["origin"].Value);
                        Point      offF = GetOffset(d, PlaceSide.Fore);
                        Point      offB = GetOffset(d, PlaceSide.Back);
                        Size       sz   = new Size(24, 8 + height * 16);

                        // create highlight patterns
                        XmlNode hlp = cn.SelectSingleNode("highlight");
                        if (hlp != null)
                        {
                            HueShiftSpriteFactory factory = new HueShiftSpriteFactory(hl_patterns);
                            if ((ss & SideStored.Fore) != 0)
                            {
                                ISprite[] arr = factory.CreateSprites(bit, pic, offF, orgn, sz);
                                for (int i = 0; i < hl_patterns; i++)
                                {
                                    hilights[i][d, PlaceSide.Fore] = arr[i];
                                }
                            }
                            if ((ss & SideStored.Back) != 0)
                            {
                                ISprite[] arr = factory.CreateSprites(bit, pic, offB, orgn, sz);
                                for (int i = 0; i < hl_patterns; i++)
                                {
                                    hilights[i][d, PlaceSide.Back] = arr[i];
                                }
                            }
                        }
                    } //if(cn.Name.Equals("pattern"))
                    cn = cn.NextSibling;
                }     //while
            }         //using
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        /// <param name="ep"></param>
        protected virtual void LoadSprites(XmlElement e, XmlElement ep)
        {
            Picture pic = GetPicture(ep, null);
            XmlNode cn  = e.FirstChild;

            while (cn != null)
            {
                if (cn.Name.Equals("pattern"))
                {
                    SideStored ss   = ParseSide(cn);
                    Direction  d    = ParseDirection(cn);
                    Point      orgn = XmlUtil.ParsePoint(cn.Attributes["origin"].Value);
                    Point      offF = GetOffset(d, PlaceSide.Fore);
                    Point      offB = GetOffset(d, PlaceSide.Back);
                    Size       sz   = new Size(24, 8 + height * 16);
                    if (variation != null)
                    {
                        for (int i = 0; i < colors.size; i++)
                        {
                            Color  c = colors[i];
                            string v = c.R.ToString() + "," + c.G.ToString() + "," + c.B.ToString();
                            variation.Attributes["to"].Value = v;
                            SpriteFactory factory = new HueTransformSpriteFactory(e);
                            if ((ss & SideStored.Fore) != 0)
                            {
                                sprites[i][d, PlaceSide.Fore] = factory.CreateSprite(pic, offF, orgn, sz);
                            }
                            if ((ss & SideStored.Back) != 0)
                            {
                                sprites[i][d, PlaceSide.Back] = factory.CreateSprite(pic, offB, orgn, sz);
                            }
                        }
                    }
                    else
                    {
                        SpriteFactory factory = new SimpleSpriteFactory();
                        if ((ss & SideStored.Fore) != 0)
                        {
                            sprites[0][d, PlaceSide.Fore] = factory.CreateSprite(pic, offF, orgn, sz);
                        }
                        if ((ss & SideStored.Back) != 0)
                        {
                            sprites[0][d, PlaceSide.Back] = factory.CreateSprite(pic, offB, orgn, sz);
                        }
                    }
                }
                cn = cn.NextSibling;
            }
        }