]> granicus.if.org Git - nethack/commitdiff
Two new options
authornethack.allison <nethack.allison>
Thu, 4 Apr 2002 03:45:03 +0000 (03:45 +0000)
committernethack.allison <nethack.allison>
Thu, 4 Apr 2002 03:45:03 +0000 (03:45 +0000)
Add "travel" boolean option to enable/disable travel command.
Add "mouse_support" wincap option to enable/disable mouse.

- When running the win32 tty version full-screen, some people
complained about the square mouse cursor.

Newsgroups: rec.games.roguelike.nethack
Subject: Re: Getting rid of the cursor?
<email deleted> <email deleted>
Followup-To:

On Thu, 04 Apr 2002 00:20:06 <email deleted> wrote:
> Ok, let me be more specific: when playing the windows non-GUI version, is
> there a way to get rid of the large rectangular white cursor?
>
> <email deleted> wrote in message
> <email deleted>
>> Can you get rid of the cursor in the windows version?  I really hate that
>> thing.
>>

<email deleted>
>Newsgroups: rec.games.roguelike.nethack
>Subject: Disabling Mouse Input
>
>I purchased an older P120 laptop to be able to play Nethack at the hotel.
>I find that I rest my thumbs on the mouse touch pad all too often and my
>@ moves unexpectedly at times. I took a peruse through defaults.nh, but
>came up empty.
>
>Anyone know if mouse input can be disabled?
>
>MRSisson

12 files changed:
doc/Guidebook.mn
doc/Guidebook.tex
doc/fixes34.1
doc/window.doc
include/flag.h
include/ntconf.h
include/winprocs.h
src/cmd.c
src/options.c
sys/share/pcmain.c
sys/winnt/nttty.c
win/tty/wintty.c

index 19f97c25888e06363333b30dab1bafb66eb82c56..05ec127bee1c0c082f29531c17462566af1f4d4c 100644 (file)
@@ -5,7 +5,7 @@
 .ds vr "NetHack 3.4
 .ds f0 "\*(vr
 .ds f1
-.ds f2 "March 20, 2002
+.ds f2 "April 3, 2002
 .mt
 A Guide to the Mazes of Menace
 (Guidebook for NetHack)
@@ -2036,6 +2036,8 @@ pit, spiked pit, hole, trap door, teleportation trap, level teleporter,
 magic portal, web, statue trap, magic trap, anti-magic field, polymorph trap.
 
 Cannot be set with the `O' command.
+.lp travel
+Allow the travel command (default on).
 .lp verbose
 Provide more commentary during the game (default on).
 .lp videocolors
@@ -2113,6 +2115,8 @@ with tiles, generally displays a heart symbol near pets.
 NetHack should use a large font.
 .lp map_mode   
 NetHack should display the map in the manner specified.
+.lp mouse_support
+Allow use of the mouse for input and travel.
 .lp player_selection
 NetHack should pop up dialog boxes, or use prompts for character selection.
 .lp popup_dialog       
index a4cae1665a5e6c3e097b9bf38b98d7ed37c54725..7a4be6bbf5e4a89cb4007cbfb35ef0004224fe45 100644 (file)
@@ -27,7 +27,7 @@
 \begin{document}
 %
 % input file: guidebook.mn
-% $Revision: 1.38 $ $Date: 2002/03/31 06:27:18 $
+% $Revision: 1.39 $ $Date: 2002/03/31 07:19:43 $
 %
 %.ds h0 "
 %.ds h1 %.ds h2 \%
@@ -40,7 +40,7 @@
 %.au
 \author{Eric S. Raymond\\
 (Extensively edited and expanded for 3.4)}
-\date{March 20, 2002}
+\date{April 3, 2002}
 
 \maketitle
 
@@ -2496,6 +2496,9 @@ magic portal, web, statue trap, magic trap, anti-magic field, polymorph trap.
 
 Cannot be set with the `{\tt O}' command.
 %.lp
+\item[\ib{travel}]
+Allow the travel command (default on).
+%.lp
 \item[\ib{verbose}]
 Provide more commentary during the game (default on).
 %.lp
@@ -2601,6 +2604,9 @@ NetHack should use a large font.
 \item[\ib{map\_mode}]
 NetHack should display the map in the manner specified.
 %.lp
+\item[\ib{mouse\_support}]
+Allow use of the mouse for input and travel.
+%.lp
 \item[\ib{player\_selection}]
 NetHack should pop up dialog boxes or use prompts for character selection.
 %.lp
