Skip to content

Commit

Permalink
Add whatis_filter option to filter eligible map locations for travel
Browse files Browse the repository at this point in the history
Compound option whatis_filter, filters the eligible map locations
when getting a cursor location for targeting. Accepts 'n' (none),
'v' (map locations in view), or 'a' (map locations in the same area,
eg. room or corridor).
  • Loading branch information
paxed committed Jul 31, 2017
1 parent 6b851e0 commit 439028d
Show file tree
Hide file tree
Showing 13 changed files with 285 additions and 43 deletions.
6 changes: 6 additions & 0 deletions dat/opthelp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ whatis_coord controls whether to include map coordinates when [n]
map -- <x,y> (map column x=0 is not used)
screen -- [row,column] (row is offset to match tty usage)
none -- no coordinates shown.
whatis_filter controls how to filter eligible map coordinates when [n]
getting a map location for eg. the travel command.
Value is the one of
n - no filtering
v - locations in view only
a - locations in same area (room, corridor, etc)

Compound options which may be set only on startup are:

Expand Down
28 changes: 23 additions & 5 deletions doc/Guidebook.mn
Original file line number Diff line number Diff line change
Expand Up @@ -2927,10 +2927,23 @@ The
option is also used with
the `/m', `/M', `/o', and `/O' sub-commands of `/',
where the `none' setting is overridden with `map'.
.lp whatis_inview
.lp whatis_filter
When getting a location on the map, and using the keys to cycle through
next and previous targets, limit the possible targets to those in view.
(default off)
next and previous targets, allows filtering the possible targets.
.lp ""
.sd
.si
.CC n "no filtering [default]"
.CC v "in view only"
.CC a "in same area only"
.ei
.ed
.lp ""
The area-filter tries to be slightly predictive - if you're standing on a doorway,
it will consider the area on the side of the door you were last moving towards.
.lp ""
Filtering can also be changed when getting a location with the ``getpos.filter''
key.
.lp whatis_menu
When getting a location on the map, and using a key to cycle through
next and previous targets, use a menu instead to pick a target.
Expand Down Expand Up @@ -3246,8 +3259,10 @@ When asked for a location, the key to go to next closest object. Default is 'o'.
When asked for a location, the key to go to previous closest object. Default is 'O'.
.lp getpos.menu
When asked for a location, and using one of the next or previous keys to cycle through targets, toggle showing a menu instead. Default is '!'.
.lp getpos.inview
When asked for a location, and using one of the next or previous keys to cycle through targets, toggle limiting possible targets to those in view only. Default is '"'.
.lp getpos.filter
When asked for a location, change the filtering mode when using one of the next
or previous keys to cycle through targets. Toggles between no filtering, in view
only, and in the same area only. Default is '"'.
.lp getpos.pick
When asked for a location, the key to choose the location, and possibly ask for more info. Default is '.'.
.lp getpos.pick.once
Expand Down Expand Up @@ -3724,6 +3739,9 @@ was interrupted.
.lp whatis_coord:compass
When targeting with cursor, describe the cursor position with coordinates
relative to your character.
.lp whatis_filter:area
When targeting with cursor, filter possible locations so only those in
the same area (eg. same room, or same corridor) are considered.
.lp nostatus_updates
Prevent updates to the status lines at the bottom of the screen, if
your screen-reader reads those lines. The same information can be
Expand Down
31 changes: 26 additions & 5 deletions doc/Guidebook.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3561,10 +3561,27 @@ \subsection*{Customization options}
of `{\tt /}',
where the `{\it none\/}' setting is overridden with `{\it map}'.
%.lp
\item[\ib{whatis\verb+_+inview}]
\item[\ib{whatis\verb+_+filter}]
When getting a location on the map, and using the keys to cycle through
next and previous targets, limit the possible targets to those in view.
(default off)
next and previous targets, allows filtering the possible targets.
(default none)
%.lp ""
The possible settings are:
%.sd
%.si
{\tt n} --- \verb#no filtering#;\\
{\tt v} --- \verb#in view only#;\\
{\tt a} --- \verb#in same area (room, corridor, etc)#.
%.ei
%.ed
%.lp ""
The area-filter tries to be slightly predictive - if you're standing on a doorway,
it will consider the area on the side of the door you were last moving towards.
%.lp ""
Filtering can also be changed when getting a location with the ``getpos.filter''
key.
%.lp
\item[\ib{whatis\verb+_+menu}]
When getting a location on the map, and using a key to cycle through
next and previous targets, use a menu instead to pick a target.
Expand Down Expand Up @@ -3974,8 +3991,8 @@ \subsection*{Changing Key Bindings}
\item{\bb{getpos.menu}}
When asked for a location, and using one of the next or previous keys to cycle through targets, toggle showing a menu instead. Default is '{\tt !}'.
%.lp
\item{\bb{getpos.inview}}
When asked for a location, and using one of the next or previous keys to cycle through targets, toggle limiting possible targets to those in view only. Default is '{\tt "}'.
\item{\bb{getpos.filter}}
When asked for a location, change the filtering mode when using one of the next or previous keys to cycle through targets. Toggles between no filtering, in view only, and in the same area only. Default is '{\tt "}'.
%.lp
\item{\bb{getpos.pick}}
When asked for a location, the key to choose the location, and possibly ask for more info. Default is ``{\tt .}''.
Expand Down Expand Up @@ -4528,6 +4545,10 @@ \subsection*{Configuring NetHack for Play by the Blind}
When targeting with cursor, describe the cursor position with coordinates
relative to your character.
%.lp
\item[\ib{whatis\verb+_+filter:area}]
When targeting with cursor, filter possible locations so only those in
the same area (eg. same room, or same corridor) are considered.
%.lp
\item[\ib{nostatus\verb+_+updates}]
Prevent updates to the status lines at the bottom of the screen, if
your screen-reader reads those lines. The same information can be
Expand Down
2 changes: 2 additions & 0 deletions doc/fixes36.1
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,8 @@ for menustyle:Traditional and Combination, support BUCX filtering for item
pick-up and container put-in and take-out; also for object IDing
for menustyle:Full and Traditional and Combination, support BUCX filtering
for the 'A' command
option whatis_filter to set filtering for eligible map locations when cursor
positioning


