Reimplement intermission input handling.

This commit is contained in:
Mari the Deer 2022-06-01 18:27:10 +02:00
commit a8ed346e67
2 changed files with 79 additions and 2 deletions

View file

@ -1,3 +1,3 @@
[default]
SWWM_MODVER="\cyDEMOLITIONIST \cw1.2.20 r13 \cu(Wed 1 Jun 18:32:44 CEST 2022)\c-";
SWWM_SHORTVER="\cw1.2.20 r13 \cu(2022-06-01 18:32:44)\c-";
SWWM_MODVER="\cyDEMOLITIONIST \cw1.2.21 \cu(Wed 1 Jun 18:33:35 CEST 2022)\c-";
SWWM_SHORTVER="\cw1.2.21 \cu(2022-06-01 18:33:35)\c-";

View file

@ -8,6 +8,8 @@ Class SWWMStatScreen : StatusScreen abstract
Font mSmallFont;
String tipstr;
transient BrokenLines tipl;
double bgfade;
bool bFade;
override void Start( wbstartstruct wbstartstruct )
{
@ -231,6 +233,19 @@ Class SWWMStatScreen : StatusScreen abstract
drawNoState();
break;
}
if ( bgfade <= 0. ) return;
// redraw BG on top, hiding the rest of the ui
TextureID tx;
if ( whichart ) tx = arttex;
else tx = bgtex;
double ar = Screen.GetAspectRatio();
Vector2 tsize = TexMan.GetScaledSize(tx);
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(tx,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);
}
override void Ticker( void )
{
@ -251,6 +266,9 @@ Class SWWMStatScreen : StatusScreen abstract
// sorry nothing
break;
}
// check fade
if ( bFade ) bgfade = min(1.,bgfade+3./GameTicRate);
else bgfade = max(0.,bgfade-4./GameTicRate);
// force toggle
if ( !swwm_interart && (whichart != 0) )
{
@ -274,6 +292,65 @@ Class SWWMStatScreen : StatusScreen abstract
if ( b <= 0 ) return inv?0:100; // for "missed" percentage
return (a*100)/b;
}
override bool OnEvent( InputEvent evt )
{
if ( evt.type == InputEvent.Type_KeyDown )
{
Array<int> usekey, firekey, altfirekey, reloadkey, zoomkey;
Bindings.GetAllKeysForCommand(usekey,"+use");
for ( int i=0; i<usekey.Size(); i++ )
{
if ( evt.KeyScan != usekey[i] ) continue;
accelerateStage = 1;
return true;
}
Bindings.GetAllKeysForCommand(firekey,"+attack");
for ( int i=0; i<firekey.Size(); i++ )
{
if ( evt.KeyScan != firekey[i] ) continue;
accelerateStage = 1;
return true;
}
Bindings.GetAllKeysForCommand(altfirekey,"+altattack");
for ( int i=0; i<altfirekey.Size(); i++ )
{
if ( evt.KeyScan != altfirekey[i] ) continue;
bFade = true;
return true;
}
Bindings.GetAllKeysForCommand(reloadkey,"+reload");
for ( int i=0; i<reloadkey.Size(); i++ )
{
if ( evt.KeyScan != reloadkey[i] ) continue;
if ( !swwm_nointertips ) PlaySound("menu/demoscroll");
whichtip = 0;
return true;
}
Bindings.GetAllKeysForCommand(zoomkey,"+zoom");
for ( int i=0; i<zoomkey.Size(); i++ )
{
if ( evt.KeyScan != zoomkey[i] ) continue;
if ( swwm_interart ) PlaySound("menu/demoscroll");
whichart = 0;
arttex.SetNull();
return true;
}
return false;
}
else if ( evt.type == InputEvent.Type_KeyUp )
{
Array<int> altfirekey;
Bindings.GetAllKeysForCommand(altfirekey,"+altattack");
for ( int i=0; i<altfirekey.Size(); i++ )
{
if ( evt.KeyScan != altfirekey[i] ) continue;
bFade = false;
return true;
}
}
return false;
}
}
Class SWWMStatScreen_SP : SWWMStatScreen