示例#1
0
        public ViewsAndSubViews()
        {
            titleAndLine = new Console(80, 25);
            mainView = new Console(59, 24);
            subView = new Console(19, 24);

            IsVisible = false;

            // Draw border and line stuff
            titleAndLine.Print(0, 0, " View and Sub View".Align(System.Windows.HorizontalAlignment.Left, 80), ColorHelper.GreenYellow, ColorHelper.DarkGreen);
            SadConsole.Shapes.Line line = new SadConsole.Shapes.Line();
            line.UseStartingCell = false;
            line.UseEndingCell = false;
            line.CellAppearance.GlyphIndex = 179;
            line.StartingLocation = new Point(59, 1);
            line.EndingLocation = new Point(59, 24);
            line.Draw(titleAndLine);

            // Setup main view
            mainView.Position = new Point(0, 1);
            mainView.Print(1, 1, "Click on a cell to draw");
            mainView.MouseMove += (s, e) => { if (e.LeftButtonDown) e.Cell.Background = Color.Blue; };

            // Setup sub view
            subView.Position = new Point(60, 1);
            subView.TextSurface = new TextSurfaceView(mainView.TextSurface, new Rectangle(0, 0, 20, 24));
            subView.MouseMove += (s, e) => { if (e.LeftButtonDown) e.Cell.Background = Color.Red; };

            // Ad the consoles to the list.
            Add(titleAndLine);
            Add(mainView);
            Add(subView);
        }
示例#2
0
        public Status() : base(30, 30)
        {
            // Setup some fake status
            Print(1, 0, "SadConsole + RogueSharp".Align(System.Windows.HorizontalAlignment.Center, 29).CreateGradient(Color.Moccasin, Color.Gray, null));

            Print(2, 2, "Health", Color.GreenYellow);
            Print(10, 2, new string((char)176, 19).CreateGradient(Color.Red, Color.GreenYellow, null));

            Print(2, 4, "Energy", Color.GreenYellow);
            Print(10, 4, new string((char)176, 19).CreateGradient(Color.Blue, Color.GreenYellow, null));


            // Draw a line down the side
            SadConsole.Shapes.Line line = new SadConsole.Shapes.Line();
            line.StartingLocation = new Point(0, 0);
            line.EndingLocation   = new Point(0, 29);
            new CellAppearance(Color.LightGray, Color.Black, 186, Microsoft.Xna.Framework.Graphics.SpriteEffects.None).CopyAppearanceTo(line.CellAppearance);
            line.UseEndingCell   = false;
            line.UseStartingCell = false;
            line.Draw(this);


            // Position the console to the right of the map view
            Position = new Microsoft.Xna.Framework.Point(30, 0);
        }
