diff --git a/Docs/Changelog_sm5.txt b/Docs/Changelog_sm5.txt
index 4bd7b11285..c0cbd0a1f8 100644
--- a/Docs/Changelog_sm5.txt
+++ b/Docs/Changelog_sm5.txt
@@ -4,6 +4,18 @@ The StepMania 5 Changelog covers all post-sm-ssc changes. For a list of changes
from StepMania 4 alpha 5 to sm-ssc v1.2.5, see Changelog_sm-ssc.txt.
________________________________________________________________________________
+2015/12/16
+----------
+* [Player] ChangeLife and SetLife functions added. [kyzentun]
+
+2015/12/13
+----------
+* [popn] Judgment levels in popn game mode now use W1 to W5. [parashep]
+
+2015/12/05
+----------
+* [Player] Guitar mode cruft removed from Player. [tertu]
+
2015/12/04
----------
* [NoteField] Changed DrawBeatBar to check the M-mod so that smaller beat
diff --git a/Docs/Luadoc/Lua.xml b/Docs/Luadoc/Lua.xml
index 89ece30f15..2066bf875e 100644
--- a/Docs/Luadoc/Lua.xml
+++ b/Docs/Luadoc/Lua.xml
@@ -1096,6 +1096,8 @@
+
+
diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml
index 01691ae881..5dd55ca0d6 100644
--- a/Docs/Luadoc/LuaDocumentation.xml
+++ b/Docs/Luadoc/LuaDocumentation.xml
@@ -3366,6 +3366,12 @@ save yourself some time, copy this for undocumented things:
+
+ Changes the life value by delta. This will broadcast a LifeChangedMessageCommand, to allow custom life bars to update to the new value. Do not call ChangeLife from within LifeChangedMessageCommand.
+
+
+ Sets the life to value. This will broadcast a LifeChangedMessageCommand, to allow custom life bars to update to the new value. Do not call SetLife from within LifeChangedMessageCommand.
+
Returns the current TimingData for this player.
diff --git a/src/CombinedLifeMeter.h b/src/CombinedLifeMeter.h
index ea2d2233d7..b44fb46b63 100644
--- a/src/CombinedLifeMeter.h
+++ b/src/CombinedLifeMeter.h
@@ -26,6 +26,8 @@ public:
* @param hns the hold note score recently received.
* @param tns the score from the initial TapNote. */
virtual void ChangeLife( PlayerNumber pn, HoldNoteScore hns, TapNoteScore tns ) = 0;
+ virtual void ChangeLife(PlayerNumber pn, float delta) = 0;
+ virtual void SetLife(PlayerNumber pn, float value) = 0;
virtual void HandleTapScoreNone( PlayerNumber pn ) = 0;
};
diff --git a/src/CombinedLifeMeterTug.cpp b/src/CombinedLifeMeterTug.cpp
index c1d8cfdbfb..3dfa6eab6b 100644
--- a/src/CombinedLifeMeterTug.cpp
+++ b/src/CombinedLifeMeterTug.cpp
@@ -137,6 +137,21 @@ void CombinedLifeMeterTug::ChangeLife( PlayerNumber pn, float fPercentToMove )
}
}
+void CombinedLifeMeterTug::SetLife(PlayerNumber pn, float value)
+{
+ switch(pn)
+ {
+ case PLAYER_1:
+ GAMESTATE->m_fTugLifePercentP1= value;
+ break;
+ case PLAYER_2:
+ GAMESTATE->m_fTugLifePercentP1= 1-value;
+ break;
+ default:
+ FAIL_M(ssprintf("Invalid player number: %i", pn));
+ }
+}
+
/*
* (c) 2003-2004 Chris Danford
* All rights reserved.
diff --git a/src/CombinedLifeMeterTug.h b/src/CombinedLifeMeterTug.h
index 7ce56eb7ed..5b7f7fa62a 100644
--- a/src/CombinedLifeMeterTug.h
+++ b/src/CombinedLifeMeterTug.h
@@ -13,10 +13,11 @@ public:
virtual void ChangeLife( PlayerNumber pn, TapNoteScore score );
virtual void ChangeLife( PlayerNumber pn, HoldNoteScore score, TapNoteScore tscore );
+ virtual void ChangeLife( PlayerNumber pn, float fPercentToMove );
+ virtual void SetLife(PlayerNumber pn, float value);
virtual void HandleTapScoreNone( PlayerNumber pn );
protected:
- void ChangeLife( PlayerNumber pn, float fPercentToMove );
MeterDisplay m_Stream[NUM_PLAYERS];
AutoActor m_sprSeparator;
diff --git a/src/LifeMeter.h b/src/LifeMeter.h
index 7f56e1e756..a9ae3c51ec 100644
--- a/src/LifeMeter.h
+++ b/src/LifeMeter.h
@@ -34,6 +34,8 @@ public:
* @param hns the hold note grade in question.
* @param tns the score received for the initial tap note. */
virtual void ChangeLife( HoldNoteScore hns, TapNoteScore tns ) = 0;
+ virtual void ChangeLife(float delta) = 0;
+ virtual void SetLife(float value) = 0;
virtual void HandleTapScoreNone() = 0;
virtual bool IsInDanger() const = 0;
virtual bool IsHot() const = 0;
diff --git a/src/LifeMeterBar.cpp b/src/LifeMeterBar.cpp
index a078037d28..f30d8d6801 100644
--- a/src/LifeMeterBar.cpp
+++ b/src/LifeMeterBar.cpp
@@ -249,6 +249,13 @@ void LifeMeterBar::ChangeLife( float fDeltaLife )
AfterLifeChanged();
}
+void LifeMeterBar::SetLife(float value)
+{
+ m_fLifePercentage= value;
+ CLAMP( m_fLifePercentage, 0, LIFE_MULTIPLIER );
+ AfterLifeChanged();
+}
+
extern ThemeMetric PENALIZE_TAP_SCORE_NONE;
void LifeMeterBar::HandleTapScoreNone()
{
diff --git a/src/LifeMeterBar.h b/src/LifeMeterBar.h
index 7de5686fb3..af5f1904b1 100644
--- a/src/LifeMeterBar.h
+++ b/src/LifeMeterBar.h
@@ -22,6 +22,7 @@ public:
virtual void ChangeLife( TapNoteScore score );
virtual void ChangeLife( HoldNoteScore score, TapNoteScore tscore );
virtual void ChangeLife( float fDeltaLifePercent );
+ virtual void SetLife(float value);
virtual void HandleTapScoreNone();
virtual void AfterLifeChanged();
virtual bool IsInDanger() const;
diff --git a/src/LifeMeterBattery.cpp b/src/LifeMeterBattery.cpp
index 8378ab5a93..f02216adff 100644
--- a/src/LifeMeterBattery.cpp
+++ b/src/LifeMeterBattery.cpp
@@ -169,13 +169,7 @@ void LifeMeterBattery::ChangeLife( TapNoteScore score )
bSubtract = true;
}
}
-
- Message msg( "LifeChanged" );
- msg.SetParam( "Player", m_pPlayerState->m_PlayerNumber );
- msg.SetParam( "LifeMeter", LuaReference::CreateFromPush(*this) );
- msg.SetParam( "LivesLeft", GetLivesLeft() );
- msg.SetParam( "LostLife", bSubtract );
- MESSAGEMAN->Broadcast( msg );
+ BroadcastLifeChanged(bSubtract);
}
void LifeMeterBattery::ChangeLife( HoldNoteScore score, TapNoteScore tscore )
@@ -191,13 +185,25 @@ void LifeMeterBattery::ChangeLife( HoldNoteScore score, TapNoteScore tscore )
SubtractLives(LET_GO_SUBTRACT_LIVES);
bSubtract = true;
}
+ BroadcastLifeChanged(bSubtract);
+}
- Message msg( "LifeChanged" );
- msg.SetParam( "Player", m_pPlayerState->m_PlayerNumber );
- msg.SetParam( "LifeMeter", LuaReference::CreateFromPush(*this) );
- msg.SetParam( "LivesLeft", GetLivesLeft() );
- msg.SetParam( "LostLife", bSubtract );
- MESSAGEMAN->Broadcast( msg );
+void LifeMeterBattery::SetLife(float value)
+{
+ int new_lives= static_cast(value);
+ bool lost= (new_lives < m_iLivesLeft);
+ m_iLivesLeft= new_lives;
+ BroadcastLifeChanged(lost);
+}
+
+void LifeMeterBattery::BroadcastLifeChanged(bool lost_life)
+{
+ Message msg("LifeChanged");
+ msg.SetParam("Player", m_pPlayerState->m_PlayerNumber);
+ msg.SetParam("LifeMeter", LuaReference::CreateFromPush(*this));
+ msg.SetParam("LivesLeft", GetLivesLeft());
+ msg.SetParam("LostLife", lost_life);
+ MESSAGEMAN->Broadcast(msg);
}
void LifeMeterBattery::HandleTapScoreNone()
diff --git a/src/LifeMeterBattery.h b/src/LifeMeterBattery.h
index e56e87822e..f6fb8b6f33 100644
--- a/src/LifeMeterBattery.h
+++ b/src/LifeMeterBattery.h
@@ -23,6 +23,7 @@ public:
virtual void ChangeLife( TapNoteScore score );
virtual void ChangeLife( HoldNoteScore score, TapNoteScore tscore );
virtual void ChangeLife( float fDeltaLifePercent );
+ virtual void SetLife(float value);
virtual void HandleTapScoreNone();
virtual bool IsInDanger() const;
virtual bool IsHot() const;
@@ -30,6 +31,8 @@ public:
virtual float GetLife() const;
virtual int GetRemainingLives() const;
+ virtual void BroadcastLifeChanged(bool lost_life);
+
void Refresh();
int GetLivesLeft() { return m_iLivesLeft; }
int GetTotalLives();
diff --git a/src/LifeMeterTime.cpp b/src/LifeMeterTime.cpp
index fc16386927..2c144f3bfa 100644
--- a/src/LifeMeterTime.cpp
+++ b/src/LifeMeterTime.cpp
@@ -178,6 +178,20 @@ void LifeMeterTime::ChangeLife( HoldNoteScore hns, TapNoteScore tns )
SendLifeChangedMessage( fOldLife, tns, hns );
}
+void LifeMeterTime::ChangeLife(float delta)
+{
+ float old_life= m_fLifeTotalLostSeconds;
+ m_fLifeTotalLostSeconds-= delta;
+ SendLifeChangedMessage(old_life, TapNoteScore_Invalid, HoldNoteScore_Invalid);
+}
+
+void LifeMeterTime::SetLife(float value)
+{
+ float old_life= m_fLifeTotalLostSeconds;
+ m_fLifeTotalLostSeconds= value;
+ SendLifeChangedMessage(old_life, TapNoteScore_Invalid, HoldNoteScore_Invalid);
+}
+
void LifeMeterTime::HandleTapScoreNone()
{
// do nothing.
diff --git a/src/LifeMeterTime.h b/src/LifeMeterTime.h
index c975286739..aca1c4b9fb 100644
--- a/src/LifeMeterTime.h
+++ b/src/LifeMeterTime.h
@@ -25,6 +25,8 @@ public:
virtual void OnLoadSong();
virtual void ChangeLife( TapNoteScore score );
virtual void ChangeLife( HoldNoteScore score, TapNoteScore tscore );
+ virtual void ChangeLife(float delta);
+ virtual void SetLife(float value);
virtual void HandleTapScoreNone();
virtual bool IsInDanger() const;
virtual bool IsHot() const;
diff --git a/src/Player.cpp b/src/Player.cpp
index e3a88c3d0f..d1143f0aae 100644
--- a/src/Player.cpp
+++ b/src/Player.cpp
@@ -235,6 +235,7 @@ Player::Player( NoteData &nd, bool bVisibleParts ) : m_NoteData(nd)
{
m_drawing_notefield_board= false;
m_bLoaded = false;
+ m_inside_lua_set_life= false;
m_pPlayerState = NULL;
m_pPlayerStageStats = NULL;
@@ -1684,6 +1685,44 @@ void Player::ChangeLife( HoldNoteScore hns, TapNoteScore tns )
ChangeLifeRecord();
}
+void Player::ChangeLife(float delta)
+{
+ // If ChangeLifeRecord is not called before the change, then the life graph
+ // will show a gradual change from the time of the previous step (or
+ // change) to the time of this change, instead of the sharp change that
+ // actually occurred. -Kyz
+ ChangeLifeRecord();
+ PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
+ if(m_pLifeMeter)
+ {
+ m_pLifeMeter->ChangeLife(delta);
+ }
+ if(m_pCombinedLifeMeter)
+ {
+ m_pCombinedLifeMeter->ChangeLife(pn, delta);
+ }
+ ChangeLifeRecord();
+}
+
+void Player::SetLife(float value)
+{
+ // If ChangeLifeRecord is not called before the change, then the life graph
+ // will show a gradual change from the time of the previous step (or
+ // change) to the time of this change, instead of the sharp change that
+ // actually occurred. -Kyz
+ ChangeLifeRecord();
+ PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
+ if(m_pLifeMeter)
+ {
+ m_pLifeMeter->SetLife(value);
+ }
+ if(m_pCombinedLifeMeter)
+ {
+ m_pCombinedLifeMeter->SetLife(pn, value);
+ }
+ ChangeLifeRecord();
+}
+
void Player::ChangeLifeRecord()
{
PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
@@ -3238,6 +3277,28 @@ RString Player::ApplyRandomAttack()
class LunaPlayer: public Luna
{
public:
+ static int SetLife(T* p, lua_State* L)
+ {
+ if(p->m_inside_lua_set_life)
+ {
+ luaL_error(L, "Do not call SetLife from inside LifeChangedMessageCommand because SetLife causes a LifeChangedMessageCommand.");
+ }
+ p->m_inside_lua_set_life= true;
+ p->SetLife(FArg(1));
+ p->m_inside_lua_set_life= false;
+ COMMON_RETURN_SELF;
+ }
+ static int ChangeLife(T* p, lua_State* L)
+ {
+ if(p->m_inside_lua_set_life)
+ {
+ luaL_error(L, "Do not call ChangeLife from inside LifeChangedMessageCommand because ChangeLife causes a LifeChangedMessageCommand.");
+ }
+ p->m_inside_lua_set_life= true;
+ p->ChangeLife(FArg(1));
+ p->m_inside_lua_set_life= false;
+ COMMON_RETURN_SELF;
+ }
static int SetActorWithJudgmentPosition( T* p, lua_State *L )
{
Actor *pActor = Luna::check(L, 1);
@@ -3258,6 +3319,8 @@ public:
LunaPlayer()
{
+ ADD_METHOD(SetLife);
+ ADD_METHOD(ChangeLife);
ADD_METHOD( SetActorWithJudgmentPosition );
ADD_METHOD( SetActorWithComboPosition );
ADD_METHOD( GetPlayerTimingData );
diff --git a/src/Player.h b/src/Player.h
index 6f18901152..955f257e7d 100644
--- a/src/Player.h
+++ b/src/Player.h
@@ -128,6 +128,9 @@ public:
virtual void PushSelf( lua_State *L );
PlayerState * GetPlayerState() { return this->m_pPlayerState; }
+ void ChangeLife(float delta);
+ void SetLife(float value);
+ bool m_inside_lua_set_life;
protected:
void UpdateTapNotesMissedOlderThan( float fMissIfOlderThanThisBeat );