whatis_coord - rename 'getpos_coord' option

Rename the option for adding coordinates to autodescribe feedback for
the '/' and ';' commands from 'getpos_coord' to 'whatis_coord', after
the '/' command that uses it instead of after the internal routine
that implements it.  The 'whatis' name was only in dat/hh as far as I
could find, so this changes it to 'what-is' and also updates dat/help
and the Guidebook to mention the name too.

Add a 'screen' choice to the option to show coordinates as row,column
rather than x,y or compass direction(s).  Revise the /m, /M, /o, /O
operations of 'what-is' to honor the whatis_coord option (mostly; a
value of 'none' gets overridden by 'map' to force coordinates).

Also, update the description of the functionality of the '/' command
in the Guidebook.  The .mn version is tested, the .tex one isn't.
This commit is contained in:
PatR
2016-01-18 19:27:53 -08:00
parent 8cd65daf39
commit 83a4234292
11 changed files with 2174 additions and 1949 deletions

View File

@@ -64,6 +64,10 @@ const char *goal;
if (getpos_hilitefunc)
putstr(tmpwin, 0, "Use $ to display valid locations.");
putstr(tmpwin, 0, "Use # to toggle automatic description.");
if (iflags.cmdassist) /* assisting the '/' command, I suppose... */
putstr(tmpwin, 0, (iflags.getpos_coords == GPCOORDS_NONE)
? "(Set 'whatis_coord' option to include coordinates with '#' text.)"
: "(Reset 'whatis_coord' option to omit coordinates from '#' text.)");
/* disgusting hack; the alternate selection characters work for any
getpos call, but they only matter for dowhatis (and doquickwhatis) */
doing_what_is = (goal == what_is_an_unknown_object);
@@ -184,32 +188,61 @@ int dx, dy;
return buf;
}
/* coordinate formatting for 'whatis_coord' option */
char *
coord_desc(x, y, outbuf, cmode)
int x, y;
char *outbuf, cmode;
{
static char screen_fmt[16]; /* [12] suffices: "[%02d,%02d]" */
int dx, dy;
outbuf[0] = '\0';
switch (cmode) {
default:
break;
case GPCOORDS_COMPASS:
/* "east", "3s", "2n,4w" */
dx = x - u.ux;
dy = y - u.uy;
Sprintf(outbuf, "(%s)", dxdy_to_dist_descr(dx, dy));
break;
case GPCOORDS_MAP: /* x,y */
/* upper left corner of map is <1,0>;
with default COLNO,ROWNO lower right corner is <79,20> */
Sprintf(outbuf, "<%d,%d>", x, y);
break;
case GPCOORDS_SCREEN: /* y+2,x */
/* for normal map sizes, force a fixed-width formatting so that
/m, /M, /o, and /O output lines up cleanly; map sizes bigger
than Nx999 or 999xM will still work, but not line up like normal
when displayed in a column setting */
if (!*screen_fmt)
Sprintf(screen_fmt, "[%%%sd,%%%sd]",
(ROWNO - 1 + 2 < 100) ? "02" : "03",
(COLNO - 1 < 100) ? "02" : "03");
/* map line 0 is screen row 2;
map column 0 isn't used, map column 1 is screen column 1 */
Sprintf(outbuf, screen_fmt, y + 2, x);
break;
}
return outbuf;
}
STATIC_OVL void
auto_describe(cx, cy)
int cx, cy;
{
coord cc;
int sym = 0, dx, dy;
int sym = 0;
char tmpbuf[BUFSZ];
const char *firstmatch = "unknown";
cc.x = cx;
cc.y = cy;
if (do_screen_description(cc, TRUE, sym, tmpbuf, &firstmatch)) {
tmpbuf[0] = '\0';
switch (iflags.getpos_coords) {
default:
break;
case GPCOORDS_COMPASS:
dx = cc.x - u.ux;
dy = cc.y - u.uy;
Sprintf(tmpbuf, " (%s)", dxdy_to_dist_descr(dx, dy));
break;
case GPCOORDS_MAP:
Sprintf(tmpbuf, " (%d,%d)", cc.x, cc.y);
break;
}
pline("%s%s", firstmatch, tmpbuf);
(void) coord_desc(cx, cy, tmpbuf, iflags.getpos_coords);
pline("%s%s%s", firstmatch, *tmpbuf ? " " : "", tmpbuf);
curs(WIN_MAP, cx, cy);
flush_screen(0);
}

View File

@@ -294,7 +294,6 @@ static struct Comp_Opt {
DISP_IN_GAME }, /*WC*/
{ "fruit", "the name of a fruit you enjoy eating", PL_FSIZ, SET_IN_GAME },
{ "gender", "your starting gender (male or female)", 8, DISP_IN_GAME },
{ "getpos_coord", "show coordinates when getting cursor position", 1, SET_IN_GAME },
{ "horsename", "the name of your (first) horse (e.g., horsename:Silver)",
PL_PSIZ, DISP_IN_GAME },
{ "map_mode", "map display mode under Windows", 20, DISP_IN_GAME }, /*WC*/
@@ -377,6 +376,9 @@ static struct Comp_Opt {
{ "roguesymset",
"load a set of rogue display symbols from the symbols file", 70,
SET_IN_GAME },
#ifdef WIN32
{ "subkeyvalue", "override keystroke value", 7, SET_IN_FILE },
#endif
{ "suppress_alert", "suppress alerts about version-specific features", 8,
SET_IN_GAME },
{ "tile_width", "width of tiles", 20, DISP_IN_GAME }, /*WC*/
@@ -395,9 +397,8 @@ static struct Comp_Opt {
{ "videoshades", "gray shades to map to black/gray/white", 32,
DISP_IN_GAME },
#endif
#ifdef WIN32
{ "subkeyvalue", "override keystroke value", 7, SET_IN_FILE },
#endif
{ "whatis_coord", "show coordinates when auto-describing cursor position",
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 },
@@ -2348,7 +2349,7 @@ boolean tinitial, tfrom_file;
return;
}
fullname = "getpos_coord";
fullname = "whatis_coord";
if (match_optname(opts, fullname, 6, TRUE)) {
if (duplicate)
complain_about_duplicate(opts, 1);
@@ -2356,11 +2357,13 @@ boolean tinitial, tfrom_file;
iflags.getpos_coords = GPCOORDS_NONE;
return;
} else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
if (tolower(*op) == GPCOORDS_NONE
|| tolower(*op) == GPCOORDS_COMPASS
|| tolower(*op) == GPCOORDS_MAP) {
iflags.getpos_coords = tolower(*op);
} else
static char gpcoords[] = { GPCOORDS_NONE, GPCOORDS_COMPASS,
GPCOORDS_MAP, GPCOORDS_SCREEN, '\0' };
char c = lowc(*op);
if (c && index(gpcoords, c))
iflags.getpos_coords = c;
else
badoption(opts);
}
return;
@@ -4042,24 +4045,55 @@ boolean setinitial, setfromfile;
free((genericptr_t) mode_pick);
}
destroy_nhwindow(tmpwin);
} else if (!strcmp("getpos_coord", optname)) {
} else if (!strcmp("whatis_coord", optname)) {
menu_item *window_pick = (menu_item *) 0;
int pick_cnt;
char gp = iflags.getpos_coords;
tmpwin = create_nhwindow(NHW_MENU);
start_menu(tmpwin);
any = zeroany;
any.a_char = GPCOORDS_COMPASS;
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_COMPASS,
0, ATR_NONE, "compass", MENU_UNSELECTED);
0, ATR_NONE, "compass ('east' or '3s' or '2n,4w')",
(gp == GPCOORDS_COMPASS) ? MENU_SELECTED : MENU_UNSELECTED);
any.a_char = GPCOORDS_MAP;
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_MAP,
0, ATR_NONE, "map", MENU_UNSELECTED);
0, ATR_NONE, "map <x,y>",
(gp == GPCOORDS_MAP) ? MENU_SELECTED : MENU_UNSELECTED);
any.a_char = GPCOORDS_SCREEN;
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_SCREEN,
0, ATR_NONE, "screen [row,column]",
(gp == GPCOORDS_SCREEN) ? MENU_SELECTED : MENU_UNSELECTED);
any.a_char = GPCOORDS_NONE;
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_NONE,
0, ATR_NONE, "none", MENU_UNSELECTED);
end_menu(tmpwin, "Select coordinate display when picking a position:");
if (select_menu(tmpwin, PICK_ONE, &window_pick) > 0) {
iflags.getpos_coords = window_pick->item.a_char;
0, ATR_NONE, "none (no coordinates displayed)",
(gp == GPCOORDS_NONE) ? MENU_SELECTED : MENU_UNSELECTED);
any.a_long = 0L;
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED);
Sprintf(buf, "map: upper-left: <%d,%d>, lower-right: <%d,%d>%s",
1, 0, COLNO - 1, ROWNO - 1,
flags.verbose ? "; column 0 unused, off left edge" : "");
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED);
if (strcmp(windowprocs.name, "tty"))
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE,
"screen: row is offset to accommodate tty interface's use of top line",
MENU_UNSELECTED);
Sprintf(buf, "screen: upper-left: [%02d,%02d], lower-right: [%d,%d]%s",
0 + 2, 1, ROWNO - 1 + 2, COLNO - 1,
#if COLNO == 80
flags.verbose ? "; column 80 is not used" :
#endif
"");
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED);
end_menu(tmpwin,
"Select coordinate display when auto-describing a map position:");
if ((pick_cnt = select_menu(tmpwin, PICK_ONE, &window_pick)) > 0) {
iflags.getpos_coords = window_pick[0].item.a_char;
/* PICK_ONE doesn't unselect preselected entry when
selecting another one */
if (pick_cnt > 1 && iflags.getpos_coords == gp)
iflags.getpos_coords = window_pick[1].item.a_char;
free((genericptr_t) window_pick);
}
destroy_nhwindow(tmpwin);
@@ -4810,10 +4844,11 @@ char *buf;
Sprintf(buf, "%s", rolestring(flags.initrole, roles, name.m));
} else if (!strcmp(optname, "runmode")) {
Sprintf(buf, "%s", runmodes[flags.runmode]);
} else if (!strcmp(optname, "getpos_coord")) {
} else if (!strcmp(optname, "whatis_coord")) {
Sprintf(buf, "%s",
(iflags.getpos_coords == GPCOORDS_MAP) ? "map"
: (iflags.getpos_coords == GPCOORDS_COMPASS) ? "compass"
: (iflags.getpos_coords == GPCOORDS_SCREEN) ? "screen"
: "none");
} else if (!strcmp(optname, "scores")) {
Sprintf(buf, "%d top/%d around%s", flags.end_top, flags.end_around,

View File

@@ -987,12 +987,7 @@ boolean do_mons; /* True => monsters, False => objects */
{
winid win;
int x, y, lo_x, lo_y, hi_x, hi_y, glyph, count = 0;
char buf[BUFSZ], outbuf[BUFSZ], coordbuf[12], fmt[12]; /* "%02d,%02d" */
/* row,column orientation rather than cartesian x,y */
Sprintf(fmt, "%%%sd,%%%sd",
(ROWNO <= 100) ? "02" : (ROWNO <= 1000) ? "03" : "",
(COLNO <= 100) ? "02" : (COLNO <= 1000) ? "03" : "");
char lookbuf[BUFSZ], outbuf[BUFSZ];
win = create_nhwindow(NHW_TEXT);
lo_y = nearby ? max(u.uy - BOLT_LIM, 0) : 0;
@@ -1001,7 +996,7 @@ boolean do_mons; /* True => monsters, False => objects */
hi_x = nearby ? min(u.ux + BOLT_LIM, COLNO - 1) : COLNO - 1;
for (y = lo_y; y <= hi_y; y++) {
for (x = lo_x; x <= hi_x; x++) {
buf[0] = '\0';
lookbuf[0] = '\0';
glyph = glyph_at(x, y);
if (do_mons) {
if (glyph_is_monster(glyph)) {
@@ -1010,49 +1005,56 @@ boolean do_mons; /* True => monsters, False => objects */
bhitpos.x = x; /* [is this actually necessary?] */
bhitpos.y = y;
if (x == u.ux && y == u.uy && canspotself()) {
(void) self_lookat(buf);
(void) self_lookat(lookbuf);
++count;
} else if ((mtmp = m_at(x, y)) != 0) {
look_at_monster(buf, (char *) 0, mtmp, x, y);
look_at_monster(lookbuf, (char *) 0, mtmp, x, y);
++count;
}
} else if (glyph_is_invisible(glyph)) {
/* remembered, unseen, creature */
Strcpy(buf, invisexplain);
Strcpy(lookbuf, invisexplain);
++count;
} else if (glyph_is_warning(glyph)) {
int warnindx = glyph_to_warning(glyph);
Strcpy(buf, def_warnsyms[warnindx].explanation);
Strcpy(lookbuf, def_warnsyms[warnindx].explanation);
++count;
}
} else { /* !do_mons */
if (glyph_is_object(glyph)) {
look_at_object(buf, x, y, glyph);
look_at_object(lookbuf, x, y, glyph);
++count;
}
}
if (*buf) {
if (count == 1) {
char which[12];
if (*lookbuf) {
char coordbuf[20], which[12], cmode;
cmode = (iflags.getpos_coords != GPCOORDS_NONE)
? iflags.getpos_coords : GPCOORDS_MAP;
if (count == 1) {
Strcpy(which, do_mons ? "monsters" : "objects");
if (nearby) {
Sprintf(coordbuf, fmt, u.uy, u.ux);
if (nearby)
Sprintf(outbuf, "%s currently shown near %s:",
upstart(which), coordbuf);
} else
upstart(which),
(cmode != GPCOORDS_COMPASS)
? coord_desc(u.ux, u.uy, coordbuf, cmode)
: !canspotself() ? "your position" : "you");
else
Sprintf(outbuf, "All %s currently shown on the map:",
which);
putstr(win, 0, outbuf);
putstr(win, 0, "");
}
Sprintf(coordbuf, fmt, y, x);
/* prefix: "C row,column " */
Sprintf(outbuf, "%s %s ", encglyph(glyph), coordbuf);
/* prefix: "coords C " where 'C' is mon or obj symbol */
Sprintf(outbuf, (cmode == GPCOORDS_SCREEN) ? "%s "
: (cmode == GPCOORDS_MAP) ? "%8s "
: "%12s ",
coord_desc(x, y, coordbuf, cmode));
Sprintf(eos(outbuf), "%s ", encglyph(glyph));
/* guard against potential overflow */
buf[sizeof buf - 1 - strlen(outbuf)] = '\0';
Strcat(outbuf, buf);
lookbuf[sizeof lookbuf - 1 - strlen(outbuf)] = '\0';
Strcat(outbuf, lookbuf);
putmixed(win, 0, outbuf);
}
}