Angband
Data Structures | Typedefs | Enumerations | Functions | Variables
ui-equip-cmp.c File Reference

Supply a "resistance grid for home" in the knowledge menu. More...

#include "cave.h"
#include "game-input.h"
#include "init.h"
#include "object.h"
#include "obj-desc.h"
#include "obj-gear.h"
#include "obj-ignore.h"
#include "obj-info.h"
#include "obj-tval.h"
#include "player.h"
#include "store.h"
#include "ui-entry.h"
#include "ui-entry-renderers.h"
#include "ui-equip-cmp.h"
#include "ui-event.h"
#include "ui-input.h"
#include "ui-object.h"
#include "ui-output.h"
#include "ui-term.h"
#include "z-color.h"
#include "z-file.h"
#include "z-textblock.h"
#include "z-util.h"
#include "z-virt.h"

Data Structures

struct  equipable
 
union  equipable_selfunc_extra
 
struct  equipable_selector
 
struct  equipable_expr
 
struct  equipable_filter
 
struct  equipable_arranger
 
struct  equipable_sorter
 
struct  prop_category
 
struct  equipable_summary
 
struct  indirect_sort_data
 
struct  menu_display_state
 
struct  obj_visitor_data
 
struct  add_obj_to_summary_closure
 Add an object to the summary of equipable items; intended for use with apply_visitor_to_pile() or apply_visitor_to_equipped(). More...
 

Typedefs

typedef bool(* equipable_selfunc) (const struct equipable *eq, const union equipable_selfunc_extra *ex)
 
typedef int(* equipable_cmpfunc) (const struct equipable *left, const struct equipable *right, int propind)
 
typedef bool(* objselfunc) (const struct object *obj, const void *closure)
 
typedef void(* objusefunc) (const struct object *obj, void *closure)
 

Enumerations

enum  equipable_source {
  EQUIP_SOURCE_WORN, EQUIP_SOURCE_PACK, EQUIP_SOURCE_FLOOR, EQUIP_SOURCE_HOME,
  EQUIP_SOURCE_STORE
}
 
enum  equipable_quality {
  EQUIP_QUAL_ARTIFACT, EQUIP_QUAL_EGO, EQUIP_QUAL_GOOD, EQUIP_QUAL_AVERAGE,
  EQUIP_QUAL_BAD
}
 
enum  equipable_expr_class { EQUIP_EXPR_SELECTOR, EQUIP_EXPR_AND, EQUIP_EXPR_OR, EQUIP_EXPR_TERMINATOR }
 
enum  store_inclusion { EQUIPABLE_NO_STORE, EQUIPABLE_ONLY_STORE, EQUIPABLE_YES_STORE }
 
enum  {
  EQUIP_CMP_MENU_DONE, EQUIP_CMP_MENU_BAIL, EQUIP_CMP_MENU_NEW_PAGE, EQUIP_CMP_MENU_SAME_PAGE,
  EQUIP_CMP_MENU_SEL0, EQUIP_CMP_MENU_SEL1
}
 

Functions

static int initialize_summary (struct player *p, struct equipable_summary **s)
 
static void cleanup_summary (struct equipable_summary *s)
 
static void cleanup_summary_items (struct equipable_summary *s)
 
static int display_page (struct equipable_summary *s, const struct player *p, bool allow_reconfig)
 
static void display_equip_cmp_help (void)
 
static void display_equip_cmp_sel_help (void)
 
static int handle_key_bail (struct keypress ch, int istate, struct equipable_summary *s, struct player *p)
 
static int handle_key_equip_cmp_general (struct keypress ch, int istate, struct equipable_summary *s, struct player *p)
 
static int handle_key_equip_cmp_select (struct keypress ch, int istate, struct equipable_summary *s, struct player *p)
 
static int prompt_for_easy_filter (struct equipable_summary *s, bool apply_not)
 
static void display_object_comparison (const struct equipable_summary *s)
 
static bool dump_to_file (const char *path)
 
static void append_to_file (ang_file *fff)
 Write all the pages with the current selection of items and properties to display. More...
 
static void filter_items (struct equipable_summary *s)
 
static bool sel_at_least_resists (const struct equipable *eq, const union equipable_selfunc_extra *ex)
 
static bool sel_does_not_resist (const struct equipable *eq, const union equipable_selfunc_extra *ex)
 
