Пример #1
0
        public static void ShowPreviousMessages(bool show_footsteps)
        {
            const int     text_height = Global.ROWS + 1;
            List <string> messages    = B.GetMessageLog();

            MouseUI.PushButtonMap(MouseMode.ScrollableMenu);
            UI.draw_bottom_commands = false;
            UI.darken_status_bar    = true;
            MouseUI.CreateMapButton(ConsoleKey.OemMinus, false, 0, 1);
            MouseUI.CreateMapButton(ConsoleKey.OemPlus, false, text_height + 1, 1);
            Screen.WriteMapString(0, 0, "".PadRight(COLS, '-'));
            Screen.WriteMapString(text_height + 1, 0, "".PadRight(COLS, '-'));
            ConsoleKeyInfo command;
            char           ch;
            int            startline = Math.Max(0, messages.Count - text_height);

            for (bool done = false; !done;)
            {
                if (startline > 0)
                {
                    Screen.WriteMapString(0, COLS - 3, new colorstring("[", Color.Yellow, "-", Color.Cyan, "]", Color.Yellow));
                }
                else
                {
                    Screen.WriteMapString(0, COLS - 3, "---");
                }
                bool more = false;
                if (startline + text_height < messages.Count)
                {
                    more = true;
                }
                if (more)
                {
                    Screen.WriteMapString(text_height + 1, COLS - 3, new colorstring("[", Color.Yellow, "+", Color.Cyan, "]", Color.Yellow));
                }
                else
                {
                    Screen.WriteMapString(text_height + 1, COLS - 3, "---");
                }
                for (int i = 1; i <= text_height; ++i)
                {
                    if (messages.Count - startline < i)
                    {
                        Screen.WriteMapString(i, 0, "".PadToMapSize());
                    }
                    else
                    {
                        Screen.WriteMapString(i, 0, messages[i + startline - 1].PadToMapSize());
                    }
                }
                UI.Display("Previous messages: ");
                command = Input.ReadKey();
                ConsoleKey ck = command.Key;
                switch (ck)
                {
                case ConsoleKey.Backspace:
                case ConsoleKey.PageUp:
                case ConsoleKey.NumPad9:
                    ch = (char)8;
                    break;

                case ConsoleKey.Enter:
                    ch = ' ';             //hackery ahoy - enter becomes space and pagedown becomes enter.
                    break;

                case ConsoleKey.PageDown:
                case ConsoleKey.NumPad3:
                    ch = (char)13;
                    break;

                case ConsoleKey.Home:
                case ConsoleKey.NumPad7:
                    ch = '[';
                    break;

                case ConsoleKey.End:
                case ConsoleKey.NumPad1:
                    ch = ']';
                    break;

                default:
                    ch = command.GetCommandChar();
                    break;
                }
                switch (ch)
                {
                case ' ':
                case (char)27:
                    done = true;
                    break;

                case '8':
                case '-':
                case '_':
                    if (startline > 0)
                    {
                        --startline;
                    }
                    break;

                case '2':
                case '+':
                case '=':
                    if (more)
                    {
                        ++startline;
                    }
                    break;

                case (char)8:
                    if (startline > 0)
                    {
                        startline -= text_height;
                        if (startline < 0)
                        {
                            startline = 0;
                        }
                    }
                    break;

                case (char)13:
                    if (messages.Count > text_height)
                    {
                        startline += text_height;
                        if (startline + text_height > messages.Count)
                        {
                            startline = messages.Count - text_height;
                        }
                    }
                    break;

                case '[':
                    startline = 0;
                    break;

                case ']':
                    startline = Math.Max(0, messages.Count - text_height);
                    break;

                default:
                    break;
                }
            }
            if (show_footsteps && player.HasAttr(AttrType.DETECTING_MOVEMENT) && Actor.previous_footsteps.Count > 0)
            {
                M.Draw();
                Screen.AnimateMapCells(Actor.previous_footsteps, new colorchar('!', Color.Red), 150);
            }
            MouseUI.PopButtonMap();
            UI.draw_bottom_commands = true;
            UI.darken_status_bar    = false;
        }
        public static void ShowPreviousMessages(bool show_footsteps)
        {
            List <string> messages = B.GetMessages();

            MouseUI.PushButtonMap(MouseMode.ScrollableMenu);
            MouseUI.CreateMapButton(ConsoleKey.OemMinus, false, 3, 1);
            MouseUI.CreateMapButton(ConsoleKey.OemPlus, false, 24, 1);
            Screen.CursorVisible = false;
            //Screen.Blank();
            Screen.WriteMapString(0, 0, "".PadRight(COLS, '-'));
            Screen.WriteMapString(21, 0, "".PadRight(COLS, '-'));
            ConsoleKeyInfo command2;
            char           ch2;
            int            startline = Math.Max(0, messages.Count - 20);

            for (bool done = false; !done;)
            {
                if (startline > 0)
                {
                    Screen.WriteMapString(0, COLS - 3, new colorstring("[", Color.Yellow, "-", Color.Cyan, "]", Color.Yellow));
                }
                else
                {
                    Screen.WriteMapString(0, COLS - 3, "---");
                }
                bool more = false;
                if (startline + 20 < messages.Count)
                {
                    more = true;
                }
                if (more)
                {
                    Screen.WriteMapString(ROWS - 1, COLS - 3, new colorstring("[", Color.Yellow, "+", Color.Cyan, "]", Color.Yellow));
                }
                else
                {
                    Screen.WriteMapString(ROWS - 1, COLS - 3, "---");
                }
                for (int i = 1; i <= 20; ++i)
                {
                    if (messages.Count - startline < i)
                    {
                        Screen.WriteMapString(i, 0, "".PadToMapSize());
                    }
                    else
                    {
                        Screen.WriteMapString(i, 0, messages[i + startline - 1].PadToMapSize());
                    }
                }
                B.DisplayNow("Previous messages: ");
                Screen.CursorVisible = true;
                command2             = Global.ReadKey();
                ConsoleKey ck = command2.Key;
                switch (ck)
                {
                case ConsoleKey.Backspace:
                case ConsoleKey.PageUp:
                case ConsoleKey.NumPad9:
                    ch2 = (char)8;
                    break;

                case ConsoleKey.Enter:
                    ch2 = ' ';             //hackery ahoy - enter becomes space and pagedown becomes enter.
                    break;

                case ConsoleKey.PageDown:
                case ConsoleKey.NumPad3:
                    ch2 = (char)13;
                    break;

                case ConsoleKey.Home:
                case ConsoleKey.NumPad7:
                    ch2 = '[';
                    break;

                case ConsoleKey.End:
                case ConsoleKey.NumPad1:
                    ch2 = ']';
                    break;

                default:
                    ch2 = Actor.ConvertInput(command2);
                    break;
                }
                switch (ch2)
                {
                case ' ':
                case (char)27:
                    done = true;
                    break;

                case '8':
                case '-':
                case '_':
                    if (startline > 0)
                    {
                        --startline;
                    }
                    break;

                case '2':
                case '+':
                case '=':
                    if (more)
                    {
                        ++startline;
                    }
                    break;

                case (char)8:
                    if (startline > 0)
                    {
                        startline -= 20;
                        if (startline < 0)
                        {
                            startline = 0;
                        }
                    }
                    break;

                case (char)13:
                    if (messages.Count > 20)
                    {
                        startline += 20;
                        if (startline + 20 > messages.Count)
                        {
                            startline = messages.Count - 20;
                        }
                    }
                    break;

                case '[':
                    startline = 0;
                    break;

                case ']':
                    startline = Math.Max(0, messages.Count - 20);
                    break;

                default:
                    break;
                }
            }
            if (show_footsteps && player.HasAttr(AttrType.DETECTING_MOVEMENT) && Actor.previous_footsteps.Count > 0)
            {
                M.Draw();
                Screen.AnimateMapCells(Actor.previous_footsteps, new colorchar('!', Color.Red), 150);
            }
            MouseUI.PopButtonMap();
        }