X11 status display

Flag some unused parameters and remove some unused variables.
Fix compile for !defined(TEXTCOLOR).
This commit is contained in:
PatR
2018-10-22 15:28:19 -07:00
parent 0470065b47
commit a6ab5c8a49

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 winstat.c $NHDT-Date: 1452920162 2016/01/16 04:56:02 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.16 $ */ /* NetHack 3.6 winstat.c $NHDT-Date: 1540247293 2018/10/22 22:28:13 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.18 $ */
/* Copyright (c) Dean Luick, 1992 */ /* Copyright (c) Dean Luick, 1992 */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -114,7 +114,7 @@ static enum statusfields X11_fieldorder[X11_NUM_STATUS_LINES][X11_NUM_STATUS_FIE
BL_CAP, BL_CONDITION, BL_FLUSH } BL_CAP, BL_CONDITION, BL_FLUSH }
}; };
static boolean X11_labels_created = FALSE; /* static boolean X11_labels_created = FALSE; */
static Widget X11_status_widget; static Widget X11_status_widget;
static Widget X11_status_labels[MAXBLSTATS]; static Widget X11_status_labels[MAXBLSTATS];
static Widget X11_cond_labels[32]; /* Ugh */ static Widget X11_cond_labels[32]; /* Ugh */
@@ -235,13 +235,16 @@ const char *text;
return; return;
label = X11_cond_labels[idx]; label = X11_cond_labels[idx];
if ((X11_condition_bits & bm)) { if ((X11_condition_bits & bm) != 0) {
int attrmask, coloridx; int attrmask, coloridx;
XFontStruct *font; XFontStruct *font;
Position lbl_x; Position lbl_x;
Position lbl_y; Position lbl_y;
#ifdef TEXTCOLOR #ifdef TEXTCOLOR
coloridx = condcolor(bm, colormasks); coloridx = condcolor(bm, colormasks);
#else
coloridx = NO_COLOR;
#endif #endif
attrmask = condattr(bm, colormasks); attrmask = condattr(bm, colormasks);
num_args = 0; num_args = 0;
@@ -263,7 +266,8 @@ const char *text;
XtSetArg(args[num_args], nhStr(XtNlabel), (text && *text) ? text : ""); num_args++; XtSetArg(args[num_args], nhStr(XtNlabel), (text && *text) ? text : ""); num_args++;
XtSetArg(args[num_args], nhStr(XtNwidth), lbl_wid); num_args++; XtSetArg(args[num_args], nhStr(XtNwidth), lbl_wid); num_args++;
fg = (coloridx != NO_COLOR) ? X11_colors[coloridx] : X11_status_widget_fg; fg = (coloridx != NO_COLOR) ? X11_colors[coloridx]
: X11_status_widget_fg;
if (attrmask & HL_INVERSE) { if (attrmask & HL_INVERSE) {
Pixel tmppx = fg; Pixel tmppx = fg;
fg = bg; fg = bg;
@@ -298,25 +302,18 @@ const char *text;
void void
X11_status_update_tty(fld, ptr, chg, percent, color, colormasks) X11_status_update_tty(fld, ptr, chg, percent, color, colormasks)
int fld, chg UNUSED, percent UNUSED, color; int fld, chg UNUSED, percent, color;
genericptr_t ptr; genericptr_t ptr;
unsigned long *colormasks; unsigned long *colormasks;
{ {
static boolean oncearound = FALSE; /* prevent premature partial display */
long *condptr = (long *) ptr; long *condptr = (long *) ptr;
int i, j, attrmask = 0;
#ifdef TEXTCOLOR
int coloridx = NO_COLOR; int coloridx = NO_COLOR;
#endif
const char *text = (char *) ptr; const char *text = (char *) ptr;
char tmpbuf[BUFSZ]; char tmpbuf[BUFSZ];
static boolean oncearound = FALSE; /* prevent premature partial display */
int attridx = 0; int attridx = 0;
XFontStruct *font; XFontStruct *font;
int direction;
int ascent;
int descent;
XCharStruct overall;
Arg args[10]; Arg args[10];
Cardinal num_args; Cardinal num_args;
Position lbl_x; Position lbl_x;
@@ -328,6 +325,10 @@ unsigned long *colormasks;
Widget label; Widget label;
Pixel fg = X11_status_widget_fg, bg = X11_status_widget_bg; Pixel fg = X11_status_widget_fg, bg = X11_status_widget_bg;
#ifndef TEXTCOLOR
color = NO_COLOR;
#endif
if (fld < BL_RESET || fld >= MAXBLSTATS) if (fld < BL_RESET || fld >= MAXBLSTATS)
return; return;
@@ -347,18 +348,10 @@ unsigned long *colormasks;
(fld == BL_TITLE && iflags.wc2_hitpointbar) ? "%-30s" : (fld == BL_TITLE && iflags.wc2_hitpointbar) ? "%-30s" :
status_fieldfmt[fld] ? status_fieldfmt[fld] : "%s", status_fieldfmt[fld] ? status_fieldfmt[fld] : "%s",
text); text);
#ifdef TEXTCOLOR
X11_status_colors[fld] = color; X11_status_colors[fld] = color;
#else
X11_status_colors[fld] = NO_COLOR;
#endif
if (iflags.wc2_hitpointbar && fld == BL_HP) { if (iflags.wc2_hitpointbar && fld == BL_HP) {
hpbar_percent = percent; hpbar_percent = percent;
#ifdef TEXTCOLOR
hpbar_color = color; hpbar_color = color;
#else
hpbar_color = NO_COLOR;
#endif
} }
break; break;
} }
@@ -381,13 +374,11 @@ unsigned long *colormasks;
text = status_vals[fld]; text = status_vals[fld];
if (fld == BL_GOLD) if (fld == BL_GOLD)
text = decode_mixed(tmpbuf, text); text = decode_mixed(tmpbuf, text);
#ifdef TEXTCOLOR #ifdef TEXTCOLOR
coloridx = X11_status_colors[fld] & 0x00FF; coloridx = X11_status_colors[fld] & 0x00FF;
#endif #endif
attridx = (X11_status_colors[fld] & 0xFF00) >> 8; attridx = (X11_status_colors[fld] & 0xFF00) >> 8;
num_args = 0; num_args = 0;
XtSetArg(args[num_args], nhStr(XtNfont), &font); num_args++; XtSetArg(args[num_args], nhStr(XtNfont), &font); num_args++;
XtSetArg(args[num_args], nhStr(XtNx), &lbl_x); num_args++; XtSetArg(args[num_args], nhStr(XtNx), &lbl_x); num_args++;
@@ -398,7 +389,8 @@ unsigned long *colormasks;
XtSetArg(args[num_args], nhStr(XtNborderWidth), &lbl_border_wid); num_args++; XtSetArg(args[num_args], nhStr(XtNborderWidth), &lbl_border_wid); num_args++;
XtGetValues(label, args, num_args); XtGetValues(label, args, num_args);
/*raw_printf("font: %i-%i", font->min_bounds.width, font->max_bounds.width);*/ /*raw_printf("font: %i-%i",
font->min_bounds.width, font->max_bounds.width);*/
if (text && *text) if (text && *text)
lbl_wid = lbl_iwidth + font->max_bounds.width * strlen(text); lbl_wid = lbl_iwidth + font->max_bounds.width * strlen(text);
@@ -408,12 +400,15 @@ unsigned long *colormasks;
/*raw_printf("1:lbl_wid=%i('%s')", lbl_wid, text);*/ /*raw_printf("1:lbl_wid=%i('%s')", lbl_wid, text);*/
num_args = 0; num_args = 0;
XtSetArg(args[num_args], nhStr(XtNlabel), (text && *text) ? text : ""); num_args++; XtSetArg(args[num_args], nhStr(XtNlabel),
(text && *text) ? text : ""); num_args++;
XtSetArg(args[num_args], nhStr(XtNwidth), lbl_wid); num_args++; XtSetArg(args[num_args], nhStr(XtNwidth), lbl_wid); num_args++;
fg = (coloridx != NO_COLOR) ? X11_colors[coloridx] : X11_status_widget_fg; fg = (coloridx != NO_COLOR) ? X11_colors[coloridx]
: X11_status_widget_fg;
if (attridx & HL_INVERSE) { if (attridx & HL_INVERSE) {
Pixel tmppx = fg; Pixel tmppx = fg;
fg = bg; fg = bg;
bg = tmppx; bg = tmppx;
} }
@@ -427,9 +422,11 @@ unsigned long *colormasks;
XtResizeWidget(label, lbl_wid, lbl_hei, lbl_border_wid); XtResizeWidget(label, lbl_wid, lbl_hei, lbl_border_wid);
} }
} else { } else {
int x,y; int x, y;
for (y = 0; y < X11_NUM_STATUS_LINES; y++) { for (y = 0; y < X11_NUM_STATUS_LINES; y++) {
Cardinal dx = 0; Cardinal dx = 0;
for (x = 0; x < X11_NUM_STATUS_FIELD; x++) { for (x = 0; x < X11_NUM_STATUS_FIELD; x++) {
int f = X11_fieldorder[y][x]; int f = X11_fieldorder[y][x];
@@ -449,7 +446,8 @@ unsigned long *colormasks;
XtSetArg(args[num_args], nhStr(XtNy), &lbl_y); num_args++; XtSetArg(args[num_args], nhStr(XtNy), &lbl_y); num_args++;
XtSetArg(args[num_args], nhStr(XtNwidth), &lbl_wid); num_args++; XtSetArg(args[num_args], nhStr(XtNwidth), &lbl_wid); num_args++;
XtSetArg(args[num_args], nhStr(XtNheight), &lbl_hei); num_args++; XtSetArg(args[num_args], nhStr(XtNheight), &lbl_hei); num_args++;
XtSetArg(args[num_args], nhStr(XtNborderWidth), &lbl_border_wid); num_args++; XtSetArg(args[num_args], nhStr(XtNborderWidth),
&lbl_border_wid); num_args++;
XtGetValues(label, args, num_args); XtGetValues(label, args, num_args);
lbl_x = dx; lbl_x = dx;
@@ -457,7 +455,8 @@ unsigned long *colormasks;
num_args = 0; num_args = 0;
XtSetArg(args[num_args], nhStr(XtNx), lbl_x); num_args++; XtSetArg(args[num_args], nhStr(XtNx), lbl_x); num_args++;
XtSetValues(label, args, num_args); XtSetValues(label, args, num_args);
XtConfigureWidget(label, lbl_x, lbl_y, lbl_wid, lbl_hei, lbl_border_wid); XtConfigureWidget(label, lbl_x, lbl_y,
lbl_wid, lbl_hei, lbl_border_wid);
if (lbl_wid > 1) if (lbl_wid > 1)
dx += lbl_wid; dx += lbl_wid;
@@ -475,7 +474,8 @@ unsigned long *colormasks;
XtSetArg(args[num_args], nhStr(XtNy), &lbl_y); num_args++; XtSetArg(args[num_args], nhStr(XtNy), &lbl_y); num_args++;
XtSetArg(args[num_args], nhStr(XtNwidth), &lbl_wid); num_args++; XtSetArg(args[num_args], nhStr(XtNwidth), &lbl_wid); num_args++;
XtSetArg(args[num_args], nhStr(XtNheight), &lbl_hei); num_args++; XtSetArg(args[num_args], nhStr(XtNheight), &lbl_hei); num_args++;
XtSetArg(args[num_args], nhStr(XtNborderWidth), &lbl_border_wid); num_args++; XtSetArg(args[num_args], nhStr(XtNborderWidth),
&lbl_border_wid); num_args++;
XtGetValues(label, args, num_args); XtGetValues(label, args, num_args);
lbl_x = dx; lbl_x = dx;
@@ -485,7 +485,8 @@ unsigned long *colormasks;
XtSetArg(args[num_args], nhStr(XtNx), lbl_x); num_args++; XtSetArg(args[num_args], nhStr(XtNx), lbl_x); num_args++;
XtSetArg(args[num_args], nhStr(XtNlabel), text); num_args++; XtSetArg(args[num_args], nhStr(XtNlabel), text); num_args++;
XtSetValues(label, args, num_args); XtSetValues(label, args, num_args);
XtConfigureWidget(label, lbl_x, lbl_y, lbl_wid, lbl_hei, lbl_border_wid); XtConfigureWidget(label, lbl_x, lbl_y,
lbl_wid, lbl_hei, lbl_border_wid);
dx += lbl_wid; dx += lbl_wid;
} }
@@ -493,14 +494,14 @@ unsigned long *colormasks;
} }
} }
/*ARGSUSED*/
void void
X11_status_update_fancy(fld, ptr, chg, percent, color, colormasks) X11_status_update_fancy(fld, ptr, chg, percent, color, colormasks)
int fld, chg UNUSED, percent UNUSED, color; int fld, chg UNUSED, percent UNUSED, color UNUSED;
genericptr_t ptr; genericptr_t ptr;
unsigned long *colormasks; unsigned long *colormasks UNUSED;
{ {
int i; static const struct {
struct {
int bl, ff; int bl, ff;
} bl_to_fancyfield[] = { } bl_to_fancyfield[] = {
{ BL_TITLE, F_NAME }, { BL_TITLE, F_NAME },
@@ -526,9 +527,8 @@ unsigned long *colormasks;
{ BL_LEVELDESC, F_DLEVEL }, { BL_LEVELDESC, F_DLEVEL },
{ BL_EXP, F_EXP } { BL_EXP, F_EXP }
}; };
static const struct {
struct { unsigned long mask;
long mask;
int ff; int ff;
} mask_to_fancyfield[] = { } mask_to_fancyfield[] = {
{ BL_MASK_STONE, F_STONE }, { BL_MASK_STONE, F_STONE },
@@ -545,10 +545,12 @@ unsigned long *colormasks;
{ BL_MASK_FLY, F_FLY }, { BL_MASK_FLY, F_FLY },
{ BL_MASK_RIDE, F_RIDE } { BL_MASK_RIDE, F_RIDE }
}; };
int i;
if (fld == BL_RESET || fld == BL_FLUSH) { if (fld == BL_RESET || fld == BL_FLUSH) {
if (WIN_STATUS != WIN_ERR) { if (WIN_STATUS != WIN_ERR) {
struct xwindow *wp = &window_list[WIN_STATUS]; struct xwindow *wp = &window_list[WIN_STATUS];
update_fancy_status(wp); update_fancy_status(wp);
} }
return; return;
@@ -625,9 +627,7 @@ Widget parent, top;
Widget w; Widget w;
Arg args[16]; Arg args[16];
Cardinal num_args; Cardinal num_args;
char buf[32];
int i, x, y; int i, x, y;
Widget testlabel;
num_args = 0; num_args = 0;
if (top != (Widget) 0) { if (top != (Widget) 0) {
@@ -653,17 +653,20 @@ Widget parent, top;
int fld = X11_fieldorder[y][x]; int fld = X11_fieldorder[y][x];
char labelname[BUFSZ]; char labelname[BUFSZ];
int prevfld; int prevfld;
if (fld <= BL_FLUSH) if (fld <= BL_FLUSH)
continue; continue;
Sprintf(labelname, "label_%s", bl_idx_to_fldname(fld)); Sprintf(labelname, "label_%s", bl_idx_to_fldname(fld));
num_args = 0; num_args = 0;
if (y > 0) { if (y > 0) {
prevfld = X11_fieldorder[y-1][0]; prevfld = X11_fieldorder[y-1][0];
XtSetArg(args[num_args], nhStr(XtNfromVert), X11_status_labels[prevfld]); num_args++; XtSetArg(args[num_args], nhStr(XtNfromVert),
X11_status_labels[prevfld]); num_args++;
} }
if (x > 0) { if (x > 0) {
prevfld = X11_fieldorder[y][x-1]; prevfld = X11_fieldorder[y][x-1];
XtSetArg(args[num_args], nhStr(XtNfromHoriz), X11_status_labels[prevfld]); num_args++; XtSetArg(args[num_args], nhStr(XtNfromHoriz),
X11_status_labels[prevfld]); num_args++;
} }
XtSetArg(args[num_args], nhStr(XtNhorizDistance), 0); num_args++; XtSetArg(args[num_args], nhStr(XtNhorizDistance), 0); num_args++;
@@ -676,7 +679,8 @@ Widget parent, top;
XtSetArg(args[num_args], nhStr(XtNjustify), XtJustifyLeft); num_args++; XtSetArg(args[num_args], nhStr(XtNjustify), XtJustifyLeft); num_args++;
XtSetArg(args[num_args], nhStr(XtNborderWidth), 0); num_args++; XtSetArg(args[num_args], nhStr(XtNborderWidth), 0); num_args++;
/* /*
XtSetArg(args[num_args], nhStr(XtNlabel), bl_idx_to_fldname(fld)); num_args++; XtSetArg(args[num_args], nhStr(XtNlabel),
bl_idx_to_fldname(fld)); num_args++;
*/ */
XtSetArg(args[num_args], nhStr(XtNlabel), ""); num_args++; XtSetArg(args[num_args], nhStr(XtNlabel), ""); num_args++;
X11_status_labels[fld] = XtCreateManagedWidget(labelname, X11_status_labels[fld] = XtCreateManagedWidget(labelname,
@@ -693,7 +697,8 @@ Widget parent, top;
num_args = 0; num_args = 0;
prevfld = X11_fieldorder[0][0]; prevfld = X11_fieldorder[0][0];
XtSetArg(args[num_args], nhStr(XtNfromVert), X11_status_labels[prevfld]); num_args++; XtSetArg(args[num_args], nhStr(XtNfromVert),
X11_status_labels[prevfld]); num_args++;
XtSetArg(args[num_args], nhStr(XtNfromHoriz), XtSetArg(args[num_args], nhStr(XtNfromHoriz),
(i == 0) ? X11_status_labels[BL_CONDITION] (i == 0) ? X11_status_labels[BL_CONDITION]
@@ -718,10 +723,11 @@ Widget parent, top;
return w; return w;
} }
/*ARGSUSED*/
void void
create_status_window_tty(wp, create_popup, parent) create_status_window_tty(wp, create_popup, parent)
struct xwindow *wp; /* window pointer */ struct xwindow *wp; /* window pointer */
boolean create_popup; boolean create_popup UNUSED;
Widget parent; Widget parent;
{ {
Arg args[10]; Arg args[10];
@@ -755,10 +761,11 @@ struct xwindow *wp;
wp->type = NHW_NONE; wp->type = NHW_NONE;
} }
/*ARGSUSED*/
void void
adjust_status_tty(wp, str) adjust_status_tty(wp, str)
struct xwindow *wp; struct xwindow *wp UNUSED;
const char *str; const char *str UNUSED;
{ {
/* nothing */ /* nothing */
} }
@@ -1445,12 +1452,11 @@ int i;
update_val(sv, val); update_val(sv, val);
} }
/*ARGUSED*/
static void static void
update_fancy_status(wp) update_fancy_status(wp)
struct xwindow *wp; struct xwindow *wp UNUSED;
{ {
struct X_status_value *sv;
long val;
int i; int i;
/*if (wp->cursy != 0) /*if (wp->cursy != 0)