static bool sel_has_flag (const struct equipable *eq, const union equipable_selfunc_extra *ex)
 
static bool sel_does_not_have_flag (const struct equipable *eq, const union equipable_selfunc_extra *ex)
 
static bool sel_has_pos_mod (const struct equipable *eq, const union equipable_selfunc_extra *ex)
 
static bool sel_has_nonpos_mod (const struct equipable *eq, const union equipable_selfunc_extra *ex)
 
static bool sel_exclude_src (const struct equipable *eq, const union equipable_selfunc_extra *ex)
 
static bool sel_only_src (const struct equipable *eq, const union equipable_selfunc_extra *ex)
 
static void sort_items (struct equipable_summary *s)
 
static wchar_t source_to_char (enum equipable_source src)
 
void equip_cmp_display (void)
 
static char * set_short_name (const struct object *obj, size_t length)
 
static void apply_simple_filter (const struct equipable_filter *f, struct equipable_summary *s)
 
static void apply_complex_filter (const struct equipable_filter *f, struct equipable_summary *s)
 
static int cmp_by_location (const struct equipable *left, const struct equipable *right, int propind)
 
static int cmp_by_quality (const struct equipable *left, const struct equipable *right, int propind)
 
static int cmp_by_short_name (const struct equipable *left, const struct equipable *right, int propind)
 
static int cmp_by_slot (const struct equipable *left, const struct equipable *right, int propind)
 
static int cmp_for_sort_items (const void *left, const void *right)
 
static bool select_any (const struct object *obj, const void *closure)
 Intended for use with apply_visitor_to_pile() or apply_visitor_to_equipped(). More...
 
static bool select_nonequipped_wearable (const struct object *obj, const void *closure)
 Test for wearable objects in the pack. More...
 
static bool select_wearable (const struct object *obj, const void *closure)
 Test for wearable objects. More...
 
static bool select_seen_wearable (const struct object *obj, const void *closure)
 Test for wearable objects that are not ignored and have been seen (have a known object). More...
 
static void count_objects (const struct object *obj, void *closure)
 Increment a counter; intended for use with apply_visitor_to_pile() or apply_visitor_to_equipped(). More...
 
static void add_obj_to_summary (const struct object *obj, void *closure)
 
static void apply_visitor_to_pile (const struct object *obj, struct obj_visitor_data *visitor)
 Given the function pointers in visitor, apply them to each object in the pile pointed to by obj. More...
 
static void apply_visitor_to_equipped (struct player *p, struct obj_visitor_data *visitor)
 Given the function pointers in visitor, apply them to each object in the given player's inventory. More...
 
static int reconfigure_for_term_if_necessary (bool update_names, struct equipable_summary *s)
 
static void compute_player_and_equipment_values (struct player *p, struct equipable_summary *s)
 
static bool check_for_two_categories (const struct ui_entry *entry, void *closure)
 
static void init_ui_equip_cmp (void)
 
static void cleanup_ui_equip_cmp (void)
 

Variables

static struct equipable_summarythe_summary = NULL
 
static struct equipable_summarys_for_file = NULL
 
static struct indirect_sort_data sort_dat
 
struct init_module ui_equip_cmp_module
 

Detailed Description

Supply a "resistance grid for home" in the knowledge menu.

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.

Typedef Documentation

◆ equipable_cmpfunc

typedef int(* equipable_cmpfunc) (const struct equipable *left, const struct equipable *right, int propind)

◆ equipable_selfunc

typedef bool(* equipable_selfunc) (const struct equipable *eq, const union equipable_selfunc_extra *ex)

◆ objselfunc

typedef bool(* objselfunc) (const struct object *obj, const void *closure)

◆ objusefunc

typedef void(* objusefunc) (const struct object *obj, void *closure)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
EQUIP_CMP_MENU_DONE 
EQUIP_CMP_MENU_BAIL 
EQUIP_CMP_MENU_NEW_PAGE 
EQUIP_CMP_MENU_SAME_PAGE 
EQUIP_CMP_MENU_SEL0 
EQUIP_CMP_MENU_SEL1 

◆ equipable_expr_class

Enumerator
EQUIP_EXPR_SELECTOR 
EQUIP_EXPR_AND 
EQUIP_EXPR_OR 
EQUIP_EXPR_TERMINATOR 

◆ equipable_quality

