示例#1
0
        public ScrollingConsole(int width, int height, int bufferHeight)
        {
            controlsContainer = new SadConsole.ControlsConsole(1, height);

            mainConsole = new SadConsole.Console(width - 1, bufferHeight);
            mainConsole.TextSurface.RenderArea  = new Microsoft.Xna.Framework.Rectangle(0, 0, width - 1, height);
            mainConsole.VirtualCursor.IsVisible = false;

            scrollBar               = SadConsole.Controls.ScrollBar.Create(System.Windows.Controls.Orientation.Vertical, height);
            scrollBar.IsEnabled     = false;
            scrollBar.ValueChanged += ScrollBar_ValueChanged;

            controlsContainer.Add(scrollBar);
            controlsContainer.Position = new Microsoft.Xna.Framework.Point(1 + mainConsole.TextSurface.Width, Position.Y);

            Children.Add(mainConsole);
            Children.Add(controlsContainer);

            scrollingCounter = 0;

            borderSurface = new SadConsole.Surfaces.BasicSurface(width + 2, height + 2, mainConsole.TextSurface.Font);
            var editor = new SadConsole.Surfaces.SurfaceEditor(borderSurface);

            SadConsole.Shapes.Box box = SadConsole.Shapes.Box.Thick();
            box.Width  = borderSurface.Width;
            box.Height = borderSurface.Height;
            box.Draw(editor);
            renderer = new SurfaceRenderer();
            renderer.Render(borderSurface);
        }
示例#2
0
        public GameObjectTest() : base(80, 23)
        {
            var textAnimation = new AnimatedSurface("default", 14, 5);           // Animated surface size. 14,5

            fallingText = new SadConsole.GameHelpers.GameObject(textAnimation);

            var editor = new SadConsole.Surfaces.SurfaceEditor(new SadConsole.Surfaces.BasicSurface(1, 1));

            for (int line = 0; line < 5; line++)
            {
                var frame = textAnimation.CreateFrame();
                editor.TextSurface = frame;
                editor.Fill(Color.Purple, Color.DarkGray, 178, null);                 // 219 178
                editor.Print(1, line, "Hello World!");
            }

            textAnimation.AnimationDuration = 1;             // Set it to -1 to make it faster than 1 sec
            textAnimation.Repeat            = true;

            textAnimation.Start();

            fallingText.Animation = textAnimation;
            //fallingText.Position = new Point(1,1);

            Children.Add(fallingText);
        }
示例#3
0
        public DungeonScreen(int screenX, int screenY, int screenWidth, int screenHeight, Font font)
        {
            Position = new Point(screenX, screenY);
            Width    = screenWidth;
            Height   = screenHeight;

            borderSurface = new SadConsole.Surfaces.BasicSurface(Width + 1, Height + 1, font);
            var editor = new SadConsole.Surfaces.SurfaceEditor(borderSurface);

            SadConsole.Shapes.Box box = SadConsole.Shapes.Box.Thick();
            box.Width  = borderSurface.Width;
            box.Height = borderSurface.Height;
            box.Draw(editor);
            renderer = new SurfaceRenderer();
            renderer.Render(borderSurface);
        }
示例#4
0
        public StatusConsole(int screenX, int screenY, int screenWidth, int screenHeight) : base(screenWidth, screenHeight)
        {
            Position = new Point(screenX, screenY);
            Width    = screenWidth;
            Height   = screenHeight;

            var lines = new[]
            {
                @"_______",
                @"|     |",
                @"| [H] |",
                @"|_____|",
                @"| |",
                @"=============",
                @"//  |     |  \\",
                @"[LAL]  |     |  [RAL]",
                @"//    | [D] |    \\",
                @"[LH]    |     |    [RH]",
                @"|     |",
                @"=======",
                @"//    \\",
                @"//      \\",
                @"[LLL]      [RLL]",
                @"//          \\",
                @"//            \\",
                @"[LF]            [RF]"
            };

            var offsets = new[]
            {
                10,
                10,
                10,
                10,
                12,
                7,
                6,
                3,
                4,
                2,
                10,
                10,
                9,
                8,
                5,
                6,
                5,
                3
            };

            for (int i = 0; i < lines.Length; i++)
            {
                Print(offsets[i], i, lines[i]);
            }

            var btHead = new SadConsole.Controls.Button(5, 1)
            {
                Text     = " H ",
                Position = new Point(11, 2)
            };

            Add(btHead);

            var btLAL = new SadConsole.Controls.Button(5, 1)
            {
                Text     = "LAL",
                Position = new Point(3, 7)
            };

            Add(btLAL);

            var btRAL = new SadConsole.Controls.Button(5, 1)
            {
                Text     = "RAL",
                Position = new Point(19, 7)
            };

            Add(btRAL);

            var btDD = new SadConsole.Controls.Button(5, 1)
            {
                Text     = " D ",
                Position = new Point(11, 8)
            };

            Add(btDD);

            var btLH = new SadConsole.Controls.Button(4, 1)
            {
                Text     = "LH",
                Position = new Point(2, 9)
            };

            Add(btLH);

            var btRH = new SadConsole.Controls.Button(4, 1)
            {
                Text     = "RH",
                Position = new Point(21, 9)
            };

            Add(btRH);

            var btLLL = new SadConsole.Controls.Button(5, 1)
            {
                Text     = "LLL",
                Position = new Point(5, 14)
            };

            Add(btLLL);

            var btRLL = new SadConsole.Controls.Button(5, 1)
            {
                Text     = "RLL",
                Position = new Point(16, 14)
            };

            Add(btRLL);

            var btLF = new SadConsole.Controls.Button(4, 1)
            {
                Text     = "LF",
                Position = new Point(3, 17)
            };

            Add(btLF);

            var btRF = new SadConsole.Controls.Button(4, 1)
            {
                Text     = "RF",
                Position = new Point(19, 17)
            };

            Add(btRF);

            SadConsole.Controls.ProgressBar health = new SadConsole.Controls.ProgressBar(2, 10, System.Windows.VerticalAlignment.Top);
            health.Position = new Point(27, 0);
            health.SetForeground(0, 9, Color.Green);
            Add(health);

            borderSurface = new SadConsole.Surfaces.BasicSurface(Width + 2, Height + 2, base.textSurface.Font);
            var editor = new SadConsole.Surfaces.SurfaceEditor(borderSurface);

            SadConsole.Shapes.Box box = SadConsole.Shapes.Box.Thick();
            box.Width  = borderSurface.Width;
            box.Height = borderSurface.Height;
            box.Draw(editor);
            base.Renderer.Render(borderSurface);
        }