Beispiel #1
0
        private Button MakeTestButtonFor <ConsoleType>(string text, string name, Action creator, Action disposer) where ConsoleType : SadConsole.Console
        {
            // Create btn
            var btn = new Button(text.Length + 2, 1)
            {
                Text  = text,
                Name  = name,
                Theme = new SadConsole.Themes.Button3dTheme()
            };

            // Calc position
            Point calcPos = new Point(btn.Width + 2, 0);

            if ((Cursor.Position + calcPos).X > Global.CurrentScreen.Width)
            {
                Cursor.Position = new Point(0, Cursor.Position.Y + 1);
            }
            btn.Position    = Cursor.Position;
            Cursor.Position = Cursor.Position + calcPos;

            // Add to SelectionConsole
            SelectionConsole.Add(btn);

            btn.Click += (s, e) =>
            {
                DeactivateCurrentTest();
                creator.Invoke();
                SelectionConsole.IsVisible = false;
                _isTestGoingOn             = true;
            };
            _disposeur = disposer;

            return(btn);
        }
Beispiel #2
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);
        }
        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;
        }
Beispiel #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.");
        }
Beispiel #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);
        }