1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-22 03:40:49 +00:00

Add a way to check if sound system is enabled

This commit is contained in:
Andrei Kortunov 2023-09-14 12:54:20 +04:00
parent ebb75008f8
commit db72a91180
4 changed files with 15 additions and 0 deletions

View File

@ -109,6 +109,9 @@ namespace MWBase
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;
///< Stops music if it's playing

View File

@ -112,6 +112,8 @@ namespace MWLua
sol::state_view& lua = context.mLua->sol();
sol::table api(lua, sol::create);
api["isEnabled"] = []() { return MWBase::Environment::get().getSoundManager()->isEnabled(); };
api["playSound3d"]
= [](std::string_view soundId, const Object& object, const sol::optional<sol::table>& options) {
auto args = getPlaySoundArgs(options);

View File

@ -173,6 +173,9 @@ namespace MWSound
void processChangedSettings(const Settings::CategorySettingVector& settings) override;
bool isEnabled() const override { return mOutput->isInitialized(); }
///< Returns true if sound system is enabled
void stopMusic() override;
///< Stops music if it's playing

View File

@ -749,6 +749,13 @@
--- @{#Sound}: Sounds and Speech
-- @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
-- @function [parent=#Sound] playSound3d