示例#3
0
        public StringParsingConsole() : base(80, 23)
        {
            IsVisible   = false;
            UseKeyboard = false;
            textSurface.DefaultForeground = ColorAnsi.White;
            Clear();
            int c = 59;
            int r = 1;

            ColoredString.CustomProcessor = CustomParseCommand;


            Print(1, r, "[c:r f:ansibluebright][c:r b:ansiblue]String parsing supports...                                                    ");
            SetGlyph(0, r, 221, Color.Black, ColorAnsi.Blue);

            r = 2;
            Color a = Color.Green;

            Print(1, ++r, "[c:r f:DodgerBlue]1.[c:r f:White] Multi-colored [c:r f:yellow]str[c:r f:red]ings");
            r++;
            Print(1, ++r, "[c:r f:DodgerBlue]2.[c:r f:White] You color the backgrounds: [c:r f:black][c:r b:Purple] Purple [c:u] [c:r b:Cyan] Cyan ");
            r++;
            Print(1, ++r, "[c:r f:DodgerBlue]3.[c:r f:White] [c:g f:LimeGreen:Orange:9]Gradients are [c:g b:Black:Red:Yellow:Red:Black:15]easily supported");
            r++;
            Print(1, ++r, "[c:r f:DodgerBlue]4.[c:r f:White] You [c:b 3]can apply [c:b 5:0.17]blink effects.");
            r++;
            Print(1, ++r, "[c:r f:DodgerBlue]5.[c:r f:White] You set [c:r f:greenyellow:9]mirroring [c:m 1]on any [c:m 2]text [c:u][c:u]you want.");

            r += 2;
            Print(1, r, "[c:r f:ansibluebright][c:r b:ansiblue]Examples                                                                      ");
            SetGlyph(0, r, 221, Color.Black, ColorAnsi.Blue);

            r += 2;

            SadConsole.Shapes.Line line = new SadConsole.Shapes.Line();
            line.StartingLocation = new Point(c, r);
            line.EndingLocation   = new Point(c, r + 5);
            line.UseEndingCell    = false;
            line.UseStartingCell  = false;
            line.Cell.Glyph       = 179;
            line.Draw(this);

            Print(1, r, "Some `[c:r f:red]text`[c:u] to print                       ");
            Print(c + 2, r, $"Some [c:r f:{Color.Red.ToParser()}]text[c:u] to print");

            Print(1, ++r, "Some `[c:r f:100,100,33]text`[c:u] to print");
            Print(c + 2, r, "Some [c:r f:255,255,0]text[c:u] to print");

            Print(1, ++r, "Some `[c:r b:ansiblackbright]text to `[c:r f:white]print");
            Print(c + 2, r, "Some [c:r b:ansiblackbright]text to [c:r f:white]print");

            Print(1, ++r, "`[c:m 1]Some `[c:r f:purple]text to`[c:u] pr`[c:u]int");
            Print(c + 2, r, "[c:m 1]Some [c:r f:purple]text to[c:u] pr[c:u]int");

            Print(1, ++r, "[c:r f:default]`[c:g f:red:green:18]`[c:g b:green:red:18]Some text to print");
            Print(c + 2, r, "[c:g f:red:green:18][c:g b:green:red:18]Some text to print");
        }
示例#4
0
 public CharacterStatusPanel(int width, int height) : base(width, height)
 {
     SadConsole.Shapes.Line line = new SadConsole.Shapes.Line();
     line.EndingLocation            = new Point(0, height - 1);
     line.CellAppearance.GlyphIndex = 179;
     line.UseEndingCell             = false;
     line.UseStartingCell           = false;
     line.Draw(this);
 }
 public MessagesConsole(int width, int height) : base(width, height)
 {
     // Draw the side bar
     SadConsole.Shapes.Line line = new SadConsole.Shapes.Line();
     line.EndingLocation            = new Point(0, height - 1);
     line.CellAppearance.GlyphIndex = 179;
     line.UseEndingCell             = false;
     line.UseStartingCell           = false;
     line.Draw(this);
 }
示例#6
0
 public static void DrawBar(int startX, int startY, int endX, int endY, int GlyphIndex, Console console)
 {
     SadConsole.Shapes.Line line = new SadConsole.Shapes.Line();
     line.StartingLocation          = new Point(startX, startY);
     line.EndingLocation            = new Point(endX, endY);
     line.CellAppearance.GlyphIndex = GlyphIndex;
     line.UseEndingCell             = false;
     line.UseStartingCell           = false;
     line.Draw(console);
 }
