Пример #1
0
        /* Set up one of our menus ready to display choices for a birth question.
         * This is slightly involved. */
        static void init_birth_menu(ref Menu_Type menu, int n_choices, int initial_choice, Region reg, bool allow_random, Menu_Type.browse_hook_func aux)
        {
            birthmenu_data menu_data;

            /* Initialise a basic menu */
            menu = new Menu_Type(Menu_Type.skin_id.SCROLL, birth_iter);

            /* A couple of behavioural flags - we want selections letters in
             * lower case and a double tap to act as a selection. */
            menu.selections = TextUI.lower_case;
            menu.flags      = (int)Menu_Type.menu_type_flags.MN_DBL_TAP;

            /* Copy across the game's suggested initial selection, etc. */
            menu.cursor = initial_choice;

            /* Allocate sufficient space for our own bits of menu information. */
            menu_data = new birthmenu_data();

            /* Allocate space for an array of menu item texts and help texts
             * (where applicable) */
            menu_data.items        = new string[n_choices];
            menu_data.allow_random = allow_random;

            /* Set private data */
            menu.priv(n_choices, menu_data);

            /* Set up the "browse" hook to display help text (where applicable). */
            menu.browse_hook = aux;

            /* Lay out the menu appropriately */
            menu.layout(reg);
        }
Пример #2
0
 /* ------------------------------------------------------------------------
  * MN_STRINGS HELPER FUNCTIONS
  *
  * MN_STRINGS is the type of menu iterator that displays a simple list of
  * strings - no action is associated, as selection will just return the index.
  * ------------------------------------------------------------------------ */
 static void display_string(Menu_Type m, int oid, bool cursor, int row, int col, int width)
 {
     throw new NotImplementedException();
     //const char **items = menu_priv(m);
     //byte color = curs_attrs[CURS_KNOWN][0 != cursor];
     //Term_putstr(col, row, width, color, items[oid]);
 }
Пример #3
0
        static ui_event column_process_direction(Menu_Type m, int dir)
        {
            throw new NotImplementedException();
            //ui_event out = EVENT_EMPTY;

            //int n = m.filter_list ? m.filter_count : m.count;

            //region *loc = &m.active;
            //int rows_per_page = loc.page_rows;
            //int cols = (n + rows_per_page - 1) / rows_per_page;

            //if (ddx[dir])
            //    m.cursor += ddx[dir] * rows_per_page;
            //if (ddy[dir])
            //    m.cursor += ddy[dir];

            ///* Adjust to the correct locations (roughly) */
            //if (m.cursor > n)
            //    m.cursor = m.cursor % rows_per_page;
            //else if (m.cursor < 0)
            //    m.cursor = (rows_per_page * cols) + m.cursor;

            //out.type = EVT_MOVE;
            //return out;
        }
Пример #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
        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);
        }
Пример #6
0
        static ui_event scroll_process_direction(Menu_Type m, int dir)
        {
            ui_event eout = new ui_event();

            /* Reject diagonals */
            if (Misc.ddx[dir] != 0 && Misc.ddy[dir] != 0)
            {
                //this was empty. TODO: Maybe return null?
            }

            /* Forward/back */
            else if (Misc.ddx[dir] != 0)
            {
                eout.type = Misc.ddx[dir] < 0 ? ui_event_type.EVT_ESCAPE : ui_event_type.EVT_SELECT;
            }

            /* Move up or down to the next valid & visible row */
            else if (Misc.ddy[dir] != 0)
            {
                m.cursor += Misc.ddy[dir];
                eout.type = ui_event_type.EVT_MOVE;
            }

            return(eout);
        }
Пример #7
0
        public static void knowledge_init()
        {
            /* Initialize the menus */
            knowledge_menu = new Menu_Type(Menu_Type.skin_id.SCROLL, Menu_Type.menu_find_iter(Menu_Type.menu_iter_id.ACTIONS));
            knowledge_menu.priv(knowledge_actions.Length, knowledge_actions);

            knowledge_menu.title      = "Display current knowledge";
            knowledge_menu.selections = lower_case;

            /* initialize other static variables */
            if (obj_group_order == null)
            {
                int i;
                int gid = -1;

                obj_group_order = new int[Object.TVal.TV_GOLD + 1];
                Utilities.atexit(cleanup_cmds);

                /* Allow for missing values */
                for (i = 0; i <= Object.TVal.TV_GOLD; i++)
                {
                    obj_group_order[i] = -1;
                }

                for (i = 0; 0 != object_text_order[i].tval; i++)
                {
                    if (object_text_order[i].name != null)
                    {
                        gid = i;
                    }
                    obj_group_order[object_text_order[i].tval] = gid;
                }
            }
        }
