Angband
|
Generic menu interaction functions. More...
#include "angband.h"
#include "cave.h"
#include "ui-target.h"
#include "ui-event.h"
#include "ui-input.h"
#include "ui-menu.h"
Data Structures | |
struct | menu_entry |
Functions | |
static void | display_menu_row (struct menu *menu, int pos, int top, bool cursor, int row, int col, int width) |
Forward declarations. More... | |
static bool | menu_calc_size (struct menu *menu) |
static bool | is_valid_row (struct menu *menu, int cursor) |
static bool | no_valid_row (struct menu *menu, int count) |
static void | display_action_aux (menu_action *act, byte color, int row, int col, int wid) |
Display an event, with possible preference overrides. More... | |
static char | menu_action_tag (struct menu *m, int oid) |
static int | menu_action_valid (struct menu *m, int oid) |
static void | menu_action_display (struct menu *m, int oid, bool cursor, int row, int col, int width) |
static bool | menu_action_handle (struct menu *m, const ui_event *event, int oid) |
static void | display_string (struct menu *m, int oid, bool cursor, int row, int col, int width) |
static int | scrolling_get_cursor (int row, int col, int n, int top, region *loc) |
Find the position of a cursor given a screen address. More... | |
static void | display_scrolling (struct menu *menu, int cursor, int *top, region *loc) |
Display current view of a skin. More... | |
static char | scroll_get_tag (struct menu *menu, int pos) |
static ui_event | scroll_process_direction (struct menu *m, int dir) |
static int | object_skin_get_cursor (int row, int col, int n, int top, region *loc) |
Find the position of a cursor given a screen address. More... | |
static void | object_skin_display (struct menu *menu, int cursor, int *top, region *loc) |
Display current view of a skin. More... | |
static char | object_skin_get_tag (struct menu *menu, int pos) |
static ui_event | object_skin_process_direction (struct menu *m, int dir) |
static int | columns_get_cursor (int row, int col, int n, int top, region *loc) |
static void | display_columns (struct menu *menu, int cursor, int *top, region *loc) |
static char | column_get_tag (struct menu *menu, int pos) |
static ui_event | column_process_direction (struct menu *m, int dir) |
static int | get_cursor_key (struct menu *menu, int top, struct keypress key) |
static menu_row_style_t | menu_row_style_for_validity (menu_row_validity_t row_valid) |
void | menu_refresh (struct menu *menu, bool reset_screen) |
Display a menu. More... | |
bool | menu_handle_mouse (struct menu *menu, const ui_event *in, ui_event *out) |
Handle mouse input in a menu. More... | |
static bool | menu_handle_action (struct menu *m, const ui_event *in) |
Handle any menu command keys / SELECT events. More... | |
bool | menu_handle_keypress (struct menu *menu, const ui_event *in, ui_event *out) |
Handle navigation keypresses. More... | |
ui_event | menu_select (struct menu *menu, int notify, bool popup) |
Run a menu. More... | |
const menu_iter * | menu_find_iter (menu_iter_id id) |
Return the menu iter struct for a given iter ID. More... | |
static const menu_skin * | menu_find_skin (skin_id id) |
void | menu_set_filter (struct menu *menu, const int filter_list[], int n) |
void | menu_release_filter (struct menu *menu) |
Remove any filters set on a menu by menu_set_filer(). More... | |
void | menu_ensure_cursor_valid (struct menu *m) |
Set the menu cursor to the next valid row. More... | |
bool | menu_layout (struct menu *m, const region *loc) |
Ready a menu for display in the region specified. More... | |
void | menu_setpriv (struct menu *menu, int count, void *data) |
Set menu private data and the number of menu items. More... | |
void * | menu_priv (struct menu *menu) |
Return menu private data, set with menu_setpriv(). More... | |
void | menu_init (struct menu *menu, skin_id skin_id, const menu_iter *iter) |
Initialise a menu, using the skin and iter functions specified. More... | |
struct menu * | menu_new (skin_id skin_id, const menu_iter *iter) |
Allocate and return a new, initialised, menu. More... | |
struct menu * | menu_new_action (menu_action *acts, size_t n) |
void | menu_free (struct menu *m) |
void | menu_set_cursor_x_offset (struct menu *m, int offset) |
Allow adjustment of the cursor's default x offset. More... | |
static int | dynamic_valid (struct menu *m, int oid) |
static void | dynamic_display (struct menu *m, int oid, bool cursor, int row, int col, int width) |
struct menu * | menu_dynamic_new (void) |
void | menu_dynamic_add_valid (struct menu *m, const char *text, int value, menu_row_validity_t valid) |
void | menu_dynamic_add (struct menu *m, const char *text, int value) |
void | menu_dynamic_add_label_valid (struct menu *m, const char *text, const char label, int value, char *label_list, menu_row_validity_t valid) |
void | menu_dynamic_add_label (struct menu *m, const char *text, const char label, int value, char *label_list) |
size_t | menu_dynamic_longest_entry (struct menu *m) |
void | menu_dynamic_calc_location (struct menu *m, int mx, int my) |
int | menu_dynamic_select (struct menu *m) |
void | menu_dynamic_free (struct menu *m) |
Variables | |
const byte | curs_attrs [2][2] |
Cursor colours. More... | |
const char | lower_case [] = "abcdefghijklmnopqrstuvwxyz" |
Some useful constants. More... | |
const char | upper_case [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
const char | all_letters [] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" |
static const menu_iter | menu_iter_actions |
Virtual function table for action_events. More... | |
static const menu_iter | menu_iter_strings |
static const menu_skin | menu_skin_scroll |
Virtual function table for scrollable menu skin. More... | |
static const menu_skin | menu_skin_object |
Virtual function table for object menu skin. More... | |
static const menu_skin | menu_skin_column |
static const menu_iter | dynamic_iter |
Generic menu interaction functions.
Copyright (c) 2007 Pete Mack Copyright (c) 2010 Andi Sidwell
This work is free software; you can redistribute it and/or modify it under the terms of either:
a) the GNU General Public License as published by the Free Software Foundation, version 2, or
b) the "Angband licence": This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.
References menu::selections.
References menu::active, menu::count, menu::cursor, ddx, ddy, EVENT_EMPTY, EVT_MOVE, menu::filter_count, menu::filter_list, region::page_rows, and ui_event::type.
References region::col, h, region::page_rows, region::row, Term_get_size(), and w.
Display an event, with possible preference overrides.
References menu_action::name, Term_erase(), and Term_putstr().
Referenced by menu_action_display().
|
static |
Forward declarations.
Modal display of menu.
References curs_attrs, menu_iter::display_row, menu::filter_list, menu::flags, flags, format(), menu_iter::get_tag, menu_skin::get_tag, menu_row_style_for_validity(), MN_NO_TAGS, MN_PVT_TAGS, MN_REL_TAGS, MN_ROW_HIDDEN, MN_ROW_VALID, menu::row_funcs, menu::selections, menu::skin, Term_putstr(), and menu_iter::valid_row.
Referenced by display_columns(), display_scrolling(), and object_skin_display().
Display current view of a skin.
References region::col, menu::count, menu::cursor, menu::cursor_x_offset, display_menu_row(), menu::filter_count, menu::filter_list, i, MAX, MIN, region::page_rows, region::row, row, Term_erase(), Term_gotoxy(), and region::width.
|
static |
References curs_attrs, CURS_KNOWN, items, menu_priv(), and Term_putstr().
References menu_priv(), menu_entry::next, and menu_entry::valid.
References keypress::code, menu::count, D2I, menu::filter_count, menu::filter_list, menu::flags, menu_iter::get_tag, menu_skin::get_tag, i, menu::inscriptions, MN_CASELESS_TAGS, MN_INSCRIP_TAGS, MN_NO_TAGS, MN_PVT_TAGS, MN_REL_TAGS, menu::row_funcs, menu::selections, menu::skin, and menu::top.
Referenced by menu_handle_keypress().
References menu::count, menu::filter_count, menu::filter_list, menu::row_funcs, and menu_iter::valid_row.
Referenced by menu_ensure_cursor_valid(), menu_handle_keypress(), menu_handle_mouse(), and no_valid_row().
|
static |
References curs_attrs, display_action_aux(), menu_action::flags, menu_priv(), and MN_ACT_GRAYED.
References menu_action::action, menu::cursor, EVT_SELECT, menu_action::flags, menu_priv(), MN_ACT_GRAYED, and ui_event::type.
References menu_priv(), and menu_action::tag.
References flags, menu_priv(), MN_ACT_HIDDEN, and menu_action::name.
|
static |
References menu::active, menu::boundary, region::col, menu::header, region::page_rows, menu::prompt, region_calculate(), region::row, menu::title, and region::width.
Referenced by menu_layout(), and menu_select().
References menu_dynamic_add_valid(), and MN_ROW_VALID.
Referenced by context_menu_command(), show_command_list(), and textui_cmd_ignore_menu().
void menu_dynamic_add_label | ( | struct menu * | m, |
const char * | text, | ||
const char | label, | ||
int | value, | ||
char * | label_list | ||
) |
References menu_dynamic_add_label_valid(), and MN_ROW_VALID.
Referenced by context_menu_cave(), context_menu_object(), context_menu_player(), context_menu_player_2(), context_menu_store(), and context_menu_store_item().
void menu_dynamic_add_label_valid | ( | struct menu * | m, |
const char * | text, | ||
const char | label, | ||
int | value, | ||
char * | label_list, | ||
menu_row_validity_t | valid | ||
) |
References menu::count, menu_dynamic_add_valid(), and menu::selections.
Referenced by menu_dynamic_add_label().
void menu_dynamic_add_valid | ( | struct menu * | m, |
const char * | text, | ||
int | value, | ||
menu_row_validity_t | valid | ||
) |
References menu::count, mem_zalloc(), menu_priv(), menu_setpriv(), menu_entry::next, menu::row_funcs, string_make(), menu_entry::valid, and menu_entry::value.
Referenced by menu_dynamic_add(), and menu_dynamic_add_label_valid().
References region::col, menu::count, term::hgt, menu_dynamic_longest_entry(), menu_layout(), region::page_rows, region::row, Term, term::wid, and region::width.
Referenced by context_menu_cave(), context_menu_command(), context_menu_player(), context_menu_player_2(), context_menu_store(), context_menu_store_item(), and show_command_list().
References mem_free(), menu_priv(), menu_entry::next, string_free(), and menu_entry::text.
Referenced by context_menu_cave(), context_menu_command(), context_menu_object(), context_menu_player(), context_menu_player_2(), context_menu_store(), context_menu_store_item(), show_command_list(), and textui_cmd_ignore_menu().
size_t menu_dynamic_longest_entry | ( | struct menu * | m | ) |
References menu_priv(), menu_entry::next, and menu_entry::text.
Referenced by context_menu_object(), menu_dynamic_calc_location(), and textui_cmd_ignore_menu().
References menu::cursor, EVT_ESCAPE, menu_priv(), menu_select(), menu_entry::next, ui_event::type, and menu_entry::value.
Referenced by context_menu_cave(), context_menu_command(), context_menu_object(), context_menu_player(), context_menu_player_2(), context_menu_store(), context_menu_store_item(), show_command_list(), and textui_cmd_ignore_menu().
Set the menu cursor to the next valid row.
References menu::count, menu::cursor, menu::filter_count, menu::filter_list, is_valid_row(), and row.
Referenced by menu_release_filter(), menu_set_filter(), and menu_setpriv().
const menu_iter* menu_find_iter | ( | menu_iter_id | id | ) |
Return the menu iter struct for a given iter ID.
Given a predefined menu kind, return its iter functions.
References menu_iter_actions, menu_iter_strings, MN_ITER_ACTIONS, and MN_ITER_STRINGS.
Referenced by display_knowledge(), menu_new_action(), and textui_knowledge_init().
References menu_skin_column, menu_skin_object, menu_skin_scroll, MN_SKIN_COLUMNS, MN_SKIN_OBJECT, and MN_SKIN_SCROLL.
Referenced by menu_init().
References mem_free().
Referenced by cleanup_options(), and death_screen().
Handle any menu command keys / SELECT events.
Returns true if the key was handled at all (including if it's not handled and just ignored).
References menu::cursor, menu::filter_list, menu::row_funcs, and menu_iter::row_handler.
Referenced by menu_select().
Handle navigation keypresses.
Returns true if they key was intelligible as navigation, regardless of whether any action was taken.
References menu::active, keypress::code, menu::count, menu::cursor, ddy, ESCAPE, EVT_ESCAPE, EVT_MOVE, EVT_SELECT, menu::filter_count, menu::filter_list, menu::flags, get_cursor_key(), is_valid_row(), KC_ENTER, ui_event::key, MN_DBL_TAP, no_valid_row(), region::page_rows, menu_skin::process_dir, menu::skin, target_dir(), menu::top, and ui_event::type.
Referenced by display_knowledge(), and menu_select().
Handle mouse input in a menu.
Mouse output is either moving, selecting, escaping, or nothing. Returns true if something changes as a result of the click.
References menu::active, mouseclick::button, region::col, menu::count, menu::cursor, EVT_ESCAPE, EVT_MOVE, EVT_NONE, EVT_SELECT, menu::filter_count, menu::filter_list, menu::flags, menu_skin::get_cursor, is_valid_row(), MN_DBL_TAP, ui_event::mouse, region_inside(), menu::skin, menu::top, ui_event::type, mouseclick::x, and mouseclick::y.
Referenced by display_knowledge(), and menu_select().
Initialise a menu, using the skin and iter functions specified.
References menu::cursor, menu::cursor_x_offset, menu_find_skin(), menu::row_funcs, and menu::skin.
Referenced by cmd_menu(), display_knowledge(), do_cmd_options_item(), ego_menu(), init_birth_menu(), menu_new(), quality_action(), quality_menu(), store_menu_init(), and textui_knowledge_init().
Ready a menu for display in the region specified.
XXX not ready for dynamic resizing just yet
References menu::boundary, loc(), and menu_calc_size().
Referenced by cmd_menu(), context_menu_object(), curse_menu(), death_screen(), display_knowledge(), do_cmd_colors(), do_cmd_keymaps(), do_cmd_options(), do_cmd_options_item(), do_cmd_spoilers(), do_cmd_visuals(), ego_menu(), init_birth_menu(), item_menu(), menu_dynamic_calc_location(), option_toggle_menu(), quality_action(), quality_menu(), spell_menu_new(), store_display_recalc(), store_menu_init(), sval_menu(), textui_action_menu_choose(), textui_browse_knowledge(), textui_cmd_ignore_menu(), wiz_create_item(), wiz_create_item_action(), and wiz_proj_demo().
Allocate and return a new, initialised, menu.
References mem_alloc(), and menu_init().
Referenced by curse_menu(), item_menu(), menu_dynamic_new(), menu_new_action(), option_toggle_menu(), spell_menu_new(), sval_menu(), textui_action_menu_choose(), wiz_create_item(), wiz_create_item_action(), and wiz_proj_demo().
struct menu* menu_new_action | ( | menu_action * | acts, |
size_t | n | ||
) |
References menu_find_iter(), menu_new(), menu_setpriv(), MN_ITER_ACTIONS, and MN_SKIN_SCROLL.
Referenced by death_screen(), do_cmd_colors(), do_cmd_keymaps(), do_cmd_options(), do_cmd_spoilers(), and do_cmd_visuals().
Return menu private data, set with menu_setpriv().
References menu::menu_data.
Referenced by cmd_list_action(), cmd_sub_entry(), display_string(), dynamic_display(), dynamic_valid(), get_curse_action(), get_curse_display(), get_item_action(), get_item_tag(), get_item_validity(), ignore_sval_menu_action(), ignore_sval_menu_display(), menu_action_display(), menu_action_handle(), menu_action_tag(), menu_action_valid(), menu_dynamic_add_valid(), menu_dynamic_free(), menu_dynamic_longest_entry(), menu_dynamic_select(), menu_question(), option_toggle_display(), spell_menu_browse(), spell_menu_destroy(), spell_menu_display(), spell_menu_handler(), spell_menu_select(), spell_menu_valid(), store_display_entry(), store_menu_handle(), store_menu_recalc(), wiz_create_item_subaction(), and wiz_create_item_subdisplay().
Display a menu.
If reset_screen is true, it will reset the screen to the previously saved state before displaying.
References menu::active, menu::boundary, menu::browse_hook, region::col, COLOUR_WHITE, menu::cursor, menu_skin::display_list, menu::filter_list, menu::header, menu::menu_data, region::page_rows, menu::prompt, region::row, screen_load(), screen_save(), menu::skin, Term_putstr(), menu::title, menu::top, and region::width.
Referenced by display_knowledge(), menu_question(), menu_select(), and textui_do_birth().
Remove any filters set on a menu by menu_set_filer().
References menu::filter_count, menu::filter_list, and menu_ensure_cursor_valid().
|
static |
References MN_ROW_HIDDEN, MN_ROW_INVALID, MN_ROW_STYLE_DISABLED, MN_ROW_STYLE_ENABLED, and MN_ROW_VALID.
Referenced by display_menu_row(), and dynamic_display().
Run a menu.
If popup is true, the screen is saved before the menu is drawn, and restored afterwards. Each time a popup menu is redrawn, it resets the screen before redrawing.
References menu::active, menu::cmd_keys, keypress::code, menu::cursor, EVENT_EMPTY, EVT_ESCAPE, EVT_KBRD, EVT_MOUSE, EVT_RESIZE, EVT_SELECT, EVT_SWITCH, menu::flags, inkey_ex(), ui_event::key, menu_calc_size(), menu_handle_action(), menu_handle_keypress(), menu_handle_mouse(), menu_refresh(), MN_NO_ACTION, region::page_rows, menu_iter::resize, menu::row_funcs, screen_load(), screen_save(), menu::switch_keys, ui_event::type, and region::width.
Referenced by cmd_menu(), curse_menu(), death_screen(), do_cmd_colors(), do_cmd_keymaps(), do_cmd_options(), do_cmd_options_item(), do_cmd_spoilers(), do_cmd_visuals(), ego_menu(), item_menu(), menu_dynamic_select(), menu_question(), option_toggle_menu(), quality_action(), quality_menu(), spell_menu_browse(), spell_menu_select(), store_get_stock(), sval_menu(), textui_action_menu_choose(), textui_browse_knowledge(), textui_store_knowledge(), use_store(), wiz_create_item(), wiz_create_item_action(), and wiz_proj_demo().
Allow adjustment of the cursor's default x offset.
References menu::cursor_x_offset.
Referenced by sval_menu().
References menu::filter_count, menu::filter_list, and menu_ensure_cursor_valid().
Referenced by display_knowledge(), option_toggle_menu(), and wiz_create_item().
Set menu private data and the number of menu items.
Menu private data is then available from inside menu callbacks using menu_priv().
References menu::count, data, menu::menu_data, and menu_ensure_cursor_valid().
Referenced by cmd_menu(), curse_menu(), display_knowledge(), do_cmd_options_item(), ego_menu(), init_birth_menu(), item_menu(), menu_dynamic_add_valid(), menu_dynamic_new(), menu_new_action(), option_toggle_menu(), quality_action(), quality_menu(), spell_menu_new(), store_menu_init(), store_menu_recalc(), sval_menu(), textui_action_menu_choose(), textui_knowledge_init(), wiz_create_item(), wiz_create_item_action(), and wiz_proj_demo().
References i, and is_valid_row().
Referenced by menu_handle_keypress().
Display current view of a skin.
References region::col, menu::count, menu::cursor, menu::cursor_x_offset, display_menu_row(), menu::filter_count, menu::filter_list, i, MAX, MIN, region::page_rows, region::row, row, Term_erase(), Term_gotoxy(), and region::width.
Find the position of a cursor given a screen address.
References region::row.
References menu::selections, and menu::top.
References ARROW_LEFT, ARROW_RIGHT, keypress::code, menu::cursor, ddx, ddy, EVENT_EMPTY, EVT_MOVE, EVT_SWITCH, ui_event::key, and ui_event::type.
References menu::selections, and menu::top.
References menu::cursor, ddx, ddy, EVENT_EMPTY, EVT_ESCAPE, EVT_MOVE, EVT_SELECT, and ui_event::type.
Find the position of a cursor given a screen address.
References region::row.
const char all_letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" |
Referenced by wiz_create_item(), and wiz_create_item_action().
Cursor colours.
Referenced by birthmenu_display(), display_artifact(), display_ego_item(), display_feature(), display_group_member(), display_menu_row(), display_monster(), display_object(), display_options_item(), display_rune(), display_string(), display_trap(), dynamic_display(), ignore_sval_menu_display(), menu_action_display(), option_toggle_display(), proj_display(), store_display_entry(), wiz_create_item_display(), and wiz_create_item_subdisplay().
const char lower_case[] = "abcdefghijklmnopqrstuvwxyz" |
Some useful constants.
Referenced by context_menu_cave(), context_menu_command(), context_menu_object(), context_menu_player(), context_menu_player_2(), context_menu_store(), context_menu_store_item(), curse_menu(), do_cmd_colors(), do_cmd_keymaps(), do_cmd_spoilers(), do_cmd_visuals(), init_birth_menu(), item_menu(), show_command_list(), spell_menu_new(), textui_cmd_ignore_menu(), and textui_knowledge_init().
Virtual function table for action_events.
Referenced by menu_find_iter().
Referenced by menu_find_iter().
Referenced by menu_find_skin().
Virtual function table for object menu skin.
Referenced by menu_find_skin().
Virtual function table for scrollable menu skin.
Referenced by menu_find_skin().
const char upper_case[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |