Angband
Data Structures | Macros | Enumerations | Functions | Variables
ui-object.c File Reference

Object lists and selection, and other object-related UI functions. More...

#include "angband.h"
#include "cave.h"
#include "cmd-core.h"
#include "cmds.h"
#include "effects.h"
#include "game-input.h"
#include "init.h"
#include "obj-desc.h"
#include "obj-gear.h"
#include "obj-ignore.h"
#include "obj-info.h"
#include "obj-knowledge.h"
#include "obj-make.h"
#include "obj-pile.h"
#include "obj-tval.h"
#include "obj-util.h"
#include "player-attack.h"
#include "player-calcs.h"
#include "player-spell.h"
#include "player-timed.h"
#include "player-util.h"
#include "store.h"
#include "ui-command.h"
#include "ui-display.h"
#include "ui-game.h"
#include "ui-input.h"
#include "ui-keymap.h"
#include "ui-menu.h"
#include "ui-object.h"
#include "ui-options.h"
#include "ui-output.h"
#include "ui-prefs.h"

Data Structures

struct  object_menu_data
 Info about a particular object. More...
 

Macros

#define MAX_ITEMS   50
 

Variables for object display and selection

More...
 

Enumerations

enum  {
  IGNORE_THIS_ITEM, UNIGNORE_THIS_ITEM, IGNORE_THIS_FLAVOR, UNIGNORE_THIS_FLAVOR,
  IGNORE_THIS_EGO, UNIGNORE_THIS_EGO, IGNORE_THIS_QUALITY
}
 

Object ignore interface

More...
 

Functions

static bool use_flavor_glyph (const struct object_kind *kind)
 

Display of individual objects in lists or for selection

More...
 
byte object_kind_attr (const struct object_kind *kind)
 Return the "attr" for a given item kind. More...
 
wchar_t object_kind_char (const struct object_kind *kind)
 Return the "char" for a given item kind. More...
 
byte object_attr (const struct object *obj)
 Return the "attr" for a given item. More...
 
wchar_t object_char (const struct object *obj)
 Return the "char" for a given item. More...
 
static void show_obj (int obj_num, int row, int col, bool cursor, olist_detail_t mode)
 Display an object. More...
 
static void wipe_obj_list (void)
 

Display of lists of objects

More...
 
static void build_obj_list (int last, struct object **list, item_tester tester, olist_detail_t mode)
 Build the object list. More...
 
static void set_obj_names (bool terse)
 Set object names and get their maximum length. More...
 
static void show_obj_list (olist_detail_t mode)
 Display a list of objects. More...
 
void show_inven (int mode, item_tester tester)
 Display the inventory. More...
 
void show_quiver (int mode, item_tester tester)
 Display the quiver. More...
 
void show_equip (int mode, item_tester tester)
 Display the equipment. More...
 
void show_floor (struct object **floor_list, int floor_num, int mode, item_tester tester)
 Display the floor. More...
 
bool get_item_allow (const struct object *obj, unsigned char ch, cmd_code cmd, bool is_harmless)
 

Object selection utilities

More...
 
static bool get_tag (struct object **tagged_obj, char tag, cmd_code cmd, bool quiver_tags)
 Find the first object in the object list with the given "tag". More...
 
static void menu_header (void)
 

Object selection menu

More...
 
char get_item_tag (struct menu *menu, int oid)
 Get an item tag. More...
 
int get_item_validity (struct menu *menu, int oid)
 Determine if an item is a valid choice. More...
 
void get_item_display (struct menu *menu, int oid, bool cursor, int row, int col, int width)
 Display an entry on the item menu. More...
 
bool get_item_action (struct menu *menu, const ui_event *event, int oid)
 Deal with events on the get_item menu. More...
 
static void item_menu_browser (int oid, void *data, const region *local_area)
 Show quiver missiles in full inventory. More...
 
struct objectitem_menu (cmd_code cmd, int prompt_size, int mode)
 Display list items to choose from. More...
 
bool textui_get_item (struct object **choice, const char *pmt, const char *str, cmd_code cmd, item_tester tester, int mode)
 Let the user select an object, save its address. More...
 
