From 9bb3f59496a74aa3a1a841441d4fd3ee48fe1bbd Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Wed, 13 Aug 2025 11:15:33 -0300 Subject: [PATCH] reworked pocket app loader --- pocket/iocontrol.lua | 3 ++- pocket/pocket.lua | 9 ++++++++- pocket/ui/apps/loader.lua | 21 +++++++++++++++++---- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/pocket/iocontrol.lua b/pocket/iocontrol.lua index b559fb0..aeb2cd7 100644 --- a/pocket/iocontrol.lua +++ b/pocket/iocontrol.lua @@ -36,7 +36,8 @@ iocontrol.LINK_STATE = LINK_STATE ---@class pocket_ioctl local io = { version = "unknown", -- pocket version - ps = psil.create() -- pocket PSIL + ps = psil.create(), -- pocket PSIL + loader_require = { sv = false, api = false } } local config = nil ---@type pkt_config diff --git a/pocket/pocket.lua b/pocket/pocket.lua index 4bbd051..5e227f3 100644 --- a/pocket/pocket.lua +++ b/pocket/pocket.lua @@ -278,7 +278,14 @@ function pocket.init_nav(smem) local app = self.apps[app_id] if app then - if app.requires_conn() and not smem.pkt_sys.pocket_comms.is_linked() then + local p_comms = smem.pkt_sys.pocket_comms + local req_sv, req_api = app.check_requires() + + if (req_sv and not p_comms.is_sv_linked()) or (req_api and not p_comms.is_api_linked()) then + -- report required connction(s) + iocontrol.get_db().loader_require = { sv = req_sv, api = req_api } + iocontrol.get_db().ps.toggle("loader_reqs") + -- bring up the app loader self.loader_return = app_id app_id = APP_ID.LOADER diff --git a/pocket/ui/apps/loader.lua b/pocket/ui/apps/loader.lua index 7a45a7a..533370c 100644 --- a/pocket/ui/apps/loader.lua +++ b/pocket/ui/apps/loader.lua @@ -32,16 +32,29 @@ local function create_pages(root) local root_pane = MultiPane{parent=main,x=1,y=1,panes={conn_sv_wait,conn_api_wait,main_pane}} - root_pane.register(db.ps, "link_state", function (state) - if state == LINK_STATE.UNLINKED or state == LINK_STATE.API_LINK_ONLY then + local function update() + local state = db.ps.get("link_state") + + if state == LINK_STATE.UNLINKED then root_pane.set_value(1) + elseif state == LINK_STATE.API_LINK_ONLY then + if not db.loader_require.sv then + root_pane.set_value(3) + db.nav.on_loader_connected() + else root_pane.set_value(1) end elseif state == LINK_STATE.SV_LINK_ONLY then - root_pane.set_value(2) + if not db.loader_require.api then + root_pane.set_value(3) + db.nav.on_loader_connected() + else root_pane.set_value(2) end else root_pane.set_value(3) db.nav.on_loader_connected() end - end) + end + + root_pane.register(db.ps, "link_state", update) + root_pane.register(db.ps, "loader_reqs", update) TextBox{parent=main_pane,text="Connected!",x=1,y=6,alignment=core.ALIGN.CENTER} end