Added MuteActions preference checking to RageSound::PlayCopy. Modified ActorSound and GameSoundManager::PlayOnce to take is_action args. Fixed doc for playcommand to mention the param table.

This commit is contained in:
Kyzentun
2015-04-08 16:15:14 -06:00
parent 84b57e7ca4
commit 8993cfe729
16 changed files with 58 additions and 18 deletions
+9 -1
View File
@@ -14,7 +14,7 @@ void ActorSound::Load( const RString &sPath )
void ActorSound::Play()
{
m_Sound.Play(false);
m_Sound.Play(m_is_action);
}
void ActorSound::Pause( bool bPause )
@@ -32,6 +32,7 @@ void ActorSound::LoadFromNode( const XNode* pNode )
RageSoundLoadParams params;
pNode->GetAttrValue("SupportPan", params.m_bSupportPan);
pNode->GetAttrValue("SupportRateChanging", params.m_bSupportRateChanging);
pNode->GetAttrValue("IsAction", m_is_action);
bool bPrecache = true;
pNode->GetAttrValue( "Precache", bPrecache );
@@ -55,6 +56,12 @@ public:
static int pause( T* p, lua_State *L ) { p->Pause(BArg(1)); COMMON_RETURN_SELF; }
static int stop( T* p, lua_State *L ) { p->Stop(); COMMON_RETURN_SELF; }
static int get( T* p, lua_State *L ) { p->PushSound( L ); return 1; }
static int set_is_action(T* p, lua_State* L)
{
p->m_is_action= BArg(1);
COMMON_RETURN_SELF;
}
DEFINE_METHOD(get_is_action, m_is_action);
LunaActorSound()
{
@@ -63,6 +70,7 @@ public:
ADD_METHOD( pause );
ADD_METHOD( stop );
ADD_METHOD( get );
ADD_GET_SET_METHODS(is_action);
}
};
+5
View File
@@ -7,6 +7,9 @@
class ActorSound: public Actor
{
public:
ActorSound()
:m_is_action(false)
{}
virtual ~ActorSound() { }
virtual ActorSound *Copy() const;
@@ -17,6 +20,8 @@ public:
void LoadFromNode( const XNode* pNode );
void PushSound( lua_State *L ) { m_Sound.PushSelf( L ); }
bool m_is_action;
//
// Lua
//
+4
View File
@@ -800,6 +800,10 @@ public:
static int PlayOnce( T* p, lua_State *L )
{
RString sPath = SArg(1);
if(lua_toboolean(L, 2) && PREFSMAN->m_MuteActions)
{
COMMON_RETURN_SELF;
}
p->PlayOnce( sPath );
COMMON_RETURN_SELF;
}
+2
View File
@@ -165,6 +165,8 @@ public:
#define ADD_METHOD( method_name ) \
AddMethod( #method_name, method_name )
#define ADD_GET_SET_METHODS(method_name) \
ADD_METHOD(get_##method_name); ADD_METHOD(set_##method_name);
#define LUA_REGISTER_NAMESPACE( T ) \
static void Register##T( lua_State *L ) { luaL_register( L, #T, T##Table ); lua_pop( L, 1 ); } \
+6 -2
View File
@@ -406,7 +406,7 @@ void RageSound::Play(bool is_action, const RageSoundParams *pParams)
if( IsPlaying() )
{
PlayCopy( pParams );
PlayCopy(is_action, pParams);
return;
}
@@ -416,8 +416,12 @@ void RageSound::Play(bool is_action, const RageSoundParams *pParams)
StartPlaying();
}
void RageSound::PlayCopy( const RageSoundParams *pParams ) const
void RageSound::PlayCopy(bool is_action, const RageSoundParams *pParams) const
{
if(is_action && PREFSMAN->m_MuteActions)
{
return;
}
RageSound *pSound = new RageSound( *this );
if( pParams )
+1 -1
View File
@@ -121,7 +121,7 @@ public:
RString GetError() const { return m_sError; }
void Play(bool is_action, const RageSoundParams *params=NULL);
void PlayCopy( const RageSoundParams *pParams = NULL ) const;
void PlayCopy(bool is_action, const RageSoundParams *pParams = NULL) const;
void Stop();
/* Cleanly pause or unpause the sound. If the sound wasn't already playing,
+1 -1
View File
@@ -114,7 +114,7 @@ void RandomSample::PlayCopyOfRandom()
int iIndexToPlay = GetNextToPlay();
if( iIndexToPlay == -1 )
return;
m_pSamples[iIndexToPlay]->PlayCopy();
m_pSamples[iIndexToPlay]->PlayCopy(true);
}
void RandomSample::Stop()
+2 -2
View File
@@ -831,7 +831,7 @@ void ScreenOptions::ProcessMenuStart( const InputEventPlus &input )
if( iCurRow < 0 )
{
// this shouldn't be happening, but it is, so we need to bail out. -aj
m_SoundStart.PlayCopy();
m_SoundStart.PlayCopy(true);
this->BeginFadingOut();
return;
}
@@ -875,7 +875,7 @@ void ScreenOptions::ProcessMenuStart( const InputEventPlus &input )
if( bEndThisScreen )
{
m_SoundStart.PlayCopy();
m_SoundStart.PlayCopy(true);
this->BeginFadingOut();
return;
}
+2 -2
View File
@@ -925,7 +925,7 @@ bool ScreenSelectMaster::MenuStart( const InputEventPlus &input )
// double press is enabled and the player hasn't made their first press
if(DOUBLE_PRESS_TO_SELECT && !m_bDoubleChoice[pn])
{
m_soundStart.PlayCopy();
m_soundStart.PlayCopy(true);
m_bDoubleChoice[pn] = true;
if(SHOW_SCROLLER)
@@ -954,7 +954,7 @@ bool ScreenSelectMaster::MenuStart( const InputEventPlus &input )
// Play a copy of the sound, so it'll finish playing even if we leave the screen immediately.
if( mc->m_sSoundPath.empty() && !m_bDoubleChoiceNoSound )
m_soundStart.PlayCopy();
m_soundStart.PlayCopy(true);
if( mc->m_sScreen.empty() )
{
+2 -2
View File
@@ -1066,12 +1066,12 @@ void ScreenSelectMusic::ChangeSteps( PlayerNumber pn, int dir )
if( dir < 0 )
{
m_soundDifficultyEasier.SetProperty( "Pan", fBalance );
m_soundDifficultyEasier.PlayCopy();
m_soundDifficultyEasier.PlayCopy(true);
}
else
{
m_soundDifficultyHarder.SetProperty( "Pan", fBalance );
m_soundDifficultyHarder.PlayCopy();
m_soundDifficultyHarder.PlayCopy(true);
}
GAMESTATE->ForceOtherPlayersToCompatibleSteps(pn);