public void Show(GameClient client)
        {
            while (true)
            {
                buffer = new ConsoleBuffer();
                buffer.SetCursorPosition(10, 3);
                buffer.Write("Settings");
                buffer.SetCursorPosition(10, 4);
                buffer.ForegroundColor = ConsoleColor.DarkCyan;
                buffer.Write("".PadRight(width, '═'));
                buffer.ResetColor();

                buffer.SetCursorPosition(10, 6);
                this.ReadMenu();

                if (Selected == Items.Length - 3)
                {
                    new CharacterEditMenu(client).Show();
                }
                if (Selected == Items.Length - 1)
                {
                    return;
                }
            }
        }
Beispiel #2
0
        public bool NumberSetting(int index, ConsoleKeyInfo key, int min, int max, int length, ref int val)
        {
            int oldval = val;

            if (Selected == index)
            {
                if (key.Key == ConsoleKey.Enter)
                {
                    if (this.fillBackround)
                    {
                        buffer.BackgroundColor = this.SelectedColor;
                    }
                    buffer.SetCursorPosition(this.X + width + 2, this.Y + Selected);
                    val = buffer.ReadNumberAlignRight(length, min, val.ToString());
                    buffer.ResetColor();
                }

                if (key.Key == ConsoleKey.RightArrow)
                {
                    val++;
                }
                if (key.Key == ConsoleKey.LeftArrow)
                {
                    val--;
                }

                if (val == min - 1)
                {
                    val = max - 1;
                }
                if (val == max)
                {
                    val = min;
                }

                if (val >= max)
                {
                    val = max - 1;
                }
                if (val < min)
                {
                    val = min;
                }
            }

            return(oldval != val);
        }
Beispiel #3
0
        public void Show(GameServer server, GameClient client)
        {
            while (true)
            {
                arena = ArenaGenerator.Generate(server.GameAssets, seed, biome_count);
                UpdateItems();

                ConsoleBuffer mapbuf = arena.MapBuffer(tempView);
                buffer = new ConsoleBuffer();
                buffer.InsertBuffer(mapbuf, 0, 0);
                buffer.SetCursorPosition(mapbuf.Width, 0);
                buffer.WriteVertical("".PadRight(25, '▌'));

                buffer.SetCursorPosition(mapbuf.Width, 7);
                buffer.Write("█".PadRight(30, '─'));

                buffer.SetCursorPosition(mapbuf.Width + 1, 1);

                this.ReadMenu();

                if (Selected == proitems.Length - 1)
                {
                    return;
                }
                if (Selected == proitems.Length - 2)
                {
                    GameState gs = new GameState(arena, max_players, port, game_name);
                    server.Open(gs);

                    IPEndPoint ep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), port);
                    new ConnectingMenu().Show(client, ep);

                    client.Close();
                    server.Close();
                    return;
                }
            }
        }
