mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-04 02:41:19 +00:00
Merge branch 'streammusic_fade' into 'master'
Add a table with fadeOut argument for streamMusic See merge request OpenMW/openmw!3774
This commit is contained in:
commit
68c280a493
@ -23,6 +23,11 @@ namespace
|
||||
float mTimeOffset = 0.f;
|
||||
};
|
||||
|
||||
struct StreamMusicArgs
|
||||
{
|
||||
float mFade = 1.f;
|
||||
};
|
||||
|
||||
PlaySoundArgs getPlaySoundArgs(const sol::optional<sol::table>& options)
|
||||
{
|
||||
PlaySoundArgs args;
|
||||
@ -55,6 +60,17 @@ namespace
|
||||
return MWSound::PlayMode::NoEnvNoScaling;
|
||||
return MWSound::PlayMode::NoEnv;
|
||||
}
|
||||
|
||||
StreamMusicArgs getStreamMusicArgs(const sol::optional<sol::table>& options)
|
||||
{
|
||||
StreamMusicArgs args;
|
||||
|
||||
if (options.has_value())
|
||||
{
|
||||
args.mFade = options->get_or("fadeOut", 1.f);
|
||||
}
|
||||
return args;
|
||||
}
|
||||
}
|
||||
|
||||
namespace MWLua
|
||||
@ -95,9 +111,10 @@ namespace MWLua
|
||||
return MWBase::Environment::get().getSoundManager()->getSoundPlaying(MWWorld::Ptr(), fileName);
|
||||
};
|
||||
|
||||
api["streamMusic"] = [](std::string_view fileName) {
|
||||
api["streamMusic"] = [](std::string_view fileName, const sol::optional<sol::table>& options) {
|
||||
auto args = getStreamMusicArgs(options);
|
||||
MWBase::SoundManager* sndMgr = MWBase::Environment::get().getSoundManager();
|
||||
sndMgr->streamMusic(std::string(fileName), MWSound::MusicType::Scripted);
|
||||
sndMgr->streamMusic(std::string(fileName), MWSound::MusicType::Scripted, args.mFade);
|
||||
};
|
||||
|
||||
api["isMusicPlaying"] = []() { return MWBase::Environment::get().getSoundManager()->isMusicPlaying(); };
|
||||
|
@ -12,7 +12,7 @@
|
||||
-- @param #string soundId ID of Sound record to play
|
||||
-- @param #table options An optional table with additional optional arguments. Can contain:
|
||||
--
|
||||
-- * `timeOffset` - a floating point number >= 0, to some time (in second) from beginning of sound file (default: 0);
|
||||
-- * `timeOffset` - a floating point number >= 0, to skip some time (in seconds) from beginning of sound file (default: 0);
|
||||
-- * `volume` - a floating point number >= 0, to set a sound volume (default: 1);
|
||||
-- * `pitch` - a floating point number >= 0, to set a sound pitch (default: 1);
|
||||
-- * `scale` - a boolean, to set if sound pitch should be scaled by simulation time scaling (default: true);
|
||||
@ -32,7 +32,7 @@
|
||||
-- @param #string fileName Path to sound file in VFS
|
||||
-- @param #table options An optional table with additional optional arguments. Can contain:
|
||||
--
|
||||
-- * `timeOffset` - a floating point number >= 0, to some time (in second) from beginning of sound file (default: 0);
|
||||
-- * `timeOffset` - a floating point number >= 0, to skip some time (in seconds) from beginning of sound file (default: 0);
|
||||
-- * `volume` - a floating point number >= 0, to set a sound volume (default: 1);
|
||||
-- * `pitch` - a floating point number >= 0, to set a sound pitch (default: 1);
|
||||
-- * `scale` - a boolean, to set if sound pitch should be scaled by simulation time scaling (default: true);
|
||||
@ -76,7 +76,13 @@
|
||||
-- Play a sound file as a music track
|
||||
-- @function [parent=#ambient] streamMusic
|
||||
-- @param #string fileName Path to file in VFS
|
||||
-- @usage ambient.streamMusic("Music\\Test\\Test.mp3");
|
||||
-- @param #table options An optional table with additional optional arguments. Can contain:
|
||||
--
|
||||
-- * `fadeOut` - a floating point number >= 0, time (in seconds) to fade out current track before playing this one (default 1.0);
|
||||
-- @usage local params = {
|
||||
-- fadeOut=2.0
|
||||
-- };
|
||||
-- ambient.streamMusic("Music\\Test\\Test.mp3", params)
|
||||
|
||||
---
|
||||
-- Stop to play current music
|
||||
|
Loading…
Reference in New Issue
Block a user