# NetHack with Qt interface

## version 0.9
(for NetHack 3.2.1)

### by Warwick Allison

### warwick@cs.uq.edu.au

## Like it?

Then VOTE for NetHack 3 in the Internet PC Games Charts! Because that is how I, and other NetHack developers get encouragement to make it such a HOT game. If you really like it, vote weekly!

And if you're a programmer, enter the COOLEST programming competition ever - win $2000 for showing off your skills, without having to give up your copyright (unlike those bogus photography `competitions'). How? See the Qt GUI Programming Contest! I'm telling you about this because I can't enter - I'm of the Mr. Random Hacker judges.

## What's new?

Version 0.9:
  In preparation for inclusion into standard NetHack distribution.
Version 0.7:
  - Allow out-of-focus string inputs (no need to move the mouse)
  - Compiles with Qt 1.0
    - Fixes occasional redraw problems
    - "string" vs. "text" problem fixed
Version 0.6:
  - Fix crash on save-bones (again, properly this time)
  - Add USER_SOUNDS support (but doesn't enable it)
  - Beeping in Linux binary too.
Version 0.5:
  - Compiles with Qt 0.99
  - Beeping
  - Various bug fixes
  - Wizard Patch included in Linux binary
Version 0.4:
  - Source code now patches over standard NetHack 3.2.1 source distribution.
  - Checked to compile with Qt 0.97 (no changes required).
Version 0.3:
  - Source code now patches over standard NetHack 3.2.0 source distribution.
  - Bug fixes
    - Two missing help windows now show up.
    - Crash on exit with bonesfiles fixed.
Version 0.2:
  - Current armour, weapon, amulet, and rings shown in status area.
  - Automatic geometry, based on root window size (unless user-specified).
  - Automatic font size and tile size, based on geometry.
  - Highlighting changed stats (as per X11/Xaw interface). The stats are highlighted for 2 moves. Should this be user-configurable?
  - Redraw more efficient when many things moving (eg. when using ESP).
  - Yes-no-type prompts now appear in the message window, similar to the X11/Xaw `slow' option. This is configurable in the source. Let me know if you prefer pop-ups, and I'll consider making it user-configurable.
  - Bug fixes
    - `Virtual memory exceeded in new' bug fixed.
    - Excess memory usage by text windows fixed.
Version 0.1:
  - Initial version.

## What is it?

NetHack is a Free graphical one-player roleplaying game with a highly modular window system interface supporting TTY, VGA, Mac, Amiga, and other displays. Qt is a graphical user interface toolkit. So, "NetHack with Qt interface" is a version of NetHack which has a user interface module written using the Qt toolkit.

## What does it look like?

(click for larger version)

## How is it better than the plain X11 interface?

The Qt interface has these extra features:

- Tiles (graphics) in the inventory and other item-menu windows.
- The player cursor changes colour as your relative hit-points drop.
- The message window greys-out older message.
- The item menus allow a count (click to left of icon - hidden feature).
- Icons for the major attributes and player states.
- Menus (only needed by newbie dungeon fodder).
- Variable size fonts and tiles.
- More space for the map as messages and status are side-by-side.
- You rarely need to put the mouse in a pop-up to interact with it.
- Macros - hidden feature - F1=multi-rest F2=multi-search F3=try-it
- It is much easier to code, so new feature-requests are more easily done.
- Sound support (but doesn't enable it)

The standard NetHack X11 interface is written in C using the Athena Widgets toolkit. The strongest reason for doing it that way was that NetHack is one of the most incredibly portable programs of any kind, and the Athena Widget Set is also available for free on a large number of X11 implementations. The problem is that Athena Widgets (also known as Xaw) is very ugly, difficult to program in, and buggy. The Qt interface toolkit on the other hand is written in C++ and is freely portable to any X11 implementation, but is less widespread, making it inappropriate for the standard NetHack X11 interface.

### Sound support

The QtNetHack patch includes experimental support for sounds to be played based on messages. For example, you can arrange for a gong to sound when the message "... cursing shoplifter..." appears. The system maps any regular expression (can be just some text) to a sound. The QtNetHack windowport is the only one providing this method, and it does so using the NAS (Network Audio System) . As distributed, the patch does not actually enable this feature - see `include/config.h` once you have applied the patch, and look for `USER_SOUNDS` for an explanation of how to enable it.

You will also want to collect some sound samples to try it out. You might want to start with the `nhsound` package, which you can find referenced on the NetHack Home Page. I'm not sure what format the files come in in that package, but you should be able to convert it if needed to one of the many sound formats supported by NAS.

If you do use the sound support, please let me know, as I am still wondering whether to bother with it. I find it very helpful to the game (eg. when I `feel feverish', I sound a dire warning, so I don't accidentally miss that vital message).

## Where do I get it?

Currently, only a Linux version is supported by me, but since Troll Tech have made the awesome move of providing all the sources for Qt under X11, any platform running X11 should be able to run Qt NetHack - see the compilation instructions below.

First, you need to install the libraries of the Qt toolkit. Note that in general, I use the latest version of Qt, and that is what you should have installed to run QtNetHack. They are available from Troll Tech's FTP site. For the Linux binary version, you actually only need the binary Qt libraries to be installed, but I recommend you get the full package if you are at all interested in writing programs.

Then, you just install this package by typing (as root):

      cd /
      tar xfvpz <wherever-you-put-the-file>/nh3.2.1qt0.9Linux-ELF.tar.gz

You will then have a program `/usr/games/nethack` (which can usually be run just by typing "`nethack`"). Note that this will overwrite any previous version of NetHack, as the package places everthing in the standard NetHack directories. Also, it includes the fabulous Wizard Patch from Larry Stewart-Zerba.

NOTICE:
  If you are using XFree86 3.2, you may not be able to use the number-pad unless you disable the XKeyboard extension. To do this, pass the option `-kb` to the server (eg. use `startx -- -kb`).

To make the game just how I like to play it, create a file in your home directory called `.nethackrc` and include the following lines there:

    #
    # Nethack configuration file.
    #
    OPTIONS=number_pad,menu-style:partial,noautopickup,showexp,time,hilite_pet,toptenwin,name:player

### Installing via Source Code

If you want, you can use the source code. You will need the full source of the Qt library, and you will need to install the full sources of NetHack 3.2.1 Also, you must have the NetPBM utilities installed on your system during compilation. NetPBM is available from many places (such as wu-archive) and for many operating systems. In the extreme case that you cannot get them working, you could copy the files from the binary distribution above - wait for the make to fail, then copy the file in by hand - you're on your own with this bit.

Install the NetHack sources, as described here. then unpack my source code from the `win` subdirectory of your installation:

    	cd win
    	tar xfz ../../nhqt0.9.tar.gz

In the created `Qt` subdirectory, you will find a patch file. From the top-level of the NetHack source directory (ie. above the "win" directory where you did the unpacking), type:

    	cd ..
    	patch -s < win/Qt/nhqt.patch

This will reconfigure the standard NetHack sources to be able to build a Qt version. You will probably want to edit the following files, just as you would have to for installing any NetHack version, to configure NetHack for your operating system (the default is SunOS4):

- `include/config.h`
- `include/unixconf.h`
- `unix/Makefile.src`

Don't worry, you'll only have to change a few obvious things. If you have problems, I suggest you try to get the X11 version working for your system prior to attempting the Qt version.

You will then have to go to the `sys/unix` subdirectory and run the `setup.sh` script and finally run "make install" from the top-level (these steps are required for any Unix build of NetHack):

    	cd sys/unix
    	./setup.sh
    	cd ../..
    	make install

After some time, you will have a compiled game for your system. Consider packaging up the binary and uploading it to an FTP site appropriate for other users of your system, but please try to stay up-to-date with my new releases if you do so. As distributed, all files are in the directory `/usr/games/lib/nethackdir`, plus the script `/usr/games/nethack`.

Finally, if you make any changes, then please send them to me so that they can be in future releases. Eventually I hope to incorporate the Qt interface into the official NetHack distributions.