core support for status field highlighting (trunk only)

This provides the core support needed for status field highlighting.
This patch doesn't actually perform status field highlighting for any port,
but provides the core hooks for doing so.

The syntax is:
OPTIONS=hilite_status:{fieldname}/{threshold}/{below}/{above}
where {fieldname} is the name of a status field.
           {threshold} is the value used as the threshold to trigger a display
                             change.  It can also be set to "updown" to trigger
                             a display change whenever it rises or whenever it falls.
                             If you end the threshold value with %, then it signifies
                             that you want to trigger the display change based on the
                             percentage of maximum.
         {below}, {above}
                        are the color or display attribute that you want to use when
                        the field value is underneath the threshold. Supported display
                        fields are:  normal, inverse, bold, black, red, green,
                                         brown, blue, magenta, cyan, gray, orange,
                                         bright-green, yellow, bright-blue, bright-magenta,
                                         bright-cyan, or white.
Valid field names are:
        alignment, armor-class, carrying-capacity,
        charisma, condition, constitution, dexterity,
        dungeon-level, experience-level, experience,
        gold, HD, hitpoints-max, hitpoints, hunger,
        intelligence, power-max, power, score,
        strength, time, title, wisdom

Refer to window.doc for details. Guidebook updates to come later.
This commit is contained in:
nethack.allison
2003-11-30 05:51:53 +00:00
parent c1c4ba99d9
commit 10480f4397
21 changed files with 997 additions and 195 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -2275,12 +2275,16 @@ const char *reason; /* explanation */
FILE *lfile;
char buf[BUFSZ];
lfile = fopen_datafile(PANICLOG, "a", TROUBLEPREFIX);
if (lfile) {
(void) fprintf(lfile, "%s %08ld: %s %s\n",
version_string(buf), yyyymmdd((time_t)0L),
type, reason);
(void) fclose(lfile);
if (!program_state.in_paniclog) {
program_state.in_paniclog = 1;
lfile = fopen_datafile(PANICLOG, "a", TROUBLEPREFIX);
if (lfile) {
(void) fprintf(lfile, "%s %08ld: %s %s\n",
version_string(buf), yyyymmdd((time_t)0L),
type, reason);
(void) fclose(lfile);
}
program_state.in_paniclog = 0;
}
#endif /* PANICLOG */
return;

View File

@@ -2138,7 +2138,23 @@ goodfruit:
return;
}
}
#if defined(STATUS_VIA_WINDOWPORT) && defined(STATUS_HILITES)
/* hilite fields in status prompt */
if (match_optname(opts, "hilite_status", 13, TRUE)) {
op = string_for_opt(opts, TRUE);
if (op && negated) {
clear_status_hilites();
return;
} else if (!op) {
/* a value is mandatory */
badoption(opts);
return;
}
if (!set_status_hilites(op))
badoption(opts);
return;
}
#endif
/* OK, if we still haven't recognized the option, check the boolean
* options list
*/
@@ -2474,12 +2490,23 @@ doset()
doset_add_menu(tmpwin, compopt[i].name,
(pass == DISP_IN_GAME) ? 0 : indexoffset);
}
#ifdef STATUS_VIA_WINDOWPORT
# ifdef STATUS_HILITES
any.a_int = -2;
get_status_hilites(buf2, 60);
if (!iflags.menu_tab_sep)
Sprintf(buf, fmtstr_doset_add_menu, any.a_int ? "" : " ",
"status_hilites", buf2);
else
Sprintf(buf, fmtstr_doset_add_menu_tab, "status_hilites", buf2);
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED);
# endif
#endif
#ifdef AUTOPICKUP_EXCEPTIONS
any.a_int = -1;
Sprintf(buf, "autopickup exceptions (%d currently set)",
count_ape_maps((int *)0, (int *)0));
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED);
#endif /* AUTOPICKUP_EXCEPTIONS */
#ifdef PREFIXES_IN_USE
any.a_void = 0;
@@ -2501,10 +2528,22 @@ doset()
for (pick_idx = 0; pick_idx < pick_cnt; ++pick_idx) {
opt_indx = pick_list[pick_idx].item.a_int - 1;
#ifdef AUTOPICKUP_EXCEPTIONS
if (opt_indx == -2) {
if (opt_indx == -2) { /* -3 due to -1 offset for select_menu() */
special_handling("autopickup_exception",
setinitial, fromfile);
} else
#endif
#ifdef STATUS_VIA_WINDOWPORT
# ifdef STATUS_HILITES
if (opt_indx == -3) { /* -3 due to -1 offset for select_menu() */
if (!status_hilite_menu())
pline("Bad status hilite(s) specified.");
else {
if (wc2_supported("status_hilites"))
preference_update("status_hilites");
}
} else
# endif
#endif
if (opt_indx < boolcount) {
/* boolean option */
@@ -3605,6 +3644,9 @@ struct wc_Opt wc2_options[] = {
{"fullscreen", WC2_FULLSCREEN},
{"softkeyboard", WC2_SOFTKEYBOARD},
{"wraptext", WC2_WRAPTEXT},
#ifdef STATUS_VIA_WINDOWPORT
{"hilite_status", WC2_HILITE_STATUS},
#endif
{(char *)0, 0L}
};

View File

@@ -252,6 +252,9 @@ void
impossible VA_DECL(const char *, s)
VA_START(s);
VA_INIT(s, const char *);
if (program_state.in_impossible)
panic("impossible called impossible");
program_state.in_impossible = 1;
{
char pbuf[BUFSZ];
Vsprintf(pbuf,s,VA_ARGS);
@@ -259,6 +262,7 @@ impossible VA_DECL(const char *, s)
}
vpline(s,VA_ARGS);
pline("Program in disorder - perhaps you'd better #quit.");
program_state.in_impossible = 0;
VA_END();
}