diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2022-11-15 07:35:07 -0500 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2022-11-15 07:35:07 -0500 |
commit | a056c15dd3781b4f6bb89fdd738b14cafc00cd85 (patch) | |
tree | 1775a5913c7bc87563b6b4a29c63514cf15b4185 /src/components/Audio.hpp | |
parent | 1405d648b6264cfda7c46f5b251258335abaee83 (diff) | |
parent | 57013add5b7c524086272be7d395f9ec5109bde2 (diff) |
merge branch lib-cleanup into ui
Diffstat (limited to 'src/components/Audio.hpp')
-rw-r--r-- | src/components/Audio.hpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/components/Audio.hpp b/src/components/Audio.hpp new file mode 100644 index 0000000..2bb63eb --- /dev/null +++ b/src/components/Audio.hpp @@ -0,0 +1,56 @@ +/** + * Copyright (C) 2019 Clyne Sullivan + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#ifndef COMPONENT_AUDIO_HPP_ +#define COMPONENT_AUDIO_HPP_ + +#include <AL/al.h> + +#include "Component.hpp" + +struct Audio : Component<Audio> +{ +public: + std::string fileName; + ALuint source; + ALuint buffer; + + Audio(std::string _fileName = "") : + fileName(_fileName), source(0), buffer(0) {} + + Audio FromLua(sol::object ref) + { + if (ref.get_type() == sol::type::table) { + sol::table tab = ref; + if (tab["file"] != nullptr) + this->fileName = tab["file"]; + } else { + throw std::string("Audio table not formatted properly"); + } + + return *this; + } + + void serialize([[maybe_unused]] cereal::JSONOutputArchive& ar) final {} + void serialize([[maybe_unused]] cereal::JSONInputArchive& ar) final {} + + virtual std::string serializeName(void) const final { + return "Audio"; + } +}; + +#endif // COMPONENT_AUDIO_HPP_ + |