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 if (replayfp && !feof(replayfp))
207 fgets(line, max, replayfp);
209 fgets(line, max, stdin);
213 line[strlen(line)-1] = '\0';
216 void setwnd(WINDOW *wnd)
217 /* change windows -- OK for this to be a no-op in tty mode */
219 if (game.options & OPTION_CURSES) {
221 curs_set(wnd == fullscreen_window || wnd == message_window || wnd == prompt_window);
226 /* clear to end of line -- can be a no-op in tty mode */
228 if (game.options & OPTION_CURSES) {
235 /* clear screen -- can be a no-op in tty mode */
237 if (game.options & OPTION_CURSES) {
245 void textcolor (int color)
248 if (game.options & OPTION_CURSES) {
254 wattron(curwnd, COLOR_PAIR(COLOR_BLACK));
257 wattron(curwnd, COLOR_PAIR(COLOR_BLUE));
260 wattron(curwnd, COLOR_PAIR(COLOR_GREEN));
263 wattron(curwnd, COLOR_PAIR(COLOR_CYAN));
266 wattron(curwnd, COLOR_PAIR(COLOR_RED));
269 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA));
272 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW));
275 wattron(curwnd, COLOR_PAIR(COLOR_WHITE));
278 wattron(curwnd, COLOR_PAIR(COLOR_BLACK) | A_BOLD);
281 wattron(curwnd, COLOR_PAIR(COLOR_BLUE) | A_BOLD);
284 wattron(curwnd, COLOR_PAIR(COLOR_GREEN) | A_BOLD);
287 wattron(curwnd, COLOR_PAIR(COLOR_CYAN) | A_BOLD);
290 wattron(curwnd, COLOR_PAIR(COLOR_RED) | A_BOLD);
293 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA) | A_BOLD);
296 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW) | A_BOLD);
299 wattron(curwnd, COLOR_PAIR(COLOR_WHITE) | A_BOLD);
306 void highvideo (void)
308 if (game.options & OPTION_CURSES) {
309 wattron(curwnd, A_REVERSE);
313 void commandhook(char *cmd, bool before) {
317 * Things past this point have policy implications.
320 void drawmaps(short l)
321 /* hook to be called after moving to redraw maps */
323 if (game.options & OPTION_CURSES) {
326 setwnd(srscan_window);
331 setwnd(report_window);
332 wclear(report_window);
333 wmove(report_window, 0, 0);
334 srscan(SCAN_NO_LEFTSIDE);
335 setwnd(lrscan_window);
336 wclear(lrscan_window);
337 wmove(lrscan_window, 0, 0);
344 static void put_srscan_sym(int x, int y, char sym)
346 wmove(srscan_window, x+1, y*2+2);
347 waddch(srscan_window, sym);
348 wrefresh(srscan_window);
351 void boom(int ii, int jj)
352 /* enemy fall down, go boom */
354 if (game.options & OPTION_CURSES) {
356 setwnd(srscan_window);
357 wattron(srscan_window, A_REVERSE);
358 put_srscan_sym(ii, jj, game.quad[ii][jj]);
362 wattroff(srscan_window, A_REVERSE);
363 put_srscan_sym(ii, jj, game.quad[ii][jj]);
365 setwnd(message_window);
370 /* sound and visual effects for teleportation */
372 if (game.options & OPTION_CURSES) {
374 setwnd(message_window);
377 prouts(" . . . . . ");
378 if (game.options & OPTION_CURSES) {
384 void tracktorpedo(int ix, int iy, int l, int i, int n, int iquad)
385 /* torpedo-track animation */
387 if (!game.options & OPTION_CURSES) {
391 proutn("Track for torpedo number %d- ", i);
395 proutn("Torpedo track- ");
397 } else if (l==4 || l==9)
399 proutn("%d - %d ", ix, iy);
401 if (game.damage[DSRSENS]==0 || game.condit==IHDOCKED) {
402 if (i != 1 && l == 1) {
406 if ((iquad==IHDOT)||(iquad==IHBLANK)){
407 put_srscan_sym(ix, iy, '+');
411 put_srscan_sym(ix, iy, iquad);
414 wattron(curwnd, A_REVERSE);
415 put_srscan_sym(ix, iy, iquad);
419 wattroff(curwnd, A_REVERSE);
420 put_srscan_sym(ix, iy, iquad);
423 proutn("%d - %d ", ix, iy);
430 if (game.options & OPTION_CURSES) {
431 setwnd(message_window);
432 wclear(message_window);
437 void setpassword(void)
439 if (!(game.options & OPTION_CURSES)) {
442 strcpy(game.passwd, citem);
444 if (*game.passwd != 0) break;
445 proutn("Please type in a secret password-");
449 for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));