Angband
Functions
ui-obj.c File Reference

lists of objects and object pictures More...

#include "angband.h"
#include "cmd-core.h"
#include "cmds.h"
#include "game-input.h"
#include "init.h"
#include "obj-desc.h"
#include "obj-gear.h"
#include "obj-identify.h"
#include "obj-info.h"
#include "obj-make.h"
#include "obj-pile.h"
#include "obj-tval.h"
#include "obj-util.h"
#include "store.h"
#include "ui-display.h"
#include "ui-game.h"
#include "ui-input.h"
#include "ui-keymap.h"
#include "ui-obj.h"
#include "ui-output.h"
#include "ui-prefs.h"

Functions

static bool use_flavor_glyph (const struct object_kind *kind)
 Determine if the attr and char should consider the item's flavor.
byte object_kind_attr (const struct object_kind *kind)
 Return the "attr" for a given item kind.
wchar_t object_kind_char (const struct object_kind *kind)
 Return the "char" for a given item kind.
byte object_attr (const struct object *o_ptr)
 Return the "attr" for a given item.
wchar_t object_char (const struct object *o_ptr)
 Return the "char" for a given item.
struct objectlabel_to_inven (int c)
 Convert a label into an item in the inventory.
struct objectlabel_to_equip (int c)
 Convert a label into an item in the equipment.
struct objectlabel_to_quiver (int c)
 Convert a label into an item in the equipment or quiver.
static void show_obj_list (int num_obj, int num_head, char labels[50][80], struct object *objects[50], olist_detail_t mode)
 Display a list of objects.
void show_inven (int mode, item_tester tester)
 Display the inventory.
void show_quiver (int mode, item_tester tester)
 Display the quiver.
void show_equip (int mode, item_tester tester)
 Display the equipment.
void show_floor (struct object **floor_list, int floor_num, int mode, item_tester tester)
 Display the floor.
bool get_item_allow (const struct object *obj, unsigned char ch, cmd_code cmd, bool is_harmless)
 Prevent certain choices depending on the inscriptions on the item.
static int get_tag (struct object **tagged_obj, char tag, cmd_code cmd, bool quiver_tags)
 Find the "first" inventory object with the given "tag" - now first in the gear array, which is really arbitrary - NRM.
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.
void display_object_recall (struct object *o_ptr)
 This draws the Object Recall subwindow when displaying a particular object (e.g.
void display_object_kind_recall (struct object_kind *kind)
 This draws the Object Recall subwindow when displaying a recalled item kind (e.g.
void display_object_recall_interactive (struct object *o_ptr)
 Display object recall modally and wait for a keypress.

Detailed Description

lists of objects and object pictures

Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke

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.

Function Documentation

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 object_kind::aware, display_object_recall(), EXTREMIFY, object_notice_everything(), and object_prep().

Referenced by update_object_subwindow().

void display_object_recall ( struct object o_ptr)

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 o_ptr)

Display object recall modally and wait for a keypress.

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

Parameters
o_ptris 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_allow ( const struct object obj,
unsigned char  ch,
cmd_code  cmd,
bool  is_harmless 
)

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(), FALSE, strnfmt(), TRUE, UN_KTRL, and verify_object().

Referenced by context_menu_object(), and textui_get_item().

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

Find the "first" inventory object with the given "tag" - now first in the gear array, which is really arbitrary - NRM.

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(), FALSE, player::gear, i, KEYMAP_MODE_ORIG, KEYMAP_MODE_ROGUE, object::kind, object::next, object::note, OPT, quark_str(), player_upkeep::quiver, TRUE, UN_KTRL, and player::upkeep.

Referenced by textui_get_item().

struct object* label_to_equip ( int  c)
read

Convert a label into an item in the equipment.

Return NULL if the label does not indicate a real item.

References A2I, player::body, player_body::count, i, and slot_object().

Referenced by textui_get_item().

struct object* label_to_inven ( int  c)
read

Convert a label into an item in the inventory.

Return NULL if the label does not indicate a real item.

References A2I, i, player_upkeep::inven, angband_constants::pack_size, player::upkeep, and z_info.

Referenced by textui_get_item().

struct object* label_to_quiver ( int  c)
read

Convert a label into an item in the equipment or quiver.

Return NULL if the label does not indicate a real item.

References A2I, i, player_upkeep::quiver, angband_constants::quiver_size, player::upkeep, and z_info.

Referenced by textui_get_item().

byte object_attr ( const struct object o_ptr)

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 o_ptr)

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().

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 angband_constants::floor_size, i, I2A, object_test(), OLIST_GOLD, show_obj_list(), strnfmt(), tval_is_money(), and z_info.

Referenced by see_floor_items(), target_set_interactive_aux(), and textui_get_item().

void show_inven ( int  mode,
item_tester  tester 
)
static void show_obj_list ( int  num_obj,
int  num_head,
char  labels[50][80],
struct object objects[50],
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 FALSE, i, I2A, my_strcpy(), object_test(), OLIST_WINDOW, player_upkeep::quiver, angband_constants::quiver_size, show_obj_list(), strnfmt(), TRUE, player::upkeep, and z_info.

Referenced by textui_get_item().

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.

Note that the user must press "-" to specify the item on the floor, and there is no way to "examine" the item on the floor, while the use of "capital" letters will "examine" an inventory/equipment item, and prompt for its use.

If a legal item is selected , we save it in "obj" and return TRUE.

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

If no item is selected, we do nothing to "obj", 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 A2I, angband_term, ANGBAND_TERM_MAX, bell(), player::body, mouseclick::button, cmd_lookup_key(), keypress::code, player_upkeep::command_wrk, player_body::count, ESCAPE, EVENT_MESSAGE_FLUSH, event_signal(), EVT_MOUSE, FALSE, angband_constants::floor_size, get_item_allow(), get_tag(), I2A, inkey_m(), player_upkeep::inven, IS_HARMLESS, KC_ENTER, ui_event::key, KEYMAP_MODE_ORIG, KEYMAP_MODE_ROGUE, label_to_equip(), label_to_inven(), label_to_quiver(), mem_free(), mem_zalloc(), ui_event::mouse, msg, my_strcat(), object_test(), OLIST_FAIL, OLIST_PRICE, OLIST_QUIVER, OLIST_SEMPTY, OLIST_WEIGHT, OPT, angband_constants::pack_size, PR_EQUIP, PR_INVEN, prt(), PW_EQUIP, PW_INVEN, player::px, player::py, player_upkeep::quiver, angband_constants::quiver_size, QUIVER_TAGS, player_upkeep::redraw, redraw_stuff(), scan_floor(), screen_load(), screen_save(), SHOW_EMPTY, show_equip(), SHOW_FAIL, show_floor(), show_inven(), SHOW_PRICES, SHOW_QUIVER, show_quiver(), slot_object(), strnfmt(), toggle_inven_equip(), TRUE, ui_event::type, UN_KTRL, player::upkeep, USE_EQUIP, USE_FLOOR, USE_INVEN, USE_QUIVER, verify_object(), window_flag, mouseclick::y, and z_info.

Referenced by textui_input_init().

static bool use_flavor_glyph ( const struct object_kind kind)
static

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().