Statscreen compat fix for recent devbuilds.

Unfortunately, the ability to switch art and tips on the fly, as well as fading the foreground, have all been lost in the process.
This commit is contained in:
Mari the Deer 2022-04-27 17:02:41 +02:00
commit 7ad3295046
3 changed files with 17 additions and 84 deletions

View file

@ -1,17 +1,10 @@
// Custom intermission screens
Class SWWMStatScreenData : SWWMStaticThinker
{
// to prevent repetition
Array<int> lasttip, lastart;
}
Class SWWMStatScreen : StatusScreen abstract
{
transient TextureID bgtex, arttex;
int whichart, whichtip;
double hs, hs2;
Vector2 ss, ss2, origin, origin2;
double bgfade;
Font mSmallFont;
String tipstr;
transient BrokenLines tipl;
@ -41,12 +34,7 @@ Class SWWMStatScreen : StatusScreen abstract
}
private void drawSWWMBg()
{
let pdata = SWWMStatScreenData(ThinkerIterator.Create("SWWMStatScreenData",Thinker.STAT_STATIC).Next());
if ( !pdata )
{
pdata = new("SWWMStatScreenData");
pdata.ChangeStatNum(Thinker.STAT_STATIC);
}
let shnd = SWWMStaticHandler(StaticEventHandler.Find("SWWMStaticHandler"));
if ( !whichart && swwm_interart )
{
int no = StringTable.Localize("$SWWM_NFANART").ToInt();
@ -63,24 +51,24 @@ Class SWWMStatScreen : StatusScreen abstract
rno++;
}
no = rno;
if ( pdata.lastart.Size() >= no )
if ( shnd.lastart.Size() >= no )
{
// exclude last one, start over
int excludeme = pdata.lastart[pdata.lastart.Size()-1];
int excludeme = shnd.lastart[shnd.lastart.Size()-1];
ents.Delete(excludeme-1);
pdata.lastart.Clear();
shnd.lastart.Clear();
}
else
{
for ( int i=0; i<pdata.lastart.Size(); i++ )
for ( int i=0; i<shnd.lastart.Size(); i++ )
{
int f = ents.Find(pdata.lastart[i]);
int f = ents.Find(shnd.lastart[i]);
if ( f != ents.Size() )
ents.Delete(f);
}
}
whichart = ents[Random[InterArt](0,ents.Size()-1)];
pdata.lastart.Push(whichart);
shnd.lastart.Push(whichart);
}
double ar = Screen.GetAspectRatio(), sar;
Vector2 tsize, vsize;
@ -130,18 +118,18 @@ Class SWWMStatScreen : StatusScreen abstract
}
// account for skipped dlc tips (important, will crash otherwise)
maxtip -= 10;
if ( pdata.lasttip.Size() >= maxtip )
if ( shnd.lasttip.Size() >= maxtip )
{
// exclude last one, start over
int excludeme = pdata.lasttip[pdata.lasttip.Size()-1];
int excludeme = shnd.lasttip[shnd.lasttip.Size()-1];
ents.Delete(excludeme-1);
pdata.lasttip.Clear();
shnd.lasttip.Clear();
}
else
{
for ( int i=0; i<pdata.lasttip.Size(); i++ )
for ( int i=0; i<shnd.lasttip.Size(); i++ )
{
int f = ents.Find(pdata.lasttip[i]);
int f = ents.Find(shnd.lasttip[i]);
if ( f != ents.Size() )
ents.Delete(f);
}
@ -149,7 +137,7 @@ Class SWWMStatScreen : StatusScreen abstract
whichtip = ents[Random[InterArt](0,ents.Size()-1)];
tipstr = "\cd"..String.Format(StringTable.Localize("$SWWM_INTERTIP"),whichtip).."\c-\n"..StringTable.Localize(String.Format("$SWWM_INTERTIP%d",whichtip));
if ( tipl ) tipl.Destroy();
pdata.lasttip.Push(whichtip);
shnd.lasttip.Push(whichtip);
}
if ( swwm_nointertips ) return;
int lw = 0;
@ -243,65 +231,11 @@ Class SWWMStatScreen : StatusScreen abstract
drawNoState();
break;
}
if ( bgfade <= 0. ) return;
// redraw bgs on top, hiding the rest of the ui
if ( whichart )
{
double ar = Screen.GetAspectRatio();
Vector2 tsize = TexMan.GetScaledSize(arttex);
double sar = tsize.x/tsize.y;
Vector2 vsize;
if ( sar > ar ) vsize = (tsize.y*ar,tsize.y);
else if ( sar < ar ) vsize = (tsize.x,tsize.x/ar);
else vsize = tsize;
Screen.DrawTexture(arttex,false,(vsize.x-tsize.x)/2,(vsize.y-tsize.y)/2,DTA_VirtualWidthF,vsize.x,DTA_VirtualHeightF,vsize.y,DTA_KeepRatio,true,DTA_Alpha,bgfade);
}
else
{
double ar = Screen.GetAspectRatio();
Vector2 tsize = TexMan.GetScaledSize(bgtex);
double sar = tsize.x/tsize.y;
Vector2 vsize;
if ( sar > ar ) vsize = (tsize.y*ar,tsize.y);
else if ( sar < ar ) vsize = (tsize.x,tsize.x/ar);
else vsize = tsize;
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_Alpha,bgfade);
}
}
protected void checkForAccelerateNew( void )
{
// check for button presses to skip delays (but only recognize fire/use buttons)
for ( int i=0; i < MAXPLAYERS; i++ )
{
if ( !playeringame[i] ) continue;
PlayerInfo p = players[i];
if ( (p.cmd.buttons^p.oldbuttons) && ((p.cmd.buttons&p.oldbuttons) == p.oldbuttons) && !p.Bot )
{
if ( p.cmd.buttons&(BT_ATTACK|BT_USE) )
{
acceleratestage = 1;
playerready[i] = true;
}
if ( p.cmd.buttons&BT_RELOAD )
{
if ( !swwm_nointertips ) PlaySound("menu/demoscroll");
whichtip = 0;
}
if ( p.cmd.buttons&BT_ZOOM )
{
if ( swwm_interart ) PlaySound("menu/demoscroll");
whichart = 0;
arttex.SetNull();
}
}
p.oldbuttons = p.buttons;
}
}
override void Ticker( void )
{
bcnt++;
if ( bcnt == 1 ) StartMusic();
checkForAccelerateNew();
switch (CurState)
{
case StatCount:
@ -317,9 +251,6 @@ Class SWWMStatScreen : StatusScreen abstract
// sorry nothing
break;
}
// check fade
if ( players[me].cmd.buttons&BT_ALTATTACK ) bgfade = min(1.,bgfade+3./GameTicRate);
else bgfade = max(0.,bgfade-4./GameTicRate);
// force toggle
if ( !swwm_interart && (whichart != 0) )
{

View file

@ -24,6 +24,8 @@ Class SWWMStaticHandler : StaticEventHandler
bool mpwarned;
// checks
ThinkerIterator sti;
// for intermissions, to prevent repetition
ui Array<int> lasttip, lastart;
override void NewGame()
{