[LifeMeterBattery] Added LostLife param to LifeChanged message. Converted LifeMeterBattery lives to an AutoActor.
This commit is contained in:
@@ -8,6 +8,11 @@ ________________________________________________________________________________
|
|||||||
StepMania 5.0 Preview 3 | 20110???
|
StepMania 5.0 Preview 3 | 20110???
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
2011/08/07
|
||||||
|
----------
|
||||||
|
* [LifeMeterBattery] Added LostLife param to LifeChanged message. [AJ]
|
||||||
|
* [LifeMeterBattery] Converted LifeMeterBattery lives to an AutoActor. [AJ]
|
||||||
|
|
||||||
2011/08/06
|
2011/08/06
|
||||||
----------
|
----------
|
||||||
* [NoteSkins/beat/default] Fix Issue 425. [AJ]
|
* [NoteSkins/beat/default] Fix Issue 425. [AJ]
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
@@ -0,0 +1,20 @@
|
|||||||
|
local player = Var "Player"
|
||||||
|
local blinkTime = 1.2
|
||||||
|
|
||||||
|
local t = Def.ActorFrame{
|
||||||
|
LoadActor("_lives")..{
|
||||||
|
-- xxx: assumes course is 4lives
|
||||||
|
InitCommand=cmd(pause;setstate,3);
|
||||||
|
LifeChangedMessageCommand=function(self,param)
|
||||||
|
if param.Player == player then
|
||||||
|
if param.LivesLeft <= 4 then
|
||||||
|
self:setstate( math.max(param.LivesLeft-1,0) )
|
||||||
|
else
|
||||||
|
self:setstate(3)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
return t;
|
||||||
+18
-41
@@ -9,12 +9,9 @@
|
|||||||
|
|
||||||
LifeMeterBattery::LifeMeterBattery()
|
LifeMeterBattery::LifeMeterBattery()
|
||||||
{
|
{
|
||||||
|
|
||||||
m_iLivesLeft = GAMESTATE->m_SongOptions.GetStage().m_iBatteryLives;
|
m_iLivesLeft = GAMESTATE->m_SongOptions.GetStage().m_iBatteryLives;
|
||||||
m_iTrailingLivesLeft = m_iLivesLeft;
|
m_iTrailingLivesLeft = m_iLivesLeft;
|
||||||
|
|
||||||
m_fBatteryBlinkTime = 0;
|
|
||||||
|
|
||||||
m_soundGainLife.Load( THEME->GetPathS("LifeMeterBattery","gain") );
|
m_soundGainLife.Load( THEME->GetPathS("LifeMeterBattery","gain") );
|
||||||
m_soundLoseLife.Load( THEME->GetPathS("LifeMeterBattery","lose"),true );
|
m_soundLoseLife.Load( THEME->GetPathS("LifeMeterBattery","lose"),true );
|
||||||
}
|
}
|
||||||
@@ -34,22 +31,19 @@ void LifeMeterBattery::Load( const PlayerState *pPlayerState, PlayerStageStats *
|
|||||||
LET_GO_SUBTRACT_LIVES.Load(sType, "LetGoSubtractLives");
|
LET_GO_SUBTRACT_LIVES.Load(sType, "LetGoSubtractLives");
|
||||||
|
|
||||||
LIVES_FORMAT.Load(sType, "NumLivesFormat");
|
LIVES_FORMAT.Load(sType, "NumLivesFormat");
|
||||||
BATTERY_BLINK_TIME.Load(sType, "BatteryBlinkTime"); // 1.2f by default
|
|
||||||
|
|
||||||
bool bPlayerEnabled = GAMESTATE->IsPlayerEnabled( pPlayerState );
|
bool bPlayerEnabled = GAMESTATE->IsPlayerEnabled( pPlayerState );
|
||||||
|
LuaThreadVariable var( "Player", LuaReference::Create(m_pPlayerState->m_PlayerNumber) );
|
||||||
|
|
||||||
m_sprFrame.Load( THEME->GetPathG(sType,"frame") );
|
m_sprFrame.Load( THEME->GetPathG(sType,"frame") );
|
||||||
this->AddChild( m_sprFrame );
|
this->AddChild( m_sprFrame );
|
||||||
|
|
||||||
m_sprBattery.Load( THEME->GetPathG(sType,"lives 1x4") );
|
m_sprBattery.Load( THEME->GetPathG(sType,"lives") );
|
||||||
m_sprBattery.SetName( ssprintf("BatteryP%i",int(pn+1)) );
|
m_sprBattery->SetName( ssprintf("BatteryP%i",int(pn+1)) );
|
||||||
// required because it's a sprite. todo: allow for AutoActoring but detect
|
|
||||||
// Sprites for old behavior. -aj
|
|
||||||
m_sprBattery.StopAnimating();
|
|
||||||
if( bPlayerEnabled )
|
if( bPlayerEnabled )
|
||||||
{
|
{
|
||||||
ActorUtil::LoadAllCommandsAndSetXY( m_sprBattery, sType );
|
ActorUtil::LoadAllCommandsAndSetXY( m_sprBattery, sType );
|
||||||
this->AddChild( &m_sprBattery );
|
this->AddChild( m_sprBattery );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_textNumLives.LoadFromFont( THEME->GetPathF(sType, "lives") );
|
m_textNumLives.LoadFromFont( THEME->GetPathF(sType, "lives") );
|
||||||
@@ -120,7 +114,6 @@ void LifeMeterBattery::SubtractLives( int iLives )
|
|||||||
m_textNumLives.PlayCommand("LoseLife");
|
m_textNumLives.PlayCommand("LoseLife");
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
m_fBatteryBlinkTime = BATTERY_BLINK_TIME;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LifeMeterBattery::AddLives( int iLives )
|
void LifeMeterBattery::AddLives( int iLives )
|
||||||
@@ -134,7 +127,6 @@ void LifeMeterBattery::AddLives( int iLives )
|
|||||||
m_textNumLives.PlayCommand("GainLife");
|
m_textNumLives.PlayCommand("GainLife");
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
m_fBatteryBlinkTime = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LifeMeterBattery::ChangeLives(int iLifeDiff)
|
void LifeMeterBattery::ChangeLives(int iLifeDiff)
|
||||||
@@ -150,19 +142,27 @@ void LifeMeterBattery::ChangeLife( TapNoteScore score )
|
|||||||
if( m_iLivesLeft == 0 )
|
if( m_iLivesLeft == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
bool bSubtract = false;
|
||||||
// this probably doesn't handle hold checkpoints. -aj
|
// this probably doesn't handle hold checkpoints. -aj
|
||||||
if( score == TNS_HitMine && MINES_SUBTRACT_LIVES > 0 )
|
if( score == TNS_HitMine && MINES_SUBTRACT_LIVES > 0 )
|
||||||
|
{
|
||||||
SubtractLives(MINES_SUBTRACT_LIVES);
|
SubtractLives(MINES_SUBTRACT_LIVES);
|
||||||
|
bSubtract = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( score < MIN_SCORE_TO_KEEP_LIFE && score > TNS_CheckpointMiss && SUBTRACT_LIVES > 0 )
|
if( score < MIN_SCORE_TO_KEEP_LIFE && score > TNS_CheckpointMiss && SUBTRACT_LIVES > 0 )
|
||||||
|
{
|
||||||
SubtractLives(SUBTRACT_LIVES);
|
SubtractLives(SUBTRACT_LIVES);
|
||||||
|
bSubtract = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Message msg( "LifeChanged" );
|
Message msg( "LifeChanged" );
|
||||||
msg.SetParam( "Player", m_pPlayerState->m_PlayerNumber );
|
msg.SetParam( "Player", m_pPlayerState->m_PlayerNumber );
|
||||||
msg.SetParam( "LifeMeter", LuaReference::CreateFromPush(*this) );
|
msg.SetParam( "LifeMeter", LuaReference::CreateFromPush(*this) );
|
||||||
msg.SetParam( "LivesLeft", GetLivesLeft() );
|
msg.SetParam( "LivesLeft", GetLivesLeft() );
|
||||||
|
msg.SetParam( "LostLife", bSubtract );
|
||||||
MESSAGEMAN->Broadcast( msg );
|
MESSAGEMAN->Broadcast( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,15 +171,20 @@ void LifeMeterBattery::ChangeLife( HoldNoteScore score, TapNoteScore tscore )
|
|||||||
if( m_iLivesLeft == 0 )
|
if( m_iLivesLeft == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
bool bSubtract = false;
|
||||||
if( score == HNS_Held && HELD_ADD_LIVES > 0 )
|
if( score == HNS_Held && HELD_ADD_LIVES > 0 )
|
||||||
AddLives(HELD_ADD_LIVES);
|
AddLives(HELD_ADD_LIVES);
|
||||||
if( score == HNS_LetGo && LET_GO_SUBTRACT_LIVES > 0 )
|
if( score == HNS_LetGo && LET_GO_SUBTRACT_LIVES > 0 )
|
||||||
|
{
|
||||||
SubtractLives(LET_GO_SUBTRACT_LIVES);
|
SubtractLives(LET_GO_SUBTRACT_LIVES);
|
||||||
|
bSubtract = true;
|
||||||
|
}
|
||||||
|
|
||||||
Message msg( "LifeChanged" );
|
Message msg( "LifeChanged" );
|
||||||
msg.SetParam( "Player", m_pPlayerState->m_PlayerNumber );
|
msg.SetParam( "Player", m_pPlayerState->m_PlayerNumber );
|
||||||
msg.SetParam( "LifeMeter", LuaReference::CreateFromPush(*this) );
|
msg.SetParam( "LifeMeter", LuaReference::CreateFromPush(*this) );
|
||||||
msg.SetParam( "LivesLeft", GetLivesLeft() );
|
msg.SetParam( "LivesLeft", GetLivesLeft() );
|
||||||
|
msg.SetParam( "LostLife", bSubtract );
|
||||||
MESSAGEMAN->Broadcast( msg );
|
MESSAGEMAN->Broadcast( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,41 +228,13 @@ int LifeMeterBattery::GetRemainingLives() const
|
|||||||
}
|
}
|
||||||
void LifeMeterBattery::Refresh()
|
void LifeMeterBattery::Refresh()
|
||||||
{
|
{
|
||||||
// todo: make this restraint metricable + handle non-sprites -aj
|
|
||||||
if( m_iLivesLeft <= 4 )
|
|
||||||
{
|
|
||||||
m_textNumLives.SetText( "" );
|
|
||||||
m_sprBattery.SetState( max(m_iLivesLeft-1,0) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//m_textNumLives.SetText( ssprintf("x%d", m_iLivesLeft-1) );
|
|
||||||
m_textNumLives.SetText( ssprintf(LIVES_FORMAT.GetValue(), m_iLivesLeft-1) );
|
m_textNumLives.SetText( ssprintf(LIVES_FORMAT.GetValue(), m_iLivesLeft-1) );
|
||||||
m_sprBattery.SetState( 3 );
|
//update m_sprBattery
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LifeMeterBattery::Update( float fDeltaTime )
|
void LifeMeterBattery::Update( float fDeltaTime )
|
||||||
{
|
{
|
||||||
LifeMeter::Update( fDeltaTime );
|
LifeMeter::Update( fDeltaTime );
|
||||||
|
|
||||||
if( m_fBatteryBlinkTime > 0 )
|
|
||||||
{
|
|
||||||
m_fBatteryBlinkTime -= fDeltaTime;
|
|
||||||
int iFrame1 = m_iLivesLeft-1;
|
|
||||||
int iFrame2 = m_iTrailingLivesLeft-1;
|
|
||||||
|
|
||||||
int iFrameNo = (int(m_fBatteryBlinkTime*15)%2) ? iFrame1 : iFrame2;
|
|
||||||
CLAMP( iFrameNo, 0, 3 );
|
|
||||||
m_sprBattery.SetState( iFrameNo );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_fBatteryBlinkTime = 0;
|
|
||||||
int iFrameNo = m_iLivesLeft-1;
|
|
||||||
CLAMP( iFrameNo, 0, 3 );
|
|
||||||
m_sprBattery.SetState( iFrameNo );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// lua start
|
// lua start
|
||||||
|
|||||||
@@ -44,8 +44,6 @@ private:
|
|||||||
int m_iLivesLeft; // dead when 0
|
int m_iLivesLeft; // dead when 0
|
||||||
int m_iTrailingLivesLeft; // lags m_iLivesLeft
|
int m_iTrailingLivesLeft; // lags m_iLivesLeft
|
||||||
|
|
||||||
float m_fBatteryBlinkTime; // if > 0 battery is blinking
|
|
||||||
|
|
||||||
ThemeMetric<float> BATTERY_BLINK_TIME;
|
ThemeMetric<float> BATTERY_BLINK_TIME;
|
||||||
ThemeMetric<TapNoteScore> MIN_SCORE_TO_KEEP_LIFE;
|
ThemeMetric<TapNoteScore> MIN_SCORE_TO_KEEP_LIFE;
|
||||||
ThemeMetric<int> DANGER_THRESHOLD;
|
ThemeMetric<int> DANGER_THRESHOLD;
|
||||||
@@ -56,7 +54,7 @@ private:
|
|||||||
ThemeMetric<RString> LIVES_FORMAT;
|
ThemeMetric<RString> LIVES_FORMAT;
|
||||||
|
|
||||||
AutoActor m_sprFrame;
|
AutoActor m_sprFrame;
|
||||||
Sprite m_sprBattery;
|
AutoActor m_sprBattery;
|
||||||
BitmapText m_textNumLives;
|
BitmapText m_textNumLives;
|
||||||
|
|
||||||
PercentageDisplay m_Percent;
|
PercentageDisplay m_Percent;
|
||||||
|
|||||||
Reference in New Issue
Block a user