Angband
Functions | Variables
game-input.c File Reference

Ask for non-command input from the UI. More...

#include "angband.h"
#include "cmd-core.h"
#include "game-input.h"

Functions

bool get_string (const char *prompt, char *buf, size_t len)
 Prompt for a string from the user. More...
 
int get_quantity (const char *prompt, int max)
 Request a quantity from the user. More...
 
bool get_check (const char *prompt)
 Verify something with the user. More...
 
bool get_com (const char *prompt, char *command)
 Prompts for a keypress. More...
 
bool get_rep_dir (int *dir, bool allow_none)
 Request a "movement" direction from the user. More...
 
bool get_aim_dir (int *dir)
 Get an "aiming" direction from the user. More...
 
int get_spell_from_book (const char *verb, struct object *book, const char *error, bool(*spell_filter)(int spell))
 Get a spell from a specified book. More...
 
int get_spell (const char *verb, item_tester book_filter, cmd_code cmd, const char *error, bool(*spell_filter)(int spell))
 Get a spell from the player. More...
 
bool 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...
 
bool get_curse (int *choice, struct object *obj)
 Get a curse from an object. More...
 
void get_panel (int *min_y, int *min_x, int *max_y, int *max_x)
 Get the borders of the area the player can see (the "panel") More...
 
bool panel_contains (unsigned int y, unsigned int x)
 Check to see if a map grid is in the panel. More...
 
bool map_is_visible (void)
 Check to see if the map is currently shown. More...
 

Variables

bool(* get_string_hook )(const char *prompt, char *buf, size_t len)
 
int(* get_quantity_hook )(const char *prompt, int max)
 
bool(* get_check_hook )(const char *prompt)
 
bool(* get_com_hook )(const char *prompt, char *command)
 
bool(* get_rep_dir_hook )(int *dir, bool allow_none)
 
bool(* get_aim_dir_hook )(int *dir)
 
int(* get_spell_from_book_hook )(const char *verb, struct object *book, const char *error, bool(*spell_filter)(int spell))
 
int(* get_spell_hook )(const char *verb, item_tester book_filter, cmd_code cmd, const char *error, bool(*spell_filter)(int spell))
 
bool(* get_item_hook )(struct object **choice, const char *pmt, const char *str, cmd_code cmd, item_tester tester, int mode)
 
bool(* get_curse_hook )(int *choice, struct object *obj)
 
void(* get_panel_hook )(int *min_y, int *min_x, int *max_y, int *max_x)
 
bool(* panel_contains_hook )(unsigned int y, unsigned int x)
 
bool(* map_is_visible_hook )(void)
 

Detailed Description

Ask for non-command input from the UI.

Copyright (c) 2014 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.

Function Documentation

bool get_aim_dir ( int dir)

Get an "aiming" direction from the user.

Parameters
diris a pointer to an integer representing the chosen direction
Returns
true if a direction was chosen, otherwise return false.

References get_aim_dir_hook.

Referenced by cmd_get_target(), and effect_simple().

bool get_check ( const char *  prompt)

Verify something with the user.

Parameters
promptis the prompt to the user, and should take the form "Query? "
Returns
whether the user answered "y"

get_check_hook() should be set to a function which asks the user for a "y/n" answer

References get_check_hook.

Referenced by context_menu_object(), death_screen(), do_cmd_cast(), do_cmd_go_down(), do_cmd_wield(), do_cmd_wiz_jump(), do_cmd_wizard(), effect_handler_RECALL(), get_debug_command(), get_file_text(), key_confirm_command(), move_player(), ranged_helper(), take_hit(), textui_cmd_debug(), textui_cmd_suicide(), ui_keymap_create(), and verify_object().

bool get_com ( const char *  prompt,
char *  command 
)

Prompts for a keypress.

Parameters
promptis the prompt to the user, and should take the form "Command: "
commandstores the keypress
Returns
whether the user accepted the entered value or escaped

References get_com_hook.

Referenced by do_cmd_locate(), do_cmd_query_symbol(), do_cmd_wiz_features(), do_cmd_wiz_hack_nick(), do_cmd_wiz_play(), do_cmd_wiz_query(), effect_handler_BANISH(), get_debug_command(), textui_get_command(), wiz_reroll_item(), and wiz_statistics().

bool get_curse ( int choice,
struct object obj 
)

Get a curse from an object.

References get_curse_hook.

Referenced by uncurse_object().

bool 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.

Parameters
choiceis the chosen object
pmtis the prompt to the player
stris the message if no valid item is available
cmdis the command (if any) the request is called from
testeris the function (if any) used to test for valid objects
modegives more information on where the object can be chosen from

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.

