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)
89 wgetch(prompt_window);
95 prouts(_("[ANNOUNCEMENT ARRIVING...]"));
99 static void pause_game(void)
103 if (game.skill > SKILL_FAIR)
104 prompt = _("[CONTINUE?]");
106 prompt = _("[PRESS ENTER TO CONTINUE]");
108 if (game.options & OPTION_CURSES) {
110 setwnd(prompt_window);
111 wclear(prompt_window);
112 waddstr(prompt_window, prompt);
113 wgetnstr(prompt_window, buf, sizeof(buf));
114 wclear(prompt_window);
115 wrefresh(prompt_window);
116 setwnd(message_window);
121 fgets(buf, sizeof(buf), stdin);
122 for (j = 0; j < rows; j++)
132 if (game.options & OPTION_CURSES) {
133 if (curwnd == message_window && getcury(curwnd) >= getmaxy(curwnd) - 3) {
141 if (linecount >= rows)
149 static void vproutn(const char *fmt, va_list ap)
151 if (game.options & OPTION_CURSES) {
152 vwprintw(curwnd, fmt, ap);
159 void proutn(const char *fmt, ...)
167 void prout(const char *fmt, ...)
176 void prouts(const char *fmt, ...)
180 wchar_t *s, mbuf[BUFSIZ];
183 vsprintf(buf, fmt, ap);
185 mbstowcs(mbuf, buf, BUFSIZ);
186 for (s = mbuf; *s; s++) {
187 /* HOW to convince ncurses to use wchar_t?? */
188 /* WHY putwchar() doesn't work?? */
189 /* OK then, convert back to mbs... */
190 char c[MB_CUR_MAX*2];
196 if (game.options & OPTION_CURSES)
204 void cgetline(char *line, int max)
206 if (game.options & OPTION_CURSES) {
207 wgetnstr(curwnd, line, max);
211 if (replayfp && !feof(replayfp))
212 (void)fgets(line, max, replayfp);
214 (void)fgets(line, max, stdin);
217 (void)fputs(line, logfp);
218 line[strlen(line)-1] = '\0';
221 void setwnd(WINDOW *wnd)
222 /* change windows -- OK for this to be a no-op in tty mode */
224 if (game.options & OPTION_CURSES) {
226 curs_set(wnd == fullscreen_window || wnd == message_window || wnd == prompt_window);
231 /* clear to end of line -- can be a no-op in tty mode */
233 if (game.options & OPTION_CURSES) {
240 /* clear screen -- can be a no-op in tty mode */
242 if (game.options & OPTION_CURSES) {
250 void textcolor(int color)
253 if (game.options & OPTION_CURSES) {
259 wattron(curwnd, COLOR_PAIR(COLOR_BLACK));
262 wattron(curwnd, COLOR_PAIR(COLOR_BLUE));
265 wattron(curwnd, COLOR_PAIR(COLOR_GREEN));
268 wattron(curwnd, COLOR_PAIR(COLOR_CYAN));
271 wattron(curwnd, COLOR_PAIR(COLOR_RED));
274 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA));
277 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW));
280 wattron(curwnd, COLOR_PAIR(COLOR_WHITE));
283 wattron(curwnd, COLOR_PAIR(COLOR_BLACK) | A_BOLD);
286 wattron(curwnd, COLOR_PAIR(COLOR_BLUE) | A_BOLD);
289 wattron(curwnd, COLOR_PAIR(COLOR_GREEN) | A_BOLD);
292 wattron(curwnd, COLOR_PAIR(COLOR_CYAN) | A_BOLD);
295 wattron(curwnd, COLOR_PAIR(COLOR_RED) | A_BOLD);
298 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA) | A_BOLD);
301 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW) | A_BOLD);
304 wattron(curwnd, COLOR_PAIR(COLOR_WHITE) | A_BOLD);
313 if (game.options & OPTION_CURSES) {
314 wattron(curwnd, A_REVERSE);
318 void commandhook(char *cmd, bool before) {
322 * Things past this point have policy implications.
325 void drawmaps(int mode)
326 /* hook to be called after moving to redraw maps */
328 if (game.options & OPTION_CURSES) {
331 setwnd(srscan_window);
335 setwnd(status_window);
336 wclear(status_window);
337 wmove(status_window, 0, 0);
338 setwnd(report_window);
339 wclear(report_window);
340 wmove(report_window, 0, 0);
342 setwnd(lrscan_window);
343 wclear(lrscan_window);
344 wmove(lrscan_window, 0, 0);
350 static void put_srscan_sym(coord w, char sym)
352 wmove(srscan_window, w.x+1, w.y*2+2);
353 waddch(srscan_window, sym);
354 wrefresh(srscan_window);
358 /* enemy fall down, go boom */
360 if (game.options & OPTION_CURSES) {
362 setwnd(srscan_window);
363 wattron(srscan_window, A_REVERSE);
364 put_srscan_sym(w, game.quad[w.x][w.y]);
368 wattroff(srscan_window, A_REVERSE);
369 put_srscan_sym(w, game.quad[w.x][w.y]);
371 setwnd(message_window);
376 /* sound and visual effects for teleportation */
378 if (game.options & OPTION_CURSES) {
380 setwnd(message_window);
383 prouts(" . . . . . ");
384 if (game.options & OPTION_CURSES) {
390 void tracktorpedo(coord w, int l, int i, int n, int iquad)
391 /* torpedo-track animation */
393 if (!(game.options & OPTION_CURSES)) {
397 proutn(_("Track for torpedo number %d- "), i);
401 proutn(_("Torpedo track- "));
403 } else if (l==4 || l==9)
405 proutn("%d - %d ", w.x, w.y);
407 if (!damaged(DSRSENS) || game.condition==docked) {
408 if (i != 1 && l == 1) {
412 if ((iquad==IHDOT)||(iquad==IHBLANK)){
413 put_srscan_sym(w, '+');
417 put_srscan_sym(w, iquad);
420 wattron(curwnd, A_REVERSE);
421 put_srscan_sym(w, iquad);
425 wattroff(curwnd, A_REVERSE);
426 put_srscan_sym(w, iquad);
429 proutn("%d - %d ", w.x, w.y);
436 if (game.options & OPTION_CURSES) {
437 setwnd(message_window);
438 wclear(message_window);
441 if (game.options & OPTION_TTY) {
446 void prstat(const char *txt, const char *fmt, ...)
452 if (game.options & OPTION_CURSES) {
455 for (i = mblen(txt, strlen(txt)); i < NSYM; i++)
458 if (game.options & OPTION_CURSES)
459 setwnd(status_window);
464 if (game.options & OPTION_CURSES)
465 setwnd(report_window);