Ejemplo n.º 1
0
        static void SnakeSettings(IDrawningRectangle <SignConsole> location, Action startWithClose, bool clear = false)
        {
            var menu         = new KeyboardMenu <ButtonInConsole>("Snake Settings");
            var sattingsMenu = new ConsolePrintMenu(location.Width, location.Height, location, menu);

            location.Register((0, 0), sattingsMenu, sattingsMenu.GetCoordinates());
            var printer = new BigPixelPrint(sattingsMenu.Width, 5, sattingsMenu, letters);

            sattingsMenu.Register((0, 1), printer, printer.GetCoordinates());
            sattingsMenu.SetWriter(printer);
            if (clear)
            {
                sattingsMenu.Fill(new SignConsole(' '));
            }
            var buttons = SetControl("Snake", menu, sattingsMenu,
                                     new string[] { "Snake Up", "Snake Down", "Snake Left", "Snake Right", "Second Snake Up", "Second Snake Down", "Second Snake Left", "Second Snake Right" },
                                     new needOption[] { needOption.snakeUp, needOption.snakeDown, needOption.snakeLeft, needOption.snakeRigh,
                                                        needOption.secondSnakeUp, needOption.secondSnakeDown, needOption.secondSnakeLeft, needOption.secondSnakeRigh });
            var exit = new ButtonInConsoleSetter(6, 1, sattingsMenu, SignConsole.GetSignConsoles("Exit"));

            sattingsMenu.Register((5, 9 + buttons.Length * 2), exit, exit.GetCoordinates());

            menu.AddLastButton(exit);
            exit.IsPressed += () =>
            {
                sattingsMenu.Close();
                location.CancelRegistration(sattingsMenu);
                MenuKeyClose();
                startWithClose?.Invoke();
            };

            sattingsMenu.Load();
            MenuKeySet(menu);
        }
Ejemplo n.º 2
0
        static void Pause(IDrawningRectangle <SignConsole> location, Action contin, Action exit)
        {
            var menu      = new KeyboardMenu <ButtonInConsole>("Pause");
            var pauseMenu = new ConsolePrintMenu(location.Width / 2, location.Height / 3 * 2, location, menu);

            location.Register((location.Width / 4, location.Height / 6), pauseMenu, pauseMenu.GetCoordinates());
            var printer = new BigPixelPrint(pauseMenu.Width - 4, 5, pauseMenu, letters);

            pauseMenu.Register((2, 2), printer, printer.GetCoordinates());
            pauseMenu.SetWriter(printer);
            pauseMenu.Frame(new SignConsole('0'));

            MenuKeySet(menu);

            var pauseButtons = MenuInicialisation(menu, pauseMenu, new string[] { "Continue", "Settings", "Exit" });

            pauseButtons[0].IsPressed += () =>
            {
                pauseMenu.Close();
                location.CancelRegistration(pauseMenu);
                MenuKeyClose();
                contin?.Invoke();
            };

            pauseButtons[1].IsPressed += () =>
            {
                pauseMenu.Hide();
                void act()
                {
                    location.Load();
                    MenuKeySet(menu);
                }

                SnakeSettings(location, act, true);
            };

            pauseButtons[2].IsPressed += () =>
            {
                pauseMenu.Close();
                location.CancelRegistration(pauseMenu);
                MenuKeyClose();
                exit?.Invoke();
            };
            pauseMenu.Fill(new SignConsole(' '));
            pauseMenu.Load();
        }