X11

From NetHackWiki
Jump to navigation Jump to search

X11 is a GUI of NetHack, mainly used on unix-type operating systems. If your copy of NetHack has that compiled in, you can enable it by setting OPTIONS=windowtype:X11 in your config file.

Character selection dialog
Without tiles or any X resources.
Running on Kubuntu Linux 6.06.

X11 can do both tile-graphics and ASCII.

If you do not have any X11 resources set for NetHack, all windows will be black text on white background, and this makes playing almost impossible, unless you turn off color.

You can define the X resources in a text file, for example NetHack.ad in the playground or ~/.Xdefaults, with one resource per line. You can then use xrdb -merge ~/.Xdefaults to make the resources active for your X session.

The configuration file that comes with NetHack sources, win/X11/NetHack.ad, contains extensive documentation about the file and what you can change in it. This file is copied to the nethack playground when compiling and installing from source.

List of some of the X resources NetHack accepts:

Resource string Value Explanation
NetHack*font font Sets the font for all NetHack windows. Must be fixed-width font!
NetHack.tile_file filename What file contains the tiles used for the map? The file must reside in the NetHack playground. If NetHack was compiled with USE_XPM, then this can be a normal xpm-bitmap, otherwise it must be NetHack's custom format.
NetHack.pet_mark_bitmap filename File to use to annotate pets in tile mode. Same restrictions as with tile_file above, except this one must be a two color, black and white, image; the white will be transparent and black will be replaced with pet_mark_color, see below.
NetHack.pet_mark_color color Color of the pet annotation mark.
NetHack*message_lines number The number of lines the message window will show without scrolling.
NetHack*message_line boolean If True, the message window has a line that separates old and new messages.
NetHack*autofocus boolean If True, force keyboard focus to attach to popup windows.
NetHack*slow boolean If True, the default, a popup for single character prompts such as y/n is not used.
NetHack*background color Sets the background color of all NetHack windows
NetHack*foreground color Sets the foreground color of all NetHack windows
NetHack*map*background color Sets the background color of the map
NetHack*map*black color Sets the color 'black' in map to some other color
NetHack*map*red color Sets the color 'red' in map to some other color
NetHack*map*green color Sets the color 'green' in map to some other color
NetHack*map*brown color Sets the color 'brown' in map to some other color
NetHack*map*blue color Sets the color 'blue' in map to some other color
NetHack*map*magenta color Sets the color 'magenta' in map to some other color
NetHack*map*cyan color Sets the color 'cyan' in map to some other color
NetHack*map*gray color Sets the color 'gray' in map to some other color
NetHack*map*orange color Sets the color 'orange' in map to some other color
NetHack*map*bright_green color Sets the color 'bright_green' in map to some other color
NetHack*map*yellow color Sets the color 'yellow' in map to some other color
NetHack*map*bright_blue color Sets the color 'bright_blue' in map to some other color
NetHack*map*bright_magenta color Sets the color 'bright_magenta' in map to some other color
NetHack*map*bright_cyan color Sets the color 'bright_cyan' in map to some other color
NetHack*map*white color Sets the color 'white' in map to some other color
  • 'boolean' can be either True or False.
  • 'color' can be defined either with a named color, or a hexadecimal RGB number, such as #00ff00.
  • 'font' can be any font string the X11 server knows about. Use xlsfonts or xfontsel or some such program to see the fonts.

Some good values would be, for example

! Lines beginning with ! are comments and are ignored.
NetHack*font:                   vga

NetHack*background:             black
NetHack*foreground:             grey

NetHack*map*background:         black

NetHack*map*black:              grey25
NetHack*map*red:                red3
NetHack*map*green:              green3
NetHack*map*brown:              DarkOrange3
NetHack*map*blue:               blue3
NetHack*map*magenta:            magenta3
NetHack*map*cyan:               cyan3
NetHack*map*gray:               gray70
NetHack*map*orange:             yellow
NetHack*map*bright_green:       green
NetHack*map*yellow:             yellow
NetHack*map*bright_blue:        blue
NetHack*map*bright_magenta:     magenta
NetHack*map*bright_cyan:        cyan
NetHack*map*white:              white

Fonts

Two fonts are bundled with the NetHack source for X11. They are win/X11/nh10.bdf and win/X11/ibm.bdf. Both contain special glyphs to display certain dungeon features.

The file win/X11/NetHack.ad used to configure the nh10 font by default. It no longer does this; instead, IBMgraphics or Unicode can be displayed.

