Merge branch 'NetHack-3.6.2'

This commit is contained in:
nhmall
2018-10-14 13:05:31 -04:00
12 changed files with 139 additions and 27 deletions
+51 -3
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 winX.c $NHDT-Date: 1526429314 2018/05/16 00:08:34 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.50 $ */
/* NetHack 3.6 winX.c $NHDT-Date: 1539392992 2018/10/13 01:09:52 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.57 $ */
/* Copyright (c) Dean Luick, 1992 */
/* NetHack may be freely redistributed. See license for details. */
@@ -85,6 +85,8 @@ int click_x, click_y, click_button; /* Click position on a map window */
/* (filled by set_button_values()). */
int updated_inventory;
static int (*old_error_handler) (Display *, XErrorEvent *);
#if !defined(NO_SIGNAL) && defined(SAFERHANGUP)
#if XtSpecificationRelease >= 6
#define X11_HANGUP_SIGNAL
@@ -148,6 +150,7 @@ static void FDECL(nhFreePixel, (XtAppContext, XrmValuePtr, XtPointer,
static boolean FDECL(new_resource_macro, (String, unsigned));
static void NDECL(load_default_resources);
static void NDECL(release_default_resources);
static int FDECL(panic_on_error, (Display *, XErrorEvent *));
#ifdef X11_HANGUP_SIGNAL
static void FDECL(X11_sig, (int));
static void FDECL(X11_sig_cb, (XtPointer, XtSignalId *));
@@ -484,6 +487,34 @@ int *x, *y, *width, *height;
*y -= top;
}
/* Change the full font name string so the weight is "bold" */
char *
fontname_boldify(fontname)
const char *fontname;
{
static char buf[BUFSZ];
char *bufp = buf;
int idx = 0;
while (*fontname) {
if (*fontname == '-')
idx++;
*bufp = *fontname;
if (idx == 3) {
strcat(buf, "bold");
bufp += 5;
do {
fontname++;
} while (*fontname && *fontname != '-');
} else {
bufp++;
fontname++;
}
}
*bufp = '\0';
return buf;
}
#ifdef TEXTCOLOR
/* ARGSUSED */
static void
@@ -1245,6 +1276,21 @@ static XtResource resources[] = {
#endif
};
static int
panic_on_error(display, error)
Display *display;
XErrorEvent *error;
{
char buf[BUFSZ];
XGetErrorText(display, error->error_code, buf, BUFSZ);
fprintf(stderr, "X Error: code %i (%s), request %i, minor %i, serial %lu\n",
error->error_code, buf,
error->request_code, error->minor_code,
error->serial);
panic("X Error");
return 0;
}
void
X11_init_nhwindows(argcp, argv)
int *argcp;
@@ -1290,6 +1336,8 @@ char **argv;
/* We don't need to realize the top level widget. */
old_error_handler = XSetErrorHandler(panic_on_error);
#ifdef TEXTCOLOR
/* add new color converter to deal with overused colormaps */
XtSetTypeConverter(XtRString, XtRPixel, nhCvtStringToPixel,
@@ -2511,7 +2559,7 @@ String *params;
Cardinal *num_params;
{
Arg arg[2];
Widget horiz_sb, vert_sb;
Widget horiz_sb, vert_sb, scrollw;
float top, shown;
Boolean do_call;
int direction;
@@ -2524,7 +2572,7 @@ Cardinal *num_params;
direction = atoi(params[0]);
Widget scrollw = viewport;
scrollw = viewport;
do {
horiz_sb = XtNameToWidget(scrollw, "*horizontal");
vert_sb = XtNameToWidget(scrollw, "*vertical");
+41
View File
@@ -778,6 +778,31 @@ Widget form,under;
return all;
}
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);
}
void
menu_create_entries(wp, curr_menu)
struct xwindow *wp;
@@ -843,6 +868,13 @@ struct menu *curr_menu;
: labelWidgetClass,
wp->w, args, num_args);
if (attr == ATR_BOLD) {
load_boldfont(wp, curr->w);
num_args = 0;
XtSetArg(args[num_args], nhStr(XtNfont), wp->menu_information->boldfs); num_args++;
XtSetValues(curr->w, args, num_args);
}
if (canpick)
XtAddCallback(linewidget, XtNcallback, menu_select,
(XtPointer) curr);
@@ -1001,6 +1033,13 @@ menu_item **menu_list;
if (menu_info->is_up && permi && menu_info->curr_menu.base) {
/* perm_invent window - explicitly destroy old menu entry widgets,
without recreating whole window */
WidgetList wlist;
Cardinal numchild;
num_args = 0;
XtSetArg(args[num_args], XtNchildren, &wlist); num_args++;
XtSetArg(args[num_args], XtNnumChildren, &numchild); num_args++;
XtGetValues(wp->w, args, num_args);
XtUnmanageChildren(wlist, numchild);
for (curr = menu_info->curr_menu.base; curr; curr = curr->next)
if (curr->w)
XtDestroyWidget(curr->w);
@@ -1285,6 +1324,8 @@ 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 */
+2 -1
View File
@@ -218,6 +218,7 @@
<DlbList Include = "$(DatDir)porthelp"/>
<DlbList Include = "$(DatDir)hh"/>
<DlbList Include = "$(DatDir)cmdhelp"/>
<DlbList Include = "$(DatDir)keyhelp"/>
<DlbList Include = "$(DatDir)history"/>
<DlbList Include = "$(DatDir)opthelp"/>
<DlbList Include = "$(DatDir)wizhelp"/>
@@ -225,4 +226,4 @@
<DlbList Include = "$(DatDir)license"/>
<DlbList Include = "$(DatDir)*.lev"/>
</ItemGroup>
</Project>
</Project>
+1
View File
@@ -218,6 +218,7 @@
<DlbList Include = "$(DatDir)porthelp"/>
<DlbList Include = "$(DatDir)hh"/>
<DlbList Include = "$(DatDir)cmdhelp"/>
<DlbList Include = "$(DatDir)keyhelp"/>
<DlbList Include = "$(DatDir)history"/>
<DlbList Include = "$(DatDir)opthelp"/>
<DlbList Include = "$(DatDir)wizhelp"/>