Пример #8
0
        /* Display an entry on a command menu */
        static void cmd_sub_entry(Menu_Type menu, int oid, bool cursor, int row, int col, int width)
        {
            ConsoleColor attr = (cursor ? ConsoleColor.Cyan : ConsoleColor.White);

            Command_Info[] commands = menu.menu_data as Command_Info[];

            //(void)width;

            /* Write the description */
            Term.putstr(col, row, -1, attr, commands[oid].desc);

            /* Include keypress */
            Term.addch(attr, ' ');
            Term.addch(attr, '(');

            /* KTRL()ing a control character does not alter it at all */
            if (UIEvent.KTRL(commands[oid].key) == commands[oid].key)
            {
                Term.addch(attr, '^');
                Term.addch(attr, UIEvent.UN_KTRL((keycode_t)commands[oid].key));
            }
            else
            {
                Term.addch(attr, commands[oid].key);
            }

            Term.addch(attr, ')');
        }
Пример #9
0
        static void menu_action_display(Menu_Type m, int oid, bool cursor, int row, int col, int width)
        {
            throw new NotImplementedException();
            //menu_action *acts = menu_priv(m);
            //byte color = curs_attrs[!(acts[oid].flags & (MN_ACT_GRAYED))][0 != cursor];

            //display_action_aux(&acts[oid], color, row, col, width);
        }
Пример #10
0
        static char column_get_tag(Menu_Type menu, int pos)
        {
            throw new NotImplementedException();
            //if (menu.selections)
            //    return menu.selections[pos];

            //return 0;
        }
Пример #11
0
        static char scroll_get_tag(Menu_Type menu, int pos)
        {
            throw new NotImplementedException();
            //if (menu.selections)
            //    return menu.selections[pos - menu.top];

            //return 0;
        }
Пример #12
0
        /* A custom "display" function for our menus that simply displays the
         * text from our stored data in a different colour if it's currently
         * selected. */
        static void birthmenu_display(Menu_Type menu, int oid, bool cursor, int row, int col, int width)
        {
            birthmenu_data data = menu.menu_data as birthmenu_data;

            ConsoleColor attr = Menu_Type.curs_attrs[(int)Menu_Type.CURS.KNOWN][cursor?1:0];

            Utilities.c_put_str(attr, data.items[oid], row, col);
        }
Пример #13
0
        static int menu_action_valid(Menu_Type m, int oid)
        {
            Menu_Action[] acts = m.menu_data as Menu_Action[];

            if ((acts[oid].flags & Menu_Action.MN_ACT_HIDDEN) != 0)
            {
                return(2);
            }

            return((acts[oid].name != null) ? 1 : 0);            //I may have swapped these two when I converted to bool...
        }
Пример #14
0
 static bool cmd_list_action(Menu_Type m, ui_event mevent, int oid)
 {
     if (mevent.type == ui_event_type.EVT_SELECT)
     {
         return(cmd_menu(ref Command_List.all[oid], m.menu_data));
     }
     else
     {
         return(false);
     }
 }
Пример #15
0
        /* Cleans up our stored menu info when we've finished with it. */
        static void free_birth_menu(Menu_Type menu)
        {
            //We're good, let garbage collection handle it
            //struct birthmenu_data *data = menu.menu_data;

            //if (data)
            //{
            //    mem_free(data.items);
            //    mem_free(data);
            //}
        }
Пример #16
0
        static bool menu_action_handle(Menu_Type m, ui_event Event, int oid)
        {
            throw new NotImplementedException();
            //menu_action *acts = menu_priv(m);

            //if (event.type == EVT_SELECT)
            //{
            //    if (!(acts.flags & MN_ACT_GRAYED) && acts[oid].action)
            //    {
            //        acts[oid].action(acts[oid].name, m.cursor);
            //        return true;
            //    }
            //}

            //return false;
        }