示例#7
0
        public StringParsingConsole()
            : base(80, 25)
        {
            IsVisible = false;
            textSurface.DefaultForeground = ColorAnsi.White;
            Clear();
            int c = 59;
            int r = 1;

            ColoredString.CustomProcessor = CustomParseCommand;

            Print(1, r, "[c:r f:ansibluebright][c:r b:ansiblue]String parsing supports...                                                    ");
            SetGlyph(0, r, 221, Color.Black, ColorAnsi.Blue);

            r = 2;
            Color a = Color.Green;
            Print(1, ++r, "[c:r f:DodgerBlue]1.[c:r f:White] Multi-colored [c:r f:yellow]str[c:r f:red]ings");
            r++;
            Print(1, ++r, "[c:r f:DodgerBlue]2.[c:r f:White] You color the backgrounds: [c:r f:black][c:r b:Purple] Purple [c:u] [c:r b:Cyan] Cyan ");
            r++;
            Print(1, ++r, "[c:r f:DodgerBlue]3.[c:r f:White] [c:g f:LimeGreen:Orange:9]Gradients are [c:g b:Black:Red:Yellow:Red:Black:15]easily supported");
            r++;
            Print(1, ++r, "[c:r f:DodgerBlue]4.[c:r f:White] You [c:b 3]can apply [c:b 5:0.17]blink effects.");
            r++;
            Print(1, ++r, "[c:r f:DodgerBlue]5.[c:r f:White] You set [c:r f:greenyellow:9]mirroring [c:m 1]on any [c:m 2]text [c:u][c:u]you want.");

            r += 2;
            Print(1, r, "[c:r f:ansibluebright][c:r b:ansiblue]Examples                                                                      ");
            SetGlyph(0, r, 221, Color.Black, ColorAnsi.Blue);

            r += 2;

            SadConsole.Shapes.Line line = new SadConsole.Shapes.Line();
            line.StartingLocation = new Point(c, r);
            line.EndingLocation = new Point(c, r + 5);
            line.UseEndingCell = false;
            line.UseStartingCell = false;
            line.CellAppearance.GlyphIndex = 179;
            line.Draw(this);

            Print(1, r, "Some `[c:r f:red]text`[c:u] to print                       ");
            Print(c + 2, r, $"Some [c:r f:{Color.Red.ToParser()}]text[c:u] to print");

            Print(1, ++r, "Some `[c:r f:100,100,33]text`[c:u] to print");
            Print(c + 2, r, "Some [c:r f:255,255,0]text[c:u] to print");

            Print(1, ++r, "Some `[c:r b:ansiblackbright]text to `[c:r f:white]print");
            Print(c + 2, r, "Some [c:r b:ansiblackbright]text to [c:r f:white]print");

            Print(1, ++r, "`[c:m 1]Some `[c:r f:purple]text to`[c:u] pr`[c:u]int");
            Print(c + 2, r, "[c:m 1]Some [c:r f:purple]text to[c:u] pr[c:u]int");

            Print(1, ++r, "[c:r f:default]`[c:g f:red:green:18]`[c:g b:green:red:18]Some text to print");
            Print(c + 2, r, "[c:g f:red:green:18][c:g b:green:red:18]Some text to print");
        }
示例#8
0
 public CharacterConsole(int width, int height) : base(width, height)
 {
     // Draw the side bar
     SadConsole.Shapes.Line line = new SadConsole.Shapes.Line
     {
         EndingLocation  = new Point(0, height - 1),
         CellAppearance  = { GlyphIndex = 179 },
         UseEndingCell   = false,
         UseStartingCell = false
     };
     line.Draw(this);
 }
