Example #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);
        }
Example #2
0
        private static void Init()
        {
            // Any setup
            if (Settings.UnlimitedFPS)
            {
                SadConsole.Game.Instance.Components.Add(new SadConsole.Game.FPSCounterComponent(SadConsole.Game.Instance));
            }

            // Setup our custom theme.
            Theme.SetupThemes();

            SadConsole.Game.Instance.Window.Title = "DemoProject Core";

            // By default SadConsole adds a blank ready-to-go console to the rendering system.
            // We don't want to use that for the sample project so we'll remove it.

            //Global.MouseState.ProcessMouseWhenOffScreen = true;

            MainConsole = new Container();

            // We'll instead use our demo consoles that show various features of SadConsole.
            Global.CurrentScreen = MainConsole;
            //Global.CurrentScreen.Print(1, 1, "Test".CreateColored(ColorAnsi.CyanBright, ColorAnsi.Cyan), ColorAnsi.BlueBright, ColorAnsi.Blue);

            var console = new SadConsole.ControlsConsole(50, 30)
            {
                new SadConsole.Controls.Button(7, 1)
                {
                    Text     = "Click",
                    Position = new Point(5, 5)
                }
            };

            console.Invalidated += (s, e) =>
            {
                Rectangle boxArea = console.Controls[0].Bounds;
                boxArea.Inflate(1, 1);
                ((ControlsConsole)s).DrawBox(boxArea, new Cell(Color.Yellow), null, CellSurface.ConnectedLineThin);
            };


            // Initialize the windows
            _characterWindow = new Windows.CharacterViewer();
        }
        public ScrollableConsole(int width, int height, int bufferHeight) : base(width - 1, bufferHeight, new Rectangle(0, 0, width - 1, height))
        {
            controlsContainer = new SadConsole.ControlsConsole(1, height);

            ViewPort = new Rectangle(0, 0, width, height);

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

            controlsContainer.Add(scrollBar);
            controlsContainer.Position  = new Point(Position.X + width - 1, Position.Y);
            controlsContainer.IsVisible = true;

            Cursor.IsVisible = true;
            Cursor.Print("Just start typing!");
            IsVisible = false;

            scrollingCounter = 0;
        }
Example #4
0
        private static void Init()
        {
            var colors = SadConsole.Themes.Library.Default.Colors.Clone();

            colors.Appearance_ControlNormal    = new Cell(Color.White, Color.Black);
            colors.Appearance_ControlFocused   = new Cell(Color.White, Color.Gray);
            colors.Appearance_ControlMouseDown = new Cell(Color.White, Color.DarkGray);
            colors.Appearance_ControlOver      = new Cell(Color.White, Color.Gray);
            colors.Appearance_ControlSelected  = new Cell(Color.White, Color.Gray);
            colors.TextLight       = Color.White;
            colors.ControlBack     = Color.Black;
            colors.ControlHostBack = Color.Black;
            colors.Text            = Color.White;
            colors.TitleText       = Color.White;

            SadConsole.Themes.Library.Default.Colors      = colors;
            SadConsole.Themes.Library.Default.ButtonTheme = new SadConsole.Themes.ButtonLinesTheme
            {
                EndCharacterLeft  = '|',
                EndCharacterRight = '|'
            };

            var console = new SadConsole.ControlsConsole(Settings.Width, Settings.Height)
            {
                DefaultBackground = Color.Black,
                DefaultForeground = Color.White
            };

            console.PrintCentre(Settings.Width / 2, 1, "Main  Screen");

            console.Add(new NavigateButton <GameScreen>(16, 3)
            {
                Text     = "Play",
                Position = new Point(Settings.Width / 2 - 8, 6)
            });

            console.Add(new NavigateButton <OptionsScreen>(16, 3)
            {
                Text     = "Options",
                Position = new Point(Settings.Width / 2 - 8, 10)
            });

            console.Add(new NavigateButton <InfoScreen>(16, 3)
            {
                Text     = "Information",
                Position = new Point(Settings.Width / 2 - 8, 14)
            });

            var exit = new SadConsole.Controls.Button(16, 3)
            {
                Text     = "Exit Game",
                Position = new Point(Settings.Width / 2 - 8, Settings.Height - 8)
            };

            exit.Click += (a, b) =>
            {
                Environment.Exit(0);
            };
            console.Add(exit);

            console.IsFocused = true;
            SadConsole.Global.CurrentScreen = console;

            GameScreen.PrintLine($"\nNeed some help? You can type <{Color.Cyan.ToInteger()},help>Help@ at any time to see all the commands you can use.");
            GameScreen.Print($" You can also enable <{Color.Orange.ToInteger()},>[info]@ messages and debug commands by enabling debug mode in the options menu.");
            GameScreen.PrintLine($"\nWhen you see a link <{Color.Cyan.ToInteger()},say you pressed a link!>like this@ you can click on it to quickly interact with objects or repeat commands.");
        }
Example #5
0
        public MainTestSelectorConsole() : base(Global.CurrentScreen.Width, Global.CurrentScreen.Height)
        {
            UseKeyboard     = true;
            Cursor.Position = Point.Zero;

            SelectionConsole = new ControlsConsole(Global.CurrentScreen.Width, 6);

            // Test health and mana progress bars.
            SelectionConsole.Add(MakeTestButtonFor <TestHealthConsole>("Health bars", "BtnTestHealth",
                                                                       creator: () =>
            {
                HUDConsole myHUDConsole;
                InventoryConsole myInventoryConsole;

                Children.Add(myHUDConsole       = new HUDConsole(Global.CurrentScreen.Width, 4));
                Children.Add(myInventoryConsole = new InventoryConsole()
                {
                    Position  = new Point(0, 8),
                    IsVisible = false
                });
                myHUDConsole.InventoryBtn.Click += (s, e) => myInventoryConsole.IsVisible = !myInventoryConsole.IsVisible;

                TestHealthConsole[] testHPConsoles = new[] {
                    new TestHealthConsole(80, 20, myHUDConsole.HpProgressBar)
                    {
                        Position = new Point(0, 5)
                    },
                    new TestHealthConsole(80, 20, myHUDConsole.ManaProgressBar)
                    {
                        Position = new Point(30, 5)
                    }
                };

                foreach (TestHealthConsole cli in testHPConsoles)
                {
                    Children.Add(cli);
                }
            },
                                                                       disposer: () =>
            {
                Children.Clear();
            }));

            // Test pixel offset.
            SelectionConsole.Add(MakeTestButtonFor <TestPixelOffsetConsole>("Pixel Offset", "BtnTestPixelOffsetConsole",
                                                                            creator: () =>
            {
                Children.Add(new TestPixelOffsetConsole(10, 5));
            },
                                                                            disposer: () =>
            {
                Children.Clear();
            }));

            // Test animated entities.
            SelectionConsole.Add(MakeTestButtonFor <TestAnimatedEntitiesConsole>("Animated Entities", "BtnTestAnimatedEntities",
                                                                                 creator: () =>
            {
                Children.Add(new TestAnimatedEntitiesConsole());
            },
                                                                                 disposer: () =>
            {
                Children.Clear();
            }));

            Children.Add(SelectionConsole);
        }