more window port interface adjustments
further adjustments to the window port interface to pass a pointer to a glyph_info struct which describes not just the glyph number itself, but also the ttychar, the color, the glyphflags, and the symset index. This affects two existing window port calls that get passed glyphs and does the parameter consistently for both of them using the glyph_info struct pointer: print_glyph() add_menu(). The recently added glyphmod parameter is now unnecessary and has been removed.
This commit is contained in:
+9
-11
@@ -58,7 +58,7 @@ int func(CHAR_P arg) { ... }
|
||||
|
||||
typedef struct nhmi {
|
||||
winid wid; /* NetHack window id */
|
||||
int glyph; /* Menu glyphs */
|
||||
glyph_info glyphinfo; /* holds menu glyph and additional glyph info */
|
||||
anything identifier; /* Value returned if item selected */
|
||||
CHAR_P accelerator; /* Character used to select item from menu */
|
||||
CHAR_P group_accel; /* Group accelerator for menu item, if any */
|
||||
@@ -582,7 +582,7 @@ curs_new_menu_item(winid wid, const char *str)
|
||||
curses_rtrim(new_str);
|
||||
new_item = (nhmenu_item *) alloc((unsigned) sizeof (nhmenu_item));
|
||||
new_item->wid = wid;
|
||||
new_item->glyph = NO_GLYPH;
|
||||
new_item->glyphinfo = nul_glyphinfo;
|
||||
new_item->identifier = cg.zeroany;
|
||||
new_item->accelerator = '\0';
|
||||
new_item->group_accel = '\0';
|
||||
@@ -601,8 +601,9 @@ curs_new_menu_item(winid wid, const char *str)
|
||||
/* Add a menu item to the given menu window */
|
||||
|
||||
void
|
||||
curses_add_nhmenu_item(winid wid, int glyph, const ANY_P *identifier,
|
||||
CHAR_P accelerator, CHAR_P group_accel, int attr,
|
||||
curses_add_nhmenu_item(winid wid, const glyph_info *glyphinfo,
|
||||
const ANY_P *identifier, CHAR_P accelerator,
|
||||
CHAR_P group_accel, int attr,
|
||||
const char *str, unsigned itemflags)
|
||||
{
|
||||
nhmenu_item *new_item, *current_items, *menu_item_ptr;
|
||||
@@ -620,7 +621,8 @@ curses_add_nhmenu_item(winid wid, int glyph, const ANY_P *identifier,
|
||||
}
|
||||
|
||||
new_item = curs_new_menu_item(wid, str);
|
||||
new_item->glyph = glyph;
|
||||
if (glyphinfo)
|
||||
new_item->glyphinfo = *glyphinfo;
|
||||
new_item->identifier = *identifier;
|
||||
new_item->accelerator = accelerator;
|
||||
new_item->group_accel = group_accel;
|
||||
@@ -1179,12 +1181,8 @@ menu_display_page(nhmenu *menu, WINDOW * win, int page_num, char *selectors)
|
||||
}
|
||||
#if 0
|
||||
/* FIXME: menuglyphs not implemented yet */
|
||||
if (menu_item_ptr->glyph != NO_GLYPH && iflags.use_menu_glyphs) {
|
||||
unsigned glyphmod[NUM_GLYPHMOD];
|
||||
|
||||
map_glyphmod(0, 0, menu_item_ptr->glyph, 0U, glyphmod);
|
||||
color = (int) glyphmod[GM_COLOR];
|
||||
|
||||
if (menu_item_ptr->glyphinfo.glyph != NO_GLYPH && iflags.use_menu_glyphs) {
|
||||
color = (int) menu_item_ptr->glyphinfo.color;
|
||||
curses_toggle_color_attr(win, color, NONE, ON);
|
||||
mvwaddch(win, menu_item_ptr->line_num + 1, start_col, curletter);
|
||||
curses_toggle_color_attr(win, color, NONE, OFF);
|
||||
|
||||
@@ -13,8 +13,9 @@ int curses_character_input_dialog(const char *prompt, const char *choices,
|
||||
CHAR_P def);
|
||||
int curses_ext_cmd(void);
|
||||
void curses_create_nhmenu(winid wid, unsigned long);
|
||||
void curses_add_nhmenu_item(winid wid, int glyph, const ANY_P *identifier,
|
||||
CHAR_P accelerator, CHAR_P group_accel, int attr,
|
||||
void curses_add_nhmenu_item(winid wid, const glyph_info *glyphinfo,
|
||||
const ANY_P *identifier, CHAR_P accelerator,
|
||||
CHAR_P group_accel, int attr,
|
||||
const char *str, unsigned itemflags);
|
||||
void curs_menu_set_bottom_heavy(winid);
|
||||
void curses_finalize_nhmenu(winid wid, const char *prompt);
|
||||
|
||||
@@ -742,20 +742,20 @@ curses_character_dialog(const char **choices, const char *prompt)
|
||||
}
|
||||
|
||||
identifier.a_int = (count + 1); /* Must be non-zero */
|
||||
curses_add_menu(wid, NO_GLYPH, &identifier, curletter, 0,
|
||||
curses_add_menu(wid, &nul_glyphinfo, &identifier, curletter, 0,
|
||||
A_NORMAL, choices[count], MENU_ITEMFLAGS_NONE);
|
||||
used_letters[count] = curletter;
|
||||
}
|
||||
|
||||
/* Random Selection */
|
||||
identifier.a_int = ROLE_RANDOM;
|
||||
curses_add_menu(wid, NO_GLYPH, &identifier, '*', 0, A_NORMAL, "Random",
|
||||
MENU_ITEMFLAGS_NONE);
|
||||
curses_add_menu(wid, &nul_glyphinfo, &identifier, '*', 0,
|
||||
A_NORMAL, "Random", MENU_ITEMFLAGS_NONE);
|
||||
|
||||
/* Quit prompt */
|
||||
identifier.a_int = ROLE_NONE;
|
||||
curses_add_menu(wid, NO_GLYPH, &identifier, 'q', 0, A_NORMAL, "Quit",
|
||||
MENU_ITEMFLAGS_NONE);
|
||||
curses_add_menu(wid, &nul_glyphinfo, &identifier, 'q', 0,
|
||||
A_NORMAL, "Quit", MENU_ITEMFLAGS_NONE);
|
||||
curses_end_menu(wid, prompt);
|
||||
ret = curses_select_menu(wid, PICK_ONE, &selected);
|
||||
if (ret == 1) {
|
||||
|
||||
@@ -55,9 +55,8 @@ curses_update_inv(void)
|
||||
|
||||
/* Adds an inventory item. 'y' is 1 rather than 0 for the first item. */
|
||||
void
|
||||
curses_add_inv(int y,
|
||||
int glyph UNUSED,
|
||||
CHAR_P accelerator, attr_t attr, const char *str)
|
||||
curses_add_inv(int y, const glyph_info *glyphinfo UNUSED, CHAR_P accelerator,
|
||||
attr_t attr, const char *str)
|
||||
{
|
||||
WINDOW *win = curses_get_nhwin(INV_WIN);
|
||||
int color = NO_COLOR;
|
||||
@@ -120,13 +119,11 @@ curses_add_inv(int y,
|
||||
}
|
||||
#if 0 /* FIXME: MENU GLYPHS */
|
||||
if (accelerator && glyph != NO_GLYPH && iflags.use_menu_glyphs) {
|
||||
unsigned glyphmod[NUM_GLYPHMOD];
|
||||
int symbol;
|
||||
attr_t glyphclr;
|
||||
|
||||
map_glyphmod(0, 0, glyph, 0U, glyphmod);
|
||||
symbol = (int) glyphmod[GM_TTYCHAR];
|
||||
color = (int) glyphmod[GM_COLOR];
|
||||
symbol = glyphinfo->ttychar;
|
||||
color = glyphinfo->color;
|
||||
|
||||
glyphclr = curses_color_attr(color, 0);
|
||||
wattron(win, glyphclr);
|
||||
|
||||
+36
-18
@@ -524,7 +524,8 @@ curses_start_menu(winid wid, unsigned long mbehavior)
|
||||
}
|
||||
|
||||
/*
|
||||
add_menu(winid wid, int glyph, const anything identifier,
|
||||
add_menu(winid wid, const glyph_info *glyphinfo,
|
||||
const anything identifier,
|
||||
char accelerator, char groupacc,
|
||||
int attr, char *str, unsigned int itemflags)
|
||||
-- Add a text line str to the given menu window. If identifier
|
||||
@@ -536,7 +537,8 @@ add_menu(winid wid, int glyph, const anything identifier,
|
||||
accelerator. It is up to the window-port to make the
|
||||
accelerator visible to the user (e.g. put "a - " in front
|
||||
of str). The value attr is the same as in putstr().
|
||||
Glyph is an optional glyph to accompany the line. If
|
||||
-- Glyph is an optional glyph to accompany the line and its
|
||||
modifiers (if any) can be found in glyphinfo. If
|
||||
window port cannot or does not want to display it, this
|
||||
is OK. If there is no glyph applicable, then this
|
||||
value will be NO_GLYPH.
|
||||
@@ -555,7 +557,8 @@ add_menu(winid wid, int glyph, const anything identifier,
|
||||
menu is displayed, set bit MENU_ITEMFLAGS_SELECTED.
|
||||
*/
|
||||
void
|
||||
curses_add_menu(winid wid, int glyph, const ANY_P * identifier,
|
||||
curses_add_menu(winid wid, const glyph_info *glyphinfo,
|
||||
const ANY_P * identifier,
|
||||
CHAR_P accelerator, CHAR_P group_accel, int attr,
|
||||
const char *str, unsigned itemflags)
|
||||
{
|
||||
@@ -565,12 +568,12 @@ curses_add_menu(winid wid, int glyph, const ANY_P * identifier,
|
||||
curses_attr = curses_convert_attr(attr);
|
||||
|
||||
if (inv_update) {
|
||||
curses_add_inv(inv_update, glyph, accelerator, curses_attr, str);
|
||||
curses_add_inv(inv_update, glyphinfo, accelerator, curses_attr, str);
|
||||
inv_update++;
|
||||
return;
|
||||
}
|
||||
|
||||
curses_add_nhmenu_item(wid, glyph, identifier, accelerator, group_accel,
|
||||
curses_add_nhmenu_item(wid, glyphinfo, identifier, accelerator, group_accel,
|
||||
curses_attr, str, itemflags);
|
||||
}
|
||||
|
||||
@@ -686,30 +689,45 @@ curses_cliparound(int x, int y)
|
||||
}
|
||||
|
||||
/*
|
||||
print_glyph(window, x, y, glyph, bkglyph, glyphmod)
|
||||
-- Print the glyph at (x,y) on the given window. Glyphs are
|
||||
integers at the interface, mapped to whatever the window-
|
||||
print_glyph(window, x, y, glyphinfo, bkglyphinfo)
|
||||
-- Print glyph at (x,y) on the given window. Glyphs are
|
||||
integers within the glyph_info struct that is passed
|
||||
at the interface, mapped to whatever the window-
|
||||
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.
|
||||
bkglyphinfo is to render the background behind the glyph.
|
||||
It's not used here.
|
||||
-- glyphmod (glyphmod[NUM_GLYPHNOD]) provides extended
|
||||
information about the glyph that window ports can use to
|
||||
enhance the display in various ways.
|
||||
-- bkglyphinfo contains a background glyph for potential use
|
||||
by some graphical or tiled environments to allow the depiction
|
||||
to fall against a background consistent with the grid
|
||||
around x,y. If bkglyphinfo->glyph is NO_GLYPH, then the
|
||||
parameter should be ignored (do nothing with it).
|
||||
-- glyph_info struct fields:
|
||||
int glyph; the display entity
|
||||
int color; color for window ports not using a tile
|
||||
int ttychar; the character mapping for the original tty
|
||||
interace. Most or all window ports wanted
|
||||
and used this for various things so it is
|
||||
provided in 3.7+
|
||||
short int symidx; offset into syms array
|
||||
unsigned glyphflags; more detail about the entity
|
||||
|
||||
*/
|
||||
|
||||
void
|
||||
curses_print_glyph(winid wid, XCHAR_P x, XCHAR_P y, int glyph,
|
||||
int bkglyph UNUSED, unsigned *glyphmod)
|
||||
curses_print_glyph(winid wid, XCHAR_P x, XCHAR_P y,
|
||||
const glyph_info *glyphinfo, const glyph_info *bkglyphinfo UNUSED)
|
||||
{
|
||||
int glyph;
|
||||
int ch;
|
||||
int color;
|
||||
unsigned int special;
|
||||
int attr = -1;
|
||||
|
||||
special = glyphmod[GM_FLAGS];
|
||||
ch = (int) glyphmod[GM_TTYCHAR];
|
||||
color = (int) glyphmod[GM_COLOR];
|
||||
glyph = glyphinfo->glyph;
|
||||
special = glyphinfo->glyphflags;
|
||||
ch = glyphinfo->ttychar;
|
||||
color = glyphinfo->color;
|
||||
if ((special & MG_PET) && iflags.hilite_pet) {
|
||||
attr = iflags.wc2_petattr;
|
||||
}
|
||||
@@ -734,7 +752,7 @@ curses_print_glyph(winid wid, XCHAR_P x, XCHAR_P y, int glyph,
|
||||
/* water and lava look the same except for color; when color is off,
|
||||
render lava in inverse video so that they look different */
|
||||
if ((special & (MG_BW_LAVA | MG_BW_ICE)) != 0 && iflags.use_inverse) {
|
||||
attr = A_REVERSE; /* map_glyphmod() only sets this if color is off */
|
||||
attr = A_REVERSE; /* map_glyphinfo() only sets this if color is off */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -373,16 +373,16 @@ curses_prev_mesg()
|
||||
for (count = 0; count < num_messages; ++count) {
|
||||
mesg = get_msg_line(do_lifo, count);
|
||||
if (turn != mesg->turn && count != 0) {
|
||||
curses_add_menu(wid, NO_GLYPH, &Id, 0, 0, A_NORMAL, "---",
|
||||
MENU_ITEMFLAGS_NONE);
|
||||
curses_add_menu(wid, &nul_glyphinfo, &Id, 0, 0,
|
||||
A_NORMAL, "---", MENU_ITEMFLAGS_NONE);
|
||||
}
|
||||
curses_add_menu(wid, NO_GLYPH, &Id, 0, 0, A_NORMAL, mesg->str,
|
||||
MENU_ITEMFLAGS_NONE);
|
||||
curses_add_menu(wid, &nul_glyphinfo, &Id, 0, 0,
|
||||
A_NORMAL, mesg->str, MENU_ITEMFLAGS_NONE);
|
||||
turn = mesg->turn;
|
||||
}
|
||||
if (!count)
|
||||
curses_add_menu(wid, NO_GLYPH, &Id, 0, 0, A_NORMAL,
|
||||
"[No past messages available.]",
|
||||
curses_add_menu(wid, &nul_glyphinfo, &Id, 0, 0,
|
||||
A_NORMAL, "[No past messages available.]",
|
||||
MENU_ITEMFLAGS_NONE);
|
||||
|
||||
curses_end_menu(wid, "");
|
||||
|
||||
@@ -675,7 +675,8 @@ curses_view_file(const char *filename, boolean must_exist)
|
||||
Id = cg.zeroany;
|
||||
|
||||
while (dlb_fgets(buf, BUFSZ, fp) != NULL) {
|
||||
curses_add_menu(wid, NO_GLYPH, &Id, 0, 0, A_NORMAL, buf, FALSE);
|
||||
curses_add_menu(wid, &nul_glyphinfo, &Id, 0, 0,
|
||||
A_NORMAL, buf, FALSE);
|
||||
}
|
||||
|
||||
dlb_fclose(fp);
|
||||
|
||||
@@ -509,8 +509,8 @@ curses_puts(winid wid, int attr, const char *text)
|
||||
return;
|
||||
}
|
||||
Id = cg.zeroany;
|
||||
curses_add_nhmenu_item(wid, NO_GLYPH, &Id, 0, 0, attr, text,
|
||||
MENU_ITEMFLAGS_NONE);
|
||||
curses_add_nhmenu_item(wid, &nul_glyphinfo, &Id, 0, 0,
|
||||
attr, text, MENU_ITEMFLAGS_NONE);
|
||||
} else {
|
||||
waddstr(win, text);
|
||||
wnoutrefresh(win);
|
||||
|
||||
Reference in New Issue
Block a user