示例#9
0
        public BorderedConsole()
            : base(80, 25)
        {
            this.IsVisible = false;

            // Get the default box shape definition. Defines which characters to use for the box.
            SadConsole.Shapes.Box box = SadConsole.Shapes.Box.GetDefaultBox();

            // Customize the box
            box.Foreground       = Color.Blue;
            box.BorderBackground = Color.White;
            box.FillColor        = Color.White;
            box.Fill             = true;
            box.Width            = textSurface.Width;
            box.Height           = textSurface.Height;

            // Draw the box shape onto the CellSurface that this console is displaying.
            box.Draw(this);

            this.Print(3, 1, "Shapes are easily created with only a few lines of code");

            // Get a circle
            SadConsole.Shapes.Circle circle = new SadConsole.Shapes.Circle();
            circle.BorderAppearance = new CellAppearance(ColorHelper.YellowGreen, Color.White, 57);
            circle.Center           = new Point(60, 13);
            circle.Radius           = 10;

            circle.Draw(this);

            // Now time to make a line
            SadConsole.Shapes.Line line = new SadConsole.Shapes.Line();
            line.StartingLocation = new Point(10, 10);
            line.EndingLocation   = new Point(45, 18);
            line.UseEndingCell    = false;
            line.UseStartingCell  = false;
            line.CellAppearance   = new Cell {
                Foreground = ColorHelper.Purple, Background = Color.White, GlyphIndex = 88
            };

            line.Draw(this);
        }
        public ViewsAndSubViews()
        {
            titleAndLine = new Console(80, 25);
            mainView     = new Console(59, 24);
            subView      = new Console(19, 24);

            IsVisible = false;

            // Draw border and line stuff
            titleAndLine.Print(0, 0, " View and Sub View".Align(System.Windows.HorizontalAlignment.Left, 80), ColorHelper.GreenYellow, ColorHelper.DarkGreen);
            SadConsole.Shapes.Line line = new SadConsole.Shapes.Line();
            line.UseStartingCell           = false;
            line.UseEndingCell             = false;
            line.CellAppearance.GlyphIndex = 179;
            line.StartingLocation          = new Point(59, 1);
            line.EndingLocation            = new Point(59, 24);
            line.Draw(titleAndLine);

            // Setup main view
            mainView.Position = new Point(0, 1);
            mainView.Print(1, 1, "Click on a cell to draw");
            mainView.MouseMove += (s, e) => { if (e.LeftButtonDown)
                                              {
                                                  e.Cell.Background = Color.Blue;
                                              }
            };

            // Setup sub view
            subView.Position    = new Point(60, 1);
            subView.TextSurface = new TextSurfaceView(mainView.TextSurface, new Rectangle(0, 0, 20, 24));
            subView.MouseMove  += (s, e) => { if (e.LeftButtonDown)
                                              {
                                                  e.Cell.Background = Color.Red;
                                              }
            };

            // Ad the consoles to the list.
            Add(titleAndLine);
            Add(mainView);
            Add(subView);
        }
示例#11
0
        public BorderedConsole(int width, int height)
            : base(width, height)
        {
            this.IsVisible = false;

            // Get the default box shape definition. Defines which characters to use for the box.
            SadConsole.Shapes.Box box = SadConsole.Shapes.Box.GetDefaultBox();

            // Customize the box
            box.Foreground = Color.Blue;
            box.BorderBackground = Color.White;
            box.FillColor = Color.White;
            box.Fill = true;
            box.Width = width;
            box.Height = height;
            
            // Draw the box shape onto the CellSurface that this console is displaying.
            box.Draw(this.CellData);

            this.CellData.Print(3, 1, "Shapes are easily created with only a few lines of code");

            // Get a circle
            SadConsole.Shapes.Circle circle = new SadConsole.Shapes.Circle();
            circle.BorderAppearance = new CellAppearance(Color.YellowGreen, Color.White, 57);
            circle.Center = new Point(60, 13);
            circle.Radius = 10;

            circle.Draw(this.CellData);

            // Now time to make a line
            SadConsole.Shapes.Line line = new SadConsole.Shapes.Line();
            line.StartingLocation = new Point(10, 10);
            line.EndingLocation = new Point(45, 18);
            line.UseEndingCell = false;
            line.UseStartingCell = false;
            line.CellAppearance = new Cell { Foreground = Color.Purple, Background = Color.White, CharacterIndex = 88 };

            line.Draw(this.CellData);

        }
示例#12
0
        public ViewsAndSubViews()
        {
            mainView = new Console(60, 23);
            subView  = new Console(19, 23);

            IsVisible = false;
            UseMouse  = true;

            //titleAndLine.Print(0, 0, " View and Sub View".Align(System.Windows.HorizontalAlignment.Left, 80), ColorHelper.GreenYellow, ColorHelper.DarkGreen);
            SadConsole.Shapes.Line line = new SadConsole.Shapes.Line();
            line.UseStartingCell  = false;
            line.UseEndingCell    = false;
            line.Cell.Glyph       = 179;
            line.StartingLocation = new Point(59, 0);
            line.EndingLocation   = new Point(59, 22);
            line.Draw(mainView);

            // Setup main view
            mainView.Position   = new Point(0, 2);
            mainView.MouseMove += (s, e) => { if (e.MouseState.Mouse.LeftButtonDown)
                                              {
                                                  e.MouseState.Cell.Background = Color.Blue; mainView.TextSurface.IsDirty = true;
                                              }
            };
            ((BasicSurface)mainView.TextSurface).OnIsDirty = (t) => subView.TextSurface.IsDirty = true;

            // Setup sub view
            subView.Position    = new Point(60, 2);
            subView.TextSurface = new SurfaceView(mainView.TextSurface, new Rectangle(0, 0, 20, 23));
            subView.MouseMove  += (s, e) => { if (e.MouseState.Mouse.LeftButtonDown)
                                              {
                                                  e.MouseState.Cell.Background = Color.Red; subView.TextSurface.IsDirty = true;
                                              }
            };

            // Ad the consoles to the list.
            Children.Add(mainView);
            Children.Add(subView);
        }
