예제 #1
0
 public Region(Region copy)
 {
     this.col = copy.col;
     this.row = copy.row;
     this.width = copy.width;
     this.page_rows = copy.page_rows;
 }
예제 #2
0
        /* Given a region with relative values, make them absolute */
        public Region calculate()
        {
            int w, h;
            Term.get_size(out w, out h);

            Region loc = new Region(this);
            if (loc.col < 0)
                loc.col += w;
            if (loc.row < 0)
                loc.row += h;
            if (loc.width <= 0)
                loc.width += w - loc.col;
            if (loc.page_rows <= 0)
                loc.page_rows += h - loc.row;

            return loc;
        }
예제 #3
0
        bool menu_calc_size()
        {
            /* Calculate term-relative positions */
            active = boundary.calculate();

            if (title != null)
            {
                active.row += 2;
                active.page_rows -= 2;
                active.col += 4;
            }

            if (header != null)
            {
                active.row++;
                active.page_rows--;
            }

            if (prompt != null)
            {
                if (active.page_rows > 1) {
                    active.page_rows--;
                } else {
                    int offset = prompt.Length + 2;
                    active.col += offset;
                    active.width -= offset;
                }
            }

            return (active.width > 0 && active.page_rows > 0);
        }
예제 #4
0
        /*
         * Display a list of commands.
         */
        static bool cmd_menu(ref Command_List list, object selection_p)
        {
            Menu_Type menu;
            Menu_Type.menu_iter commands_menu = new Menu_Type.menu_iter( null, null, cmd_sub_entry, null, null );
            Region area = new Region(23, 4, 37, 13);

            ui_event evt;
            //Command_Info selection = selection_p as Command_Info;

            /* Set up the menu */
            menu = new Menu_Type(Menu_Type.skin_id.SCROLL, commands_menu);
            menu.priv(list.list.Length, list.list);
            menu.layout(area);

            /* Set up the screen */
            Utilities.screen_save();
            Utilities.window_make(21, 3, 62, 17);

            /* Select an entry */
            evt = menu.select(0, true);

            /* Load de screen */
            Utilities.screen_load();

            if (evt.type == ui_event_type.EVT_SELECT)
                selection_p = list.list[menu.cursor]; //This was originally selection as above

            return false;
        }
예제 #5
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);
        }
예제 #6
0
        /* ================== SKINS ============== */
        /* Scrolling menu */
        /* Find the position of a cursor given a screen address */
        static int scrolling_get_cursor(int row, int col, int n, int top, Region loc)
        {
            throw new NotImplementedException();
            //int cursor = row - loc.row + top;
            //if (cursor >= n) cursor = n - 1;

            //return cursor;
        }
예제 #7
0
        static void display_columns(Menu_Type menu, int cursor, ref int top, Region loc)
        {
            throw new NotImplementedException();
            //int c, r;
            //int w, h;
            //int n = menu.filter_list ? menu.filter_count : menu.count;
            //int col = loc.col;
            //int row = loc.row;
            //int rows_per_page = loc.page_rows;
            //int cols = (n + rows_per_page - 1) / rows_per_page;
            //int colw = 23;

            //Term_get_size(&w, &h);

            //if ((colw * cols) > (w - col))
            //    colw = (w - col) / cols;

            //for (c = 0; c < cols; c++)
            //{
            //    for (r = 0; r < rows_per_page; r++)
            //    {
            //        int pos = c * rows_per_page + r;
            //        bool is_cursor = (pos == cursor);

            //        if (pos < n)
            //            display_menu_row(menu, pos, 0, is_cursor,
            //                    row + r, col + c * colw, colw);
            //    }
            //}

            //if (menu.cursor >= 0)
            //    Term_gotoxy(col + (cursor / rows_per_page) * colw,
            //            row + (cursor % rows_per_page) - *top);
        }
예제 #8
0
        /*** Multi-column menus ***/
        /* Find the position of a cursor given a screen address */
        static int columns_get_cursor(int row, int col, int n, int top, Region loc)
        {
            throw new NotImplementedException();
            //int rows_per_page = loc.page_rows;
            //int colw = loc.width / (n + rows_per_page - 1) / rows_per_page;
            //int cursor = row + rows_per_page * (col - loc.col) / colw;

            //if (cursor < 0) cursor = 0;	/* assert: This should never happen */
            //if (cursor >= n) cursor = n - 1;

            //return cursor;
        }
