TTY: Add compile-time option for tile data hinting
Several people have asked if 3.6.0 supports playing with tiles on a public server. Because there's no way for the user's end to know what that white @ is, this adds special console escape codes for tile hinting. The idea was originally a patch called TelnetTiles by Justin Hiltscher, but this expanded version comes via NAO, where it's been in use for years. This is basically an interim hack, which should go away when/if we support actual client-server model.
This commit is contained in:
@@ -160,6 +160,7 @@ database entries for Cleaver, Sunsword, Frost and Fire brands, and
|
|||||||
Platform- and/or Interface-Specific New Features
|
Platform- and/or Interface-Specific New Features
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
tty: menu_overlay -option to clear screen and align menus to left
|
tty: menu_overlay -option to clear screen and align menus to left
|
||||||
|
tty: compile-time option to output escape codes for tile data hints
|
||||||
|
|
||||||
|
|
||||||
NetHack Community Patches (or Variation) Included
|
NetHack Community Patches (or Variation) Included
|
||||||
|
|||||||
@@ -439,6 +439,33 @@ typedef unsigned char uchar;
|
|||||||
* bugs left here.
|
* bugs left here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* TTY_TILES_ESCCODES: Enable output of special console escape codes
|
||||||
|
* which act as hints for external programs such as EbonHack.
|
||||||
|
*
|
||||||
|
* Only for TTY_GRAPHICS.
|
||||||
|
*
|
||||||
|
* All of the escape codes are in the format ESC [ N z, where N can be
|
||||||
|
* one or more positive integer values, separated by semicolons.
|
||||||
|
* For example ESC [ 1 ; 0 ; 120 z
|
||||||
|
*
|
||||||
|
* Possible codes are:
|
||||||
|
* ESC [ 1 ; 0 ; n ; m z Start a glyph (aka a tile) number n, with flags m
|
||||||
|
* ESC [ 1 ; 1 z End a glyph.
|
||||||
|
* ESC [ 1 ; 2 ; n z Select a window n to output to.
|
||||||
|
* ESC [ 1 ; 3 z End of data. NetHack has finished sending data,
|
||||||
|
* and is waiting for input.
|
||||||
|
*
|
||||||
|
* Whenever NetHack outputs anything, it will first output the "select window"
|
||||||
|
* code. Whenever NetHack outputs a tile, it will first output the "start
|
||||||
|
* glyph" code, then the escape codes for color and the glyph character
|
||||||
|
* itself, and then the "end glyph" code.
|
||||||
|
*
|
||||||
|
* To compile NetHack with this, add tile.c to WINSRC and tile.o to WINOBJ
|
||||||
|
* in the hints file or Makefile.
|
||||||
|
* Set boolean option vt_tiledata in your config file to turn this on.
|
||||||
|
* Note that gnome-terminal at least doesn't work with this. */
|
||||||
|
/* #define TTY_TILES_ESCCODES */
|
||||||
|
|
||||||
/* #define STATUS_VIA_WINDOWPORT */ /* re-work of the status line
|
/* #define STATUS_VIA_WINDOWPORT */ /* re-work of the status line
|
||||||
updating process */
|
updating process */
|
||||||
/* #define STATUS_HILITES */ /* support hilites of status fields */
|
/* #define STATUS_HILITES */ /* support hilites of status fields */
|
||||||
@@ -459,6 +486,12 @@ typedef unsigned char uchar;
|
|||||||
|
|
||||||
/* End of Section 4 */
|
/* End of Section 4 */
|
||||||
|
|
||||||
|
#ifdef TTY_TILES_ESCCODES
|
||||||
|
# ifndef USE_TILES
|
||||||
|
# define USE_TILES
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "global.h" /* Define everything else according to choices above */
|
#include "global.h" /* Define everything else according to choices above */
|
||||||
|
|
||||||
#endif /* CONFIG_H */
|
#endif /* CONFIG_H */
|
||||||
|
|||||||
@@ -259,6 +259,9 @@ struct instance_flags {
|
|||||||
#ifdef LAN_FEATURES
|
#ifdef LAN_FEATURES
|
||||||
boolean lan_mail; /* mail is initialized */
|
boolean lan_mail; /* mail is initialized */
|
||||||
boolean lan_mail_fetched; /* mail is awaiting display */
|
boolean lan_mail_fetched; /* mail is awaiting display */
|
||||||
|
#endif
|
||||||
|
#ifdef TTY_TILES_ESCCODES
|
||||||
|
boolean vt_tiledata; /* output console codes for tile support in TTY */
|
||||||
#endif
|
#endif
|
||||||
boolean wizweight; /* display weight of everything in wizard mode */
|
boolean wizweight; /* display weight of everything in wizard mode */
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -225,6 +225,11 @@ static struct Bool_Opt {
|
|||||||
{ "use_inverse", &iflags.wc_inverse, FALSE, SET_IN_GAME }, /*WC*/
|
{ "use_inverse", &iflags.wc_inverse, FALSE, SET_IN_GAME }, /*WC*/
|
||||||
#endif
|
#endif
|
||||||
{ "verbose", &flags.verbose, TRUE, SET_IN_GAME },
|
{ "verbose", &flags.verbose, TRUE, SET_IN_GAME },
|
||||||
|
#ifdef TTY_TILES_ESCCODES
|
||||||
|
{ "vt_tiledata", &iflags.vt_tiledata, FALSE, SET_IN_FILE },
|
||||||
|
#else
|
||||||
|
{ "vt_tiledata", (boolean *) 0, FALSE, SET_IN_FILE },
|
||||||
|
#endif
|
||||||
{ "wizweight", &iflags.wizweight, FALSE, SET_IN_WIZGAME },
|
{ "wizweight", &iflags.wizweight, FALSE, SET_IN_WIZGAME },
|
||||||
{ "wraptext", &iflags.wc2_wraptext, FALSE, SET_IN_GAME },
|
{ "wraptext", &iflags.wc2_wraptext, FALSE, SET_IN_GAME },
|
||||||
#ifdef ZEROCOMP
|
#ifdef ZEROCOMP
|
||||||
|
|||||||
@@ -1323,6 +1323,9 @@ static const char *build_opts[] = {
|
|||||||
#ifdef TEXTCOLOR
|
#ifdef TEXTCOLOR
|
||||||
"color",
|
"color",
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef TTY_TILES_ESCCODES
|
||||||
|
"console escape codes for tile hinting",
|
||||||
|
#endif
|
||||||
#ifdef COM_COMPL
|
#ifdef COM_COMPL
|
||||||
"command line completion",
|
"command line completion",
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -37,6 +37,15 @@ extern void msmsg(const char *, ...);
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef TTY_TILES_ESCCODES
|
||||||
|
extern short glyph2tile[];
|
||||||
|
#define TILE_ANSI_COMMAND 'z'
|
||||||
|
#define AVTC_GLYPH_START 0
|
||||||
|
#define AVTC_GLYPH_END 1
|
||||||
|
#define AVTC_SELECT_WINDOW 2
|
||||||
|
#define AVTC_INLINE_SYNC 3
|
||||||
|
#endif
|
||||||
|
|
||||||
extern char mapped_menu_cmds[]; /* from options.c */
|
extern char mapped_menu_cmds[]; /* from options.c */
|
||||||
|
|
||||||
/* this is only needed until tty_status_* routines are written */
|
/* this is only needed until tty_status_* routines are written */
|
||||||
@@ -175,6 +184,36 @@ static const char default_menu_cmds[] = {
|
|||||||
MENU_INVERT_PAGE, MENU_SEARCH, 0 /* null terminator */
|
MENU_INVERT_PAGE, MENU_SEARCH, 0 /* null terminator */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef TTY_TILES_ESCCODES
|
||||||
|
static int vt_tile_current_window = -2;
|
||||||
|
|
||||||
|
void
|
||||||
|
print_vt_code(i, c, d)
|
||||||
|
int i, c, d;
|
||||||
|
{
|
||||||
|
if (iflags.vt_tiledata) {
|
||||||
|
if (c >= 0) {
|
||||||
|
if (i == AVTC_SELECT_WINDOW) {
|
||||||
|
if (c == vt_tile_current_window) return;
|
||||||
|
vt_tile_current_window = c;
|
||||||
|
}
|
||||||
|
if (d >= 0)
|
||||||
|
printf("\033[1;%d;%d;%d%c", i, c, d, TILE_ANSI_COMMAND);
|
||||||
|
else
|
||||||
|
printf("\033[1;%d;%d%c", i, c, TILE_ANSI_COMMAND);
|
||||||
|
} else {
|
||||||
|
printf("\033[1;%d%c", i, TILE_ANSI_COMMAND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
# define print_vt_code(i, c, d) ;
|
||||||
|
#endif /* !TTY_TILES_ESCCODES */
|
||||||
|
#define print_vt_code1(i) print_vt_code((i), -1, -1)
|
||||||
|
#define print_vt_code2(i,c) print_vt_code((i), (c), -1)
|
||||||
|
#define print_vt_code3(i,c,d) print_vt_code((i), (c), (d))
|
||||||
|
|
||||||
|
|
||||||
/* clean up and quit */
|
/* clean up and quit */
|
||||||
STATIC_OVL void
|
STATIC_OVL void
|
||||||
bail(mesg)
|
bail(mesg)
|
||||||
@@ -1427,6 +1466,8 @@ winid window;
|
|||||||
panic(winpanicstr, window);
|
panic(winpanicstr, window);
|
||||||
ttyDisplay->lastwin = window;
|
ttyDisplay->lastwin = window;
|
||||||
|
|
||||||
|
print_vt_code2(AVTC_SELECT_WINDOW, window);
|
||||||
|
|
||||||
switch (cw->type) {
|
switch (cw->type) {
|
||||||
case NHW_MESSAGE:
|
case NHW_MESSAGE:
|
||||||
if (ttyDisplay->toplin) {
|
if (ttyDisplay->toplin) {
|
||||||
@@ -2060,6 +2101,8 @@ boolean blocking; /* with ttys, all windows are blocking */
|
|||||||
ttyDisplay->lastwin = window;
|
ttyDisplay->lastwin = window;
|
||||||
ttyDisplay->rawprint = 0;
|
ttyDisplay->rawprint = 0;
|
||||||
|
|
||||||
|
print_vt_code2(AVTC_SELECT_WINDOW, window);
|
||||||
|
|
||||||
switch (cw->type) {
|
switch (cw->type) {
|
||||||
case NHW_MESSAGE:
|
case NHW_MESSAGE:
|
||||||
if (ttyDisplay->toplin == 1) {
|
if (ttyDisplay->toplin == 1) {
|
||||||
@@ -2145,6 +2188,8 @@ winid window;
|
|||||||
if (window == WIN_ERR || (cw = wins[window]) == (struct WinDesc *) 0)
|
if (window == WIN_ERR || (cw = wins[window]) == (struct WinDesc *) 0)
|
||||||
panic(winpanicstr, window);
|
panic(winpanicstr, window);
|
||||||
|
|
||||||
|
print_vt_code2(AVTC_SELECT_WINDOW, window);
|
||||||
|
|
||||||
switch (cw->type) {
|
switch (cw->type) {
|
||||||
case NHW_MESSAGE:
|
case NHW_MESSAGE:
|
||||||
if (ttyDisplay->toplin)
|
if (ttyDisplay->toplin)
|
||||||
@@ -2214,6 +2259,8 @@ register int x, y; /* not xchar: perhaps xchar is unsigned and
|
|||||||
panic(winpanicstr, window);
|
panic(winpanicstr, window);
|
||||||
ttyDisplay->lastwin = window;
|
ttyDisplay->lastwin = window;
|
||||||
|
|
||||||
|
print_vt_code2(AVTC_SELECT_WINDOW, window);
|
||||||
|
|
||||||
#if defined(USE_TILES) && defined(MSDOS)
|
#if defined(USE_TILES) && defined(MSDOS)
|
||||||
adjust_cursor_flags(cw);
|
adjust_cursor_flags(cw);
|
||||||
#endif
|
#endif
|
||||||
@@ -2302,6 +2349,8 @@ char ch;
|
|||||||
if (window == WIN_ERR || (cw = wins[window]) == (struct WinDesc *) 0)
|
if (window == WIN_ERR || (cw = wins[window]) == (struct WinDesc *) 0)
|
||||||
panic(winpanicstr, window);
|
panic(winpanicstr, window);
|
||||||
|
|
||||||
|
print_vt_code2(AVTC_SELECT_WINDOW, window);
|
||||||
|
|
||||||
switch (cw->type) {
|
switch (cw->type) {
|
||||||
case NHW_STATUS:
|
case NHW_STATUS:
|
||||||
case NHW_MAP:
|
case NHW_MAP:
|
||||||
@@ -2369,6 +2418,8 @@ const char *str;
|
|||||||
|
|
||||||
ttyDisplay->lastwin = window;
|
ttyDisplay->lastwin = window;
|
||||||
|
|
||||||
|
print_vt_code2(AVTC_SELECT_WINDOW, window);
|
||||||
|
|
||||||
switch (cw->type) {
|
switch (cw->type) {
|
||||||
case NHW_MESSAGE:
|
case NHW_MESSAGE:
|
||||||
/* really do this later */
|
/* really do this later */
|
||||||
@@ -3065,9 +3116,13 @@ int bkglyph UNUSED;
|
|||||||
/* map glyph to character and color */
|
/* map glyph to character and color */
|
||||||
(void) mapglyph(glyph, &ch, &color, &special, x, y);
|
(void) mapglyph(glyph, &ch, &color, &special, x, y);
|
||||||
|
|
||||||
|
print_vt_code2(AVTC_SELECT_WINDOW, window);
|
||||||
|
|
||||||
/* Move the cursor. */
|
/* Move the cursor. */
|
||||||
tty_curs(window, x, y);
|
tty_curs(window, x, y);
|
||||||
|
|
||||||
|
print_vt_code3(AVTC_GLYPH_START, glyph2tile[glyph], special);
|
||||||
|
|
||||||
#ifndef NO_TERMS
|
#ifndef NO_TERMS
|
||||||
if (ul_hack && ch == '_') { /* non-destructive underscore */
|
if (ul_hack && ch == '_') { /* non-destructive underscore */
|
||||||
(void) putchar((char) ' ');
|
(void) putchar((char) ' ');
|
||||||
@@ -3111,6 +3166,8 @@ int bkglyph UNUSED;
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print_vt_code1(AVTC_GLYPH_END);
|
||||||
|
|
||||||
wins[window]->curx++; /* one character over */
|
wins[window]->curx++; /* one character over */
|
||||||
ttyDisplay->curx++; /* the real cursor moved too */
|
ttyDisplay->curx++; /* the real cursor moved too */
|
||||||
}
|
}
|
||||||
@@ -3121,6 +3178,7 @@ const char *str;
|
|||||||
{
|
{
|
||||||
if (ttyDisplay)
|
if (ttyDisplay)
|
||||||
ttyDisplay->rawprint++;
|
ttyDisplay->rawprint++;
|
||||||
|
print_vt_code2(AVTC_SELECT_WINDOW, NHW_BASE);
|
||||||
#if defined(MICRO) || defined(WIN32CON)
|
#if defined(MICRO) || defined(WIN32CON)
|
||||||
msmsg("%s\n", str);
|
msmsg("%s\n", str);
|
||||||
#else
|
#else
|
||||||
@@ -3135,6 +3193,7 @@ const char *str;
|
|||||||
{
|
{
|
||||||
if (ttyDisplay)
|
if (ttyDisplay)
|
||||||
ttyDisplay->rawprint++;
|
ttyDisplay->rawprint++;
|
||||||
|
print_vt_code2(AVTC_SELECT_WINDOW, NHW_BASE);
|
||||||
term_start_raw_bold();
|
term_start_raw_bold();
|
||||||
#if defined(MICRO) || defined(WIN32CON)
|
#if defined(MICRO) || defined(WIN32CON)
|
||||||
msmsg("%s", str);
|
msmsg("%s", str);
|
||||||
@@ -3153,7 +3212,7 @@ const char *str;
|
|||||||
int
|
int
|
||||||
tty_nhgetch()
|
tty_nhgetch()
|
||||||
{
|
{
|
||||||
int i;
|
int i, tmp;
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
/* kludge alert: Some Unix variants return funny values if getc()
|
/* kludge alert: Some Unix variants return funny values if getc()
|
||||||
* is called, interrupted, and then called again. There
|
* is called, interrupted, and then called again. There
|
||||||
@@ -3164,6 +3223,7 @@ tty_nhgetch()
|
|||||||
char nestbuf;
|
char nestbuf;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
print_vt_code1(AVTC_INLINE_SYNC);
|
||||||
(void) fflush(stdout);
|
(void) fflush(stdout);
|
||||||
/* Note: if raw_print() and wait_synch() get called to report terminal
|
/* Note: if raw_print() and wait_synch() get called to report terminal
|
||||||
* initialization problems, then wins[] and ttyDisplay might not be
|
* initialization problems, then wins[] and ttyDisplay might not be
|
||||||
@@ -3186,6 +3246,12 @@ tty_nhgetch()
|
|||||||
i = '\033'; /* same for EOF */
|
i = '\033'; /* same for EOF */
|
||||||
if (ttyDisplay && ttyDisplay->toplin == 1)
|
if (ttyDisplay && ttyDisplay->toplin == 1)
|
||||||
ttyDisplay->toplin = 2;
|
ttyDisplay->toplin = 2;
|
||||||
|
#ifdef TTY_TILES_ESCCODES
|
||||||
|
/* hack to force output of the window select code */
|
||||||
|
tmp = vt_tile_current_window;
|
||||||
|
vt_tile_current_window++;
|
||||||
|
print_vt_code2(AVTC_SELECT_WINDOW, tmp);
|
||||||
|
#endif /* TTY_TILES_ESCCODES */
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user