Пример #17
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);
            }
        }
Пример #18
0
 static bool cmd_list_action(Menu_Type m, ui_event mevent, int oid)
 {
     if (mevent.type == ui_event_type.EVT_SELECT)
         return cmd_menu(ref Command_List.all[oid], m.menu_data);
     else
         return false;
 }
Пример #19
0
        static ui_event scroll_process_direction(Menu_Type m, int dir)
        {
            ui_event eout = new ui_event();

            /* Reject diagonals */
            if(Misc.ddx[dir] != 0 && Misc.ddy[dir] != 0) {
                //this was empty. TODO: Maybe return null?
            }

            /* Forward/back */
            else if(Misc.ddx[dir] != 0)
                eout.type = Misc.ddx[dir] < 0 ? ui_event_type.EVT_ESCAPE : ui_event_type.EVT_SELECT;

            /* Move up or down to the next valid & visible row */
            else if(Misc.ddy[dir] != 0) {
                m.cursor += Misc.ddy[dir];
                eout.type = ui_event_type.EVT_MOVE;
            }

            return eout;
        }
Пример #20
0
        static char scroll_get_tag(Menu_Type menu, int pos)
        {
            throw new NotImplementedException();
            //if (menu.selections)
            //    return menu.selections[pos - menu.top];

            //return 0;
        }
Пример #21
0
        static int menu_action_valid(Menu_Type m, int oid)
        {
            Menu_Action[] acts = m.menu_data as Menu_Action[];

            if ((acts[oid].flags & Menu_Action.MN_ACT_HIDDEN) != 0)
                return 2;

            return (acts[oid].name != null) ? 1 : 0; //I may have swapped these two when I converted to bool...
        }
Пример #22
0
 /* ------------------------------------------------------------------------
  * MN_ACTIONS HELPER FUNCTIONS
  *
  * MN_ACTIONS is the type of menu iterator that displays a simple list of
  * menu_actions.
  * ------------------------------------------------------------------------ */
 static char menu_action_tag(Menu_Type m, int oid)
 {
     throw new NotImplementedException();
     //menu_action *acts = menu_priv(m);
     //return acts[oid].tag;
 }
Пример #23
0
        /* Display an entry on a command menu */
        static void cmd_sub_entry(Menu_Type menu, int oid, bool cursor, int row, int col, int width)
        {
            ConsoleColor attr = (cursor ? ConsoleColor.Cyan : ConsoleColor.White);
            Command_Info[] commands = menu.menu_data as Command_Info[];

            //(void)width;

            /* Write the description */
            Term.putstr(col, row, -1, attr, commands[oid].desc);

            /* Include keypress */
            Term.addch(attr, ' ');
            Term.addch(attr, '(');

            /* KTRL()ing a control character does not alter it at all */
            if (UIEvent.KTRL(commands[oid].key) == commands[oid].key)
            {
                Term.addch(attr, '^');
                Term.addch(attr, UIEvent.UN_KTRL((keycode_t)commands[oid].key));
            }
            else
            {
                Term.addch(attr, commands[oid].key);
            }

            Term.addch(attr, ')');
        }
Пример #24
0
 /* ------------------------------------------------------------------------
  * MN_STRINGS HELPER FUNCTIONS
  *
  * MN_STRINGS is the type of menu iterator that displays a simple list of
  * strings - no action is associated, as selection will just return the index.
  * ------------------------------------------------------------------------ */
 static void display_string(Menu_Type m, int oid, bool cursor, int row, int col, int width)
 {
     throw new NotImplementedException();
     //const char **items = menu_priv(m);
     //byte color = curs_attrs[CURS_KNOWN][0 != cursor];
     //Term_putstr(col, row, width, color, items[oid]);
 }
Пример #25
0
 public static void store_menu_recalc(Menu_Type m)
 {
     Store store = current_store();
     m.priv(store.stock_num, store.stock);
 }