void display_object_recall (struct object *obj)
 

Object recall

More...
 
void display_object_kind_recall (struct object_kind *kind)
 This draws the Object Recall subwindow when displaying a recalled item kind (e.g. More...
 
void display_object_recall_interactive (struct object *obj)
 Display object recall modally and wait for a keypress. More...
 
void textui_obj_examine (void)
 Examine an object. More...
 
void textui_cmd_ignore_menu (struct object *obj)
 
void textui_cmd_ignore (void)
 
void textui_cmd_toggle_ignore (void)
 

Variables

static struct object_menu_data items [MAX_ITEMS]
 
static int num_obj
 
static int num_head
 
static size_t max_len
 
static int ex_width
 
static int ex_offset
 
static item_tester tester_m
 

Variables for object selection

More...
 
static region area = { 20, 1, -1, -2 }
 
static struct objectselection
 
static const char * prompt
 
static char header [80]
 
static int i1
 
static int i2
 
static int e1
 
static int e2
 
static int q1
 
static int q2
 
static int f1
 
static int f2
 
static struct object ** floor_list
 
static olist_detail_t olist_mode = 0
 
static int item_mode
 
static cmd_code item_cmd
 
static bool newmenu = false
 
static bool allow_all = false
 

Detailed Description

Object lists and selection, and other object-related UI functions.

Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke Copyright (c) 2007-9 Andi Sidwell, Chris Carr, Ed Graham, Erik Osheim Copyright (c) 2015 Nick McConnell

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.

Macro Definition Documentation

#define MAX_ITEMS   50


Variables for object display and selection

Referenced by wipe_obj_list().

Enumeration Type Documentation

anonymous enum


Object ignore interface

Enumerator
IGNORE_THIS_ITEM 
UNIGNORE_THIS_ITEM 
IGNORE_THIS_FLAVOR 
UNIGNORE_THIS_FLAVOR 
IGNORE_THIS_EGO 
UNIGNORE_THIS_EGO 
IGNORE_THIS_QUALITY 

Function Documentation

static void build_obj_list ( int  last,
struct object **  list,
item_tester  tester,
olist_detail_t  mode 
)
static
void display_object_kind_recall ( struct object_kind kind)

This draws the Object Recall subwindow when displaying a recalled item kind (e.g.

a generic ring of acid or a generic blade of chaos)

References display_object_recall(), EXTREMIFY, OBJECT_NULL, and object_prep().

Referenced by update_object_subwindow().

void display_object_recall ( struct object obj)


Object recall

This draws the Object Recall subwindow when displaying a particular object (e.g. a helmet in the backpack, or a scroll on the ground)

References clear_from(), object_desc(), object_info(), ODESC_FULL, ODESC_PREFIX, OINFO_NONE, SCREEN_REGION, textblock_free(), and textui_textblock_place().

Referenced by display_object_kind_recall(), and update_object_subwindow().

void display_object_recall_interactive ( struct object obj)

Display object recall modally and wait for a keypress.

This is set up for use in look mode (see target_set_interactive_aux()).

Parameters
objis the object to be described.

References EVENT_MESSAGE_FLUSH, event_signal(), object_desc(), object_info(), ODESC_FULL, ODESC_PREFIX, OINFO_NONE, SCREEN_REGION, textblock_free(), and textui_textblock_show().

Referenced by target_recall_loop_object().

bool get_item_action ( struct menu menu,
const ui_event event,
int  oid 
)
bool get_item_allow ( const struct object obj,
unsigned char  ch,
cmd_code  cmd,
bool  is_harmless 
)


Object selection utilities

Prevent certain choices depending on the inscriptions on the item.

The item can be negative to mean "item on floor".

References check_for_inscrip(), cmd_verb(), strnfmt(), UN_KTRL, and verify_object().

Referenced by context_menu_object(), and get_item_action().

void get_item_display ( struct menu menu,
int  oid,
bool  cursor,
int  row,
int  col,
int  width 
)

Display an entry on the item menu.

References olist_mode, and show_obj().

Referenced by item_menu().

char get_item_tag ( struct menu menu,
int  oid 
)

Get an item tag.

References object_menu_data::key, and menu_priv().

Referenced by item_menu().

int get_item_validity ( struct menu menu,
int  oid 
)

Determine if an item is a valid choice.

References menu_priv(), and NULL.

Referenced by item_menu().

static bool get_tag ( struct object **  tagged_obj,
char  tag,
cmd_code  cmd,
bool  quiver_tags 
)
static

Find the first object in the object list with the given "tag".

The object list needs to be built before this function is called.

A "tag" is a char "n" appearing as "@n" anywhere in the inscription of an object.

Also, the tag "@xn" will work as well, where "n" is a tag-char, and "x" is the action that tag will work for.

References cmd_lookup_key(), i, items, KEYMAP_MODE_ORIG, KEYMAP_MODE_ROGUE, object::note, num_obj, object_menu_data::object, OPT, quark_str(), player_upkeep::quiver, UN_KTRL, and player::upkeep.

Referenced by item_menu().

struct object* item_menu ( cmd_code  cmd,
int  prompt_size,
int  mode 
)
static void item_menu_browser ( int  oid,
void data,
const region local_area 
)
static
static void menu_header ( void  )
static


Object selection menu

Make the correct header for the selection menu

References allow_all, player_upkeep::command_wrk, e1, e2, f1, f2, header, i1, i2, I2A, item_mode, my_strcat(), q1, q2, strnfmt(), player::upkeep, USE_EQUIP, USE_INVEN, and USE_QUIVER.

Referenced by textui_get_item().

byte object_attr ( const struct object obj)

Return the "attr" for a given item.

Use "flavor" if available. Default to user definitions.

References object::kind, and object_kind_attr().

Referenced by display_missile(), display_player_equippy(), and prt_equippy().

wchar_t object_char ( const struct object obj)

Return the "char" for a given item.

Use "flavor" if available. Default to user definitions.

References object::kind, and object_kind_char().

Referenced by display_missile(), display_player_equippy(), and prt_equippy().

byte object_kind_attr ( const struct object_kind kind)

Return the "attr" for a given item kind.

Use "flavor" if available. Default to user definitions.

References flavor::fidx, object_kind::flavor, flavor_x_attr, object_kind::kidx, kind_x_attr, and use_flavor_glyph().

Referenced by display_object(), grid_data_as_text(), object_attr(), and object_list_format_section().

wchar_t object_kind_char ( const struct object_kind kind)

Return the "char" for a given item kind.

Use "flavor" if available. Default to user definitions.

References flavor::fidx, object_kind::flavor, flavor_x_char, object_kind::kidx, kind_x_char, and use_flavor_glyph().

Referenced by display_object(), grid_data_as_text(), object_char(), and object_list_format_section().

static void set_obj_names ( bool  terse)
static

Set object names and get their maximum length.

Only makes sense after building the object list.

References i, items, MAX, max_len, num_head, num_obj, object_menu_data::object, object_desc(), ODESC_FULL, ODESC_PREFIX, ODESC_TERSE, and strnfmt().

Referenced by item_menu(), and show_obj_list().

void show_equip ( int  mode,
item_tester  tester 
)
void show_floor ( struct object **  floor_list,
int  floor_num,
int  mode,
item_tester  tester 
)

Display the floor.

Builds a list of objects and passes them off to show_obj_list() for display. Mode flags documented in object.h

References build_obj_list(), angband_constants::floor_size, num_head, show_obj_list(), wipe_obj_list(), and z_info.

Referenced by see_floor_items(), and target_set_interactive_aux().

void show_inven ( int  mode,
item_tester  tester 
)
static void show_obj ( int  obj_num,
int  row,
int  col,
bool  cursor,
olist_detail_t  mode 
)
static
static void show_obj_list ( olist_detail_t  mode)
static
void show_quiver ( int  mode,
item_tester  tester 
)

Display the quiver.

Builds a list of objects and passes them off to show_obj_list() for display. Mode flags documented in object.h

References build_obj_list(), i, NULL, num_head, player_upkeep::quiver, angband_constants::quiver_size, show_obj_list(), player::upkeep, wipe_obj_list(), and z_info.

Referenced by death_info().

void textui_cmd_ignore ( void  )
void textui_cmd_ignore_menu ( struct object obj)
void textui_cmd_toggle_ignore ( void  )
bool textui_get_item ( struct object **  choice,
const char *  pmt,
const char *  str,
cmd_code  cmd,
item_tester  tester,
int  mode 
)

Let the user select an object, save its address.

Return true only if an acceptable item was chosen by the user.

The user is allowed to choose acceptable items from the equipment, inventory, quiver, or floor, respectively, if the proper flag was given, and there are any acceptable items in that location.

The equipment, inventory or quiver are displayed (even if no acceptable items are in that location) if the proper flag was given.

If there are no acceptable items available anywhere, and "str" is not NULL, then it will be used as the text of a warning message before the function returns.

If a legal item is selected , we save it in "choice" and return true.

If no item is available, we do nothing to "choice", and we display a warning message, using "str" if available, and return false.

If no item is selected, we do nothing to "choice", and return false.

Global "player->upkeep->command_wrk" is used to choose between equip/inven/quiver/floor listings. It is equal to USE_INVEN or USE_EQUIP or USE_QUIVER or USE_FLOOR, except when this function is first called, when it is equal to zero, which will cause it to be set to USE_INVEN.

We always erase the prompt when we are done, leaving a blank line, or a warning message, if appropriate, if no items are available.

Note that only "acceptable" floor objects get indexes, so between two commands, the indexes of floor objects may change. XXX XXX XXX

References allow_all, angband_term, ANGBAND_TERM_MAX, player::body, build_obj_list(), CMD_NULL, player_upkeep::command_wrk, player_body::count, e1, e2, EVENT_MESSAGE_FLUSH, event_signal(), f1, f2, angband_constants::floor_size, header, i1, i2, player_upkeep::inven, item_cmd, item_menu(), item_mode, MAX, mem_free(), mem_zalloc(), menu_header(), msg, newmenu, NULL, object_test(), OFLOOR_SENSE, OFLOOR_TEST, OFLOOR_VISIBLE, OLIST_FAIL, olist_mode, OLIST_PRICE, OLIST_QUIVER, OLIST_SEMPTY, OLIST_WEIGHT, angband_constants::pack_size, PR_EQUIP, PR_INVEN, prompt, prt(), PW_EQUIP, PW_INVEN, q1, q2, player_upkeep::quiver, angband_constants::quiver_size, QUIVER_TAGS, player_upkeep::redraw, redraw_stuff(), scan_floor(), screen_load(), screen_save(), SHOW_EMPTY, SHOW_FAIL, SHOW_PRICES, SHOW_QUIVER, slot_object(), tester_m, toggle_inven_equip(), player::upkeep, USE_EQUIP, USE_FLOOR, USE_INVEN, USE_QUIVER, window_flag, wipe_obj_list(), and z_info.

Referenced by textui_input_init().

void textui_obj_examine ( void  )
static bool use_flavor_glyph ( const struct object_kind kind)
static


Display of individual objects in lists or for selection

Determine if the attr and char should consider the item's flavor

Identified scrolls should use their own tile.

References object_kind::aware, object_kind::flavor, and object_kind::tval.

Referenced by object_kind_attr(), and object_kind_char().

static void wipe_obj_list ( void  )
static

Variable Documentation

bool allow_all = false
static
region area = { 20, 1, -1, -2 }
static
int e1
static
int e2
static
int ex_offset
static
int ex_width
static
int f1
static
int f2
static
struct object** floor_list
static
char header[80]
static
int i1
static
int i2
static
cmd_code item_cmd
static
int item_mode
static
struct object_menu_data items[MAX_ITEMS]
static
size_t max_len
static
bool newmenu = false
static
int num_head
static
int num_obj
static
olist_detail_t olist_mode = 0
static
const char* prompt
static
int q1
static
int q2
static
struct object* selection
static

Referenced by item_menu().

item_tester tester_m
static


Variables for object selection

Referenced by textui_get_item().