- Unbreak input with cheat codes (and set a longer prefix). - Fix cracktro scrolls cutting off early. - Fix artifacts on M_SWWM graphic due to texture wrap.
116 lines
5.3 KiB
Text
116 lines
5.3 KiB
Text
// Things for the titlemap
|
|
|
|
Class SWWMTitleStuff : EventHandler
|
|
{
|
|
transient ui TextureID tex[3];
|
|
transient ui Font TewiFont, MPlusFont;
|
|
transient ui CVar lang, fuzz;
|
|
transient ui Array<String> scrolls;
|
|
transient ui int sline;
|
|
transient ui double sbase;
|
|
transient ui String lastlang;
|
|
|
|
// 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);
|
|
Vector2 tsize, vsize;
|
|
if ( !fuzz ) fuzz = CVar.GetCvar('swwm_fuzz',players[consoleplayer]);
|
|
if ( fuzz.GetBool() )
|
|
{
|
|
tsize = TexMan.GetScaledSize(tex[2]);
|
|
double zoom = max(ceil(Screen.GetWidth()/tsize.x),ceil(Screen.GetHeight()/tsize.y));
|
|
vsize = (Screen.GetWidth(),Screen.GetHeight())/zoom;
|
|
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());
|
|
}
|
|
else Screen.Dim("Black",1.,0,0,Screen.GetWidth(),Screen.GetHeight());
|
|
double ar = Screen.GetAspectRatio();
|
|
tsize = TexMan.GetScaledSize(tex[0]);
|
|
double 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);
|
|
if ( (level.maptime/Thinker.TICRATE) < 30 ) return;
|
|
// scrolls
|
|
if ( (scrolls.Size() <= 0 ) || (lastlang != lang.GetString()) )
|
|
{
|
|
scrolls.Clear();
|
|
String sstr = StringTable.Localize("$SWWM_TITLESCROLL");
|
|
sstr.Split(scrolls,"\n");
|
|
sbase = (level.maptime+e.FracTic)/Thinker.TICRATE;
|
|
if ( sline >= scrolls.Size() ) sline = 0;
|
|
}
|
|
lastlang = lang.GetString();
|
|
// estimate scrool length
|
|
double llen = fnt.StringWidth(scrolls[sline]);
|
|
double soffset = 40*((level.maptime+e.FracTic)/Thinker.TICRATE-sbase);
|
|
if ( soffset > llen+320 )
|
|
{
|
|
sline++;
|
|
if ( sline >= scrolls.Size() ) sline = 0;
|
|
sbase = (level.maptime+e.FracTic)/Thinker.TICRATE;
|
|
soffset = 0;
|
|
}
|
|
double xx = 320-soffset;
|
|
int tlen = scrolls[sline].CodePointCount();
|
|
for ( int i=0, pos=0; i<tlen; i++ )
|
|
{
|
|
int ch;
|
|
[ch, pos] = scrolls[sline].GetNextCodePoint(pos);
|
|
if ( (xx > -8) && (xx < 320) )
|
|
{
|
|
for ( double trl = .1; trl < 1.; trl += .04 )
|
|
{
|
|
double yy = 160+10*sin(15*i+160*(level.maptime+e.FracTic)/Thinker.TICRATE-90.*(1.-trl));
|
|
alf = max(0,1.-abs(160-xx)/160.)**.5;
|
|
alf *= .2*trl;
|
|
double xxofs = 5*sin(15*i+120*(level.maptime+e.FracTic)/Thinker.TICRATE-90.*(1.-trl))-16*(1.-trl);
|
|
Screen.DrawChar(fnt,Font.CR_BLUE,xx-xxofs,yy,ch,DTA_VirtualWidth,320,DTA_VirtualHeight,200,DTA_KeepRatio,true,DTA_Alpha,alf,DTA_LegacyRenderStyle,STYLE_Add);
|
|
}
|
|
double yy = 160+10*sin(15*i+160*(level.maptime+e.FracTic)/Thinker.TICRATE);
|
|
alf = max(0,1.-abs(160-xx)/160.)**.5;
|
|
double xxofs = 5*sin(15*i+120*(level.maptime+e.FracTic)/Thinker.TICRATE);
|
|
Color c = Color(int(127.5+127.5*sin(10*i+80*(level.maptime+e.FracTic)/Thinker.TICRATE)),0,0);
|
|
Screen.DrawChar(fnt,Font.CR_SAPPHIRE,xx-xxofs,yy,ch,DTA_VirtualWidth,320,DTA_VirtualHeight,200,DTA_KeepRatio,true,DTA_Alpha,alf);
|
|
}
|
|
xx += fnt.GetCharWidth(ch)-1; // keming
|
|
}
|
|
}
|
|
}
|