X11 dynamic map mode selection

Prompted by a question from Pat a long time back, this change finally allows
tiles or text map mode to be chosen dynamically at runtime (using the
"tiled_map" option) rather than having to pick it via an X resource and
keep your selection until you exit. This brings map mode selection up to a
level similar to most other graphical window ports.
In addition, the map mode automatically switches to text on the Rogue
level, also like other graphical window ports.
The default mode for the X11 binary is now tiles, once again, like most (all?)
other graphical window ports.
The patch also removes some dead X11 code that is unlikely to be useful again.
This commit is contained in:
cohrs
2003-10-03 02:09:27 +00:00
parent ed8ce13d8f
commit a5c8b517d2
6 changed files with 191 additions and 182 deletions
+18 -22
View File
@@ -102,7 +102,7 @@ static XtSignalId X11_sig_id;
/* Interface definition, for windows.c */
struct window_procs X11_procs = {
"X11",
WC_COLOR|WC_HILITE_PET,
WC_COLOR|WC_HILITE_PET|WC_TILED_MAP,
0L,
X11_init_nhwindows,
X11_player_selection,
@@ -156,7 +156,7 @@ struct window_procs X11_procs = {
#else
genl_outrip,
#endif
genl_preference_update,
X11_preference_update,
};
/*
@@ -248,8 +248,7 @@ XtConvertArgRec const nhcolorConvertArgs[] = {
return False; \
} \
*(type*)(toVal->addr) = (value); \
} \
else { \
} else { \
static type static_val; \
static_val = (value); \
toVal->addr = (genericptr_t)&static_val; \
@@ -258,11 +257,6 @@ XtConvertArgRec const nhcolorConvertArgs[] = {
return True; \
}
/* decl.h declares these, but it screws up structure references -dlc */
#undef red
#undef green
#undef blue
/*
* Find a color that approximates the color named in "str". The "str" color
* may be a color name ("red") or number ("#7f0000"). If str == NULL, then
@@ -952,7 +946,7 @@ static XtResource resources[] = {
{ "double_tile_size", "Double_tile_size", XtRBoolean, sizeof(Boolean),
XtOffset(AppResources *,double_tile_size), XtRString, "False" },
{ "tile_file", "Tile_file", XtRString, sizeof(String),
XtOffset(AppResources *,tile_file), XtRString, "" },
XtOffset(AppResources *,tile_file), XtRString, "x11tiles" },
{ "icon", "Icon", XtRString, sizeof(String),
XtOffset(AppResources *,icon), XtRString, "nh72" },
{ "message_lines", "Message_lines", XtRInt, sizeof(int),
@@ -998,6 +992,9 @@ char** argv;
for (i = 0; i < MAX_WINDOWS; i++)
window_list[i].type = NHW_NONE;
/* add another option that can be set */
set_wc_option_mod_status(WC_TILED_MAP, SET_IN_GAME);
/*
* setuid hack: make sure that if nethack is setuid, to use real uid
* when opening X11 connections, in case the user is using xauth, since
@@ -1751,6 +1748,17 @@ X11_yn_function(ques, choices, def)
return yn_return;
}
/*ARGSUSED*/
void
X11_preference_update(pref)
const char *pref;
{
if (!strcmp(pref, "tiled_map")) {
if (WIN_MAP != WIN_ERR)
display_map_window(&window_list[WIN_MAP]);
}
}
/* End global functions ==================================================== */
/*
@@ -1972,11 +1980,6 @@ init_standard_windows()
XtSetValues(message_viewport, args, ONE);
max_width = status_width;
} else {
/***** The status display looks better when left justified.
XtSetArg(args[0], XtNhorizDistance,
status_hd+((message_vp_width-status_width)/2));
XtSetValues(status, args, ONE);
*****/
max_width = message_vp_width;
}
XtSetArg(args[0], XtNhorizDistance, map_vp_hd+((int)(max_width-map_vp_width)/2));
@@ -1985,13 +1988,6 @@ init_standard_windows()
} else { /* map is widest */
XtSetArg(args[0], XtNwidth, map_vp_width);
XtSetValues(message_viewport, args, ONE);
/***** The status display looks better when left justified.
XtSetArg(args[0], XtNhorizDistance,
status_hd+((map_vp_width-status_width)/2));
XtSetValues(status, args, ONE);
*****/
}
/*
* Clear all data values on the fancy status widget so that the values