swwmgz_m/zscript/swwm_title.zsc

64 lines
3.2 KiB
Text

// Things for the titlemap
Class SWWMTitleStuff : EventHandler
{
transient ui TextureID tex[3];
transient ui Font TewiFont, MPlusFont;
transient ui CVar lang;
// returns MPlus if we're playing in Japanese, otherwise returns the requested font
private ui Font LangFont( Font req )
{
if ( !lang ) lang = CVar.GetCVar('language',players[consoleplayer]);
if ( lang.GetString() ~== "jp" ) return MPlusFont;
return req;
}
override void WorldTick()
{
if ( level.maptime == 1 ) S_ChangeMusic("music/TRAUMATI.XM");
}
override void RenderUnderlay( RenderEvent e )
{
if ( gamestate != GS_TITLELEVEL ) return;
if ( !tex[0] ) tex[0] = TexMan.CheckForTexture("graphics/UnSXLogo.png",TexMan.Type_Any);
if ( !tex[1] ) tex[1] = TexMan.CheckForTexture("graphics/SWWMGZLogo.png",TexMan.Type_Any);
if ( !tex[2] ) tex[2] = TexMan.CheckForTexture("graphics/tempbg.png",TexMan.Type_Any);
if ( !TewiFont ) TewiFont = Font.GetFont('TewiShadedInverse');
if ( !MPlusFont ) MPlusFont = Font.GetFont('MPlusShadedInverse');
Font fnt = LangFont(TewiFont);
double ar = Screen.GetAspectRatio();
Vector2 tsize = TexMan.GetScaledSize(tex[2]);
double sar = tsize.x/tsize.y;
Vector2 vsize;
if ( sar < ar ) vsize = (tsize.x,tsize.x/ar);
else if ( sar > ar ) vsize = (tsize.y*ar,tsize.y);
else vsize = tsize;
Screen.DrawTexture(tex[2],false,(vsize.x-tsize.x)/2,(vsize.y-tsize.y)/2,DTA_VirtualWidthF,vsize.x,DTA_VirtualHeightF,vsize.y,DTA_KeepRatio,true,DTA_ColorOverlay,Color(192,0,0,0));
Screen.Dim("Black",clamp(1.-((level.maptime+e.FracTic)/Thinker.TICRATE)*.05,0.,1.),0,0,Screen.GetWidth(),Screen.GetHeight());
tsize = TexMan.GetScaledSize(tex[0]);
sar = tsize.x/tsize.y;
if ( sar > ar ) vsize = (tsize.x,tsize.x/ar);
else if ( sar < ar ) vsize = (tsize.y*ar,tsize.y);
else vsize = tsize;
double alf = clamp(((level.maptime+e.FracTic)/Thinker.TICRATE)-2,0.,1.);
alf *= 1.-clamp(((level.maptime+e.FracTic)/Thinker.TICRATE)-8,0.,1.);
Screen.DrawTexture(tex[0],false,(vsize.x-tsize.x)/2,(vsize.y-tsize.y)/2,DTA_VirtualWidthF,vsize.x,DTA_VirtualHeightF,vsize.y,DTA_KeepRatio,true,DTA_Alpha,alf);
String str = StringTable.Localize("$SWWM_TITLEPRESENTS");
alf = clamp(((level.maptime+e.FracTic)/Thinker.TICRATE)-10,0.,1.);
alf *= 1.-clamp(((level.maptime+e.FracTic)/Thinker.TICRATE)-16,0.,1.);
Screen.DrawText(fnt,Font.CR_WHITE,(320-fnt.StringWidth(str))/2,(200-fnt.GetHeight())/2,str,DTA_VirtualWidth,320,DTA_VirtualHeight,200,DTA_KeepRatio,true,DTA_Alpha,alf);
str = StringTable.Localize("$SWWM_TITLEMODBY");
alf = clamp(((level.maptime+e.FracTic)/Thinker.TICRATE)-18,0.,1.);
alf *= 1.-clamp(((level.maptime+e.FracTic)/Thinker.TICRATE)-24,0.,1.);
Screen.DrawText(fnt,Font.CR_WHITE,(320-fnt.StringWidth(str))/2,(200-fnt.GetHeight())/2,str,DTA_VirtualWidth,320,DTA_VirtualHeight,200,DTA_KeepRatio,true,DTA_Alpha,alf);
tsize = TexMan.GetScaledSize(tex[1]);
sar = tsize.x/tsize.y;
if ( sar > ar ) vsize = (tsize.x,tsize.x/ar);
else if ( sar < ar ) vsize = (tsize.y*ar,tsize.y);
else vsize = tsize;
alf = clamp(((level.maptime+e.FracTic)/Thinker.TICRATE)-26,0.,2.)*.5;
Screen.DrawTexture(tex[1],false,(vsize.x-tsize.x)/2,(vsize.y-tsize.y)/2,DTA_VirtualWidthF,vsize.x,DTA_VirtualHeightF,vsize.y,DTA_KeepRatio,true,DTA_Alpha,alf);
}
}