Update home.spk

This commit is contained in:
Ale32bit 2016-11-23 19:41:11 +01:00 committed by GitHub
parent 48646398ea
commit 1620d63658

View file

@ -1,149 +1,120 @@
--
-- sPhone Application Package
-- Built with SPK builder 1.2 local buttonsInHome = {
-- {"sphone.header",23,1,25,1,sPhone.theme["header"],sPhone.theme["headerText"],"vvv"},
{ {"sphone.appList",12,20,14,20,sPhone.theme["backgroundColor"],sPhone.theme["header"],"==="},
files = "{\ {"sphone.shell",2,3,8,5,colors.black,colors.yellow," Shell",2},
[ \"home.lua\" ] = \"\\\ {"sphone.lock",19,3,24,5,colors.lightGray,colors.black," Lock",2},
\\\ {"sphone.chat",11,3,16,5,colors.black,colors.white," Chat",2},
local buttonsInHome = {\\\ {"sphone.gps",11,7,15,9,colors.red,colors.black," GPS",2},
{\\\"sPhone.header\\\",23,1,25,1,sPhone.theme[\\\"header\\\"],sPhone.theme[\\\"headerText\\\"],\\\"vvv\\\"},\\\ {"sphone.info",18,7,23,9,colors.lightGray,colors.black," Info",2},
{\\\"sPhone.appsButton\\\",12,20,14,20,sPhone.theme[\\\"backgroundColor\\\"],sPhone.theme[\\\"header\\\"],\\\"===\\\"},\\\ {"sphone.store",2,7,8,9,colors.green,colors.white," Store",2},
{\\\"sPhone.shell\\\",2,3,8,5,colors.black,colors.yellow,\\\" Shell\\\",2},\\\ }
{\\\"sPhone.lock\\\",19,3,24,5,colors.lightGray,colors.black,\\\" Lock\\\",2},\\\
{\\\"sPhone.chat\\\",11,3,16,5,colors.black,colors.white,\\\" Chat\\\",2},\\\ local function clear()
{\\\"sPhone.gps\\\",11,7,15,9,colors.red,colors.black,\\\" GPS\\\",2},\\\ term.setBackgroundColor(sPhone.theme["backgroundColor"])
{\\\"sPhone.info\\\",18,7,23,9,colors.lightGray,colors.black,\\\" Info\\\",2},\\\ term.clear()
{\\\"sPhone.store\\\",2,7,8,9,colors.green,colors.white,\\\" Store\\\",2},\\\ term.setCursorPos(1,1)
}\\\ term.setTextColor(sPhone.theme["text"])
\\\ end
\\\
local appsOnHome = {\\\ local function drawHome()
[\\\"sPhone.shell\\\"] = \\\"/.sPhone/apps/shell\\\",\\\ local function box(x,y,text,bg,colorText,page)
[\\\"sPhone.chat\\\"] = \\\"/.sPhone/apps/chat\\\",\\\ graphics.box(x,y,x+1+#text,y+2,bg)
[\\\"sPhone.gps\\\"] = \\\"/.sPhone/apps/gps\\\",\\\ term.setCursorPos(x+1,y+1)
[\\\"sPhone.info\\\"] = \\\"/.sPhone/apps/system/info\\\",\\\ term.setTextColor(colorText)
[\\\"sPhone.store\\\"] = \\\"/.sPhone/apps/store\\\",\\\ write(text)
[\\\"sPhone.appsButton\\\"] = \\\"/.sPhone/apps/appList\\\",\\\ end
\\\ clear()
}\\\
\\\
local function clear()\\\ visum.buttons(buttonsInHome,true)
term.setBackgroundColor(sPhone.theme[\\\"backgroundColor\\\"])\\\
term.clear()\\\ local w, h = term.getSize()
term.setCursorPos(1,1)\\\ paintutils.drawLine(1,1,w,1, sPhone.theme["header"])
term.setTextColor(sPhone.theme[\\\"text\\\"])\\\ term.setTextColor(sPhone.theme["headerText"])
end\\\ visum.align("right","vvv ",false,1)
\\\ end
local function drawHome()\\\ local function footerMenu()
local function box(x,y,text,bg,colorText,page)\\\ sPhone.isFooterMenuOpen = true
graphics.box(x,y,x+1+#text,y+2,bg)\\\ function redraw()
term.setCursorPos(x+1,y+1)\\\ drawHome()
term.setTextColor(colorText)\\\ local w, h = term.getSize()
write(text)\\\ graphics.box(1,2,w,4,sPhone.theme["header"])
end\\\ term.setTextColor(sPhone.theme["headerText"])
clear()\\\ term.setBackgroundColor(sPhone.theme["header"])
\\\ visum.align("right","^^^ ",false,1)
\\\ visum.align("right", "Reboot ",false,3)
visum.buttons(buttonsInHome,true)\\\ term.setCursorPos(11,3)
\\\ write("Settings")
local w, h = term.getSize()\\\ term.setCursorPos(2,3)
paintutils.drawLine(1,1,w,1, sPhone.theme[\\\"header\\\"])\\\ write("Shutdown")
term.setTextColor(sPhone.theme[\\\"headerText\\\"])\\\ end
visum.align(\\\"right\\\",\\\"vvv \\\",false,1)\\\ while true do
end\\\ term.redirect(sPhone.mainTerm)
local function footerMenu()\\\ drawHome()
sPhone.isFooterMenuOpen = true\\\ redraw()
function redraw()\\\ local _,_,x,y = os.pullEvent("mouse_click")
drawHome()\\\ if y == 3 then
local w, h = term.getSize()\\\ if x > 1 and x < 10 then
graphics.box(1,2,w,4,sPhone.theme[\\\"header\\\"])\\\ os.shutdown()
term.setTextColor(sPhone.theme[\\\"headerText\\\"])\\\ sPhone.inHome = true
term.setBackgroundColor(sPhone.theme[\\\"header\\\"])\\\ elseif x > 19 and x < 26 then
visum.align(\\\"right\\\",\\\"^^^ \\\",false,1)\\\ os.reboot()
visum.align(\\\"right\\\", \\\"Reboot \\\",false,3)\\\ sPhone.inHome = true
term.setCursorPos(11,3)\\\ elseif x > 10 and x < 19 then
write(\\\"Settings\\\")\\\ sPhone.inHome = false
term.setCursorPos(2,3)\\\ sPhone.launch("sphone.settings")
write(\\\"Shutdown\\\")\\\ sPhone.inHome = true
end\\\ drawHome()
while true do\\\ end
term.redirect(sPhone.mainTerm)\\\ elseif y == 1 then
drawHome()\\\ if x < 26 and x > 22 then
redraw()\\\ sPhone.isFooterMenuOpen = false
local _,_,x,y = os.pullEvent(\\\"mouse_click\\\")\\\ return
if y == 3 then\\\ end
if x > 1 and x < 10 then\\\ end
os.shutdown()\\\ end
sPhone.inHome = true\\\ end
elseif x > 19 and x < 26 then\\\ local function buttonHomeLoop()
os.reboot()\\\ while true do
sPhone.inHome = true\\\ drawHome()
elseif x > 10 and x < 19 then\\\ term.setCursorBlink(false)
sPhone.inHome = false\\\ local autoLockTimer = os.startTimer(10)
sPhone.launch(\\\"sphone.settings\\\")\\\ local id = visum.buttons(buttonsInHome)
sPhone.inHome = true\\\
drawHome()\\\ if id == "sphone.header" then
end\\\ footerMenu()
elseif y == 1 then\\\ elseif id == "sphone.lock" then
if x < 26 and x > 22 then\\\ sPhone.inHome = false
sPhone.isFooterMenuOpen = false\\\ sPhone.login()
return\\\ sPhone.inHome = true
end\\\ else
end\\\ sPhone.inHome = false
end\\\ os.pullEvent = os.oldPullEvent
end\\\ sPhone.launch(id)
local function buttonHomeLoop()\\\ os.pullEvent = os.pullEventRaw
while true do\\\ sPhone.inHome = true
drawHome()\\\ end
term.setCursorBlink(false)\\\ end
local autoLockTimer = os.startTimer(10)\\\
local id = visum.buttons(buttonsInHome)\\\ sPhone.inHome = false
\\\
if id == \\\"sPhone.header\\\" then\\\ end
footerMenu()\\\
elseif id == \\\"sPhone.lock\\\" then\\\ local function updateClock()
sPhone.inHome = false\\\ while true do
sPhone.login()\\\ if sPhone.inHome then
sPhone.inHome = true\\\ term.setCursorPos(1,1)
elseif appsOnHome[id] then\\\ term.setBackgroundColor(sPhone.theme["header"])
sPhone.inHome = false\\\ term.setTextColor(sPhone.theme["headerText"])
os.pullEvent = os.oldPullEvent\\\ term.setCursorPos(1,1)
shell.run(appsOnHome[id])\\\ write(" ")
os.pullEvent = os.pullEventRaw\\\ term.setCursorPos(1,1)
sPhone.inHome = true\\\ write(" "..textutils.formatTime(os.time(), not config.read("/.sPhone/config/sPhone","format12time")))
end\\\ end
end\\\ sleep(0)
\\\ end
sPhone.inHome = false\\\ end
\\\
end\\\ parallel.waitForAll(buttonHomeLoop, updateClock)
\\\
local function updateClock()\\\
while true do\\\
if sPhone.inHome then\\\
term.setCursorPos(1,1)\\\
term.setBackgroundColor(sPhone.theme[\\\"header\\\"])\\\
term.setTextColor(sPhone.theme[\\\"headerText\\\"])\\\
term.setCursorPos(1,1)\\\
write(\\\" \\\")\\\
term.setCursorPos(1,1)\\\
write(\\\" \\\"..textutils.formatTime(os.time(), not config.read(\\\"/.sPhone/config/sPhone\\\",\\\"format12time\\\")))\\\
end\\\
sleep(0)\\\
end\\\
end\\\
\\\
parallel.waitForAll(buttonHomeLoop, updateClock)\\\
\",\
}",
config = "{\
type = \"home\",\
main = \"home.lua\",\
name = \"sPhone Home\",\
version = 1,\
id = \"sphone.home\",\
author = \"BeaconNet\",\
hidden = true,\
}",
}