summaryrefslogtreecommitdiff
path: root/src/ui/ui_fsm.cpp
diff options
context:
space:
mode:
authorailurux <ailuruxx@gmail.com>2024-02-12 15:36:56 +1100
committerailurux <ailuruxx@gmail.com>2024-02-12 15:36:56 +1100
commit9512bd97bbac48fa33339cc248c76070063bbc61 (patch)
tree00ecbfecf5961954a7f7e349a73ab0ba52e90d88 /src/ui/ui_fsm.cpp
parent679521d8e37171e8698d618fca9a7908348c429f (diff)
downloadtangara-fw-9512bd97bbac48fa33339cc248c76070063bbc61.tar.gz
Add buttons for shuffle + repeat track
Diffstat (limited to 'src/ui/ui_fsm.cpp')
-rw-r--r--src/ui/ui_fsm.cpp39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp
index 12584ec7..6e4bbe6f 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) {
@@ -417,7 +440,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",
@@ -564,6 +588,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);
}