index 1790fdd73b9509c8c1f01c44bf3424f5d0283f95..cc0090ee03c1b2502e1cc8a22c0af26b14d59097 100644 (file)
@@ -69,3 +69,5 @@ General New Features
 --------------------
 lootabc option
 showrace option
+travel option
+mouse_support wincap option
index f2aa2202ec04228ef6a166b16407873f92bf45b4..7e17b2814a5de643694e6102cce0bc74e4b5fcbe 100644 (file)
@@ -499,6 +499,7 @@ to support:
   |                    |                    | wc_backgrnd_status |char *  |
   |                    |                    | wc_foregrnd_text   |char *  |
   |                    |                    | wc_backgrnd_text   |char *  |
+  |  mouse             | WC_MOUSE_SUPPORT   | wc_mouse_support   |boolean |
   +--------------------+--------------------+--------------------+--------+
 
 align_message  -- where to place message window (top, bottom, left, right)
@@ -541,6 +542,7 @@ windowcolors
                -- port should use these colors for window foreground/background
                   colors.  Syntax:
                     menu fore/back message fore/back status fore/back text fore/back
+mouse_support  -- port should enable mouse support if possible
 
 Whenever one of these settings is adjusted, the port is notified of a change
 to the setting by calling the port's preference_update() routine. The port
@@ -578,10 +580,11 @@ To add a new wincap option, please follow all these steps:
        2. Add the description to the paragraph below the chart.
        3. Add the WC_ to the bit list in include/winprocs.h (if there is room).
        4. Add the wc_ field(s) to the iflags structure in flag.h.
-       5. Add an appropriate parser to parseoptions() in options.c.
-       6. Add code to display current value to get_compopt_value() in options.c.
-       7. Document the option in Guidebook.mn and Guidebook.tex.
-       8. Add the bit name to the OR'd values in your window port's winprocs struct
+       5. Add the name and value to wc_options[] in options.c
+       6. Add an appropriate parser to parseoptions() in options.c.
+       7. Add code to display current value to get_compopt_value() in options.c.
+       8. Document the option in Guidebook.mn and Guidebook.tex.
+       9. Add the bit name to the OR'd values in your window port's winprocs struct
           wincap mask if your port supports the option.
 
 V.  New or respecified common, high level routines
index c1445f03ebf8f17f6b4540c6ac89072e7fe51820..4c2ec7003eaf4f0aeadddcb4feb45fb2e544f568 100644 (file)
@@ -252,10 +252,12 @@ struct instance_flags {
        boolean wc_large_font;          /* draw in larger fonts (say, 12pt instead
                                                of 9pt) */
        boolean wc_eight_bit_input;     /* allow eight bit input               */
+       boolean wc_mouse_support;       /* allow mouse support */
 
        /* Items which belong in flags, but are here to allow save compatibility */
        boolean  lootabc;       /* use "a/b/c" rather than "o/i/b" when looting */
        boolean  showrace;      /* show hero glyph by race rather than by role */
+       boolean  travelcmd;     /* allow travel command */
 };
 
 /*
index 95cb0c920cea46adcedc8d6b540bca47de4e06e1..db358b8e13bb716ba0db0c734edbbe30ba94b4e2 100644 (file)
@@ -121,6 +121,10 @@ extern char hackdir[];
 #define getuid() 1
 #define getlogin() ((char *)0)
 extern void NDECL(win32_abort);
+#ifdef WIN32CON
+extern void FDECL(nttty_preference_update, (const char *));
+extern void NDECL(toggle_mouse_support);
+#endif
 
 #include <fcntl.h>
 #ifndef __BORLANDC__
index 87a21ca0537bba2b308065b84e99c015e8e2604d..76ce49f27802f3b3dfd820f8d59ee3c1c8eecb97 100644 (file)
@@ -165,7 +165,8 @@ extern NEARDATA struct window_procs windowprocs;
 #define WC_MAP_MODE     0x10000000L    /* 29 map_mode option                        */
 #define WC_WINDOWCOLORS  0x20000000L   /* 30 background color for message window    */
 #define WC_PLAYER_SELECTION  0x40000000L /* 31 background color for message window    */
-                                       /* 1 free bit */
+#define WC_MOUSE_SUPPORT 0x80000000L   /* 32 mouse support                          */
+                                       /* no free bits */
 
 #define ALIGN_LEFT     1
 #define ALIGN_RIGHT    2
