Skip to content

Commit

Permalink
[SP] Map the UI module internal font numbers 1 to 4 to the names of d…
Browse files Browse the repository at this point in the history
…efault fonts and dynamically register them to avoid undesired font changes when registering other fonts too early.
  • Loading branch information
Daggolin committed Nov 11, 2023
1 parent c54bc58 commit d786f19
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions code/ui/ui_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3072,14 +3072,30 @@ qboolean ItemParse_name( itemDef_t *item)
return qtrue;
}

int MenuFontToReal( int menuFontIndex )
{
// Default fonts from a clean installation
switch ( menuFontIndex ) {
case 1: return UI_RegisterFont( "aurabesh" );
case 2: return UI_RegisterFont( "ergoec" );
case 3: return UI_RegisterFont( "anewhope" );
case 4: return UI_RegisterFont( "arialnb" );

default:
return DC->Assets.qhMediumFont;
}
}

qboolean ItemParse_font( itemDef_t *item )
{
if (PC_ParseInt(&item->font))
{
return qfalse;
}

// Translate to real font
item->font = MenuFontToReal( item->font );

return qtrue;
}

Expand Down Expand Up @@ -8261,7 +8277,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
while (1)
{
// FIXME - add some type of parameter in the menu file like descfont to specify the font for the descriptions for this menu.
textWidth = DC->textWidth(textPtr, fDescScale, 4); // item->font);
textWidth = DC->textWidth(textPtr, fDescScale, MenuFontToReal(4)); // item->font);

if (parent->descAlignment == ITEM_ALIGN_RIGHT)
{
Expand Down Expand Up @@ -8297,7 +8313,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
}

// FIXME - add some type of parameter in the menu file like descfont to specify the font for the descriptions for this menu.
DC->drawText(xPos, parent->descY + iYadj, fDescScale, parent->descColor, textPtr, 0, parent->descTextStyle, 4); //item->font);
DC->drawText(xPos, parent->descY + iYadj, fDescScale, parent->descColor, textPtr, 0, parent->descTextStyle, MenuFontToReal(4)); //item->font);
break;
}
}
Expand Down

0 comments on commit d786f19

Please sign in to comment.