Add a way to check if sound system is enabled

macos_ci_fix
Andrei Kortunov 1 year ago
parent ebb75008f8
commit db72a91180

@ -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

@ -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);

@ -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

@ -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

Loading…
Cancel
Save