Update appList.lua

This commit is contained in:
Ale32bit 2016-11-17 16:00:03 +01:00 committed by GitHub
parent 5332352174
commit 62f902044a

View file

@ -1,52 +1,27 @@
local spkList = "/.sPhone/config/spklist" local spkList = "/.sPhone/config/spklist"
local dir = "/.sPhone/apps/spk/" local dir = "/.sPhone/apps/spk/"
local apps = {}
local ind = {}
if not fs.exists(spkList) then if not fs.exists(spkList) then
config.list("/.sPhone/config/spklist") config.list("/.sPhone/config/spklist")
end end
for k,v in pairs(config.list(spkList)) do
local apps = {}
for k,v in pairs(config.list(spkList)) do
table.insert(apps,{ table.insert(apps,{
id = k, id = k,
name = v, name = v,
}) })
end end
for k,v in ipairs(apps) do
for k,v in ipairs(apps) do
local hid = config.read(dir..v.id.."/.spk","hidden") local hid = config.read(dir..v.id.."/.spk","hidden")
if hid then if hid then
table.remove(apps,k) table.remove(apps,k)
end end
end end
for k,v in ipairs(apps) do
local function drawHome() ind[ v.id ] = v.name
term.setBackgroundColor(sPhone.theme["backgroundColor"]) end
term.clear() sPhone.launch(sPhone.list(nil,{
term.setTextColor(sPhone.theme["text"]) list = ind,
sPhone.header("Apps","X") pairs = true,
term.setBackgroundColor(sPhone.theme["backgroundColor"]) title = " Apps"
term.setTextColor(sPhone.theme["text"]) }))
term.setCursorPos(1,3)
for k, v in pairs(apps) do
print(v.name)
end
end
drawHome()
local w, h = term.getSize()
while true do
drawHome()
local _,_,x,y = os.pullEvent("mouse_click")
if x == w and y == 1 then
break
elseif y >= 2 then
if apps[y-2] then
sPhone.launch(apps[y-2].id)
return
end
end
end