yet more updates
Changes to be committed: modified: include/botl.h modified: include/extern.h modified: include/wintty.h modified: src/botl.c modified: src/options.c modified: src/windows.c modified: win/tty/wintty.c get the tty versions started
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 botl.h $NHDT-Date: 1433099923 2015/05/31 19:18:43 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.13 $ */
|
||||
/* NetHack 3.6 botl.h $NHDT-Date: 1433105378 2015/05/31 20:49:38 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.14 $ */
|
||||
/* Copyright (c) Michael Allison, 2003 */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 extern.h $NHDT-Date: 1433087625 2015/05/31 15:53:45 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.499 $ */
|
||||
/* NetHack 3.6 extern.h $NHDT-Date: 1433105379 2015/05/31 20:49:39 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.500 $ */
|
||||
/* Copyright (c) Steve Creps, 1988. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -155,7 +155,7 @@ E void NDECL(status_finish);
|
||||
E void FDECL(status_notify_windowport, (BOOLEAN_P));
|
||||
#ifdef STATUS_HILITES
|
||||
E boolean FDECL(set_status_hilites, (char *op, BOOLEAN_P));
|
||||
E void NDECL(clear_status_hilites);
|
||||
E void FDECL(clear_status_hilites, (BOOLEAN_P));
|
||||
E char *FDECL(get_status_hilites, (char *, int));
|
||||
E boolean NDECL(status_hilite_menu);
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 wintty.h $NHDT-Date: 1432512782 2015/05/25 00:13:02 $ $NHDT-Branch: master $:$NHDT-Revision: 1.21 $ */
|
||||
/* NetHack 3.6 wintty.h $NHDT-Date: 1433105383 2015/05/31 20:49:43 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.22 $ */
|
||||
/* Copyright (c) David Cohrs, 1991,1992 */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -215,6 +215,13 @@ E short FDECL(set_tty_font_name, (winid, char *));
|
||||
#endif
|
||||
E char *NDECL(tty_get_color_string);
|
||||
#endif
|
||||
#ifdef STATUS_VIA_WINDOWPORT
|
||||
E void NDECL(tty_status_init);
|
||||
E void FDECL(tty_status_update, (int, genericptr_t, int, int));
|
||||
#ifdef STATUS_HILITES
|
||||
E void FDECL(tty_status_threshold, (int, int, anything, int, int, int));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* other defs that really should go away (they're tty specific) */
|
||||
E void NDECL(tty_start_screen);
|
||||
|
||||
13
src/botl.c
13
src/botl.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 botl.c $NHDT-Date: 1433099909 2015/05/31 19:18:29 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.58 $ */
|
||||
/* NetHack 3.6 botl.c $NHDT-Date: 1433105388 2015/05/31 20:49:48 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.59 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -1101,7 +1101,8 @@ boolean from_configfile;
|
||||
}
|
||||
|
||||
void
|
||||
clear_status_hilites()
|
||||
clear_status_hilites(from_configfile)
|
||||
boolean from_configfile;
|
||||
{
|
||||
int i;
|
||||
anything it;
|
||||
@@ -1110,7 +1111,8 @@ clear_status_hilites()
|
||||
(void) memset((genericptr_t) &status_hilites[i], 0,
|
||||
sizeof(struct hilite_s));
|
||||
/* notify window port */
|
||||
status_threshold(i, blstats[0][i].anytype, it, 0, 0, 0);
|
||||
if (!from_configfile)
|
||||
status_threshold(i, blstats[0][i].anytype, it, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1262,7 +1264,9 @@ status_notify_windowport(all)
|
||||
boolean all;
|
||||
{
|
||||
int idx;
|
||||
anything it;
|
||||
|
||||
it.a_void = 0;
|
||||
for (idx = 0; idx < MAXBLSTATS; ++idx) {
|
||||
if (status_hilites[idx].set)
|
||||
status_threshold(idx, status_hilites[idx].anytype,
|
||||
@@ -1270,6 +1274,9 @@ boolean all;
|
||||
status_hilites[idx].behavior,
|
||||
status_hilites[idx].coloridx[0],
|
||||
status_hilites[idx].coloridx[1]);
|
||||
else
|
||||
status_threshold(idx, blstats[0][idx].anytype, it, 0, 0, 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 options.c $NHDT-Date: 1433087806 2015/05/31 15:56:46 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.209 $ */
|
||||
/* NetHack 3.6 options.c $NHDT-Date: 1433105391 2015/05/31 20:49:51 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.210 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -3146,7 +3146,7 @@ boolean tinitial, tfrom_file;
|
||||
complain_about_duplicate(opts, 1);
|
||||
op = string_for_opt(opts, TRUE);
|
||||
if (op && negated) {
|
||||
clear_status_hilites();
|
||||
clear_status_hilites(tfrom_file);
|
||||
return;
|
||||
} else if (!op) {
|
||||
/* a value is mandatory */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 windows.c $NHDT-Date: 1433099917 2015/05/31 19:18:37 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.31 $ */
|
||||
/* NetHack 3.6 windows.c $NHDT-Date: 1433105394 2015/05/31 20:49:54 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.32 $ */
|
||||
/* Copyright (c) D. Cohrs, 1993. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -804,10 +804,10 @@ const char *string UNUSED;
|
||||
/* genl backward compat stuff */
|
||||
/*****************************************************************************/
|
||||
|
||||
const char *fieldnm[MAXBLSTATS];
|
||||
const char *fieldfmt[MAXBLSTATS];
|
||||
char *vals[MAXBLSTATS];
|
||||
boolean activefields[MAXBLSTATS];
|
||||
const char *status_fieldnm[MAXBLSTATS];
|
||||
const char *status_fieldfmt[MAXBLSTATS];
|
||||
char *status_vals[MAXBLSTATS];
|
||||
boolean status_activefields[MAXBLSTATS];
|
||||
NEARDATA winid WIN_STATUS;
|
||||
|
||||
void
|
||||
@@ -815,10 +815,10 @@ genl_status_init()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < MAXBLSTATS; ++i) {
|
||||
vals[i] = (char *) alloc(MAXCO);
|
||||
*vals[i] = '\0';
|
||||
activefields[i] = FALSE;
|
||||
fieldfmt[i] = (const char *) 0;
|
||||
status_vals[i] = (char *) alloc(MAXCO);
|
||||
*status_vals[i] = '\0';
|
||||
status_activefields[i] = FALSE;
|
||||
status_fieldfmt[i] = (const char *) 0;
|
||||
}
|
||||
/* Use a window for the genl version; backward port compatibility */
|
||||
WIN_STATUS = create_nhwindow(NHW_STATUS);
|
||||
@@ -833,9 +833,9 @@ genl_status_finish()
|
||||
|
||||
/* free alloc'd memory here */
|
||||
for (i = 0; i < MAXBLSTATS; ++i) {
|
||||
if (vals[i])
|
||||
free((genericptr_t) vals[i]);
|
||||
vals[i] = (char *) 0;
|
||||
if (status_vals[i])
|
||||
free((genericptr_t) status_vals[i]);
|
||||
status_vals[i] = (char *) 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -846,9 +846,9 @@ const char *nm;
|
||||
const char *fmt;
|
||||
boolean enable;
|
||||
{
|
||||
fieldfmt[fieldidx] = fmt;
|
||||
fieldnm[fieldidx] = nm;
|
||||
activefields[fieldidx] = enable;
|
||||
status_fieldfmt[fieldidx] = fmt;
|
||||
status_fieldnm[fieldidx] = nm;
|
||||
status_activefields[fieldidx] = enable;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -870,29 +870,29 @@ genericptr_t ptr;
|
||||
};
|
||||
|
||||
if (idx != BL_FLUSH) {
|
||||
if (!activefields[idx])
|
||||
if (!status_activefields[idx])
|
||||
return;
|
||||
switch (idx) {
|
||||
case BL_CONDITION:
|
||||
cond = *condptr;
|
||||
*vals[idx] = '\0';
|
||||
*status_vals[idx] = '\0';
|
||||
if (cond & BL_MASK_BLIND)
|
||||
Strcat(vals[idx], " Blind");
|
||||
Strcat(status_vals[idx], " Blind");
|
||||
if (cond & BL_MASK_CONF)
|
||||
Strcat(vals[idx], " Conf");
|
||||
Strcat(status_vals[idx], " Conf");
|
||||
if (cond & BL_MASK_FOODPOIS)
|
||||
Strcat(vals[idx], " FoodPois");
|
||||
Strcat(status_vals[idx], " FoodPois");
|
||||
if (cond & BL_MASK_ILL)
|
||||
Strcat(vals[idx], " Ill");
|
||||
Strcat(status_vals[idx], " Ill");
|
||||
if (cond & BL_MASK_STUNNED)
|
||||
Strcat(vals[idx], " Stun");
|
||||
Strcat(status_vals[idx], " Stun");
|
||||
if (cond & BL_MASK_HALLU)
|
||||
Strcat(vals[idx], " Hallu");
|
||||
Strcat(status_vals[idx], " Hallu");
|
||||
if (cond & BL_MASK_SLIMED)
|
||||
Strcat(vals[idx], " Slime");
|
||||
Strcat(status_vals[idx], " Slime");
|
||||
break;
|
||||
default:
|
||||
Sprintf(vals[idx], fieldfmt[idx] ? fieldfmt[idx] : "%s", text);
|
||||
Sprintf(status_vals[idx], status_fieldfmt[idx] ? status_fieldfmt[idx] : "%s", text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -901,14 +901,14 @@ genericptr_t ptr;
|
||||
newbot1[0] = '\0';
|
||||
for (i = 0; fieldorder[0][i] != BL_FLUSH; ++i) {
|
||||
int idx1 = fieldorder[0][i];
|
||||
if (activefields[idx1])
|
||||
Strcat(newbot1, vals[idx1]);
|
||||
if (status_activefields[idx1])
|
||||
Strcat(newbot1, status_vals[idx1]);
|
||||
}
|
||||
newbot2[0] = '\0';
|
||||
for (i = 0; fieldorder[1][i] != BL_FLUSH; ++i) {
|
||||
int idx2 = fieldorder[1][i];
|
||||
if (activefields[idx2])
|
||||
Strcat(newbot2, vals[idx2]);
|
||||
if (status_activefields[idx2])
|
||||
Strcat(newbot2, status_vals[idx2]);
|
||||
}
|
||||
curs(WIN_STATUS, 1, 0);
|
||||
putstr(WIN_STATUS, 0, newbot1);
|
||||
|
||||
104
win/tty/wintty.c
104
win/tty/wintty.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 wintty.c $NHDT-Date: 1433099933 2015/05/31 19:18:53 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.96 $ */
|
||||
/* NetHack 3.6 wintty.c $NHDT-Date: 1433105400 2015/05/31 20:50:00 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.97 $ */
|
||||
/* Copyright (c) David Cohrs, 1991 */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -89,10 +89,11 @@ struct window_procs tty_procs = {
|
||||
#endif
|
||||
tty_getmsghistory, tty_putmsghistory,
|
||||
#ifdef STATUS_VIA_WINDOWPORT
|
||||
genl_status_init, genl_status_finish, genl_status_enablefield,
|
||||
genl_status_update,
|
||||
tty_status_init,
|
||||
genl_status_finish, genl_status_enablefield,
|
||||
tty_status_update,
|
||||
#ifdef STATUS_HILITES
|
||||
genl_status_threshold,
|
||||
tty_status_threshold,
|
||||
#endif
|
||||
#endif
|
||||
genl_can_suspend_yes,
|
||||
@@ -3031,18 +3032,51 @@ const char *s;
|
||||
#ifdef STATUS_VIA_WINDOWPORT
|
||||
|
||||
/*
|
||||
* These come from the genl_ routines
|
||||
* in src/windows.c
|
||||
* The following data structures come from the genl_ routines in
|
||||
* src/windows.c and as such are considered to be on the window-port
|
||||
* "side" of things, rather than the NetHack-core "side" of things.
|
||||
*/
|
||||
extern const char *fieldnm[MAXBLSTATS];
|
||||
extern const char *fieldfmt[MAXBLSTATS];
|
||||
extern char *vals[MAXBLSTATS];
|
||||
extern boolean activefields[MAXBLSTATS];
|
||||
|
||||
extern const char *status_fieldnm[MAXBLSTATS];
|
||||
extern const char *status_fieldfmt[MAXBLSTATS];
|
||||
extern char *status_vals[MAXBLSTATS];
|
||||
extern boolean status_activefields[MAXBLSTATS];
|
||||
extern winid WIN_STATUS;
|
||||
|
||||
#ifdef STATUS_HILITES
|
||||
typedef struct hilite_data_struct {
|
||||
int thresholdtype;
|
||||
anything threshold;
|
||||
int behavior;
|
||||
int under;
|
||||
int over;
|
||||
} hilite_data_t;
|
||||
static hilite_data_t tty_status_hilites[MAXBLSTATS];
|
||||
static int tty_status_colors[MAXBLSTATS];
|
||||
#endif
|
||||
|
||||
void
|
||||
tty_status_update(idx, ptr, chg, percent)
|
||||
int idx, chg, percent;
|
||||
tty_status_init()
|
||||
{
|
||||
int i;
|
||||
|
||||
/* let genl_status_init do most of the initialization */
|
||||
genl_status_init();
|
||||
|
||||
for (i = 0; i < MAXBLSTATS; ++i) {
|
||||
#ifdef STATUS_HILITES
|
||||
tty_status_colors[i] = CLR_MAX; /* no color */
|
||||
tty_status_hilites[i].thresholdtype = 0;
|
||||
tty_status_hilites[i].behavior = BL_TH_NONE;
|
||||
tty_status_hilites[i].under = BL_HILITE_NONE;
|
||||
tty_status_hilites[i].over = BL_HILITE_NONE;
|
||||
#endif /* STATUS_HILITES */
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tty_status_update(fldidx, ptr, chg, percent)
|
||||
int fldidx, chg, percent;
|
||||
genericptr_t ptr;
|
||||
{
|
||||
char newbot1[MAXCO], newbot2[MAXCO];
|
||||
@@ -3058,46 +3092,48 @@ genericptr_t ptr;
|
||||
BL_CAP, BL_CONDITION, BL_FLUSH}
|
||||
};
|
||||
|
||||
if (idx != BL_FLUSH) {
|
||||
if (!activefields[idx])
|
||||
if (fldidx != BL_FLUSH) {
|
||||
if (!status_activefields[fldidx])
|
||||
return;
|
||||
switch (idx) {
|
||||
switch (fldidx) {
|
||||
case BL_CONDITION:
|
||||
cond = *condptr;
|
||||
*vals[idx] = '\0';
|
||||
*status_vals[fldidx] = '\0';
|
||||
if (cond & BL_MASK_BLIND)
|
||||
Strcat(vals[idx], " Blind");
|
||||
Strcat(status_vals[fldidx], " Blind");
|
||||
if (cond & BL_MASK_CONF)
|
||||
Strcat(vals[idx], " Conf");
|
||||
Strcat(status_vals[fldidx], " Conf");
|
||||
if (cond & BL_MASK_FOODPOIS)
|
||||
Strcat(vals[idx], " FoodPois");
|
||||
Strcat(status_vals[fldidx], " FoodPois");
|
||||
if (cond & BL_MASK_ILL)
|
||||
Strcat(vals[idx], " Ill");
|
||||
Strcat(status_vals[fldidx], " Ill");
|
||||
if (cond & BL_MASK_STUNNED)
|
||||
Strcat(vals[idx], " Stun");
|
||||
Strcat(status_vals[fldidx], " Stun");
|
||||
if (cond & BL_MASK_HALLU)
|
||||
Strcat(vals[idx], " Hallu");
|
||||
Strcat(status_vals[fldidx], " Hallu");
|
||||
if (cond & BL_MASK_SLIMED)
|
||||
Strcat(vals[idx], " Slime");
|
||||
Strcat(status_vals[fldidx], " Slime");
|
||||
break;
|
||||
default:
|
||||
Sprintf(vals[idx], fieldfmt[idx] ? fieldfmt[idx] : "%s", text);
|
||||
Sprintf(status_vals[fldidx], status_fieldfmt[fldidx] ? status_fieldfmt[fldidx] : "%s", text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* This genl version updates everything on the display, everytime */
|
||||
/* This version copied from the genl_ version currently
|
||||
* updates everything on the display, everytime
|
||||
*/
|
||||
newbot1[0] = '\0';
|
||||
for (i = 0; fieldorder[0][i] != BL_FLUSH; ++i) {
|
||||
int idx1 = fieldorder[0][i];
|
||||
if (activefields[idx1])
|
||||
Strcat(newbot1, vals[idx1]);
|
||||
int fldidx1 = fieldorder[0][i];
|
||||
if (status_activefields[fldidx1])
|
||||
Strcat(newbot1, status_vals[fldidx1]);
|
||||
}
|
||||
newbot2[0] = '\0';
|
||||
for (i = 0; fieldorder[1][i] != BL_FLUSH; ++i) {
|
||||
int idx2 = fieldorder[1][i];
|
||||
if (activefields[idx2])
|
||||
Strcat(newbot2, vals[idx2]);
|
||||
int fldidx2 = fieldorder[1][i];
|
||||
if (status_activefields[fldidx2])
|
||||
Strcat(newbot2, status_vals[fldidx2]);
|
||||
}
|
||||
curs(WIN_STATUS, 1, 0);
|
||||
putstr(WIN_STATUS, 0, newbot1);
|
||||
@@ -3106,12 +3142,18 @@ genericptr_t ptr;
|
||||
}
|
||||
|
||||
#ifdef STATUS_HILITES
|
||||
|
||||
void
|
||||
tty_status_threshold(fldidx, thresholdtype, threshold, behavior, under, over)
|
||||
int fldidx, thresholdtype;
|
||||
int behavior, under, over;
|
||||
anything threshold;
|
||||
{
|
||||
tty_status_hilites[fldidx].thresholdtype = thresholdtype;
|
||||
tty_status_hilites[fldidx].threshold = threshold;
|
||||
tty_status_hilites[fldidx].behavior = behavior;
|
||||
tty_status_hilites[fldidx].under = under;
|
||||
tty_status_hilites[fldidx].over = over;
|
||||
return;
|
||||
}
|
||||
#endif /* STATUS_HILITES */
|
||||
|
||||
Reference in New Issue
Block a user