Factor some menu code.

git-svn-id: https://svn.eduke32.com/eduke32@6200 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2017-06-19 23:06:45 +00:00
parent 57b5a47b9d
commit 9abe8f7958
2 changed files with 8 additions and 10 deletions

View file

@ -3984,7 +3984,7 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current
++numvalidentries;
// assumes height == font->get_yline()!
totalheight += entry->type == Spacer ? entry->getSpacerHeight() : entry->font->get_yline();
totalheight += entry->getHeight();
}
calculatedentryspacing = (klabs(menu->format->bottomcutoff) - menu->format->pos.y - totalheight) / (numvalidentries > 1 ? numvalidentries - 1 : 1);
@ -3998,7 +3998,7 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current
if (entry == NULL)
continue;
int32_t const height = entry->type == Spacer ? entry->getSpacerHeight() : entry->font->get_yline();
int32_t const height = entry->getHeight();
y += height;
totalHeight = y;
@ -4021,15 +4021,13 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current
for (e = 0; e < menu->numEntries; ++e)
{
MenuEntry_t *entry = menu->entrylist[e];
uint8_t status = 0;
int32_t height, x;
vec2_t textsize;
if (entry == NULL)
continue;
x = menu->format->pos.x + entry->getIndent();
int32_t x = menu->format->pos.x + entry->getIndent();
uint8_t status = 0;
if (e == menu->currentEntry)
status |= MT_Selected;
if (entry->flags & Disabled)
@ -4039,10 +4037,11 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current
const int32_t dodraw = entry->type != Spacer && 0 <= y - menu->scrollPos + entry->font->get_yline() && y - menu->scrollPos <= klabs(menu->format->bottomcutoff) - menu->format->pos.y;
vec2_t textsize;
if (dodraw)
textsize = Menu_Text(origin.x + x, origin.y + y_upper + y - menu->scrollPos, entry->font, entry->name, status, ydim_upper, ydim_lower);
height = entry->type == Spacer ? entry->getSpacerHeight() : entry->font->get_yline(); // max(textsize.y, entry->font->get_yline()); // bluefont Q ruins this
int32_t const height = entry->getHeight(); // max(textsize.y, entry->font->get_yline()); // bluefont Q ruins this
if (entry->format->width < 0)
status |= MT_XRight;

View file

@ -324,10 +324,9 @@ typedef struct MenuEntry_t
int32_t getMarginBottom() const { return scale(format->marginBottom, font->zoom, 65536); }
int32_t getIndent() const { return scale(format->indent, font->zoom, 65536); }
int32_t getSpacerHeight() const
int32_t getHeight() const
{
Bassert(type == Spacer);
return scale(((MenuSpacer_t *)entry)->height, font->zoom, 65536);
return type == Spacer ? scale(((MenuSpacer_t *)entry)->height, font->zoom, 65536) : font->get_yline();
}
} MenuEntry_t;