mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-10 15:45:37 +00:00
Add a table with fadeOut argument for streamMusic
This commit is contained in:
parent
51426eb754
commit
14e6af8bea
@ -23,6 +23,11 @@ namespace
|
|||||||
float mTimeOffset = 0.f;
|
float mTimeOffset = 0.f;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct StreamMusicArgs
|
||||||
|
{
|
||||||
|
float mFade = 1.f;
|
||||||
|
};
|
||||||
|
|
||||||
PlaySoundArgs getPlaySoundArgs(const sol::optional<sol::table>& options)
|
PlaySoundArgs getPlaySoundArgs(const sol::optional<sol::table>& options)
|
||||||
{
|
{
|
||||||
PlaySoundArgs args;
|
PlaySoundArgs args;
|
||||||
@ -55,6 +60,17 @@ namespace
|
|||||||
return MWSound::PlayMode::NoEnvNoScaling;
|
return MWSound::PlayMode::NoEnvNoScaling;
|
||||||
return MWSound::PlayMode::NoEnv;
|
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
|
namespace MWLua
|
||||||
@ -95,9 +111,10 @@ namespace MWLua
|
|||||||
return MWBase::Environment::get().getSoundManager()->getSoundPlaying(MWWorld::Ptr(), fileName);
|
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();
|
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(); };
|
api["isMusicPlaying"] = []() { return MWBase::Environment::get().getSoundManager()->isMusicPlaying(); };
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
-- @param #string soundId ID of Sound record to play
|
-- @param #string soundId ID of Sound record to play
|
||||||
-- @param #table options An optional table with additional optional arguments. Can contain:
|
-- @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);
|
-- * `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);
|
-- * `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);
|
-- * `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 #string fileName Path to sound file in VFS
|
||||||
-- @param #table options An optional table with additional optional arguments. Can contain:
|
-- @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);
|
-- * `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);
|
-- * `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);
|
-- * `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
|
-- Play a sound file as a music track
|
||||||
-- @function [parent=#ambient] streamMusic
|
-- @function [parent=#ambient] streamMusic
|
||||||
-- @param #string fileName Path to file in VFS
|
-- @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
|
-- Stop to play current music
|
||||||
|
Loading…
x
Reference in New Issue
Block a user