Merge branch 'NetHack-3.6.2'
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 winX.c $NHDT-Date: 1546081304 2018/12/29 11:01:44 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.71 $ */
|
||||
/* NetHack 3.6 winX.c $NHDT-Date: 1552422652 2019/03/12 20:30:52 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.72 $ */
|
||||
/* Copyright (c) Dean Luick, 1992 */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -1355,10 +1355,20 @@ int how;
|
||||
time_t when;
|
||||
{
|
||||
struct xwindow *wp;
|
||||
FILE *rip_fp;
|
||||
|
||||
check_winid(window);
|
||||
wp = &window_list[window];
|
||||
|
||||
/* make sure the graphic_tombstone is available; it's not easy to
|
||||
revert to ordinary text tombstone once we're past this point... */
|
||||
rip_fp = fopen(appResources.tombstone, "r"); /* "rip.xpm" */
|
||||
if (!rip_fp) {
|
||||
genl_outrip(window, how, when);
|
||||
return;
|
||||
}
|
||||
(void) fclose(rip_fp);
|
||||
|
||||
if (wp->type == NHW_TEXT) {
|
||||
wp->text_information->is_rip = TRUE;
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 wintext.c $NHDT-Date: 1546081305 2018/12/29 11:01:45 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.17 $ */
|
||||
/* NetHack 3.6 wintext.c $NHDT-Date: 1552422654 2019/03/12 20:30:54 $ $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. */
|
||||
|
||||
@@ -181,8 +181,7 @@ boolean blocking;
|
||||
* _some_ lines. Finally, use the number of lines in the text if
|
||||
* there are fewer than the max.
|
||||
*/
|
||||
nlines =
|
||||
(XtScreen(wp->w)->height - text_info->extra_height) / font_height;
|
||||
nlines = (XtScreen(wp->w)->height - text_info->extra_height) / font_height;
|
||||
nlines -= 4;
|
||||
|
||||
if (nlines > text_info->text.num_lines)
|
||||
@@ -204,13 +203,16 @@ boolean blocking;
|
||||
#ifdef GRAPHIC_TOMBSTONE
|
||||
if (text_info->is_rip) {
|
||||
Widget rip = create_ripout_widget(XtParent(wp->w));
|
||||
XtSetArg(args[num_args], nhStr(XtNfromVert), rip);
|
||||
num_args++;
|
||||
|
||||
if (rip) {
|
||||
XtSetArg(args[num_args], nhStr(XtNfromVert), rip);
|
||||
num_args++;
|
||||
} else
|
||||
text_info->is_rip = FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (width
|
||||
> (Dimension) XtScreen(wp->w)->width) { /* too wide for screen */
|
||||
if (width > (Dimension) XtScreen(wp->w)->width) { /* too wide for screen */
|
||||
/* Back off some amount - we really need to back off the scrollbar */
|
||||
/* width plus some extra. */
|
||||
width = XtScreen(wp->w)->width - 20;
|
||||
@@ -420,8 +422,7 @@ boolean concat;
|
||||
if (str) {
|
||||
(void) memcpy((tb->text + tb->text_last), str, length + 1);
|
||||
if (length) {
|
||||
/* Remove all newlines. Otherwise we have a confused line count.
|
||||
*/
|
||||
/* Remove all newlines. Otherwise we have a confused line count. */
|
||||
copy = (tb->text + tb->text_last);
|
||||
while ((copy = index(copy, '\n')) != (char *) 0)
|
||||
*copy = ' ';
|
||||
@@ -577,6 +578,7 @@ XtPointer widget_data; /* expose event from Window widget */
|
||||
int len = strlen(rip_line[i]);
|
||||
XFontStruct *font = WindowFontStruct(w);
|
||||
int width = XTextWidth(font, rip_line[i], len);
|
||||
|
||||
XDrawString(dpy, XtWindow(w), gc, x - width / 2, y, rip_line[i], len);
|
||||
x += appResources.tombtext_dx;
|
||||
y += appResources.tombtext_dy;
|
||||
@@ -603,14 +605,16 @@ create_ripout_widget(Widget parent)
|
||||
|
||||
attributes.valuemask = XpmCloseness;
|
||||
attributes.closeness = 65535; /* Try anything */
|
||||
errorcode =
|
||||
XpmReadFileToImage(XtDisplay(parent), appResources.tombstone,
|
||||
&rip_image, 0, &attributes);
|
||||
errorcode = XpmReadFileToImage(XtDisplay(parent),
|
||||
appResources.tombstone,
|
||||
&rip_image, 0, &attributes);
|
||||
if (errorcode != XpmSuccess) {
|
||||
char buf[BUFSZ];
|
||||
|
||||
Sprintf(buf, "Failed to load %s: %s", appResources.tombstone,
|
||||
XpmGetErrorString(errorcode));
|
||||
X11_raw_print(buf);
|
||||
return (Widget) 0;
|
||||
}
|
||||
rip_width = rip_image->width;
|
||||
rip_height = rip_image->height;
|
||||
|
||||
@@ -17,6 +17,36 @@
|
||||
#define strncasecmp strncmpi
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Note:
|
||||
*
|
||||
* Prototypes need to use the widened/unwidened type macros (CHAR_P, &c)
|
||||
* in order to match fields of the window_procs struct (see winprocs.h).
|
||||
* But for a standard-conforming compiler, we'll end up with the widened
|
||||
* types necessary to match the mixed prototype/old-style function
|
||||
* definition environment as used by nethack's core. Prototype
|
||||
int func(CHAR_P);
|
||||
* becomes
|
||||
int func(int);
|
||||
* after expansion, which matches the definition
|
||||
int func(arg) char arg; { ... }
|
||||
* according to the rules of the C standard. But the use of new-style
|
||||
* definitions
|
||||
int func(char arg) { ... }
|
||||
* by the curses interface turns that into a conflict. No widening takes
|
||||
* place so it ought to be 'int func(char);' instead. Unfortunately that
|
||||
* would be incompatible for functions assigned to window_procs.
|
||||
*
|
||||
* So, the code here (also cursmain.c and cursinvt.c) is mis-using the
|
||||
* widening macros for variable types
|
||||
int func(CHAR_P arg) { ... }
|
||||
* (no doubt modelling it after the C++ code in win/Qt where the option
|
||||
* to switch the applicable definitions to old-style isn't available).
|
||||
* Other alternatives aren't significantly better so just live with it.
|
||||
* [Redoing the windowing interface to avoid narrow arguments would be
|
||||
* better since that would fix Qt's usage too.]
|
||||
*/
|
||||
|
||||
/* Dialog windows for curses interface */
|
||||
|
||||
|
||||
@@ -76,7 +106,8 @@ static int menu_max_height(void);
|
||||
static nhmenu *nhmenus = NULL; /* NetHack menu array */
|
||||
|
||||
|
||||
/* Get a line of text from the player, such as asking for a character name or a wish */
|
||||
/* Get a line of text from the player, such as asking for a character name
|
||||
or a wish */
|
||||
|
||||
void
|
||||
curses_line_input_dialog(const char *prompt, char *answer, int buffer)
|
||||
@@ -333,7 +364,7 @@ curses_ext_cmd()
|
||||
if (iflags.extmenu) {
|
||||
return extcmd_via_menu();
|
||||
}
|
||||
|
||||
|
||||
startx = 0;
|
||||
starty = 0;
|
||||
if (iflags.wc_popup_dialog) { /* Prompt in popup window */
|
||||
@@ -341,9 +372,9 @@ curses_ext_cmd()
|
||||
extwin2 = curses_create_window(25, 1, UP);
|
||||
wrefresh(extwin2);
|
||||
/* create window inside window to prevent overwriting of border */
|
||||
getbegyx(extwin2,y0,x0);
|
||||
getmaxyx(extwin2,h,w);
|
||||
extwin = newwin(1, w-2, y0+1, x0+1);
|
||||
getbegyx(extwin2, y0, x0);
|
||||
getmaxyx(extwin2, h, w);
|
||||
extwin = newwin(1, w - 2, y0 + 1, x0 + 1);
|
||||
if (w - 4 < maxlen) maxlen = w - 4;
|
||||
} else {
|
||||
curses_get_window_xy(MESSAGE_WIN, &winx, &winy);
|
||||
@@ -355,8 +386,9 @@ curses_ext_cmd()
|
||||
}
|
||||
|
||||
winy += messageh - 1;
|
||||
extwin = newwin(1, messagew-2, winy, winx);
|
||||
if (messagew - 4 < maxlen) maxlen = messagew - 4;
|
||||
extwin = newwin(1, messagew - 2, winy, winx);
|
||||
if (messagew - 4 < maxlen)
|
||||
maxlen = messagew - 4;
|
||||
pline("#");
|
||||
}
|
||||
|
||||
@@ -390,7 +422,7 @@ curses_ext_cmd()
|
||||
break;
|
||||
}
|
||||
|
||||
if ((letter == '\r') || (letter == '\n')) {
|
||||
if (letter == '\r' || letter == '\n') {
|
||||
if (ret == -1) {
|
||||
for (count = 0; extcmdlist[count].ef_txt; count++) {
|
||||
if (!strcasecmp(cur_choice, extcmdlist[count].ef_txt)) {
|
||||
@@ -402,7 +434,9 @@ curses_ext_cmd()
|
||||
break;
|
||||
}
|
||||
|
||||
if ((letter == '\b') || (letter == KEY_BACKSPACE)) {
|
||||
if (letter == '\177') /* DEL/Rubout */
|
||||
letter = '\b';
|
||||
if (letter == '\b' || letter == KEY_BACKSPACE) {
|
||||
if (prompt_width == 0) {
|
||||
ret = -1;
|
||||
break;
|
||||
@@ -749,10 +783,9 @@ menu_get_accel(boolean first)
|
||||
|
||||
ret = next_letter;
|
||||
|
||||
if (((next_letter < 'z') && (next_letter >= 'a')) || ((next_letter < 'Z')
|
||||
&& (next_letter >=
|
||||
'A')) ||
|
||||
((next_letter < '9') && (next_letter >= '0'))) {
|
||||
if ((next_letter < 'z' && next_letter >= 'a')
|
||||
|| (next_letter < 'Z' && next_letter >= 'A')
|
||||
|| (next_letter < '9' && next_letter >= '0')) {
|
||||
next_letter++;
|
||||
} else if (next_letter == 'z') {
|
||||
next_letter = 'A';
|
||||
@@ -789,8 +822,8 @@ menu_is_multipage(nhmenu *menu, int width, int height)
|
||||
menu_item_ptr->num_lines = num_lines;
|
||||
curline += num_lines;
|
||||
menu_item_ptr = menu_item_ptr->next_item;
|
||||
if ((curline > height) || ((curline > height - 2) &&
|
||||
(height == menu_max_height()))) {
|
||||
if (curline > height
|
||||
|| (curline > height - 2 && height == menu_max_height())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -895,7 +928,7 @@ menu_win_size(nhmenu *menu)
|
||||
menu_item_ptr = menu_item_ptr->next_item;
|
||||
}
|
||||
|
||||
/* If the widest entry is smaller than maxwidth, reduce maxwidth accordingly */
|
||||
/* If widest entry is smaller than maxwidth, reduce maxwidth accordingly */
|
||||
if (maxentrywidth < maxwidth) {
|
||||
maxwidth = maxentrywidth;
|
||||
}
|
||||
@@ -922,7 +955,7 @@ menu_win_size(nhmenu *menu)
|
||||
if (lastline < maxheight) {
|
||||
maxheight = lastline;
|
||||
}
|
||||
} else { /* If multipage, make sure we have enough width for page footer */
|
||||
} else { /* If multipage, make sure we have enough width for page footer */
|
||||
|
||||
if (width < 20) {
|
||||
width = 20;
|
||||
@@ -1218,8 +1251,8 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how)
|
||||
menu_item_ptr = menu->entries;
|
||||
|
||||
while (menu_item_ptr != NULL) {
|
||||
if ((menu_item_ptr->identifier.a_void != NULL) &&
|
||||
(strstri(menu_item_ptr->str, search_key))) {
|
||||
if (menu_item_ptr->identifier.a_void != NULL
|
||||
&& strstri(menu_item_ptr->str, search_key)) {
|
||||
if (how == PICK_ONE) {
|
||||
menu_clear_selections(menu);
|
||||
menu_select_deselect(win, menu_item_ptr, SELECT);
|
||||
@@ -1247,12 +1280,11 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how)
|
||||
menu_item_ptr = menu->entries;
|
||||
while (menu_item_ptr != NULL) {
|
||||
if (menu_item_ptr->identifier.a_void != NULL) {
|
||||
if (((curletter == menu_item_ptr->accelerator) &&
|
||||
((curpage == menu_item_ptr->page_num) ||
|
||||
(!menu->reuse_accels))) || ((menu_item_ptr->group_accel)
|
||||
&& (curletter ==
|
||||
menu_item_ptr->
|
||||
group_accel))) {
|
||||
if ((curletter == menu_item_ptr->accelerator
|
||||
&& (curpage == menu_item_ptr->page_num
|
||||
|| !menu->reuse_accels))
|
||||
|| (menu_item_ptr->group_accel
|
||||
&& curletter == menu_item_ptr->group_accel)) {
|
||||
if (curpage != menu_item_ptr->page_num) {
|
||||
curpage = menu_item_ptr->page_num;
|
||||
menu_display_page(menu, win, curpage);
|
||||
@@ -1266,7 +1298,7 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how)
|
||||
num_selected = 1;
|
||||
dismiss = TRUE;
|
||||
break;
|
||||
} else if ((how == PICK_ANY) && (curletter == count_letter)) {
|
||||
} else if (how == PICK_ANY && curletter == count_letter) {
|
||||
menu_select_deselect(win, menu_item_ptr, SELECT);
|
||||
menu_item_ptr->count = count;
|
||||
count = 0;
|
||||
@@ -1280,7 +1312,7 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how)
|
||||
}
|
||||
}
|
||||
|
||||
if ((how == PICK_ANY) && (num_selected != -1)) {
|
||||
if (how == PICK_ANY && num_selected != -1) {
|
||||
num_selected = 0;
|
||||
menu_item_ptr = menu->entries;
|
||||
|
||||
|
||||
@@ -84,9 +84,9 @@ struct window_procs curses_procs = {
|
||||
/*
|
||||
* Global variables for curses interface
|
||||
*/
|
||||
|
||||
|
||||
int term_rows, term_cols; /* size of underlying terminal */
|
||||
int orig_cursor; /* Preserve initial cursor state */
|
||||
int orig_cursor; /* Preserve initial cursor state */
|
||||
WINDOW *base_term; /* underlying terminal window */
|
||||
boolean counting; /* Count window is active */
|
||||
WINDOW *mapwin, *statuswin, *messagewin; /* Main windows */
|
||||
@@ -96,7 +96,7 @@ WINDOW *mapwin, *statuswin, *messagewin; /* Main windows */
|
||||
the inventory window. */
|
||||
static int inv_update = 0;
|
||||
|
||||
/*
|
||||
/*
|
||||
init_nhwindows(int* argcp, char** argv)
|
||||
-- Initialize the windows used by NetHack. This can also
|
||||
create the standard windows listed at the top, but does
|
||||
@@ -264,7 +264,7 @@ curses_resume_nhwindows()
|
||||
curses_refresh_nethack_windows();
|
||||
}
|
||||
|
||||
/* Create a window of type "type" which can be
|
||||
/* Create a window of type "type" which can be
|
||||
NHW_MESSAGE (top line)
|
||||
NHW_STATUS (bottom lines)
|
||||
NHW_MAP (main dungeon)
|
||||
@@ -307,6 +307,7 @@ void
|
||||
curses_display_nhwindow(winid wid, BOOLEAN_P block)
|
||||
{
|
||||
menu_item *selected = NULL;
|
||||
|
||||
if (curses_is_menu(wid) || curses_is_text(wid)) {
|
||||
curses_end_menu(wid, "");
|
||||
curses_select_menu(wid, PICK_NONE, &selected);
|
||||
@@ -314,9 +315,9 @@ curses_display_nhwindow(winid wid, BOOLEAN_P block)
|
||||
}
|
||||
|
||||
/* don't overwrite the splash screen first time through */
|
||||
if (!iflags.window_inited && wid == MAP_WIN)
|
||||
if (!iflags.window_inited && wid == MAP_WIN) {
|
||||
iflags.window_inited = TRUE;
|
||||
else {
|
||||
} else {
|
||||
/* actually display the window */
|
||||
wnoutrefresh(curses_get_nhwin(wid));
|
||||
/* flush pending writes from other windows too */
|
||||
@@ -332,7 +333,7 @@ curses_display_nhwindow(winid wid, BOOLEAN_P block)
|
||||
}
|
||||
|
||||
|
||||
/* Destroy will dismiss the window if the window has not
|
||||
/* Destroy will dismiss the window if the window has not
|
||||
* already been dismissed.
|
||||
*/
|
||||
void
|
||||
@@ -586,7 +587,7 @@ print_glyph(window, x, y, glyph, bkglyph)
|
||||
port wants (symbol, font, color, attributes, ...there's
|
||||
a 1-1 map between glyphs and distinct things on the map).
|
||||
bkglyph is to render the background behind the glyph.
|
||||
It's not used here.
|
||||
It's not used here.
|
||||
*/
|
||||
void
|
||||
curses_print_glyph(winid wid, XCHAR_P x, XCHAR_P y, int glyph,
|
||||
@@ -679,8 +680,8 @@ int nh_poskey(int *x, int *y, int *mod)
|
||||
a position in the MAP window is returned in x, y and mod.
|
||||
mod may be one of
|
||||
|
||||
CLICK_1 -- mouse click type 1
|
||||
CLICK_2 -- mouse click type 2
|
||||
CLICK_1 -- mouse click type 1
|
||||
CLICK_2 -- mouse click type 2
|
||||
|
||||
The different click types can map to whatever the
|
||||
hardware supports. If no mouse is supported, this
|
||||
@@ -841,14 +842,14 @@ preference_update(preference)
|
||||
port of that change. If your window-port is capable of
|
||||
dynamically adjusting to the change then it should do so.
|
||||
Your window-port will only be notified of a particular
|
||||
change if it indicated that it wants to be by setting the
|
||||
change if it indicated that it wants to be by setting the
|
||||
corresponding bit in the wincap mask.
|
||||
*/
|
||||
void
|
||||
curses_preference_update(const char *pref)
|
||||
{
|
||||
if ((strcmp(pref, "align_status") == 0) ||
|
||||
(strcmp(pref, "align_message") == 0)) {
|
||||
if (!strcmp(pref, "align_status")
|
||||
|| !strcmp(pref, "align_message")) {
|
||||
curses_create_main_windows();
|
||||
curses_last_messages();
|
||||
doredraw();
|
||||
|
||||
Reference in New Issue
Block a user