diff --git a/SfmlSoundSystem.hpp b/SfmlSoundSystem.hpp index 13e80d5..b356d83 100644 --- a/SfmlSoundSystem.hpp +++ b/SfmlSoundSystem.hpp @@ -2,7 +2,7 @@ // // SFML Sound System (https://github.com/Hapaxia/SfmlSoundSystem) // -// Copyright(c) 2016-2018 M.J.Silk +// Copyright(c) 2016-2021 M.J.Silk // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages diff --git a/SfmlSoundSystem/Common.hpp b/SfmlSoundSystem/Common.hpp index 697a336..6a60cf6 100644 --- a/SfmlSoundSystem/Common.hpp +++ b/SfmlSoundSystem/Common.hpp @@ -5,7 +5,7 @@ // // Common // -// Copyright(c) 2016-2018 M.J.Silk +// Copyright(c) 2016-2021 M.J.Silk // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages diff --git a/SfmlSoundSystem/Control.cpp b/SfmlSoundSystem/Control.cpp index 01b3c91..45dba9f 100644 --- a/SfmlSoundSystem/Control.cpp +++ b/SfmlSoundSystem/Control.cpp @@ -5,7 +5,7 @@ // // Control // -// Copyright(c) 2016-2018 M.J.Silk +// Copyright(c) 2016-2021 M.J.Silk // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages @@ -75,6 +75,12 @@ void Control::update() previous.stop(); } +bool Control::copyBuffer(const std::string& soundId, const sf::SoundBuffer& soundBuffer) +{ + return m_bufferVolumes.emplace(soundId, 1.f).second && + m_buffers.emplace(soundId, soundBuffer).second; +} + bool Control::loadBuffer(const std::string& soundId, const std::vector& memoryBlock) { sf::SoundBuffer soundBuffer; @@ -177,6 +183,11 @@ sf::Time Control::getCurrentMusicPosition() const return sf::Time::Zero; } +bool Control::restartMusic() +{ + return playMusic(m_currentMusic); +} + void Control::pauseMusic() { if (getCurrentMusicStatus() == sf::SoundSource::Status::Playing) diff --git a/SfmlSoundSystem/Control.hpp b/SfmlSoundSystem/Control.hpp index cf03a01..36303ea 100644 --- a/SfmlSoundSystem/Control.hpp +++ b/SfmlSoundSystem/Control.hpp @@ -5,7 +5,7 @@ // // Control // -// Copyright(c) 2016-2018 M.J.Silk +// Copyright(c) 2016-2021 M.J.Silk // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages @@ -50,12 +50,13 @@ namespace sfmlSoundSystem { -// SSS (SFML Sound System) v1.3 - Control +// SSS (SFML Sound System) v1.4 - Control class Control { public: Control(); void update(); + bool copyBuffer(const std::string& soundId, const sf::SoundBuffer& soundBuffer); bool loadBuffer(const std::string& soundId, const std::vector& memoryBlock); bool linkMusic(const std::string& musicId, std::vector& memoryBlock); bool loadBuffer(const std::string& soundId, const char* memoryBlock, std::size_t memorySize); @@ -67,6 +68,7 @@ class Control bool assignVolumeSound(const std::string& soundId, float volume = 1.f); bool assignVolumeMusic(const std::string& musicId, float volume = 1.f); sf::Time getCurrentMusicPosition() const; + bool restartMusic(); void pauseMusic(); void resumeMusic(); void stopFx(); @@ -78,6 +80,7 @@ class Control std::string getCurrentMusic() const; sf::SoundSource::Status getCurrentMusicStatus() const; unsigned int getNumberOfSoundsPlaying() const; + bool getIsCurrentlyPaused() const; @@ -136,5 +139,10 @@ inline unsigned int Control::getNumberOfSoundsPlaying() const return total; } +inline bool Control::getIsCurrentlyPaused() const +{ + return getCurrentMusicStatus() == sf::SoundSource::Status::Paused; +} + } // namespace sfmlSoundSystem #endif // SFMLSOUNDSYSTEM_CONTROL_HPP