Пример #26
0
        /*
         *
         */
        static bool store_menu_handle(Menu_Type m, ui_event mevent, int oid)
        {
            bool processed = true;

            if (mevent.type == ui_event_type.EVT_SELECT)
            {
                /* Nothing for now, except "handle" the event */
                return true;
                /* In future, maybe we want a display a list of what you can do. */
            }
            else if (mevent.type == ui_event_type.EVT_KBRD)
            {
                bool storechange = false;

                switch ((char)mevent.key.code) {
                    case 's':
                    case 'd': storechange = store_sell(); break;
                    case 'p':
                    case 'g': storechange = store_purchase(oid); break;
                    case 'l':
                    case 'x': store_examine(oid); break;

                    case '?': {
                        /* Toggle help */
                        if ((store_flags & STORE_SHOW_HELP) != 0)
                            store_flags &= ~(STORE_SHOW_HELP);
                        else
                            store_flags |= STORE_SHOW_HELP;

                        /* Redisplay */
                        store_flags |= STORE_INIT_CHANGE;
                        break;
                    }

                    case '=': {
                        Do_Command.options();
                        store_menu_set_selections(m, false);
                        break;
                    }

                    default:
                        processed = store_process_command_key(mevent.key);
                        break;
                }

                if ((char)mevent.key.code == UIEvent.KTRL('R')) {
                    /* XXX redraw functionality should be another menu_iter handler */
                    Term.clear();
                    store_flags |= (STORE_FRAME_CHANGE | STORE_GOLD_CHANGE);
                }

                /* Let the game handle any core commands (equipping, etc) */
                Game_Command.process_command(cmd_context.CMD_STORE, true);

                if (storechange)
                    store_menu_recalc(m);

                if (processed) {
                    Game_Event.signal(Game_Event.Event_Type.INVENTORY);
                    Game_Event.signal(Game_Event.Event_Type.EQUIPMENT);
                }

                /* Notice and handle stuff */
                Misc.p_ptr.notice_stuff();
                Misc.p_ptr.handle_stuff();

                /* Display the store */
                store_display_recalc(m);
                store_menu_recalc(m);
                store_redraw();

                return processed;
            }

            return false;
        }
Пример #27
0
        static void cmd_list_entry(Menu_Type menu, int oid, bool cursor, int row, int col, int width)
        {
            ConsoleColor attr = (cursor ? ConsoleColor.Cyan : ConsoleColor.White);

            Term.putstr(col, row, -1, attr, Command_List.all[oid].name);
        }
Пример #28
0
        /* ------------------------------------------------------------------------
         * MN_ACTIONS HELPER FUNCTIONS
         *
         * MN_ACTIONS is the type of menu iterator that displays a simple list of
         * menu_actions.
         * ------------------------------------------------------------------------ */

        static char menu_action_tag(Menu_Type m, int oid)
        {
            throw new NotImplementedException();
            //menu_action *acts = menu_priv(m);
            //return acts[oid].tag;
        }
Пример #29
0
 static void cmd_list_entry(Menu_Type menu, int oid, bool cursor, int row, int col, int width)
 {
     ConsoleColor attr = (cursor ? ConsoleColor.Cyan : ConsoleColor.White);
     Term.putstr(col, row, -1, attr, Command_List.all[oid].name);
 }
Пример #30
0
        static void menu_action_display(Menu_Type m, int oid, bool cursor, int row, int col, int width)
        {
            throw new NotImplementedException();
            //menu_action *acts = menu_priv(m);
            //byte color = curs_attrs[!(acts[oid].flags & (MN_ACT_GRAYED))][0 != cursor];

            //display_action_aux(&acts[oid], color, row, col, width);
        }
Пример #31
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;
        }
Пример #32
0
        static bool menu_action_handle(Menu_Type m, ui_event Event, int oid)
        {
            throw new NotImplementedException();
            //menu_action *acts = menu_priv(m);

            //if (event.type == EVT_SELECT)
            //{
            //    if (!(acts.flags & MN_ACT_GRAYED) && acts[oid].action)
            //    {
            //        acts[oid].action(acts[oid].name, m.cursor);
            //        return true;
            //    }
            //}

            //return false;
        }
