Add getpos_coord option

Allows showing the coordinate when picking a position on the
map with '/' and autodescribe is on.

This is another blind player request
This commit is contained in:
Pasi Kallinen
2016-01-11 21:07:33 +02:00
parent 9cfc0ac5d7
commit 0ee5d8ce47
5 changed files with 107 additions and 1 deletions

View File

@@ -2125,6 +2125,11 @@ The default is to randomly pick an appropriate gender.
If you prefix a `!' or ``no'' to the value, you can
exclude that gender from being picked randomly.
Cannot be set with the `O' command. Persistent.
.lp getpos_coord
When using the `/' command to look around on the map with
``autodescribe'' on, display coordinates after the description.
The value specified should be the first letter of one of the following:
absolute, cartesian, or none. Default is none.
.lp "help "
If more information is available for an object looked at
with the `/' command, ask if you want to see it (default on). Turning help

View File

@@ -2559,6 +2559,12 @@ If you prefix `{\tt !}' or ``{\tt no}'' to the value, you can
exclude that gender from being picked randomly.
Cannot be set with the `{\tt O}' command. Persistent.
%.lp
\item[\ib{getpos\verb+_+coord}]
When using the `{\tt /}' command to look around on the map with
``{\tt autodescribe}'' on, display coordinates after the description.
The value specified should be the first letter of one of the following:
absolute, cartesian, or none. Default is none.
%.lp
\item[\ib{help}]
If more information is available for an object looked at
with the `{\tt /}' command, ask if you want to see it (default on).

View File

@@ -167,6 +167,11 @@ struct sysflag {
*
*/
/* values for iflags.getpos_coords */
#define GPCOORDS_NONE 'n'
#define GPCOORDS_ABSOLUTE 'a'
#define GPCOORDS_CARTESIAN 'c'
struct instance_flags {
/* stuff that really isn't option or platform related. They are
* set and cleared during the game to control the internal
@@ -185,6 +190,7 @@ struct instance_flags {
boolean mon_polycontrol; /* debug: control monster polymorphs */
/* stuff that is related to options and/or user or platform preferences */
unsigned msg_history; /* hint: # of top lines to save */
int getpos_coords; /* show coordinates when getting cursor position */
int menu_headings; /* ATR for menu headings */
int *opt_booldup; /* for duplication of boolean opts in config file */
int *opt_compdup; /* for duplication of compound opts in config file */

View File

@@ -149,6 +149,34 @@ boolean do_mons;
} /* pass */
}
char *
dxdy_to_dist_descr(dx,dy)
int dx,dy;
{
static char buf[QBUFSZ];
int d;
if (!dx && !dy)
Sprintf(buf, "here");
else if ((d = xytod(dx,dy)) != -1)
Sprintf(buf, "%s", directionname(d));
else {
char tmp[QBUFSZ];
buf[0] = '\0';
if (dy) {
Sprintf(tmp, "%i%c", abs(dy), (dy > 0) ? 's' : 'n');
Strcat(buf, tmp);
}
if (dy && dx)
Strcat(buf, ",");
if (dx) {
Sprintf(tmp, "%i%c", abs(dx), (dx > 0) ? 'e' : 'w');
Strcat(buf, tmp);
}
}
return buf;
}
int
getpos(ccp, force, goal)
coord *ccp;
@@ -192,12 +220,27 @@ const char *goal;
coord cc;
int sym = 0;
char tmpbuf[BUFSZ];
char outbuf[BUFSZ];
const char *firstmatch = NULL;
int dx,dy;
cc.x = cx;
cc.y = cy;
if (do_screen_description(cc, TRUE, sym, tmpbuf, &firstmatch)) {
pline1(firstmatch);
outbuf[0] = '\0';
switch (iflags.getpos_coords) {
default:
break;
case GPCOORDS_CARTESIAN:
dx = cc.x - u.ux;
dy = cc.y - u.uy;
Sprintf(outbuf, " (%s)", dxdy_to_dist_descr(dx,dy));
break;
case GPCOORDS_ABSOLUTE:
Sprintf(outbuf, " (%d,%d)", cc.x,cc.y);
break;
}
pline("%s%s", firstmatch, outbuf);
curs(WIN_MAP, cx, cy);
flush_screen(0);
}

View File

@@ -294,6 +294,7 @@ 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*/
@@ -685,6 +686,7 @@ initoptions_init()
iflags.prevmsg_window = 's';
#endif
iflags.menu_headings = ATR_INVERSE;
iflags.getpos_coords = GPCOORDS_NONE;
/* hero's role, race, &c haven't been chosen yet */
flags.initrole = flags.initrace = flags.initgend = flags.initalign =
@@ -2332,6 +2334,24 @@ boolean tinitial, tfrom_file;
return;
}
fullname = "getpos_coord";
if (match_optname(opts, fullname, 6, TRUE)) {
if (duplicate)
complain_about_duplicate(opts, 1);
if (negated) {
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_CARTESIAN
|| tolower(*op) == GPCOORDS_ABSOLUTE) {
iflags.getpos_coords = tolower(*op);
} else
badoption(opts);
}
return;
}
fullname = "warnings";
if (match_optname(opts, fullname, 5, TRUE)) {
if (duplicate)
@@ -4008,6 +4028,27 @@ boolean setinitial, setfromfile;
free((genericptr_t) mode_pick);
}
destroy_nhwindow(tmpwin);
} else if (!strcmp("getpos_coord", optname)) {
menu_item *window_pick = (menu_item *) 0;
tmpwin = create_nhwindow(NHW_MENU);
start_menu(tmpwin);
any = zeroany;
any.a_char = GPCOORDS_ABSOLUTE;
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_ABSOLUTE,
0, ATR_NONE, "absolute", MENU_UNSELECTED);
any.a_char = GPCOORDS_CARTESIAN;
add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_CARTESIAN,
0, ATR_NONE, "cartesian", 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;
free((genericptr_t) window_pick);
}
destroy_nhwindow(tmpwin);
} else if (!strcmp("msg_window", optname)) {
#ifdef TTY_GRAPHICS
/* by Christian W. Cooper */
@@ -4755,6 +4796,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")) {
Sprintf(buf, "%s",
(iflags.getpos_coords == GPCOORDS_ABSOLUTE) ? "absolute"
: (iflags.getpos_coords == GPCOORDS_CARTESIAN) ? "cartesian"
: "none");
} else if (!strcmp(optname, "scores")) {
Sprintf(buf, "%d top/%d around%s", flags.end_top, flags.end_around,
flags.end_own ? "/own" : "");