示例#1
0
        private void UpdatePreview()
        {
            int        pal          = (int)palSelector.Value;
            BitmapBits levelImg8bpp = new BitmapBits(maxwidth * 8, Lines.Length * texmap.Height * 8);
            int        y            = 0;

            for (int l = 0; l < Lines.Length; l++)
            {
                int x = 0;
                for (int i = 0; i < Lines[l].Length; i++)
                {
                    CharMapInfo cm = texmap.Characters[Lines[l][i]];
                    int         w  = cm.Width ?? texmap.DefaultWidth;
                    for (int y2 = 0; y2 < texmap.Height; y2++)
                    {
                        for (int x2 = 0; x2 < w; x2++)
                        {
                            levelImg8bpp.DrawBitmap(LevelData.TileToBmp8bpp(LevelData.TileArray, cm.Map[x2, y2], pal), (x + x2) * 8, (y + y2) * 8);
                        }
                    }
                    x += w;
                }
                y += texmap.Height;
            }
            pictureBox1.Image = levelImg8bpp.ToBitmap(LevelData.BmpPal);
        }
示例#2
0
        public TextMapping(string map)
        {
            Height       = 1;
            DefaultWidth = 1;
            Characters   = new Dictionary <char, CharMapInfo>();
            int    i    = 0;
            ushort tile = 0;

            while (i < map.Length)
            {
                char start = map[i++];
                char?end   = null;
                if (i < map.Length && map[i] == '-')
                {
                    ++i;
                    end = map[i++];
                }
                if (i < map.Length && map[i] == ':')
                {
                    ++i;
                    int    pipe = map.IndexOf('|', i);
                    string num;
                    if (pipe == -1)
                    {
                        num = map.Substring(i);
                    }
                    else
                    {
                        num = map.Substring(i, pipe - i);
                    }
                    i += num.Length;
                    if (num.StartsWith("0x"))
                    {
                        tile = ushort.Parse(num.Substring(2), NumberStyles.HexNumber);
                    }
                    else
                    {
                        tile = ushort.Parse(num, NumberStyles.Integer, NumberFormatInfo.InvariantInfo);
                    }
                }
                if (end.HasValue)
                {
                    for (char c = start; c <= end.Value; c++)
                    {
                        Characters[c] = new CharMapInfo()
                        {
                            Map = new ushort[1, 1] {
                                { tile++ }
                            }
                        }
                    }
                }
                ;