8 static int rows, linecount; /* for paging */
11 WINDOW *fullscreen_window;
12 WINDOW *srscan_window;
13 WINDOW *report_window;
14 WINDOW *lrscan_window;
15 WINDOW *message_window;
16 WINDOW *prompt_window;
18 static void outro(void)
19 /* wrap up, either normally or due to signal */
21 if (game.options & OPTION_CURSES) {
36 setlocale(LC_ALL, "");
37 bindtextdomain(PACKAGE, LOCALEDIR);
41 fprintf(stderr,"Unable to register outro(), exiting...\n");
44 if (!(game.options & OPTION_CURSES)) {
45 rows = atoi(getenv("LINES"));
57 init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK);
58 init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK);
59 init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK);
60 init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
61 init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK);
62 init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
63 init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK);
64 init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK);
68 fullscreen_window = stdscr;
69 srscan_window = newwin(12, 25, 0, 0);
70 report_window = newwin(10, 0, 1, 25);
71 lrscan_window = newwin(10, 0, 0, 64);
72 message_window = newwin(0, 0, 12, 0);
73 prompt_window = newwin(1, 0, LINES-2, 0);
74 scrollok(message_window, TRUE);
75 setwnd(fullscreen_window);
82 /* wait for user action -- OK to do nothing if on a TTY */
84 if (game.options & OPTION_CURSES)
88 void pause_game(bool announcement)
93 if (game.skill > SKILL_FAIR)
94 prompt = _("[ANOUNCEMENT ARRIVING...]");
96 prompt = _("[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]");
99 if (game.skill > SKILL_FAIR)
100 prompt = _("[CONTINUE?]");
102 prompt = _("[PRESS ENTER TO CONTINUE]");
105 if (game.options & OPTION_CURSES) {
107 setwnd(prompt_window);
108 wclear(prompt_window);
109 waddstr(prompt_window, prompt);
110 wgetnstr(prompt_window, buf, sizeof(buf));
111 wclear(prompt_window);
112 wrefresh(prompt_window);
113 setwnd(message_window);
117 fgets(buf, sizeof(buf), stdin);
120 for (j = 0; j < rows; j++)
131 if (game.options & OPTION_CURSES) {
132 if (curwnd == message_window && linecount >= getmaxy(curwnd) - 3) {
137 if (curwnd == message_window)
142 if (linecount >= rows)
150 static void vproutn(char *fmt, va_list ap)
152 if (game.options & OPTION_CURSES) {
153 vwprintw(curwnd, fmt, ap);
160 void proutn(char *fmt, ...)
168 void prout(char *fmt, ...)
177 void prouts(char *fmt, ...)
180 char *s, buf[BUFSIZ];
183 vsprintf(buf, fmt, ap);
185 for (s = buf; *s; s++) {
187 if (game.options & OPTION_CURSES) {
198 void cgetline(char *line, int max)
200 if (game.options & OPTION_CURSES) {
201 wgetnstr(curwnd, line, max);
205 if (replayfp && !feof(replayfp))
206 fgets(line, max, replayfp);
208 fgets(line, max, stdin);
212 line[strlen(line)-1] = '\0';
215 void setwnd(WINDOW *wnd)
216 /* change windows -- OK for this to be a no-op in tty mode */
218 if (game.options & OPTION_CURSES) {
220 curs_set(wnd == fullscreen_window || wnd == message_window || wnd == prompt_window);
225 /* clear to end of line -- can be a no-op in tty mode */
227 if (game.options & OPTION_CURSES) {
234 /* clear screen -- can be a no-op in tty mode */
236 if (game.options & OPTION_CURSES) {
244 void textcolor (int color)
247 if (game.options & OPTION_CURSES) {
253 wattron(curwnd, COLOR_PAIR(COLOR_BLACK));
256 wattron(curwnd, COLOR_PAIR(COLOR_BLUE));
259 wattron(curwnd, COLOR_PAIR(COLOR_GREEN));
262 wattron(curwnd, COLOR_PAIR(COLOR_CYAN));
265 wattron(curwnd, COLOR_PAIR(COLOR_RED));
268 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA));
271 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW));
274 wattron(curwnd, COLOR_PAIR(COLOR_WHITE));
277 wattron(curwnd, COLOR_PAIR(COLOR_BLACK) | A_BOLD);
280 wattron(curwnd, COLOR_PAIR(COLOR_BLUE) | A_BOLD);
283 wattron(curwnd, COLOR_PAIR(COLOR_GREEN) | A_BOLD);
286 wattron(curwnd, COLOR_PAIR(COLOR_CYAN) | A_BOLD);
289 wattron(curwnd, COLOR_PAIR(COLOR_RED) | A_BOLD);
292 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA) | A_BOLD);
295 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW) | A_BOLD);
298 wattron(curwnd, COLOR_PAIR(COLOR_WHITE) | A_BOLD);
305 void highvideo (void)
307 if (game.options & OPTION_CURSES) {
308 wattron(curwnd, A_REVERSE);
312 void commandhook(char *cmd, bool before) {
316 * Things past this point have policy implications.
319 void drawmaps(int mode)
320 /* hook to be called after moving to redraw maps */
322 if (game.options & OPTION_CURSES) {
325 setwnd(srscan_window);
330 setwnd(report_window);
331 wclear(report_window);
332 wmove(report_window, 0, 0);
333 srscan(SCAN_NO_LEFTSIDE);
334 setwnd(lrscan_window);
335 wclear(lrscan_window);
336 wmove(lrscan_window, 0, 0);
343 static void put_srscan_sym(coord w, char sym)
345 wmove(srscan_window, w.x+1, w.y*2+2);
346 waddch(srscan_window, sym);
347 wrefresh(srscan_window);
351 /* enemy fall down, go boom */
353 if (game.options & OPTION_CURSES) {
355 setwnd(srscan_window);
356 wattron(srscan_window, A_REVERSE);
357 put_srscan_sym(w, game.quad[w.x][w.y]);
361 wattroff(srscan_window, A_REVERSE);
362 put_srscan_sym(w, game.quad[w.x][w.y]);
364 setwnd(message_window);
369 /* sound and visual effects for teleportation */
371 if (game.options & OPTION_CURSES) {
373 setwnd(message_window);
376 prouts(" . . . . . ");
377 if (game.options & OPTION_CURSES) {
383 void tracktorpedo(coord w, int l, int i, int n, int iquad)
384 /* torpedo-track animation */
386 if (!game.options & OPTION_CURSES) {
390 proutn(_("Track for torpedo number %d- "), i);
394 proutn(_("Torpedo track- "));
396 } else if (l==4 || l==9)
398 proutn("%d - %d ", w.x, w.y);
400 if (!damaged(DSRSENS) || game.condition==docked) {
401 if (i != 1 && l == 1) {
405 if ((iquad==IHDOT)||(iquad==IHBLANK)){
406 put_srscan_sym(w, '+');
410 put_srscan_sym(w, iquad);
413 wattron(curwnd, A_REVERSE);
414 put_srscan_sym(w, iquad);
418 wattroff(curwnd, A_REVERSE);
419 put_srscan_sym(w, iquad);
422 proutn("%d - %d ", w.x, w.y);
429 if (game.options & OPTION_CURSES) {
430 setwnd(message_window);
431 wclear(message_window);