diff options
author | Florian Diebold <flodiebold@gmail.com> | 2011-10-06 23:05:31 +0200 |
---|---|---|
committer | Florian Diebold <flodiebold@gmail.com> | 2011-10-15 23:18:00 +0200 |
commit | 50c127e8ad514a2817be501f8bd2acbeb1bce4e4 (patch) | |
tree | 073e5b5af7dbe680202740922a66fcdd537c1b08 /crawl-ref/source/libunix.cc | |
parent | cde49cf01ee4d1acf2a4c36050fbeb8c228d1606 (diff) | |
download | crawl-ref-50c127e8ad514a2817be501f8bd2acbeb1bce4e4.tar.gz crawl-ref-50c127e8ad514a2817be501f8bd2acbeb1bce4e4.zip |
Make Webtiles output happen in parallel to the console display, and make the server record ttyrecs.
Crawl compiled with WEBTILES=y should now be playable
normally (i.e. indistinguishable from one compiled without WEBTILES)
when run from a terminal. (This is not yet completely the case.)
The Webtiles data is written on a Unix-domain datagram socket; the
Crawl parameter -webtiles-socket determines a path on which the Crawl
process receives control messages.
The Webtiles server then runs Crawl in a pseudo-terminal and records its
console output into a ttyrec file.
The goal of all this is of course to be able to watch Webtiles games
from ssh, and later the reverse.
Diffstat (limited to 'crawl-ref/source/libunix.cc')
-rw-r--r-- | crawl-ref/source/libunix.cc | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/crawl-ref/source/libunix.cc b/crawl-ref/source/libunix.cc index 80143870bf..deaee2afac 100644 --- a/crawl-ref/source/libunix.cc +++ b/crawl-ref/source/libunix.cc @@ -227,6 +227,17 @@ int getchk() } wint_t c; + +#ifdef USE_TILE_WEB + refresh(); + + tiles.redraw(); + tiles.await_input(c, true); + + if (c > 0) + return c; +#endif + switch (get_wch(&c)) { case ERR: @@ -414,10 +425,18 @@ void console_startup(void) crawl_view.init_geometry(); set_mouse_enabled(false); + +#ifdef USE_TILE_WEB + tiles.resize(); +#endif } void console_shutdown() { +#ifdef USE_TILE_WEB + tiles.shutdown(); +#endif + // resetty(); endwin(); @@ -457,6 +476,13 @@ void putwch(ucs_t chr) c = ' '; // TODO: recognize unsupported characters and try to transliterate addnwstr(&c, 1); + +#ifdef USE_TILE_WEB + ucs_t buf[2]; + buf[0] = chr; + buf[1] = 0; + tiles.put_ucs_string(buf); +#endif } void puttext(int x1, int y1, const crawl_view_buffer &vbuf) @@ -483,6 +509,10 @@ void puttext(int x1, int y1, const crawl_view_buffer &vbuf) void update_screen(void) { refresh(); + +#ifdef USE_TILE_WEB + tiles.set_need_redraw(); +#endif } void clear_to_end_of_line(void) @@ -490,6 +520,10 @@ void clear_to_end_of_line(void) textcolor(LIGHTGREY); textbackground(BLACK); clrtoeol(); + +#ifdef USE_TILE_WEB + tiles.clear_to_end_of_line(); +#endif } int get_number_of_lines(void) @@ -511,6 +545,10 @@ void clrscr() printf("%s", DGL_CLEAR_SCREEN); fflush(stdout); #endif + +#ifdef USE_TILE_WEB + tiles.clrscr(); +#endif } void set_cursor_enabled(bool enabled) @@ -604,6 +642,10 @@ static int curs_fg_attr(int col) void textcolor(int col) { (void)attrset(Current_Colour = curs_fg_attr(col)); + +#ifdef USE_TILE_WEB + tiles.textcolor(col); +#endif } static int curs_bg_attr(int col) @@ -662,6 +704,10 @@ static int curs_bg_attr(int col) void textbackground(int col) { (void)attrset(Current_Colour = curs_bg_attr(col)); + +#ifdef USE_TILE_WEB + tiles.textbackground(col); +#endif } @@ -745,6 +791,11 @@ int wherey() void delay(unsigned int time) { +#ifdef USE_TILE_WEB + tiles.redraw(); + tiles.send_message("delay(%d);", time); +#endif + refresh(); if (time) usleep(time * 1000); @@ -757,6 +808,7 @@ bool kbhit() return true; wint_t c; +#ifndef USE_TILE_WEB int i; nodelay(stdscr, TRUE); @@ -775,4 +827,12 @@ bool kbhit() default: return false; } +#else + bool result = tiles.await_input(c, false); + + if (result && (c != 0)) + pending = c; + + return result; +#endif } |