diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/crepe/Exception.cpp | 2 | ||||
-rw-r--r-- | src/crepe/Exception.h | 2 | ||||
-rw-r--r-- | src/crepe/api/AudioSource.cpp | 23 | ||||
-rw-r--r-- | src/crepe/api/AudioSource.h | 39 | ||||
-rw-r--r-- | src/crepe/facade/DB.cpp | 11 |
5 files changed, 7 insertions, 70 deletions
diff --git a/src/crepe/Exception.cpp b/src/crepe/Exception.cpp index dab8f2e..bfdbcdd 100644 --- a/src/crepe/Exception.cpp +++ b/src/crepe/Exception.cpp @@ -6,7 +6,7 @@ using namespace std; using namespace crepe; -const char * Exception::what() { return error.c_str(); } +const char * Exception::what() const noexcept { return error.c_str(); } Exception::Exception(const char * fmt, ...) { va_list args; diff --git a/src/crepe/Exception.h b/src/crepe/Exception.h index 6473043..80af068 100644 --- a/src/crepe/Exception.h +++ b/src/crepe/Exception.h @@ -11,7 +11,7 @@ public: //! printf Exception(const char * fmt, ...); //! Get formatted error message - const char * what(); + const char * what() const noexcept; protected: Exception() = default; diff --git a/src/crepe/api/AudioSource.cpp b/src/crepe/api/AudioSource.cpp deleted file mode 100644 index 63fd0d7..0000000 --- a/src/crepe/api/AudioSource.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include <memory> - -#include "../facade/Sound.h" - -#include "AudioSource.h" - -using namespace crepe; - -AudioSource::AudioSource(std::unique_ptr<Asset> audio_clip) { - this->sound = std::make_unique<crepe::Sound>(std::move(audio_clip)); -} - -void AudioSource::play() { return this->play(false); } - -void AudioSource::play(bool looping) { - this->sound->set_looping(looping); - this->sound->play(); -} - -void AudioSource::stop() { - this->sound->pause(); - this->sound->rewind(); -} diff --git a/src/crepe/api/AudioSource.h b/src/crepe/api/AudioSource.h deleted file mode 100644 index 1e24ae8..0000000 --- a/src/crepe/api/AudioSource.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once - -#include <memory> - -#include "../Asset.h" -#include "../Component.h" - -namespace crepe { - -class Sound; - -//! Audio source component -class AudioSource : public Component { -public: - AudioSource(std::unique_ptr<Asset> audio_clip); - virtual ~AudioSource() = default; - -public: - //! Start or resume this audio source - void play(); - void play(bool looping); - //! Stop this audio source - void stop(); - -public: - //! Sample file location - std::unique_ptr<Asset> audio_clip; - //! TODO: ????? - bool play_on_awake; - //! Repeat the current audio clip during playback - bool loop; - //! Normalized volume (0.0 - 1.0) - float volume; - -private: - std::unique_ptr<Sound> sound; -}; - -} // namespace crepe diff --git a/src/crepe/facade/DB.cpp b/src/crepe/facade/DB.cpp index 0a2f455..405f7c4 100644 --- a/src/crepe/facade/DB.cpp +++ b/src/crepe/facade/DB.cpp @@ -19,15 +19,14 @@ DB::DB(const string & path) { this->db = {db, [](libdb::DB * db) { db->close(db, 0); }}; // load or create database file - if ((ret = this->db->open(this->db.get(), NULL, path.c_str(), NULL, - libdb::DB_BTREE, DB_CREATE, 0)) - != 0) - throw Exception("db->open: %s", libdb::db_strerror(ret)); + ret = this->db->open(this->db.get(), NULL, path.c_str(), NULL, + libdb::DB_BTREE, DB_CREATE, 0); + if (ret != 0) throw Exception("db->open: %s", libdb::db_strerror(ret)); // create cursor libdb::DBC * cursor; - if ((ret = this->db->cursor(this->db.get(), NULL, &cursor, 0)) != 0) - throw Exception("db->cursor: %s", libdb::db_strerror(ret)); + ret = this->db->cursor(this->db.get(), NULL, &cursor, 0); + if (ret != 0) throw Exception("db->cursor: %s", libdb::db_strerror(ret)); this->cursor = {cursor, [](libdb::DBC * cursor) { cursor->close(cursor); }}; } |