Add drawfill item type and clean up item flags
This commit is contained in:
parent
44666c339a
commit
af4cb5573b
3 changed files with 67 additions and 40 deletions
|
|
@ -1886,18 +1886,19 @@ static menuitemflags_t parsestyle(const char *p)
|
|||
|
||||
if STYLE("THIN2", ITF_THIN2)
|
||||
else if STYLE("THIN", ITF_THIN)
|
||||
else if STYLE("HEADER", ITF_HEADER|IT_HIGHLIGHT)
|
||||
else if STYLE("PATCH", IT_PATCH)
|
||||
else if STYLE("MAPTHUMBNAIL", IT_MAPTHUMBNAIL)
|
||||
else if STYLE("HEADER", ITF_HEADER|ITH_HIGHLIGHT)
|
||||
else if STYLE("PATCH", ITF_PATCH)
|
||||
else if STYLE("MAPTHUMBNAIL", ITF_THUMBNAIL)
|
||||
else if STYLE("FILL", ITF_FILL)
|
||||
|
||||
if STYLE("SMALL", IT_SMALL)
|
||||
|
||||
if STYLE("CENTER", IT_CENTER)
|
||||
else if STYLE("RIGHT", IT_RIGHT)
|
||||
|
||||
if STYLE("HIGHLIGHT", IT_HIGHLIGHT)
|
||||
else if STYLE("RECOMMENDEDHIGHLIGHT", IT_RECOMMENDEDHIGHLIGHT)
|
||||
else if STYLE("WARNINGHIGHLIGHT", IT_WARNINGHIGHLIGHT)
|
||||
if STYLE("HIGHLIGHT", ITH_HIGHLIGHT)
|
||||
else if STYLE("RECOMMENDEDHIGHLIGHT", ITH_RECOMMEND)
|
||||
else if STYLE("WARNINGHIGHLIGHT", ITH_WARNING)
|
||||
|
||||
return IT_HIDDEN;
|
||||
#undef STYLE
|
||||
|
|
|
|||
61
src/m_menu.c
61
src/m_menu.c
|
|
@ -2473,7 +2473,7 @@ static void M_DrawRightString(menuitem_t *item, INT16 x, INT16 y, INT32 vflags,
|
|||
(BASEVIDWIDTH - x, y, vflags|highlightflags, name);
|
||||
}
|
||||
else if (item->patch)
|
||||
V_DrawRightAlignedString(BASEVIDWIDTH - x, y, (selected || item->status & IT_HIGHLIGHT ? highlightflags : 0)|vflags, item->patch);
|
||||
V_DrawRightAlignedString(BASEVIDWIDTH - x, y, (selected || (item->status & ITH_MASK) == ITH_HIGHLIGHT ? highlightflags : 0)|vflags, item->patch);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2484,7 +2484,7 @@ static INT32 M_DrawMenuItem(menuitem_t *item, INT16 x, INT16 y, INT32 vflags, bo
|
|||
const char *string = item->text ? item->text : "";
|
||||
fixed_t scale = item->status & IT_SMALL ? FRACUNIT/2 : FRACUNIT;
|
||||
int font;
|
||||
int colorflag;
|
||||
INT32 colorflag;
|
||||
INT32 (*widthfunc)(const char *string, INT32 option);
|
||||
|
||||
if (item->status & IT_SECRET)
|
||||
|
|
@ -2495,13 +2495,45 @@ static INT32 M_DrawMenuItem(menuitem_t *item, INT16 x, INT16 y, INT32 vflags, bo
|
|||
else if (item->status & IT_GRAYEDOUT)
|
||||
vflags |= V_TRANSLUCENT;
|
||||
|
||||
switch (item->status & ITH_MASK)
|
||||
{
|
||||
case ITH_HIGHLIGHT:
|
||||
colorflag = highlightflags; break;
|
||||
case ITH_RECOMMEND:
|
||||
colorflag = recommendedflags; break;
|
||||
case ITH_WARNING:
|
||||
colorflag = warningflags; break;
|
||||
default:
|
||||
colorflag = 0; break;
|
||||
}
|
||||
|
||||
// color a dinosaur?
|
||||
if ((item->status & ITF_MASK) == ITF_FILL)
|
||||
{
|
||||
UINT16 fillw, fillh;
|
||||
UINT8 fillc;
|
||||
// TODO: any form of overflow during conversion is UB apparently??? but I want this damn thing done today
|
||||
if (sscanf(item->patch, "%hux%hu,%hhu", &fillw, &fillh, &fillc) != 3)
|
||||
return 0;
|
||||
|
||||
if (item->status & IT_CENTER)
|
||||
width = fillw/2;
|
||||
else if (item->status & IT_RIGHT)
|
||||
width = fillw;
|
||||
|
||||
V_DrawFill(x - width, y, fillw, fillh, fillc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// draw a patch or map thumbnail instead of a string?
|
||||
if (item->status & IT_PATCH || item->status & IT_MAPTHUMBNAIL)
|
||||
if ((item->status & ITF_MASK) >= ITF_IMAGETYPE)
|
||||
{
|
||||
patch_t *p = NULL;
|
||||
UINT8 *cmap = NULL;
|
||||
|
||||
if (item->status & IT_MAPTHUMBNAIL)
|
||||
switch (item->status & ITF_MASK)
|
||||
{
|
||||
case ITF_THUMBNAIL:
|
||||
{
|
||||
INT32 mapnum = item->argument;
|
||||
|
||||
|
|
@ -2514,13 +2546,16 @@ static INT32 M_DrawMenuItem(menuitem_t *item, INT16 x, INT16 y, INT32 vflags, bo
|
|||
{
|
||||
scale = M_GetMapThumbnail(mapnum, &p)/4;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
case ITF_PATCH:
|
||||
{
|
||||
if (!item->patch)
|
||||
return 0;
|
||||
|
||||
p = W_CachePatchName(item->patch, PU_CACHE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (item->status & IT_CENTER)
|
||||
|
|
@ -2528,12 +2563,7 @@ static INT32 M_DrawMenuItem(menuitem_t *item, INT16 x, INT16 y, INT32 vflags, bo
|
|||
else if (item->status & IT_RIGHT)
|
||||
width = SHORT(p->width);
|
||||
|
||||
if (item->status & IT_HIGHLIGHT)
|
||||
cmap = V_GetStringColormap(highlightflags);
|
||||
else if (item->status & IT_RECOMMENDEDHIGHLIGHT)
|
||||
cmap = V_GetStringColormap(recommendedflags);
|
||||
else if (item->status & IT_WARNINGHIGHLIGHT)
|
||||
cmap = V_GetStringColormap(warningflags);
|
||||
cmap = V_GetStringColormap(colorflag);
|
||||
|
||||
V_DrawFixedPatch((x - width)<<FRACBITS, y<<FRACBITS, scale, vflags & ~V_FLIP, p, cmap);
|
||||
return width;
|
||||
|
|
@ -2561,15 +2591,6 @@ static INT32 M_DrawMenuItem(menuitem_t *item, INT16 x, INT16 y, INT32 vflags, bo
|
|||
else if (item->status & IT_RIGHT)
|
||||
width = widthfunc(string, vflags);
|
||||
|
||||
if (item->status & IT_HIGHLIGHT)
|
||||
colorflag = highlightflags;
|
||||
else if (item->status & IT_RECOMMENDEDHIGHLIGHT)
|
||||
colorflag = recommendedflags;
|
||||
else if (item->status & IT_WARNINGHIGHLIGHT)
|
||||
colorflag = warningflags;
|
||||
else
|
||||
colorflag = 0;
|
||||
|
||||
V_DrawStringScaled((x - width)<<FRACBITS, y<<FRACBITS, scale, FRACUNIT, FRACUNIT, (selected ? highlightflags : colorflag)|vflags, font, string);
|
||||
|
||||
if (!(item->status & (IT_SECRET|IT_GRAYEDOUT)))
|
||||
|
|
|
|||
33
src/m_menu.h
33
src/m_menu.h
|
|
@ -135,22 +135,27 @@ typedef enum
|
|||
IT_TEMPORARY = 1<<8, // with IT_OFS*, offset applies only to this item
|
||||
IT_OVERLAY = 1<<9, // item is drawn at absolute coordinates, without scrolling
|
||||
|
||||
IT_PATCH = 1<<10, // display a patch instead of text
|
||||
IT_CENTER = 1<<11, // center the text/patch
|
||||
IT_RIGHT = 1<<12, // right-align the text/patch
|
||||
IT_SMALL = 1<<13, // draw at half scale
|
||||
IT_HIGHLIGHT = 1<<14, // add highlightflags to text/patch
|
||||
IT_RECOMMENDEDHIGHLIGHT = 1<<15, // add recommendedflags to text/patch
|
||||
IT_WARNINGHIGHLIGHT = 1<<16, // add warningflags to text/patch
|
||||
IT_MAPTHUMBNAIL = 1<<17, // display a mapthumbnail instead of text
|
||||
IT_CENTER = 1<<10, // center the text/patch
|
||||
IT_RIGHT = 1<<11, // right-align the text/patch
|
||||
IT_SMALL = 1<<12, // draw at half scale
|
||||
|
||||
ITF_STANDARD = 0<<18, // standard font
|
||||
ITF_HEADER = 1<<18, // standard font, with an offset to the left
|
||||
ITF_THIN = 2<<18, // thin font
|
||||
ITF_THIN2 = 3<<18, // thin font with tighter spacing
|
||||
ITH_NONE = 0<<13, // no highlight
|
||||
ITH_HIGHLIGHT = 1<<13, // add highlightflags to text/patch
|
||||
ITH_RECOMMEND = 2<<13, // add recommendedflags to text/patch
|
||||
ITH_WARNING = 3<<13, // add warningflags to text/patch
|
||||
ITH_MASK = 0x3<<13,
|
||||
|
||||
ITF_MASK = 3<<18,
|
||||
IT_STYLE = IT_PATCH|IT_CENTER|IT_RIGHT|IT_SMALL|IT_HIGHLIGHT|ITF_MASK,
|
||||
ITF_STANDARD = 0<<15, // standard font
|
||||
ITF_HEADER = 1<<15, // standard font, with an offset to the left
|
||||
ITF_THIN = 2<<15, // thin font
|
||||
ITF_THIN2 = 3<<15, // thin font with tighter spacing
|
||||
ITF_FILL = 4<<15, // call drawfill using parameters in item->patch
|
||||
ITF_PATCH = 5<<15, // display a patch instead of text
|
||||
ITF_THUMBNAIL = 6<<15, // display the thumbnail of the mapname in item->patch
|
||||
ITF_IMAGETYPE = ITF_PATCH,
|
||||
ITF_MASK = 0x7<<15,
|
||||
|
||||
IT_STYLE = IT_CENTER|IT_RIGHT|IT_SMALL|ITH_MASK|ITF_MASK,
|
||||
} menuitemflags_t;
|
||||
|
||||
#define MAXSTRINGLENGTH 32
|
||||
|
|
|
|||
Loading…
Reference in a new issue