9 static int rows, linecount; /* for paging */
12 WINDOW *fullscreen_window;
13 WINDOW *srscan_window;
14 WINDOW *report_window;
15 WINDOW *status_window;
16 WINDOW *lrscan_window;
17 WINDOW *message_window;
18 WINDOW *prompt_window;
20 static void outro(void)
21 /* wrap up, either normally or due to signal */
23 if (game.options & OPTION_CURSES) {
38 setlocale(LC_ALL, "");
39 bindtextdomain(PACKAGE, LOCALEDIR);
43 fprintf(stderr,"Unable to register outro(), exiting...\n");
46 if (!(game.options & OPTION_CURSES)) {
47 char *ln_env = getenv("LINES");
48 rows = ln_env ? atoi(ln_env) : 25;
60 init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK);
61 init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK);
62 init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK);
63 init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
64 init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK);
65 init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
66 init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK);
67 init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK);
71 fullscreen_window = stdscr;
72 srscan_window = newwin(12, 25, 0, 0);
73 report_window = newwin(11, 0, 1, 25);
74 status_window = newwin(10, 0, 1, 39);
75 lrscan_window = newwin(5, 0, 0, 64);
76 message_window = newwin(0, 0, 12, 0);
77 prompt_window = newwin(1, 0, LINES-2, 0);
78 scrollok(message_window, TRUE);
79 setwnd(fullscreen_window);
86 /* wait for user action -- OK to do nothing if on a TTY */
88 if (game.options & OPTION_CURSES)
95 if (game.skill > SKILL_FAIR)
96 prouts(_("[ANOUNCEMENT ARRIVING...]"));
98 prouts(_("[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]"));
102 static void pause_game(void)
106 if (game.skill > SKILL_FAIR)
107 prompt = _("[CONTINUE?]");
109 prompt = _("[PRESS ENTER TO CONTINUE]");
111 if (game.options & OPTION_CURSES) {
113 setwnd(prompt_window);
114 wclear(prompt_window);
115 waddstr(prompt_window, prompt);
116 wgetnstr(prompt_window, buf, sizeof(buf));
117 wclear(prompt_window);
118 wrefresh(prompt_window);
119 setwnd(message_window);
124 fgets(buf, sizeof(buf), stdin);
125 for (j = 0; j < rows; j++)
135 if (game.options & OPTION_CURSES) {
136 if (curwnd == message_window && getcury(curwnd) >= getmaxy(curwnd) - 3) {
144 if (linecount >= rows)
152 static void vproutn(const char *fmt, va_list ap)
154 if (game.options & OPTION_CURSES) {
155 vwprintw(curwnd, fmt, ap);
162 void proutn(const char *fmt, ...)
170 void prout(const char *fmt, ...)
179 void prouts(const char *fmt, ...)
183 wchar_t *s, mbuf[BUFSIZ];
186 vsprintf(buf, fmt, ap);
188 mbstowcs(mbuf, buf, BUFSIZ);
189 for (s = mbuf; *s; s++) {
190 /* HOW to convince ncurses to use wchar_t?? */
191 /* WHY putwchar() doesn't work?? */
192 /* OK then, convert back to mbs... */
193 char c[MB_CUR_MAX*2];
199 if (game.options & OPTION_CURSES)
207 void cgetline(char *line, int max)
209 if (game.options & OPTION_CURSES) {
210 wgetnstr(curwnd, line, max);
214 if (replayfp && !feof(replayfp))
215 fgets(line, max, replayfp);
217 fgets(line, max, stdin);
221 line[strlen(line)-1] = '\0';
224 void setwnd(WINDOW *wnd)
225 /* change windows -- OK for this to be a no-op in tty mode */
227 if (game.options & OPTION_CURSES) {
229 curs_set(wnd == fullscreen_window || wnd == message_window || wnd == prompt_window);
234 /* clear to end of line -- can be a no-op in tty mode */
236 if (game.options & OPTION_CURSES) {
243 /* clear screen -- can be a no-op in tty mode */
245 if (game.options & OPTION_CURSES) {
253 void textcolor(int color)
256 if (game.options & OPTION_CURSES) {
262 wattron(curwnd, COLOR_PAIR(COLOR_BLACK));
265 wattron(curwnd, COLOR_PAIR(COLOR_BLUE));
268 wattron(curwnd, COLOR_PAIR(COLOR_GREEN));
271 wattron(curwnd, COLOR_PAIR(COLOR_CYAN));
274 wattron(curwnd, COLOR_PAIR(COLOR_RED));
277 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA));
280 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW));
283 wattron(curwnd, COLOR_PAIR(COLOR_WHITE));
286 wattron(curwnd, COLOR_PAIR(COLOR_BLACK) | A_BOLD);
289 wattron(curwnd, COLOR_PAIR(COLOR_BLUE) | A_BOLD);
292 wattron(curwnd, COLOR_PAIR(COLOR_GREEN) | A_BOLD);
295 wattron(curwnd, COLOR_PAIR(COLOR_CYAN) | A_BOLD);
298 wattron(curwnd, COLOR_PAIR(COLOR_RED) | A_BOLD);
301 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA) | A_BOLD);
304 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW) | A_BOLD);
307 wattron(curwnd, COLOR_PAIR(COLOR_WHITE) | A_BOLD);
316 if (game.options & OPTION_CURSES) {
317 wattron(curwnd, A_REVERSE);
321 void commandhook(char *cmd, bool before) {
325 * Things past this point have policy implications.
328 void drawmaps(int mode)
329 /* hook to be called after moving to redraw maps */
331 if (game.options & OPTION_CURSES) {
334 setwnd(srscan_window);
338 setwnd(status_window);
339 wclear(status_window);
340 wmove(status_window, 0, 0);
341 setwnd(report_window);
342 wclear(report_window);
343 wmove(report_window, 0, 0);
345 setwnd(lrscan_window);
346 wclear(lrscan_window);
347 wmove(lrscan_window, 0, 0);
353 static void put_srscan_sym(coord w, char sym)
355 wmove(srscan_window, w.x+1, w.y*2+2);
356 waddch(srscan_window, sym);
357 wrefresh(srscan_window);
361 /* enemy fall down, go boom */
363 if (game.options & OPTION_CURSES) {
365 setwnd(srscan_window);
366 wattron(srscan_window, A_REVERSE);
367 put_srscan_sym(w, game.quad[w.x][w.y]);
371 wattroff(srscan_window, A_REVERSE);
372 put_srscan_sym(w, game.quad[w.x][w.y]);
374 setwnd(message_window);
379 /* sound and visual effects for teleportation */
381 if (game.options & OPTION_CURSES) {
383 setwnd(message_window);
386 prouts(" . . . . . ");
387 if (game.options & OPTION_CURSES) {
393 void tracktorpedo(coord w, int l, int i, int n, int iquad)
394 /* torpedo-track animation */
396 if (!game.options & OPTION_CURSES) {
400 proutn(_("Track for torpedo number %d- "), i);
404 proutn(_("Torpedo track- "));
406 } else if (l==4 || l==9)
408 proutn("%d - %d ", w.x, w.y);
410 if (!damaged(DSRSENS) || game.condition==docked) {
411 if (i != 1 && l == 1) {
415 if ((iquad==IHDOT)||(iquad==IHBLANK)){
416 put_srscan_sym(w, '+');
420 put_srscan_sym(w, iquad);
423 wattron(curwnd, A_REVERSE);
424 put_srscan_sym(w, iquad);
428 wattroff(curwnd, A_REVERSE);
429 put_srscan_sym(w, iquad);
432 proutn("%d - %d ", w.x, w.y);
439 if (game.options & OPTION_CURSES) {
440 setwnd(message_window);
441 wclear(message_window);
444 if (game.options & OPTION_TTY) {
449 void prstat(const char *txt, const char *fmt, ...)
455 if (game.options & OPTION_CURSES) {
458 for (i = mblen(txt, strlen(txt)); i < NSYM; i++)
461 if (game.options & OPTION_CURSES)
462 setwnd(status_window);
467 if (game.options & OPTION_CURSES)
468 setwnd(report_window);