Platform- and/or Interface-Specific New Features
Expand Down
8 changes: 8 additions & 0 deletions include/decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,14 @@ E char *fqn_prefix_names[PREFIX_COUNT];

E NEARDATA struct savefile_info sfcap, sfrestinfo, sfsaveinfo;

struct opvar {
xchar spovartyp; /* one of SPOVAR_foo */
union {
char *str;
long l;
} vardata;
};

struct autopickup_exception {
struct nhregex *regex;
char *pattern;
Expand Down
7 changes: 6 additions & 1 deletion include/extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ E void NDECL(heal_legs);
/* ### do_name.c ### */

E char *FDECL(coord_desc, (int, int, char *, CHAR_P));
E boolean FDECL(getpos_menu, (coord *, BOOLEAN_P, int));
E boolean FDECL(getpos_menu, (coord *, int));
E int FDECL(getpos, (coord *, BOOLEAN_P, const char *));
E void FDECL(getpos_sethilite, (void (*f)(int)));
E void FDECL(new_mname, (struct monst *, int));
Expand Down Expand Up @@ -2250,6 +2250,11 @@ E boolean
FDECL(dig_corridor, (coord *, coord *, BOOLEAN_P, SCHAR_P, SCHAR_P));
E void FDECL(fill_room, (struct mkroom *, BOOLEAN_P));
E boolean FDECL(load_special, (const char *));
E xchar FDECL(selection_getpoint, (int, int, struct opvar *));
E struct opvar *FDECL(selection_opvar, (char *));
E void FDECL(opvar_free_x, (struct opvar *));
E void FDECL(set_selection_floodfillchk, (int FDECL((*), (int,int))));
E void FDECL(selection_floodfill, (struct opvar *, int, int, BOOLEAN_P));

/* ### spell.c ### */

Expand Down
10 changes: 9 additions & 1 deletion include/flag.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ struct sysflag {
#define GPCOORDS_COMFULL 'f'
#define GPCOORDS_SCREEN 's'

enum getloc_filters {
GFILTER_NONE = 0,
GFILTER_VIEW,
GFILTER_AREA,

NUM_GFILTER
};

struct instance_flags {
/* stuff that really isn't option or platform related. They are
* set and cleared during the game to control the internal
Expand All @@ -194,7 +202,7 @@ struct instance_flags {
#define TER_MON 0x08
#define TER_DETECT 0x10 /* detect_foo magic rather than #terrain */
boolean getloc_travelmode;
boolean getloc_limitview;
int getloc_filter; /* GFILTER_foo */
boolean getloc_usemenu;
coord travelcc; /* coordinates for travel_cache */
boolean window_inited; /* true if init_nhwindows() completed */
Expand Down
6 changes: 6 additions & 0 deletions include/rm.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ enum screen_symbols {
#define is_cmap_drawbridge(i) ((i) >= S_vodbridge && (i) <= S_hcdbridge)
#define is_cmap_door(i) ((i) >= S_vodoor && (i) <= S_hcdoor)
#define is_cmap_wall(i) ((i) >= S_stone && (i) <= S_trwall)
#define is_cmap_room(i) ((i) >= S_room && (i) <= S_darkroom)
#define is_cmap_corr(i) ((i) >= S_corr && (i) <= S_litcorr)
#define is_cmap_furniture(i) ((i) >= S_upstair && (i) <= S_fountain)
#define is_cmap_water(i) ((i) == S_pool || (i) == S_water)
#define is_cmap_lava(i) ((i) == S_lava)


struct symdef {
uchar sym;
Expand Down
8 changes: 0 additions & 8 deletions include/sp_lev.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,6 @@ enum opcode_defs {
#define SP_MAPCHAR_LIT(l) ((((l) >> 8) & 0xffff) - 10)
#define SP_MAPCHAR_PACK(typ, lit) (((10 + (lit)) << 8) | ((typ) & 0xff))

struct opvar {
xchar spovartyp; /* one of SPOVAR_foo */
union {
char *str;
long l;
} vardata;
};

struct splev_var {
struct splev_var *next;
char *name;
Expand Down
8 changes: 6 additions & 2 deletions src/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3741,7 +3741,7 @@ struct {
{ NHKF_GETPOS_INTERESTING_NEXT, 'a', "getpos.all.next" },
{ NHKF_GETPOS_INTERESTING_PREV, 'A', "getpos.all.prev" },
{ NHKF_GETPOS_HELP, '?', "getpos.help" },
{ NHKF_GETPOS_LIMITVIEW, '"', "getpos.inview" },
{ NHKF_GETPOS_LIMITVIEW, '"', "getpos.filter" },
{ NHKF_GETPOS_MENU, '!', "getpos.menu" }
};

Expand Down Expand Up @@ -5030,10 +5030,14 @@ dotravel(VOID_ARGS)
}
iflags.getloc_travelmode = TRUE;
if (iflags.menu_requested) {
if (!getpos_menu(&cc, TRUE, GLOC_INTERESTING)) {
int gf = iflags.getloc_filter;
iflags.getloc_filter = GFILTER_VIEW;
if (!getpos_menu(&cc, GLOC_INTERESTING)) {
iflags.getloc_filter = gf;
iflags.getloc_travelmode = FALSE;
return 0;
}
iflags.getloc_filter = gf;
} else {
pline("Where do you want to travel to?");
if (getpos(&cc, TRUE, "the desired destination") < 0) {
Expand Down
Loading

0 comments on commit 439028d

Please sign in to comment.