more status_hilite work

Changes to be committed:
	modified:   include/extern.h
	modified:   src/botl.c
	modified:   src/options.c
	modified:   src/windows.c

defer notification of the window port until after
proper initialization. Options are processed very
early in 3.6.0
This commit is contained in:
nhmall
2015-05-31 11:54:06 -04:00
parent ef0c00d99b
commit 7e4074b61f
4 changed files with 49 additions and 33 deletions
+13 -8
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 extern.h $NHDT-Date: 1432890461 2015/05/29 09:07:41 $ $NHDT-Branch: master $:$NHDT-Revision: 1.498 $ */ /* NetHack 3.6 extern.h $NHDT-Date: 1433087625 2015/05/31 15:53:45 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.499 $ */
/* Copyright (c) Steve Creps, 1988. */ /* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -152,14 +152,9 @@ E void NDECL(bot);
#ifdef STATUS_VIA_WINDOWPORT #ifdef STATUS_VIA_WINDOWPORT
E void FDECL(status_initialize, (BOOLEAN_P)); E void FDECL(status_initialize, (BOOLEAN_P));
E void NDECL(status_finish); E void NDECL(status_finish);
E void NDECL(genl_status_init); E void FDECL(status_notify_windowport, (BOOLEAN_P));
E void NDECL(genl_status_finish);
E void FDECL(genl_status_update, (int, genericptr_t, int, int));
E void FDECL(genl_status_enablefield,
(int, const char *, const char *, BOOLEAN_P));
#ifdef STATUS_HILITES #ifdef STATUS_HILITES
E void FDECL(genl_status_threshold, (int, int, anything, int, int, int)); E boolean FDECL(set_status_hilites, (char *op, BOOLEAN_P));
E boolean FDECL(set_status_hilites, (char *op));
E void NDECL(clear_status_hilites); E void NDECL(clear_status_hilites);
E char *FDECL(get_status_hilites, (char *, int)); E char *FDECL(get_status_hilites, (char *, int));
E boolean NDECL(status_hilite_menu); E boolean NDECL(status_hilite_menu);
@@ -2629,6 +2624,16 @@ E void FDECL(genl_putmsghistory, (const char *, BOOLEAN_P));
#ifdef HANGUPHANDLING #ifdef HANGUPHANDLING
E void NDECL(nhwindows_hangup); E void NDECL(nhwindows_hangup);
#endif #endif
#ifdef STATUS_VIA_WINDOWPORT
E void NDECL(genl_status_init);
E void NDECL(genl_status_finish);
E void FDECL(genl_status_enablefield,
(int, const char *, const char *, BOOLEAN_P));
E void FDECL(genl_status_update, (int, genericptr_t, int, int));
#ifdef STATUS_HILITES
E void FDECL(genl_status_threshold, (int, int, anything, int, int, int));
#endif
#endif
/* ### wizard.c ### */ /* ### wizard.c ### */
+33 -22
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 botl.c $NHDT-Date: 1433082365 2015/05/31 14:26:05 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.53 $ */ /* NetHack 3.6 botl.c $NHDT-Date: 1433087631 2015/05/31 15:53:51 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.54 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -96,20 +96,6 @@ STATIC_DCL void NDECL(bot1);
STATIC_DCL void NDECL(bot2); STATIC_DCL void NDECL(bot2);
#endif #endif
/* MAXCO must hold longest uncompressed status line, and must be larger
* than COLNO
*
* longest practical second status line at the moment is
* Astral Plane $:12345 HP:700(700) Pw:111(111) AC:-127 Xp:30/123456789
* T:123456 Satiated Conf FoodPois Ill Blind Stun Hallu Overloaded
* -- or somewhat over 130 characters
*/
#if COLNO <= 140
#define MAXCO 160
#else
#define MAXCO (COLNO + 20)
#endif
STATIC_OVL NEARDATA int mrank_sz = STATIC_OVL NEARDATA int mrank_sz =
0; /* loaded by max_rank_sz (from u_init) */ 0; /* loaded by max_rank_sz (from u_init) */
STATIC_DCL const char *NDECL(rank); STATIC_DCL const char *NDECL(rank);
@@ -1049,6 +1035,7 @@ bot()
struct hilite_s { struct hilite_s {
boolean set; boolean set;
unsigned anytype;
anything threshold; anything threshold;
int behavior; int behavior;
int coloridx[2]; int coloridx[2];
@@ -1065,8 +1052,9 @@ struct hilite_s status_hilites[MAXBLSTATS];
* strings, then calls assign_hilite() to make the adjustments. * strings, then calls assign_hilite() to make the adjustments.
*/ */
boolean boolean
set_status_hilites(op) set_status_hilites(op, from_configfile)
char *op; char *op;
boolean from_configfile;
{ {
char hsbuf[4][QBUFSZ]; char hsbuf[4][QBUFSZ];
boolean rslt, badopt = FALSE; boolean rslt, badopt = FALSE;
@@ -1080,7 +1068,7 @@ char *op;
if (c == ' ') { if (c == ' ') {
if (fldnum >= 2) { if (fldnum >= 2) {
rslt = assign_hilite(&hsbuf[0][0], &hsbuf[1][0], &hsbuf[2][0], rslt = assign_hilite(&hsbuf[0][0], &hsbuf[1][0], &hsbuf[2][0],
&hsbuf[3][0]); &hsbuf[3][0], from_configfile);
if (!rslt) { if (!rslt) {
badopt = TRUE; badopt = TRUE;
break; break;
@@ -1101,7 +1089,7 @@ char *op;
} }
if (fldnum >= 2 && !badopt) { if (fldnum >= 2 && !badopt) {
rslt = assign_hilite(&hsbuf[0][0], &hsbuf[1][0], &hsbuf[2][0], rslt = assign_hilite(&hsbuf[0][0], &hsbuf[1][0], &hsbuf[2][0],
&hsbuf[3][0]); &hsbuf[3][0], from_configfile);
if (!rslt) if (!rslt)
badopt = TRUE; badopt = TRUE;
} }
@@ -1125,8 +1113,9 @@ clear_status_hilites()
} }
STATIC_OVL boolean STATIC_OVL boolean
assign_hilite(sa, sb, sc, sd) assign_hilite(sa, sb, sc, sd, from_configfile)
char *sa, *sb, *sc, *sd; char *sa, *sb, *sc, *sd;
boolean from_configfile;
{ {
char *tmp, *how; char *tmp, *how;
int i = -1, dt = -1, idx = -1; int i = -1, dt = -1, idx = -1;
@@ -1253,13 +1242,35 @@ char *sa, *sb, *sc, *sd;
status_hilites[idx].threshold = threshold; status_hilites[idx].threshold = threshold;
status_hilites[idx].set = TRUE; status_hilites[idx].set = TRUE;
} }
status_hilites[idx].anytype = dt;
/* Now finally, we notify the window port */ /* Now finally, we notify the window port */
status_threshold(idx, dt, threshold, status_hilites[idx].behavior, if (!from_configfile)
status_hilites[idx].coloridx[0], status_threshold(idx, status_hilites[idx].anytype,
status_hilites[idx].coloridx[1]); status_hilites[idx].threshold,
status_hilites[idx].behavior,
status_hilites[idx].coloridx[0],
status_hilites[idx].coloridx[1]);
return TRUE; return TRUE;
} }
void
status_notify_windowport(all)
boolean all;
{
int idx;
for (idx = 0; idx < MAXBLSTATS; ++idx) {
if (status_hilites[idx].set)
status_threshold(idx, status_hilites[idx].anytype,
status_hilites[idx].threshold,
status_hilites[idx].behavior,
status_hilites[idx].coloridx[0],
status_hilites[idx].coloridx[1]);
}
}
/* /*
* get_status_hilites * get_status_hilites
* *
+2 -2
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 options.c $NHDT-Date: 1432974335 2015/05/30 08:25:35 $ $NHDT-Branch: master $:$NHDT-Revision: 1.207 $ */ /* NetHack 3.6 options.c $NHDT-Date: 1433087636 2015/05/31 15:53:56 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.208 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -3153,7 +3153,7 @@ boolean tinitial, tfrom_file;
badoption(opts); badoption(opts);
return; return;
} }
if (!set_status_hilites(op)) if (!set_status_hilites(op, tfrom_file))
badoption(opts); badoption(opts);
return; return;
} }
+1 -1
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 windows.c $NHDT-Date: 1433082382 2015/05/31 14:26:22 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.29 $ */ /* NetHack 3.6 windows.c $NHDT-Date: 1433087641 2015/05/31 15:54:01 $ $NHDT-Branch: status_hilite $:$NHDT-Revision: 1.30 $ */
/* Copyright (c) D. Cohrs, 1993. */ /* Copyright (c) D. Cohrs, 1993. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */