Exemple #1
0
        public static void ClearScreen(bool resetGrid = true)
        {
            ScreenShapes.DrawRectangle(0, 0, Eight.RealWidth, Eight.RealHeight, BackgroundColor);

            if (resetGrid)
            {
                Display.TextGrid = Enumerable.Repeat(Utils.ToULong(' ', ForegroundColor, BackgroundColor), Display.TextGrid.Length).ToArray();
            }
            Display.TextFlags = new byte[Display.TextFlags.Length];

            Display.Dirty = true;
        }
Exemple #2
0
        public static unsafe void DrawChar(char c, int x, int y, int fg, int bg)
        {
            if (Eight.IsQuitting)
            {
                return;
            }

            if (x < 0 || y < 0 || x >= Eight.WindowWidth || y >= Eight.WindowHeight)
            {
                return;
            }

            var flag = (Utils.TextFlag)Display.TextFlags[x + y * Eight.WindowWidth];

            if (flag.HasFlag(Utils.TextFlag.Reversed))
            {
                var fgc = fg;
                fg = bg;
                bg = fgc;
            }

            if (flag.HasFlag(Utils.TextFlag.Blinking) && Display.BlinkOn)
            {
                var fgc = fg;
                fg = bg;
                bg = fgc;
            }

            var bgc = Color.FromArgb(bg);

            if (c >= Display.TextFont.CharList.Length)
            {
                c = '?';
            }
            var matrix = Display.TextFont.CharList[c];

            if (matrix == null)
            {
                matrix = Display.TextFont.CharList['?'];
            }

            var bgRectangle = new SDL_Rect {
                x = (x * Eight.CellWidth),
                y = (y * Eight.CellHeight),
                w = Eight.CellWidth,
                h = Eight.CellHeight,
            };

            // Draw BG
            SDL_FillRect(Display.Surface, ref bgRectangle, SDL_MapRGB(((SDL_Surface *)Display.Surface)->format, bgc.R, bgc.G, bgc.B));

            // Draw char
            int deltaX = (Eight.CellWidth - matrix.GetLength(1)) / 2;

            for (int gy = 0; gy < matrix.GetLength(0); gy++)
            {
                for (int gx = 0; gx < matrix.GetLength(1); gx++)
                {
                    if (matrix[gy, gx])
                    {
                        ScreenShapes.DrawPixel(gx + (x * Eight.CellWidth) + deltaX, gy + (y * Eight.CellHeight), fg);
                    }
                }
            }

            // Draw flags
            if (flag.HasFlag(Utils.TextFlag.Underlined))
            {
                ScreenShapes.DrawRectangle(x * Eight.CellWidth, y * Eight.CellHeight + Eight.CellHeight - 1, Eight.CellWidth, 1, fg);
            }

            if (flag.HasFlag(Utils.TextFlag.Strikethrough))
            {
                ScreenShapes.DrawRectangle(x * Eight.CellWidth, y * Eight.CellHeight + Eight.CellHeight / 2, Eight.CellWidth, 1, fg);
            }

            Display.Dirty = true;
        }