From 3f1fadbeef571a6653f5648c2b78073ddd37d169 Mon Sep 17 00:00:00 2001 From: Robin Howard Date: Sun, 21 Jan 2024 18:13:49 +1100 Subject: Plumb queue next+previous through to Lua, incl. with stubs and docs. --- src/ui/include/ui_fsm.hpp | 3 +++ src/ui/ui_fsm.cpp | 26 ++++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) (limited to 'src/ui') diff --git a/src/ui/include/ui_fsm.hpp b/src/ui/include/ui_fsm.hpp index 9de1169b..3ddef738 100644 --- a/src/ui/include/ui_fsm.hpp +++ b/src/ui/include/ui_fsm.hpp @@ -164,6 +164,9 @@ class Lua : public UiState { auto SetPlaying(const lua::LuaValue&) -> bool; auto SetRandom(const lua::LuaValue&) -> bool; auto SetRepeat(const lua::LuaValue&) -> bool; + + auto QueueNext(lua_State*) -> int; + auto QueuePrevious(lua_State*) -> int; }; } // namespace states diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp index e532e693..fe790816 100644 --- a/src/ui/ui_fsm.cpp +++ b/src/ui/ui_fsm.cpp @@ -396,12 +396,16 @@ void Lua::entry() { {"track", &sPlaybackTrack}, {"position", &sPlaybackPosition}, }); - sLua->bridge().AddPropertyModule("queue", { - {"position", &sQueuePosition}, - {"size", &sQueueSize}, - {"replay", &sQueueRepeat}, - {"random", &sQueueRandom}, - }); + sLua->bridge().AddPropertyModule( + "queue", + { + {"next", [&](lua_State* s) { return QueueNext(s); }}, + {"previous", [&](lua_State* s) { return QueuePrevious(s); }}, + {"position", &sQueuePosition}, + {"size", &sQueueSize}, + {"replay", &sQueueRepeat}, + {"random", &sQueueRandom}, + }); sLua->bridge().AddPropertyModule("volume", { {"current_pct", &sVolumeCurrentPct}, @@ -476,6 +480,16 @@ auto Lua::PushLuaScreen(lua_State* s) -> int { return 0; } +auto Lua::QueueNext(lua_State*) -> int { + sServices->track_queue().next(); + return 0; +} + +auto Lua::QueuePrevious(lua_State*) -> int { + sServices->track_queue().previous(); + return 0; +} + auto Lua::PopLuaScreen(lua_State* s) -> int { PopScreen(); luavgl_set_root(s, sCurrentScreen->content()); -- cgit v1.2.3