diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-18 17:36:51 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-18 17:36:51 +1000 |
commit | 6e1d29fe861ef5a81c5458cd8ae68d09f36e28c3 (patch) | |
tree | 36fb8a412649f1e749e2b9fc0268e80bc05251fb /source/frontend/StarVoiceLuaBindings.cpp | |
parent | 34bb0b54222c1c0f3450c56e76f89f192d77374b (diff) |
Provide speaker info to HUD indicators
Diffstat (limited to 'source/frontend/StarVoiceLuaBindings.cpp')
-rw-r--r-- | source/frontend/StarVoiceLuaBindings.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source/frontend/StarVoiceLuaBindings.cpp b/source/frontend/StarVoiceLuaBindings.cpp new file mode 100644 index 0000000..e3271fd --- /dev/null +++ b/source/frontend/StarVoiceLuaBindings.cpp @@ -0,0 +1,29 @@ +#include "StarVoiceLuaBindings.hpp" +#include "StarVoice.hpp" + +namespace Star { + +LuaCallbacks LuaBindings::makeVoiceCallbacks(Voice* voice) { + LuaCallbacks callbacks; + + callbacks.registerCallback("speakers", [voice](Maybe<bool> onlyPlaying) -> List<Json> { + List<Json> list; + + for (auto& speaker : voice->speakers(onlyPlaying.value(true))) { + list.append(JsonObject{ + {"speakerId", speaker->speakerId }, + {"entityId", speaker->entityId }, + {"name", speaker->name }, + {"playing", (bool)speaker->playing }, + {"muted", (bool)speaker->muted }, + {"loudness", (float)speaker->decibelLevel }, + }); + } + + return list; + }); + + return callbacks; +} + +} |