From ca8f25d4b60c4ce25bb1ee25502d941cf330cf24 Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 1 Jun 2015 08:33:17 -0400 Subject: [PATCH] more updates and on/off option --- include/flag.h | 5 +++-- src/botl.c | 2 +- src/options.c | 3 ++- src/windows.c | 2 +- win/tty/wintty.c | 55 ++++++++++++++++++++++++++++++++++++------------ 5 files changed, 49 insertions(+), 18 deletions(-) diff --git a/include/flag.h b/include/flag.h index 3d2139f2d..9768cd732 100644 --- a/include/flag.h +++ b/include/flag.h @@ -206,8 +206,9 @@ struct instance_flags { boolean zerocomp; /* write zero-compressed save files */ boolean rlecomp; /* run-length comp of levels when writing savefile */ uchar num_pad_mode; - boolean echo; /* 1 to echo characters */ - boolean use_menu_color; /* use color in menus; only if wc_color */ + boolean echo; /* 1 to echo characters */ + boolean use_menu_color; /* use color in menus; only if wc_color */ + boolean use_status_color; /* use color in status */ #if 0 boolean DECgraphics; /* use DEC VT-xxx extended character set */ boolean IBMgraphics; /* use IBM extended character set */ diff --git a/src/botl.c b/src/botl.c index badb0f260..3ba06f526 100644 --- a/src/botl.c +++ b/src/botl.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 botl.c $NHDT-Date: 1433115548 2015/05/31 23:39:08 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.60 $ */ +/* NetHack 3.6 botl.c $NHDT-Date: 1433161984 2015/06/01 12:33:04 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.61 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ diff --git a/src/options.c b/src/options.c index c700dd43b..f3b921f9e 100644 --- a/src/options.c +++ b/src/options.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 options.c $NHDT-Date: 1433105391 2015/05/31 20:49:51 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.210 $ */ +/* NetHack 3.6 options.c $NHDT-Date: 1433161989 2015/06/01 12:33:09 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.211 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -196,6 +196,7 @@ static struct Bool_Opt { { "sparkle", &flags.sparkle, TRUE, SET_IN_GAME }, { "splash_screen", &iflags.wc_splash_screen, TRUE, DISP_IN_GAME }, /*WC*/ { "standout", &flags.standout, FALSE, SET_IN_GAME }, + { "statuscolors", &iflags.use_status_color, FALSE, SET_IN_GAME }, { "tiled_map", &iflags.wc_tiled_map, PREFER_TILED, DISP_IN_GAME }, /*WC*/ { "time", &flags.time, FALSE, SET_IN_GAME }, #ifdef TIMED_DELAY diff --git a/src/windows.c b/src/windows.c index 25507a3c0..5ba25a448 100644 --- a/src/windows.c +++ b/src/windows.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 windows.c $NHDT-Date: 1433105394 2015/05/31 20:49:54 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.32 $ */ +/* NetHack 3.6 windows.c $NHDT-Date: 1433161992 2015/06/01 12:33:12 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.33 $ */ /* Copyright (c) D. Cohrs, 1993. */ /* NetHack may be freely redistributed. See license for details. */ diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 52842e3ca..1c383c426 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 wintty.c $NHDT-Date: 1433115559 2015/05/31 23:39:19 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.98 $ */ +/* NetHack 3.6 wintty.c $NHDT-Date: 1433161993 2015/06/01 12:33:13 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.99 $ */ /* Copyright (c) David Cohrs, 1991 */ /* NetHack may be freely redistributed. See license for details. */ @@ -3075,7 +3075,7 @@ tty_status_init() for (i = 0; i < MAXBLSTATS; ++i) { #ifdef STATUS_HILITES - tty_status_colors[i] = CLR_MAX; /* no color */ + tty_status_colors[i] = NO_COLOR; /* no color */ tty_status_hilites[i].thresholdtype = 0; tty_status_hilites[i].behavior = BL_TH_NONE; tty_status_hilites[i].under = BL_HILITE_NONE; @@ -3130,7 +3130,7 @@ genericptr_t ptr; int statusattr[] = {ATR_BOLD, ATR_INVERSE, ATR_NONE}; int attridx = 0; long value = -1L; - + static boolean beenhere = FALSE; enum statusfields fieldorder[2][15] = { { BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH, BL_ALIGN, BL_SCORE, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_FLUSH}, @@ -3174,7 +3174,7 @@ genericptr_t ptr; #ifdef STATUS_HILITES switch (tty_status_hilites[fldidx].behavior) { case BL_TH_NONE: - tty_status_colors[fldidx] = CLR_MAX; + tty_status_colors[fldidx] = NO_COLOR; break; case BL_TH_UPDOWN: @@ -3183,7 +3183,7 @@ genericptr_t ptr; else if (chg < 0) tty_status_colors[fldidx] = tty_status_hilites[fldidx].under; else - tty_status_colors[fldidx] = CLR_MAX; + tty_status_colors[fldidx] = NO_COLOR; break; case BL_TH_VAL_PERCENTAGE: @@ -3204,7 +3204,7 @@ genericptr_t ptr; case BL_TH_VAL_ABSOLUTE: { - int c = CLR_MAX; + int c = NO_COLOR; int o = tty_status_hilites[fldidx].over; int u = tty_status_hilites[fldidx].under; anything *t = &tty_status_hilites[fldidx].threshold; @@ -3236,9 +3236,34 @@ genericptr_t ptr; } #endif /* STATUS_HILITES */ - /* This version copied from the genl_ version currently + /* For now, this version copied from the genl_ version currently * updates everything on the display, everytime */ + + if (!beenhere || !iflags.use_status_color) { + char newbot1[MAXCO], newbot2[MAXCO]; + + newbot1[0] = '\0'; + for (i = 0; fieldorder[0][i] >= 0; ++i) { + int idx1 = fieldorder[0][i]; + if (status_activefields[idx1]) + Strcat(newbot1, status_vals[idx1]); + } + newbot2[0] = '\0'; + for (i = 0; fieldorder[1][i] >= 0; ++i) { + int idx2 = fieldorder[1][i]; + if (status_activefields[idx2]) + Strcat(newbot2, status_vals[idx2]); + } + + curs(WIN_STATUS, 1, 0); + putstr(WIN_STATUS, 0, newbot1); + curs(WIN_STATUS, 1, 1); + putmixed(WIN_STATUS, 0, newbot2); /* putmixed() due to GOLD glyph */ + beenhere = TRUE; + return; + } + curs(WIN_STATUS, 1, 0); for (i = 0; fieldorder[0][i] != BL_FLUSH; ++i) { int fldidx1 = fieldorder[0][i]; @@ -3251,10 +3276,12 @@ genericptr_t ptr; putstr(WIN_STATUS, 0, status_vals[fldidx1]); term_end_attr(statusattr[attridx]); #ifdef TEXTCOLOR - } else if (tty_status_colors[fldidx1] != NO_COLOR) { - term_start_color(tty_status_colors[fldidx1]); + } else if (tty_status_colors[fldidx1] != CLR_MAX) { + if (tty_status_colors[fldidx1] != NO_COLOR) + term_start_color(tty_status_colors[fldidx1]); putstr(WIN_STATUS, 0, status_vals[fldidx1]); - term_end_color(); + if (tty_status_colors[fldidx1] != NO_COLOR) + term_end_color(); #endif } else putstr(WIN_STATUS, 0, status_vals[fldidx1]); @@ -3272,15 +3299,17 @@ genericptr_t ptr; putstr(WIN_STATUS, 0, status_vals[fldidx2]); term_end_attr(statusattr[attridx]); #ifdef TEXTCOLOR - } else if (tty_status_colors[fldidx2] != NO_COLOR) { - term_start_color(tty_status_colors[fldidx2]); + } else if (tty_status_colors[fldidx2] != CLR_MAX) { + if (tty_status_colors[fldidx2] != NO_COLOR) + term_start_color(tty_status_colors[fldidx2]); if (fldidx2 == BL_GOLD) { /* putmixed() due to GOLD glyph */ putmixed(WIN_STATUS, 0, status_vals[fldidx2]); } else { putstr(WIN_STATUS, 0, status_vals[fldidx2]); } - term_end_color(); + if (tty_status_colors[fldidx2] != NO_COLOR) + term_end_color(); #endif } else putstr(WIN_STATUS, 0, status_vals[fldidx2]); -- 2.40.0