index e1915a8e328fe6765c4a196df72672a3e66830ca..3070c8d6305889ec0e8d8d7d2b9447befd713c9d 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1738,11 +1738,14 @@ register char *cmd;
                    multi = 0;
                    return;
         case CMD_TRAVEL:
-                   flags.travel = 1;
-                   flags.run = 8;
-                   flags.nopick = 1;
-                   do_rush = TRUE;
-                   break;
+                   if (iflags.travelcmd) {
+                           flags.travel = 1;
+                           flags.run = 8;
+                           flags.nopick = 1;
+                           do_rush = TRUE;
+                           break;
+                   }
+                   /*FALLTHRU*/
         default:   if (movecmd(*cmd)) {        /* ordinary movement */
                        do_walk = TRUE;
                    } else if (movecmd(iflags.num_pad ?
@@ -1936,62 +1939,81 @@ click_to_cmd(x, y, mod)
     x -= u.ux;
     y -= u.uy;
 
-    if ( abs(x) <= 1 && abs(y) <= 1 ) {
-       x = sgn(x), y = sgn(y);
+    if (iflags.travelcmd) {
+        if (abs(x) <= 1 && abs(y) <= 1 ) {
+            x = sgn(x), y = sgn(y);
+        } else {
+            u.tx = u.ux+x;
+            u.ty = u.uy+y;
+            cmd[0] = CMD_TRAVEL;
+            return cmd;
+        }
+
+        if(x == 0 && y == 0) {
+            /* here */
+            if(IS_FOUNTAIN(levl[u.ux][u.uy].typ) || IS_SINK(levl[u.ux][u.uy].typ)) {
+                cmd[0]=mod == CLICK_1 ? 'q' : M('d');
+                return cmd;
+            } else if(IS_THRONE(levl[u.ux][u.uy].typ)) {
+                cmd[0]=M('s');
+                return cmd;
+            } else if((u.ux == xupstair && u.uy == yupstair)
+                      || (u.ux == sstairs.sx && u.uy == sstairs.sy && sstairs.up)
+                      || (u.ux == xupladder && u.uy == yupladder)) {
+                return "<";
+            } else if((u.ux == xdnstair && u.uy == ydnstair)
+                      || (u.ux == sstairs.sx && u.uy == sstairs.sy && !sstairs.up)
+                      || (u.ux == xdnladder && u.uy == ydnladder)) {
+                return ">";
+            } else if(OBJ_AT(u.ux, u.uy)) {
+                cmd[0] = Is_container(level.objects[u.ux][u.uy]) ? M('l') : ',';
+                return cmd;
+            } else {
+                return "."; /* just rest */
+            }
+        }
+
+        /* directional commands */
+
+        dir = xytod(x, y);
+
+        if (!m_at(u.ux+x, u.uy+y) && !test_move(u.ux, u.uy, x, y, 1)) {
+            cmd[1] = (iflags.num_pad ? ndir[dir] : sdir[dir]);
+            cmd[2] = 0;
+            if (IS_DOOR(levl[u.ux+x][u.uy+y].typ)) {
+                /* slight assistance to the player: choose kick/open for them */
+                if (levl[u.ux+x][u.uy+y].doormask & D_LOCKED) {
+                    cmd[0] = C('d');
+                    return cmd;
+                }
+                if (levl[u.ux+x][u.uy+y].doormask & D_CLOSED) {
+                    cmd[0] = 'o';
+                    return cmd;
+                }
+            }
+            if (levl[u.ux+x][u.uy+y].typ <= SCORR) {
+                cmd[0] = 's';
+                cmd[1] = 0;
+                return cmd;
+            }
+        }
     } else {
-       u.tx = u.ux+x;
-       u.ty = u.uy+y;
-       cmd[0] = CMD_TRAVEL;
-       return cmd;
-    }
-
-    if(x == 0 && y == 0) {
-       /* here */
-       if(IS_FOUNTAIN(levl[u.ux][u.uy].typ) || IS_SINK(levl[u.ux][u.uy].typ)) {
-           cmd[0]=mod == CLICK_1 ? 'q' : M('d');
-           return cmd;
-       } else if(IS_THRONE(levl[u.ux][u.uy].typ)) {
-           cmd[0]=M('s');
-           return cmd;
-       } else if((u.ux == xupstair && u.uy == yupstair)
-                 || (u.ux == sstairs.sx && u.uy == sstairs.sy && sstairs.up)
-                 || (u.ux == xupladder && u.uy == yupladder)) {
-           return "<";
-       } else if((u.ux == xdnstair && u.uy == ydnstair)
-                 || (u.ux == sstairs.sx && u.uy == sstairs.sy && !sstairs.up)
-                 || (u.ux == xdnladder && u.uy == ydnladder)) {
-           return ">";
-       } else if(OBJ_AT(u.ux, u.uy)) {
-           cmd[0] = Is_container(level.objects[u.ux][u.uy]) ? M('l') : ',';
-           return cmd;
-       } else {
-           return "."; /* just rest */
-       }
-    }
-
-    /* directional commands */
-
-    dir = xytod(x, y);
-
-    if (!m_at(u.ux+x, u.uy+y) && !test_move(u.ux, u.uy, x, y, 1)) {
-       cmd[1] = (iflags.num_pad ? ndir[dir] : sdir[dir]);
-       cmd[2] = 0;
-       if (IS_DOOR(levl[u.ux+x][u.uy+y].typ)) {
-           /* slight assistance to the player: choose kick/open for them */
-           if (levl[u.ux+x][u.uy+y].doormask & D_LOCKED) {
-               cmd[0] = C('d');
-               return cmd;
-           }
-           if (levl[u.ux+x][u.uy+y].doormask & D_CLOSED) {
-               cmd[0] = 'o';
-               return cmd;
-           }
-       }
-       if (levl[u.ux+x][u.uy+y].typ <= SCORR) {
-           cmd[0] = 's';
-           cmd[1] = 0;
-           return cmd;
-       }
+        /* convert without using floating point, allowing sloppy clicking */
+        if(x > 2*abs(y))
+            x = 1, y = 0;
+        else if(y > 2*abs(x))
+            x = 0, y = 1;
+        else if(x < -2*abs(y))
+            x = -1, y = 0;
+        else if(y < -2*abs(x))
+            x = 0, y = -1;
+        else
+            x = sgn(x), y = sgn(y);
+
+        if(x == 0 && y == 0)   /* map click on player to "rest" command */
+            return ".";
+
+        dir = xytod(x, y);
     }
 
     /* move, attack, etc. */
@@ -2142,6 +2164,8 @@ dotravel()
        /* Keyboard travel command */
        static char cmd[2];
        coord cc;
+
+       if (!iflags.travelcmd) return 0;
        cmd[1]=0;
        cc.x = u.ux;
        cc.y = u.uy;
index 1fe7a565d9d1034d8284ec2363ea55d3d41045a8..ed1eee1f118d930afb0668701e55ace5bfeff98b 100644 (file)
@@ -128,6 +128,7 @@ static struct Bool_Opt
 #else
        {"msg_window", (boolean *)0, FALSE, SET_IN_FILE},
 #endif
+       {"mouse_support", &iflags.wc_mouse_support, TRUE, DISP_IN_GAME},        /*WC*/
 #ifdef NEWS
        {"news", &iflags.news, TRUE, DISP_IN_GAME},
 #else
@@ -183,6 +184,7 @@ static struct Bool_Opt
 #endif
        {"tombstone",&flags.tombstone, TRUE, SET_IN_GAME},
        {"toptenwin",&flags.toptenwin, FALSE, SET_IN_GAME},
+       {"travel", &iflags.travelcmd, TRUE, SET_IN_GAME},
        {"use_inverse",   &iflags.wc_inverse, FALSE, SET_IN_GAME},              /*WC*/
        {"verbose", &flags.verbose, TRUE, SET_IN_GAME},
        {(char *)0, (boolean *)0, FALSE, 0}
@@ -2990,6 +2992,7 @@ struct wc_Opt wc_options[] = {
        {"hilite_pet", WC_HILITE_PET},
        {"large_font", WC_LARGE_FONT},  /* now obsolete */
        {"popup_dialog", WC_POPUP_DIALOG},
+       {"player_selection", WC_PLAYER_SELECTION},
        {"preload_tiles", WC_PRELOAD_TILES},
        {"tiled_map", WC_TILED_MAP},
        {"tile_file", WC_TILE_FILE},
@@ -3013,7 +3016,10 @@ struct wc_Opt wc_options[] = {
        {"font_text", WC_FONT_TEXT},
        {"map_mode", WC_MAP_MODE},
        {"scroll_margin", WC_SCROLL_MARGIN},
+       {"splash_screen", WC_SPLASH_SCREEN},
        {"vary_msgcount",WC_VARY_MSGCOUNT},
+       {"windowcolors", WC_WINDOWCOLORS},
+       {"mouse_support", WC_MOUSE_SUPPORT},
        {(char *)0, 0L}
 };
 
index 36b6ef1589c54fe1583922e9fa642b3afcc19f5e..1ce86ea0f7da04bfea808da6dd62dd2711516987 100644 (file)
@@ -245,6 +245,10 @@ char *argv[];
        process_options(argc, argv);
 #endif
 
+#ifdef WIN32CON
+       toggle_mouse_support(); /* must come after process_options */
+#endif
+
 #ifdef MFLOPPY
        set_lock_and_bones();
 # ifndef AMIGA
index ffb51b652b2f7b48e031d1b89af68a87defbc1a9..0ad4e2ba7f4a2b93c07b91716c8d91fe1d5f38d5 100644 (file)
@@ -128,6 +128,7 @@ int *wid, *hgt;
        if (twid > 80) twid = 80;
        *wid = twid;
        *hgt = origcsbi.srWindow.Bottom - origcsbi.srWindow.Top;
+       set_option_mod_status("mouse_support", SET_IN_GAME);
 }
 
 void
@@ -225,16 +226,18 @@ nttty_open()
                        0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,0);
 #endif       
        GetConsoleMode(hConIn,&cmode);
-#ifndef NO_MOUSE_ALLOWED
+#ifdef NO_MOUSE_ALLOWED
        mask = ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT |
-              ENABLE_ECHO_INPUT | ENABLE_WINDOW_INPUT;   
+              ENABLE_MOUSE_INPUT | ENABLE_ECHO_INPUT | ENABLE_WINDOW_INPUT;   
 #else
        mask = ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT |
-              ENABLE_MOUSE_INPUT | ENABLE_ECHO_INPUT | ENABLE_WINDOW_INPUT;   
+              ENABLE_ECHO_INPUT | ENABLE_WINDOW_INPUT;   
 #endif
        /* Turn OFF the settings specified in the mask */
        cmode &= ~mask;
+#ifndef NO_MOUSE_ALLOWED
        cmode |= ENABLE_MOUSE_INPUT;
+#endif
        SetConsoleMode(hConIn,cmode);
        if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE)) {
                /* Unable to set control handler */
@@ -484,7 +487,7 @@ nttty_kbhit()
                        retval = 1;
                }
 
