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

Text UI options handling code (everything accessible from '=') More...

#include "angband.h"
#include "cmds.h"
#include "game-input.h"
#include "init.h"
#include "obj-desc.h"
#include "obj-ignore.h"
#include "obj-tval.h"
#include "obj-util.h"
#include "object.h"
#include "player-calcs.h"
#include "ui-display.h"
#include "ui-help.h"
#include "ui-input.h"
#include "ui-keymap.h"
#include "ui-knowledge.h"
#include "ui-menu.h"
#include "ui-options.h"
#include "ui-prefs.h"
#include "ui-target.h"

Data Structures

struct  ignore_choice
 

Quality ignore menu

More...
 
struct  tval_desc
 

Sval ignore menu

More...
 

Macros

#define EGO_MENU_HELPTEXT   "{light green}Movement keys{/} scroll the list\n{light red}ESC{/} returns to the previous menu\n{light blue}Enter{/} toggles the current setting."
 

Ego item ignore menu

More...
 

Functions

static bool get_pref_path (const char *what, int row, char *buf, size_t max)
 Prompt the user for a filename to save the pref file to. More...
 
static void dump_pref_file (void(*dump)(ang_file *), const char *title, int row)
 
static void do_cmd_pref_file_hack (long row)
 Ask for a "user pref file" and process it. More...
 
static void option_toggle_display (struct menu *m, int oid, bool cursor, int row, int col, int width)
 

Options display and setting

More...
 
static bool option_toggle_handle (struct menu *m, const ui_event *event, int oid)
 Handle keypresses for an option entry. More...
 
static void option_toggle_menu (const char *name, int page)
 Interact with some options. More...
 
void do_cmd_options_birth (void)
 Edit birth options. More...
 
static void do_cmd_options_win (const char *name, int row)
 Modify the "window" options. More...
 
static struct keypress keymap_get_trigger (void)
 Ask for, and display, a keymap trigger. More...
 
static void ui_keymap_pref_load (const char *title, int row)
 Keymap menu action functions. More...
 
static void ui_keymap_pref_append (const char *title, int row)
 
static void ui_keymap_query (const char *title, int row)
 
static void ui_keymap_create (const char *title, int row)
 
static void ui_keymap_remove (const char *title, int row)
 
static void keymap_browse_hook (int oid, void *db, const region *loc)
 
static void do_cmd_keymaps (const char *title, int row)
 
static void visuals_pref_load (const char *title, int row)
 

Interact with visuals

More...
 
static void visuals_dump_monsters (const char *title, int row)
 
static void visuals_dump_objects (const char *title, int row)
 
static void visuals_dump_features (const char *title, int row)
 
static void visuals_dump_flavors (const char *title, int row)
 
static void visuals_reset (const char *title, int row)
 
static void visuals_browse_hook (int oid, void *db, const region *loc)
 
static void do_cmd_visuals (const char *title, int row)
 Interact with "visuals". More...
 
static void colors_pref_load (const char *title, int row)
 

Interact with colours

More...
 
static void colors_pref_dump (const char *title, int row)
 
static void colors_modify (const char *title, int row)
 
static void colors_browse_hook (int oid, void *db, const region *loc)
 
static void do_cmd_colors (const char *title, int row)
 Interact with "colors". More...
 
static bool askfor_aux_numbers (char *buf, size_t buflen, size_t *curs, size_t *len, struct keypress keypress, bool firsttime)
 

Non-complex menu actions

More...
 
static void do_cmd_delay (const char *name, int row)
 Set base delay factor. More...
 
static void do_cmd_hp_warn (const char *name, int row)
 Set hitpoint warning level. More...
 
static void do_cmd_lazymove_delay (const char *name, int row)
 Set "lazy-movement" delay. More...
 
static void do_dump_options (const char *title, int row)
 Write options to a file. More...
 
static void do_dump_autoinsc (const char *title, int row)
 Write autoinscriptions to a file. More...
 
static void options_load_pref_file (const char *n, int row)
 Load a pref file. More...
 
static const char * strip_ego_name (const char *name)
 Skip common prefixes in ego-item names. More...
 
int ego_item_name (char *buf, size_t buf_size, struct ego_desc *desc)
 Display an ego-item type on the screen. More...
 
