示例#1
0
 private void LoadAnsi()
 {
     _textSurface.Clear();
     SadConsole.Ansi.Document   doc    = new SadConsole.Ansi.Document($"./ansi/{files[fileIndex]}");
     SadConsole.Ansi.AnsiWriter writer = new SadConsole.Ansi.AnsiWriter(doc, this);
     writer.ReadEntireDocument();
     Data   = new TextSurface(80, 25 + _textSurface.TimesShiftedUp);
     writer = new SadConsole.Ansi.AnsiWriter(doc, this);
     writer.ReadEntireDocument();
 }
示例#2
0
        public AnsiConsole()
            : base(80, 25)
        {
            IsVisible = false;
            CanUseKeyboard = true;
            //files = SadConsole.Serializer.Load<string[]>("./ansi/files.json");
            files = System.IO.Directory.GetFiles("./ansi");

            NextAnsi();
            LoadAnsi();

            KeyboardHandler = (cons, info) =>
            {

                if (info.IsKeyDown(Keys.Left))
                    cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left - 1, cons.TextSurface.RenderArea.Top, 80, 25);

                if (info.IsKeyDown(Keys.Right))
                    cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left + 1, cons.TextSurface.RenderArea.Top, 80, 25);

                if (info.IsKeyDown(Keys.Up))
                    cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left, cons.TextSurface.RenderArea.Top - 1, 80, 25);

                if (info.IsKeyDown(Keys.Down))
                    cons.TextSurface.RenderArea = new Rectangle(cons.TextSurface.RenderArea.Left, cons.TextSurface.RenderArea.Top + 1, 80, 25);

                if (info.IsKeyReleased(Keys.Space))
                {
                    NextAnsi();
                    LoadAnsi();
                }

                if (info.IsKeyReleased(Keys.L))
                {
                    if (writer == null || lineCounter == lines.Length)
                    {
                        NextAnsi();
                        lineCounter = 0;
                        Clear();
                        lines = doc.AnsiString.Split('\n');
                        writer = new SadConsole.Ansi.AnsiWriter(doc, this);
                    }

                    writer.AnsiReadLine(lines[lineCounter], true);

                    lineCounter++;

                    if (lineCounter > lines.Length)
                        writer = null;
                }

                return true;
            };
        }
示例#3
0
 private void LoadAnsi()
 {
     Clear();
     writer = new SadConsole.Ansi.AnsiWriter(doc, this);
     writer.ReadEntireDocument();
     TextSurface = new BasicSurface(80, 25 + TimesShiftedUp);
     writer      = new SadConsole.Ansi.AnsiWriter(doc, this);
     writer.ReadEntireDocument();
     textSurface.RenderArea = new Rectangle(0, 0, 80, 25);
     writer = null;
 }
示例#4
0
        public override bool ProcessKeyboard(SadConsole.Input.Keyboard info)
        {
            if (info.IsKeyDown(Keys.Left))
            {
                ViewPort = new Rectangle(ViewPort.Left - 1, ViewPort.Top, 80, 23);
            }

            if (info.IsKeyDown(Keys.Right))
            {
                ViewPort = new Rectangle(ViewPort.Left + 1, ViewPort.Top, 80, 23);
            }

            if (info.IsKeyDown(Keys.Up))
            {
                ViewPort = new Rectangle(ViewPort.Left, ViewPort.Top - 1, 80, 23);
            }

            if (info.IsKeyDown(Keys.Down))
            {
                ViewPort = new Rectangle(ViewPort.Left, ViewPort.Top + 1, 80, 23);
            }

            if (info.IsKeyReleased(Keys.Space))
            {
                NextAnsi();
                LoadAnsi();
            }

            if (info.IsKeyReleased(Keys.L))
            {
                if (writer == null || lineCounter == lines.Length)
                {
                    NextAnsi();
                    lineCounter = 0;
                    Clear();
                    lines  = doc.AnsiString.Split('\n');
                    writer = new SadConsole.Ansi.AnsiWriter(doc, this);
                }

                writer.AnsiReadLine(lines[lineCounter], true);

                lineCounter++;

                if (lineCounter > lines.Length)
                {
                    writer = null;
                }
            }

            return(true);
        }
示例#5
0
        public override bool ProcessKeyboard(SadConsole.Input.Keyboard info)
        {
            if (info.IsKeyDown(Keys.Left))
            {
                View = View.WithPosition(new Point(View.Position.X - 1, View.Position.Y));
            }

            if (info.IsKeyDown(Keys.Right))
            {
                View = View.WithPosition(new Point(View.Position.X + 1, View.Position.Y));
            }

            if (info.IsKeyDown(Keys.Up))
            {
                View = View.WithPosition(new Point(View.Position.X, View.Position.Y - 1));
            }

            if (info.IsKeyDown(Keys.Down))
            {
                View = View.WithPosition(new Point(View.Position.X, View.Position.Y + 1));
            }

            if (info.IsKeyReleased(Keys.Space))
            {
                NextAnsi();
                LoadAnsi();
            }

            if (info.IsKeyReleased(Keys.L))
            {
                if (writer == null || lineCounter == lines.Length)
                {
                    NextAnsi();
                    lineCounter = 0;
                    this.Clear();
                    lines  = doc.AnsiString.Split('\n');
                    writer = new SadConsole.Ansi.AnsiWriter(doc, this);
                }

                writer.AnsiReadLine(lines[lineCounter], true);

                lineCounter++;

                if (lineCounter > lines.Length)
                {
                    writer = null;
                }
            }

            return(true);
        }