References get_item_hook.

Referenced by cmd_get_item(), context_menu_player_display_floor(), death_examine(), do_cmd_equip(), do_cmd_inven(), do_cmd_quiver(), do_cmd_wiz_play(), effect_handler_BRAND_AMMO(), effect_handler_BRAND_BOLTS(), effect_handler_IDENTIFY(), effect_handler_RECHARGE(), effect_handler_REMOVE_CURSE(), enchant_spell(), player_pickup_item(), store_sell(), textui_cmd_ignore(), textui_get_spell(), textui_obj_examine(), and textui_spell_browse().

void get_panel ( int min_y,
int min_x,
int max_y,
int max_x 
)

Get the borders of the area the player can see (the "panel")

References get_panel_hook.

Referenced by target_get_monsters().

int get_quantity ( const char *  prompt,
int  max 
)

Request a quantity from the user.

Parameters
promptis the prompt to the user, and should take the form "Prompt: "
maxis the maximum value to accept
Returns
the quantity

References get_quantity_hook.

Referenced by cmd_get_quantity(), do_cmd_wiz_effect(), get_debug_command(), player_pickup_aux(), store_purchase(), and store_sell().

bool get_rep_dir ( int dir,
bool  allow_none 
)

Request a "movement" direction from the user.

Parameters
diris a pointer to an integer representing the chosen direction
allow_nonecan be set to true to allow the null direction
Returns
true if a direction was chosen, otherwise return false.

References get_rep_dir_hook.

Referenced by cmd_get_direction().

int get_spell ( const char *  verb,
item_tester  book_filter,
cmd_code  cmd,
const char *  error,
bool(*)(int spell)  spell_filter 
)

Get a spell from the player.

References get_spell_hook.

Referenced by cmd_get_spell().

int get_spell_from_book ( const char *  verb,
struct object book,
const char *  error,
bool(*)(int spell)  spell_filter 
)

Get a spell from a specified book.

References get_spell_from_book_hook.

Referenced by cmd_get_spell().

bool get_string ( const char *  prompt,
char *  buf,
size_t  len 
)

Prompt for a string from the user.

Parameters
promptis the prompt to the user, and should take the form "Prompt: "
bufis the user string, and the value passed in is the default
lenis the length of buf
Returns
whether the user accepted the entered value or escaped

References get_string_hook.

Referenced by choose_profile(), cmd_get_string(), do_cmd_note(), do_cmd_pref(), do_cmd_wiz_change_aux(), do_cmd_wiz_jump(), get_debug_command(), get_file_text(), glyph_command(), textui_cmd_rest(), textui_get_quantity(), wiz_quantity_item(), and wiz_tweak_item().

bool map_is_visible ( void  )

Check to see if the map is currently shown.

References map_is_visible_hook.

Referenced by redraw_stuff(), and update_stuff().

bool panel_contains ( unsigned int  y,
unsigned int  x 
)

Check to see if a map grid is in the panel.

References panel_contains_hook.

Referenced by draw_path(), load_path(), message_flags(), monster_desc(), project(), and target_sighted().

Variable Documentation

bool(* get_aim_dir_hook)(int *dir)

Referenced by get_aim_dir(), and textui_input_init().

bool(* get_check_hook)(const char *prompt)

Referenced by get_check(), and textui_input_init().

bool(* get_com_hook)(const char *prompt, char *command)

Referenced by get_com(), and textui_input_init().

bool(* get_curse_hook)(int *choice, struct object *obj)

Referenced by get_curse(), and textui_input_init().

bool(* get_item_hook)(struct object **choice, const char *pmt, const char *str, cmd_code cmd, item_tester tester, int mode)

Referenced by get_item(), and textui_input_init().

void(* get_panel_hook)(int *min_y, int *min_x, int *max_y, int *max_x)

Referenced by get_panel(), and textui_input_init().

int(* get_quantity_hook)(const char *prompt, int max)

Referenced by get_quantity(), and textui_input_init().

bool(* get_rep_dir_hook)(int *dir, bool allow_none)

Referenced by get_rep_dir(), and textui_input_init().

int(* get_spell_from_book_hook)(const char *verb, struct object *book, const char *error, bool(*spell_filter)(int spell))
int(* get_spell_hook)(const char *verb, item_tester book_filter, cmd_code cmd, const char *error, bool(*spell_filter)(int spell))

Referenced by get_spell(), and textui_input_init().

bool(* get_string_hook)(const char *prompt, char *buf, size_t len)

Referenced by get_string(), and textui_input_init().

bool(* map_is_visible_hook)(void)
bool(* panel_contains_hook)(unsigned int y, unsigned int x)