Example #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);
        }
Example #2
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);
        }
Example #3
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);
        }
Example #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;
        }
Example #5
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);
        }