예제 #1
0
        public int[] GetPreview(Glyph[] font, int[] palette, char[] text, bool shadow)
        {
            this.font    = font;
            this.palette = palette;
            int[] pixels = new int[256 * 16];

            // While there are more characters to draw
            for (int i = 0, c = 0; i < text.Length; i++)
            {
                if (text[i] >= 0x20 && text[i] <= 0x9F)
                {
                    int   width       = font[text[i] - 32].Width;
                    int   maxWidth    = font[text[i] - 32].MaxWidth;
                    int[] glyphPixels = font[text[i] - 32].GetPixels(palette);
                    int   left        = (maxWidth - width) / 2;

                    // 12 rows per character
                    for (int y = 0, b = 1; y < 12; y++, b++)
                    {
                        for (int x = 0, a = shadow ? c + 1 : c + left + 1; x < 8; x++, a++) // # of pixels per row
                        {
                            if (pixels[b * 256 + a] == 0)
                            {
                                pixels[b * 256 + a] = glyphPixels[y * maxWidth + x];
                            }
                        }
                    }
                    if (shadow)
                    {
                        c += Math.Max(font[text[i] - 32].GetRightMostPixel(palette), width + 1);
                    }
                    else
                    {
                        c += 8;
                    }
                }
            }
            if (shadow)
            {
                Do.DrawShadow(pixels, 256, palette[3]);
            }
            else
            {
                Do.DrawBorder(pixels, 256, palette[3]);
            }

            // Finished
            return(pixels);
        }
예제 #2
0
        // accessor functions
        public int[] GetPreview(Glyph[] font, Glyph[] triangles,
                                int[] palette, int[] palette_t, char[] text, int left)
        {
            this.font      = font;
            this.triangles = triangles;
            this.palette   = palette;
            this.palette_t = palette_t;
            //
            drawOptions   = new bool[3];
            drawPageBreak = false;
            location      = new Point(left + 1, 6);
            //
            text = ConvertSpecialCases(text);
            int offset = GetOffset(text, left);

            location = new Point(left + 1, 6);
            if (text.Length <= pages.Peek() + 1)
            {
                PageUp();
            }
            //
            int line = 0;

            int[]     pixels = new int[256 * 56];
            ArrayList words  = new ArrayList();

            AddWords(words, text, offset);
            foreach (List <char> word in words)
            {
                int wordWidth = WordWidth(word);
                if (location.X + wordWidth >= 256 - left)
                {
                    if (line == 2)
                    {
                        next = lineOffset[1];
                        Do.DrawBorder(pixels, 256, palette[3]);
                        AddTriangles(pixels);
                        return(pixels);
                    }
                    line++;
                    lineOffset[line] = offset + 1;
                    location.X       = left + 1; location.Y += 16;
                }
                foreach (char l in word)
                {
                    if (l >= 0x20 && l <= 0x9F)
                    {
                        int   height      = font[l - 32].Height;
                        int   width       = font[l - 32].Width;
                        int   maxWidth    = font[l - 32].MaxWidth;
                        int[] glyphPixels = font[l - 32].GetPixels(palette);
                        if (location.X + width >= 256 - left)
                        {
                            if (line == 2)
                            {
                                next = lineOffset[1];
                                Do.DrawBorder(pixels, 256, palette[3]);
                                AddTriangles(pixels);
                                return(pixels);
                            }
                            line++;
                            lineOffset[line] = offset + 1;
                            location.X       = left + 1; location.Y += 16;
                            break;
                        }
                        for (int y = 0, b = location.Y; y < height; y++, b++)    // 12 rows per character
                        {
                            for (int x = 0, a = location.X; x < width; x++, a++) // # of pixels per row
                            {
                                pixels[b * 256 + a] = glyphPixels[y * maxWidth + x];
                            }
                        }
                        location.X += width + 1;
                    }
                    else
                    {
                        switch ((byte)l)
                        {
                        case 0x00: goto case 0x06;     // End String Press A

                        case 0x06:
                            Do.DrawBorder(pixels, 256, palette[3]);
                            AddTriangles(pixels);
                            return(pixels);

                        case 0x01:     // Line Break
                        case 0x02:
                            if (line == 2)
                            {
                                next = lineOffset[1];
                                Do.DrawBorder(pixels, 256, palette[3]);
                                AddTriangles(pixels);
                                return(pixels);
                            }
                            line++;
                            lineOffset[line] = offset + 1;
                            location.X       = left + 1; location.Y += 16;
                            break;

                        case 0x03:      // Page Break Press A
                            drawPageBreak = true;
                            goto case 0x04;

                        case 0x04:
                            offset++;
                            next = offset;
                            Do.DrawBorder(pixels, 256, palette[3]);
                            AddTriangles(pixels);
                            return(pixels);

                        case 0x07: drawOptions[line] = true; break;

                        default: break;
                        }
                    }
                    offset++;
                }
            }
            Do.DrawBorder(pixels, 256, palette[3]);
            AddTriangles(pixels);
            return(pixels);
        }
