Ejemplo n.º 1
0
        static void CreateStartMeni(IDrawningRectangle <SignConsole> location)
        {
            KeyPress.SetControl("Menu");
            var menu        = new KeyboardMenu <ButtonInConsole>("menu");
            var menuPrinter = new ConsolePrintMenu(location.Width, location.Height, location, menu);

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

            menuPrinter.Register((0, 1), printer, printer.GetCoordinates());
            menuPrinter.SetWriter(printer);
            MenuKeySet(menu);

            var buttons = MenuInicialisation(menu, menuPrinter, new string[] { "Snake start", "Settings", "Exit" });

            buttons[0].IsPressed += () =>
            {
                menuPrinter.Hide();
                void act()
                {
                    menuPrinter.Load();
                    MenuKeySet(menu);
                }

                SnakeMenuLoad(location, act);
            };

            buttons[1].IsPressed += () =>
            {
                menuPrinter.Hide();
                void act()
                {
                    menuPrinter.Load();
                    MenuKeySet(menu);
                }

                CommonSettings(location, act);
            };

            buttons[2].IsPressed += () =>
            {
                menuPrinter.Close();
                location.CancelRegistration(menuPrinter);
                KeyPress.Close();
                MenuKeyClose();
                return;
            };

            menuPrinter.Load();
        }
Ejemplo n.º 2
0
        static void SnakeMenuLoad(IDrawningRectangle <SignConsole> location, Action startWithClose)
        {
            var menu      = new KeyboardMenu <ButtonInConsole>("Snake");
            var snakeMenu = new ConsolePrintMenu(location.Width, location.Height, location, menu);

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

            snakeMenu.Register((0, 1), printer, printer.GetCoordinates());
            snakeMenu.SetWriter(printer);

            void act()
            {
                snakeMenu.Load();
                MenuKeySet(menu, new bool[] { false, false, true });
            }

            var buttons       = MenuInicialisation(menu, snakeMenu, new string[] { "Start", "Mode", "Settings", "Exit" });
            var snakeSettings = new SnakeSettings();

            buttons[0].IsPressed += () =>
            {
                snakeMenu.Hide();
                SnakeStart(location, snakeSettings, act);
                KeyPress.SetControl("Menu");
                snakeMenu.Load();
            };

            buttons[1].IsPressed += () =>
            {
                snakeMenu.Hide();
                SnakeMode(location, act, snakeSettings);
            };

            buttons[2].IsPressed += () =>
            {
                snakeMenu.Hide();
                SnakeSettings(location, act);
            };

            buttons[3].IsPressed += () => {
                snakeMenu.Close();
                location.CancelRegistration(snakeMenu);
                MenuKeyClose();
                startWithClose?.Invoke();
            };
            act();
        }
Ejemplo n.º 3
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();
        }