The file win/X11/nethack.rc contains configurations to use with these fonts. The configurations are outdated, aligned with NetHack 3.4.3. Users who want to use these fonts can configure them in the symbols file.

nh10.bdf

An image of nh10.bdf follows. The image is doubled in size for readability.

Nh10font.png

The following configuration is derived from the old configuration for the nh10 font. Add this to the symbols file to make it available.

start: X11_NH10Font
    Restrictions: primary
    S_strange_obj:          \xb4
    S_weapon:               \xb7
    S_armor:                \xbc
    S_ring:                 \xc0
    S_amulet:               \xb5
    S_tool:                 \xb8
    S_food:                 \xb6
    S_potion:               \xbd
    S_scroll:               \xbe
    S_book:                 \xc4
    S_wand:                 \xbf
    S_coin:                 \xc2
    S_gem:                  \xc1
    S_rock:                 \xbb
    S_ball:                 \xb9
    S_chain:                \xba
    S_venom:                \xc3
    S_stone:                ' '
    S_vwall:                \x19
    S_hwall:                \x12
    S_tlcorn:               \x0d
    S_trcorn:               \x0c
    S_blcorn:               \x0e
    S_brcorn:               \x0b
    S_crwall:               \x0f
    S_tuwall:               \x17
    S_tdwall:               \x18
    S_tlwall:               \x16
    S_trwall:               \x15
    S_ndoor:                \x80
    S_vodoor:               \x81
    S_hodoor:               \x82
    S_vcdoor:               \x83
    S_hcdoor:               \x84
    S_bars:                 '#'
    S_tree:                 '#'
    S_room:                 \x85
    S_corr:                 \x86
    S_litcorr:              \x87
    S_upstair:              \x88
    S_dnstair:              \x89
    S_upladder:             \x91
    S_dnladder:             \x92
    S_brupstair:            \x88
    S_brdnstair:            \x89
    S_brupladder:           \x91
    S_brdnladder:           \x92
    S_altar:                \x90
    S_grave:                \x7c
    S_throne:               \x8f
    S_sink:                 \x8e
    S_fountain:             \x8d
    S_pool:                 \x8c
    S_ice:                  \x95
    S_lava:                 \x96
    S_vodbridge:            \x1f
    S_hodbridge:            \x1f
    S_vcdbridge:            \x93
    S_hcdbridge:            \x94
    S_air:                  \x1f
    S_cloud:                \xa1
    S_water:                \x8c
    S_arrow_trap:           \x8a
    S_dart_trap:            \x8a
    S_falling_rock_trap:    \x8a
    S_squeaky_board:        \x8a
    S_bear_trap:            \x8a
    S_land_mine:            \x8a
    S_rolling_boulder_trap: \x8a
    S_sleeping_gas_trap:    \x8a
    S_rust_trap:            \x8a
    S_fire_trap:            \x8a
    S_pit:                  \x8a
    S_spiked_pit:           \x8a
    S_hole:                 \x8a
    S_trap_door:            \x8a
    S_teleportation_trap:   \x8a
    S_level_teleporter:     \x8b
    S_magic_portal:         \x8a
    S_web:                  \x8a
    S_statue_trap:          \x8a
    S_magic_trap:           \x8a
    S_anti_magic_trap:      \x8a
    S_polymorph_trap:       \x8a
    S_vbeam:                \x97
    S_hbeam:                \x98
    S_lslant:               \x99
    S_rslant:               \x9a
    S_digbeam:              \x9b
    S_flashbeam:            \x9c
    S_boomleft:             \x9d
    S_boomright:            \x9e
    S_ss1:                  \x9f
    S_ss2:                  \xa0
    S_ss3:                  \xa1
    S_ss4:                  \xa2
    S_sw_tl:                \xa3
    S_sw_tc:                \xa4
    S_sw_tr:                \xa5
    S_sw_ml:                \xa6
    S_sw_mr:                \xa7
    S_sw_bl:                \xa8
    S_sw_bc:                \xa9
    S_sw_br:                \xaa
    S_expl_tl:              \xab
    S_expl_tc:              \xac
    S_expl_tr:              \xad
    S_expl_ml:              \xae
    S_expl_mc:              \xaf
    S_expl_mr:              \xb0
    S_expl_bl:              \xb1
    S_expl_bc:              \xb2
    S_expl_br:              \xb3

#   S_darkroom
#   S_lavawall
#   S_vibrating_square
#   S_trapped_door
#   S_trapped_chest
#   S_poisoncloud
#   S_goodpos
#   S_engroom
#   S_engrcorr
finish

