mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-29 04:06:40 +00:00
Add a way to check if sound system is enabled
This commit is contained in:
parent
ebb75008f8
commit
db72a91180
4 changed files with 15 additions and 0 deletions
|
@ -109,6 +109,9 @@ namespace MWBase
|
||||||
|
|
||||||
virtual void processChangedSettings(const std::set<std::pair<std::string, std::string>>& settings) = 0;
|
virtual void processChangedSettings(const std::set<std::pair<std::string, std::string>>& settings) = 0;
|
||||||
|
|
||||||
|
virtual bool isEnabled() const = 0;
|
||||||
|
///< Returns true if sound system is enabled
|
||||||
|
|
||||||
virtual void stopMusic() = 0;
|
virtual void stopMusic() = 0;
|
||||||
///< Stops music if it's playing
|
///< Stops music if it's playing
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,8 @@ namespace MWLua
|
||||||
sol::state_view& lua = context.mLua->sol();
|
sol::state_view& lua = context.mLua->sol();
|
||||||
sol::table api(lua, sol::create);
|
sol::table api(lua, sol::create);
|
||||||
|
|
||||||
|
api["isEnabled"] = []() { return MWBase::Environment::get().getSoundManager()->isEnabled(); };
|
||||||
|
|
||||||
api["playSound3d"]
|
api["playSound3d"]
|
||||||
= [](std::string_view soundId, const Object& object, const sol::optional<sol::table>& options) {
|
= [](std::string_view soundId, const Object& object, const sol::optional<sol::table>& options) {
|
||||||
auto args = getPlaySoundArgs(options);
|
auto args = getPlaySoundArgs(options);
|
||||||
|
|
|
@ -173,6 +173,9 @@ namespace MWSound
|
||||||
|
|
||||||
void processChangedSettings(const Settings::CategorySettingVector& settings) override;
|
void processChangedSettings(const Settings::CategorySettingVector& settings) override;
|
||||||
|
|
||||||
|
bool isEnabled() const override { return mOutput->isInitialized(); }
|
||||||
|
///< Returns true if sound system is enabled
|
||||||
|
|
||||||
void stopMusic() override;
|
void stopMusic() override;
|
||||||
///< Stops music if it's playing
|
///< Stops music if it's playing
|
||||||
|
|
||||||
|
|
|
@ -749,6 +749,13 @@
|
||||||
--- @{#Sound}: Sounds and Speech
|
--- @{#Sound}: Sounds and Speech
|
||||||
-- @field [parent=#core] #Sound sound
|
-- @field [parent=#core] #Sound sound
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Checks if sound system is enabled (any functions to play sounds are no-ops when it is disabled).
|
||||||
|
-- It can not be enabled or disabled during runtime.
|
||||||
|
-- @function [parent=#Sound] isEnabled
|
||||||
|
-- @return #boolean
|
||||||
|
-- @usage local enabled = core.sound.isEnabled();
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Play a 3D sound, attached to object
|
-- Play a 3D sound, attached to object
|
||||||
-- @function [parent=#Sound] playSound3d
|
-- @function [parent=#Sound] playSound3d
|
||||||
|
|
Loading…
Reference in a new issue