NetHack / NetHack

Official NetHack Git Repository

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rendering Tilesets on terminals that support displaying images?

OrangeBurrito opened this issue · comments

I'm not sure how technically feasible this is, but terminals like iTerm2 are able to render images using something like imgcat. Perhaps it could be possible to loop through the characters onscreen and convert them to their image equivalents?

Not to say you couldn't just use a GUI, but the current up-to-date versions (e.g. Qt) aren't that great from a UX standpoint, lacking a few quality-of-life things like Curses's general layout ( perm_invent ) or odd default keybindings.

It might be possible, but unless there's a way to cache the tile images on the rendering side (or refer to images by index), it would bloat the data stream; the game would have to send the base64 encoded tile data for every map location, which is a lot of duplicates.

One approach might be to use a font that puts emojis in the Unicode private use areas, and set up a mapping in the symbols file to use it. This part still needs some work: the last I tried, objects still don't render according to the symbols file, at least for Unicode symbol sets. Also, I would think that objects should render according to appearance rather than function, e.g., a symbol for "glass wand" rather than "wand of probing".

Isn't this what the vt_tiledata option is for? It causes nethack to output an escape sequence containing a tile index number after setting up screen positioning.

Normally it's used on a remote server to pass tile info to a local program which knows how to decode the sequences and render the corresponding tiles. It seems to me that having nethack pipe its output into that sort of program locally could achieve similar results. [Disclaimer: I've never used it.]

I think what @pat-rankin proposes would be possible. If vt_tiledata is enabled, NetHack should be able to use that to pipe tile data in a format that the local terminal graphics protocol could interpret. I believe that the three most common of these protocols are sixel, iTerm2, and Kitty. With Sixel, I think that in some cases it would be as simple as requesting that the terminal print a string of data that can be interpreted by the sixel protocol, as seen in the sample code on sixel's wikipedia page.

If there is interest, I would be willing to try to write up a patch for this. I occasionally am struck by the urge to play in tiles, but am often frustrated by the lack of UI functionality in comparison to the curses windowport.