diff --git a/Docs/Changelog_sm5.txt b/Docs/Changelog_sm5.txt index 0b788553b0..3b604c5943 100644 --- a/Docs/Changelog_sm5.txt +++ b/Docs/Changelog_sm5.txt @@ -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 diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml index dcb99289c2..7529391287 100644 --- a/Docs/Luadoc/LuaDocumentation.xml +++ b/Docs/Luadoc/LuaDocumentation.xml @@ -1237,8 +1237,8 @@ save yourself some time, copy this for undocumented things: Starts the Actor's movement. (Usually used for Sprites or Models.) - - Plays a command named sCommandName. + + Plays a command named sCommandName. params is passed to the command as an argument if it is a table. [02 Actor.lua] Sets the visibility of the Actor based on p being a human player. @@ -1802,11 +1802,15 @@ save yourself some time, copy this for undocumented things: This Actor represents a playable sound. There are two attributes that can be set on load.
* SupportPan - Let the sound pan from side to side.
- * SupportRateChanging - Let the sound change rate and pitch. + * SupportRateChanging - Let the sound change rate and pitch.
+ * IsAction - If true, the sound is an action sound, and will be muted if the MuteActions preference is turned on.
Returns the that can be played by this Actor. + + Returns whether the sound is an action. + Loads the sound at sPath. @@ -1819,6 +1823,9 @@ save yourself some time, copy this for undocumented things: [02 Sound.lua] Plays the sound on the given player's side. You must set SupportPan = true on load. + + Sets whether the sound is an action. + Stops the sound. @@ -2460,8 +2467,8 @@ save yourself some time, copy this for undocumented things: tells the sound manager to apply the current music rate. If alignBeat is true or nil, the length is automatically adjusted to cover an integer number of beats.
- - Play the sound at sPath one time. + + Play the sound at sPath one time. is_action is optional, if it is true, the sound is an action sound, and will be muted if the MuteActions preference is turned on. Stops the music. diff --git a/Themes/default/BGAnimations/Screen cancel/default.lua b/Themes/default/BGAnimations/Screen cancel/default.lua index fa945f224e..6c32c81a02 100644 --- a/Themes/default/BGAnimations/Screen cancel/default.lua +++ b/Themes/default/BGAnimations/Screen cancel/default.lua @@ -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); }; }; \ No newline at end of file diff --git a/Themes/default/BGAnimations/ScreenHeartEntry overlay.lua b/Themes/default/BGAnimations/ScreenHeartEntry overlay.lua index 896d70a37c..b12acd00aa 100644 --- a/Themes/default/BGAnimations/ScreenHeartEntry overlay.lua +++ b/Themes/default/BGAnimations/ScreenHeartEntry overlay.lua @@ -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 diff --git a/Themes/default/BGAnimations/ScreenOptionsCustomizeProfile overlay.lua b/Themes/default/BGAnimations/ScreenOptionsCustomizeProfile overlay.lua index c92063429a..7e7e9fa322 100644 --- a/Themes/default/BGAnimations/ScreenOptionsCustomizeProfile overlay.lua +++ b/Themes/default/BGAnimations/ScreenOptionsCustomizeProfile overlay.lua @@ -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) diff --git a/Themes/default/BGAnimations/ScreenSelectProfile overlay.lua b/Themes/default/BGAnimations/ScreenSelectProfile overlay.lua index 790c54b52e..f01a206f2e 100644 --- a/Themes/default/BGAnimations/ScreenSelectProfile overlay.lua +++ b/Themes/default/BGAnimations/ScreenSelectProfile overlay.lua @@ -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); }; }; diff --git a/src/ActorSound.cpp b/src/ActorSound.cpp index 789f816882..20dd986b33 100644 --- a/src/ActorSound.cpp +++ b/src/ActorSound.cpp @@ -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); } }; diff --git a/src/ActorSound.h b/src/ActorSound.h index 8b1d29d90a..c1dc87b8e4 100644 --- a/src/ActorSound.h +++ b/src/ActorSound.h @@ -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 // diff --git a/src/GameSoundManager.cpp b/src/GameSoundManager.cpp index 73d2153901..5e448a74d7 100644 --- a/src/GameSoundManager.cpp +++ b/src/GameSoundManager.cpp @@ -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; } diff --git a/src/LuaBinding.h b/src/LuaBinding.h index 04a345c202..985ece38d4 100644 --- a/src/LuaBinding.h +++ b/src/LuaBinding.h @@ -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 ); } \ diff --git a/src/RageSound.cpp b/src/RageSound.cpp index 3b4506aec9..771f850e30 100644 --- a/src/RageSound.cpp +++ b/src/RageSound.cpp @@ -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 ) diff --git a/src/RageSound.h b/src/RageSound.h index 787fe4a239..28b32a08d7 100644 --- a/src/RageSound.h +++ b/src/RageSound.h @@ -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, diff --git a/src/RandomSample.cpp b/src/RandomSample.cpp index 1f519422a1..1e9ee8fae4 100644 --- a/src/RandomSample.cpp +++ b/src/RandomSample.cpp @@ -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() diff --git a/src/ScreenOptions.cpp b/src/ScreenOptions.cpp index 3395c43579..9b887c468c 100644 --- a/src/ScreenOptions.cpp +++ b/src/ScreenOptions.cpp @@ -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; } diff --git a/src/ScreenSelectMaster.cpp b/src/ScreenSelectMaster.cpp index f4f42e7257..8c7df2c66f 100644 --- a/src/ScreenSelectMaster.cpp +++ b/src/ScreenSelectMaster.cpp @@ -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() ) { diff --git a/src/ScreenSelectMusic.cpp b/src/ScreenSelectMusic.cpp index 6065f9d27a..6fbe3b253b 100644 --- a/src/ScreenSelectMusic.cpp +++ b/src/ScreenSelectMusic.cpp @@ -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);