Пример #33
0
        /* Allow the user to select from the current menu, and return the
         * corresponding command to the game.  Some actions are handled entirely
         * by the UI (displaying help text, for instance). */
        static birth_stage menu_question(birth_stage current, Menu_Type current_menu, Command_Code choice_command)
        {
            birthmenu_data menu_data = current_menu.menu_data as birthmenu_data;

            birth_stage next = birth_stage.BIRTH_RESET;

            /* Print the question currently being asked. */
            clear_question();
            Term.putstr(QUESTION_COL, QUESTION_ROW, -1, ConsoleColor.Yellow, menu_data.hint);

            current_menu.cmd_keys = "?=*\x18";                   /* ?, =, *, <ctl-X> */

            while (next == birth_stage.BIRTH_RESET)
            {
                /* Display the menu, wait for a selection of some sort to be made. */
                ui_event cx = current_menu.select(ui_event_type.EVT_KBRD, false);

                /* As all the menus are displayed in "hierarchical" style, we allow
                 * use of "back" (left arrow key or equivalent) to step back in
                 * the proces as well as "escape". */
                if (cx.type == ui_event_type.EVT_ESCAPE)
                {
                    next = birth_stage.BIRTH_BACK;
                }
                else if (cx.type == ui_event_type.EVT_SELECT)
                {
                    if (current == birth_stage.BIRTH_ROLLER_CHOICE)
                    {
                        Game_Command.insert(Command_Code.FINALIZE_OPTIONS);

                        if (current_menu.cursor != 0)
                        {
                            /* Do a first roll of the stats */
                            Game_Command.insert(Command_Code.ROLL_STATS);
                            next = current + 2;
                        }
                        else
                        {
                            /*
                             * Make sure we've got a point-based char to play with.
                             * We call point_based_start here to make sure we get
                             * an update on the points totals before trying to
                             * display the screen.  The call to CMD_RESET_STATS
                             * forces a rebuying of the stats to give us up-to-date
                             * totals.  This is, it should go without saying, a hack.
                             */
                            point_based_start();
                            Game_Command.insert(Command_Code.RESET_STATS);
                            Game_Command.get_top().set_arg_choice(0, 1);
                            next = current + 1;
                        }
                    }
                    else
                    {
                        Game_Command.insert(choice_command);
                        Game_Command.get_top().set_arg_choice(0, current_menu.cursor);
                        next = current + 1;
                    }
                }
                else if (cx.type == ui_event_type.EVT_KBRD)
                {
                    /* '*' chooses an option at random from those the game's provided. */
                    if (cx.key.code == (keycode_t)'*' && menu_data.allow_random)
                    {
                        current_menu.cursor = Random.randint0(current_menu.count);
                        Game_Command.insert(choice_command);
                        Game_Command.get_top().set_arg_choice(0, current_menu.cursor);
                        current_menu.refresh(false);
                        next = current + 1;
                    }
                    else if (cx.key.code == (keycode_t)'=')
                    {
                        Do_Command.options_birth();
                        next = current;
                    }
                    else if (cx.key.code == (keycode_t)UIEvent.KTRL('X'))
                    {
                        Game_Command.insert(Command_Code.QUIT);
                        next = birth_stage.BIRTH_COMPLETE;
                    }
                    else if (cx.key.code == (keycode_t)'?')
                    {
                        Do_Command.help();
                    }
                }
            }

            return(next);
        }