Enumerator
EQUIP_QUAL_ARTIFACT 
EQUIP_QUAL_EGO 
EQUIP_QUAL_GOOD 
EQUIP_QUAL_AVERAGE 
EQUIP_QUAL_BAD 

◆ equipable_source

Enumerator
EQUIP_SOURCE_WORN 
EQUIP_SOURCE_PACK 
EQUIP_SOURCE_FLOOR 
EQUIP_SOURCE_HOME 
EQUIP_SOURCE_STORE 

◆ store_inclusion

Enumerator
EQUIPABLE_NO_STORE 
EQUIPABLE_ONLY_STORE 
EQUIPABLE_YES_STORE 

Function Documentation

◆ add_obj_to_summary()

static void add_obj_to_summary ( const struct object obj,
void closure 
)
static

◆ append_to_file()

static void append_to_file ( ang_file fff)
static

◆ apply_complex_filter()

static void apply_complex_filter ( const struct equipable_filter f,
struct equipable_summary s 
)
static

◆ apply_simple_filter()

static void apply_simple_filter ( const struct equipable_filter f,
struct equipable_summary s 
)
static

◆ apply_visitor_to_equipped()

static void apply_visitor_to_equipped ( struct player p,
struct obj_visitor_data visitor 
)
static

Given the function pointers in visitor, apply them to each object in the given player's inventory.

References player::body, player_body::count, i, obj_visitor_data::selfunc, obj_visitor_data::selfunc_closure, slot_object(), obj_visitor_data::usefunc, and obj_visitor_data::usefunc_closure.

Referenced by initialize_summary().

◆ apply_visitor_to_pile()

static void apply_visitor_to_pile ( const struct object obj,
struct obj_visitor_data visitor 
)
static

Given the function pointers in visitor, apply them to each object in the pile pointed to by obj.

Assumes that the functions do not modify the structure of the pile.

References object::next, obj_visitor_data::selfunc, obj_visitor_data::selfunc_closure, obj_visitor_data::usefunc, and obj_visitor_data::usefunc_closure.

Referenced by initialize_summary().

◆ check_for_two_categories()

static bool check_for_two_categories ( const struct ui_entry entry,
void closure 
)
static

References categories, and ui_entry_has_category().

Referenced by initialize_summary().

◆ cleanup_summary()

static void cleanup_summary ( struct equipable_summary s)
static

◆ cleanup_summary_items()

static void cleanup_summary_items ( struct equipable_summary s)
static

◆ cleanup_ui_equip_cmp()

static void cleanup_ui_equip_cmp ( void  )
static

References cleanup_summary().

◆ cmp_by_location()

static int cmp_by_location ( const struct equipable left,
const struct equipable right,
int  propind 
)
static

References equipable::src.

Referenced by initialize_summary().

◆ cmp_by_quality()

static int cmp_by_quality ( const struct equipable left,
const struct equipable right,
int  propind 
)
static

References equipable::qual.

Referenced by initialize_summary().

◆ cmp_by_short_name()

static int cmp_by_short_name ( const struct equipable left,
const struct equipable right,
int  propind 
)
static

References equipable::short_name.

Referenced by initialize_summary().

◆ cmp_by_slot()

static int cmp_by_slot ( const struct equipable left,
const struct equipable right,
int  propind 
)
static

References equipable::slot.

Referenced by initialize_summary().

◆ cmp_for_sort_items()

static int cmp_for_sort_items ( const void left,
const void right 
)
static

◆ compute_player_and_equipment_values()

static void compute_player_and_equipment_values ( struct player p,
struct equipable_summary s 
)
static

◆ count_objects()

static void count_objects ( const struct object obj,
void closure 
)
static

Increment a counter; intended for use with apply_visitor_to_pile() or apply_visitor_to_equipped().

Referenced by initialize_summary().

◆ display_equip_cmp_help()

static void display_equip_cmp_help ( void  )
static

◆ display_equip_cmp_sel_help()

static void display_equip_cmp_sel_help ( void  )
static

◆ display_object_comparison()

static void display_object_comparison ( const struct equipable_summary s)
static

◆ display_page()

static int display_page ( struct equipable_summary s,
const struct player p,
bool  allow_reconfig 
)
static

◆ dump_to_file()

static bool dump_to_file ( const char *  path)
static

◆ equip_cmp_display()

