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
+6
View File
@@ -4,6 +4,12 @@ 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. from StepMania 4 alpha 5 to sm-ssc v1.2.5, see Changelog_sm-ssc.txt.
________________________________________________________________________________ ________________________________________________________________________________
2015/04/08
----------
* [ActorSound] IsAction attribute added. get/set_is_action functions added.
[kyzentun]
* [GameSoundManager] is_action arg added to PlayOnce. [kyzentun]
2015/04/06 2015/04/06
---------- ----------
* [global] rec_print_children and rec_print_table lua functions added to * [global] rec_print_children and rec_print_table lua functions added to
+12 -5
View File
@@ -1237,8 +1237,8 @@ save yourself some time, copy this for undocumented things:
<Function name='play' return='void' arguments=''> <Function name='play' return='void' arguments=''>
Starts the Actor's movement. (Usually used for Sprites or Models.) Starts the Actor's movement. (Usually used for Sprites or Models.)
</Function> </Function>
<Function name='playcommand' return='void' arguments='string sCommandName'> <Function name='playcommand' return='void' arguments='string sCommandName, table params'>
Plays a command named <code>sCommandName</code>. Plays a command named <code>sCommandName</code>. <code>params</code> is passed to the command as an argument if it is a table.
</Function> </Function>
<Function name='player' theme='_fallback' return='void' arguments='PlayerNumber p'> <Function name='player' theme='_fallback' return='void' arguments='PlayerNumber p'>
[02 Actor.lua] Sets the visibility of the Actor based on <code>p</code> being a human player. [02 Actor.lua] Sets the visibility of the Actor based on <code>p</code> being a human player.
@@ -1802,11 +1802,15 @@ save yourself some time, copy this for undocumented things:
<Description> <Description>
This Actor represents a playable sound. There are two attributes that can be set on load.<br /> This Actor represents a playable sound. There are two attributes that can be set on load.<br />
* <code>SupportPan</code> - Let the sound pan from side to side.<br /> * <code>SupportPan</code> - Let the sound pan from side to side.<br />
* <code>SupportRateChanging</code> - Let the sound change rate and pitch. * <code>SupportRateChanging</code> - Let the sound change rate and pitch.<br />
* <code>IsAction</code> - If true, the sound is an action sound, and will be muted if the MuteActions preference is turned on.
</Description> </Description>
<Function name='get' return='RageSound' arguments=''> <Function name='get' return='RageSound' arguments=''>
Returns the <Link class='RageSound' /> that can be played by this Actor. Returns the <Link class='RageSound' /> that can be played by this Actor.
</Function> </Function>
<Function name='get_is_action' return='bool' arguments=''>
Returns whether the sound is an action.
</Function>
<Function name='load' return='void' arguments='string sPath'> <Function name='load' return='void' arguments='string sPath'>
Loads the sound at <code>sPath</code>. Loads the sound at <code>sPath</code>.
</Function> </Function>
@@ -1819,6 +1823,9 @@ save yourself some time, copy this for undocumented things:
<Function name='playforplayer' theme='_fallback' return='void' arguments='PlayerNumber pn'> <Function name='playforplayer' theme='_fallback' return='void' arguments='PlayerNumber pn'>
[02 Sound.lua] Plays the sound on the given player's side. You must set <code>SupportPan = true</code> on load. [02 Sound.lua] Plays the sound on the given player's side. You must set <code>SupportPan = true</code> on load.
</Function> </Function>
<Function name='set_is_action' return='' arguments='bool is_action'>
Sets whether the sound is an action.
</Function>
<Function name='stop' return='void' arguments=''> <Function name='stop' return='void' arguments=''>
Stops the sound. Stops the sound.
</Function> </Function>
@@ -2460,8 +2467,8 @@ save yourself some time, copy this for undocumented things:
tells the sound manager to apply the current music rate. If <code>alignBeat</code> tells the sound manager to apply the current music rate. If <code>alignBeat</code>
is true or nil, the length is automatically adjusted to cover an integer number of beats. is true or nil, the length is automatically adjusted to cover an integer number of beats.
</Function> </Function>
<Function name='PlayOnce' return='void' arguments='string sPath'> <Function name='PlayOnce' return='void' arguments='string sPath, bool is_action'>
Play the sound at <code>sPath</code> one time. Play the sound at <code>sPath</code> one time. <code>is_action</code> is optional, if it is true, the sound is an action sound, and will be muted if the MuteActions preference is turned on.
</Function> </Function>
<Function name='StopMusic' return='void' arguments='void'> <Function name='StopMusic' return='void' arguments='void'>
Stops the music. Stops the music.
@@ -4,6 +4,7 @@ return Def.ActorFrame {
OnCommand=cmd(diffuse,color("0,0,0,0.5");sleep,5/60;diffusealpha,1;sleep,5/60); OnCommand=cmd(diffuse,color("0,0,0,0.5");sleep,5/60;diffusealpha,1;sleep,5/60);
}; };
LoadActor(THEME:GetPathS("_Screen","cancel")) .. { LoadActor(THEME:GetPathS("_Screen","cancel")) .. {
IsAction= true,
StartTransitioningCommand=cmd(play); StartTransitioningCommand=cmd(play);
}; };
}; };
@@ -83,7 +83,7 @@ local function input(event)
if not heart_entries[pn] then return end if not heart_entries[pn] then return end
local done= heart_entries[pn]:handle_input(event.GameButton) local done= heart_entries[pn]:handle_input(event.GameButton)
if done then if done then
SOUND:PlayOnce(THEME:GetPathS("Common", "Start")) SOUND:PlayOnce(THEME:GetPathS("Common", "Start"), true)
local all_done= true local all_done= true
for pn, entry in pairs(heart_entries) do for pn, entry in pairs(heart_entries) do
if not entry.done then all_done= false break end if not entry.done then all_done= false break end
@@ -243,7 +243,7 @@ local function exit_screen()
local profile_id= GAMESTATE:GetEditLocalProfileID() local profile_id= GAMESTATE:GetEditLocalProfileID()
PROFILEMAN:SaveLocalProfile(profile_id) PROFILEMAN:SaveLocalProfile(profile_id)
SCREENMAN:GetTopScreen():StartTransitioningScreen("SM_GoToNextScreen") SCREENMAN:GetTopScreen():StartTransitioningScreen("SM_GoToNextScreen")
SOUND:PlayOnce(THEME:GetPathS("Common", "Start")) SOUND:PlayOnce(THEME:GetPathS("Common", "Start"), true)
end end
local function input(event) local function input(event)
@@ -300,12 +300,15 @@ local t = Def.ActorFrame {
}; };
-- sounds -- sounds
LoadActor( THEME:GetPathS("Common","start") )..{ LoadActor( THEME:GetPathS("Common","start") )..{
IsAction= true,
StartButtonMessageCommand=cmd(play); StartButtonMessageCommand=cmd(play);
}; };
LoadActor( THEME:GetPathS("Common","cancel") )..{ LoadActor( THEME:GetPathS("Common","cancel") )..{
IsAction= true,
BackButtonMessageCommand=cmd(play); BackButtonMessageCommand=cmd(play);
}; };
LoadActor( THEME:GetPathS("Common","value") )..{ LoadActor( THEME:GetPathS("Common","value") )..{
IsAction= true,
DirectionButtonMessageCommand=cmd(play); DirectionButtonMessageCommand=cmd(play);
}; };
}; };
+9 -1
View File
@@ -14,7 +14,7 @@ void ActorSound::Load( const RString &sPath )
void ActorSound::Play() void ActorSound::Play()
{ {
m_Sound.Play(false); m_Sound.Play(m_is_action);
} }
void ActorSound::Pause( bool bPause ) void ActorSound::Pause( bool bPause )
@@ -32,6 +32,7 @@ void ActorSound::LoadFromNode( const XNode* pNode )
RageSoundLoadParams params; RageSoundLoadParams params;
pNode->GetAttrValue("SupportPan", params.m_bSupportPan); pNode->GetAttrValue("SupportPan", params.m_bSupportPan);
pNode->GetAttrValue("SupportRateChanging", params.m_bSupportRateChanging); pNode->GetAttrValue("SupportRateChanging", params.m_bSupportRateChanging);
pNode->GetAttrValue("IsAction", m_is_action);
bool bPrecache = true; bool bPrecache = true;
pNode->GetAttrValue( "Precache", bPrecache ); 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 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 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 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() LunaActorSound()
{ {
@@ -63,6 +70,7 @@ public:
ADD_METHOD( pause ); ADD_METHOD( pause );
ADD_METHOD( stop ); ADD_METHOD( stop );
ADD_METHOD( get ); ADD_METHOD( get );
ADD_GET_SET_METHODS(is_action);
} }
}; };
+5
View File
@@ -7,6 +7,9 @@
class ActorSound: public Actor class ActorSound: public Actor
{ {
public: public:
ActorSound()
:m_is_action(false)
{}
virtual ~ActorSound() { } virtual ~ActorSound() { }
virtual ActorSound *Copy() const; virtual ActorSound *Copy() const;
@@ -17,6 +20,8 @@ public:
void LoadFromNode( const XNode* pNode ); void LoadFromNode( const XNode* pNode );
void PushSound( lua_State *L ) { m_Sound.PushSelf( L ); } void PushSound( lua_State *L ) { m_Sound.PushSelf( L ); }
bool m_is_action;
// //
// Lua // Lua
// //
+4
View File
@@ -800,6 +800,10 @@ public:
static int PlayOnce( T* p, lua_State *L ) static int PlayOnce( T* p, lua_State *L )
{ {
RString sPath = SArg(1); RString sPath = SArg(1);
if(lua_toboolean(L, 2) && PREFSMAN->m_MuteActions)
{
COMMON_RETURN_SELF;
}
p->PlayOnce( sPath ); p->PlayOnce( sPath );
COMMON_RETURN_SELF; COMMON_RETURN_SELF;
} }
+2
View File
@@ -165,6 +165,8 @@ public:
#define ADD_METHOD( method_name ) \ #define ADD_METHOD( method_name ) \
AddMethod( #method_name, 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 ) \ #define LUA_REGISTER_NAMESPACE( T ) \
static void Register##T( lua_State *L ) { luaL_register( L, #T, T##Table ); lua_pop( L, 1 ); } \ 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() ) if( IsPlaying() )
{ {
PlayCopy( pParams ); PlayCopy(is_action, pParams);
return; return;
} }
@@ -416,8 +416,12 @@ void RageSound::Play(bool is_action, const RageSoundParams *pParams)
StartPlaying(); 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 ); RageSound *pSound = new RageSound( *this );
if( pParams ) if( pParams )
+1 -1
View File
@@ -121,7 +121,7 @@ public:
RString GetError() const { return m_sError; } RString GetError() const { return m_sError; }
void Play(bool is_action, const RageSoundParams *params=NULL); 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(); void Stop();
/* Cleanly pause or unpause the sound. If the sound wasn't already playing, /* 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(); int iIndexToPlay = GetNextToPlay();
if( iIndexToPlay == -1 ) if( iIndexToPlay == -1 )
return; return;
m_pSamples[iIndexToPlay]->PlayCopy(); m_pSamples[iIndexToPlay]->PlayCopy(true);
} }
void RandomSample::Stop() void RandomSample::Stop()
+2 -2
View File
@@ -831,7 +831,7 @@ void ScreenOptions::ProcessMenuStart( const InputEventPlus &input )
if( iCurRow < 0 ) if( iCurRow < 0 )
{ {
// this shouldn't be happening, but it is, so we need to bail out. -aj // this shouldn't be happening, but it is, so we need to bail out. -aj
m_SoundStart.PlayCopy(); m_SoundStart.PlayCopy(true);
this->BeginFadingOut(); this->BeginFadingOut();
return; return;
} }
@@ -875,7 +875,7 @@ void ScreenOptions::ProcessMenuStart( const InputEventPlus &input )
if( bEndThisScreen ) if( bEndThisScreen )
{ {
m_SoundStart.PlayCopy(); m_SoundStart.PlayCopy(true);
this->BeginFadingOut(); this->BeginFadingOut();
return; 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 // double press is enabled and the player hasn't made their first press
if(DOUBLE_PRESS_TO_SELECT && !m_bDoubleChoice[pn]) if(DOUBLE_PRESS_TO_SELECT && !m_bDoubleChoice[pn])
{ {
m_soundStart.PlayCopy(); m_soundStart.PlayCopy(true);
m_bDoubleChoice[pn] = true; m_bDoubleChoice[pn] = true;
if(SHOW_SCROLLER) 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. // 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 ) if( mc->m_sSoundPath.empty() && !m_bDoubleChoiceNoSound )
m_soundStart.PlayCopy(); m_soundStart.PlayCopy(true);
if( mc->m_sScreen.empty() ) if( mc->m_sScreen.empty() )
{ {
+2 -2
View File
@@ -1066,12 +1066,12 @@ void ScreenSelectMusic::ChangeSteps( PlayerNumber pn, int dir )
if( dir < 0 ) if( dir < 0 )
{ {
m_soundDifficultyEasier.SetProperty( "Pan", fBalance ); m_soundDifficultyEasier.SetProperty( "Pan", fBalance );
m_soundDifficultyEasier.PlayCopy(); m_soundDifficultyEasier.PlayCopy(true);
} }
else else
{ {
m_soundDifficultyHarder.SetProperty( "Pan", fBalance ); m_soundDifficultyHarder.SetProperty( "Pan", fBalance );
m_soundDifficultyHarder.PlayCopy(); m_soundDifficultyHarder.PlayCopy(true);
} }
GAMESTATE->ForceOtherPlayersToCompatibleSteps(pn); GAMESTATE->ForceOtherPlayersToCompatibleSteps(pn);