Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
ur_sounds.hpp
1
11
12#ifndef ZOAPPSOUNDS_H
13#define ZOAPPSOUNDS_H
14
15#include <array>
16
17#include <toymaker/engine/sound/types.hpp>
18#include <toymaker/engine/sim_system.hpp>
19
20enum class UrSoundFX: uint8_t {
21 MUSIC,
22 BUTTON_HOVER,
23 BUTTON_CLICK,
24 PIECE_LAUNCH,
25 PIECE_MOVE,
26 DICE_ROLL,
27
28 TOTAL,
29};
30
36class UrSoundPlayer: public ToyMaker::SimObjectAspect<UrSoundPlayer> {
37public:
38 UrSoundPlayer(): SimObjectAspect<UrSoundPlayer>{0} {}
39 inline static std::string getSimObjectAspectTypeName() { return "UrSoundPlayer"; }
40 static std::shared_ptr<BaseSimObjectAspect> create(const nlohmann::json& jsonAspectProperties);
41 std::shared_ptr<BaseSimObjectAspect> clone() const override;
42 void playEffect(UrSoundFX effect, uint8_t priority=0);
43
44 inline uint8_t getVolume() const { return mVolume; };
45
46 void decrementVolume5();
47 void incrementVolume5();
48
49private:
50 std::array<std::shared_ptr<ToyMaker::Sound>, static_cast<uint8_t>(UrSoundFX::TOTAL)> mSounds {};
51
52 std::unique_ptr<ToyMaker::SoundChannel> mChannelMusic { nullptr };
53 std::unique_ptr<ToyMaker::SoundChannel> mChannelEffects { nullptr };
54 uint8_t mEffectPriority { 0 };
55 uint8_t mVolume { 100 };
56
57 void onActivated() override;
58};
59
60#endif