Merge branch 'NetHack-3.6.2-beta01' into NetHack-3.6.2
This commit is contained in:
@@ -100,6 +100,10 @@ NetHack*highlight_prompt: False
|
||||
! has a lot of popups and is almost unplayable without some kind of autofocus.
|
||||
!NetHack*autofocus: True
|
||||
!
|
||||
|
||||
! True, use a "fancy" style status area vs. TTY-style status lines
|
||||
!NetHack*fancy_status: False
|
||||
|
||||
! Specify the number of rows and columns of the map window. The default
|
||||
! is the standard 80x21 window. Note: this _does_not_ change nethack's
|
||||
! level size, only what you see of it.
|
||||
@@ -170,80 +174,80 @@ NetHack*player_selection_dialog*play.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
|
||||
|
||||
! role selection window (OPTIONS=player_selection:prompts)
|
||||
NetHack*player_selection*random.foreground: NETHACK_CLR_RANDOM
|
||||
NetHack*player_selection*random.background: black
|
||||
NetHack*player_selection*random.borderColor: NETHACK_CLR_RANDOM
|
||||
NetHack*player_selection*random.borderWidth: 1
|
||||
NetHack*player_selection*random.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*player_selection*random.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*player_selection*quit.foreground: NETHACK_CLR_QUIT
|
||||
NetHack*player_selection*quit.borderColor: NETHACK_CLR_QUIT
|
||||
NetHack*player_selection*quit.borderWidth: 1
|
||||
NetHack*player_selection*quit.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*player_selection*quit.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*player_selection*btn_random.foreground: NETHACK_CLR_RANDOM
|
||||
NetHack*player_selection*btn_random.background: black
|
||||
NetHack*player_selection*btn_random.borderColor: NETHACK_CLR_RANDOM
|
||||
NetHack*player_selection*btn_random.borderWidth: 1
|
||||
NetHack*player_selection*btn_random.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*player_selection*btn_random.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*player_selection*btn_quit.foreground: NETHACK_CLR_QUIT
|
||||
NetHack*player_selection*btn_quit.borderColor: NETHACK_CLR_QUIT
|
||||
NetHack*player_selection*btn_quit.borderWidth: 1
|
||||
NetHack*player_selection*btn_quit.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*player_selection*btn_quit.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*player_selection*Command.foreground: NETHACK_CLR_FG
|
||||
NetHack*player_selection*Command.borderColor: NETHACK_CLR_FG
|
||||
NetHack*player_selection*Command.borderWidth: NETHACK_CMD_BORDER
|
||||
|
||||
! race selection window
|
||||
NetHack*race_selection*random.foreground: NETHACK_CLR_RANDOM
|
||||
NetHack*race_selection*random.background: black
|
||||
NetHack*race_selection*random.borderColor: NETHACK_CLR_RANDOM
|
||||
NetHack*race_selection*random.borderWidth: 1
|
||||
NetHack*race_selection*random.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*race_selection*random.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*race_selection*quit.foreground: NETHACK_CLR_QUIT
|
||||
NetHack*race_selection*quit.borderColor: NETHACK_CLR_QUIT
|
||||
NetHack*race_selection*quit.borderWidth: 1
|
||||
NetHack*race_selection*quit.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*race_selection*quit.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*race_selection*btn_random.foreground: NETHACK_CLR_RANDOM
|
||||
NetHack*race_selection*btn_random.background: black
|
||||
NetHack*race_selection*btn_random.borderColor: NETHACK_CLR_RANDOM
|
||||
NetHack*race_selection*btn_random.borderWidth: 1
|
||||
NetHack*race_selection*btn_random.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*race_selection*btn_random.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*race_selection*btn_quit.foreground: NETHACK_CLR_QUIT
|
||||
NetHack*race_selection*btn_quit.borderColor: NETHACK_CLR_QUIT
|
||||
NetHack*race_selection*btn_quit.borderWidth: 1
|
||||
NetHack*race_selection*btn_quit.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*race_selection*btn_quit.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*race_selection*Command.foreground: NETHACK_CLR_FG
|
||||
NetHack*race_selection*Command.borderColor: NETHACK_CLR_FG
|
||||
NetHack*race_selection*Command.borderWidth: NETHACK_CMD_BORDER
|
||||
|
||||
! gender selection window
|
||||
NetHack*gender_selection*random.foreground: NETHACK_CLR_RANDOM
|
||||
NetHack*gender_selection*random.background: black
|
||||
NetHack*gender_selection*random.borderColor: NETHACK_CLR_RANDOM
|
||||
NetHack*gender_selection*random.borderWidth: 1
|
||||
NetHack*gender_selection*random.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*gender_selection*random.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*gender_selection*quit.foreground: NETHACK_CLR_QUIT
|
||||
NetHack*gender_selection*quit.borderColor: NETHACK_CLR_QUIT
|
||||
NetHack*gender_selection*quit.borderWidth: 1
|
||||
NetHack*gender_selection*quit.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*gender_selection*quit.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*gender_selection*btn_random.foreground: NETHACK_CLR_RANDOM
|
||||
NetHack*gender_selection*btn_random.background: black
|
||||
NetHack*gender_selection*btn_random.borderColor: NETHACK_CLR_RANDOM
|
||||
NetHack*gender_selection*btn_random.borderWidth: 1
|
||||
NetHack*gender_selection*btn_random.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*gender_selection*btn_random.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*gender_selection*btn_quit.foreground: NETHACK_CLR_QUIT
|
||||
NetHack*gender_selection*btn_quit.borderColor: NETHACK_CLR_QUIT
|
||||
NetHack*gender_selection*btn_quit.borderWidth: 1
|
||||
NetHack*gender_selection*btn_quit.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*gender_selection*btn_quit.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*gender_selection*Command.foreground: NETHACK_CLR_FG
|
||||
NetHack*gender_selection*Command.borderColor: NETHACK_CLR_FG
|
||||
NetHack*gender_selection*Command.borderWidth: NETHACK_CMD_BORDER
|
||||
|
||||
! alignment selection window
|
||||
NetHack*alignment_selection*random.foreground: NETHACK_CLR_RANDOM
|
||||
NetHack*alignment_selection*random.background: black
|
||||
NetHack*alignment_selection*random.borderColor: NETHACK_CLR_RANDOM
|
||||
NetHack*alignment_selection*random.borderWidth: 1
|
||||
NetHack*alignment_selection*random.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*alignment_selection*random.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*alignment_selection*quit.foreground: NETHACK_CLR_QUIT
|
||||
NetHack*alignment_selection*quit.borderColor: NETHACK_CLR_QUIT
|
||||
NetHack*alignment_selection*quit.borderWidth: 1
|
||||
NetHack*alignment_selection*quit.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*alignment_selection*quit.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*alignment_selection*btn_random.foreground: NETHACK_CLR_RANDOM
|
||||
NetHack*alignment_selection*btn_random.background: black
|
||||
NetHack*alignment_selection*btn_random.borderColor: NETHACK_CLR_RANDOM
|
||||
NetHack*alignment_selection*btn_random.borderWidth: 1
|
||||
NetHack*alignment_selection*btn_random.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*alignment_selection*btn_random.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*alignment_selection*btn_quit.foreground: NETHACK_CLR_QUIT
|
||||
NetHack*alignment_selection*btn_quit.borderColor: NETHACK_CLR_QUIT
|
||||
NetHack*alignment_selection*btn_quit.borderWidth: 1
|
||||
NetHack*alignment_selection*btn_quit.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*alignment_selection*btn_quit.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*alignment_selection*Command.foreground: NETHACK_CLR_FG
|
||||
NetHack*alignment_selection*Command.borderColor: NETHACK_CLR_FG
|
||||
NetHack*alignment_selection*Command.borderWidth: NETHACK_CMD_BORDER
|
||||
|
||||
! extended commands window
|
||||
NetHack*extended_commands*dismiss.foreground: NETHACK_CLR_QUIT
|
||||
NetHack*extended_commands*dismiss.borderColor: NETHACK_CLR_QUIT
|
||||
NetHack*extended_commands*dismiss.borderWidth: 1
|
||||
NetHack*extended_commands*dismiss.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*extended_commands*dismiss.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*extended_commands*help.foreground: NETHACK_CLR_HELP
|
||||
NetHack*extended_commands*help.borderColor: NETHACK_CLR_HELP
|
||||
NetHack*extended_commands*help.borderWidth: 1
|
||||
NetHack*extended_commands*help.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*extended_commands*help.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*extended_commands*btn_dismiss.foreground: NETHACK_CLR_QUIT
|
||||
NetHack*extended_commands*btn_dismiss.borderColor: NETHACK_CLR_QUIT
|
||||
NetHack*extended_commands*btn_dismiss.borderWidth: 1
|
||||
NetHack*extended_commands*btn_dismiss.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*extended_commands*btn_dismiss.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*extended_commands*btn_help.foreground: NETHACK_CLR_HELP
|
||||
NetHack*extended_commands*btn_help.borderColor: NETHACK_CLR_HELP
|
||||
NetHack*extended_commands*btn_help.borderWidth: 1
|
||||
NetHack*extended_commands*btn_help.shapeStyle: NETHACK_BTN_SHAPE
|
||||
NetHack*extended_commands*btn_help.cornerRoundPercent: NETHACK_BTN_ROUND
|
||||
NetHack*extended_commands*Command.foreground: NETHACK_CLR_FG
|
||||
NetHack*extended_commands*Command.borderColor: NETHACK_CLR_FG
|
||||
NetHack*extended_commands*Command.borderWidth: NETHACK_CMD_BORDER
|
||||
@@ -302,13 +306,13 @@ NetHack*map*green: green3
|
||||
NetHack*map*brown: DarkOrange3
|
||||
NetHack*map*blue: blue3
|
||||
NetHack*map*magenta: magenta3
|
||||
NetHack*map*cyan: cyan3
|
||||
NetHack*map*cyan: Dark cyan
|
||||
NetHack*map*gray: gray50
|
||||
NetHack*map*orange: yellow
|
||||
NetHack*map*orange: orange
|
||||
NetHack*map*bright_green: green
|
||||
NetHack*map*yellow: yellow
|
||||
NetHack*map*bright_blue: blue
|
||||
NetHack*map*bright_magenta: magenta
|
||||
NetHack*map*bright_blue: Royal blue
|
||||
NetHack*map*bright_magenta: Fuchsia
|
||||
NetHack*map*bright_cyan: cyan
|
||||
NetHack*map*white: white
|
||||
!
|
||||
|
||||
185
win/X11/winX.c
185
win/X11/winX.c
@@ -49,6 +49,7 @@
|
||||
#include "hack.h"
|
||||
#include "winX.h"
|
||||
#include "dlb.h"
|
||||
#include "xwindow.h"
|
||||
|
||||
#ifndef NO_SIGNAL
|
||||
#include <signal.h>
|
||||
@@ -103,7 +104,7 @@ struct window_procs X11_procs = {
|
||||
(WC_COLOR | WC_HILITE_PET | WC_ASCII_MAP | WC_TILED_MAP
|
||||
| WC_PLAYER_SELECTION | WC_PERM_INVENT | WC_MOUSE_SUPPORT),
|
||||
#if defined(STATUS_HILITES)
|
||||
WC2_FLUSH_STATUS | WC2_RESET_STATUS |
|
||||
WC2_FLUSH_STATUS | WC2_RESET_STATUS | WC2_HILITE_STATUS |
|
||||
#endif
|
||||
0L,
|
||||
X11_init_nhwindows,
|
||||
@@ -133,9 +134,9 @@ struct window_procs X11_procs = {
|
||||
#else
|
||||
genl_outrip,
|
||||
#endif
|
||||
X11_preference_update, genl_getmsghistory, genl_putmsghistory,
|
||||
genl_status_init, genl_status_finish, genl_status_enablefield,
|
||||
genl_status_update,
|
||||
X11_preference_update, X11_getmsghistory, X11_putmsghistory,
|
||||
X11_status_init, X11_status_finish, X11_status_enablefield,
|
||||
X11_status_update,
|
||||
genl_can_suspend_no, /* XXX may not always be correct */
|
||||
};
|
||||
|
||||
@@ -181,6 +182,43 @@ static winid message_win = WIN_ERR, /* These are the winids of the message, */
|
||||
status_win = WIN_ERR; /* are created in init_windows(). */
|
||||
static Pixmap icon_pixmap = None; /* Pixmap for icon. */
|
||||
|
||||
void
|
||||
X11_putmsghistory(msg, is_restoring)
|
||||
const char *msg;
|
||||
boolean is_restoring;
|
||||
{
|
||||
if (WIN_MESSAGE != WIN_ERR) {
|
||||
struct xwindow *wp = &window_list[WIN_MESSAGE];
|
||||
debugpline2("X11_putmsghistory('%s',%i)", msg, is_restoring);
|
||||
if (msg)
|
||||
append_message(wp, msg);
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
X11_getmsghistory(init)
|
||||
boolean init;
|
||||
{
|
||||
if (WIN_MESSAGE != WIN_ERR) {
|
||||
static struct line_element *curr = (struct line_element *) 0;
|
||||
static int numlines = 0;
|
||||
struct xwindow *wp = &window_list[WIN_MESSAGE];
|
||||
|
||||
if (!curr) {
|
||||
curr = wp->mesg_information->head;
|
||||
numlines = 0;
|
||||
}
|
||||
|
||||
if (numlines < wp->mesg_information->num_lines) {
|
||||
curr = curr->next;
|
||||
numlines++;
|
||||
debugpline2("X11_getmsghistory(%i)='%s'", init, curr->line);
|
||||
return curr->line;
|
||||
}
|
||||
}
|
||||
return (char *) 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the window structure that corresponds to the given widget. Note
|
||||
* that this is not the popup widget, nor the viewport, but the child.
|
||||
@@ -226,6 +264,102 @@ find_free_window()
|
||||
return (winid) windex;
|
||||
}
|
||||
|
||||
|
||||
XColor
|
||||
get_nhcolor(wp, clr)
|
||||
struct xwindow *wp;
|
||||
int clr;
|
||||
{
|
||||
init_menu_nhcolors(wp);
|
||||
/* FIXME: init_menu_nhcolors may fail */
|
||||
|
||||
if (clr >= 0 && clr < CLR_MAX)
|
||||
return wp->nh_colors[clr];
|
||||
|
||||
return wp->nh_colors[0];
|
||||
}
|
||||
|
||||
void
|
||||
init_menu_nhcolors(wp)
|
||||
struct xwindow *wp;
|
||||
{
|
||||
static const char *mapCLR_to_res[CLR_MAX] = {
|
||||
XtNblack,
|
||||
XtNred,
|
||||
XtNgreen,
|
||||
XtNbrown,
|
||||
XtNblue,
|
||||
XtNmagenta,
|
||||
XtNcyan,
|
||||
XtNgray,
|
||||
XtNforeground,
|
||||
XtNorange,
|
||||
XtNbright_green,
|
||||
XtNyellow,
|
||||
XtNbright_blue,
|
||||
XtNbright_magenta,
|
||||
XtNbright_cyan,
|
||||
XtNwhite,
|
||||
};
|
||||
Display *dpy;
|
||||
Colormap screen_colormap;
|
||||
XrmDatabase rDB;
|
||||
XrmValue value;
|
||||
Status rc;
|
||||
int color;
|
||||
char *ret_type[32];
|
||||
char clr_name[BUFSZ];
|
||||
char clrclass[BUFSZ];
|
||||
const char *wintypenames[NHW_TEXT] = {
|
||||
"message", "status", "map", "menu", "text"
|
||||
};
|
||||
const char *wtn;
|
||||
char wtn_up[BUFSZ];
|
||||
|
||||
if (wp->nh_colors_inited || !wp->type)
|
||||
return;
|
||||
|
||||
wtn = wintypenames[wp->type - 1];
|
||||
Strcpy(wtn_up, wtn);
|
||||
(void) upstart(wtn_up);
|
||||
|
||||
dpy = XtDisplay(wp->w);
|
||||
screen_colormap = DefaultColormap(dpy, DefaultScreen(dpy));
|
||||
rDB = XrmGetDatabase(dpy);
|
||||
|
||||
for (color = 0; color < CLR_MAX; color++) {
|
||||
Sprintf(clr_name, "nethack.%s.%s", wtn, mapCLR_to_res[color]);
|
||||
Sprintf(clrclass, "NetHack.%s.%s", wtn_up, mapCLR_to_res[color]);
|
||||
|
||||
if (!XrmGetResource(rDB, clr_name, clrclass, ret_type, &value)) {
|
||||
Sprintf(clr_name, "nethack.map.%s", mapCLR_to_res[color]);
|
||||
Sprintf(clrclass, "NetHack.Map.%s", mapCLR_to_res[color]);
|
||||
}
|
||||
|
||||
if (!XrmGetResource(rDB, clr_name, clrclass, ret_type, &value)) {
|
||||
impossible("XrmGetResource error (%s)", clr_name);
|
||||
} else if (!strcmp(ret_type[0], "String")) {
|
||||
char tmpbuf[256];
|
||||
|
||||
if (value.size >= sizeof tmpbuf)
|
||||
value.size = sizeof tmpbuf - 1;
|
||||
(void) strncpy(tmpbuf, (char *) value.addr, (int) value.size);
|
||||
tmpbuf[value.size] = '\0';
|
||||
/* tmpbuf now contains the color name from the named resource */
|
||||
|
||||
rc = XAllocNamedColor(dpy, screen_colormap, tmpbuf,
|
||||
&wp->nh_colors[color],
|
||||
&wp->nh_colors[color]);
|
||||
if (rc == 0) {
|
||||
impossible("XAllocNamedColor failed for color %i (%s)",
|
||||
color, clr_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wp->nh_colors_inited = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Color conversion. The default X11 color converters don't try very
|
||||
* hard to find matching colors in PseudoColor visuals. If they can't
|
||||
@@ -515,6 +649,31 @@ const char *fontname;
|
||||
return buf;
|
||||
}
|
||||
|
||||
void
|
||||
load_boldfont(wp, w)
|
||||
struct xwindow *wp;
|
||||
Widget w;
|
||||
{
|
||||
Arg args[1];
|
||||
XFontStruct *fs;
|
||||
unsigned long ret;
|
||||
char *fontname;
|
||||
Display *dpy;
|
||||
|
||||
if (wp->boldfs)
|
||||
return;
|
||||
|
||||
XtSetArg(args[0], nhStr(XtNfont), &fs);
|
||||
XtGetValues(w, args, 1);
|
||||
|
||||
if (!XGetFontProperty(fs, XA_FONT, &ret))
|
||||
return;
|
||||
|
||||
wp->boldfs_dpy = dpy = XtDisplay(w);
|
||||
fontname = fontname_boldify(XGetAtomName(dpy, (Atom)ret));
|
||||
wp->boldfs = XLoadQueryFont(dpy, fontname);
|
||||
}
|
||||
|
||||
#ifdef TEXTCOLOR
|
||||
/* ARGSUSED */
|
||||
static void
|
||||
@@ -790,9 +949,11 @@ const char *str;
|
||||
toplines[TBUFSZ - 1] = 0;
|
||||
append_message(wp, str);
|
||||
break;
|
||||
#ifndef STATUS_HILITES
|
||||
case NHW_STATUS:
|
||||
adjust_status(wp, str);
|
||||
break;
|
||||
#endif
|
||||
case NHW_MAP:
|
||||
impossible("putstr: called on map window \"%s\"", str);
|
||||
break;
|
||||
@@ -913,6 +1074,9 @@ int type;
|
||||
wp->prevx = wp->prevy = wp->cursx = wp->cursy = wp->pixel_width =
|
||||
wp->pixel_height = 0;
|
||||
wp->keep_window = FALSE;
|
||||
wp->nh_colors_inited = FALSE;
|
||||
wp->boldfs = (XFontStruct *) 0;
|
||||
wp->boldfs_dpy = (Display *) 0;
|
||||
|
||||
switch (type) {
|
||||
case NHW_MAP:
|
||||
@@ -1057,6 +1221,12 @@ winid window;
|
||||
WIN_INVEN = WIN_ERR;
|
||||
}
|
||||
|
||||
if (wp->boldfs) {
|
||||
XFreeFont(wp->boldfs_dpy, wp->boldfs);
|
||||
wp->boldfs = (XFontStruct *) 0;
|
||||
wp->boldfs_dpy = (Display *) 0;
|
||||
}
|
||||
|
||||
switch (wp->type) {
|
||||
case NHW_MAP:
|
||||
destroy_map_window(wp);
|
||||
@@ -1230,6 +1400,8 @@ static XtActionsRec actions[] = {
|
||||
static XtResource resources[] = {
|
||||
{ nhStr("slow"), nhStr("Slow"), XtRBoolean, sizeof(Boolean),
|
||||
XtOffset(AppResources *, slow), XtRString, nhStr("True") },
|
||||
{ nhStr("fancy_status"), nhStr("Fancy_status"), XtRBoolean, sizeof(Boolean),
|
||||
XtOffset(AppResources *, fancy_status), XtRString, nhStr("True") },
|
||||
{ nhStr("autofocus"), nhStr("AutoFocus"), XtRBoolean, sizeof(Boolean),
|
||||
XtOffset(AppResources *, autofocus), XtRString, nhStr("False") },
|
||||
{ nhStr("message_line"), nhStr("Message_line"), XtRBoolean,
|
||||
@@ -2214,7 +2386,7 @@ static int
|
||||
input_event(exit_condition)
|
||||
int exit_condition;
|
||||
{
|
||||
if (WIN_STATUS != WIN_ERR) /* hilighting on the fancy status window */
|
||||
if (appResources.fancy_status && WIN_STATUS != WIN_ERR) /* hilighting on the fancy status window */
|
||||
check_turn_events();
|
||||
if (WIN_MAP != WIN_ERR) /* make sure cursor is not clipped */
|
||||
check_cursor_visibility(&window_list[WIN_MAP]);
|
||||
@@ -2484,7 +2656,8 @@ init_standard_windows()
|
||||
* after the fancy status widget is realized (above, with the game popup),
|
||||
* but before it is popped up.
|
||||
*/
|
||||
null_out_status();
|
||||
if (appResources.fancy_status)
|
||||
null_out_status();
|
||||
/*
|
||||
* Set the map size to its standard size. As with the message window
|
||||
* above, the map window needs to be set to its constrained size until
|
||||
|
||||
@@ -32,12 +32,9 @@
|
||||
#undef PRESERVE_NO_SYSV
|
||||
#endif
|
||||
|
||||
#include "xwindow.h"
|
||||
#include "hack.h"
|
||||
#include "winX.h"
|
||||
|
||||
XColor FDECL(get_nhcolor, (struct xwindow *, int));
|
||||
static void FDECL(init_menu_nhcolors, (struct xwindow *));
|
||||
static void FDECL(menu_size_change_handler, (Widget, XtPointer,
|
||||
XEvent *, Boolean *));
|
||||
static void FDECL(menu_select, (Widget, XtPointer, XtPointer));
|
||||
@@ -55,7 +52,6 @@ static void FDECL(invert_all, (struct xwindow *));
|
||||
static void FDECL(invert_match, (struct xwindow *, char *));
|
||||
static void FDECL(menu_popdown, (struct xwindow *));
|
||||
static Widget FDECL(menu_create_buttons, (struct xwindow *, Widget, Widget));
|
||||
static void FDECL(load_boldfont, (struct xwindow *, Widget));
|
||||
static void FDECL(menu_create_entries, (struct xwindow *, struct menu *));
|
||||
static void FDECL(destroy_menu_entry_widgets, (struct xwindow *));
|
||||
static void NDECL(create_menu_translation_tables);
|
||||
@@ -1121,31 +1117,6 @@ Widget form,under;
|
||||
return all;
|
||||
}
|
||||
|
||||
static void
|
||||
load_boldfont(wp, w)
|
||||
struct xwindow *wp;
|
||||
Widget w;
|
||||
{
|
||||
Arg args[1];
|
||||
XFontStruct *fs;
|
||||
unsigned long ret;
|
||||
char *fontname;
|
||||
Display *dpy;
|
||||
|
||||
if (wp->menu_information->boldfs)
|
||||
return;
|
||||
|
||||
XtSetArg(args[0], nhStr(XtNfont), &fs);
|
||||
XtGetValues(w, args, 1);
|
||||
|
||||
if (!XGetFontProperty(fs, XA_FONT, &ret))
|
||||
return;
|
||||
|
||||
wp->menu_information->boldfs_dpy = dpy = XtDisplay(w);
|
||||
fontname = fontname_boldify(XGetAtomName(dpy, (Atom)ret));
|
||||
wp->menu_information->boldfs = XLoadQueryFont(dpy, fontname);
|
||||
}
|
||||
|
||||
static void
|
||||
menu_create_entries(wp, curr_menu)
|
||||
struct xwindow *wp;
|
||||
@@ -1185,7 +1156,7 @@ struct menu *curr_menu;
|
||||
get_nhcolor(wp, color).pixel); num_args++;
|
||||
}
|
||||
|
||||
/* TODO: ATR_BOLD, ATR_DIM, ATR_ULINE, ATR_BLINK */
|
||||
/* TODO: ATR_DIM, ATR_ULINE, ATR_BLINK */
|
||||
|
||||
if (attr == ATR_INVERSE) {
|
||||
XtSetArg(args[num_args], nhStr(XtNforeground),
|
||||
@@ -1215,7 +1186,7 @@ struct menu *curr_menu;
|
||||
load_boldfont(wp, curr->w);
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], nhStr(XtNfont),
|
||||
wp->menu_information->boldfs); num_args++;
|
||||
wp->boldfs); num_args++;
|
||||
XtSetValues(curr->w, args, num_args);
|
||||
}
|
||||
|
||||
@@ -1315,91 +1286,6 @@ struct xwindow *wp;
|
||||
}
|
||||
}
|
||||
|
||||
XColor
|
||||
get_nhcolor(wp, clr)
|
||||
struct xwindow *wp;
|
||||
int clr;
|
||||
{
|
||||
init_menu_nhcolors(wp);
|
||||
|
||||
if (clr >= 0 && clr < CLR_MAX)
|
||||
return wp->menu_information->nh_colors[clr];
|
||||
|
||||
return wp->menu_information->nh_colors[0];
|
||||
}
|
||||
|
||||
static void
|
||||
init_menu_nhcolors(wp)
|
||||
struct xwindow *wp;
|
||||
{
|
||||
static const char *mapCLR_to_res[CLR_MAX] = {
|
||||
XtNblack,
|
||||
XtNred,
|
||||
XtNgreen,
|
||||
XtNbrown,
|
||||
XtNblue,
|
||||
XtNmagenta,
|
||||
XtNcyan,
|
||||
XtNgray,
|
||||
XtNforeground,
|
||||
XtNorange,
|
||||
XtNbright_green,
|
||||
XtNyellow,
|
||||
XtNbright_blue,
|
||||
XtNbright_magenta,
|
||||
XtNbright_cyan,
|
||||
XtNwhite,
|
||||
};
|
||||
Display *dpy;
|
||||
Colormap screen_colormap;
|
||||
XrmDatabase rDB;
|
||||
XrmValue value;
|
||||
Status rc;
|
||||
int color;
|
||||
char *ret_type[32];
|
||||
char clr_name[BUFSZ];
|
||||
char clrclass[BUFSZ];
|
||||
|
||||
if (wp->menu_information->nh_colors_inited)
|
||||
return;
|
||||
|
||||
dpy = XtDisplay(wp->w);
|
||||
screen_colormap = DefaultColormap(dpy, DefaultScreen(dpy));
|
||||
rDB = XrmGetDatabase(dpy);
|
||||
|
||||
for (color = 0; color < CLR_MAX; color++) {
|
||||
Sprintf(clr_name, "nethack.menu.%s", mapCLR_to_res[color]);
|
||||
Sprintf(clrclass, "NetHack.Menu.%s", mapCLR_to_res[color]);
|
||||
|
||||
if (!XrmGetResource(rDB, clr_name, clrclass, ret_type, &value)) {
|
||||
Sprintf(clr_name, "nethack.map.%s", mapCLR_to_res[color]);
|
||||
Sprintf(clrclass, "NetHack.Map.%s", mapCLR_to_res[color]);
|
||||
}
|
||||
|
||||
if (!XrmGetResource(rDB, clr_name, clrclass, ret_type, &value)) {
|
||||
impossible("XrmGetResource error (%s)", clr_name);
|
||||
} else if (!strcmp(ret_type[0], "String")) {
|
||||
char tmpbuf[256];
|
||||
|
||||
if (value.size >= sizeof tmpbuf)
|
||||
value.size = sizeof tmpbuf - 1;
|
||||
(void) strncpy(tmpbuf, (char *) value.addr, (int) value.size);
|
||||
tmpbuf[value.size] = '\0';
|
||||
/* tmpbuf now contains the color name from the named resource */
|
||||
|
||||
rc = XAllocNamedColor(dpy, screen_colormap, tmpbuf,
|
||||
&wp->menu_information->nh_colors[color],
|
||||
&wp->menu_information->nh_colors[color]);
|
||||
if (rc == 0) {
|
||||
impossible("XAllocNamedColor failed for color %i (%s)",
|
||||
color, clr_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wp->menu_information->nh_colors_inited = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
create_menu_window(wp)
|
||||
struct xwindow *wp;
|
||||
@@ -1413,7 +1299,6 @@ struct xwindow *wp;
|
||||
reset_menu_to_default(&wp->menu_information->new_menu);
|
||||
reset_menu_count(wp->menu_information);
|
||||
wp->w = wp->popup = (Widget) 0;
|
||||
wp->menu_information->nh_colors_inited = FALSE;
|
||||
wp->menu_information->permi_x = -1;
|
||||
wp->menu_information->permi_y = -1;
|
||||
wp->menu_information->permi_w = -1;
|
||||
@@ -1425,9 +1310,6 @@ destroy_menu_window(wp)
|
||||
struct xwindow *wp;
|
||||
{
|
||||
clear_old_menu(wp); /* this will also destroy the widgets */
|
||||
if (wp->menu_information->boldfs)
|
||||
XFreeFont(wp->menu_information->boldfs_dpy,
|
||||
wp->menu_information->boldfs);
|
||||
free((genericptr_t) wp->menu_information);
|
||||
wp->menu_information = (struct menu_info_t *) 0;
|
||||
wp->type = NHW_NONE; /* allow re-use */
|
||||
|
||||
@@ -50,6 +50,8 @@ static char mesg_translations[] = "#override\n\
|
||||
<Key>Right: scroll(6)\n\
|
||||
<Key>Up: scroll(8)\n\
|
||||
<Key>Down: scroll(2)\n\
|
||||
<Btn4Down>: scroll(8)\n\
|
||||
<Btn5Down>: scroll(2)\n\
|
||||
<Key>: input()";
|
||||
|
||||
/* Move the message window's vertical scrollbar's slider to the bottom. */
|
||||
|
||||
@@ -1247,11 +1247,10 @@ X11_player_selection_dialog()
|
||||
} else {
|
||||
ps_selected = -1;
|
||||
nh_XtPopup(popup, (int) XtGrabExclusive, form);
|
||||
/* The callback will enable the event loop exit. */
|
||||
(void) x_event(EXIT_ON_EXIT);
|
||||
}
|
||||
|
||||
/* The callback will enable the event loop exit. */
|
||||
(void) x_event(flags.randomall ? EXIT_ON_SENT_EVENT : EXIT_ON_EXIT);
|
||||
|
||||
nh_XtPopdown(popup);
|
||||
XtDestroyWidget(popup);
|
||||
|
||||
@@ -1994,11 +1993,12 @@ Widget *formp; /* return */
|
||||
Widget popup, popform, form, label, above, left, right, view;
|
||||
Widget *commands, *curr;
|
||||
int i;
|
||||
Arg args[8];
|
||||
Arg args[12];
|
||||
Cardinal num_args;
|
||||
Dimension width, other_width, max_width, border_width,
|
||||
height, cumulative_height, screen_height;
|
||||
int distance, skip;
|
||||
char btnname[BUFSZ];
|
||||
|
||||
commands = (Widget *) alloc((unsigned) num_names * sizeof (Widget));
|
||||
|
||||
@@ -2073,11 +2073,13 @@ Widget *formp; /* return */
|
||||
*/
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], nhStr(XtNfromVert), label); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNlabel), left_name); num_args++;
|
||||
#if 0
|
||||
XtSetArg(args[num_args], nhStr(XtNshapeStyle),
|
||||
XmuShapeRoundedRectangle); num_args++;
|
||||
#endif
|
||||
left = XtCreateManagedWidget(left_name, commandWidgetClass, form, args,
|
||||
Sprintf(btnname, "btn_%s", left_name);
|
||||
left = XtCreateManagedWidget(btnname, commandWidgetClass, form, args,
|
||||
num_args);
|
||||
XtAddCallback(left, XtNcallback, left_callback, (XtPointer) 0);
|
||||
skip = (distance < 4) ? 8 : 2 * distance;
|
||||
@@ -2094,11 +2096,13 @@ Widget *formp; /* return */
|
||||
XtSetArg(args[num_args], nhStr(XtNfromHoriz), left); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNhorizDistance), skip); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNfromVert), label); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNlabel), right_name); num_args++;
|
||||
#if 0
|
||||
XtSetArg(args[num_args], nhStr(XtNshapeStyle),
|
||||
XmuShapeRoundedRectangle); num_args++;
|
||||
#endif
|
||||
right = XtCreateManagedWidget(right_name, commandWidgetClass, form, args,
|
||||
Sprintf(btnname, "btn_%s", right_name);
|
||||
right = XtCreateManagedWidget(btnname, commandWidgetClass, form, args,
|
||||
num_args);
|
||||
XtAddCallback(right, XtNcallback, right_callback, (XtPointer) 0);
|
||||
|
||||
|
||||
@@ -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 */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#endif
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <X11/IntrinsicP.h>
|
||||
#include <X11/StringDefs.h>
|
||||
#include <X11/Shell.h>
|
||||
#include <X11/Xaw/AsciiText.h>
|
||||
@@ -22,6 +23,7 @@
|
||||
#include <X11/Xaw/Form.h>
|
||||
#include <X11/Xaw/Paned.h>
|
||||
#include <X11/Xaw/Label.h>
|
||||
#include <X11/Xaw/Viewport.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#ifdef PRESERVE_NO_SYSV
|
||||
@@ -31,18 +33,754 @@
|
||||
#undef PRESERVE_NO_SYSV
|
||||
#endif
|
||||
|
||||
#include "xwindow.h"
|
||||
|
||||
#include "hack.h"
|
||||
#include "winX.h"
|
||||
|
||||
/*
|
||||
* Fancy status form entry storage indices.
|
||||
*/
|
||||
#define F_DUMMY 0
|
||||
#define F_STR 1
|
||||
#define F_DEX 2
|
||||
#define F_CON 3
|
||||
#define F_INT 4
|
||||
#define F_WIS 5
|
||||
#define F_CHA 6
|
||||
|
||||
#define F_NAME 7
|
||||
#define F_DLEVEL 8
|
||||
#define F_GOLD 9
|
||||
#define F_HP 10
|
||||
#define F_MAXHP 11
|
||||
#define F_POWER 12
|
||||
#define F_MAXPOWER 13
|
||||
#define F_AC 14
|
||||
#define F_LEVEL 15
|
||||
#define F_EXP 16
|
||||
#define F_ALIGN 17
|
||||
#define F_TIME 18
|
||||
#define F_SCORE 19
|
||||
|
||||
/* status conditions grouped by columns; tty orders these differently */
|
||||
#define F_STONE 20
|
||||
#define F_SLIME 21
|
||||
#define F_STRNGL 22
|
||||
#define F_FOODPOIS 23
|
||||
#define F_TERMILL 24
|
||||
|
||||
#define F_HUNGER 25
|
||||
#define F_ENCUMBER 26
|
||||
#define F_LEV 27
|
||||
#define F_FLY 28
|
||||
#define F_RIDE 29
|
||||
|
||||
#define F_BLIND 30
|
||||
#define F_DEAF 31
|
||||
#define F_STUN 32
|
||||
#define F_CONF 33
|
||||
#define F_HALLU 34
|
||||
|
||||
#define NUM_STATS 35
|
||||
|
||||
static void FDECL(update_fancy_status, (struct xwindow *));
|
||||
static void FDECL(update_fancy_status_field, (int));
|
||||
static Widget FDECL(create_fancy_status, (Widget, Widget));
|
||||
static void FDECL(destroy_fancy_status, (struct xwindow *));
|
||||
static void FDECL(create_status_window_fancy, (struct xwindow *, BOOLEAN_P, Widget));
|
||||
static void FDECL(create_status_window_tty, (struct xwindow *, BOOLEAN_P, Widget));
|
||||
static void FDECL(destroy_status_window_fancy, (struct xwindow *));
|
||||
static void FDECL(destroy_status_window_tty, (struct xwindow *));
|
||||
static void FDECL(adjust_status_fancy, (struct xwindow *, const char *));
|
||||
static void FDECL(adjust_status_tty, (struct xwindow *, const char *));
|
||||
|
||||
extern const char *status_fieldfmt[MAXBLSTATS];
|
||||
extern char *status_vals[MAXBLSTATS];
|
||||
extern boolean status_activefields[MAXBLSTATS];
|
||||
static long X11_condition_bits;
|
||||
static int X11_status_colors[MAXBLSTATS];
|
||||
static int hpbar_percent, hpbar_color;
|
||||
|
||||
#define X11_NUM_STATUS_LINES 2
|
||||
#define X11_NUM_STATUS_FIELD 15
|
||||
|
||||
static enum statusfields X11_fieldorder[X11_NUM_STATUS_LINES][X11_NUM_STATUS_FIELD] = {
|
||||
{ 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 },
|
||||
{ BL_LEVELDESC, BL_GOLD, BL_HP, BL_HPMAX, BL_ENE, BL_ENEMAX,
|
||||
BL_AC, BL_XP, BL_EXP, BL_HD, BL_TIME, BL_HUNGER,
|
||||
BL_CAP, BL_CONDITION, BL_FLUSH }
|
||||
};
|
||||
|
||||
static Widget X11_status_widget;
|
||||
static Widget X11_status_labels[MAXBLSTATS];
|
||||
static Widget X11_cond_labels[32]; /* Ugh */
|
||||
|
||||
struct xwindow *xw_status_win;
|
||||
static Pixel X11_status_widget_fg, X11_status_widget_bg;
|
||||
|
||||
|
||||
int
|
||||
condcolor(bm, bmarray)
|
||||
long bm;
|
||||
unsigned long *bmarray;
|
||||
{
|
||||
int i;
|
||||
|
||||
if (bm && bmarray)
|
||||
for (i = 0; i < CLR_MAX; ++i) {
|
||||
if (bmarray[i] && (bm & bmarray[i]))
|
||||
return i;
|
||||
}
|
||||
return NO_COLOR;
|
||||
}
|
||||
|
||||
int
|
||||
condattr(bm, bmarray)
|
||||
long bm;
|
||||
unsigned long *bmarray;
|
||||
{
|
||||
int attr = 0;
|
||||
int i;
|
||||
|
||||
if (bm && bmarray) {
|
||||
for (i = HL_ATTCLR_DIM; i < BL_ATTCLR_MAX; ++i) {
|
||||
if (bmarray[i] && (bm & bmarray[i])) {
|
||||
switch(i) {
|
||||
case HL_ATTCLR_DIM:
|
||||
attr |= HL_DIM;
|
||||
break;
|
||||
case HL_ATTCLR_BLINK:
|
||||
attr |= HL_BLINK;
|
||||
break;
|
||||
case HL_ATTCLR_ULINE:
|
||||
attr |= HL_ULINE;
|
||||
break;
|
||||
case HL_ATTCLR_INVERSE:
|
||||
attr |= HL_INVERSE;
|
||||
break;
|
||||
case HL_ATTCLR_BOLD:
|
||||
attr |= HL_BOLD;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return attr;
|
||||
}
|
||||
|
||||
void
|
||||
X11_status_init()
|
||||
{
|
||||
#ifdef STATUS_HILITES
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAXBLSTATS; ++i)
|
||||
X11_status_colors[i] = NO_COLOR; /* no color */
|
||||
X11_condition_bits = 0L;
|
||||
hpbar_percent = 0, hpbar_color = NO_COLOR;
|
||||
#endif /* STATUS_HILITES */
|
||||
/* let genl_status_init do most of the initialization */
|
||||
genl_status_init();
|
||||
}
|
||||
|
||||
void
|
||||
X11_status_finish()
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
void
|
||||
X11_status_enablefield(fieldidx, nm, fmt, enable)
|
||||
int fieldidx;
|
||||
const char *nm;
|
||||
const char *fmt;
|
||||
boolean enable;
|
||||
{
|
||||
genl_status_enablefield(fieldidx, nm, fmt, enable);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
cond_bm2idx(bm)
|
||||
unsigned long bm;
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 32; i++)
|
||||
if ((1 << i) == bm)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
MaybeDisplayCond(bm, colormasks, text)
|
||||
unsigned long bm;
|
||||
unsigned long *colormasks;
|
||||
const char *text;
|
||||
{
|
||||
int idx = cond_bm2idx(bm);
|
||||
Widget label;
|
||||
Arg args[10];
|
||||
Cardinal num_args;
|
||||
Pixel fg = X11_status_widget_fg, bg = X11_status_widget_bg;
|
||||
Dimension lbl_wid;
|
||||
Dimension lbl_hei;
|
||||
Dimension lbl_border_wid;
|
||||
Dimension lbl_iwidth;
|
||||
|
||||
if (idx < 0)
|
||||
return;
|
||||
|
||||
label = X11_cond_labels[idx];
|
||||
if ((X11_condition_bits & bm) != 0) {
|
||||
int attrmask, coloridx;
|
||||
XFontStruct *font;
|
||||
Position lbl_x;
|
||||
Position lbl_y;
|
||||
|
||||
#ifdef TEXTCOLOR
|
||||
coloridx = condcolor(bm, colormasks);
|
||||
#else
|
||||
coloridx = NO_COLOR;
|
||||
#endif
|
||||
attrmask = condattr(bm, colormasks);
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], nhStr(XtNfont), &font); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNx), &lbl_x); 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(XtNheight), &lbl_hei); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNinternalWidth), &lbl_iwidth); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNborderWidth), &lbl_border_wid); num_args++;
|
||||
XtGetValues(label, args, num_args);
|
||||
|
||||
if (text && *text)
|
||||
lbl_wid = lbl_iwidth + font->max_bounds.width * strlen(text);
|
||||
else
|
||||
lbl_wid = 1;
|
||||
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], nhStr(XtNlabel), (text && *text) ? text : ""); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNwidth), lbl_wid); num_args++;
|
||||
|
||||
fg = (coloridx != NO_COLOR) ? get_nhcolor(xw_status_win, coloridx).pixel
|
||||
: X11_status_widget_fg;
|
||||
if (attrmask & HL_INVERSE) {
|
||||
Pixel tmppx = fg;
|
||||
fg = bg;
|
||||
bg = tmppx;
|
||||
}
|
||||
|
||||
if (attrmask & HL_BOLD) {
|
||||
load_boldfont(xw_status_win, label);
|
||||
XtSetArg(args[num_args], nhStr(XtNfont),
|
||||
xw_status_win->boldfs); num_args++;
|
||||
}
|
||||
|
||||
if (fg == bg)
|
||||
fg = get_nhcolor(xw_status_win, CLR_GRAY).pixel;
|
||||
|
||||
XtSetArg(args[num_args], nhStr(XtNforeground), fg); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbackground), bg); num_args++;
|
||||
XtSetValues(label, args, num_args);
|
||||
XtResizeWidget(label, lbl_wid, lbl_hei, lbl_border_wid);
|
||||
} else {
|
||||
num_args = 0;
|
||||
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(XtNinternalWidth), &lbl_iwidth); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNborderWidth), &lbl_border_wid); num_args++;
|
||||
XtGetValues(label, args, num_args);
|
||||
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], nhStr(XtNlabel), ""); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNwidth), 1); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNforeground), fg); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbackground), bg); num_args++;
|
||||
XtSetValues(label, args, num_args);
|
||||
|
||||
XtResizeWidget(label, lbl_wid, lbl_hei, lbl_border_wid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
X11_status_update_tty(fld, ptr, chg, percent, color, colormasks)
|
||||
int fld, chg UNUSED, percent, color;
|
||||
genericptr_t ptr;
|
||||
unsigned long *colormasks;
|
||||
{
|
||||
static boolean oncearound = FALSE; /* prevent premature partial display */
|
||||
long *condptr = (long *) ptr;
|
||||
int coloridx = NO_COLOR;
|
||||
const char *text = (char *) ptr;
|
||||
char tmpbuf[BUFSZ];
|
||||
int attridx = 0;
|
||||
|
||||
XFontStruct *font;
|
||||
Arg args[10];
|
||||
Cardinal num_args;
|
||||
Position lbl_x;
|
||||
Position lbl_y;
|
||||
Dimension lbl_wid;
|
||||
Dimension lbl_hei;
|
||||
Dimension lbl_border_wid;
|
||||
Dimension lbl_iwidth;
|
||||
Widget label;
|
||||
Pixel fg = X11_status_widget_fg, bg = X11_status_widget_bg;
|
||||
|
||||
#ifndef TEXTCOLOR
|
||||
color = NO_COLOR;
|
||||
#endif
|
||||
|
||||
if (fld < BL_RESET || fld >= MAXBLSTATS)
|
||||
return;
|
||||
|
||||
if ((fld >= 0 && fld < MAXBLSTATS) && !status_activefields[fld])
|
||||
return;
|
||||
|
||||
if (fld != BL_FLUSH && fld != BL_RESET) {
|
||||
if (!status_activefields[fld])
|
||||
return;
|
||||
switch (fld) {
|
||||
case BL_CONDITION:
|
||||
X11_condition_bits = *condptr;
|
||||
oncearound = TRUE;
|
||||
break;
|
||||
default:
|
||||
Sprintf(status_vals[fld],
|
||||
(fld == BL_TITLE && iflags.wc2_hitpointbar) ? "%-30s" :
|
||||
status_fieldfmt[fld] ? status_fieldfmt[fld] : "%s",
|
||||
text);
|
||||
X11_status_colors[fld] = color;
|
||||
if (iflags.wc2_hitpointbar && fld == BL_HP) {
|
||||
hpbar_percent = percent;
|
||||
hpbar_color = color;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (fld == BL_CONDITION) {
|
||||
MaybeDisplayCond(BL_MASK_STONE, colormasks, "Stone");
|
||||
MaybeDisplayCond(BL_MASK_SLIME, colormasks, "Slime");
|
||||
MaybeDisplayCond(BL_MASK_STRNGL, colormasks, "Strngl");
|
||||
MaybeDisplayCond(BL_MASK_FOODPOIS, colormasks, "FoodPois");
|
||||
MaybeDisplayCond(BL_MASK_TERMILL, colormasks, "TermIll");
|
||||
MaybeDisplayCond(BL_MASK_BLIND, colormasks, "Blind");
|
||||
MaybeDisplayCond(BL_MASK_DEAF, colormasks, "Deaf");
|
||||
MaybeDisplayCond(BL_MASK_STUN, colormasks, "Stun");
|
||||
MaybeDisplayCond(BL_MASK_CONF, colormasks, "Conf");
|
||||
MaybeDisplayCond(BL_MASK_HALLU, colormasks, "Hallu");
|
||||
MaybeDisplayCond(BL_MASK_LEV, colormasks, "Lev");
|
||||
MaybeDisplayCond(BL_MASK_FLY, colormasks, "Fly");
|
||||
MaybeDisplayCond(BL_MASK_RIDE, colormasks, "Ride");
|
||||
} else {
|
||||
label = X11_status_labels[fld];
|
||||
text = status_vals[fld];
|
||||
if (fld == BL_GOLD)
|
||||
text = decode_mixed(tmpbuf, text);
|
||||
#ifdef TEXTCOLOR
|
||||
coloridx = X11_status_colors[fld] & 0x00FF;
|
||||
#endif
|
||||
attridx = (X11_status_colors[fld] & 0xFF00) >> 8;
|
||||
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], nhStr(XtNfont), &font); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNx), &lbl_x); 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(XtNheight), &lbl_hei); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNinternalWidth), &lbl_iwidth); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNborderWidth), &lbl_border_wid); num_args++;
|
||||
XtGetValues(label, args, num_args);
|
||||
|
||||
/*raw_printf("font: %i-%i",
|
||||
font->min_bounds.width, font->max_bounds.width);*/
|
||||
|
||||
if (text && *text)
|
||||
lbl_wid = lbl_iwidth + font->max_bounds.width * strlen(text);
|
||||
else
|
||||
lbl_wid = 1;
|
||||
|
||||
/*raw_printf("1:lbl_wid=%i('%s')", lbl_wid, text);*/
|
||||
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], nhStr(XtNlabel),
|
||||
(text && *text) ? text : ""); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNwidth), lbl_wid); num_args++;
|
||||
|
||||
fg = (coloridx != NO_COLOR) ? get_nhcolor(xw_status_win, coloridx).pixel
|
||||
: X11_status_widget_fg;
|
||||
if (attridx & HL_INVERSE) {
|
||||
Pixel tmppx = fg;
|
||||
|
||||
fg = bg;
|
||||
bg = tmppx;
|
||||
}
|
||||
|
||||
if (attridx & HL_BOLD) {
|
||||
load_boldfont(xw_status_win, label);
|
||||
XtSetArg(args[num_args], nhStr(XtNfont),
|
||||
xw_status_win->boldfs); num_args++;
|
||||
}
|
||||
|
||||
if (fg == bg)
|
||||
fg = get_nhcolor(xw_status_win, CLR_GRAY).pixel;
|
||||
|
||||
XtSetArg(args[num_args], nhStr(XtNforeground), fg); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbackground), bg); num_args++;
|
||||
XtSetValues(label, args, num_args);
|
||||
XtResizeWidget(label, lbl_wid, lbl_hei, lbl_border_wid);
|
||||
}
|
||||
} else {
|
||||
int x, y;
|
||||
|
||||
for (y = 0; y < X11_NUM_STATUS_LINES; y++) {
|
||||
Cardinal dx = 0;
|
||||
|
||||
for (x = 0; x < X11_NUM_STATUS_FIELD; x++) {
|
||||
int f = X11_fieldorder[y][x];
|
||||
|
||||
if (f <= BL_FLUSH)
|
||||
continue;
|
||||
if (!status_activefields[f])
|
||||
continue;
|
||||
|
||||
if (f == BL_CONDITION) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
label = X11_cond_labels[i];
|
||||
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], nhStr(XtNx), &lbl_x); 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(XtNheight), &lbl_hei); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNborderWidth),
|
||||
&lbl_border_wid); num_args++;
|
||||
XtGetValues(label, args, num_args);
|
||||
|
||||
lbl_x = dx;
|
||||
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], nhStr(XtNx), lbl_x); num_args++;
|
||||
XtSetValues(label, args, num_args);
|
||||
XtConfigureWidget(label, lbl_x, lbl_y,
|
||||
lbl_wid, lbl_hei, lbl_border_wid);
|
||||
|
||||
if (lbl_wid > 1)
|
||||
dx += lbl_wid;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
label = X11_status_labels[f];
|
||||
|
||||
text = status_vals[f];
|
||||
if (f == BL_GOLD)
|
||||
text = decode_mixed(tmpbuf, text);
|
||||
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], nhStr(XtNx), &lbl_x); 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(XtNheight), &lbl_hei); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNborderWidth),
|
||||
&lbl_border_wid); num_args++;
|
||||
XtGetValues(label, args, num_args);
|
||||
|
||||
lbl_x = dx;
|
||||
/*raw_printf("2:lbl_wid=%i('%s')", lbl_wid, text);*/
|
||||
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], nhStr(XtNx), lbl_x); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNlabel), text); num_args++;
|
||||
XtSetValues(label, args, num_args);
|
||||
XtConfigureWidget(label, lbl_x, lbl_y,
|
||||
lbl_wid, lbl_hei, lbl_border_wid);
|
||||
|
||||
dx += lbl_wid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
X11_status_update_fancy(fld, ptr, chg, percent, color, colormasks)
|
||||
int fld, chg UNUSED, percent UNUSED, color UNUSED;
|
||||
genericptr_t ptr;
|
||||
unsigned long *colormasks UNUSED;
|
||||
{
|
||||
static const struct {
|
||||
int bl, ff;
|
||||
} bl_to_fancyfield[] = {
|
||||
{ BL_TITLE, F_NAME },
|
||||
{ BL_STR, F_STR },
|
||||
{ BL_DX, F_DEX },
|
||||
{ BL_CO, F_CON },
|
||||
{ BL_IN, F_INT },
|
||||
{ BL_WI, F_WIS },
|
||||
{ BL_CH, F_CHA },
|
||||
{ BL_ALIGN, F_ALIGN },
|
||||
{ BL_SCORE, F_SCORE },
|
||||
{ BL_CAP, F_ENCUMBER },
|
||||
{ BL_GOLD, F_GOLD },
|
||||
{ BL_ENE, F_POWER },
|
||||
{ BL_ENEMAX, F_MAXPOWER },
|
||||
{ BL_XP, F_LEVEL },
|
||||
{ BL_AC, F_AC },
|
||||
/*{ BL_HD, F_ },*/
|
||||
{ BL_TIME, F_TIME },
|
||||
{ BL_HUNGER, F_HUNGER },
|
||||
{ BL_HP, F_HP },
|
||||
{ BL_HPMAX, F_MAXHP },
|
||||
{ BL_LEVELDESC, F_DLEVEL },
|
||||
{ BL_EXP, F_EXP }
|
||||
};
|
||||
static const struct {
|
||||
unsigned long mask;
|
||||
int ff;
|
||||
} mask_to_fancyfield[] = {
|
||||
{ BL_MASK_STONE, F_STONE },
|
||||
{ BL_MASK_SLIME, F_SLIME },
|
||||
{ BL_MASK_STRNGL, F_STRNGL },
|
||||
{ BL_MASK_FOODPOIS, F_FOODPOIS },
|
||||
{ BL_MASK_TERMILL, F_TERMILL },
|
||||
{ BL_MASK_BLIND, F_BLIND },
|
||||
{ BL_MASK_DEAF, F_DEAF },
|
||||
{ BL_MASK_STUN, F_STUN },
|
||||
{ BL_MASK_CONF, F_CONF },
|
||||
{ BL_MASK_HALLU, F_HALLU },
|
||||
{ BL_MASK_LEV, F_LEV },
|
||||
{ BL_MASK_FLY, F_FLY },
|
||||
{ BL_MASK_RIDE, F_RIDE }
|
||||
};
|
||||
int i;
|
||||
|
||||
if (fld == BL_RESET || fld == BL_FLUSH) {
|
||||
if (WIN_STATUS != WIN_ERR) {
|
||||
struct xwindow *wp = &window_list[WIN_STATUS];
|
||||
|
||||
update_fancy_status(wp);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (fld == BL_CONDITION) {
|
||||
unsigned long mask = (unsigned long) ptr;
|
||||
|
||||
for (i = 0; i < SIZE(mask_to_fancyfield); i++)
|
||||
if (mask_to_fancyfield[i].mask == mask)
|
||||
update_fancy_status_field(mask_to_fancyfield[i].ff);
|
||||
} else {
|
||||
for (i = 0; i < SIZE(bl_to_fancyfield); i++)
|
||||
if (bl_to_fancyfield[i].bl == fld)
|
||||
update_fancy_status_field(bl_to_fancyfield[i].ff);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
X11_status_update(fld, ptr, chg, percent, color, colormasks)
|
||||
int fld, chg UNUSED, percent UNUSED, color;
|
||||
genericptr_t ptr;
|
||||
unsigned long *colormasks;
|
||||
{
|
||||
if (appResources.fancy_status)
|
||||
X11_status_update_fancy(fld, ptr, chg, percent, color, colormasks);
|
||||
else
|
||||
X11_status_update_tty(fld, ptr, chg, percent, color, colormasks);
|
||||
}
|
||||
|
||||
Widget
|
||||
create_tty_status(parent, top)
|
||||
Widget parent, top;
|
||||
{
|
||||
Widget form; /* The form that surrounds everything. */
|
||||
Widget w;
|
||||
Arg args[16];
|
||||
Cardinal num_args;
|
||||
int i, x, y;
|
||||
|
||||
num_args = 0;
|
||||
if (top != (Widget) 0) {
|
||||
XtSetArg(args[num_args], nhStr(XtNfromVert), top);
|
||||
num_args++;
|
||||
}
|
||||
XtSetArg(args[num_args], nhStr(XtNdefaultDistance), 0);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], XtNborderWidth, 0);
|
||||
num_args++;
|
||||
XtSetArg(args[num_args], XtNwidth, 400); num_args++;
|
||||
XtSetArg(args[num_args], XtNheight, 100); num_args++;
|
||||
form = XtCreateManagedWidget("status_viewport", viewportWidgetClass,
|
||||
parent, args, num_args);
|
||||
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], XtNwidth, 400); num_args++;
|
||||
XtSetArg(args[num_args], XtNheight, 100); num_args++;
|
||||
w = XtCreateManagedWidget("status_form", formWidgetClass,
|
||||
form, args, num_args);
|
||||
for (y = 0; y < X11_NUM_STATUS_LINES; y++) {
|
||||
for (x = 0; x < X11_NUM_STATUS_FIELD; x++) {
|
||||
int fld = X11_fieldorder[y][x];
|
||||
char labelname[BUFSZ];
|
||||
int prevfld;
|
||||
|
||||
if (fld <= BL_FLUSH)
|
||||
continue;
|
||||
Sprintf(labelname, "label_%s", bl_idx_to_fldname(fld));
|
||||
num_args = 0;
|
||||
if (y > 0) {
|
||||
prevfld = X11_fieldorder[y-1][0];
|
||||
XtSetArg(args[num_args], nhStr(XtNfromVert),
|
||||
X11_status_labels[prevfld]); num_args++;
|
||||
}
|
||||
if (x > 0) {
|
||||
prevfld = X11_fieldorder[y][x-1];
|
||||
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(XtNvertDistance), 0); num_args++;
|
||||
|
||||
XtSetArg(args[num_args], nhStr(XtNtopMargin), 0); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbottomMargin), 0); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNleftMargin), 0); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNrightMargin), 0); 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(XtNlabel),
|
||||
bl_idx_to_fldname(fld)); num_args++;
|
||||
*/
|
||||
XtSetArg(args[num_args], nhStr(XtNlabel), ""); num_args++;
|
||||
X11_status_labels[fld] = XtCreateManagedWidget(labelname,
|
||||
labelWidgetClass, w,
|
||||
args, num_args);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
char condname[BUFSZ];
|
||||
int prevfld;
|
||||
|
||||
Sprintf(condname, "cond_%i", i);
|
||||
num_args = 0;
|
||||
|
||||
prevfld = X11_fieldorder[0][0];
|
||||
XtSetArg(args[num_args], nhStr(XtNfromVert),
|
||||
X11_status_labels[prevfld]); num_args++;
|
||||
|
||||
XtSetArg(args[num_args], nhStr(XtNfromHoriz),
|
||||
(i == 0) ? X11_status_labels[BL_CONDITION]
|
||||
: X11_cond_labels[i-1]); num_args++;
|
||||
|
||||
XtSetArg(args[num_args], nhStr(XtNhorizDistance), 0); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNvertDistance), 0); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNtopMargin), 0); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbottomMargin), 0); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNleftMargin), 0); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNrightMargin), 0); 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(XtNlabel), ""); num_args++;
|
||||
X11_cond_labels[i] = XtCreateManagedWidget(condname,
|
||||
labelWidgetClass, w,
|
||||
args, num_args);
|
||||
}
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
create_status_window_tty(wp, create_popup, parent)
|
||||
struct xwindow *wp; /* window pointer */
|
||||
boolean create_popup UNUSED;
|
||||
Widget parent;
|
||||
{
|
||||
Arg args[10];
|
||||
Cardinal num_args;
|
||||
|
||||
wp->type = NHW_STATUS;
|
||||
X11_status_widget = wp->w = create_tty_status(parent, (Widget) 0);
|
||||
|
||||
num_args = 0;
|
||||
XtSetArg(args[num_args], nhStr(XtNforeground), &X11_status_widget_fg); num_args++;
|
||||
XtSetArg(args[num_args], nhStr(XtNbackground), &X11_status_widget_bg); num_args++;
|
||||
XtGetValues(X11_status_widget, args, num_args);
|
||||
}
|
||||
|
||||
void
|
||||
destroy_status_window_tty(wp)
|
||||
struct xwindow *wp;
|
||||
{
|
||||
/* If status_information is defined, then it a "text" status window. */
|
||||
if (wp->status_information) {
|
||||
if (wp->popup) {
|
||||
nh_XtPopdown(wp->popup);
|
||||
if (!wp->keep_window)
|
||||
XtDestroyWidget(wp->popup), wp->popup = (Widget) 0;
|
||||
}
|
||||
free((genericptr_t) wp->status_information);
|
||||
wp->status_information = 0;
|
||||
} else {
|
||||
}
|
||||
if (!wp->keep_window)
|
||||
wp->type = NHW_NONE;
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
adjust_status_tty(wp, str)
|
||||
struct xwindow *wp UNUSED;
|
||||
const char *str UNUSED;
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
void
|
||||
create_status_window(wp, create_popup, parent)
|
||||
struct xwindow *wp; /* window pointer */
|
||||
boolean create_popup;
|
||||
Widget parent;
|
||||
{
|
||||
xw_status_win = wp;
|
||||
if (appResources.fancy_status)
|
||||
create_status_window_fancy(wp, create_popup, parent);
|
||||
else
|
||||
create_status_window_tty(wp, create_popup, parent);
|
||||
}
|
||||
|
||||
void
|
||||
destroy_status_window(wp)
|
||||
struct xwindow *wp;
|
||||
{
|
||||
if (appResources.fancy_status)
|
||||
destroy_status_window_fancy(wp);
|
||||
else
|
||||
destroy_status_window_tty(wp);
|
||||
}
|
||||
|
||||
void
|
||||
adjust_status(wp, str)
|
||||
struct xwindow *wp;
|
||||
const char *str;
|
||||
{
|
||||
if (appResources.fancy_status)
|
||||
adjust_status_fancy(wp, str);
|
||||
else
|
||||
adjust_status_tty(wp, str);
|
||||
}
|
||||
|
||||
extern const char *hu_stat[]; /* from eat.c */
|
||||
extern const char *enc_stat[]; /* from botl.c */
|
||||
|
||||
static void FDECL(update_fancy_status, (struct xwindow *));
|
||||
static Widget FDECL(create_fancy_status, (Widget, Widget));
|
||||
static void FDECL(destroy_fancy_status, (struct xwindow *));
|
||||
|
||||
void
|
||||
create_status_window(wp, create_popup, parent)
|
||||
create_status_window_fancy(wp, create_popup, parent)
|
||||
struct xwindow *wp; /* window pointer */
|
||||
boolean create_popup;
|
||||
Widget parent;
|
||||
@@ -60,7 +798,7 @@ Widget parent;
|
||||
* window.
|
||||
*/
|
||||
if (!parent)
|
||||
panic("create_status_window: no parent for fancy status");
|
||||
panic("create_status_window_fancy: no parent for fancy status");
|
||||
wp->status_information = 0;
|
||||
wp->w = create_fancy_status(parent, (Widget) 0);
|
||||
return;
|
||||
@@ -133,7 +871,7 @@ Widget parent;
|
||||
}
|
||||
|
||||
void
|
||||
destroy_status_window(wp)
|
||||
destroy_status_window_fancy(wp)
|
||||
struct xwindow *wp;
|
||||
{
|
||||
/* If status_information is defined, then it a "text" status window. */
|
||||
@@ -159,7 +897,7 @@ struct xwindow *wp;
|
||||
* + We didn't set stringInPlace on the widget.
|
||||
*/
|
||||
void
|
||||
adjust_status(wp, str)
|
||||
adjust_status_fancy(wp, str)
|
||||
struct xwindow *wp;
|
||||
const char *str;
|
||||
{
|
||||
@@ -216,52 +954,6 @@ static Widget FDECL(init_column, (const char *, Widget, Widget, Widget,
|
||||
static void NDECL(fixup_cond_widths);
|
||||
static Widget FDECL(init_info_form, (Widget, Widget, Widget));
|
||||
|
||||
/*
|
||||
* Form entry storage indices.
|
||||
*/
|
||||
#define F_DUMMY 0
|
||||
#define F_STR 1
|
||||
#define F_DEX 2
|
||||
#define F_CON 3
|
||||
#define F_INT 4
|
||||
#define F_WIS 5
|
||||
#define F_CHA 6
|
||||
|
||||
#define F_NAME 7
|
||||
#define F_DLEVEL 8
|
||||
#define F_GOLD 9
|
||||
#define F_HP 10
|
||||
#define F_MAXHP 11
|
||||
#define F_POWER 12
|
||||
#define F_MAXPOWER 13
|
||||
#define F_AC 14
|
||||
#define F_LEVEL 15
|
||||
#define F_EXP 16
|
||||
#define F_ALIGN 17
|
||||
#define F_TIME 18
|
||||
#define F_SCORE 19
|
||||
|
||||
/* status conditions grouped by columns; tty orders these differently */
|
||||
#define F_STONE 20
|
||||
#define F_SLIME 21
|
||||
#define F_STRNGL 22
|
||||
#define F_FOODPOIS 23
|
||||
#define F_TERMILL 24
|
||||
|
||||
#define F_HUNGER 25
|
||||
#define F_ENCUMBER 26
|
||||
#define F_LEV 27
|
||||
#define F_FLY 28
|
||||
#define F_RIDE 29
|
||||
|
||||
#define F_BLIND 30
|
||||
#define F_DEAF 31
|
||||
#define F_STUN 32
|
||||
#define F_CONF 33
|
||||
#define F_HALLU 34
|
||||
|
||||
#define NUM_STATS 35
|
||||
|
||||
/*
|
||||
* Notes:
|
||||
* + Alignment needs a different init value, because -1 is an alignment.
|
||||
@@ -583,18 +1275,13 @@ long new_value;
|
||||
* [**] HD is shown instead of level and exp if Upolyd.
|
||||
*/
|
||||
static void
|
||||
update_fancy_status(wp)
|
||||
struct xwindow *wp;
|
||||
update_fancy_status_field(i)
|
||||
int i;
|
||||
{
|
||||
struct X_status_value *sv;
|
||||
struct X_status_value *sv = &shown_stats[i];
|
||||
long val;
|
||||
int i;
|
||||
|
||||
if (wp->cursy != 0)
|
||||
return; /* do a complete update when line 0 is done */
|
||||
|
||||
for (i = 0, sv = shown_stats; i < NUM_STATS; i++, sv++) {
|
||||
switch (i) {
|
||||
switch (i) {
|
||||
case F_DUMMY:
|
||||
val = 0L;
|
||||
break;
|
||||
@@ -734,11 +1421,25 @@ struct xwindow *wp;
|
||||
val = 0L;
|
||||
break;
|
||||
} /* default */
|
||||
} /* switch */
|
||||
update_val(sv, val);
|
||||
}
|
||||
} /* switch */
|
||||
update_val(sv, val);
|
||||
}
|
||||
|
||||
/*ARGUSED*/
|
||||
static void
|
||||
update_fancy_status(wp)
|
||||
struct xwindow *wp UNUSED;
|
||||
{
|
||||
int i;
|
||||
|
||||
/*if (wp->cursy != 0)
|
||||
return;*/ /* do a complete update when line 0 is done */
|
||||
|
||||
for (i = 0; i < NUM_STATS; i++)
|
||||
update_fancy_status_field(i);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Turn off hilighted status values after a certain amount of turns.
|
||||
*/
|
||||
|
||||
@@ -27,23 +27,26 @@ void *me;
|
||||
void *nextprocs;
|
||||
void *nextdata;
|
||||
{
|
||||
struct chainin_data *tdp = 0;
|
||||
|
||||
switch (cmd) {
|
||||
case WINCHAIN_ALLOC: {
|
||||
struct chainin_data *tdp = calloc(1, sizeof(struct chainin_data));
|
||||
case WINCHAIN_ALLOC:
|
||||
tdp = (struct chainin_data *) alloc(sizeof *tdp);
|
||||
tdp->nprocs = 0;
|
||||
tdp->ndata = 0;
|
||||
tdp->linknum = n;
|
||||
cibase = tdp;
|
||||
return tdp;
|
||||
}
|
||||
case WINCHAIN_INIT: {
|
||||
struct chainin_data *tdp = me;
|
||||
cibase = 0;
|
||||
break;
|
||||
case WINCHAIN_INIT:
|
||||
tdp = me;
|
||||
tdp->nprocs = nextprocs;
|
||||
tdp->ndata = nextdata;
|
||||
return tdp;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
raw_printf("chainin_procs_chain: bad cmd\n");
|
||||
exit(EXIT_FAILURE);
|
||||
panic("chainin_procs_chain: bad cmd\n");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
return tdp;
|
||||
}
|
||||
|
||||
/* XXX if we don't need this, take it out of the table */
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
struct chainout_data {
|
||||
struct window_procs *nprocs;
|
||||
#if 0
|
||||
void *ndata;
|
||||
void *ndata;
|
||||
|
||||
#endif
|
||||
int linknum;
|
||||
@@ -24,21 +24,23 @@ void *me;
|
||||
void *nextprocs;
|
||||
void *nextdata UNUSED;
|
||||
{
|
||||
struct chainout_data *tdp = 0;
|
||||
|
||||
switch (cmd) {
|
||||
case WINCHAIN_ALLOC: {
|
||||
struct chainout_data *tdp = calloc(1, sizeof(struct chainout_data));
|
||||
case WINCHAIN_ALLOC:
|
||||
tdp = (struct chainout_data *) alloc(sizeof *tdp);
|
||||
tdp->nprocs = 0;
|
||||
tdp->linknum = n;
|
||||
return tdp;
|
||||
}
|
||||
case WINCHAIN_INIT: {
|
||||
struct chainout_data *tdp = me;
|
||||
break;
|
||||
case WINCHAIN_INIT:
|
||||
tdp = me;
|
||||
tdp->nprocs = nextprocs;
|
||||
return tdp;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
raw_printf("chainout_procs_chain: bad cmd\n");
|
||||
exit(EXIT_FAILURE);
|
||||
panic("chainout_procs_chain: bad cmd\n");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
return tdp;
|
||||
}
|
||||
|
||||
/* XXX if we don't need this, take it out of the table */
|
||||
|
||||
@@ -48,22 +48,25 @@ void *me;
|
||||
void *nextprocs;
|
||||
void *nextdata;
|
||||
{
|
||||
struct trace_data *tdp = 0;
|
||||
|
||||
switch (cmd) {
|
||||
case WINCHAIN_ALLOC: {
|
||||
struct trace_data *tdp = calloc(1, sizeof(struct trace_data));
|
||||
case WINCHAIN_ALLOC:
|
||||
tdp = (struct trace_data *) alloc(sizeof *tdp);
|
||||
tdp->nprocs = 0;
|
||||
tdp->ndata = 0;
|
||||
tdp->linknum = n;
|
||||
return tdp;
|
||||
}
|
||||
case WINCHAIN_INIT: {
|
||||
struct trace_data *tdp = me;
|
||||
break;
|
||||
case WINCHAIN_INIT:
|
||||
tdp = me;
|
||||
tdp->nprocs = nextprocs;
|
||||
tdp->ndata = nextdata;
|
||||
return tdp;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
raw_printf("trace_procs_chain: bad cmd\n");
|
||||
exit(EXIT_FAILURE);
|
||||
panic("trace_procs_chain: bad cmd\n");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
return tdp;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -71,20 +74,22 @@ trace_procs_init(dir)
|
||||
int dir;
|
||||
{
|
||||
char fname[200];
|
||||
long pid;
|
||||
|
||||
/* processors shouldn't need this test, but just in case */
|
||||
if (dir != WININIT)
|
||||
return;
|
||||
|
||||
sprintf(fname, "%s/tlog.%d", HACKDIR, getpid());
|
||||
pid = (long) getpid();
|
||||
Sprintf(fname, "%s/tlog.%ld", HACKDIR, pid);
|
||||
wc_tracelogf = fopen(fname, "w");
|
||||
if (wc_tracelogf == NULL) {
|
||||
if (!wc_tracelogf) {
|
||||
fprintf(stderr, "Can't open trace log file %s: %s\n", fname,
|
||||
strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
nh_terminate(EXIT_FAILURE);
|
||||
}
|
||||
setvbuf(wc_tracelogf, (char *) NULL, _IONBF, 0);
|
||||
fprintf(wc_tracelogf, "Trace log started for pid %d\n", getpid());
|
||||
setvbuf(wc_tracelogf, (char *) 0, _IONBF, 0);
|
||||
fprintf(wc_tracelogf, "Trace log started for pid %ld\n", pid);
|
||||
|
||||
indent_level = 0;
|
||||
}
|
||||
@@ -769,7 +774,7 @@ char *bufp;
|
||||
}
|
||||
|
||||
if (bufp) {
|
||||
fprintf(wc_tracelogf, "%p)\n", bufp);
|
||||
fprintf(wc_tracelogf, "%s)\n", fmt_ptr((genericptr_t) bufp));
|
||||
} else {
|
||||
fprintf(wc_tracelogf, "NULL)\n");
|
||||
}
|
||||
@@ -785,7 +790,7 @@ void *vp;
|
||||
{
|
||||
struct trace_data *tdp = vp;
|
||||
int rv;
|
||||
int ecl_size;
|
||||
int ecl_size = 0;
|
||||
|
||||
/* this is ugly, but the size isn't exposed */
|
||||
const struct ext_func_tab *efp;
|
||||
@@ -1095,7 +1100,8 @@ unsigned long *colormasks;
|
||||
ptr, chg, percent);
|
||||
|
||||
PRE;
|
||||
(*tdp->nprocs->win_status_update)(tdp->ndata, idx, ptr, chg, percent, color, colormasks);
|
||||
(*tdp->nprocs->win_status_update)(tdp->ndata, idx, ptr, chg, percent,
|
||||
color, colormasks);
|
||||
POST;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user