marisa_m/zscript/menu/marisa_inter.zsc

168 lines
6.6 KiB
Plaintext

// intermission stat screen
Class MarisaStatScreen : SWWMStatScreen
{
TextureID bgtex;
TextureID marisatex[2];
TitleSmoke smk[128];
TextureID smk_tex[8];
TitleSmoke ash[128];
TextureID ash_tex[8];
override void Start( wbstartstruct wbstartstruct )
{
Super.Start(wbstartstruct);
lnamecolor = Font.FindFontColor('MiniWhite');
lauthcolor = Font.FindFontColor('MiniIbukiHUD');
lsubcolor = Font.FindFontColor('MiniCrimson');
statbasecolor = Font.FindFontColor('MiniIce');
statcolor0 = Font.FindFontColor('MiniWhite');
statcolor1 = Font.FindFontColor('MiniBrass');
statcolor2 = Font.FindFontColor('MiniRed');
tipcolor0 = Font.FindFontColor('MiniIce');
tipcolor1 = Font.FindFontColor('MiniWhite');
glarecolor = 0xFFFF0000;
}
override void StartMusic()
{
S_ChangeMusic("music/marisa_intermus.ogg");
}
override String StatCnt( int a, int b )
{
if ( b <= 0 ) return "N/A";
return String.Format("%s \c[MiniIbukiHUD]/\c- %s \c[MiniIbukiHUD](\c-%3d%%\c[MiniIbukiHUD])",SWWMUtility.ThousandsNum(max(a,0)),SWWMUtility.ThousandsNum(b),GetPct(a,b));
}
override String TimeStr( int secs )
{
secs = max(secs,0);
int h = secs/3600;
int m = (secs/60)%60;
int s = secs%60;
if ( h ) return String.Format("%d\c[MiniIbukiHUD]:\c-%02d\c[MiniIbukiHUD]:\c-%02d",h,m,s);
if ( m ) return String.Format("%d\c[MiniIbukiHUD]:\c-%02d",m,s);
return String.Format("%d",s);
}
override void Ticker( void )
{
Super.Ticker();
TickSmokeLayers();
}
private void TickSmokeLayers()
{
for ( int i=0; i<128; i++ )
{
int presim = 0;
if ( smk[i].age >= smk[i].maxage )
{
if ( smk[i].maxage == 0 ) presim = Random[UIStuff](0,60);
else presim = -1;
smk[i].age = Random[UIStuff](-20,0);
smk[i].maxage = Random[UIStuff](60,120);
smk[i].pos = (FRandom[UIStuff](-512.,512.),FRandom[UIStuff](0.,256.));
smk[i].vel = (FRandom[UIStuff](-1.,3.),FRandom[UIStuff](-2.,-6.));
smk[i].ang = FRandom[UIStuff](0.,360.);
smk[i].angvel = FRandom[UIStuff](1.,4.)*RandomPick[UIStuff](-1,1);
smk[i].scale = FRandom[UIStuff](2.,4.);
}
for ( int j=0; j<=presim; j++ )
{
smk[i].age++;
if ( smk[i].age <= 0 ) continue;
smk[i].pos += smk[i].vel;
smk[i].ang += smk[i].angvel;
}
}
for ( int i=0; i<128; i++ )
{
int presim = 0;
if ( ash[i].age >= ash[i].maxage )
{
if ( ash[i].maxage == 0 ) presim = Random[UIStuff](0,90);
else presim = -1;
ash[i].age = Random[UIStuff](-20,0);
ash[i].maxage = Random[UIStuff](120,480);
ash[i].pos = (FRandom[UIStuff](-512.,512.),FRandom[UIStuff](0.,64.));
ash[i].vel = (FRandom[UIStuff](-1.5,1.5),FRandom[UIStuff](-.5,-2.));
ash[i].ang = FRandom[UIStuff](0.,360.);
ash[i].angvel = FRandom[UIStuff](.2,.8)*RandomPick[UIStuff](-1,1);
ash[i].scale = FRandom[UIStuff](4.,8.);
ash[i].alpha = FRandom[UIStuff](.3,.8);
}
for ( int j=0; j<=presim; j++ )
{
ash[i].age++;
if ( ash[i].age <= 0 ) continue;
ash[i].pos += ash[i].vel;
ash[i].ang += ash[i].angvel;
}
}
}
private void RenderSmokeLayer( double GameSecs, bool back, double alpha = 1. )
{
double zoomscl = Screen.GetHeight()/600.;
int imin = back?64:0;
int imax = back?128:64;
int base = back?250:750;
for ( int i=imin; i<imax; i++ )
{
if ( !smk[i].maxage ) continue;
if ( !smk_tex[i%8] ) smk_tex[i%8] = TexMan.CheckForTexture("graphics/title_smoke_"..(i%8)..".png");
Vector2 pos = (smk[i].pos+smk[i].vel*fractic+(0,base))*zoomscl+(Screen.GetWidth()/2,0);
double scl = smk[i].scale*zoomscl;
double ang = smk[i].ang+smk[i].angvel*fractic;
double alf = cos((smk[i].age/double(smk[i].maxage))*90)*alpha;
alf *= clamp(smk[i].age/10.,0,1);
Screen.DrawTexture(smk_tex[i%8],false,pos.x,pos.y,DTA_CenterOffset,true,DTA_Rotate,ang,DTA_ScaleX,scl,DTA_ScaleY,scl,DTA_Alpha,alf,DTA_LegacyRenderStyle,STYLE_AddShaded,DTA_FillColor,Color(32,32,32));
}
if ( back ) return;
base = 600;
for ( int i=0; i<128; i++ )
{
if ( !ash[i].maxage ) continue;
if ( !ash_tex[i%8] ) ash_tex[i%8] = TexMan.CheckForTexture("graphics/title_dust_"..(i%8)..".png");
Vector2 pos = (ash[i].pos+ash[i].vel*fractic+(0,base))*zoomscl+(Screen.GetWidth()/2,0);
double scl = ash[i].scale*zoomscl;
double ang = ash[i].ang+ash[i].angvel*fractic;
double alf = 1.-(ash[i].age/double(ash[i].maxage))**2.;
alf *= clamp(ash[i].age/5.,0,1);
alf *= ash[i].alpha;
Screen.DrawTexture(ash_tex[i%8],false,pos.x,pos.y,DTA_CenterOffset,true,DTA_Rotate,ang,DTA_ScaleX,scl,DTA_ScaleY,scl,DTA_Alpha,alf,DTA_LegacyRenderStyle,STYLE_Shaded,DTA_FillColor,Color(128,128,128));
}
}
override void drawSWWMBg()
{
double GameSecs = (bcnt+fractic)/double(GameTicRate);
if ( swwm_fuzz )
{
if ( !bgtex ) bgtex = TexMan.CheckForTexture("graphics/tempbg.png");
Vector2 tsize = TexMan.GetScaledSize(bgtex);
double zoom = max(ceil(Screen.GetWidth()/tsize.x),ceil(Screen.GetHeight()/tsize.y));
Vector2 vsize = (Screen.GetWidth(),Screen.GetHeight())/zoom;
Screen.DrawTexture(bgtex,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(128,0,0,0));
Screen.Dim(Color(8,8,8),1.-clamp(GameSecs,.1,1.),0,0,Screen.GetWidth(),Screen.GetHeight());
}
else Screen.Dim(Color(8,8,8),1.,0,0,Screen.GetWidth(),Screen.GetHeight());
double texscl = Screen.GetHeight()/1300.;
if ( !gradtex ) gradtex = TexMan.CheckForTexture("graphics/title_grad.png");
Screen.DrawTexture(gradtex,false,0,Screen.GetHeight(),DTA_DestWidth,Screen.GetWidth(),DTA_DestHeight,1024*CleanYFac_1,DTA_LegacyRenderStyle,STYLE_Shaded,DTA_FillColor,Color(0,0,0),DTA_TopOffset,256);
RenderSmokeLayer(GameSecs,true,.5);
if ( !marisatex[0] ) marisatex[0] = TexMan.CheckForTexture("graphics/title_marisa.png");
if ( !marisatex[1] ) marisatex[1] = TexMan.CheckForTexture("graphics/title_marisa_eyes.png");
double ofs;
if ( sp_state >= 2 ) ofs = 120;
else ofs = 120*SWWMUtility.smerp(clamp(GameSecs,0.,1.));
Screen.DrawTexture(marisatex[0],false,Screen.GetWidth()/2+ofs*CleanXFac_1,0,DTA_ScaleX,texscl,DTA_ScaleY,texscl);
RenderSmokeLayer(GameSecs,false,1.);
Screen.DrawTexture(gradtex,false,0,Screen.GetHeight(),DTA_DestWidth,Screen.GetWidth(),DTA_DestHeight,512*CleanYFac_1,DTA_LegacyRenderStyle,STYLE_Shaded,DTA_FillColor,Color(0,0,0),DTA_TopOffset,256,DTA_Alpha,.8);
Screen.DrawTexture(marisatex[1],false,Screen.GetWidth()/2+ofs*CleanXFac_1,0,DTA_ScaleX,texscl,DTA_ScaleY,texscl);
double alf = clamp((glarestr-fractic)/20.,0.,1.)**2;
if ( alf > 0. ) Screen.DrawTexture(marisatex[1],false,Screen.GetWidth()/2+ofs*CleanXFac_1,0,DTA_ScaleX,texscl,DTA_ScaleY,texscl,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alf);
}
}