示例#13
0
        public Status()
            : base(30, 30)
        {
            // Setup some fake status
            Print(1, 0, "SadConsole + RogueSharp".Align(System.Windows.HorizontalAlignment.Center, 29).CreateGradient(Color.Moccasin, Color.Gray, null));

            Print(2, 2, "Health", Color.GreenYellow);
            Print(10, 2, new string((char)176, 19).CreateGradient(Color.Red, Color.GreenYellow, null));

            Print(2, 4, "Energy", Color.GreenYellow);
            Print(10, 4, new string((char)176, 19).CreateGradient(Color.Blue, Color.GreenYellow, null));

            // Draw a line down the side
            SadConsole.Shapes.Line line = new SadConsole.Shapes.Line();
            line.StartingLocation = new Point(0, 0);
            line.EndingLocation = new Point(0, 29);
            new CellAppearance(Color.LightGray, Color.Black, 186, Microsoft.Xna.Framework.Graphics.SpriteEffects.None).CopyAppearanceTo(line.CellAppearance);
            line.UseEndingCell = false;
            line.UseStartingCell = false;
            line.Draw(this);

            // Position the console to the right of the map view
            Position = new Microsoft.Xna.Framework.Point(30, 0);
        }
示例#14
0
        private void SetAnimationLine(Point mousePosition)
        {
            // Draw the line (erase old) to where the mouse is
            // create the animation frame
            AnimatedTextSurface animation = new AnimatedTextSurface("line", Math.Max(firstPoint.Value.X, mousePosition.X) - Math.Min(firstPoint.Value.X, mousePosition.X) + 1,
                                                                            Math.Max(firstPoint.Value.Y, mousePosition.Y) - Math.Min(firstPoint.Value.Y, mousePosition.Y) + 1,
                                                                            Settings.Config.ScreenFont);

            var frame = animation.CreateFrame();

            Point p1;
            Point p2;

            if (firstPoint.Value.X > mousePosition.X)
            {
                if (firstPoint.Value.Y > mousePosition.Y)
                {
                    p1 = new Point(frame.Width - 1, frame.Height - 1);
                    p2 = new Point(0, 0);
                }
                else
                {
                    p1 = new Point(frame.Width - 1, 0);
                    p2 = new Point(0, frame.Height - 1);
                }
            }
            else
            {
                if (firstPoint.Value.Y > mousePosition.Y)
                {
                    p1 = new Point(0, frame.Height - 1);
                    p2 = new Point(frame.Width - 1, 0);
                }
                else
                {
                    p1 = new Point(0, 0);
                    p2 = new Point(frame.Width - 1, frame.Height - 1);
                }
            }

            animation.Center = p1;

            //_lineStyle = new CellAppearance(
            //                    EditorConsoleManager.Instance.ToolPane.CommonCharacterPickerPanel.SettingForeground,
            //                    EditorConsoleManager.Instance.ToolPane.CommonCharacterPickerPanel.SettingBackground,
            //                    EditorConsoleManager.Instance.ToolPane.CommonCharacterPickerPanel.SettingCharacter);
            //_lineStyle.SpriteEffect = EditorConsoleManager.Instance.ToolPane.CommonCharacterPickerPanel.SettingMirrorEffect;
            //_lineStyle.CopyAppearanceTo(_lineCell);

            lineShape = new SadConsole.Shapes.Line();
            lineShape.CellAppearance = lineCell;
            lineShape.UseEndingCell = false;
            lineShape.UseStartingCell = false;
            lineShape.StartingLocation = p1;
            lineShape.EndingLocation = p2;
            lineShape.Draw(new SurfaceEditor(frame));

            settingsPanel.LineLength = frame.Width > frame.Height ? frame.Width : frame.Height;

            Brush.Animation = animation;
        }