예제 #9
0
 public bool layout(Region loc)
 {
     boundary = loc;
     return menu_calc_size();
 }
예제 #10
0
        static void display_resistance_panel(player_flag_record[] resists, int size, Region bounds)
        {
            Player.Player p_ptr = Player.Player.instance;
            int col = bounds.col;
            int row = bounds.row;
            Term.putstr(col, row++, RES_COLS, ConsoleColor.White, "      abcdefghijkl@");
            for (int i = 0; i < size-3; i++, row++)
            {
                ConsoleColor name_attr = ConsoleColor.White;
                Term.gotoxy(col+6, row);
                /* repeated extraction of flags is inefficient but more natural */
                for (int j = Misc.INVEN_WIELD; j <= Misc.INVEN_TOTAL; j++)
                {
                    Object.Object o_ptr = p_ptr.inventory[j];
                    Bitflag f = new Bitflag(Object_Flag.SIZE);

                    ConsoleColor[] alternatingcols = new ConsoleColor[]{ ConsoleColor.Gray, ConsoleColor.DarkGray };
                    ConsoleColor attr = alternatingcols[j % 2]; /* alternating columns */
                    char sym = '.';

                    bool res, imm, vuln;

                    /* Wipe flagset */
                    f.wipe();

                    if (j < Misc.INVEN_TOTAL && o_ptr.kind != null)
                    {
                        o_ptr.object_flags_known(ref f);
                    }
                    else if (j == Misc.INVEN_TOTAL)
                    {
                        Player.Player.player_flags(ref f);

                        /* If the race has innate infravision/digging, force the corresponding flag
                           here.  If we set it in player_flags(), then all callers of that
                           function will think the infravision is caused by equipment. */
                        if (p_ptr.Race.infra > 0)
                            f.on(Object_Flag.INFRA.value);
                        if (p_ptr.Race.r_skills[(int)Skill.DIGGING] > 0)
                            f.on(Object_Flag.TUNNEL.value);
                    }

                    res = f.has(resists[i].res_flag.value);
                    imm = f.has(resists[i].im_flag.value);
                    vuln = f.has(resists[i].vuln_flag.value);

                    if (imm) name_attr = ConsoleColor.DarkGreen;
                    else if (res && name_attr == ConsoleColor.White) name_attr = ConsoleColor.Cyan;

                    if (vuln) sym = '-';
                    else if (imm) sym = '*';
                    else if (res) sym = '+';
                    else if ((j < Misc.INVEN_TOTAL) && o_ptr.kind != null &&
                        !o_ptr.object_flag_is_known(resists[i].res_flag.value)) sym = '?';
                    Term.addch(attr, sym);
                }
                Term.putstr(col, row, 6, name_attr, resists[i].name.ToString());
            }
            Term.putstr(col, row++, RES_COLS, ConsoleColor.White, "      abcdefghijkl@");
            /* Equippy */
            display_player_equippy(row++, col+6);
        }
예제 #11
0
        static void display_panel(Data_Panel[] panel, int count, bool left_adj, Region bounds)
        {
            int i;
            string buffer;
            int col = bounds.col;
            int row = bounds.row;
            int w = bounds.width;
            int offset = 0;

            bounds.erase();

            if (left_adj)
            {
                for (i = 0; i < count; i++)
                {
                    int len = panel[i].label.Length;
                    if (offset < len) offset = len;
                }
                offset += 2;
            }

            for (i = 0; i < count; i++, row++)
            {
                int len;
                if (panel[i].label.Length > 0) continue;
                Term.putstr(col, row, panel[i].label.Length, ConsoleColor.White, panel[i].label);

                buffer = String.Format(panel[i].fmt, panel[i].value[0].value, panel[i].value[1].value);

                len = buffer.Length;
                len = len < w - offset ? len : w - offset - 1;
                if (left_adj)
                    Term.putstr(col+offset, row, len, panel[i].color, buffer);
                else
                    Term.putstr(col+w-len, row, len, panel[i].color, buffer);
            }
        }