static int ego_comp_func (const void *a_ptr, const void *b_ptr)
 Utility function used for sorting an array of ego-item indices by ego-item name. More...
 
static void ego_display (struct menu *menu, int oid, bool cursor, int row, int col, int width)
 Display an entry on the sval menu. More...
 
static bool ego_action (struct menu *menu, const ui_event *event, int oid)
 Deal with events on the sval menu. More...
 
static void ego_menu (const char *unused, int also_unused)
 Display list of ego items to be ignored. More...
 
static int cmp_ignore (const void *a, const void *b)
 Ordering function for ignore choices. More...
 
int quality_validity (struct menu *menu, int oid)
 Determine if an item is a valid choice. More...
 
static void quality_display (struct menu *menu, int oid, bool cursor, int row, int col, int width)
 Display an entry in the menu. More...
 
static void quality_subdisplay (struct menu *menu, int oid, bool cursor, int row, int col, int width)
 Display the quality ignore subtypes. More...
 
static bool quality_action (struct menu *m, const ui_event *event, int oid)
 Handle keypresses. More...
 
static void quality_menu (void *unused, const char *also_unused)
 Display quality ignore menu. More...
 
bool ignore_tval (int tval)
 Determines whether a tval is eligible for sval-ignore. More...
 
static void ignore_sval_menu_display (struct menu *menu, int oid, bool cursor, int row, int col, int width)
 Display an entry on the sval menu. More...
 
static bool ignore_sval_menu_action (struct menu *m, const ui_event *event, int oid)
 Deal with events on the sval menu. More...
 
static int ignore_collect_kind (int tval, ignore_choice **ch)
 Collect all tvals in the big ignore_choice array. More...
 
static bool sval_menu (int tval, const char *desc)
 Display list of svals to be ignored. More...
 
static bool seen_tval (int tval)
 Returns true if there's anything to display a menu of. More...
 
static char tag_options_item (struct menu *menu, int oid)
 
static int valid_options_item (struct menu *menu, int oid)
 
static void display_options_item (struct menu *menu, int oid, bool cursor, int row, int col, int width)
 
static bool handle_options_item (struct menu *menu, const ui_event *event, int oid)
 
void do_cmd_options_item (const char *title, int row)
 Display and handle the main ignoring menu. More...
 
void do_cmd_options (void)
 Display the options main menu. More...
 
void cleanup_options (void)
 

Variables

static const menu_iter option_toggle_iter
 Toggle option menu display and handling functions. More...
 
static struct keypress keymap_buffer [KEYMAP_ACTION_MAX]
 

Interact with keymaps

More...
 
static struct menukeymap_menu
 
static menu_action keymap_actions []
 
static struct menuvisual_menu
 
static menu_action visual_menu_items []
 
static struct menucolor_menu
 
static menu_action color_events []
 
static tval_desc sval_dependent []
 Categories for sval-dependent ignore. More...
 
static const menu_iter ignore_sval_menu
 
struct {
   char   tag
 
   const char *   name
 
