Пример #1
0
        //Inventory Menu, similarly to combat Menu, returns a letter
        public string InvMenu(List <string> item, string title, int x)
        {
            //var originalpos = Console.CursorTop;
            int            i = 0;
            ConsoleKeyInfo k;

            //Looking for the longest string in the menu
            int longest = Construct.Longest(item);


            if (longest > x)
            {
                x = longest;
            }
            int extraY = title.Length / x;

            if (title.Length % x != 0)
            {
                extraY++;
            }
            int height = item.Count + extraY;

            this.X    = x;
            this.Y    = height;
            this.posX = (Console.WindowWidth - this.X - 2) / 2;

            //Printing the boxy box
            Boxy Boxy = new Boxy(this.X, this.Y, this.posX, this.posY, this.Center);

            Boxy.BiPrint();
            Boxy.WriteLine(title);

            while (1 < 2)
            {
                Boxy.GoTop();
                Boxy.Jump(extraY);
                foreach (string element in item)
                {
                    Boxy.WriteLine(element);
                }

                Boxy.GoTop();
                Boxy.Jump(extraY + i);
                Console.ForegroundColor = ConsoleColor.Black;
                Console.BackgroundColor = ConsoleColor.Yellow;
                Boxy.WriteLine(item[i]);
                Console.ResetColor();

                Boxy.GoTo(this.posX + Boxy.X - 1, this.posY + extraY - 2);


                while (1 < 2)
                {
                    k = Console.ReadKey();

                    if (k.Key == ConsoleKey.UpArrow)
                    {
                        if (i == 0)
                        {
                            i = item.Count - 1;
                        }
                        else
                        {
                            i--;
                        }
                        break;
                    }
                    else if (k.Key == ConsoleKey.DownArrow)
                    {
                        if (i == item.Count - 1)
                        {
                            i = 0;
                        }
                        else
                        {
                            i++;
                        }
                        break;
                    }
                    else if (k.Key == ConsoleKey.Enter)
                    {
                        return(item[i].Substring(0, 1).ToLower());
                    }
                }
            }

            return("p");
        }
Пример #2
0
        //Combat menu returns the first letter of the selected option
        public string CombatMenu(string title, bool cure, bool meditate, bool fury)
        {
            //var originalpos = Console.CursorTop;
            int            i = 0;
            ConsoleKeyInfo k;

            //Options
            List <string> item = new List <string>();

            item.Add("Ataque");
            item.Add("Conjuro");
            item.Add("Discurso épico");
            if (cure)
            {
                item.Add("Sanaciión");
            }
            if (meditate)
            {
                item.Add("Meditar");
            }
            if (fury)
            {
                item.Add("Enfurecer");
            }
            item.Add("Inventario");
            item.Add("Huir");

            //Looking for the longest string in the menu
            int longest = Construct.Longest(item);

            X = 17;

            if (longest > X)
            {
                X = longest;
            }

            Boxy counter = new Boxy(X, Y, 1, 1, Center);

            int extraY = counter.CountLines(title);

            Y = item.Count + extraY;

            this.posX = (Console.WindowWidth - this.X - 2) / 2;

            //Printing the boxy box
            Boxy Boxy = new Boxy(X, Y, posX, posY, Center);

            Boxy.BiPrint();
            Boxy.WriteLine(title);

            while (1 < 2)
            {
                Boxy.GoTop();
                Boxy.Jump(extraY);
                foreach (string element in item)
                {
                    Boxy.WriteLine(element);
                }

                Boxy.GoTop();
                Boxy.Jump(extraY + i);
                Console.ForegroundColor = ConsoleColor.Black;
                Console.BackgroundColor = ConsoleColor.Yellow;
                Boxy.WriteLine(item[i]);
                Console.ResetColor();

                Boxy.GoTo(this.posX + Boxy.X - 1, this.posY + extraY - 2);


                while (1 < 2)
                {
                    k = Console.ReadKey();

                    if (k.Key == ConsoleKey.UpArrow)
                    {
                        if (i == 0)
                        {
                            i = item.Count - 1;
                        }
                        else
                        {
                            i--;
                        }
                        break;
                    }
                    else if (k.Key == ConsoleKey.DownArrow)
                    {
                        if (i == item.Count - 1)
                        {
                            i = 0;
                        }
                        else
                        {
                            i++;
                        }
                        break;
                    }
                    else if (k.Key == ConsoleKey.Enter)
                    {
                        return(item[i].Substring(0, 1).ToLower());
                    }
                }
            }
        }