Beispiel #4
0
        public static void Show(string title, ref string result, int width = 35)
        {
            ConsoleBuffer buf = new ConsoleBuffer(width, 5);

            buf.ForegroundColor = ConsoleColor.Yellow;

            // window borders
            buf.Write("/".PadRight(width - 1, '-') + "\\");
            buf.SetCursorPosition(0, buf.Height - 1);
            buf.Write("\\".PadRight(width - 1, '-') + "/");
            buf.SetCursorPosition(0, 1);
            buf.WriteVertical("|||");
            buf.SetCursorPosition(width - 1, 1);
            buf.WriteVertical("|||");

            // Title
            buf.SetCursorPosition(4, 0);
            buf.Write(" " + title + " ");

            // Textbox frame
            buf.SetCursorPosition(2, 2);
            buf.Write(">");

            int Xoffset = (80 - width) / 2;
            int Yoffset = 9;

            buf.DrawSelf(Xoffset, Yoffset);
            Console.SetCursorPosition(4 + Xoffset, 2 + Yoffset);
            bool vis = Console.CursorVisible;

            Console.ForegroundColor = buf.ForegroundColor;
            Console.BackgroundColor = buf.BackgroundColor;

            Console.CursorVisible = true;
            result = Console.ReadLine();
            Console.CursorVisible = vis;
        }
        public static int Show(string text, string[] options)
        {
            Menu menu = new Menu(options)
            {
                width = 10, SelectedColor = ConsoleColor.Yellow, fillBackround = false
            };

            int width = 60;

            if (text.Length < 60)
            {
                width = text.Length + 4;
            }

            text = TextBreaker.BreakText(text, width - 4);
            int height = 3 + text.Count(x => x == '\n') + options.Length;

            ConsoleBuffer buf = new ConsoleBuffer(width, height)
            {
                ForegroundColor = ConsoleColor.Yellow
            };

            buf.SetCursorPosition(0, 0);
            buf.Write("/".PadRight(width - 1, '-') + "\\");
            buf.SetCursorPosition(0, height - 1);
            buf.Write("\\".PadRight(width - 1, '-') + "/");

            buf.SetCursorPosition(0, 1);
            buf.WriteVertical("".PadRight(height - 2, '|'));
            buf.SetCursorPosition(width - 1, 1);
            buf.WriteVertical("".PadRight(height - 2, '|'));

            buf.ForegroundColor = ConsoleColor.Gray;

            string[] lines = text.Split('\n');
            for (int i = 0; i < lines.Length; i++)
            {
                buf.SetCursorPosition(2, 1 + i);
                buf.Write(lines[i]);
            }

            menu.BufferX = (80 - width) / 2;
            menu.BufferY = (25 - height) / 2;

            buf.SetCursorPosition(width / 2 - 4, height - 1 - options.Length);
            menu.buffer = buf;
            menu.ReadMenu();

            return(menu.Selected);
        }
        public void Show()
        {
            client = new GameClient();

            if (File.Exists("player.char"))
            {
                client.Character = PlayerCharacter.ReadFromFile("player.char");
            }

            while (true)
            {
                buffer = new ConsoleBuffer();

                ConsoleColor logo1 = ConsoleColor.Red, logo2 = ConsoleColor.DarkCyan, black = ConsoleColor.Black;

                buffer.Clear();
                buffer.ForegroundColor = logo1;
                buffer.Write("\n" +
                             "              ██░ ██  █    ██  ███▄    █   ▄████ ▓█████  ██▀███  \n" +
                             "             ▓██░ ██▒ ██  ▓██▒ ██ ▀█   █  ██▒ ▀█▒▓█   ▀ ▓██ ▒ ██▒\n" +
                             "             ▒██▀▀██░▓██  ▒██░▓██  ▀█ ██▒▒██░▄▄▄░▒███   ▓██ ░▄█ ▒\n" +
                             "             ░▓█ ░██ ▓▓█  ░██░▓██▒  ▐▌██▒░▓█  ██▓▒▓█  ▄ ▒██▀▀█▄  \n" +
                             "             ░▓█▒░██▓▒▒█████▓ ▒██ ░  ▓██░░▒▓███▀▒░▒████▒░██▓ ▒██▒\n" +
                             "              ▒ ░░▒░▒░▒▓▒ ▒ ▒ ░ ▒ ░  ▒ ▒  ░▒   ▒ ░░ ▒░ ░░ ▒▓ ░▒▓░\n" +
                             "              ▒ ░▒░ ░░░▒░ ░░░ ░ ░ ▒  ░ ▒░  ░   ░  ░ ░  ░  ░▒ ░ ▒░\n" +
                             "              ░  ░░ ░ ░░░ ░ ░    ░░  ░ ░ ░ ░   ░    ░     ░░   ░ \n" +
                             "              ░  ░  ░   ░              ░       ░    ░  ░   ░     \n"
                             );

                if (true)
                {
                    buffer.SetCursorPosition(0, buffer.CursorTop - 3);
                    string online =
                        "                ██████╗ ███╗   ██╗██╗     ██╗███╗   ██╗███████╗\n" +
                        "               ██╔═══██╗████╗  ██║██║     ██║████╗  ██║██╔════╝\n" +
                        "               ██║   ██║██╔██╗ ██║██║     ██║██╔██╗ ██║█████╗  \n" +
                        "               ██║   ██║██║╚██╗██║██║     ██║██║╚██╗██║██╔══╝  \n" +
                        "               ╚██████╔╝██║ ╚████║███████╗██║██║ ╚████║███████╗\n" +
                        "                ╚═════╝ ╚═╝  ╚═══╝╚══════╝╚═╝╚═╝   ╚══╝╚══════╝\n"
                    ;

                    int X = buffer.CursorLeft, Y = buffer.CursorTop;
                    for (int i = 0; i < online.Length; i++)
                    {
                        int x = i % (online.Length / 6) + X, y = i / (online.Length / 6) + Y;
                        ConsoleBuffer.CharInfo ci = buffer[x, y];
                        char overchar             = ' ';
                        if (ci.Char.AsciiChar == ConsoleBuffer.ASCII.IndexOf('░'))
                        {
                            overchar = '▒';
                        }
                        if (ci.Char.AsciiChar == ConsoleBuffer.ASCII.IndexOf('▒'))
                        {
                            overchar = '▓';
                        }


                        char online_char = online[i];
                        if (online_char == '\n')
                        {
                            online_char = ' ';
                        }

                        if (online_char == '█')
                        {
                            buffer.DrawText(overchar.ToString(), x, y, logo1, logo2);
                        }
                        else if (online_char == ' ')
                        {
                            buffer.DrawText(" ", x, y, logo2, black);
                        }
                        else
                        {
                            buffer.DrawText(online_char.ToString(), x, y, logo2, overchar != ' ' ? black : black);
                        }
                    }
                }


                buffer.SetCursorPosition(35, buffer.CursorTop + 7);
                int selected = this.ReadMenu();

                if (selected == 0)
                {
                    GameServer server = new GameServer();
                    server.LoadAssets();
                    new MapPreviewMenu().Show(server, client);
                }
                if (selected == 1)
                {
                    bool      valid  = true;
                    string    result = "";
                    IPAddress ip     = null;
                    int       port   = GameServer.DEFAULT_PORT;
                    InputBox.Show("Enter IP address", ref result);

                    if (result.Contains(':'))
                    {
                        if (int.TryParse(result.Split(':')[1], out port))
                        {
                            result = result.Split(':')[0];
                        }
                        else
                        {
                            valid = false;
                        }
                    }

                    if (IPAddress.TryParse(result, out ip))
                    {
                        IPEndPoint ep = new IPEndPoint(ip, port);
                        new ConnectingMenu().Show(client, ep);
                    }
                    else
                    {
                        valid = false;
                    }

                    if (!valid)
                    {
                        MessageBox.Show("Invalid IP address format.", MessageBox.Buttons.OK);
                    }
                }
                if (selected == 3)
                {
                    new SettingsMenu().Show(client);
                }
                if (selected == Items.Length - 1)
                {
                    ConsoleBuffer.Fullscreen = false;
                    return;
                }
            }
        }