Amiga: restore glyph icons in menus

Core changes routed transient inventory away from WIN_INVEN, so the
port's win == WIN_INVEN gate stopped matching and glyphs vanished.
Track has_glyphs on the menu and key rendering and sizing off that.
This commit is contained in:
Ingo Paschke
2026-05-09 17:11:33 +02:00
parent ed4d100459
commit c1ae9d5d8c
3 changed files with 46 additions and 81 deletions
+1
View File
@@ -32,6 +32,7 @@ struct amii_menu {
const char *query; /* Query string */ const char *query; /* Query string */
int count; /* Number of strings. */ int count; /* Number of strings. */
char chr; /* Character to assign for accelerator */ char chr; /* Character to assign for accelerator */
boolean has_glyphs; /* Any item carries a real glyph (AMIV) */
}; };
/* descriptor for Amiga Intuition-based windows. If we decide to cope with /* descriptor for Amiga Intuition-based windows. If we decide to cope with
+39 -70
View File
@@ -47,6 +47,7 @@ amii_start_menu(winid window, unsigned long mbehavior UNUSED)
cw->menu.items = 0; cw->menu.items = 0;
cw->menu.count = 0; cw->menu.count = 0;
cw->menu.chr = 'a'; cw->menu.chr = 'a';
cw->menu.has_glyphs = FALSE;
if (cw->morestr) if (cw->morestr)
free(cw->morestr); free(cw->morestr);
@@ -85,6 +86,8 @@ amii_add_menu(winid window, const glyph_info *glyphinfo, const anything *id,
mip->attr = attr; mip->attr = attr;
mip->color = clr; mip->color = clr;
mip->glyph = Is_rogue_level(&u.uz) ? NO_GLYPH : (glyphinfo ? glyphinfo->glyph : NO_GLYPH); mip->glyph = Is_rogue_level(&u.uz) ? NO_GLYPH : (glyphinfo ? glyphinfo->glyph : NO_GLYPH);
if (mip->glyph != NO_GLYPH)
cw->menu.has_glyphs = TRUE;
mip->selector = 0; mip->selector = 0;
mip->gselector = gch; mip->gselector = gch;
mip->count = -1; mip->count = -1;
@@ -255,12 +258,9 @@ DoMenuScroll(int win, int blocking, int how, menu_item **retmip)
/* Initial guess at window sizing values */ /* Initial guess at window sizing values */
txwd = txwidth; txwd = txwidth;
if (WINVERS_AMIV) { if (WINVERS_AMIV && cw->menu.has_glyphs)
if (win == WIN_INVEN) txh = max(txheight, pictdata.ysize + 3); /* interline space */
txh = max(txheight, pictdata.ysize + 3); /* interline space */ else
else
txh = txheight; /* interline space */
} else
txh = txheight; /* interline space */ txh = txheight; /* interline space */
/* Check to see if we should open the window, should need to for /* Check to see if we should open the window, should need to for
@@ -280,10 +280,8 @@ DoMenuScroll(int win, int blocking, int how, menu_item **retmip)
if (!alwaysinvent || win != WIN_INVEN) { if (!alwaysinvent || win != WIN_INVEN) {
xsize = scrn->WBorLeft + scrn->WBorRight + MenuScroll.Width + 1 xsize = scrn->WBorLeft + scrn->WBorRight + MenuScroll.Width + 1
+ (txwd * cw->maxcol); + (txwd * cw->maxcol);
if (WINVERS_AMIV) { if (WINVERS_AMIV && cw->menu.has_glyphs)
if (win == WIN_INVEN) xsize += pictdata.xsize + 4;
xsize += pictdata.xsize + 4;
}
if (xsize > amiIDisplay->xpix) if (xsize > amiIDisplay->xpix)
xsize = amiIDisplay->xpix; xsize = amiIDisplay->xpix;
@@ -322,7 +320,7 @@ DoMenuScroll(int win, int blocking, int how, menu_item **retmip)
/* Make space for the glyph to appear at the left of the /* Make space for the glyph to appear at the left of the
* description */ * description */
if (WINVERS_AMIV) if (WINVERS_AMIV && cw->menu.has_glyphs)
xsize += pictdata.xsize + 4; xsize += pictdata.xsize + 4;
if (xsize > amiIDisplay->xpix) if (xsize > amiIDisplay->xpix)
@@ -394,52 +392,36 @@ DoMenuScroll(int win, int blocking, int how, menu_item **retmip)
SetFont(w->RPort, HackFont); SetFont(w->RPort, HackFont);
#endif #endif
txwd = w->RPort->TxWidth; txwd = w->RPort->TxWidth;
if (WINVERS_AMIV) { if (WINVERS_AMIV && cw->menu.has_glyphs)
if (win == WIN_INVEN) txh = max(w->RPort->TxHeight,
txh = max(w->RPort->TxHeight, pictdata.ysize + 3); /* interline space */
pictdata.ysize + 3); /* interline space */ else
else
txh = w->RPort->TxHeight; /* interline space */
} else
txh = w->RPort->TxHeight; /* interline space */ txh = w->RPort->TxHeight; /* interline space */
/* subtract 2 to account for spacing away from border (1 on each side) /* subtract 2 to account for spacing away from border (1 on each side)
*/ */
wheight = (w->Height - w->BorderTop - w->BorderBottom - 2) / txh; wheight = (w->Height - w->BorderTop - w->BorderBottom - 2) / txh;
if (WINVERS_AMIV) { if (WINVERS_AMIV && cw->menu.has_glyphs) {
if (win == WIN_INVEN) { cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4
cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4 - pictdata.xsize - 3) / txwd;
- pictdata.xsize - 3) / txwd;
} else {
cw->cols =
(w->Width - w->BorderLeft - w->BorderRight - 4) / txwd;
}
} else { } else {
cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4) / txwd; cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4) / txwd;
} }
totalvis = CountLines(win); totalvis = CountLines(win);
} else { } else {
txwd = w->RPort->TxWidth; txwd = w->RPort->TxWidth;
if (WINVERS_AMIV) { if (WINVERS_AMIV && cw->menu.has_glyphs)
if (win == WIN_INVEN) txh = max(w->RPort->TxHeight,
txh = max(w->RPort->TxHeight, pictdata.ysize + 3); /* interline space */
pictdata.ysize + 3); /* interline space */ else
else
txh = w->RPort->TxHeight; /* interline space */
} else {
txh = w->RPort->TxHeight; /* interline space */ txh = w->RPort->TxHeight; /* interline space */
}
/* subtract 2 to account for spacing away from border (1 on each side) /* subtract 2 to account for spacing away from border (1 on each side)
*/ */
wheight = (w->Height - w->BorderTop - w->BorderBottom - 2) / txh; wheight = (w->Height - w->BorderTop - w->BorderBottom - 2) / txh;
if (WINVERS_AMIV) { if (WINVERS_AMIV && cw->menu.has_glyphs) {
if (win == WIN_INVEN) { cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4
cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4 - pictdata.xsize - 3) / txwd;
- pictdata.xsize - 3) / txwd;
} else
cw->cols =
(w->Width - w->BorderLeft - w->BorderRight - 4) / txwd;
} else { } else {
cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4) / txwd; cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4) / txwd;
} }
@@ -551,13 +533,9 @@ DoMenuScroll(int win, int blocking, int how, menu_item **retmip)
totalvis = CountLines(win); totalvis = CountLines(win);
wheight = wheight =
(w->Height - w->BorderTop - w->BorderBottom - 2) / txh; (w->Height - w->BorderTop - w->BorderBottom - 2) / txh;
if (WINVERS_AMIV) { if (WINVERS_AMIV && cw->menu.has_glyphs) {
if (win == WIN_INVEN) { cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4
cw->cols = (w->Width - w->BorderLeft - w->BorderRight - pictdata.xsize - 3) / txwd;
- 4 - pictdata.xsize - 3) / txwd;
} else
cw->cols = (w->Width - w->BorderLeft - w->BorderRight
- 4) / txwd;
} else { } else {
cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4) cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4)
/ txwd; / txwd;
@@ -1126,12 +1104,9 @@ FindLine(winid win, int line)
panic(winpanicstr, win, "No Window in FindLine"); panic(winpanicstr, win, "No Window in FindLine");
} }
txwd = w->RPort->TxWidth; txwd = w->RPort->TxWidth;
if (WINVERS_AMIV) { if (WINVERS_AMIV && cw->menu.has_glyphs) {
if (win == WIN_INVEN) { cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4
cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4 - pictdata.xsize - 3) / txwd;
- pictdata.xsize - 3) / txwd;
} else
cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4) / txwd;
} else { } else {
cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4) / txwd; cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4) / txwd;
} }
@@ -1189,12 +1164,9 @@ CountLines(winid win)
} }
txwd = w->RPort->TxWidth; txwd = w->RPort->TxWidth;
if (WINVERS_AMIV) { if (WINVERS_AMIV && cw->menu.has_glyphs) {
if (win == WIN_INVEN) { cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4
cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4 - pictdata.xsize - 3) / txwd;
- pictdata.xsize - 3) / txwd;
} else
cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4) / txwd;
} else { } else {
cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4) / txwd; cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4) / txwd;
} }
@@ -1255,7 +1227,7 @@ DisplayData(winid win, int start)
rp = w->RPort; rp = w->RPort;
SetDrMd(rp, JAM2); SetDrMd(rp, JAM2);
if (WINVERS_AMIV && win == WIN_INVEN) { if (WINVERS_AMIV && cw->menu.has_glyphs) {
wheight = (w->Height - w->BorderTop - w->BorderBottom - 2) wheight = (w->Height - w->BorderTop - w->BorderBottom - 2)
/ max(rp->TxHeight, pictdata.ysize + 3); / max(rp->TxHeight, pictdata.ysize + 3);
} else { } else {
@@ -1265,12 +1237,9 @@ DisplayData(winid win, int start)
cw->rows = wheight; cw->rows = wheight;
txwd = rp->TxWidth; txwd = rp->TxWidth;
if (WINVERS_AMIV) { if (WINVERS_AMIV && cw->menu.has_glyphs) {
if (win == WIN_INVEN) { cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4
cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4 - pictdata.xsize - 3) / txwd;
- pictdata.xsize - 3) / txwd;
} else
cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4) / txwd;
} else { } else {
cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4) / txwd; cw->cols = (w->Width - w->BorderLeft - w->BorderRight - 4) / txwd;
} }
@@ -1292,7 +1261,7 @@ DisplayData(winid win, int start)
for (disprow = i = start; disprow < wheight + start; i++) { for (disprow = i = start; disprow < wheight + start; i++) {
/* Just erase unused lines in the window */ /* Just erase unused lines in the window */
if (i >= cw->maxrow) { if (i >= cw->maxrow) {
if (WINVERS_AMIV && win == WIN_INVEN) { if (WINVERS_AMIV && cw->menu.has_glyphs) {
amii_curs(win, 0, disprow - start); amii_curs(win, 0, disprow - start);
amiga_print_glyph(win, 0, NO_GLYPH); amiga_print_glyph(win, 0, NO_GLYPH);
} }
@@ -1312,7 +1281,7 @@ DisplayData(winid win, int start)
* current line */ * current line */
if (cw->type != NHW_MESSAGE || cw->data[i][SEL_ITEM] >= 0) { if (cw->type != NHW_MESSAGE || cw->data[i][SEL_ITEM] >= 0) {
amii_curs(win, 1, disprow - start); amii_curs(win, 1, disprow - start);
if (WINVERS_AMIV && win == WIN_INVEN) { if (WINVERS_AMIV && cw->menu.has_glyphs) {
if (mip) if (mip)
amiga_print_glyph(win, 0, mip->glyph); amiga_print_glyph(win, 0, mip->glyph);
amii_curs(win, 1, disprow - start); amii_curs(win, 1, disprow - start);
@@ -1389,7 +1358,7 @@ DisplayData(winid win, int start)
while (*t == ' ') while (*t == ' ')
++t; ++t;
amii_curs(win, 1, disprow - start - 1); amii_curs(win, 1, disprow - start - 1);
if (mip && win == WIN_INVEN && WINVERS_AMIV) { if (mip && WINVERS_AMIV && cw->menu.has_glyphs) {
/* Erase any previous glyph drawn here. */ /* Erase any previous glyph drawn here. */
amiga_print_glyph(win, 0, NO_GLYPH); amiga_print_glyph(win, 0, NO_GLYPH);
amii_curs(win, 1, disprow - start - 1); amii_curs(win, 1, disprow - start - 1);
+6 -11
View File
@@ -1695,17 +1695,12 @@ amii_curs(winid window, int x, int y)
rp = w->RPort; rp = w->RPort;
if (cw->type == NHW_MENU) { if (cw->type == NHW_MENU) {
if (WINVERS_AMIV) { if (WINVERS_AMIV && cw->menu.has_glyphs) {
if (window == WIN_INVEN) { Move(rp, (x * rp->TxWidth) + w->BorderLeft + 1
Move(rp, (x * rp->TxWidth) + w->BorderLeft + 1 + pictdata.xsize + 4,
+ pictdata.xsize + 4, (y * max(rp->TxHeight, pictdata.ysize + 3))
(y * max(rp->TxHeight, pictdata.ysize + 3)) + rp->TxBaseline + pictdata.ysize - rp->TxHeight
+ rp->TxBaseline + pictdata.ysize - rp->TxHeight + w->BorderTop + 4);
+ w->BorderTop + 4);
} else {
Move(rp, (x * rp->TxWidth) + w->BorderLeft + 1,
(y * rp->TxHeight) + rp->TxBaseline + w->BorderTop + 1);
}
} else { } else {
Move(rp, (x * rp->TxWidth) + w->BorderLeft + 1, Move(rp, (x * rp->TxWidth) + w->BorderLeft + 1,
(y * rp->TxHeight) + rp->TxBaseline + w->BorderTop + 1); (y * rp->TxHeight) + rp->TxBaseline + w->BorderTop + 1);