int curses_get_mouse(int *mousex, int *mousey, int *mod) { int key = '\033'; #ifdef NCURSES_MOUSE_VERSION MEVENT event; if (getmouse(&event) == OK) { /* When the user clicks left mouse button */ if(event.bstate & BUTTON1_CLICKED) { /* See if coords are in map window & convert coords */ if (wmouse_trafo(mapwin, &event.y, &event.x, TRUE)) { key = 0; /* Flag mouse click */ *mousex = event.x; *mousey = event.y; if (curses_window_has_border(MAP_WIN)) { (*mousex)--; (*mousey)--; } *mod = CLICK_1; } } } #endif /* NCURSES_MOUSE_VERSION */ return key; }
static void refresh_map_window() { int mapwinx, mapwiny, maph, mapw, mapwinw, mapwinh, mapx, mapy; WINDOW *map_window = curses_get_nhwin(MAP_WIN); boolean border = curses_window_has_border(MAP_WIN); curses_get_window_xy(MAP_WIN, &mapwinx, &mapwiny); curses_get_window_size(MAP_WIN, &mapwinh, &mapwinw); maph = ROWNO; mapw = COLNO; mapx = u.ux - (mapwinw / 2); if ((mapx + mapwinw) > mapw) { mapx = mapw - mapwinw; } if (mapx < 0) { mapx = 0; } mapy = u.uy - (mapwinh / 2); if ((mapy + mapwinh) > maph) { mapy = maph - mapwinh; } if (mapy < 0) { mapy = 0; } prefresh(map_window, mapy, mapx, mapwiny, mapwinx, mapwiny + mapwinh - 1, mapwinx + mapwinw - 1); }
void curses_putch(winid wid, int x, int y, int ch, int color, int attr) { WINDOW *win; boolean border = curses_window_has_border(wid); if (border && (wid != MAP_WIN)) { x++; y++; } win = curses_get_nhwin(wid); curses_toggle_color_attr(win, color, attr, ON); #ifdef PDCURSES mvwaddrawch(win, y, x, ch); #else mvwaddch(win, y, x, ch); #endif if (wid == MAP_WIN) { refresh_map_window(); } else { wrefresh(win); } curses_toggle_color_attr(win, color, attr, OFF); }
void curses_last_messages() { boolean border = curses_window_has_border(MESSAGE_WIN); if (border) { mx = 1; my = 1; } else { mx = 0; my = 0; } pline("%s", toplines); }
void curses_clear_nhwin(winid wid) { WINDOW *win = curses_get_nhwin(wid); boolean border = curses_window_has_border(wid); werase(win); if (border && (wid != MAP_WIN)) box(win, 0, 0); if (wid != MAP_WIN) { wrefresh(win); } else { refresh_map_window(); } }
void curses_clear_nhwin(winid wid) { WINDOW *win = curses_get_nhwin(wid); boolean border = curses_window_has_border(wid); if (wid == MAP_WIN) { clearok(win, TRUE); /* Redraw entire screen when refreshed */ clear_map(); } werase(win); if (border) { box(win, 0, 0); } }
void curses_clear_unhighlight_message_window() { int mh, mw, count; boolean border = curses_window_has_border(MESSAGE_WIN); WINDOW *win = curses_get_nhwin(MESSAGE_WIN); turn_lines = 1; curses_get_window_size(MESSAGE_WIN, &mh, &mw); mx = 0; if (border) { mx++; } if (mh == 1) { curses_clear_nhwin(MESSAGE_WIN); } else { mx += mw; /* Force new line on new turn */ if (border) { for (count = 0; count < mh; count++) { mvwchgat(win, count+1, 1, mw, COLOR_PAIR(8), A_NORMAL, NULL); } } else { for (count = 0; count < mh; count++) { mvwchgat(win, count, 0, mw, COLOR_PAIR(8), A_NORMAL, NULL); } } wrefresh(win); } }
void curses_putch(winid wid, int x, int y, int ch, int color, int attr) { int sx, sy, ex, ey; boolean border = curses_window_has_border(wid); nethack_char nch; static boolean map_initted = FALSE; if (wid == STATUS_WIN) { curses_update_stats(FALSE); } if (wid != MAP_WIN) { return; } if (!map_initted) { clear_map(); map_initted = TRUE; } map[y][x].ch = ch; map[y][x].color = color; map[y][x].attr = attr; nch = map[y][x]; (void)curses_map_borders(&sx, &sy, &ex, &ey, -1, -1); if ((x >= sx) && (x <= ex) && (y >= sy) && (y <= ey)) { if (border) { x++; y++; } write_wchar(mapwin, x - sx, y - sy, nch); } wrefresh(mapwin); }
void curses_move_cursor(winid wid, int x, int y) { int sx, sy, ex, ey; int xadj = 0; int yadj = 0; #ifndef PDCURSES WINDOW *win = curses_get_nhwin(MAP_WIN); #endif if (wid != MAP_WIN) { return; } #ifdef PDCURSES /* PDCurses seems to not handle wmove correctly, so we use move and physical screen coordinates instead */ curses_get_window_xy(wid, &xadj, &yadj); #endif curs_x = x + xadj; curs_y = y + yadj; curses_map_borders(&sx, &sy, &ex, &ey, x, y); if (curses_window_has_border(wid)) { curs_x++; curs_y++; } if ((x >= sx) && (x <= ex) && (y >= sy) && (y <= ey)) { curs_x -= sx; curs_y -= sy; #ifdef PDCURSES move(curs_y, curs_x); #else wmove(win, curs_y, curs_x); #endif } }
static void scroll_window(winid wid) { int wh, ww, s_top, s_bottom; boolean border = curses_window_has_border(wid); WINDOW *win = curses_get_nhwin(wid); curses_get_window_size(wid, &wh, &ww); if (wh == 1) { curses_clear_nhwin(wid); return; } if (border) { s_top = 1; s_bottom = wh; } else { s_top = 0; s_bottom = wh - 1; } scrollok(win, TRUE); wsetscrreg(win, s_top, s_bottom); scroll(win); scrollok(win, FALSE); if (wid == MESSAGE_WIN) { if (border) mx = 1; else mx = 0; } if (border) { box(win, 0, 0); } wrefresh(win); }
WINDOW *curses_create_window(int width, int height, orient orientation) { int mapx, mapy, maph, mapw = 0; int startx = 0; int starty = 0; WINDOW *win; boolean map_border = FALSE; int mapb_offset = 0; if ((orientation == UP) || (orientation == DOWN) || (orientation == LEFT) || (orientation == RIGHT)) { if (invent || (moves > 1)) { map_border = curses_window_has_border(MAP_WIN); curses_get_window_xy(MAP_WIN, &mapx, &mapy); curses_get_window_size(MAP_WIN, &maph, &mapw); } else { map_border = TRUE; mapx = 0; mapy = 0; maph = term_rows; mapw = term_cols; } } if (map_border) { mapb_offset = 1; } width += 2; /* leave room for bounding box */ height += 2; if ((width > term_cols) || (height > term_rows)) panic("curses_create_window: Terminal too small for dialog window"); switch (orientation) { case CENTER: { startx = (term_cols / 2) - (width / 2); starty = (term_rows / 2) - (height / 2); break; } case UP: { if (invent || (moves > 1)) { startx = (mapw / 2) - (width / 2) + mapx + mapb_offset; } else { startx = 0; } starty = mapy + mapb_offset; break; } case DOWN: { if (invent || (moves > 1)) { startx = (mapw / 2) - (width / 2) + mapx + mapb_offset; } else { startx = 0; } starty = height - mapy - 1 - mapb_offset; break; } case LEFT: { if (map_border && (width < term_cols)) startx = 1; else startx = 0; starty = term_rows - height; break; } case RIGHT: { if (invent || (moves > 1)) { startx = (mapw + mapx + (mapb_offset * 2)) - width; } else { startx = term_cols - width; } starty = 0; break; } default: { panic("curses_create_window: Bad orientation"); } } if (startx < 0) { startx = 0; } if (starty < 0) { starty = 0; } win = newwin(height, width, starty, startx); curses_toggle_color_attr(win, DIALOG_BORDER_COLOR, NONE, ON); box(win, 0, 0); curses_toggle_color_attr(win, DIALOG_BORDER_COLOR, NONE, OFF); return win; }
void curses_message_win_puts(const char *message, boolean recursed) { int height, width, linespace, count; char *tmpstr; WINDOW *win = curses_get_nhwin(MESSAGE_WIN); boolean border = curses_window_has_border(MESSAGE_WIN); int message_length = strlen(message); int border_space = 0; if (!recursed) { strcpy(toplines, message); mesg_add_line((char *) message); } curses_get_window_size(MESSAGE_WIN, &height, &width); if (border) { border_space = 1; if (mx < 1) { mx = 1; } if (my < 1) { my = 1; } } linespace = ((width + border_space) - 3) - mx; if (linespace < message_length) { if (my >= (height - 1 + border_space)) /* bottom of message win */ { if (turn_lines == height) { curses_more(); } else { scroll_window(MESSAGE_WIN); turn_lines++; } } else { if (mx != border_space) { my++; mx = border_space; } } } if (height > 1) { curses_toggle_color_attr(win, NONE, ATR_BOLD, ON); } if ((mx == border_space) && ((message_length + 2) > width)) { tmpstr = curses_break_str(message, (width - 2), 1); mvwprintw(win, my, mx, tmpstr); mx += strlen(tmpstr); free(tmpstr); if (height > 1) { curses_toggle_color_attr(win, NONE, ATR_BOLD, OFF); } wrefresh(win); curses_message_win_puts(curses_str_remainder(message, (width - 2), 1), TRUE); } else { mvwprintw(win, my, mx, message); curses_toggle_color_attr(win, NONE, ATR_BOLD, OFF); } wrefresh(win); mx += message_length + 1; }
void curses_count_window(const char *count_text) { int startx, starty, winx, winy; int messageh, messagew; static WINDOW *countwin = NULL; if ((count_text == NULL) && (countwin != NULL)) { delwin(countwin); countwin = NULL; counting = FALSE; return; } counting = TRUE; if (iflags.wc_popup_dialog) /* Display count in popup window */ { startx = 1; starty = 1; if (countwin == NULL) { countwin = curses_create_window(25, 1, UP); } } else /* Display count at bottom of message window */ { curses_get_window_xy(MESSAGE_WIN, &winx, &winy); curses_get_window_size(MESSAGE_WIN, &messageh, &messagew); if (curses_window_has_border(MESSAGE_WIN)) { winx++; winy++; } winy += messageh - 1; if (countwin == NULL) { pline("#"); #ifndef PDCURSES countwin = newwin(1, 25, winy, winx); #endif /* !PDCURSES */ } #ifdef PDCURSES else { curses_destroy_win(countwin); } countwin = newwin(1, 25, winy, winx); #endif /* PDCURSES */ startx = 0; starty = 0; } mvwprintw(countwin, starty, startx, "%s", count_text); wrefresh(countwin); }
void curses_draw_map(int sx, int sy, int ex, int ey) { int curx, cury; int bspace = 0; #ifdef MAP_SCROLLBARS int sbsx, sbsy, sbex, sbey, count; nethack_char hsb_back, hsb_bar, vsb_back, vsb_bar; #endif if (curses_window_has_border(MAP_WIN)) { bspace++; } #ifdef MAP_SCROLLBARS hsb_back.ch = '-'; hsb_back.color = SCROLLBAR_BACK_COLOR; hsb_back.attr = A_NORMAL; hsb_bar.ch = '*'; hsb_bar.color = SCROLLBAR_COLOR; hsb_bar.attr = A_NORMAL; vsb_back.ch = '|'; vsb_back.color = SCROLLBAR_BACK_COLOR; vsb_back.attr = A_NORMAL; vsb_bar.ch = '*'; vsb_bar.color = SCROLLBAR_COLOR; vsb_bar.attr = A_NORMAL; /* Horizontal scrollbar */ if ((sx > 0) || (ex < (COLNO - 1))) { sbsx = (sx * ((float)(ex - sx + 1) / COLNO)); sbex = (ex * ((float)(ex - sx + 1) / COLNO)); for (count = 0; count < sbsx; count++) { write_char(mapwin, count + bspace, ey - sy + 1 + bspace, hsb_back); } for (count = sbsx; count <= sbex; count++) { write_char(mapwin, count + bspace, ey - sy + 1 + bspace, hsb_bar); } for (count = sbex + 1; count <= (ex - sx); count++) { write_char(mapwin, count + bspace, ey - sy + 1 + bspace, hsb_back); } } /* Vertical scrollbar */ if ((sy > 0) || (ey < (ROWNO - 1))) { sbsy = (sy * ((float)(ey - sy + 1) / ROWNO)); sbey = (ey * ((float)(ey - sy + 1) / ROWNO)); for (count = 0; count < sbsy; count++) { write_char(mapwin, ex - sx + 1 + bspace, count + bspace, vsb_back); } for (count = sbsy; count <= sbey; count++) { write_char(mapwin, ex - sx + 1 + bspace, count + bspace, vsb_bar); } for (count = sbey + 1; count <= (ey - sy); count++) { write_char(mapwin, ex - sx + 1 + bspace, count + bspace, vsb_back); } } #endif /* MAP_SCROLLBARS */ for (curx = sx; curx <= ex; curx++) { for (cury = sy; cury <= ey; cury++) { write_char(mapwin, curx - sx + bspace, cury - sy + bspace, map[cury][curx]); } } }
void curses_message_win_puts(const char *message, boolean recursed) { int height, width, linespace; char *tmpstr; WINDOW *win = curses_get_nhwin(MESSAGE_WIN); boolean border = curses_window_has_border(MESSAGE_WIN); int message_length = strlen(message); int border_space = 0; static long suppress_turn = -1; if (strncmp("Count:", message, 6) == 0) { curses_count_window(message); return; } if (suppress_turn == moves) { return; } curses_get_window_size(MESSAGE_WIN, &height, &width); if (border) { border_space = 1; if (mx < 1) { mx = 1; } if (my < 1) { my = 1; } } linespace = ((width + border_space) - 3) - mx; if (strcmp(message, "#") == 0) /* Extended command or Count: */ { if ((strcmp(toplines, "#") != 0) && (my >= (height - 1 + border_space)) && (height != 1)) /* Bottom of message window */ { scroll_window(MESSAGE_WIN); mx = width; my--; strcpy(toplines, message); } return; } if (!recursed) { strcpy(toplines, message); mesg_add_line((char *) message); } if (linespace < message_length) { if (my >= (height - 1 + border_space)) /* bottom of message win */ { if ((turn_lines > height) || (height == 1)) { /* Pause until key is hit - Esc suppresses any further messages that turn */ if (curses_more() == '\033') { suppress_turn = moves; return; } } else { scroll_window(MESSAGE_WIN); turn_lines++; } } else { if (mx != border_space) { my++; mx = border_space; } } } if (height > 1) { curses_toggle_color_attr(win, NONE, A_BOLD, ON); } if ((mx == border_space) && ((message_length + 2) > width)) { tmpstr = curses_break_str(message, (width - 2), 1); mvwprintw(win, my, mx, "%s", tmpstr); mx += strlen(tmpstr); if (strlen(tmpstr) < (width - 2)) { mx++; } free(tmpstr); if (height > 1) { curses_toggle_color_attr(win, NONE, A_BOLD, OFF); } wrefresh(win); curses_message_win_puts(curses_str_remainder(message, (width - 2), 1), TRUE); } else { mvwprintw(win, my, mx, "%s", message); curses_toggle_color_attr(win, NONE, A_BOLD, OFF); mx += message_length + 1; } wrefresh(win); }
int curses_ext_cmd() { int count, letter, prompt_width, startx, starty, winx, winy; int messageh, messagew; int ret = -1; char cur_choice[BUFSZ]; int matches = 0; WINDOW *extwin = NULL; if (iflags.extmenu) { return extcmd_via_menu(); } if (iflags.wc_popup_dialog) /* Prompt in popup window */ { startx = 1; starty = 1; extwin = curses_create_window(25, 1, UP); } else { curses_get_window_xy(MESSAGE_WIN, &winx, &winy); curses_get_window_size(MESSAGE_WIN, &messageh, &messagew); if (curses_window_has_border(MESSAGE_WIN)) { winx++; winy++; } winy += messageh - 1; extwin = newwin(1, 25, winy, winx); startx = 0; starty = 0; pline("#"); } cur_choice[0] = '\0'; while (1) { wmove(extwin, starty, startx); waddstr(extwin, "# "); wmove(extwin, starty, startx + 2); curses_toggle_color_attr(extwin, NONE, A_UNDERLINE, ON); waddstr(extwin, cur_choice); curses_toggle_color_attr(extwin, NONE, A_UNDERLINE, OFF); wmove(extwin, starty, strlen(cur_choice) + startx + 2); wprintw(extwin, " ", cur_choice); if (matches == 1) { wmove(extwin, starty, strlen(cur_choice) + startx + 2); wprintw(extwin, "%s ", extcmdlist[ret].ef_txt + strlen(cur_choice)); } wrefresh(extwin); letter = getch(); prompt_width = strlen(cur_choice); matches = 0; if (letter == '\033') { ret = -1; break; } if ((letter == '\r') || (letter == '\n')) { break; } if ((letter == '\b') || (letter == KEY_BACKSPACE)) { if (prompt_width == 0) { ret = -1; break; } else { cur_choice[prompt_width - 1] = '\0'; letter = '*'; prompt_width--; } } for (count = 0; extcmdlist[count].ef_txt; count++) { if (strlen(extcmdlist[count].ef_txt) > prompt_width) { if (strncasecmp(cur_choice, extcmdlist[count].ef_txt, prompt_width) == 0) { if ((extcmdlist[count].ef_txt[prompt_width] == lowc(letter)) || letter == '*') { if ((matches == 0) && (letter != '*')) { ret = count; cur_choice[prompt_width] = letter; cur_choice[prompt_width + 1] = '\0'; } matches++; } } } } } curses_destroy_win(extwin); return ret; }
void curses_update_stats() { char buf[BUFSZ]; int count, enc, orient, sx_start; WINDOW *win = curses_get_nhwin(STATUS_WIN); static boolean first = TRUE; boolean horiz; int sx = 0; int sy = 0; boolean border = curses_window_has_border(STATUS_WIN); if (border) { sx++; sy++; } sx_start = sx; if (first) { init_stats(); first = FALSE; } orient = curses_get_window_orientation(STATUS_WIN); if ((orient == ALIGN_RIGHT) || (orient == ALIGN_LEFT)) { horiz = FALSE; } else { horiz = TRUE; } curses_clear_nhwin(STATUS_WIN); /* Line 1 */ /* Player name and title */ strcpy(buf, plname); if ('a' <= buf[0] && buf[0] <= 'z') buf[0] += 'A'-'a'; strcat(buf, " the "); if (u.mtimedone) { char mname[BUFSZ]; int k = 0; strcpy(mname, mons[u.umonnum].mname); while(mname[k] != 0) { if ((k == 0 || (k > 0 && mname[k-1] == ' ')) && 'a' <= mname[k] && mname[k] <= 'z') { mname[k] += 'A' - 'a'; } k++; } strcat(buf, mname); } else { strcat(buf, rank_of(u.ulevel, pl_character[0], flags.female)); } if (strcmp(buf, prevname.txt) != 0) /* Title changed */ { prevname.highlight_turns = 5; prevname.highlight_color = HIGHLIGHT_COLOR; free(prevname.txt); prevname.txt = curses_copy_of(buf); } if (prevname.label != NULL) { mvwaddstr(win, sy, sx, prevname.label); sx += strlen(prevname.label); } if (prevname.highlight_turns > 0) { curses_toggle_color_attr(win, prevname.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevname.txt); curses_toggle_color_attr(win, prevname.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevname.txt); } if (horiz) { sx += strlen(prevname.txt) + 1; } else { sx = sx_start; sy++; } /* Strength */ if (ACURR(A_STR) != prevstr.value) /* Strength changed */ { if (ACURR(A_STR) > prevstr.value) { prevstr.highlight_color = STAT_UP_COLOR; } else { prevstr.highlight_color = STAT_DOWN_COLOR; } prevstr.value = ACURR(A_STR); if (ACURR(A_STR) > 118) { sprintf(buf, "%d", ACURR(A_STR) - 100); } else if (ACURR(A_STR)==118) { sprintf(buf, "18/**"); } else if(ACURR(A_STR) > 18) { sprintf(buf, "18/%02d", ACURR(A_STR) - 18); } else { sprintf(buf, "%d", ACURR(A_STR)); } free(prevstr.txt); prevstr.txt = curses_copy_of(buf); prevstr.highlight_turns = 5; } if (prevstr.label != NULL) { mvwaddstr(win, sy, sx, prevstr.label); sx += strlen(prevstr.label); } if (prevstr.highlight_turns > 0) { curses_toggle_color_attr(win, prevstr.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevstr.txt); curses_toggle_color_attr(win, prevstr.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevstr.txt); } if (horiz) { sx += strlen(prevstr.txt) + 1; } else { sx = sx_start; sy++; } /* Intelligence */ if (ACURR(A_INT) != prevint.value) /* Intelligence changed */ { if (ACURR(A_INT) > prevint.value) { prevint.highlight_color = STAT_UP_COLOR; } else { prevint.highlight_color = STAT_DOWN_COLOR; } prevint.value = ACURR(A_INT); sprintf(buf, "%d", ACURR(A_INT)); free(prevint.txt); prevint.txt = curses_copy_of(buf); prevint.highlight_turns = 5; } if (prevint.label != NULL) { mvwaddstr(win, sy, sx, prevint.label); sx += strlen(prevint.label); } if (prevint.highlight_turns > 0) { curses_toggle_color_attr(win, prevint.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevint.txt); curses_toggle_color_attr(win, prevint.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevint.txt); } if (horiz) { sx += strlen(prevint.txt) + 1; } else { sx = sx_start; sy++; } /* Wisdom */ if (ACURR(A_WIS) != prevwis.value) /* Wisdom changed */ { if (ACURR(A_WIS) > prevwis.value) { prevwis.highlight_color = STAT_UP_COLOR; } else { prevwis.highlight_color = STAT_DOWN_COLOR; } prevwis.value = ACURR(A_WIS); sprintf(buf, "%d", ACURR(A_WIS)); free(prevwis.txt); prevwis.txt = curses_copy_of(buf); prevwis.highlight_turns = 5; } if (prevwis.label != NULL) { mvwaddstr(win, sy, sx, prevwis.label); sx += strlen(prevwis.label); } if (prevwis.highlight_turns > 0) { curses_toggle_color_attr(win, prevwis.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevwis.txt); curses_toggle_color_attr(win, prevwis.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevwis.txt); } if (horiz) { sx += strlen(prevwis.txt) + 1; } else { sx = sx_start; sy++; } /* Dexterity */ if (ACURR(A_DEX) != prevdex.value) /* Dexterity changed */ { if (ACURR(A_DEX) > prevdex.value) { prevdex.highlight_color = STAT_UP_COLOR; } else { prevdex.highlight_color = STAT_DOWN_COLOR; } prevdex.value = ACURR(A_DEX); sprintf(buf, "%d", ACURR(A_DEX)); free(prevdex.txt); prevdex.txt = curses_copy_of(buf); prevdex.highlight_turns = 5; } if (prevdex.label != NULL) { mvwaddstr(win, sy, sx, prevdex.label); sx += strlen(prevdex.label); } if (prevdex.highlight_turns > 0) { curses_toggle_color_attr(win, prevdex.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevdex.txt); curses_toggle_color_attr(win, prevdex.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevdex.txt); } if (horiz) { sx += strlen(prevdex.txt) + 1; } else { sx = sx_start; sy++; } /* Constitution */ if (ACURR(A_CON) != prevcon.value) /* Constitution changed */ { if (ACURR(A_CON) > prevcon.value) { prevcon.highlight_color = STAT_UP_COLOR; } else { prevcon.highlight_color = STAT_DOWN_COLOR; } prevcon.value = ACURR(A_CON); sprintf(buf, "%d", ACURR(A_CON)); free(prevcon.txt); prevcon.txt = curses_copy_of(buf); prevcon.highlight_turns = 5; } if (prevcon.label != NULL) { mvwaddstr(win, sy, sx, prevcon.label); sx += strlen(prevcon.label); } if (prevcon.highlight_turns > 0) { curses_toggle_color_attr(win, prevcon.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevcon.txt); curses_toggle_color_attr(win, prevcon.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevcon.txt); } if (horiz) { sx += strlen(prevcon.txt) + 1; } else { sx = sx_start; sy++; } /* Charisma */ if (ACURR(A_CHA) != prevcha.value) /* Charisma changed */ { if (ACURR(A_CHA) > prevcha.value) { prevcha.highlight_color = STAT_UP_COLOR; } else { prevcha.highlight_color = STAT_DOWN_COLOR; } prevcha.value = ACURR(A_CHA); sprintf(buf, "%d", ACURR(A_CHA)); free(prevcha.txt); prevcha.txt = curses_copy_of(buf); prevcha.highlight_turns = 5; } if (prevcha.label != NULL) { mvwaddstr(win, sy, sx, prevcha.label); sx += strlen(prevcha.label); } if (prevcha.highlight_turns > 0) { curses_toggle_color_attr(win, prevcha.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevcha.txt); curses_toggle_color_attr(win, prevcha.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevcha.txt); } if (horiz) { sx += strlen(prevcha.txt) + 1; } else { sx = sx_start; sy++; } /* Alignment */ if (prevalign.alignment != u.ualign.type) /* Alignment changed */ { prevalign.highlight_color = HIGHLIGHT_COLOR; prevalign.highlight_turns = 10; /* This is a major change! */ prevalign.alignment = u.ualign.type; free(prevalign.txt); switch (u.ualign.type) { case A_LAWFUL: { prevalign.txt = curses_copy_of("Lawful"); break; } case A_NEUTRAL: { prevalign.txt = curses_copy_of("Neutral"); break; } case A_CHAOTIC: { prevalign.txt = curses_copy_of("Chaotic"); break; } } } if (prevalign.label != NULL) { mvwaddstr(win, sy, sx, prevalign.label); sx += strlen(prevalign.label); } if (prevalign.highlight_turns > 0) { curses_toggle_color_attr(win, prevalign.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevalign.txt); curses_toggle_color_attr(win, prevalign.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevalign.txt); } /* Line 2 */ sx = sx_start; sy++; /* Dungeon Level */ if (depth(&u.uz) != prevdepth.value) /* Dungeon level changed */ { prevdepth.highlight_color = HIGHLIGHT_COLOR; prevdepth.highlight_turns = 5; prevdepth.value = depth(&u.uz); free(prevdepth.txt); if (In_endgame(&u.uz)) { strcpy(buf, (Is_astralevel(&u.uz) ? "Astral Plane":"End Game")); } else { sprintf(buf, "%d", depth(&u.uz)); } prevdepth.txt = curses_copy_of(buf); } if (prevdepth.label != NULL) { mvwaddstr(win, sy, sx, prevdepth.label); sx += strlen(prevdepth.label); } if (prevdepth.highlight_turns > 0) { curses_toggle_color_attr(win, prevdepth.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevdepth.txt); curses_toggle_color_attr(win, prevdepth.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevdepth.txt); } if (horiz) { sx += strlen(prevdepth.txt) + 1; } else { sx = sx_start; sy++; } /* Gold */ #ifndef GOLDOBJ if (prevau.value != u.ugold) /* Gold changed */ { if (u.ugold > prevau.value) { #else if (prevau.value != money_cnt(invent)) /* Gold changed */ { if (money_cnt(invent) > prevau.value) { #endif prevau.highlight_color = HI_GOLD; } else { prevau.highlight_color = STAT_DOWN_COLOR; } #ifndef GOLDOBJ prevau.value = u.ugold; sprintf(buf,"%ld", u.ugold); #else prevau.value = money_cnt(invent); sprintf(buf,"%ld", money_cnt(invent)); #endif free(prevau.txt); prevau.txt = curses_copy_of(buf); prevau.highlight_turns = 5; } if (prevau.label != NULL) { mvwaddstr(win, sy, sx, prevau.label); sx += strlen(prevau.label); } if (prevau.highlight_turns > 0) { curses_toggle_color_attr(win, prevau.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevau.txt); curses_toggle_color_attr(win, prevau.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevau.txt); } if (horiz) { sx += strlen(prevau.txt) + 1; } else { sx = sx_start; sy++; } /* Hit Points */ if (u.mtimedone) /* Currently polymorphed - show monster HP */ { if (u.mh != prevhp.value) { if (u.mh > prevhp.value) { prevhp.highlight_color = STAT_UP_COLOR; } else { prevhp.highlight_color = STAT_DOWN_COLOR; } prevhp.highlight_turns = 3; prevhp.value = u.mh; sprintf(buf, "%d", u.mh); free(prevhp.txt); prevhp.txt = curses_copy_of(buf); } } else if (u.uhp != prevhp.value) /* Not polymorphed */ { if (u.uhp > prevhp.value) { prevhp.highlight_color = STAT_UP_COLOR; } else { prevhp.highlight_color = STAT_DOWN_COLOR; } prevhp.value = u.uhp; sprintf(buf, "%d", u.uhp); free(prevhp.txt); prevhp.txt = curses_copy_of(buf); prevhp.highlight_turns = 3; } if (prevhp.label != NULL) { mvwaddstr(win, sy, sx, prevhp.label); sx += strlen(prevhp.label); } if (prevhp.highlight_turns > 0) { curses_toggle_color_attr(win, prevhp.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevhp.txt); curses_toggle_color_attr(win, prevhp.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevhp.txt); } sx += strlen(prevhp.txt); /* Max Hit Points */ if (u.mtimedone) /* Currently polymorphed - show monster HP */ { if (u.mhmax != prevmhp.value) { if (u.mhmax > prevmhp.value) { prevmhp.highlight_color = STAT_UP_COLOR; } else { prevmhp.highlight_color = STAT_DOWN_COLOR; } prevmhp.value = u.mhmax; sprintf(buf, "%d", u.mhmax); free(prevmhp.txt); prevmhp.txt = curses_copy_of(buf); prevmhp.highlight_turns = 3; } } else if (u.uhpmax != prevmhp.value) /* Not polymorphed */ { if (u.uhpmax > prevmhp.value) { prevmhp.highlight_color = STAT_UP_COLOR; } else { prevmhp.highlight_color = STAT_DOWN_COLOR; } prevmhp.value = u.uhpmax; sprintf(buf, "%d", u.uhpmax); free(prevmhp.txt); prevmhp.txt = curses_copy_of(buf); prevmhp.highlight_turns = 3; } if (prevmhp.label != NULL) { mvwaddstr(win, sy, sx, prevmhp.label); sx += strlen(prevmhp.label); } if (prevmhp.highlight_turns > 0) { curses_toggle_color_attr(win, prevmhp.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevmhp.txt); curses_toggle_color_attr(win, prevmhp.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevmhp.txt); } if (horiz) { sx += strlen(prevmhp.txt) + 1; } else { sx = sx_start; sy++; } /* Power */ if (u.uen != prevpow.value) { if (u.uen > prevpow.value) { prevpow.highlight_color = STAT_UP_COLOR; } else { prevpow.highlight_color = STAT_DOWN_COLOR; } prevpow.value = u.uen; sprintf(buf, "%d", u.uen); free(prevpow.txt); prevpow.txt = curses_copy_of(buf); prevpow.highlight_turns = 3; } if (prevpow.label != NULL) { mvwaddstr(win, sy, sx, prevpow.label); sx += strlen(prevpow.label); } if (prevpow.highlight_turns > 0) { curses_toggle_color_attr(win, prevpow.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevpow.txt); curses_toggle_color_attr(win, prevpow.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevpow.txt); } sx += strlen(prevpow.txt); /* Max Power */ if (u.uenmax != prevmpow.value) { if (u.uenmax > prevmpow.value) { prevmpow.highlight_color = STAT_UP_COLOR; } else { prevmpow.highlight_color = STAT_DOWN_COLOR; } prevmpow.value = u.uenmax; sprintf(buf, "%d", u.uenmax); free(prevmpow.txt); prevmpow.txt = curses_copy_of(buf); prevmpow.highlight_turns = 3; } if (prevmpow.label != NULL) { mvwaddstr(win, sy, sx, prevmpow.label); sx += strlen(prevmpow.label); } if (prevmpow.highlight_turns > 0) { curses_toggle_color_attr(win, prevmpow.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevmpow.txt); curses_toggle_color_attr(win, prevmpow.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevmpow.txt); } if (horiz) { sx += strlen(prevmpow.txt) + 1; } else { sx = sx_start; sy++; } /* Armor Class */ if (u.uac != prevac.value) { if (u.uac > prevac.value) /* Lower is better for AC */ { prevac.highlight_color = STAT_DOWN_COLOR; } else { prevac.highlight_color = STAT_UP_COLOR; } prevac.value = u.uac; sprintf(buf, "%d", u.uac); free(prevac.txt); prevac.txt = curses_copy_of(buf); prevac.highlight_turns = 5; } if (prevac.label != NULL) { mvwaddstr(win, sy, sx, prevac.label); sx += strlen(prevac.label); } if (prevac.highlight_turns > 0) { curses_toggle_color_attr(win, prevac.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevac.txt); curses_toggle_color_attr(win, prevac.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevac.txt); } if (horiz) { sx += strlen(prevac.txt) + 1; } else { sx = sx_start; sy++; } /* Experience */ #ifdef EXP_ON_BOTL if (prevexp.display != flags.showexp) /* Setting has changed */ { prevexp.display = flags.showexp; free(prevlevel.label); if (prevexp.display) { prevlevel.label = curses_copy_of("/"); } else { prevlevel.label = curses_copy_of("Lvl:"); } } if (prevexp.display && !u.mtimedone) { if (u.uexp != prevexp.value) { if (u.uexp > prevexp.value) { prevexp.highlight_color = STAT_UP_COLOR; } else { prevexp.highlight_color = STAT_DOWN_COLOR; } sprintf(buf, "%d", u.uexp); free(prevexp.txt); prevexp.txt = curses_copy_of(buf); prevexp.highlight_turns = 3; } if (prevexp.label != NULL) { mvwaddstr(win, sy, sx, prevexp.label); sx += strlen(prevexp.label); } if (prevexp.highlight_turns > 0) { curses_toggle_color_attr(win, prevexp.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevexp.txt); curses_toggle_color_attr(win, prevexp.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevexp.txt); } sx += strlen(prevexp.txt); } prevexp.value = u.uexp; /* Track it even when it's not displayed */ #endif /* EXP_ON_BOTL */ /* Level */ if (u.mtimedone) /* Currently polymorphed - show monster HD */ { if (strncmp(prevlevel.label, "HD:", 3) != 0) { free(prevlevel.label); prevlevel.label = curses_copy_of("HD:"); } if (mons[u.umonnum].mlevel != prevlevel.value) { if (mons[u.umonnum].mlevel > prevlevel.value) { prevlevel.highlight_color = STAT_UP_COLOR; } else { prevlevel.highlight_color = STAT_DOWN_COLOR; } prevlevel.highlight_turns = 5; } prevlevel.value = mons[u.umonnum].mlevel; sprintf(buf, "%d", mons[u.umonnum].mlevel); free(prevlevel.txt); prevlevel.txt = curses_copy_of(buf); } else /* Not polymorphed */ { if (strncmp(prevlevel.label, "HD:", 3) == 0) { free(prevlevel.label); if (prevexp.display) { prevlevel.label = curses_copy_of("/"); } else { prevlevel.label = curses_copy_of("Lvl:"); } } if (u.ulevel > prevlevel.value) { prevlevel.highlight_color = STAT_UP_COLOR; prevlevel.highlight_turns = 5; } else if (u.ulevel < prevlevel.value) { prevlevel.highlight_color = STAT_DOWN_COLOR; prevlevel.highlight_turns = 5; } prevlevel.value = u.ulevel; sprintf(buf, "%d", u.ulevel); free(prevlevel.txt); prevlevel.txt = curses_copy_of(buf); } if (prevlevel.label != NULL) { mvwaddstr(win, sy, sx, prevlevel.label); sx += strlen(prevlevel.label); } if (prevlevel.highlight_turns > 0) { curses_toggle_color_attr(win, prevlevel.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevlevel.txt); curses_toggle_color_attr(win, prevlevel.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevlevel.txt); } if (horiz) { sx += strlen(prevlevel.txt) + 1; } else { sx = sx_start; sy++; } /* Time */ if (prevtime.display != flags.time) /* Setting has changed */ { prevtime.display = flags.time; } if (prevtime.display) { if (moves != prevtime.value) { sprintf(buf, "%ld", moves); free(prevtime.txt); prevtime.txt = curses_copy_of(buf); } if (prevtime.label != NULL) { mvwaddstr(win, sy, sx, prevtime.label); sx += strlen(prevtime.label); } mvwaddstr(win, sy, sx, prevtime.txt); if (horiz) { sx += strlen(prevtime.txt) + 1; } else { sx = sx_start; sy++; } } /* Score */ #ifdef SCORE_ON_BOTL if (prevscore.display != flags.showscore) /* Setting has changed */ { prevscore.display = flags.showscore; } if (prevscore.display) { if (botl_score() != prevscore.value) { if (botl_score() > prevscore.value) { prevscore.highlight_color = STAT_UP_COLOR; } else /* Not sure this is possible */ { prevscore.highlight_color = STAT_DOWN_COLOR; } sprintf(buf, "%ld", botl_score()); free(prevscore.txt); prevscore.txt = curses_copy_of(buf); prevscore.highlight_turns = 3; } if (prevscore.label != NULL) { mvwaddstr(win, sy, sx, prevscore.label); sx += strlen(prevscore.label); } if (prevscore.highlight_turns > 0) { curses_toggle_color_attr(win, prevscore.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevscore.txt); curses_toggle_color_attr(win, prevscore.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevscore.txt); } if (horiz) { sx += strlen(prevscore.txt) + 1; } else { sx = sx_start; sy++; } } prevscore.value = botl_score(); /* Track it even when it's not displayed */ #endif /* SCORE_ON_BOTL */ /* Hunger */ if (u.uhs != prevhunger.value) { if ((u.uhs > prevhunger.value) || (u.uhs > 3)) { prevhunger.highlight_color = STAT_DOWN_COLOR; } else { prevhunger.highlight_color = STAT_UP_COLOR; } prevhunger.value = u.uhs; for (count = 0; count < strlen(hu_stat[u.uhs]); count++) { if ((hu_stat[u.uhs][count]) == ' ') { break; } buf[count] = hu_stat[u.uhs][count]; } buf[count] = '\0'; free(prevhunger.txt); prevhunger.txt = curses_copy_of(buf); prevhunger.highlight_turns = 5; } if (prevhunger.label != NULL) { mvwaddstr(win, sy, sx, prevhunger.label); sx += strlen(prevhunger.label); } if (prevhunger.highlight_turns > 0) { curses_toggle_color_attr(win, prevhunger.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevhunger.txt); curses_toggle_color_attr(win, prevhunger.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevhunger.txt); } if (strlen(prevhunger.txt) > 0) { if (horiz) { sx += strlen(prevhunger.txt) + 1; } else { sx = sx_start; sy++; } } /* Confusion */ if (Confusion != prevconf.value) { prevconf.highlight_color = STAT_DOWN_COLOR; if (prevconf.txt != NULL) { free(prevconf.txt); } if (Confusion) { prevconf.txt = curses_copy_of("Conf"); } else { prevconf.txt = NULL; } if (prevconf.value == 0) { prevconf.highlight_turns = 5; } prevconf.value = Confusion; } if (prevconf.label != NULL) { mvwaddstr(win, sy, sx, prevconf.label); sx += strlen(prevconf.label); } if (prevconf.txt != NULL) { if (prevconf.highlight_turns > 0) { curses_toggle_color_attr(win, prevconf.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevconf.txt); curses_toggle_color_attr(win, prevconf.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevconf.txt); } } if (prevconf.txt != NULL) { if (horiz) { sx += strlen(prevconf.txt) + 1; } else { sx = sx_start; sy++; } } /* Blindness */ if (Blind != prevblind.value) { prevblind.highlight_color = STAT_DOWN_COLOR; if (prevblind.txt != NULL) { free(prevblind.txt); } if (Blind) { prevblind.txt = curses_copy_of("Blind"); } else { prevblind.txt = NULL; } if (prevblind.value == 0) { prevblind.highlight_turns = 5; } prevblind.value = Blind; } if (prevblind.label != NULL) { mvwaddstr(win, sy, sx, prevblind.label); sx += strlen(prevblind.label); } if (prevblind.txt != NULL) { if (prevblind.highlight_turns > 0) { curses_toggle_color_attr(win, prevblind.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevblind.txt); curses_toggle_color_attr(win, prevblind.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevblind.txt); } } if (prevblind.txt != NULL) { if (horiz) { sx += strlen(prevblind.txt) + 1; } else { sx = sx_start; sy++; } } /* Stun */ if (Stunned != prevstun.value) { prevstun.highlight_color = STAT_DOWN_COLOR; if (prevstun.txt != NULL) { free(prevstun.txt); } if (Stunned) { prevstun.txt = curses_copy_of("Stun"); } else { prevstun.txt = NULL; } if (prevstun.value == 0) { prevstun.highlight_turns = 5; } prevstun.value = Stunned; } if (prevstun.label != NULL) { mvwaddstr(win, sy, sx, prevstun.label); sx += strlen(prevstun.label); } if (prevstun.txt != NULL) { if (prevstun.highlight_turns > 0) { curses_toggle_color_attr(win, prevstun.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevstun.txt); curses_toggle_color_attr(win, prevstun.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevstun.txt); } } if (prevstun.txt != NULL) { if (horiz) { sx += strlen(prevstun.txt) + 1; } else { sx = sx_start; sy++; } } /* Hallucination */ if (Hallucination != prevhallu.value) { prevhallu.highlight_color = STAT_DOWN_COLOR; if (prevhallu.txt != NULL) { free(prevhallu.txt); } if (Hallucination) { prevhallu.txt = curses_copy_of("Hallu"); } else { prevhallu.txt = NULL; } if (prevhallu.value == 0) { prevhallu.highlight_turns = 5; } prevhallu.value = Hallucination; } if (prevhallu.label != NULL) { mvwaddstr(win, sy, sx, prevhallu.label); sx += strlen(prevhallu.label); } if (prevhallu.txt != NULL) { if (prevhallu.highlight_turns > 0) { curses_toggle_color_attr(win, prevhallu.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevhallu.txt); curses_toggle_color_attr(win, prevhallu.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevhallu.txt); } } if (prevhallu.txt != NULL) { if (horiz) { sx += strlen(prevhallu.txt) + 1; } else { sx = sx_start; sy++; } } /* Sick */ if (Sick != prevsick.value) { prevsick.highlight_color = STAT_DOWN_COLOR; if (prevsick.txt != NULL) { free(prevsick.txt); } if (Sick) { if (u.usick_type & SICK_VOMITABLE) { prevsick.txt = curses_copy_of("FoodPois"); } else { prevsick.txt = curses_copy_of("Ill"); } } else { prevsick.txt = NULL; } if (prevsick.value == 0) { prevsick.highlight_turns = 5; } prevsick.value = Sick; } if (prevsick.label != NULL) { mvwaddstr(win, sy, sx, prevsick.label); sx += strlen(prevsick.label); } if (prevsick.txt != NULL) { if (prevsick.highlight_turns > 0) { curses_toggle_color_attr(win, prevsick.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevsick.txt); curses_toggle_color_attr(win, prevsick.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevsick.txt); } } if (prevsick.txt != NULL) { if (horiz) { sx += strlen(prevsick.txt) + 1; } else { sx = sx_start; sy++; } } /* Slime */ if (Slimed != prevslime.value) { prevslime.highlight_color = STAT_DOWN_COLOR; if (prevslime.txt != NULL) { free(prevslime.txt); } if (Slimed) { prevslime.txt = curses_copy_of("Slime"); } else { prevslime.txt = NULL; } if (prevslime.value == 0) { prevslime.highlight_turns = 5; } prevslime.value = Slimed; } if (prevslime.label != NULL) { mvwaddstr(win, sy, sx, prevslime.label); sx += strlen(prevslime.label); } if (prevslime.txt != NULL) { if (prevslime.highlight_turns > 0) { curses_toggle_color_attr(win, prevslime.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevslime.txt); curses_toggle_color_attr(win, prevslime.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevslime.txt); } } if (prevslime.txt != NULL) { if (horiz) { sx += strlen(prevslime.txt) + 1; } else { sx = sx_start; sy++; } } /* Encumberance */ enc = near_capacity(); if (enc != prevencumb.value) { if (enc < prevencumb.value) { prevencumb.highlight_color = STAT_UP_COLOR; } else { prevencumb.highlight_color = STAT_DOWN_COLOR; } if (prevencumb.txt != NULL) { free(prevencumb.txt); } if (enc > UNENCUMBERED) { sprintf(buf, "%s", enc_stat[enc]); prevencumb.txt = curses_copy_of(buf); prevencumb.highlight_turns = 5; } else { prevencumb.txt = NULL; } prevencumb.value = enc; } if (prevencumb.label != NULL) { mvwaddstr(win, sy, sx, prevencumb.label); sx += strlen(prevencumb.label); } if (prevencumb.txt != NULL) { if (prevencumb.highlight_turns > 0) { curses_toggle_color_attr(win, prevencumb.highlight_color, NONE, ON); mvwaddstr(win, sy, sx, prevencumb.txt); curses_toggle_color_attr(win, prevencumb.highlight_color, NONE, OFF); } else { mvwaddstr(win, sy, sx, prevencumb.txt); } } if (prevencumb.txt != NULL) { if (horiz) { sx += strlen(prevencumb.txt) + 1; } else { sx = sx_start; sy++; } } wrefresh(win); } /* Decrement the highlight_turns for all stats. Call curses_update_stats if needed to unhighlight a stat */ void curses_decrement_highlight() { boolean unhighlight = FALSE; if (prevname.highlight_turns > 0) { prevname.highlight_turns--; if (prevname.highlight_turns == 0) { unhighlight = TRUE; } } if (prevdepth.highlight_turns > 0) { prevdepth.highlight_turns--; if (prevdepth.highlight_turns == 0) { unhighlight = TRUE; } } if (prevstr.highlight_turns > 0) { prevstr.highlight_turns--; if (prevstr.highlight_turns == 0) { unhighlight = TRUE; } } if (prevint.highlight_turns > 0) { prevint.highlight_turns--; if (prevint.highlight_turns == 0) { unhighlight = TRUE; } } if (prevwis.highlight_turns > 0) { prevwis.highlight_turns--; if (prevwis.highlight_turns == 0) { unhighlight = TRUE; } } if (prevdex.highlight_turns > 0) { prevdex.highlight_turns--; if (prevdex.highlight_turns == 0) { unhighlight = TRUE; } } if (prevcon.highlight_turns > 0) { prevcon.highlight_turns--; if (prevcon.highlight_turns == 0) { unhighlight = TRUE; } } if (prevcha.highlight_turns > 0) { prevcha.highlight_turns--; if (prevcha.highlight_turns == 0) { unhighlight = TRUE; } } if (prevalign.highlight_turns > 0) { prevalign.highlight_turns--; if (prevalign.highlight_turns == 0) { unhighlight = TRUE; } } if (prevau.highlight_turns > 0) { prevau.highlight_turns--; if (prevau.highlight_turns == 0) { unhighlight = TRUE; } } if (prevhp.highlight_turns > 0) { prevhp.highlight_turns--; if (prevhp.highlight_turns == 0) { unhighlight = TRUE; } } if (prevmhp.highlight_turns > 0) { prevmhp.highlight_turns--; if (prevmhp.highlight_turns == 0) { unhighlight = TRUE; } } if (prevlevel.highlight_turns > 0) { prevlevel.highlight_turns--; if (prevlevel.highlight_turns == 0) { unhighlight = TRUE; } } if (prevpow.highlight_turns > 0) { prevpow.highlight_turns--; if (prevpow.highlight_turns == 0) { unhighlight = TRUE; } } if (prevmpow.highlight_turns > 0) { prevmpow.highlight_turns--; if (prevmpow.highlight_turns == 0) { unhighlight = TRUE; } } if (prevac.highlight_turns > 0) { prevac.highlight_turns--; if (prevac.highlight_turns == 0) { unhighlight = TRUE; } } #ifdef EXP_ON_BOTL if (prevexp.highlight_turns > 0) { prevexp.highlight_turns--; if (prevexp.highlight_turns == 0) { unhighlight = TRUE; } } #endif if (prevtime.highlight_turns > 0) { prevtime.highlight_turns--; if (prevtime.highlight_turns == 0) { unhighlight = TRUE; } } #ifdef SCORE_ON_BOTL if (prevscore.highlight_turns > 0) { prevscore.highlight_turns--; if (prevscore.highlight_turns == 0) { unhighlight = TRUE; } } #endif if (prevhunger.highlight_turns > 0) { prevhunger.highlight_turns--; if (prevhunger.highlight_turns == 0) { unhighlight = TRUE; } } if (prevconf.highlight_turns > 0) { prevconf.highlight_turns--; if (prevconf.highlight_turns == 0) { unhighlight = TRUE; } } if (prevblind.highlight_turns > 0) { prevblind.highlight_turns--; if (prevblind.highlight_turns == 0) { unhighlight = TRUE; } } if (prevstun.highlight_turns > 0) { prevstun.highlight_turns--; if (prevstun.highlight_turns == 0) { unhighlight = TRUE; } } if (prevhallu.highlight_turns > 0) { prevhallu.highlight_turns--; if (prevhallu.highlight_turns == 0) { unhighlight = TRUE; } } if (prevsick.highlight_turns > 0) { prevsick.highlight_turns--; if (prevsick.highlight_turns == 0) { unhighlight = TRUE; } } if (prevslime.highlight_turns > 0) { prevslime.highlight_turns--; if (prevslime.highlight_turns == 0) { unhighlight = TRUE; } } if (prevencumb.highlight_turns > 0) { prevencumb.highlight_turns--; if (prevencumb.highlight_turns == 0) { unhighlight = TRUE; } } if (unhighlight) { curses_update_stats(); } } /* Initialize the stats with beginning values. */ static void init_stats() { char buf[BUFSZ]; int count; /* Player name and title */ strcpy(buf, plname); if ('a' <= buf[0] && buf[0] <= 'z') buf[0] += 'A'-'a'; strcat(buf, " the "); if (u.mtimedone) { char mname[BUFSZ]; int k = 0; strcpy(mname, mons[u.umonnum].mname); while(mname[k] != 0) { if ((k == 0 || (k > 0 && mname[k-1] == ' ')) && 'a' <= mname[k] && mname[k] <= 'z') { mname[k] += 'A' - 'a'; } k++; } strcat(buf, mname); } else { strcat(buf, rank_of(u.ulevel, pl_character[0], flags.female)); } prevname.txt = curses_copy_of(buf); prevname.display = TRUE; prevname.highlight_turns = 0; prevname.label = NULL; /* Strength */ if (ACURR(A_STR) > 118) { sprintf(buf, "%d", ACURR(A_STR) - 100); } else if (ACURR(A_STR)==118) { sprintf(buf, "18/**"); } else if(ACURR(A_STR) > 18) { sprintf(buf, "18/%02d", ACURR(A_STR) - 18); } else { sprintf(buf, "%d", ACURR(A_STR)); } prevstr.value = ACURR(A_STR); prevstr.txt = curses_copy_of(buf); prevstr.display = TRUE; prevstr.highlight_turns = 0; prevstr.label = curses_copy_of("Str:"); /* Intelligence */ sprintf(buf, "%d", ACURR(A_INT)); prevint.value = ACURR(A_INT); prevint.txt = curses_copy_of(buf); prevint.display = TRUE; prevint.highlight_turns = 0; prevint.label = curses_copy_of("Int:"); /* Wisdom */ sprintf(buf, "%d", ACURR(A_WIS)); prevwis.value = ACURR(A_WIS); prevwis.txt = curses_copy_of(buf); prevwis.display = TRUE; prevwis.highlight_turns = 0; prevwis.label = curses_copy_of("Wis:"); /* Dexterity */ sprintf(buf, "%d", ACURR(A_DEX)); prevdex.value = ACURR(A_DEX); prevdex.txt = curses_copy_of(buf); prevdex.display = TRUE; prevdex.highlight_turns = 0; prevdex.label = curses_copy_of("Dex:"); /* Constitution */ sprintf(buf, "%d", ACURR(A_CON)); prevcon.value = ACURR(A_CON); prevcon.txt = curses_copy_of(buf); prevcon.display = TRUE; prevcon.highlight_turns = 0; prevcon.label = curses_copy_of("Con:"); /* Charisma */ sprintf(buf, "%d", ACURR(A_CHA)); prevcha.value = ACURR(A_CHA); prevcha.txt = curses_copy_of(buf); prevcha.display = TRUE; prevcha.highlight_turns = 0; prevcha.label = curses_copy_of("Cha:"); /* Alignment */ switch (u.ualign.type) { case A_LAWFUL: { prevalign.txt = curses_copy_of("Lawful"); break; } case A_NEUTRAL: { prevalign.txt = curses_copy_of("Neutral"); break; } case A_CHAOTIC: { prevalign.txt = curses_copy_of("Chaotic"); break; } } prevalign.alignment = u.ualign.type; prevalign.display = TRUE; prevalign.highlight_turns = 0; prevalign.label = NULL; /* Dungeon level */ if (In_endgame(&u.uz)) { strcpy(buf, (Is_astralevel(&u.uz) ? "Astral Plane":"End Game")); } else { sprintf(buf, "%d", depth(&u.uz)); } prevdepth.value = depth(&u.uz); prevdepth.txt = curses_copy_of(buf); prevdepth.display = TRUE; prevdepth.highlight_turns = 0; prevdepth.label = curses_copy_of("Dlvl:"); /* Gold */ #ifndef GOLDOBJ sprintf(buf,"%ld", u.ugold); prevau.value = u.ugold; #else sprintf(buf,"%ld", money_cnt(invent)); prevau.value = money_cnt(invent); #endif prevau.txt = curses_copy_of(buf); prevau.display = TRUE; prevau.highlight_turns = 0; sprintf(buf, "%c:", GOLD_SYM); prevau.label = curses_copy_of(buf); /* Hit Points */ if (u.mtimedone) /* Currently polymorphed - show monster HP */ { prevhp.value = u.mh; sprintf(buf, "%d", u.mh); prevhp.txt = curses_copy_of(buf); } else if (u.uhp != prevhp.value) /* Not polymorphed */ { prevhp.value = u.uhp; sprintf(buf, "%d", u.uhp); prevhp.txt = curses_copy_of(buf); } prevhp.display = TRUE; prevhp.highlight_turns = 0; prevhp.label = curses_copy_of("HP:"); /* Max Hit Points */ if (u.mtimedone) /* Currently polymorphed - show monster HP */ { prevmhp.value = u.mhmax; sprintf(buf, "%d", u.mhmax); prevmhp.txt = curses_copy_of(buf); } else /* Not polymorphed */ { prevmhp.value = u.uhpmax; sprintf(buf, "%d", u.uhpmax); prevmhp.txt = curses_copy_of(buf); } prevmhp.display = TRUE; prevmhp.highlight_turns = 0; prevmhp.label = curses_copy_of("/"); /* Power */ prevpow.value = u.uen; sprintf(buf, "%d", u.uen); prevpow.txt = curses_copy_of(buf); prevpow.display = TRUE; prevpow.highlight_turns = 0; prevpow.label = curses_copy_of("Pw:"); /* Max Power */ prevmpow.value = u.uenmax; sprintf(buf, "%d", u.uenmax); prevmpow.txt = curses_copy_of(buf); prevmpow.display = TRUE; prevmpow.highlight_turns = 0; prevmpow.label = curses_copy_of("/"); /* Armor Class */ prevac.value = u.uac; sprintf(buf, "%d", u.uac); prevac.txt = curses_copy_of(buf); prevac.display = TRUE; prevac.highlight_turns = 0; prevac.label = curses_copy_of("AC:"); /* Experience */ #ifdef EXP_ON_BOTL prevexp.value = u.uexp; sprintf(buf, "%ld", u.uexp); prevexp.txt = curses_copy_of(buf); prevexp.display = flags.showexp; prevexp.highlight_turns = 0; prevexp.label = curses_copy_of("Xp:"); #endif /* Level */ if (u.mtimedone) /* Currently polymorphed - show monster HP */ { prevlevel.value = mons[u.umonnum].mlevel; sprintf(buf, "%d", mons[u.umonnum].mlevel); prevlevel.txt = curses_copy_of(buf); prevlevel.label = curses_copy_of("HD:"); } else if (u.ulevel != prevlevel.value) /* Not polymorphed */ { prevlevel.value = u.ulevel; sprintf(buf, "%d", u.ulevel); prevlevel.txt = curses_copy_of(buf); if (prevexp.display) { prevlevel.label = curses_copy_of("/"); } else { prevlevel.label = curses_copy_of("Lvl:"); } } prevlevel.display = TRUE; prevlevel.highlight_turns = 0; /* Time */ prevtime.value = moves; sprintf(buf, "%ld", moves); prevtime.txt = curses_copy_of(buf); prevtime.display = flags.time; prevtime.highlight_turns = 0; prevtime.label = curses_copy_of("T:"); /* Score */ #ifdef SCORE_ON_BOTL prevscore.value = botl_score(); sprintf(buf, "%ld", botl_score()); prevscore.txt = curses_copy_of(buf); prevscore.display = flags.showscore; prevscore.highlight_turns = 0; prevscore.label = curses_copy_of("S:"); #endif /* Hunger */ prevhunger.value = u.uhs; for (count = 0; count < strlen(hu_stat[u.uhs]); count++) { if ((hu_stat[u.uhs][count]) == ' ') { break; } buf[count] = hu_stat[u.uhs][count]; } buf[count] = '\0'; prevhunger.txt = curses_copy_of(buf); prevhunger.display = TRUE; prevhunger.highlight_turns = 0; prevhunger.label = NULL; /* Confusion */ prevconf.value = Confusion; if (Confusion) { prevconf.txt = curses_copy_of("Conf"); } else { prevconf.txt = NULL; } prevconf.display = TRUE; prevconf.highlight_turns = 0; prevconf.label = NULL; /* Blindness */ prevblind.value = Blind; if (Blind) { prevblind.txt = curses_copy_of("Blind"); } else { prevblind.txt = NULL; } prevblind.display = TRUE; prevblind.highlight_turns = 0; prevblind.label = NULL; /* Stun */ prevstun.value = Stunned; if (Stunned) { prevstun.txt = curses_copy_of("Stun"); } else { prevstun.txt = NULL; } prevstun.display = TRUE; prevstun.highlight_turns = 0; prevstun.label = NULL; /* Hallucination */ prevhallu.value = Hallucination; if (Hallucination) { prevhallu.txt = curses_copy_of("Hallu"); } else { prevhallu.txt = NULL; } prevhallu.display = TRUE; prevhallu.highlight_turns = 0; prevhallu.label = NULL; /* Sick */ prevsick.value = Sick; if (Sick) { if (u.usick_type & SICK_VOMITABLE) { prevsick.txt = curses_copy_of("Sick"); } else { prevsick.txt = curses_copy_of("Ill"); } } else { prevsick.txt = NULL; } prevsick.display = TRUE; prevsick.highlight_turns = 0; prevsick.label = NULL; /* Slimed */ prevslime.value = Slimed; if (Slimed) { prevslime.txt = curses_copy_of("Slime"); } else { prevslime.txt = NULL; } prevslime.display = TRUE; prevslime.highlight_turns = 0; prevslime.label = NULL; /* Encumberance */ prevencumb.value = near_capacity(); if (prevencumb.value > UNENCUMBERED) { sprintf(buf, "%s", enc_stat[prevencumb.value]); prevencumb.txt = curses_copy_of(buf); } else { prevencumb.txt = NULL; } prevencumb.display = TRUE; prevencumb.highlight_turns = 0; prevencumb.label = NULL; }