Add whatis_filter option to filter eligible map locations for travel

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).
This commit is contained in:
Pasi Kallinen
2017-07-31 16:58:23 +03:00
parent 6b851e0503
commit 439028dcae
13 changed files with 285 additions and 43 deletions

View File

@@ -233,7 +233,6 @@ static struct Bool_Opt {
{ "vt_tiledata", (boolean *) 0, FALSE, SET_IN_FILE },
#endif
{ "whatis_menu", &iflags.getloc_usemenu, FALSE, SET_IN_GAME },
{ "whatis_inview", &iflags.getloc_limitview, FALSE, SET_IN_GAME },
{ "wizweight", &iflags.wizweight, FALSE, SET_IN_WIZGAME },
{ "wraptext", &iflags.wc2_wraptext, FALSE, SET_IN_GAME },
#ifdef ZEROCOMP
@@ -403,6 +402,8 @@ static struct Comp_Opt {
#endif
{ "whatis_coord", "show coordinates when auto-describing cursor position",
1, SET_IN_GAME },
{ "whatis_filter", "filter coordinate locations when targeting next or previous",
1, SET_IN_GAME },
{ "windowcolors", "the foreground/background colors of windows", /*WC*/
80, DISP_IN_GAME },
{ "windowtype", "windowing system to use", WINTYPELEN, DISP_IN_GAME },
@@ -2379,7 +2380,7 @@ boolean tinitial, tfrom_file;
}
fullname = "whatis_coord";
if (match_optname(opts, fullname, 6, TRUE)) {
if (match_optname(opts, fullname, 8, TRUE)) {
if (duplicate)
complain_about_duplicate(opts, 1);
if (negated) {
@@ -2399,6 +2400,33 @@ boolean tinitial, tfrom_file;
return;
}
fullname = "whatis_filter";
if (match_optname(opts, fullname, 8, TRUE)) {
if (duplicate)
complain_about_duplicate(opts, 1);
if (negated) {
iflags.getloc_filter = GFILTER_NONE;
return;
} else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
char c = lowc(*op);
switch (c) {
case 'n':
iflags.getloc_filter = GFILTER_NONE;
break;
case 'v':
iflags.getloc_filter = GFILTER_VIEW;
break;
case 'a':
iflags.getloc_filter = GFILTER_AREA;
break;
default:
badoption(opts);
}
}
return;
}
fullname = "warnings";
if (match_optname(opts, fullname, 5, TRUE)) {
if (duplicate)
@@ -4283,6 +4311,37 @@ boolean setinitial, setfromfile;
free((genericptr_t) window_pick);
}
destroy_nhwindow(tmpwin);
} else if (!strcmp("whatis_filter", optname)) {
menu_item *window_pick = (menu_item *) 0;
int pick_cnt;
char gf = iflags.getloc_filter;
tmpwin = create_nhwindow(NHW_MENU);
start_menu(tmpwin);
any = zeroany;
any.a_char = (GFILTER_NONE + 1);
add_menu(tmpwin, NO_GLYPH, &any, 'n',
0, ATR_NONE, "no filtering",
(gf == GFILTER_NONE) ? MENU_SELECTED : MENU_UNSELECTED);
any.a_char = (GFILTER_VIEW + 1);
add_menu(tmpwin, NO_GLYPH, &any, 'v',
0, ATR_NONE, "in view only",
(gf == GFILTER_VIEW) ? MENU_SELECTED : MENU_UNSELECTED);
any.a_char = (GFILTER_AREA + 1);
add_menu(tmpwin, NO_GLYPH, &any, 'a',
0, ATR_NONE, "in same area",
(gf == GFILTER_AREA) ? MENU_SELECTED : MENU_UNSELECTED);
end_menu(tmpwin,
"Select location filtering when going for next/previous map position:");
if ((pick_cnt = select_menu(tmpwin, PICK_ONE, &window_pick)) > 0) {
iflags.getloc_filter = (window_pick[0].item.a_char - 1);
/* PICK_ONE doesn't unselect preselected entry when
selecting another one */
if (pick_cnt > 1 && iflags.getloc_filter == gf)
iflags.getloc_filter = (window_pick[1].item.a_char - 1);
free((genericptr_t) window_pick);
}
destroy_nhwindow(tmpwin);
} else if (!strcmp("msg_window", optname)) {
#ifdef TTY_GRAPHICS
/* by Christian W. Cooper */
@@ -5057,6 +5116,11 @@ char *buf;
: (iflags.getpos_coords == GPCOORDS_COMFULL) ? "full compass"
: (iflags.getpos_coords == GPCOORDS_SCREEN) ? "screen"
: "none");
} else if (!strcmp(optname, "whatis_filter")) {
Sprintf(buf, "%s",
(iflags.getloc_filter == GFILTER_VIEW) ? "view"
: (iflags.getloc_filter == GFILTER_AREA) ? "area"
: "none");
} else if (!strcmp(optname, "scores")) {
Sprintf(buf, "%d top/%d around%s", flags.end_top, flags.end_around,
flags.end_own ? "/own" : "");