ibm.bdf

Despite the name, ibm.bdf bears only some resemblance to code page 437.

An image of ibm.bdf follows. The image is doubled in size for readability.

Ibmfont.png

The following configuration is derived from the old configuration for the ibm.bdf font. Add this to the symbols file to make it available.

start: X11_IBMFont
    Restrictions: primary
    S_strange_obj:           \xcf
    S_weapon:                \xd2
    S_armor:                 \xd7
    S_ring:                  \xdb
    S_amulet:                \xd0
    S_tool:                  \xd3
    S_food:                  \xd1
    S_potion:                \xd8
    S_scroll:                \xd9
    S_book:                  \xdf
    S_wand:                  \xda
    S_coin:                  \xdd
    S_gem:                   \xdc
    S_rock:                  \xd6
    S_ball:                  \xd4
    S_chain:                 \xd5
    S_venom:                 \xde
    S_stone:                 ' '
    S_vwall:                 \x80
    S_hwall:                 \x81
    S_tlcorn:                \x82
    S_trcorn:                \x83
    S_blcorn:                \x84
    S_brcorn:                \x85
    S_crwall:                \x86
    S_tuwall:                \x87
    S_tdwall:                \x88
    S_tlwall:                \x89
    S_trwall:                \x8a
    S_ndoor:                 \x8b
    S_vodoor:                '-'
    S_hodoor:                \x7c
    S_vcdoor:                \x8e
    S_hcdoor:                \x8f
    S_bars:                  '#'
    S_tree:                  '#'
    S_room:                  \x90
    S_corr:                  \x91
    S_litcorr:               \x92
    S_upstair:               \x93
    S_dnstair:               \x94
    S_upladder:              \x9b
    S_dnladder:              \x9c
    S_brupstair:             \x93
    S_brdnstair:             \x94
    S_brupladder:            \x9b
    S_brdnladder:            \x9c
    S_altar:                 \xe3
    S_grave:                 \x7c
    S_throne:                \x9a
    S_sink:                  \x99
    S_fountain:              \x98
    S_pool:                  \x97
    S_ice:                   \x9f
    S_lava:                  \xa0
    S_vodbridge:             \xc8
    S_hodbridge:             \xc8
    S_vcdbridge:             \x9d
    S_hcdbridge:             \x9e
    S_air:                   \xfa
    S_cloud:                 \xaa
    S_water:                 \x97
    S_arrow_trap:            \x95
    S_dart_trap:             \x95
    S_falling_rock_trap:     \x95
    S_squeaky_board:         \x95
    S_bear_trap:             \x95
    S_land_mine:             \x95
    S_rolling_boulder_trap:  \x95
    S_sleeping_gas_trap:     \x95
    S_rust_trap:             \x95
    S_fire_trap:             \x95
    S_pit:                   \x95
    S_spiked_pit:            \x95
    S_hole:                  \x95
    S_trap_door:             \x95
    S_teleportation_trap:    \x95
    S_level_teleporter:      \x96
    S_magic_portal:          \x95
    S_web:                   \x95
    S_statue_trap:           \x95
    S_magic_trap:            \x95
    S_anti_magic_trap:       \x95
    S_polymorph_trap:        \x95
    S_vbeam:                 \xa1
    S_hbeam:                 \xa2
    S_lslant:                \xa3
    S_rslant:                \xa4
    S_digbeam:               \xa5
    S_flashbeam:             \xa6
    S_boomleft:              \xa7
    S_boomright:             \xa8
    S_ss1:                   \xa9
    S_ss2:                   \xaa
    S_ss3:                   \xab
    S_ss4:                   \xac
    S_sw_tl:                 \xad
    S_sw_tc:                 \xae
    S_sw_tr:                 \xaf
    S_sw_ml:                 \xb0
    S_sw_mr:                 \xb1
    S_sw_bl:                 \xb2
    S_sw_bc:                 \xb3
    S_sw_br:                 \xb4
    S_expl_tl:               \xb5
    S_expl_tc:               \xb6
    S_expl_tr:               \xb7
    S_expl_ml:               \xb8
    S_expl_mc:               \xb9
    S_expl_mr:               \xba
    S_expl_bl:               \xbb
    S_expl_bc:               \xbc
    S_expl_br:               \xbd

#   S_darkroom
#   S_lavawall
#   S_vibrating_square
#   S_trapped_door
#   S_trapped_chest
#   S_poisoncloud
#   S_goodpos
#   S_engroom
#   S_engrcorr
finish