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 = {} table.insert(apps,{
id = k,
for k,v in pairs(config.list(spkList)) do name = v,
table.insert(apps,{ })
id = k, end
name = v, for k,v in ipairs(apps) do
}) local hid = config.read(dir..v.id.."/.spk","hidden")
end if hid then
table.remove(apps,k)
for k,v in ipairs(apps) do end
local hid = config.read(dir..v.id.."/.spk","hidden") end
if hid then for k,v in ipairs(apps) do
table.remove(apps,k) ind[ v.id ] = v.name
end end
end sPhone.launch(sPhone.list(nil,{
list = ind,
local function drawHome() pairs = true,
term.setBackgroundColor(sPhone.theme["backgroundColor"]) title = " Apps"
term.clear() }))
term.setTextColor(sPhone.theme["text"])
sPhone.header("Apps","X")
term.setBackgroundColor(sPhone.theme["backgroundColor"])
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