示例#6
0
        private void LoadAnsi()
        {
            Clear();

            ansiSurface = new ScrollingConsole(80, 25);
            writer      = new SadConsole.Ansi.AnsiWriter(doc, ansiSurface);
            writer.ReadEntireDocument();

            Resize(80, ansiSurface.Height + ansiSurface.TimesShiftedUp, true);
            ViewPort = new Rectangle(0, 0, 80, 25);

            writer = new SadConsole.Ansi.AnsiWriter(doc, this);
            writer.ReadEntireDocument();
            writer = null;
        }
示例#7
0
        public StartScreen(int screenWidth, int screenHeight)
        {
            _screenWidth   = screenWidth;
            _screenHeight  = screenHeight;
            _currentPoints = Data.Entities.GetChargenPoints();
            UseMouse       = true;
            var bgTxt     = new CellSurface(80, 60);
            var ansiTitle = new SadConsole.Ansi.AnsiWriter(FileLoader.TitleScreen, bgTxt);

            ansiTitle.ReadEntireDocument();
            ansiTitle.Process(0);
            SetupViews(screenWidth, screenHeight, bgTxt);
            SetupTraitCheckBoxes();
            RegisterEvents();
        }
示例#8
0
        private void LoadAnsi()
        {
            this.Clear();

            ansiSurface = new Console(80, 25);
            writer      = new SadConsole.Ansi.AnsiWriter(doc, ansiSurface);
            writer.ReadEntireDocument();

            // TODO: Why did I need to add + 2? Wierd. Something broken with ansi :( :( :(
            this.Resize(80, 23, 80, ansiSurface.Height + ansiSurface.TimesShiftedUp + 2, true);
            this.View = new Rectangle(0, 0, 80, 25);

            writer = new SadConsole.Ansi.AnsiWriter(doc, this);
            writer.ReadEntireDocument();
            writer = null;
        }
示例#9
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            System.Drawing.Graphics graphics = e.Graphics;

            SadConsole.FontMaster.LoadFont("IBM.font"); // Sets default font if not set

            var textSurface = new SadConsole.Consoles.TextSurface(80, 24);
            var console     = new SadConsole.Consoles.SurfaceEditor(textSurface);
            var renderer    = new SadConsole.Consoles.TextSurfaceRenderer();

            var doc    = new SadConsole.Ansi.Document("QS-SIERR.ANS");
            var writer = new SadConsole.Ansi.AnsiWriter(doc, console);

            writer.ReadEntireDocument();

            // Get times scrolled
            if (console.TimesShiftedUp != 0)
            {
                textSurface.Dispose();
                console.TextSurface = textSurface = new SadConsole.Consoles.TextSurface(80, 24 + console.TimesShiftedUp);

                console.ClearShiftValues();

                writer = new SadConsole.Ansi.AnsiWriter(doc, console);
                writer.ReadEntireDocument();
            }

            // Create graphics image
            //Bitmap outputImage = new Bitmap(console.TextSurface.Width * SadConsole.FontMaster.DefaultFont.Size.X,
            //                                 console.TextSurface.Height * SadConsole.FontMaster.DefaultFont.Size.Y);
            //Graphics graphics = Graphics.FromImage(outputImage);
            graphics.Clear(Color.Black);

            // Draw ansi surface to image
            renderer.RenderTarget = graphics;
            renderer.Render((SadConsole.Consoles.TextSurface)console.TextSurface, new Point(0, 0), false);

            // Save image
            //outputImage.Save("ansi.png", ImageFormat.Png);

            // Clean up
            //graphics.Dispose();
            //outputImage.Dispose();
            textSurface.Dispose();
        }
示例#10
0
 private void LoadAnsi()
 {
     Clear();
     writer = new SadConsole.Ansi.AnsiWriter(doc, this);
     writer.ReadEntireDocument();
     TextSurface = new TextSurface(80, 25 + TimesShiftedUp);
     writer = new SadConsole.Ansi.AnsiWriter(doc, this);
     writer.ReadEntireDocument();
     textSurface.RenderArea = new Rectangle(0, 0, 80, 25);
     writer = null;
 }
示例#11
0
        public AnsiConsole() : base(80, 23)
        {
            IsVisible   = false;
            UseKeyboard = true;
            //files = SadConsole.Serializer.Load<string[]>("./ansi/files.json");
            files = System.IO.Directory.GetFiles("./ansi").Where(f => !f.EndsWith("json")).ToArray();

            NextAnsi();
            LoadAnsi();

            KeyboardHandler = (cons, info) =>
            {
                if (info.IsKeyDown(Keys.Left))
                {
                    cons.ViewPort = new Rectangle(cons.ViewPort.Left - 1, cons.ViewPort.Top, 80, 23);
                }

                if (info.IsKeyDown(Keys.Right))
                {
                    cons.ViewPort = new Rectangle(cons.ViewPort.Left + 1, cons.ViewPort.Top, 80, 23);
                }

                if (info.IsKeyDown(Keys.Up))
                {
                    cons.ViewPort = new Rectangle(cons.ViewPort.Left, cons.ViewPort.Top - 1, 80, 23);
                }

                if (info.IsKeyDown(Keys.Down))
                {
                    cons.ViewPort = new Rectangle(cons.ViewPort.Left, cons.ViewPort.Top + 1, 80, 23);
                }

                if (info.IsKeyReleased(Keys.Space))
                {
                    NextAnsi();
                    LoadAnsi();
                }

                if (info.IsKeyReleased(Keys.L))
                {
                    if (writer == null || lineCounter == lines.Length)
                    {
                        NextAnsi();
                        lineCounter = 0;
                        Clear();
                        lines  = doc.AnsiString.Split('\n');
                        writer = new SadConsole.Ansi.AnsiWriter(doc, this);
                    }

                    writer.AnsiReadLine(lines[lineCounter], true);

                    lineCounter++;

                    if (lineCounter > lines.Length)
                    {
                        writer = null;
                    }
                }

                return(true);
            };
        }