示例#15
0
        public void ProcessMouse(MouseConsoleState info, ISurface surface, bool isInBounds)
        {
            if (cancelled)
            {
                // wait until left button is released...
                if (info.Mouse.LeftButtonDown)
                {
                    return;
                }
                else
                {
                    cancelled = false;
                }
            }

            if (info.Mouse.LeftButtonDown)
            {
                if (!firstPoint.HasValue)
                {
                    RefreshTool();
                    firstPoint = info.ConsolePosition;
                    return;
                }
                else
                {
                    // Check for right click cancel.
                    if (info.Mouse.RightButtonDown)
                    {
                        cancelled                = true;
                        firstPoint               = null;
                        secondPoint              = null;
                        Brush.Animation          = Brush.Animations["single"];
                        settingsPanel.LineLength = 0;

                        return;
                    }


                    secondPoint = info.ConsolePosition;

                    // Draw the line (erase old) to where the mouse is
                    // create the animation frame
                    AnimatedSurface animation = new AnimatedSurface("line", Math.Max(firstPoint.Value.X, secondPoint.Value.X) - Math.Min(firstPoint.Value.X, secondPoint.Value.X) + 1,
                                                                    Math.Max(firstPoint.Value.Y, secondPoint.Value.Y) - Math.Min(firstPoint.Value.Y, secondPoint.Value.Y) + 1,
                                                                    SadConsoleEditor.Settings.Config.ScreenFont);

                    var frame = animation.CreateFrame();

                    Point p1;
                    Point p2;

                    if (firstPoint.Value.X > secondPoint.Value.X)
                    {
                        if (firstPoint.Value.Y > secondPoint.Value.Y)
                        {
                            p1 = Point.Zero;
                            p2 = new Point(frame.Width - 1, frame.Height - 1);
                        }
                        else
                        {
                            p1 = new Point(0, frame.Height - 1);
                            p2 = new Point(frame.Width - 1, 0);
                        }
                    }
                    else
                    {
                        if (firstPoint.Value.Y > secondPoint.Value.Y)
                        {
                            p1 = new Point(frame.Width - 1, 0);
                            p2 = new Point(0, frame.Height - 1);
                        }
                        else
                        {
                            p1 = new Point(frame.Width - 1, frame.Height - 1);
                            p2 = Point.Zero;
                        }
                    }


                    animation.Center = p1;

                    SadConsoleEditor.Settings.QuickEditor.TextSurface = frame;

                    lineShape                  = new SadConsole.Shapes.Line();
                    lineShape.Cell             = lineCell;
                    lineShape.UseEndingCell    = false;
                    lineShape.UseStartingCell  = false;
                    lineShape.StartingLocation = p1;
                    lineShape.EndingLocation   = p2;
                    lineShape.Draw(SadConsoleEditor.Settings.QuickEditor);

                    settingsPanel.LineLength = frame.Width > frame.Height ? frame.Width : frame.Height;

                    Brush.Animation = animation;
                }
            }
            else if (firstPoint.HasValue)
            {
                settingsPanel.LineLength = 0;

                // We let go outside of bounds
                if (!isInBounds)
                {
                    firstPoint      = null;
                    Brush.Animation = Brush.Animations["single"];
                    cancelled       = true;
                    return;
                }

                // Position the shape and draw
                SadConsoleEditor.Settings.QuickEditor.TextSurface = surface;

                lineShape.StartingLocation = firstPoint.Value + info.Console.TextSurface.RenderArea.Location;
                lineShape.EndingLocation   = info.ConsolePosition + info.Console.TextSurface.RenderArea.Location;
                lineShape.Draw(SadConsoleEditor.Settings.QuickEditor);

                Brush.Animation = Brush.Animations["single"];
                Brush.Position  = secondPoint.Value;


                firstPoint  = null;
                secondPoint = null;
            }
        }