swwmgz_m/zscript/swwm_title.zsc
Marisa Kirisame eb2ee7b29f Push to master all the current WIP stuff in 0.9.11b:
- Reduce number of collectibles (some might come back in the future).
 - Merge both DLC weaponsets into one, removing redundant weapons.
 - Readjust prices of some items.
 - Initial work on collectibles (currently Frispy Corn is done).
 - Added bigfont for main menu, based on Source Han Sans.
 - Reduced default HUD margin to 10.
 - Added blob shadows.
 - Added precise crosshair drawing.
 - Tweaked decals, imported more stuff from UT.
 - Swapped the Ynykron impact decal for something better.
 - Fixes to slope alignment code.
 - Implemented headpats for MBF Helper Dogs and Cacodemons.
 - Implemented partial HDoom support, with love and headpats.
 - Fix various string functions breaking on unicode.
 - Added cracktro-style text scroll to Titlemap.
 - Fixed handling of healthbars for friendly monsters.
 - Workaround for maps that use the old author name hack (" - by: " separator).
 - Fixed Silver Bullet not autoswitching on first pickup.
 - Fixed misalignment of Silver Bullet zoomed aim.
 - Silver Bullet is unchambered on first pickup, consistent with Candygun.
 - Adjusted collision sizes of all items across the board.
 - Implemented "Use To Pickup" to work around any issues introduced by the previous change.
 - Swapped CHANF_LOOPING for CHANF_LOOP in many cases, this was a typo.
 - Tweaked Biospark arc lengths, for balance and higher performance.
 - Fix misaligned fire offsets of some weapons (most noticeable on Wallbuster).
 - Prettified the loading disclaimers for BD and HDoom.
 - Add pickup flash to all items.
 - Add custom key models for Doom and Heretic.
 - Fix blown kisses giving you "need key" messages.
 - Fix worn armor and embiggeners not being removed on scripted inventory resets.
 - Remove all references to the no longer planned Radio.
 - Workaround for gzdoom devbuild quirk where MenuSound changed its argument type.
 - Added timezone to fake clock.
 - Fix some times and dates in said clock.
 - SWWM blood now also hits ceilings.
 - Added default properties to DLC ammo and weapon stubs.
 - Lore entries for collectibles and dlc weapons (incomplete).
 - Massive amount of typo fixes across the board.
2020-10-20 11:37:14 +02:00

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);
}
}
}