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);
42 fprintf(stderr,"Unable to register outro(), exiting...\n");
45 if (!(game.options & OPTION_CURSES)) {
46 rows = atoi(getenv("LINES"));
58 init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK);
59 init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK);
60 init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK);
61 init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
62 init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK);
63 init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
64 init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK);
65 init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK);
69 fullscreen_window = stdscr;
70 srscan_window = newwin(12, 25, 0, 0);
71 report_window = newwin(10, 0, 1, 25);
72 lrscan_window = newwin(10, 0, 0, 64);
73 message_window = newwin(0, 0, 12, 0);
74 prompt_window = newwin(1, 0, LINES-2, 0);
75 scrollok(message_window, TRUE);
76 setwnd(fullscreen_window);
83 /* wait for user action -- OK to do nothing if on a TTY */
85 if (game.options & OPTION_CURSES)
89 void pause_game(int i)
94 if (game.skill > SKILL_FAIR)
95 prompt = "[ANOUNCEMENT ARRIVING...]";
97 prompt = "[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]";
100 if (game.skill > SKILL_FAIR)
101 prompt = "[CONTINUE?]";
103 prompt = "[PRESS ENTER TO CONTINUE]";
106 if (game.options & OPTION_CURSES) {
108 setwnd(prompt_window);
109 wclear(prompt_window);
110 waddstr(prompt_window, prompt);
111 wgetnstr(prompt_window, buf, sizeof(buf));
112 wclear(prompt_window);
113 wrefresh(prompt_window);
114 setwnd(message_window);
118 fgets(buf, sizeof(buf), stdin);
121 for (j = 0; j < rows; j++)
132 if (game.options & OPTION_CURSES) {
133 if (curwnd == message_window && linecount >= getmaxy(curwnd) - 3) {
138 if (curwnd == message_window)
143 if (linecount >= rows)
151 static void vproutn(char *fmt, va_list ap)
153 if (game.options & OPTION_CURSES) {
154 vwprintw(curwnd, fmt, ap);
161 void proutn(char *fmt, ...)
169 void prout(char *fmt, ...)
178 void prouts(char *fmt, ...)
181 char *s, buf[BUFSIZ];
184 vsprintf(buf, fmt, ap);
186 for (s = buf; *s; s++) {
188 if (game.options & OPTION_CURSES) {
199 void cgetline(char *line, int max)
201 if (game.options & OPTION_CURSES) {
202 wgetnstr(curwnd, line, max);
206 fgets(line, max, stdin);
210 line[strlen(line)-1] = '\0';
213 void setwnd(WINDOW *wnd)
214 /* change windows -- OK for this to be a no-op in tty mode */
216 if (game.options & OPTION_CURSES) {
218 curs_set(wnd == fullscreen_window || wnd == message_window || wnd == prompt_window);
223 /* clear to end of line -- can be a no-op in tty mode */
225 if (game.options & OPTION_CURSES) {
232 /* clear screen -- can be a no-op in tty mode */
234 if (game.options & OPTION_CURSES) {
242 void textcolor (int color)
245 if (game.options & OPTION_CURSES) {
251 wattron(curwnd, COLOR_PAIR(COLOR_BLACK));
254 wattron(curwnd, COLOR_PAIR(COLOR_BLUE));
257 wattron(curwnd, COLOR_PAIR(COLOR_GREEN));
260 wattron(curwnd, COLOR_PAIR(COLOR_CYAN));
263 wattron(curwnd, COLOR_PAIR(COLOR_RED));
266 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA));
269 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW));
272 wattron(curwnd, COLOR_PAIR(COLOR_WHITE));
275 wattron(curwnd, COLOR_PAIR(COLOR_BLACK) | A_BOLD);
278 wattron(curwnd, COLOR_PAIR(COLOR_BLUE) | A_BOLD);
281 wattron(curwnd, COLOR_PAIR(COLOR_GREEN) | A_BOLD);
284 wattron(curwnd, COLOR_PAIR(COLOR_CYAN) | A_BOLD);
287 wattron(curwnd, COLOR_PAIR(COLOR_RED) | A_BOLD);
290 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA) | A_BOLD);
293 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW) | A_BOLD);
296 wattron(curwnd, COLOR_PAIR(COLOR_WHITE) | A_BOLD);
303 void highvideo (void)
305 if (game.options & OPTION_CURSES) {
306 wattron(curwnd, A_REVERSE);
310 void commandhook(char *cmd, bool before) {
314 * Things past this point have policy implications.
317 void drawmaps(short l)
318 /* hook to be called after moving to redraw maps */
320 if (game.options & OPTION_CURSES) {
323 setwnd(srscan_window);
328 setwnd(report_window);
329 wclear(report_window);
330 wmove(report_window, 0, 0);
331 srscan(SCAN_NO_LEFTSIDE);
332 setwnd(lrscan_window);
333 wclear(lrscan_window);
334 wmove(lrscan_window, 0, 0);
341 static void put_srscan_sym(int x, int y, char sym)
343 wmove(srscan_window, x+1, y*2+2);
344 waddch(srscan_window, sym);
345 wrefresh(srscan_window);
348 void boom(int ii, int jj)
349 /* enemy fall down, go boom */
351 if (game.options & OPTION_CURSES) {
353 setwnd(srscan_window);
354 wattron(srscan_window, A_REVERSE);
355 put_srscan_sym(ii, jj, game.quad[ii][jj]);
359 wattroff(srscan_window, A_REVERSE);
360 put_srscan_sym(ii, jj, game.quad[ii][jj]);
362 setwnd(message_window);
367 /* sound and visual effects for teleportation */
369 if (game.options & OPTION_CURSES) {
371 setwnd(message_window);
374 prouts(" . . . . . ");
375 if (game.options & OPTION_CURSES) {
381 void tracktorpedo(int ix, int iy, int l, int i, int n, int iquad)
382 /* torpedo-track animation */
384 if (!game.options & OPTION_CURSES) {
388 proutn("Track for torpedo number %d- ", i);
392 proutn("Torpedo track- ");
394 } else if (l==4 || l==9)
396 proutn("%d - %d ", ix, iy);
398 if (game.damage[DSRSENS]==0 || game.condit==IHDOCKED) {
399 if (i != 1 && l == 1) {
403 if ((iquad==IHDOT)||(iquad==IHBLANK)){
404 put_srscan_sym(ix, iy, '+');
408 put_srscan_sym(ix, iy, iquad);
411 wattron(curwnd, A_REVERSE);
412 put_srscan_sym(ix, iy, iquad);
416 wattroff(curwnd, A_REVERSE);
417 put_srscan_sym(ix, iy, iquad);
420 proutn("%d - %d ", ix, iy);
427 if (game.options & OPTION_CURSES) {
428 setwnd(message_window);
429 wclear(message_window);
434 void setpassword(void)
436 if (!(game.options & OPTION_CURSES)) {
439 strcpy(game.passwd, citem);
441 if (*game.passwd != 0) break;
442 proutn("Please type in a secret password-");
446 for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));