diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-02-12 17:10:03 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-02-12 17:10:03 +1100 |
| commit | 36f4c77fb22fd8ba433696a6fbd005d504e86186 (patch) | |
| tree | b3242f8edcd395f2b498fad40e43e1f36a9a2b00 /src/ui/ui_fsm.cpp | |
| parent | 03c0968168090b1093bda7e05874c201ae58b57b (diff) | |
| parent | 527374c72e1ec52e1d5814dbee3587ae100631dd (diff) | |
| download | tangara-fw-36f4c77fb22fd8ba433696a6fbd005d504e86186.tar.gz | |
Merge branch 'main' of codeberg.org:cool-tech-zone/tangara-fw
Diffstat (limited to 'src/ui/ui_fsm.cpp')
| -rw-r--r-- | src/ui/ui_fsm.cpp | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp index 630238e7..728c9756 100644 --- a/src/ui/ui_fsm.cpp +++ b/src/ui/ui_fsm.cpp @@ -127,8 +127,30 @@ lua::Property UiState::sPlaybackPosition{0}; lua::Property UiState::sQueuePosition{0}; lua::Property UiState::sQueueSize{0}; -lua::Property UiState::sQueueRepeat{false}; -lua::Property UiState::sQueueRandom{false}; +lua::Property UiState::sQueueRepeat{false, [](const lua::LuaValue& val) { + if (!std::holds_alternative<bool>(val)) { + return false; + } + bool new_val = std::get<bool>(val); + sServices->track_queue().repeat(new_val); + return true; +}}; +lua::Property UiState::sQueueReplay{false, [](const lua::LuaValue& val) { + if (!std::holds_alternative<bool>(val)) { + return false; + } + bool new_val = std::get<bool>(val); + sServices->track_queue().replay(new_val); + return true; +}}; +lua::Property UiState::sQueueRandom{false, [](const lua::LuaValue& val) { + if (!std::holds_alternative<bool>(val)) { + return false; + } + bool new_val = std::get<bool>(val); + sServices->track_queue().random(new_val); + return true; +}}; lua::Property UiState::sVolumeCurrentPct{ 0, [](const lua::LuaValue& val) { @@ -296,6 +318,7 @@ void UiState::react(const audio::QueueUpdate&) { sQueuePosition.Update(current_pos); sQueueRandom.Update(queue.random()); sQueueRepeat.Update(queue.repeat()); + sQueueReplay.Update(queue.replay()); } void UiState::react(const audio::PlaybackStarted& ev) { @@ -423,7 +446,8 @@ void Lua::entry() { {"previous", [&](lua_State* s) { return QueuePrevious(s); }}, {"position", &sQueuePosition}, {"size", &sQueueSize}, - {"replay", &sQueueRepeat}, + {"replay", &sQueueReplay}, + {"repeat_track", &sQueueRepeat}, {"random", &sQueueRandom}, }); sLua->bridge().AddPropertyModule("volume", @@ -567,6 +591,15 @@ auto Lua::SetRepeat(const lua::LuaValue& val) -> bool { return true; } +auto Lua::SetReplay(const lua::LuaValue& val) -> bool { + if (!std::holds_alternative<bool>(val)) { + return false; + } + bool b = std::get<bool>(val); + sServices->track_queue().replay(b); + return true; +} + void Lua::exit() { lv_group_set_default(NULL); } |