Пример #34
0
        public static int get_birth_command(bool wait)
        {
            birth_stage next = current_stage;

            switch (current_stage)
            {
            case birth_stage.BIRTH_RESET:
            {
                Game_Command.insert(Command_Code.BIRTH_RESET);

                roller = birth_stage.BIRTH_RESET;

                if (quickstart_allowed)
                {
                    next = birth_stage.BIRTH_QUICKSTART;
                }
                else
                {
                    next = birth_stage.BIRTH_SEX_CHOICE;
                }

                break;
            }

            case birth_stage.BIRTH_QUICKSTART:
            {
                Files.display_player(0);
                next = get_quickstart_command();
                break;
            }

            case birth_stage.BIRTH_SEX_CHOICE:
            case birth_stage.BIRTH_CLASS_CHOICE:
            case birth_stage.BIRTH_RACE_CHOICE:
            case birth_stage.BIRTH_ROLLER_CHOICE:
            {
                Menu_Type    menu    = sex_menu;
                Command_Code command = Command_Code.CHOOSE_SEX;

                Term.clear();
                print_menu_instructions();

                if (current_stage > birth_stage.BIRTH_SEX_CHOICE)
                {
                    sex_menu.refresh(false);
                    menu    = race_menu;
                    command = Command_Code.CHOOSE_RACE;
                }

                if (current_stage > birth_stage.BIRTH_RACE_CHOICE)
                {
                    race_menu.refresh(false);
                    menu    = class_menu;
                    command = Command_Code.CHOOSE_CLASS;
                }

                if (current_stage > birth_stage.BIRTH_CLASS_CHOICE)
                {
                    class_menu.refresh(false);
                    menu    = roller_menu;
                    command = Command_Code.NULL;
                }

                next = menu_question(current_stage, menu, command);

                if (next == birth_stage.BIRTH_BACK)
                {
                    next = current_stage - 1;
                }

                /* Make sure that the character gets reset before quickstarting */
                if (next == birth_stage.BIRTH_QUICKSTART)
                {
                    next = birth_stage.BIRTH_RESET;
                }

                break;
            }

            case birth_stage.BIRTH_POINTBASED:
            {
                roller = birth_stage.BIRTH_POINTBASED;

                if (prev > birth_stage.BIRTH_POINTBASED)
                {
                    point_based_start();
                }

                next = point_based_command();

                if (next == birth_stage.BIRTH_BACK)
                {
                    next = birth_stage.BIRTH_ROLLER_CHOICE;
                }

                if (next != birth_stage.BIRTH_POINTBASED)
                {
                    point_based_stop();
                }

                break;
            }

            case birth_stage.BIRTH_ROLLER:
            {
                roller = birth_stage.BIRTH_ROLLER;
                next   = roller_command(prev < birth_stage.BIRTH_ROLLER);
                if (next == birth_stage.BIRTH_BACK)
                {
                    next = birth_stage.BIRTH_ROLLER_CHOICE;
                }

                break;
            }

            case birth_stage.BIRTH_NAME_CHOICE:
            {
                if (prev < birth_stage.BIRTH_NAME_CHOICE)
                {
                    Files.display_player(0);
                }

                next = get_name_command();
                if (next == birth_stage.BIRTH_BACK)
                {
                    next = roller;
                }

                break;
            }

            case birth_stage.BIRTH_FINAL_CONFIRM:
            {
                if (prev < birth_stage.BIRTH_FINAL_CONFIRM)
                {
                    Files.display_player(0);
                }

                next = get_confirm_command();
                if (next == birth_stage.BIRTH_BACK)
                {
                    next = birth_stage.BIRTH_NAME_CHOICE;
                }

                break;
            }
            }

            prev          = current_stage;
            current_stage = next;

            return(0);
        }
Пример #35
0
        static char column_get_tag(Menu_Type menu, int pos)
        {
            throw new NotImplementedException();
            //if (menu.selections)
            //    return menu.selections[pos];

            //return 0;
        }
Пример #36
0
        static ui_event column_process_direction(Menu_Type m, int dir)
        {
            throw new NotImplementedException();
            //ui_event out = EVENT_EMPTY;

            //int n = m.filter_list ? m.filter_count : m.count;

            //region *loc = &m.active;
            //int rows_per_page = loc.page_rows;
            //int cols = (n + rows_per_page - 1) / rows_per_page;

            //if (ddx[dir])
            //    m.cursor += ddx[dir] * rows_per_page;
            //if (ddy[dir])
            //    m.cursor += ddy[dir];

            ///* Adjust to the correct locations (roughly) */
            //if (m.cursor > n)
            //    m.cursor = m.cursor % rows_per_page;
            //else if (m.cursor < 0)
            //    m.cursor = (rows_per_page * cols) + m.cursor;

            //out.type = EVT_MOVE;
            //return out;
        }