예제 #3
0
        public int[] GetPreview(Glyph[] font, int[] palette, char[] text, bool menu, bool allowclipping)
        {
            this.font    = font;
            this.palette = palette;
            //
            int offset = GetOffset(text, menu);

            if (text.Length <= pages.Peek() + 1)
            {
                PageUp();
            }
            //
            location = new Point(9, 11);
            int[] pixels = new int[256 * 32];
            while (offset != text.Length)
            {
                if (text[offset] >= 0x20 && text[offset] <= 0x9F)
                {
                    if (location.X + font[text[offset] - 32].Width >= 256)
                    {
                        Do.DrawBorder(pixels, 256, palette[3]);
                        return(pixels);
                    }
                    int width;
                    if (!allowclipping)
                    {
                        width = MinimumWidth(font[text[offset] - 32]);
                    }
                    else
                    {
                        width = font[text[offset] - 32].Width;
                    }
                    int   maxWidth    = font[text[offset] - 32].MaxWidth;
                    int[] glyphPixels = font[text[offset] - 32].GetPixels(palette);
                    for (int y = 0, b = location.Y; y < 12; y++, b++)        // 12 rows per character
                    {
                        for (int x = 0, a = location.X; x < width; x++, a++) // # of pixels per row
                        {
                            pixels[b * 256 + a] = glyphPixels[y * maxWidth + x];
                        }
                    }
                    location.X += width + 1;
                }
                else if (!menu)
                {
                    switch ((byte)text[offset])
                    {
                    case 0x00:     // END (End string)
                        offset++;
                        Do.DrawBorder(pixels, 256, palette[3]);
                        return(pixels);

                    case 0x01:     // BREAK (Line break)
                        offset++;
                        next = offset;
                        Do.DrawBorder(pixels, 256, palette[3]);
                        return(pixels);

                    case 0x1C:
                        offset++;
                        break;

                    default: break;
                    }
                }
                offset++;
            }
            Do.DrawBorder(pixels, 256, palette[3]);
            return(pixels);
        }
예제 #4
0
        // Constructor
        public int[] GetPreview(Glyph[] font, int[] palette, char[] dlg, Size size, Point location, int lines)
        {
            this.font    = font;
            this.palette = palette;
            this.size    = size;
            int   charPtr = 0, line = 0;
            Point point = new Point(location.X, location.Y);

            int[] pixels = new int[size.Width * size.Height];
            while (charPtr != dlg.Length) // while there is more characters to draw
            {
                if (dlg[charPtr] >= 0x20 && dlg[charPtr] <= 0x9F)
                {
                    int   width       = font[dlg[charPtr] - 32].Width;
                    int   maxWidth    = font[dlg[charPtr] - 32].MaxWidth;
                    int[] glyphPixels = font[dlg[charPtr] - 32].GetPixels(palette);
                    int   m           = 0;                                 // the counter for adding to the x coord
                    for (int x = 0, a = point.X; x < width; x++, a++, m++) // # of pixels per row
                    {
                        for (int y = 0, b = point.Y; y < 8; y++, b++)      // 12 rows per character
                        {
                            // if past max width, start new line
                            if (point.X + x > size.Width - location.X)
                            {
                                point.Y += 8; b += 8;
                                point.X  = location.X + 1; a = location.X + 1;
                                m        = 0; line++;
                            }
                            // if past max lines, end drawing
                            if (line >= lines)
                            {
                                Do.DrawBorder(pixels, size.Width, palette[3]);
                                return(pixels);
                            }
                            pixels[b * size.Width + a] = glyphPixels[y * maxWidth + x];
                        }
                    }
                    point.X += m;
                }
                else
                {
                    switch ((byte)dlg[charPtr])
                    {
                    case 0x00:     // END (End string)
                        charPtr++;
                        Do.DrawBorder(pixels, size.Width, palette[3]);
                        return(pixels);

                    case 0x01:     // BREAK (Line break)
                        line++;
                        point.Y += 8; point.X = location.X;
                        break;

                    default: break;
                    }
                }
                charPtr++;
            }
            Do.DrawBorder(pixels, size.Width, palette[3]);
            return(pixels);
        }