   void(*   action )()
 
extra_item_options []
 Extra options on the "item options" menu. More...
 
static const menu_iter options_item_iter
 
static struct menuoption_menu
 

Main menu definitions and display

More...
 
static menu_action option_actions []
 

Detailed Description

Text UI options handling code (everything accessible from '=')

Copyright (c) 1997-2000 Robert A. Koeneke, James E. Wilson, Ben Harrison 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.

Macro Definition Documentation

#define EGO_MENU_HELPTEXT   "{light green}Movement keys{/} scroll the list\n{light red}ESC{/} returns to the previous menu\n{light blue}Enter{/} toggles the current setting."


Ego item ignore menu

Referenced by ego_menu().

Function Documentation

static bool askfor_aux_numbers ( char *  buf,
size_t  buflen,
size_t *  curs,
size_t *  len,
struct keypress  keypress,
bool  firsttime 
)
static
void cleanup_options ( void  )

References menu_free().

Referenced by textui_cleanup().

static int cmp_ignore ( const void a,
const void b 
)
static

Ordering function for ignore choices.

Aware comes before unaware, and then sort alphabetically.

References ignore_choice::aware, ignore_choice::kind, and object_kind_name().

Referenced by sval_menu().

static void colors_browse_hook ( int  oid,
void db,
const region loc 
)
static
static void colors_modify ( const char *  title,
int  row 
)
static
static void colors_pref_dump ( const char *  title,
int  row 
)
static

References dump_colors(), and dump_pref_file().

static void colors_pref_load ( const char *  title,
int  row 
)
static


Interact with colours

References do_cmd_pref_file_hack(), Term_redraw(), Term_xtra(), and TERM_XTRA_REACT.

static void display_options_item ( struct menu menu,
int  oid,
bool  cursor,
int  row,
int  col,
int  width 
)
static
static void do_cmd_colors ( const char *  title,
int  row 
)
static
static void do_cmd_delay ( const char *  name,
int  row 
)
static
static void do_cmd_hp_warn ( const char *  name,
int  row 
)
static
static void do_cmd_keymaps ( const char *  title,
int  row 
)
static
static void do_cmd_lazymove_delay ( const char *  name,
int  row 
)
static
void do_cmd_options ( void  )
void do_cmd_options_birth ( void  )

Edit birth options.

References OPT_PAGE_BIRTH, and option_toggle_menu().

Referenced by menu_question().

void do_cmd_options_item ( const char *  title,
int  row 
)
static void do_cmd_options_win ( const char *  name,
int  row 
)
static
static void do_cmd_pref_file_hack ( long  row)
static

Ask for a "user pref file" and process it.

This function should only be used by standard interaction commands, in which a standard "Command:" prompt is present on the given row.

Allow absolute file names? XXX XXX XXX

References askfor_aux(), player::full_name, msg, my_strcat(), NULL, player_safe_name(), process_pref_file(), prt(), screen_load(), and screen_save().

Referenced by colors_pref_load(), options_load_pref_file(), ui_keymap_pref_load(), and visuals_pref_load().

static void do_cmd_visuals ( const char *  title,
int  row 
)
static
static void do_dump_autoinsc ( const char *  title,
int  row 
)
static

Write autoinscriptions to a file.

References dump_autoinscriptions(), and dump_pref_file().

static void do_dump_options ( const char *  title,
int  row 
)
static

Write options to a file.

References dump_pref_file(), and option_dump().

static void dump_pref_file ( void(*)(ang_file *)  dump,
const char *  title,
int  row 
)
static
static bool ego_action ( struct menu menu,
const ui_event event,
int  oid 
)
static

Deal with events on the sval menu.

References ego_desc::e_idx, ego_ignore_toggle(), EVT_SELECT, ego_desc::itype, menu::menu_data, and ui_event::type.

Referenced by ego_menu().

static int ego_comp_func ( const void a_ptr,
const void b_ptr 
)
static

Utility function used for sorting an array of ego-item indices by ego-item name.

References ego_desc::short_name.

Referenced by ego_menu().

static void ego_display ( struct menu menu,
int  oid,
bool  cursor,
int  row,
int  col,
int  width 
)
static
int ego_item_name ( char *  buf,
size_t  buf_size,
struct ego_desc desc 
)
static void ego_menu ( const char *  unused,
int  also_unused 
)
static
static bool get_pref_path ( const char *  what,
int  row,
char *  buf,
size_t  max 
)
static

Prompt the user for a filename to save the pref file to.

References ANGBAND_DIR_USER, askfor_aux(), format(), player::full_name, my_strcat(), NULL, ok, path_build(), player_safe_name(), prt(), screen_load(), and screen_save().

Referenced by dump_pref_file().

static bool handle_options_item ( struct menu menu,
const ui_event event,
int  oid 
)
static
static int ignore_collect_kind ( int  tval,
ignore_choice **  ch 
)
static
static bool ignore_sval_menu_action ( struct menu m,
const ui_event event,
int  oid 
)
static
static void ignore_sval_menu_display ( struct menu menu,
int  oid,
bool  cursor,
int  row,
int  col,
int  width 
)
static
bool ignore_tval ( int  tval)

Determines whether a tval is eligible for sval-ignore.

References i, and N_ELEMENTS.

Referenced by o_xtra_act(), and textui_cmd_ignore_menu().

static void keymap_browse_hook ( int  oid,
void db,
const region loc 
)
static
static struct keypress keymap_get_trigger ( void  )
static

Ask for, and display, a keymap trigger.

Returns the trigger input.

Note that both "event_signal(EVENT_INPUT_FLUSH)" calls are extremely important. This may no longer be true, since "util.c" is much simpler now. XXX XXX XXX

References COLOUR_WHITE, EVENT_INPUT_FLUSH, event_signal(), inkey(), KEYPRESS_NULL, keypress_to_text(), and Term_addstr().

Referenced by ui_keymap_create(), ui_keymap_query(), and ui_keymap_remove().

static void option_toggle_display ( struct menu m,
int  oid,
bool  cursor,
int  row,
int  col,
int  width 
)
static


Options display and setting

Displays an option entry.

References c_prt(), curs_attrs, CURS_KNOWN, format(), menu_priv(), option_desc(), option_name(), and options.

static bool option_toggle_handle ( struct menu m,
const ui_event event,
int  oid 
)
static
static void option_toggle_menu ( const char *  name,
int  page 
)
static
static void options_load_pref_file ( const char *  n,
int  row 
)
static

Load a pref file.

References do_cmd_pref_file_hack().

static bool quality_action ( struct menu m,
const ui_event event,
int  oid 
)
static
static void quality_display ( struct menu menu,
int  oid,
bool  cursor,
int  row,
int  col,
int  width 
)
static
static void quality_menu ( void unused,
const char *  also_unused 
)
static
static void quality_subdisplay ( struct menu menu,
int  oid,
bool  cursor,
int  row,
int  col,
int  width 
)
static

Display the quality ignore subtypes.

References c_put_str(), COLOUR_L_BLUE, COLOUR_WHITE, quality_name_struct::name, and quality_values.

Referenced by quality_action().

int quality_validity ( struct menu menu,
int  oid 
)

Determine if an item is a valid choice.

Referenced by quality_menu().

static bool seen_tval ( int  tval)
static

Returns true if there's anything to display a menu of.

References object_kind::everseen, i, k_info, angband_constants::k_max, object_kind::name, object_kind::tval, and z_info.

Referenced by display_options_item().

static const char* strip_ego_name ( const char *  name)
static

Skip common prefixes in ego-item names.

References name, and prefix().

Referenced by ego_menu().

static bool sval_menu ( int  tval,
const char *  desc 
)
static
static char tag_options_item ( struct menu menu,
int  oid 
)
static

References extra_item_options, I2A, and N_ELEMENTS.

static void ui_keymap_create ( const char *  title,
int  row 
)
static
static void ui_keymap_pref_append ( const char *  title,
int  row 
)
static

References dump_pref_file(), and keymap_dump().

static void ui_keymap_pref_load ( const char *  title,
int  row 
)
static

Keymap menu action functions.

References do_cmd_pref_file_hack().

static void ui_keymap_query ( const char *  title,
int  row 
)
static
static void ui_keymap_remove ( const char *  title,
int  row 
)
static
static int valid_options_item ( struct menu menu,
int  oid 
)
static

References extra_item_options, and N_ELEMENTS.

static void visuals_browse_hook ( int  oid,
void db,
const region loc 
)
static
static void visuals_dump_features ( const char *  title,
int  row 
)
static
static void visuals_dump_flavors ( const char *  title,
int  row 
)
static

References dump_flavors(), and dump_pref_file().

static void visuals_dump_monsters ( const char *  title,
int  row 
)
static
static void visuals_dump_objects ( const char *  title,
int  row 
)
static

References dump_objects(), and dump_pref_file().

static void visuals_pref_load ( const char *  title,
int  row 
)
static


Interact with visuals

References do_cmd_pref_file_hack().

static void visuals_reset ( const char *  title,
int  row 
)
static

Variable Documentation

void(* action)()
menu_action color_events[]
static
Initial value:
=
{
{ 0, 0, "Load a user pref file", colors_pref_load },
{ 0, 0, "Dump colors", colors_pref_dump },
{ 0, 0, "Modify colors", colors_modify }
}
static void colors_pref_dump(const char *title, int row)
Definition: ui-options.c:712
static void colors_modify(const char *title, int row)
Definition: ui-options.c:717
static void colors_pref_load(const char *title, int row)
Interact with colours
Definition: ui-options.c:700
struct menu* color_menu
static
struct { ... } extra_item_options[]
Initial value:
= {
{ 'Q', "Quality ignoring options", quality_menu },
{ 'E', "Ego ignoring options", ego_menu},
{ '{', "Autoinscription setup", textui_browse_object_knowledge },
}
void textui_browse_object_knowledge(const char *name, int row)
Display known objects.
Definition: ui-knowledge.c:1965
static void quality_menu(void *unused, const char *also_unused)
Display quality ignore menu.
Definition: ui-options.c:1385
static void ego_menu(const char *unused, int also_unused)
Display list of ego items to be ignored.
Definition: ui-options.c:1172

Extra options on the "item options" menu.

Referenced by display_options_item(), do_cmd_options_item(), handle_options_item(), tag_options_item(), and valid_options_item().

const menu_iter ignore_sval_menu
static
Initial value:
=
{
}
static bool ignore_sval_menu_action(struct menu *m, const ui_event *event, int oid)
Deal with events on the sval menu.
Definition: ui-options.c:1494
static void ignore_sval_menu_display(struct menu *menu, int oid, bool cursor, int row, int col, int width)
Display an entry on the sval menu.
Definition: ui-options.c:1469
NULL
Definition: list-summon-types.h:18
menu_action keymap_actions[]
static
Initial value:
=
{
{ 0, 0, "Load a user pref file", ui_keymap_pref_load },
{ 0, 0, "Save keymaps to file", ui_keymap_pref_append },
{ 0, 0, "Query a keymap", ui_keymap_query },
{ 0, 0, "Create a keymap", ui_keymap_create },
{ 0, 0, "Remove a keymap", ui_keymap_remove },
}
static void ui_keymap_create(const char *title, int row)
Definition: ui-options.c:460
static void ui_keymap_query(const char *title, int row)
Definition: ui-options.c:428
static void ui_keymap_remove(const char *title, int row)
Definition: ui-options.c:540
static void ui_keymap_pref_load(const char *title, int row)
Keymap menu action functions.
Definition: ui-options.c:418
static void ui_keymap_pref_append(const char *title, int row)
Definition: ui-options.c:423
struct keypress keymap_buffer[KEYMAP_ACTION_MAX]
static


Interact with keymaps

Current (or recent) keymap action

Referenced by keymap_browse_hook(), and ui_keymap_create().

struct menu* keymap_menu
static
const char* name
menu_action option_actions[]
static
Initial value:
=
{
{ 0, 'a', "User interface options", option_toggle_menu },
{ 0, 'b', "Birth (difficulty) options", option_toggle_menu },
{ 0, 'x', "Cheat options", option_toggle_menu },
{ 0, 'w', "Subwindow setup", do_cmd_options_win },
{ 0, 'i', "Item ignoring setup", do_cmd_options_item },
{ 0, '{', "Auto-inscription setup", textui_browse_object_knowledge },
{ 0, 0, NULL, NULL },
{ 0, 'd', "Set base delay factor", do_cmd_delay },
{ 0, 'h', "Set hitpoint warning", do_cmd_hp_warn },
{ 0, 'm', "Set movement delay", do_cmd_lazymove_delay },
{ 0, 0, NULL, NULL },
{ 0, 's', "Save subwindow setup to pref file", do_dump_options },
{ 0, 't', "Save autoinscriptions to pref file", do_dump_autoinsc },
{ 0, 0, NULL, NULL },
{ 0, 'l', "Load a user pref file", options_load_pref_file },
{ 0, 'k', "Edit keymaps (advanced)", do_cmd_keymaps },
{ 0, 'c', "Edit colours (advanced)", do_cmd_colors },
{ 0, 'v', "Save visuals (advanced)", do_cmd_visuals },
}
static void options_load_pref_file(const char *n, int row)
Load a pref file.
Definition: ui-options.c:1037
static void do_dump_options(const char *title, int row)
Write options to a file.
Definition: ui-options.c:1023
static void do_cmd_hp_warn(const char *name, int row)
Set hitpoint warning level.
Definition: ui-options.c:911
static void do_cmd_delay(const char *name, int row)
Set base delay factor.
Definition: ui-options.c:882
static void do_cmd_lazymove_delay(const char *name, int row)
Set "lazy-movement" delay.
Definition: ui-options.c:949
void textui_browse_object_knowledge(const char *name, int row)
Display known objects.
Definition: ui-knowledge.c:1965
static void do_cmd_keymaps(const char *title, int row)
Definition: ui-options.c:584
void do_cmd_options_item(const char *title, int row)
Display and handle the main ignoring menu.
Definition: ui-options.c:1756
static void option_toggle_menu(const char *name, int page)
Interact with some options.
Definition: ui-options.c:174
static void do_cmd_visuals(const char *title, int row)
Interact with "visuals".
Definition: ui-options.c:672
static void do_cmd_options_win(const char *name, int row)
Modify the "window" options.
Definition: ui-options.c:232
NULL
Definition: list-summon-types.h:18
static void do_cmd_colors(const char *title, int row)
Interact with "colors".
Definition: ui-options.c:824
static void do_dump_autoinsc(const char *title, int row)
Write autoinscriptions to a file.
Definition: ui-options.c:1030
struct menu* option_menu
static


Main menu definitions and display

const menu_iter option_toggle_iter
static
Initial value:
= {
NULL
}
static bool option_toggle_handle(struct menu *m, const ui_event *event, int oid)
Handle keypresses for an option entry.
Definition: ui-options.c:119
static void option_toggle_display(struct menu *m, int oid, bool cursor, int row, int col, int width)
Options display and setting
Definition: ui-options.c:106
NULL
Definition: list-summon-types.h:18

Toggle option menu display and handling functions.

const menu_iter options_item_iter
static
Initial value:
=
{
}
static int valid_options_item(struct menu *menu, int oid)
Definition: ui-options.c:1683
static void display_options_item(struct menu *menu, int oid, bool cursor, int row, int col, int width)
Definition: ui-options.c:1702
static char tag_options_item(struct menu *menu, int oid)
Definition: ui-options.c:1664
static bool handle_options_item(struct menu *menu, const ui_event *event, int oid)
Definition: ui-options.c:1723
NULL
Definition: list-summon-types.h:18
tval_desc sval_dependent[]
static
Initial value:
=
{
{ TV_STAFF, "Staffs" },
{ TV_WAND, "Wands" },
{ TV_ROD, "Rods" },
{ TV_SCROLL, "Scrolls" },
{ TV_POTION, "Potions" },
{ TV_RING, "Rings" },
{ TV_AMULET, "Amulets" },
{ TV_FOOD, "Food" },
{ TV_MUSHROOM, "Mushrooms" },
{ TV_MAGIC_BOOK, "Magic books" },
{ TV_PRAYER_BOOK, "Prayer books" },
{ TV_LIGHT, "Lights" },
{ TV_FLASK, "Flasks of oil" },
{ TV_GOLD, "Money" },
}

Categories for sval-dependent ignore.

char tag
struct menu* visual_menu
static
menu_action visual_menu_items[]
static
Initial value:
=
{
{ 0, 0, "Load a user pref file", visuals_pref_load },
{ 0, 0, "Save monster attr/chars", visuals_dump_monsters },
{ 0, 0, "Save object attr/chars", visuals_dump_objects },
{ 0, 0, "Save feature attr/chars", visuals_dump_features },
{ 0, 0, "Save flavor attr/chars", visuals_dump_flavors },
{ 0, 0, "Reset visuals", visuals_reset },
}
static void visuals_dump_monsters(const char *title, int row)
Definition: ui-options.c:618
static void visuals_pref_load(const char *title, int row)
Interact with visuals
Definition: ui-options.c:613
static void visuals_dump_flavors(const char *title, int row)
Definition: ui-options.c:633
static void visuals_dump_objects(const char *title, int row)
Definition: ui-options.c:623
static void visuals_dump_features(const char *title, int row)
Definition: ui-options.c:628
static void visuals_reset(const char *title, int row)
Definition: ui-options.c:638