Пример #37
0
        /*
         * Redisplay a single store entry
         */
        static void store_display_entry(Menu_Type menu, int oid, bool cursor, int row, int col, int width)
        {
            Object.Object o_ptr;
            int x;
            Object.Object.Detail desc = Object.Object.Detail.PREFIX;

            //char o_name[80];
            //char out_val[160];
            string o_name;
            string out_val;
            ConsoleColor colour;

            Store store = current_store();

            Misc.assert(store != null);

            /* Get the object */
            o_ptr = store.stock[oid];

            /* Describe the object - preserving insriptions in the home */
            if (store.sidx == STORE.HOME) desc = Object.Object.Detail.FULL;
            else desc = Object.Object.Detail.FULL | Object.Object.Detail.STORE;
            o_name = o_ptr.object_desc(Object.Object.Detail.PREFIX | desc);

            /* Display the object */
            Utilities.c_put_str(Misc.tval_to_attr[o_ptr.tval & 0x7F], o_name, row, col);

            /* Show weights */
            colour = Menu_Type.curs_attrs[(int)Menu_Type.CURS.KNOWN][cursor?1:0];
            //out_val = String.Format("%3d.%d lb", o_ptr.weight / 10, o_ptr.weight % 10);
            out_val = String.Format("{0}.{1} lb", o_ptr.weight / 10, o_ptr.weight % 10);
            Utilities.c_put_str(colour, out_val, row, scr_places_x[(int)LOC.WEIGHT]);

            /* Describe an object (fully) in a store */
            if (store.sidx != STORE.HOME)
            {
                /* Extract the "minimum" price */
                x = price_item(o_ptr, false, 1);

                /* Make sure the player can afford it */
                if ((int) Misc.p_ptr.au < (int) x)
                    colour = Menu_Type.curs_attrs[(int)Menu_Type.CURS.UNKNOWN][cursor?1:0];

                /* Actually draw the price */
                if (((o_ptr.tval == TVal.TV_WAND) || (o_ptr.tval == TVal.TV_STAFF)) && (o_ptr.number > 1))
                    //strnfmt(out_val, sizeof out_val, "%9ld avg", (long)x);
                    out_val = String.Format("{0} avg", x);
                else
                    //strnfmt(out_val, sizeof out_val, "%9ld    ", (long)x);
                    out_val = String.Format("{0}    ", (long)x);

                Utilities.c_put_str(colour, out_val, row, scr_places_x[(int)LOC.PRICE]);
            }
        }
Пример #38
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);
        }
Пример #39
0
        /*
         * This function sets up screen locations based on the current term size.
         *
         * Current screen layout:
         *  line 0: reserved for messages
         *  line 1: shopkeeper and their purse / item buying price
         *  line 2: empty
         *  line 3: table headers
         *
         *  line 4: Start of items
         *
         * If help is turned off, then the rest of the display goes as:
         *
         *  line (height - 4): end of items
         *  line (height - 3): "more" prompt
         *  line (height - 2): empty
         *  line (height - 1): Help prompt and remaining gold
         *
         * If help is turned on, then the rest of the display goes as:
         *
         *  line (height - 7): end of items
         *  line (height - 6): "more" prompt
         *  line (height - 4): gold remaining
         *  line (height - 3): command help
         */
        public static void store_display_recalc(Menu_Type m)
        {
            int wid, hgt;
            Region loc;

            Store store = current_store();

            Term.get_size(out wid, out hgt);

            /* Clip the width at a maximum of 104 (enough room for an 80-char item name) */
            if (wid > 104) wid = 104;

            /* Clip the text_out function at two smaller than the screen width */
            Misc.text_out_wrap = wid - 2;

            /* X co-ords first */
            scr_places_x[(int)LOC.PRICE] = wid - 14;
            scr_places_x[(int)LOC.AU] = wid - 26;
            scr_places_x[(int)LOC.OWNER] = wid - 2;
            scr_places_x[(int)LOC.WEIGHT] = wid - 14;

            /* Add space for for prices */
            if (store.sidx != STORE.HOME)
                scr_places_x[(int)LOC.WEIGHT] -= 10;

            /* Then Y */
            scr_places_y[(int)LOC.OWNER] = 1;
            scr_places_y[(int)LOC.HEADER] = 3;

            /* If we are displaying help, make the height smaller */
            if ((store_flags & (STORE_SHOW_HELP)) != 0)
                hgt -= 3;

            scr_places_y[(int)LOC.MORE] = hgt - 3;
            scr_places_y[(int)LOC.AU] = hgt - 1;

            loc = m.boundary;

            /* If we're displaying the help, then put it with a line of padding */
            if ((store_flags & (STORE_SHOW_HELP)) != 0)
            {
                scr_places_y[(int)LOC.HELP_CLEAR] = hgt - 1;
                scr_places_y[(int)LOC.HELP_PROMPT] = hgt;
                loc.page_rows = -5;
            }
            else
            {
                scr_places_y[(int)LOC.HELP_CLEAR] = hgt - 2;
                scr_places_y[(int)LOC.HELP_PROMPT] = hgt - 1;
                loc.page_rows = -2;
            }

            m.layout(loc);
        }
