Пример #1
0
        /* Display current view of a skin */
        static void display_scrolling(Menu_Type menu, int cursor, ref int top, Region loc)
        {
            int col           = loc.col;
            int row           = loc.row;
            int rows_per_page = loc.page_rows;
            int n             = (menu.filter_list != null) ? menu.filter_count : menu.count;
            int i;

            /* Keep a certain distance from the top when possible */
            if ((cursor <= top) && (top > 0))
            {
                top = cursor - 1;
            }

            /* Keep a certain distance from the bottom when possible */
            if (cursor >= top + (rows_per_page - 1))
            {
                top = cursor - (rows_per_page - 1) + 1;
            }

            /* Limit the top to legal places */
            top = Math.Min(top, n - rows_per_page);
            top = Math.Max(top, 0);

            for (i = 0; i < rows_per_page; i++)
            {
                /* Blank all lines */
                Term.erase(col, row + i, loc.width);
                if (i < n)
                {
                    /* Redraw the line if it's within the number of menu items */
                    bool is_curs = (i == cursor - top);
                    menu.display_menu_row(i + top, top, is_curs, row + i, col, loc.width);
                }
            }

            if (cursor >= 0)
            {
                Term.gotoxy(col, row + cursor - top);
            }
        }
Пример #2
0
        /* Display current view of a skin */
        static void display_scrolling(Menu_Type menu, int cursor, ref int top, Region loc)
        {
            int col = loc.col;
            int row = loc.row;
            int rows_per_page = loc.page_rows;
            int n = (menu.filter_list != null) ? menu.filter_count : menu.count;
            int i;

            /* Keep a certain distance from the top when possible */
            if ((cursor <= top) && (top > 0))
                top = cursor - 1;

            /* Keep a certain distance from the bottom when possible */
            if (cursor >= top + (rows_per_page - 1))
                top = cursor - (rows_per_page - 1) + 1;

            /* Limit the top to legal places */
            top = Math.Min(top, n - rows_per_page);
            top = Math.Max(top, 0);

            for (i = 0; i < rows_per_page; i++)
            {
                /* Blank all lines */
                Term.erase(col, row + i, loc.width);
                if (i < n)
                {
                    /* Redraw the line if it's within the number of menu items */
                    bool is_curs = (i == cursor - top);
                    menu.display_menu_row(i + top, top, is_curs, row + i, col, loc.width);
                }
            }

            if (cursor >= 0)
                Term.gotoxy(col, row + cursor - top);
        }