Tweak the F1 menu to always scale to factors of 640x360.

This commit is contained in:
Mari the Deer 2025-05-03 18:44:18 +02:00
commit 87522cab3d
4 changed files with 26 additions and 36 deletions

View file

@ -36,44 +36,45 @@ Class SWWMHelpMenu : GenericMenu
bgtex = TexMan.CheckForTexture("graphics/tempbg.png");
mSmallFont = Font.GetFont('TewiFont');
mSmallFont2 = Font.GetFont('TewiFontOutline');
int cropwidth = 584;
for ( int i=0; i<NUM_HELP_PAGES; i++ )
{
switch ( i )
{
case PAGE_STORY:
pagehdr[i] = StringTable.Localize("$SWWM_HELP_STORY");
if ( gameinfo.gametype&GAME_Heretic ) pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_STORYHERETIC"),600);
else if ( gameinfo.gametype&GAME_Hexen ) pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_STORYHEXEN"),600);
else if ( SWWMUtility.IsEviternity() || SWWMUtility.IsEviternityTwo() ) pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_STORYEVITERNITY"),600);
else pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_STORYDOOM"),600);
if ( gameinfo.gametype&GAME_Heretic ) pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_STORYHERETIC"),cropwidth);
else if ( gameinfo.gametype&GAME_Hexen ) pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_STORYHEXEN"),cropwidth);
else if ( SWWMUtility.IsEviternity() || SWWMUtility.IsEviternityTwo() ) pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_STORYEVITERNITY"),cropwidth);
else pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_STORYDOOM"),cropwidth);
break;
case PAGE_DEMO:
pagehdr[i] = StringTable.Localize("$SWWM_HELP_DEMO");
pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_DEMOTXT"),600);
pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_DEMOTXT"),cropwidth);
break;
case PAGE_ARSENAL1:
pagehdr[i] = StringTable.Localize("$SWWM_HELP_ARSE1");
pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_ARSE1TXT"),600);
pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_ARSE1TXT"),cropwidth);
break;
case PAGE_ARSENAL2:
pagehdr[i] = StringTable.Localize("$SWWM_HELP_ARSE2");
pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_ARSE2TXT"),600);
pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_ARSE2TXT"),cropwidth);
break;
case PAGE_ARSENAL3:
pagehdr[i] = StringTable.Localize("$SWWM_HELP_ARSE3");
pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_ARSE3TXT"),600);
pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_ARSE3TXT"),cropwidth);
break;
case PAGE_KBASE:
pagehdr[i] = StringTable.Localize("$SWWM_HELP_KBASE");
pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_KBASETXT"),600);
pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_KBASETXT"),cropwidth);
break;
case PAGE_TECH:
pagehdr[i] = StringTable.Localize("$SWWM_HELP_TECH");
pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_TECHTXT"),600);
pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_TECHTXT"),cropwidth);
break;
case PAGE_TIPS:
pagehdr[i] = StringTable.Localize("$SWWM_HELP_TIPS");
pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_TIPSTXT"),600);
pagetxt[i] = mSmallFont.BreakLines(StringTable.Localize("$SWWM_HELP_TIPSTXT"),cropwidth);
break;
}
}
@ -166,7 +167,7 @@ Class SWWMHelpMenu : GenericMenu
}
// big bulk of code
private void DrawPage( int page, double xofs = 0., double alpha = 1. )
private void DrawPage( int page, double hs, double xofs = 0., double alpha = 1. )
{
int h = mSmallFont.GetHeight();
int maxlen = 0, lh;
@ -176,7 +177,7 @@ Class SWWMHelpMenu : GenericMenu
let hdr = pagehdr[page];
let l = pagetxt[page];
lh = l.Count()*h;
Screen.DrawText(mSmallFont2,Font.CR_FIRE,xofs+(Screen.GetWidth()-mSmallFont2.StringWidth(hdr)*CleanXFac_1)/2,(Screen.GetHeight()-(h*3+lh)*CleanYFac_1)/2,hdr,DTA_CleanNoMove_1,true,DTA_Alpha,alpha);
Screen.DrawText(mSmallFont2,Font.CR_FIRE,xofs+(Screen.GetWidth()-mSmallFont2.StringWidth(hdr)*hs)/2,(Screen.GetHeight()-(h*3+lh)*hs)/2,hdr,DTA_ScaleX,hs,DTA_ScaleY,hs,DTA_Alpha,alpha);
for ( int i=0; i<l.Count(); i++ )
{
int len = l.StringWidth(i);
@ -184,8 +185,8 @@ Class SWWMHelpMenu : GenericMenu
}
for ( int i=0; i<l.Count(); i++ )
{
Screen.DrawText(mSmallFont,Font.CR_WHITE,xofs+(Screen.GetWidth()-maxlen*CleanXFac_1)/2,(Screen.GetHeight()-lh*CleanYFac_1)/2+y,l.StringAt(i),DTA_CleanNoMove_1,true,DTA_Alpha,alpha);
y += h*CleanYFac_1;
Screen.DrawText(mSmallFont,Font.CR_WHITE,xofs+(Screen.GetWidth()-maxlen*hs)/2,(Screen.GetHeight()-lh*hs)/2+y,l.StringAt(i),DTA_ScaleX,hs,DTA_ScaleY,hs,DTA_Alpha,alpha);
y += h*hs;
}
}
@ -200,21 +201,22 @@ Class SWWMHelpMenu : GenericMenu
}
else Screen.Dim(0xFF000000,.8,0,0,Screen.GetWidth(),Screen.GetHeight());
double alph = clamp(((MenuTime()+System.GetTimeFrac())-fadetic)*(5./GameTicRate),0.,1.);
if ( (prevpage == -1) || (alph >= 1.) ) DrawPage(curpage);
double hs = max(min(floor(Screen.GetWidth()/640.),floor(Screen.GetHeight()/360.)),1.);
if ( (prevpage == -1) || (alph >= 1.) ) DrawPage(curpage,hs);
else
{
DrawPage(prevpage,-(pagedir*alph*32)*CleanXFac_1,(1.-alph)**3);
DrawPage(curpage,(pagedir*(1.-alph)*32)*CleanXFac_1,alph**3);
DrawPage(prevpage,hs,-(pagedir*alph*32)*hs,(1.-alph)**3);
DrawPage(curpage,hs,(pagedir*(1.-alph)*32)*hs,alph**3);
}
int h = mSmallFont.GetHeight();
double y = Screen.GetHeight()/2-(h*2)*CleanYFac_1;
double y = Screen.GetHeight()/2-(h*2)*hs;
for ( int i=0; i<4; i++ )
{
if ( curpage > 0 )
Screen.DrawText(mSmallFont,Font.CR_GOLD,12*CleanXFac_1,y,"<",DTA_CleanNoMove_1,true);
Screen.DrawText(mSmallFont,Font.CR_GOLD,12*hs,y,"<",DTA_ScaleX,hs,DTA_ScaleY,hs);
if ( curpage < NUM_HELP_PAGES-1 )
Screen.DrawText(mSmallFont,Font.CR_GOLD,Screen.GetWidth()-18*CleanXFac_1,y,">",DTA_CleanNoMove_1,true);
y += h*CleanYFac_1;
Screen.DrawText(mSmallFont,Font.CR_GOLD,Screen.GetWidth()-18*hs,y,">",DTA_ScaleX,hs,DTA_ScaleY,hs);
y += h*hs;
}
Super.Drawer();
}