void hallucinate(void) { object *obj, *monster; short ch; if (blind) { return; } obj = level_objects.next_object; while (obj) { ch = mvinch_rogue(obj->row, obj->col); if (((ch < 'A') || (ch > 'Z')) && ((obj->row != rogue.row) || (obj->col != rogue.col))) if ((ch != ' ') && (ch != '.') && (ch != '#') && (ch != '+')) { addch_rogue(gr_obj_char()); } obj = obj->next_object; } monster = level_monsters.next_monster; while (monster) { ch = mvinch_rogue(monster->row, monster->col); if ((ch >= 'A') && (ch <= 'Z')) { addch_rogue(get_rand('A', 'Z')); } monster = monster->next_monster; } }
void message(char *msg, boolean intrpt) { if (!save_is_interactive) { return; } if (intrpt) { interrupted = 1; } cant_int = 1; if (!msg_cleared) { mvaddstr_rogue(MIN_ROW - 1, msg_col, mesg[11]); refresh(); wait_for_ack(); check_message(); } (void) strcpy(msg_line, msg); mvaddstr_rogue(MIN_ROW - 1, 0, msg); addch_rogue(' '); refresh(); msg_cleared = 0; msg_col = strlen(msg); cant_int = 0; if (did_int) { did_int = 0; onintr(0); /* 「0」に意味はないが警告除去のために値を入れる。onintr関数を見直す必要がある。 */ } }
void pad(char *s, short n) { short i; for (i = strlen(s); i < n; i++) { addch_rogue(' '); } }
int do_input_line(boolean is_msg, int row, int col, char *prompt, char *insert, char *buf, char *if_cancelled, boolean add_blank, boolean do_echo, int first_ch) { short ch; short i = 0, n = 0; #if defined( JAPAN ) short k; char kanji[MAX_TITLE_LENGTH]; #endif /* JAPAN */ if (is_msg) { message(prompt, 0); n = strlen(prompt) + 1; } else { mvaddstr_rogue(row, col, prompt); } if (insert[0]) { mvaddstr_rogue(row, col + n, insert); (void) strcpy(buf, insert); i = strlen(insert); #if defined( JAPAN ) k = 0; while (k < i) { ch = insert[k]; #if defined( EUC ) if (ch & 0x80) { /* for EUC code by Yasha */ kanji[k] = kanji[k + 1] = 1; k += 2; } else { kanji[k] = 0; k++; } #else /* not EUC */ if (ch >= 0x81 && ch <= 0x9f || ch >= 0xe0 && ch <= 0xfc) { kanji[k] = kanji[k + 1] = 1; k += 2; } else { kanji[k] = 0; k++; } #endif /* not EUC */ } #endif /* JAPAN */ move(row, col + n + i); refresh(); } #if defined( JAPAN ) for (;;) { if (first_ch) { ch = first_ch; first_ch = 0; } else { ch = rgetchar(); } if (ch == '\r' || ch == '\n' || ch == CANCEL) { break; } if ((ch == '\b') && (i > 0)) { i -= kanji[i - 1] ? 2 : 1; if (do_echo) { mvaddstr_rogue(row, col + n + i, " "); move(row, col + n + i); } } else if ( #if defined( EUC ) (ch >= ' ' && !(ch & 0x80)) && (i < MAX_TITLE_LENGTH - 2) #else /* Shift JIS */ (ch >= ' ' && ch <= '~' || ch >= 0xa0 && ch <= 0xde) && (i < MAX_TITLE_LENGTH - 2) #endif /* not EUC */ ) { if ((ch != ' ') || (i > 0)) { buf[i] = ch; kanji[i] = 0; if (do_echo) { addch(ch); } i++; } } else if ( #if defined( EUC ) (ch & 0x80) && (i < MAX_TITLE_LENGTH - 3) #else /* Shift JIS */ (ch >= 0x81 && ch <= 0x9f || ch >= 0xe0 && ch <= 0xfc) && (i < MAX_TITLE_LENGTH - 3) #endif /* not EUC */ ) { buf[i] = ch; buf[i + 1] = rgetchar(); kanji[i] = kanji[i + 1] = 1; if (do_echo) { addch_rogue(buf[i]); addch_rogue(buf[i + 1]); } i += 2; } refresh(); } if (is_msg) { check_message(); } while ((i > 0) && (buf[i - 1] == ' ') && (kanji[i - 1] == 0)) { i--; } if (add_blank) { buf[i++] = ' '; } #else /* not JAPAN */ while (((ch = rgetchar()) != '\r') && (ch != '\n') && (ch != CANCEL)) { if ((ch >= ' ') && (ch <= '~') && (i < MAX_TITLE_LENGTH - 2)) { if ((ch != ' ') || (i > 0)) { buf[i++] = ch; if (do_echo) { addch_rogue(ch); } } } if ((ch == '\b') && (i > 0)) { i--; if (do_echo) { mvaddch_rogue(row, col + n + i, ' '); move(row, col + n + i); } } refresh(); } if (is_msg) { check_message(); } if (add_blank) { buf[i++] = ' '; } else { while ((i > 0) && (buf[i - 1] == ' ')) { i--; } } #endif /* not JAPAN */ buf[i] = 0; if ((ch == CANCEL) || (i == 0) || ((i == 1) && add_blank)) { if (is_msg && if_cancelled) { message(if_cancelled, 0); } return ((ch == CANCEL) ? -1 : 0); } return i; }
void inventory(object *pack, unsigned short mask) { object *obj; short i, j, maxlen, n; short row, col; char *p; char *msg = " =スペースを押してください="; short len = 30; if (!(obj = pack->next_object)) { message(mesg[26], 0); return; } #define Protected(obj) ((obj->what_is & ARMOR) && obj->is_protected) nextpage: i = 0; maxlen = len; while (obj && i < ROGUE_LINES - 2) { if (obj->what_is & mask) { p = descs[i]; *p++ = ' '; *p++ = obj->ichar; *p++ = Protected(obj) ? '}' : ')'; *p++ = ' '; get_desc(obj, p, 0); if ((n = strlen(descs[i])) > maxlen) { maxlen = n; } i++; } obj = obj->next_object; } (void) strcpy(descs[i++], msg); if (i == 0) { return; } col = ROGUE_COLUMNS - (maxlen + 2); for (row = 0; row < i; row++) { if (row > 0) { for (j = col; j < ROGUE_COLUMNS; j++) { descs[row - 1][j - col] = mvinch_rogue(row, j); } descs[row - 1][j - col] = 0; } mvaddstr_rogue(row, col, descs[row]); clrtoeol(); } refresh(); wait_for_ack(); move(0, 0); clrtoeol(); #if defined( COLOR ) for (j = 1; j < i; j++) { move(j, col); for (p = descs[j - 1]; *p; p++) { addch_rogue(*p); } } #else /* not COLOR */ for (j = 1; j < i; j++) { /* by Yasha */ move(j, col); /* by Yasha */ clrtoeol(); /* by Yasha */ addstr_rogue(descs[j - 1]); /* by Yasha */ } /* by Yasha */ move(ROGUE_LINES - 1, 0); /* by Yasha */ clrtoeol(); /* by Yasha */ print_stats(STAT_ALL); /* by Yasha */ #endif /* not COLOR */ if (obj) { goto nextpage; } }