Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
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);
        }