mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 19:20:46 +00:00
Factor some menu code.
git-svn-id: https://svn.eduke32.com/eduke32@6200 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
57b5a47b9d
commit
9abe8f7958
2 changed files with 8 additions and 10 deletions
|
@ -3984,7 +3984,7 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current
|
||||||
++numvalidentries;
|
++numvalidentries;
|
||||||
|
|
||||||
// assumes height == font->get_yline()!
|
// 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);
|
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)
|
if (entry == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int32_t const height = entry->type == Spacer ? entry->getSpacerHeight() : entry->font->get_yline();
|
int32_t const height = entry->getHeight();
|
||||||
|
|
||||||
y += height;
|
y += height;
|
||||||
totalHeight = y;
|
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)
|
for (e = 0; e < menu->numEntries; ++e)
|
||||||
{
|
{
|
||||||
MenuEntry_t *entry = menu->entrylist[e];
|
MenuEntry_t *entry = menu->entrylist[e];
|
||||||
uint8_t status = 0;
|
|
||||||
int32_t height, x;
|
|
||||||
vec2_t textsize;
|
|
||||||
|
|
||||||
if (entry == NULL)
|
if (entry == NULL)
|
||||||
continue;
|
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)
|
if (e == menu->currentEntry)
|
||||||
status |= MT_Selected;
|
status |= MT_Selected;
|
||||||
if (entry->flags & Disabled)
|
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;
|
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)
|
if (dodraw)
|
||||||
textsize = Menu_Text(origin.x + x, origin.y + y_upper + y - menu->scrollPos, entry->font, entry->name, status, ydim_upper, ydim_lower);
|
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)
|
if (entry->format->width < 0)
|
||||||
status |= MT_XRight;
|
status |= MT_XRight;
|
||||||
|
|
|
@ -324,10 +324,9 @@ typedef struct MenuEntry_t
|
||||||
|
|
||||||
int32_t getMarginBottom() const { return scale(format->marginBottom, font->zoom, 65536); }
|
int32_t getMarginBottom() const { return scale(format->marginBottom, font->zoom, 65536); }
|
||||||
int32_t getIndent() const { return scale(format->indent, 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 type == Spacer ? scale(((MenuSpacer_t *)entry)->height, font->zoom, 65536) : font->get_yline();
|
||||||
return scale(((MenuSpacer_t *)entry)->height, font->zoom, 65536);
|
|
||||||
}
|
}
|
||||||
} MenuEntry_t;
|
} MenuEntry_t;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue