9 static int rows, linecount; /* for paging */
10 static bool pause_latch;
13 WINDOW *fullscreen_window;
14 WINDOW *srscan_window;
15 WINDOW *report_window;
16 WINDOW *status_window;
17 WINDOW *lrscan_window;
18 WINDOW *message_window;
19 WINDOW *prompt_window;
21 static void outro(void)
22 /* wrap up, either normally or due to signal */
24 if (game.options & OPTION_CURSES) {
39 setlocale(LC_ALL, "");
40 bindtextdomain(PACKAGE, LOCALEDIR);
44 fprintf(stderr,"Unable to register outro(), exiting...\n");
47 if (!(game.options & OPTION_CURSES)) {
48 char *ln_env = getenv("LINES");
49 rows = ln_env ? atoi(ln_env) : 25;
61 init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK);
62 init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK);
63 init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK);
64 init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
65 init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK);
66 init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
67 init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK);
68 init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK);
72 fullscreen_window = stdscr;
73 srscan_window = newwin(12, 25, 0, 0);
74 report_window = newwin(11, 0, 1, 25);
75 status_window = newwin(10, 0, 1, 39);
76 lrscan_window = newwin(5, 0, 0, 64);
77 message_window = newwin(0, 0, 12, 0);
78 prompt_window = newwin(1, 0, LINES-2, 0);
79 scrollok(message_window, TRUE);
80 setwnd(fullscreen_window);
87 /* wait for user action -- OK to do nothing if on a TTY */
89 if (game.options & OPTION_CURSES)
93 void pause_reset(void)
98 void pause_game(bool announcement)
106 if (game.skill > SKILL_FAIR)
107 prompt = _("[ANOUNCEMENT ARRIVING...]");
109 prompt = _("[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]");
112 if (game.skill > SKILL_FAIR)
113 prompt = _("[CONTINUE?]");
115 prompt = _("[PRESS ENTER TO CONTINUE]");
118 if (game.options & OPTION_CURSES) {
120 setwnd(prompt_window);
121 wclear(prompt_window);
122 waddstr(prompt_window, prompt);
123 wgetnstr(prompt_window, buf, sizeof(buf));
124 wclear(prompt_window);
125 wrefresh(prompt_window);
126 setwnd(message_window);
130 fgets(buf, sizeof(buf), stdin);
133 for (j = 0; j < rows; j++)
146 if (game.options & OPTION_CURSES) {
147 if (curwnd == message_window && getcury(curwnd) >= getmaxy(curwnd) - 3) {
155 if (linecount >= rows)
163 static void vproutn(const char *fmt, va_list ap)
165 if (game.options & OPTION_CURSES) {
166 vwprintw(curwnd, fmt, ap);
173 void proutn(const char *fmt, ...)
181 void prout(const char *fmt, ...)
190 void prouts(const char *fmt, ...)
194 wchar_t *s, mbuf[BUFSIZ];
197 vsprintf(buf, fmt, ap);
199 mbstowcs(mbuf, buf, BUFSIZ);
200 for (s = mbuf; *s; s++) {
201 /* HOW to convince ncurses to use wchar_t?? */
202 /* WHY putwchar() doesn't work?? */
203 /* OK then, convert back to mbs... */
204 char c[MB_CUR_MAX*2];
210 if (game.options & OPTION_CURSES)
218 void cgetline(char *line, int max)
220 if (game.options & OPTION_CURSES) {
221 wgetnstr(curwnd, line, max);
225 if (replayfp && !feof(replayfp))
226 fgets(line, max, replayfp);
228 fgets(line, max, stdin);
232 line[strlen(line)-1] = '\0';
235 void setwnd(WINDOW *wnd)
236 /* change windows -- OK for this to be a no-op in tty mode */
238 if (game.options & OPTION_CURSES) {
240 curs_set(wnd == fullscreen_window || wnd == message_window || wnd == prompt_window);
245 /* clear to end of line -- can be a no-op in tty mode */
247 if (game.options & OPTION_CURSES) {
254 /* clear screen -- can be a no-op in tty mode */
256 if (game.options & OPTION_CURSES) {
264 void textcolor(int color)
267 if (game.options & OPTION_CURSES) {
273 wattron(curwnd, COLOR_PAIR(COLOR_BLACK));
276 wattron(curwnd, COLOR_PAIR(COLOR_BLUE));
279 wattron(curwnd, COLOR_PAIR(COLOR_GREEN));
282 wattron(curwnd, COLOR_PAIR(COLOR_CYAN));
285 wattron(curwnd, COLOR_PAIR(COLOR_RED));
288 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA));
291 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW));
294 wattron(curwnd, COLOR_PAIR(COLOR_WHITE));
297 wattron(curwnd, COLOR_PAIR(COLOR_BLACK) | A_BOLD);
300 wattron(curwnd, COLOR_PAIR(COLOR_BLUE) | A_BOLD);
303 wattron(curwnd, COLOR_PAIR(COLOR_GREEN) | A_BOLD);
306 wattron(curwnd, COLOR_PAIR(COLOR_CYAN) | A_BOLD);
309 wattron(curwnd, COLOR_PAIR(COLOR_RED) | A_BOLD);
312 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA) | A_BOLD);
315 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW) | A_BOLD);
318 wattron(curwnd, COLOR_PAIR(COLOR_WHITE) | A_BOLD);
327 if (game.options & OPTION_CURSES) {
328 wattron(curwnd, A_REVERSE);
332 void commandhook(char *cmd, bool before) {
336 * Things past this point have policy implications.
339 void drawmaps(int mode)
340 /* hook to be called after moving to redraw maps */
342 if (game.options & OPTION_CURSES) {
345 setwnd(srscan_window);
349 setwnd(status_window);
350 wclear(status_window);
351 wmove(status_window, 0, 0);
352 setwnd(report_window);
353 wclear(report_window);
354 wmove(report_window, 0, 0);
356 setwnd(lrscan_window);
357 wclear(lrscan_window);
358 wmove(lrscan_window, 0, 0);
364 static void put_srscan_sym(coord w, char sym)
366 wmove(srscan_window, w.x+1, w.y*2+2);
367 waddch(srscan_window, sym);
368 wrefresh(srscan_window);
372 /* enemy fall down, go boom */
374 if (game.options & OPTION_CURSES) {
376 setwnd(srscan_window);
377 wattron(srscan_window, A_REVERSE);
378 put_srscan_sym(w, game.quad[w.x][w.y]);
382 wattroff(srscan_window, A_REVERSE);
383 put_srscan_sym(w, game.quad[w.x][w.y]);
385 setwnd(message_window);
390 /* sound and visual effects for teleportation */
392 if (game.options & OPTION_CURSES) {
394 setwnd(message_window);
397 prouts(" . . . . . ");
398 if (game.options & OPTION_CURSES) {
404 void tracktorpedo(coord w, int l, int i, int n, int iquad)
405 /* torpedo-track animation */
407 if (!game.options & OPTION_CURSES) {
411 proutn(_("Track for torpedo number %d- "), i);
415 proutn(_("Torpedo track- "));
417 } else if (l==4 || l==9)
419 proutn("%d - %d ", w.x, w.y);
421 if (!damaged(DSRSENS) || game.condition==docked) {
422 if (i != 1 && l == 1) {
426 if ((iquad==IHDOT)||(iquad==IHBLANK)){
427 put_srscan_sym(w, '+');
431 put_srscan_sym(w, iquad);
434 wattron(curwnd, A_REVERSE);
435 put_srscan_sym(w, iquad);
439 wattroff(curwnd, A_REVERSE);
440 put_srscan_sym(w, iquad);
443 proutn("%d - %d ", w.x, w.y);
450 if (game.options & OPTION_CURSES) {
451 setwnd(message_window);
452 wclear(message_window);
455 if (game.options & OPTION_TTY) {
460 void prstat(const char *txt, const char *fmt, ...)
466 if (game.options & OPTION_CURSES) {
469 for (i = mblen(txt, strlen(txt)); i < NSYM; i++)
472 if (game.options & OPTION_CURSES)
473 setwnd(status_window);
478 if (game.options & OPTION_CURSES)
479 setwnd(report_window);