void equip_cmp_display ( void  )

◆ filter_items()

static void filter_items ( struct equipable_summary s)
static

◆ handle_key_bail()

static int handle_key_bail ( struct keypress  ch,
int  istate,
struct equipable_summary s,
struct player p 
)
static

References EQUIP_CMP_MENU_DONE.

Referenced by equip_cmp_display().

◆ handle_key_equip_cmp_general()

static int handle_key_equip_cmp_general ( struct keypress  ch,
int  istate,
struct equipable_summary s,
struct player p 
)
static

◆ handle_key_equip_cmp_select()

static int handle_key_equip_cmp_select ( struct keypress  ch,
int  istate,
struct equipable_summary s,
struct player p 
)
static

◆ init_ui_equip_cmp()

static void init_ui_equip_cmp ( void  )
static

◆ initialize_summary()

static int initialize_summary ( struct player p,
struct equipable_summary **  s 
)
static

◆ prompt_for_easy_filter()

static int prompt_for_easy_filter ( struct equipable_summary s,
bool  apply_not 
)
static

◆ reconfigure_for_term_if_necessary()

static int reconfigure_for_term_if_necessary ( bool  update_names,
struct equipable_summary s 
)
static

◆ sel_at_least_resists()

static bool sel_at_least_resists ( const struct equipable eq,
const union equipable_selfunc_extra ex 
)
static

◆ sel_does_not_have_flag()

static bool sel_does_not_have_flag ( const struct equipable eq,
const union equipable_selfunc_extra ex 
)
static

◆ sel_does_not_resist()

static bool sel_does_not_resist ( const struct equipable eq,
const union equipable_selfunc_extra ex 
)
static

◆ sel_exclude_src()

static bool sel_exclude_src ( const struct equipable eq,
const union equipable_selfunc_extra ex 
)
static

◆ sel_has_flag()

static bool sel_has_flag ( const struct equipable eq,
const union equipable_selfunc_extra ex 
)
static

◆ sel_has_nonpos_mod()

static bool sel_has_nonpos_mod ( const struct equipable eq,
const union equipable_selfunc_extra ex 
)
static

◆ sel_has_pos_mod()

static bool sel_has_pos_mod ( const struct equipable eq,
const union equipable_selfunc_extra ex 
)
static

◆ sel_only_src()

static bool sel_only_src ( const struct equipable eq,
const union equipable_selfunc_extra ex 
)
static

◆ select_any()

static bool select_any ( const struct object obj,
const void closure 
)
static

◆ select_nonequipped_wearable()

static bool select_nonequipped_wearable ( const struct object obj,
const void closure 
)
static

Test for wearable objects in the pack.

Intended for use with apply_visitor_to_pile(). Assumes obj is in the player's gear.

References player::body, object_is_equipped(), p, and tval_is_wearable().

Referenced by initialize_summary().

◆ select_seen_wearable()

static bool select_seen_wearable ( const struct object obj,
const void closure 
)
static

Test for wearable objects that are not ignored and have been seen (have a known object).

Intended for use with apply_visitor_to_pile().

References ignore_item_ok(), object::known, and tval_is_wearable().

Referenced by initialize_summary().

◆ select_wearable()

static bool select_wearable ( const struct object obj,
const void closure 
)
static

Test for wearable objects.

Intended for use with apply_visitor_to_pile().

References tval_is_wearable().

Referenced by initialize_summary().

◆ set_short_name()

static char* set_short_name ( const struct object obj,
size_t  length 
)
static

◆ sort_items()

static void sort_items ( struct equipable_summary s)
static

◆ source_to_char()

static wchar_t source_to_char ( enum equipable_source  src)
static

Variable Documentation

◆ s_for_file

struct equipable_summary* s_for_file = NULL
static

◆ sort_dat

struct indirect_sort_data sort_dat
static

Referenced by cmp_for_sort_items(), and sort_items().

◆ the_summary

struct equipable_summary* the_summary = NULL
static

Referenced by append_to_file().

◆ ui_equip_cmp_module

struct init_module ui_equip_cmp_module
Initial value:
= {
.name = "ui-equip-cmp",
}
static void cleanup_ui_equip_cmp(void)
Definition: ui-equip-cmp.c:2468
static void init_ui_equip_cmp(void)
Definition: ui-equip-cmp.c:2462