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.
________________________________________________________________________________
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
----------
* [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=''>
Starts the Actor's movement. (Usually used for Sprites or Models.)
</Function>
<Function name='playcommand' return='void' arguments='string sCommandName'>
Plays a command named <code>sCommandName</code>.
<Function name='playcommand' return='void' arguments='string sCommandName, table params'>
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 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.
@@ -1802,11 +1802,15 @@ save yourself some time, copy this for undocumented things:
<Description>
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>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>
<Function name='get' return='RageSound' arguments=''>
Returns the <Link class='RageSound' /> that can be played by this Actor.
</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'>
Loads the sound at <code>sPath</code>.
</Function>
@@ -1819,6 +1823,9 @@ save yourself some time, copy this for undocumented things:
<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.
</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=''>
Stops the sound.
</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>
is true or nil, the length is automatically adjusted to cover an integer number of beats.
</Function>
<Function name='PlayOnce' return='void' arguments='string sPath'>
Play the sound at <code>sPath</code> one time.
<Function name='PlayOnce' return='void' arguments='string sPath, bool is_action'>
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 name='StopMusic' return='void' arguments='void'>
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);
};
LoadActor(THEME:GetPathS("_Screen","cancel")) .. {
IsAction= true,
StartTransitioningCommand=cmd(play);
};
};
@@ -83,7 +83,7 @@ local function input(event)
if not heart_entries[pn] then return end
local done= heart_entries[pn]:handle_input(event.GameButton)
if done then
SOUND:PlayOnce(THEME:GetPathS("Common", "Start"))
SOUND:PlayOnce(THEME:GetPathS("Common", "Start"), true)
local all_done= true
for pn, entry in pairs(heart_entries) do
if not entry.done then all_done= false break end
@@ -243,7 +243,7 @@ local function exit_screen()
local profile_id= GAMESTATE:GetEditLocalProfileID()
PROFILEMAN:SaveLocalProfile(profile_id)
SCREENMAN:GetTopScreen():StartTransitioningScreen("SM_GoToNextScreen")
SOUND:PlayOnce(THEME:GetPathS("Common", "Start"))
SOUND:PlayOnce(THEME:GetPathS("Common", "Start"), true)
end
local function input(event)
@@ -300,12 +300,15 @@ local t = Def.ActorFrame {
};
-- sounds
LoadActor( THEME:GetPathS("Common","start") )..{
IsAction= true,
StartButtonMessageCommand=cmd(play);
};
LoadActor( THEME:GetPathS("Common","cancel") )..{
IsAction= true,
BackButtonMessageCommand=cmd(play);
};
LoadActor( THEME:GetPathS("Common","value") )..{
IsAction= true,
DirectionButtonMessageCommand=cmd(play);
};
};
+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);