-               else /* Discard it, its an insignificant event */
+               else /* Discard it, it's an insignificant event */
                        ReadConsoleInput(hConIn,&ir,1,&count);
                } else  /* There are no events in console event queue */ {
                done = 1;         /* Stop looking               */
@@ -862,4 +865,29 @@ standoutend()
        colorchange = TRUE;
 }
 
+#ifndef NO_MOUSE_ALLOWED
+void
+toggle_mouse_support()
+{
+        DWORD cmode;
+       GetConsoleMode(hConIn,&cmode);
+       if (iflags.wc_mouse_support)
+               cmode |= ENABLE_MOUSE_INPUT;
+       else
+               cmode &= ~ENABLE_MOUSE_INPUT;
+       SetConsoleMode(hConIn,cmode);
+}
+#endif
+
+/* handle tty options updates here */
+void nttty_preference_update(pref)
+const char *pref;
+{
+       if( stricmp( pref, "mouse_support")==0) {
+#ifndef NO_MOUSE_ALLOWED
+               toggle_mouse_support();
+#endif
+       }
+       return;
+}
 #endif /* WIN32CON */
index fe8007a836821ca9648b142c55f1fbf1694de092..e5ed37773e9216f3ab60384d276cac349297a855 100644 (file)
@@ -45,6 +45,9 @@ struct window_procs tty_procs = {
     "tty",
 #ifdef MSDOS
     WC_TILED_MAP|WC_ASCII_MAP|
+#endif
+#if defined(WIN32CON)
+    WC_MOUSE_SUPPORT|
 #endif
     WC_COLOR|WC_HILITE_PET|WC_INVERSE|WC_EIGHT_BIT_IN,
     tty_init_nhwindows,
@@ -100,7 +103,11 @@ struct window_procs tty_procs = {
     tty_start_screen,
     tty_end_screen,
     genl_outrip,
+#if defined(WIN32CON)
+    nttty_preference_update,
+#else
     genl_preference_update,
+#endif
 };
 
 static int maxwin = 0;                 /* number of windows in use */