Пример #40
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);
        }
Пример #41
0
        public static void store_menu_set_selections(Menu_Type menu, bool knowledge_menu)
        {
            if (knowledge_menu)
            {
                if (Option.rogue_like_commands.value)
                {
                    /* These two can't intersect! */
                    menu.cmd_keys = "?Ieilx";
                    menu.selections = "abcdfghjkmnopqrstuvwyz134567";
                }
                /* Original */
                else
                {
                    /* These two can't intersect! */
                    menu.cmd_keys = "?Ieil";
                    menu.selections = "abcdfghjkmnopqrstuvwxyz13456";
                }
            }
            else
            {
                /* Roguelike */
                if (Option.rogue_like_commands.value)
                {
                    /* These two can't intersect! */
                    menu.cmd_keys = "\x04\x05\x10?={}~CEIPTdegilpswx"; /* \x10 = ^p , \x04 = ^D, \x05 = ^E */
                    menu.selections = "abcfmnoqrtuvyz13456790ABDFGH";
                }

                /* Original */
                else
                {
                    /* These two can't intersect! */
                    menu.cmd_keys = "\x05\x010?={}~CEIbdegiklpstwx"; /* \x05 = ^E, \x10 = ^p */
                    menu.selections = "acfhjmnoqruvyz13456790ABDFGH";
                }
            }
        }
Пример #42
0
        /*
         * Enter a store, and interact with it.
         */
        public static void store(Command_Code code, cmd_arg[] args)
        {
            /* Take note of the store number from the terrain feature */
            Store store = Store.current_store();
            Menu_Type menu;

            /* Verify that there is a store */
            if (store == null) {
                Utilities.msg("You see no store here.");
                return;
            }

            /* Check if we can enter the store */
            if (Option.birth_no_stores.value) {
                Utilities.msg("The doors are locked.");
                return;
            }

            /* Shut down the normal game view - it won't be updated - and start
               up the store state. */
            Game_Event.signal(Game_Event.Event_Type.LEAVE_GAME);
            Game_Event.signal(Game_Event.Event_Type.ENTER_STORE);

            /* Forget the view */
            Cave.forget_view();

            /* Reset the command variables */
            Misc.p_ptr.command_arg = 0;

            /*** Display ***/

            /* Save current screen (ie. dungeon) */
            Utilities.screen_save();

            /*** Inventory display ***/

            /* Wipe the menu and set it up */
            menu = new Menu_Type(Menu_Type.skin_id.SCROLL, Store.store_menu);
            menu.layout(Store.store_menu_region);

            Store.store_menu_set_selections(menu, false);
            Store.store_flags = Store.STORE_INIT_CHANGE;
            Store.store_display_recalc(menu);
            Store.store_menu_recalc(menu);
            Store.store_redraw();

            /* Say a friendly hello. */
            if (store.sidx != STORE.HOME)
                Store.prt_welcome(store.owner);

            Term.msg_flag = false;
            menu.select(0, false);
            Term.msg_flag = false;

            /* Switch back to the normal game view. */
            Game_Event.signal(Game_Event.Event_Type.LEAVE_STORE);
            Game_Event.signal(Game_Event.Event_Type.ENTER_GAME);

            /* Take a turn */
            Misc.p_ptr.energy_use = 100;

            /* Flush messages XXX XXX XXX */
            Utilities.message_flush();

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

            /* Update the visuals */
            Misc.p_ptr.update |= (Misc.PU_UPDATE_VIEW | Misc.PU_MONSTERS);

            /* Redraw entire screen */
            Misc.p_ptr.redraw |= (uint)(Misc.PR_BASIC | Misc.PR_EXTRA);

            /* Redraw map */
            Misc.p_ptr.redraw |= (Misc.PR_MAP);
        }