clicklook (main trunk only)

This allows the use of the right mouse button to
look at things on the screen when the
'clicklook' option is set.

Concept came from a patch for 3.4.0
that I saw referenced on r.g.r.n
[see http://www.steelskies.com/nethack.php]
but the implementation is different.
This commit is contained in:
nethack.allison
2003-06-30 02:09:04 +00:00
parent 00addd7eea
commit cec8e1ee31
8 changed files with 93 additions and 54 deletions
+4 -1
View File
@@ -5,7 +5,7 @@
.ds vr "NetHack 3.4 .ds vr "NetHack 3.4
.ds f0 "\*(vr .ds f0 "\*(vr
.ds f1 .ds f1
.ds f2 "June 5, 2003 .ds f2 "June 29, 2003
.mt .mt
A Guide to the Mazes of Menace A Guide to the Mazes of Menace
(Guidebook for NetHack) (Guidebook for NetHack)
@@ -1656,6 +1656,9 @@ Check free disk space before writing files to disk (default on).
You may have to turn this off if you have more than 2 GB free space You may have to turn this off if you have more than 2 GB free space
on the partition used for your save and level files. on the partition used for your save and level files.
Only applies when MFLOPPY was defined during compilation. Only applies when MFLOPPY was defined during compilation.
.lp clicklook
Allows looking at things on the screen by navigating the mouse
over them and clicking the right mouse button (default off).
.lp cmdassist .lp cmdassist
Have the game provide some additional command assistance for Have the game provide some additional command assistance for
new players if it detects some anticipated mistakes (default on). new players if it detects some anticipated mistakes (default on).
+6 -2
View File
@@ -27,7 +27,7 @@
\begin{document} \begin{document}
% %
% input file: guidebook.mn % input file: guidebook.mn
% $Revision: 1.65 $ $Date: 2003/05/12 03:05:00 $ % $Revision: 1.66 $ $Date: 2003/06/06 03:49:35 $
% %
%.ds h0 " %.ds h0 "
%.ds h1 %.ds h2 \% %.ds h1 %.ds h2 \%
@@ -40,7 +40,7 @@
%.au %.au
\author{Eric S. Raymond\\ \author{Eric S. Raymond\\
(Extensively edited and expanded for 3.4)} (Extensively edited and expanded for 3.4)}
\date{June 5, 2003} \date{June 29, 2003}
\maketitle \maketitle
@@ -2078,6 +2078,10 @@ You may have to turn this off if you have more than 2 GB free space
on the partition used for your save and level files. on the partition used for your save and level files.
Only applies when MFLOPPY was defined during compilation. Only applies when MFLOPPY was defined during compilation.
%.lp %.lp
\item[\ib{clicklook}]
Allows looking at things on the screen by navigating the mouse
over them and clicking the right mouse button (default off).
%.lp
\item[\ib{cmdassist}] \item[\ib{cmdassist}]
Have the game provide some additional command assistance for new Have the game provide some additional command assistance for new
players if it detects some anticipated mistakes (default on). players if it detects some anticipated mistakes (default on).
+2
View File
@@ -41,6 +41,8 @@ General New Features
-------------------- --------------------
burying a punishment ball no longer ends your punishment burying a punishment ball no longer ends your punishment
#tip command--pay a modest gratuity #tip command--pay a modest gratuity
add clicklook option to allow looking at things on the display by clicking
right mouse button when floating mouse pointer over them
Platform- and/or Interface-Specific New Features Platform- and/or Interface-Specific New Features
+1
View File
@@ -1405,6 +1405,7 @@ E int NDECL(dowhatdoes);
E char *FDECL(dowhatdoes_core,(CHAR_P, char *)); E char *FDECL(dowhatdoes_core,(CHAR_P, char *));
E int NDECL(dohelp); E int NDECL(dohelp);
E int NDECL(dohistory); E int NDECL(dohistory);
E int FDECL(do_look, (int, coord *));
/* ### pcmain.c ### */ /* ### pcmain.c ### */
+1
View File
@@ -262,6 +262,7 @@ struct instance_flags {
boolean wc_mouse_support; /* allow mouse support */ boolean wc_mouse_support; /* allow mouse support */
boolean cmdassist; /* provide detailed assistance for some commands */ boolean cmdassist; /* provide detailed assistance for some commands */
boolean clicklook; /* allow right-clicking for look */
boolean obsolete; /* obsolete options can point at this, it isn't used */ boolean obsolete; /* obsolete options can point at this, it isn't used */
#ifdef WIN32CON #ifdef WIN32CON
#define MAX_ALTKEYHANDLER 25 #define MAX_ALTKEYHANDLER 25
+16 -1
View File
@@ -14,7 +14,8 @@
#define NR_OF_EOFS 20 #define NR_OF_EOFS 20
#endif #endif
#define CMD_TRAVEL (char)0x90 #define CMD_TRAVEL (char)0x90
#define CMD_CLICKLOOK (char)0x8F
#ifdef DEBUG #ifdef DEBUG
/* /*
@@ -151,6 +152,7 @@ static void NDECL(end_of_input);
#endif /* OVLB */ #endif /* OVLB */
static const char* readchar_queue=""; static const char* readchar_queue="";
static coord clicklook_cc;
STATIC_DCL char *NDECL(parse); STATIC_DCL char *NDECL(parse);
STATIC_DCL boolean FDECL(help_dir, (CHAR_P,const char *)); STATIC_DCL boolean FDECL(help_dir, (CHAR_P,const char *));
@@ -1853,6 +1855,12 @@ register char *cmd;
flags.move = FALSE; flags.move = FALSE;
multi = 0; multi = 0;
return; return;
case CMD_CLICKLOOK:
if (iflags.clicklook) {
flags.move = FALSE;
do_look(2, &clicklook_cc);
}
return;
case CMD_TRAVEL: case CMD_TRAVEL:
if (flags.travelcmd) { if (flags.travelcmd) {
flags.travel = 1; flags.travel = 1;
@@ -2167,6 +2175,13 @@ click_to_cmd(x, y, mod)
static char cmd[4]; static char cmd[4];
cmd[1]=0; cmd[1]=0;
if (iflags.clicklook && mod == CLICK_2) {
clicklook_cc.x = x;
clicklook_cc.y = y;
cmd[0] = CMD_CLICKLOOK;
return cmd;
}
x -= u.ux; x -= u.ux;
y -= u.uy; y -= u.uy;
+1
View File
@@ -68,6 +68,7 @@ static struct Bool_Opt
#else #else
{"checkspace", (boolean *)0, FALSE, SET_IN_FILE}, {"checkspace", (boolean *)0, FALSE, SET_IN_FILE},
#endif #endif
{"clicklook", &iflags.clicklook, FALSE, SET_IN_GAME},
{"cmdassist", &iflags.cmdassist, TRUE, SET_IN_GAME}, {"cmdassist", &iflags.cmdassist, TRUE, SET_IN_GAME},
# if defined(MICRO) || defined(WIN32) # if defined(MICRO) || defined(WIN32)
{"color", &iflags.wc_color,TRUE, SET_IN_GAME}, /*WC*/ {"color", &iflags.wc_color,TRUE, SET_IN_GAME}, /*WC*/
+62 -50
View File
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)pager.c 3.4 2002/12/18 */ /* SCCS Id: @(#)pager.c 3.4 2003/06/29 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -13,7 +13,6 @@ STATIC_DCL int FDECL(append_str, (char *, const char *));
STATIC_DCL struct permonst * FDECL(lookat, (int, int, char *, char *)); STATIC_DCL struct permonst * FDECL(lookat, (int, int, char *, char *));
STATIC_DCL void FDECL(checkfile, STATIC_DCL void FDECL(checkfile,
(char *,struct permonst *,BOOLEAN_P,BOOLEAN_P)); (char *,struct permonst *,BOOLEAN_P,BOOLEAN_P));
STATIC_DCL int FDECL(do_look, (BOOLEAN_P));
STATIC_DCL boolean FDECL(help_menu, (int *)); STATIC_DCL boolean FDECL(help_menu, (int *));
#ifdef PORT_HELP #ifdef PORT_HELP
extern void NDECL(port_help); extern void NDECL(port_help);
@@ -454,10 +453,13 @@ bad_data_file: impossible("'data' file in wrong format");
/* also used by getpos hack in do_name.c */ /* also used by getpos hack in do_name.c */
const char what_is_an_unknown_object[] = "an unknown object"; const char what_is_an_unknown_object[] = "an unknown object";
STATIC_OVL int int
do_look(quick) do_look(mode, click_cc)
boolean quick; /* use cursor && don't search for "more info" */ int mode;
coord *click_cc;
{ {
boolean quick = (mode == 1); /* use cursor && don't search for "more info" */
boolean clicklook = (mode == 2); /* right mouse-click method */
char out_str[BUFSZ], look_buf[BUFSZ]; char out_str[BUFSZ], look_buf[BUFSZ];
const char *x_str, *firstmatch = 0; const char *x_str, *firstmatch = 0;
struct permonst *pm = 0; struct permonst *pm = 0;
@@ -472,28 +474,34 @@ do_look(quick)
int skipped_venom; /* non-zero if we ignored "splash of venom" */ int skipped_venom; /* non-zero if we ignored "splash of venom" */
static const char *mon_interior = "the interior of a monster"; static const char *mon_interior = "the interior of a monster";
if (quick) { if (!clicklook) {
from_screen = TRUE; /* yes, we want to use the cursor */ if (quick) {
} else { from_screen = TRUE; /* yes, we want to use the cursor */
i = ynq("Specify unknown object by cursor?"); } else {
if (i == 'q') return 0; i = ynq("Specify unknown object by cursor?");
from_screen = (i == 'y'); if (i == 'q') return 0;
} from_screen = (i == 'y');
if (from_screen) {
cc.x = u.ux;
cc.y = u.uy;
sym = 0; /* gcc -Wall lint */
} else {
getlin("Specify what? (type the word)", out_str);
if (out_str[0] == '\0' || out_str[0] == '\033')
return 0;
if (out_str[1]) { /* user typed in a complete string */
checkfile(out_str, pm, TRUE, TRUE);
return 0;
} }
sym = out_str[0];
if (from_screen) {
cc.x = u.ux;
cc.y = u.uy;
sym = 0; /* gcc -Wall lint */
} else {
getlin("Specify what? (type the word)", out_str);
if (out_str[0] == '\0' || out_str[0] == '\033')
return 0;
if (out_str[1]) { /* user typed in a complete string */
checkfile(out_str, pm, TRUE, TRUE);
return 0;
}
sym = out_str[0];
}
} else { /* clicklook */
cc.x = click_cc->x;
cc.y = click_cc->y;
sym = 0;
from_screen = FALSE;
} }
/* Save the verbose flag, we change it later. */ /* Save the verbose flag, we change it later. */
@@ -510,21 +518,23 @@ do_look(quick)
found = 0; found = 0;
out_str[0] = '\0'; out_str[0] = '\0';
if (from_screen) { if (from_screen || clicklook) {
int glyph; /* glyph at selected position */ int glyph; /* glyph at selected position */
if (flags.verbose) if (from_screen) {
pline("Please move the cursor to %s.", if (flags.verbose)
what_is_an_unknown_object); pline("Please move the cursor to %s.",
else what_is_an_unknown_object);
pline("Pick an object."); else
pline("Pick an object.");
ans = getpos(&cc, quick, what_is_an_unknown_object); ans = getpos(&cc, quick, what_is_an_unknown_object);
if (ans < 0 || cc.x < 0) { if (ans < 0 || cc.x < 0) {
flags.verbose = save_verbose; flags.verbose = save_verbose;
return 0; /* done */ return 0; /* done */
}
flags.verbose = FALSE; /* only print long question once */
} }
flags.verbose = FALSE; /* only print long question once */
/* Convert the glyph at the selected position to a symbol. */ /* Convert the glyph at the selected position to a symbol. */
glyph = glyph_at(cc.x,cc.y); glyph = glyph_at(cc.x,cc.y);
@@ -560,7 +570,7 @@ do_look(quick)
/* Check for monsters */ /* Check for monsters */
for (i = 0; i < MAXMCLASSES; i++) { for (i = 0; i < MAXMCLASSES; i++) {
if (sym == (from_screen ? monsyms[i] : def_monsyms[i]) && if (sym == ((from_screen || clicklook) ? monsyms[i] : def_monsyms[i]) &&
monexplain[i]) { monexplain[i]) {
need_to_look = TRUE; need_to_look = TRUE;
if (!found) { if (!found) {
@@ -575,7 +585,7 @@ do_look(quick)
/* handle '@' as a special case if it refers to you and you're /* handle '@' as a special case if it refers to you and you're
playing a character which isn't normally displayed by that playing a character which isn't normally displayed by that
symbol; firstmatch is assumed to already be set for '@' */ symbol; firstmatch is assumed to already be set for '@' */
if ((from_screen ? if (((from_screen || clicklook) ?
(sym == monsyms[S_HUMAN] && cc.x == u.ux && cc.y == u.uy) : (sym == monsyms[S_HUMAN] && cc.x == u.ux && cc.y == u.uy) :
(sym == def_monsyms[S_HUMAN] && !flags.showrace)) && (sym == def_monsyms[S_HUMAN] && !flags.showrace)) &&
!(Race_if(PM_HUMAN) || Race_if(PM_ELF)) && !Upolyd) !(Race_if(PM_HUMAN) || Race_if(PM_ELF)) && !Upolyd)
@@ -586,7 +596,7 @@ do_look(quick)
* and looking at something other than our own symbol, then just say * and looking at something other than our own symbol, then just say
* "the interior of a monster". * "the interior of a monster".
*/ */
if (u.uswallow && from_screen && is_swallow_sym(sym)) { if (u.uswallow && (from_screen || clicklook) && is_swallow_sym(sym)) {
if (!found) { if (!found) {
Sprintf(out_str, "%c %s", sym, mon_interior); Sprintf(out_str, "%c %s", sym, mon_interior);
firstmatch = mon_interior; firstmatch = mon_interior;
@@ -598,9 +608,9 @@ do_look(quick)
/* Now check for objects */ /* Now check for objects */
for (i = 1; i < MAXOCLASSES; i++) { for (i = 1; i < MAXOCLASSES; i++) {
if (sym == (from_screen ? oc_syms[i] : def_oc_syms[i])) { if (sym == ((from_screen || clicklook) ? oc_syms[i] : def_oc_syms[i])) {
need_to_look = TRUE; need_to_look = TRUE;
if (from_screen && i == VENOM_CLASS) { if ((from_screen || clicklook) && i == VENOM_CLASS) {
skipped_venom++; skipped_venom++;
continue; continue;
} }
@@ -630,7 +640,8 @@ do_look(quick)
/* Now check for graphics symbols */ /* Now check for graphics symbols */
for (hit_trap = FALSE, i = 0; i < MAXPCHARS; i++) { for (hit_trap = FALSE, i = 0; i < MAXPCHARS; i++) {
x_str = defsyms[i].explanation; x_str = defsyms[i].explanation;
if (sym == (from_screen ? showsyms[i] : defsyms[i].sym) && *x_str) { if (sym == ((from_screen || clicklook) ?
showsyms[i] : defsyms[i].sym) && *x_str) {
/* avoid "an air", "a water", or "a floor of a room" */ /* avoid "an air", "a water", or "a floor of a room" */
int article = (i == S_room) ? 2 : /* 2=>"the" */ int article = (i == S_room) ? 2 : /* 2=>"the" */
!(strcmp(x_str, "air") == 0 || /* 1=>"an" */ !(strcmp(x_str, "air") == 0 || /* 1=>"an" */
@@ -663,7 +674,8 @@ do_look(quick)
/* Now check for warning symbols */ /* Now check for warning symbols */
for (i = 1; i < WARNCOUNT; i++) { for (i = 1; i < WARNCOUNT; i++) {
x_str = def_warnsyms[i].explanation; x_str = def_warnsyms[i].explanation;
if (sym == (from_screen ? warnsyms[i] : def_warnsyms[i].sym)) { if (sym == ((from_screen || clicklook) ?
warnsyms[i] : def_warnsyms[i].sym)) {
if (!found) { if (!found) {
Sprintf(out_str, "%c %s", Sprintf(out_str, "%c %s",
sym, def_warnsyms[i].explanation); sym, def_warnsyms[i].explanation);
@@ -674,7 +686,7 @@ do_look(quick)
} }
/* Kludge: warning trumps boulders on the display. /* Kludge: warning trumps boulders on the display.
Reveal the boulder too or player can get confused */ Reveal the boulder too or player can get confused */
if (from_screen && sobj_at(BOULDER, cc.x, cc.y)) if ((from_screen || clicklook) && sobj_at(BOULDER, cc.x, cc.y))
Strcat(out_str, " co-located with a boulder"); Strcat(out_str, " co-located with a boulder");
break; /* out of for loop*/ break; /* out of for loop*/
} }
@@ -707,7 +719,7 @@ do_look(quick)
* If we are looking at the screen, follow multiple possibilities or * If we are looking at the screen, follow multiple possibilities or
* an ambiguous explanation by something more detailed. * an ambiguous explanation by something more detailed.
*/ */
if (from_screen) { if (from_screen || clicklook) {
if (found > 1 || need_to_look) { if (found > 1 || need_to_look) {
char monbuf[BUFSZ]; char monbuf[BUFSZ];
char temp_buf[BUFSZ]; char temp_buf[BUFSZ];
@@ -731,7 +743,7 @@ do_look(quick)
pline("%s", out_str); pline("%s", out_str);
/* check the data file for information about this thing */ /* check the data file for information about this thing */
if (found == 1 && ans != LOOK_QUICK && ans != LOOK_ONCE && if (found == 1 && ans != LOOK_QUICK && ans != LOOK_ONCE &&
(ans == LOOK_VERBOSE || (flags.help && !quick))) { (ans == LOOK_VERBOSE || (flags.help && !quick)) && !clicklook) {
char temp_buf[BUFSZ]; char temp_buf[BUFSZ];
Strcpy(temp_buf, firstmatch); Strcpy(temp_buf, firstmatch);
checkfile(temp_buf, pm, FALSE, (boolean)(ans == LOOK_VERBOSE)); checkfile(temp_buf, pm, FALSE, (boolean)(ans == LOOK_VERBOSE));
@@ -740,7 +752,7 @@ do_look(quick)
pline("I've never heard of such things."); pline("I've never heard of such things.");
} }
} while (from_screen && !quick && ans != LOOK_ONCE); } while (from_screen && !quick && ans != LOOK_ONCE && !clicklook);
flags.verbose = save_verbose; flags.verbose = save_verbose;
return 0; return 0;
@@ -750,13 +762,13 @@ do_look(quick)
int int
dowhatis() dowhatis()
{ {
return do_look(FALSE); return do_look(0,(coord *)0);
} }
int int
doquickwhatis() doquickwhatis()
{ {
return do_look(TRUE); return do_look(1,(coord *)0);
} }
int int