Compare commits
10 commits
d3bbb1732c
...
089596eff1
Author | SHA1 | Date | |
---|---|---|---|
|
089596eff1 | ||
|
c55608d64c | ||
|
61938809fb | ||
|
c1eb4997e5 | ||
|
1eceddcc43 | ||
|
63b101a374 | ||
|
84c85deed4 | ||
|
e987bb5000 | ||
|
573539228e | ||
|
168cb41276 |
7 changed files with 2500 additions and 7 deletions
1761
apps/3d6/kristwallet.spk
Normal file
1761
apps/3d6/kristwallet.spk
Normal file
File diff suppressed because it is too large
Load diff
|
@ -785,12 +785,11 @@ end\\\
|
||||||
\",\
|
\",\
|
||||||
}",
|
}",
|
||||||
config = "{\
|
config = "{\
|
||||||
type = \"networking\",\
|
type = \"Networking\",\
|
||||||
author = \"Ale32bit\",\
|
author = \"Ale32bit\",\
|
||||||
name = \"Beam\",\
|
name = \"Beam\",\
|
||||||
id = \"ale32bit.beam\",\
|
id = \"ale32bit.beam\",\
|
||||||
version = 2.2,\
|
version = 2.2,\
|
||||||
main = \"beam.lua\",\
|
main = \"beam.lua\",\
|
||||||
type = \"Networking\",\
|
|
||||||
}",
|
}",
|
||||||
}
|
}
|
||||||
|
|
|
@ -760,11 +760,11 @@ os.pullEvent = oldPullEvent\\\
|
||||||
\",\
|
\",\
|
||||||
}",
|
}",
|
||||||
config = "{\
|
config = "{\
|
||||||
|
type = \"Networking\",\
|
||||||
main = \"bluecloud.lua\",\
|
main = \"bluecloud.lua\",\
|
||||||
name = \"BlueCloud\",\
|
name = \"BlueCloud\",\
|
||||||
id = \"ale32bit.bluecloud\",\
|
id = \"ale32bit.bluecloud\",\
|
||||||
author = \"Ale32bit\",\
|
author = \"Ale32bit\",\
|
||||||
version = 1,\
|
version = 1,\
|
||||||
type = \"Networking\",\
|
|
||||||
}",
|
}",
|
||||||
}
|
}
|
||||||
|
|
729
apps/Ale32bit/homeplus.spk
Normal file
729
apps/Ale32bit/homeplus.spk
Normal file
|
@ -0,0 +1,729 @@
|
||||||
|
--
|
||||||
|
-- sPhone Application Package
|
||||||
|
-- Built with SPK builder 1.2
|
||||||
|
--
|
||||||
|
{
|
||||||
|
files = "{\
|
||||||
|
[ \"paint.lua\" ] = \"-- Paint created by nitrogenfingers (edited by dan200)\\\
|
||||||
|
-- http://www.youtube.com/user/NitrogenFingers\\\
|
||||||
|
\\\
|
||||||
|
------------\\\
|
||||||
|
-- Fields --\\\
|
||||||
|
------------\\\
|
||||||
|
\\\
|
||||||
|
-- The width and height of the terminal\\\
|
||||||
|
local w,h = term.getSize()\\\
|
||||||
|
\\\
|
||||||
|
-- The selected colours on the left and right mouse button, and the colour of the canvas\\\
|
||||||
|
local leftColour, rightColour = colours.white, nil\\\
|
||||||
|
local canvasColour = colours.black\\\
|
||||||
|
\\\
|
||||||
|
-- The values stored in the canvas\\\
|
||||||
|
local canvas = {}\\\
|
||||||
|
\\\
|
||||||
|
-- The menu options\\\
|
||||||
|
local mChoices = { \\\"Save\\\",\\\"Exit\\\" }\\\
|
||||||
|
\\\
|
||||||
|
-- The message displayed in the footer bar\\\
|
||||||
|
local fMessage = \\\"Press Ctrl to access menu\\\"\\\
|
||||||
|
\\\
|
||||||
|
-------------------------\\\
|
||||||
|
-- Initialisation --\\\
|
||||||
|
-------------------------\\\
|
||||||
|
\\\
|
||||||
|
-- Determine if we can even run this\\\
|
||||||
|
if not term.isColour() then\\\
|
||||||
|
print(\\\"Requires an Advanced Computer\\\")\\\
|
||||||
|
return\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
-- Determines if the file exists, and can be edited on this computer\\\
|
||||||
|
local tArgs = {...}\\\
|
||||||
|
if #tArgs == 0 then\\\
|
||||||
|
print(\\\"Usage: paint <path>\\\")\\\
|
||||||
|
return\\\
|
||||||
|
end\\\
|
||||||
|
local sPath = shell.resolve(tArgs[1])\\\
|
||||||
|
local bReadOnly = fs.isReadOnly(sPath)\\\
|
||||||
|
if fs.exists(sPath) and fs.isDir(sPath) then\\\
|
||||||
|
print(\\\"Cannot edit a directory.\\\")\\\
|
||||||
|
return\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
term.setBackgroundColor(colors.black)\\\
|
||||||
|
term.clear()\\\
|
||||||
|
\\\
|
||||||
|
---------------\\\
|
||||||
|
-- Functions --\\\
|
||||||
|
---------------\\\
|
||||||
|
\\\
|
||||||
|
local function getCanvasPixel( x, y )\\\
|
||||||
|
if canvas[y] then\\\
|
||||||
|
return canvas[y][x]\\\
|
||||||
|
end\\\
|
||||||
|
return nil\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
--[[\\\
|
||||||
|
Converts a colour value to a text character\\\
|
||||||
|
params: colour = the number to convert to a hex value\\\
|
||||||
|
returns: a string representing the chosen colour\\\
|
||||||
|
]]\\\
|
||||||
|
local function getCharOf( colour )\\\
|
||||||
|
-- Incorrect values always convert to nil\\\
|
||||||
|
if type(colour) == \\\"number\\\" then\\\
|
||||||
|
local value = math.floor( math.log(colour) / math.log(2) ) + 1\\\
|
||||||
|
if value >= 1 and value <= 16 then\\\
|
||||||
|
return string.sub( \\\"0123456789abcdef\\\", value, value )\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
return \\\" \\\"\\\
|
||||||
|
end \\\
|
||||||
|
\\\
|
||||||
|
--[[\\\
|
||||||
|
Converts a text character to colour value\\\
|
||||||
|
params: char = the char (from string.byte) to convert to number\\\
|
||||||
|
returns: the colour number of the hex value\\\
|
||||||
|
]]\\\
|
||||||
|
local tColourLookup = {}\\\
|
||||||
|
for n=1,16 do\\\
|
||||||
|
tColourLookup[ string.byte( \\\"0123456789abcdef\\\",n,n ) ] = 2^(n-1)\\\
|
||||||
|
end\\\
|
||||||
|
local function getColourOf( char )\\\
|
||||||
|
-- Values not in the hex table are transparent (canvas coloured)\\\
|
||||||
|
return tColourLookup[char]\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
--[[ \\\
|
||||||
|
Loads the file into the canvas\\\
|
||||||
|
params: path = the path of the file to open\\\
|
||||||
|
returns: nil\\\
|
||||||
|
]]\\\
|
||||||
|
local function load(path)\\\
|
||||||
|
-- Load the file\\\
|
||||||
|
if fs.exists(path) then\\\
|
||||||
|
local file = fs.open(sPath, \\\"r\\\")\\\
|
||||||
|
local sLine = file.readLine()\\\
|
||||||
|
while sLine do\\\
|
||||||
|
local line = {}\\\
|
||||||
|
for x=1,w-2 do\\\
|
||||||
|
line[x] = getColourOf( string.byte(sLine,x,x) )\\\
|
||||||
|
end\\\
|
||||||
|
table.insert( canvas, line )\\\
|
||||||
|
sLine = file.readLine()\\\
|
||||||
|
end\\\
|
||||||
|
file.close()\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
--[[ \\\
|
||||||
|
Saves the current canvas to file \\\
|
||||||
|
params: path = the path of the file to save\\\
|
||||||
|
returns: true if save was successful, false otherwise\\\
|
||||||
|
]]\\\
|
||||||
|
local function save(path)\\\
|
||||||
|
-- Open file\\\
|
||||||
|
local sDir = string.sub(sPath, 1, #sPath - #fs.getName(sPath))\\\
|
||||||
|
if not fs.exists(sDir) then\\\
|
||||||
|
fs.makeDir(sDir)\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
local file = fs.open( path, \\\"w\\\" )\\\
|
||||||
|
if not file then\\\
|
||||||
|
return false\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
-- Encode (and trim)\\\
|
||||||
|
local tLines = {}\\\
|
||||||
|
local nLastLine = 0\\\
|
||||||
|
for y=1,h-1 do\\\
|
||||||
|
local sLine = \\\"\\\"\\\
|
||||||
|
local nLastChar = 0\\\
|
||||||
|
for x=1,w-2 do\\\
|
||||||
|
local c = getCharOf( getCanvasPixel( x, y ) )\\\
|
||||||
|
sLine = sLine .. c\\\
|
||||||
|
if c ~= \\\" \\\" then\\\
|
||||||
|
nLastChar = x\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
sLine = string.sub( sLine, 1, nLastChar )\\\
|
||||||
|
tLines[y] = sLine\\\
|
||||||
|
if string.len( sLine ) > 0 then\\\
|
||||||
|
nLastLine = y\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
-- Save out\\\
|
||||||
|
for n=1,nLastLine do\\\
|
||||||
|
file.writeLine( tLines[ n ] )\\\
|
||||||
|
end\\\
|
||||||
|
file.close()\\\
|
||||||
|
return true\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
--[[ \\\
|
||||||
|
Draws colour picker sidebar, the pallette and the footer\\\
|
||||||
|
returns: nil\\\
|
||||||
|
]]\\\
|
||||||
|
local function drawInterface()\\\
|
||||||
|
-- Footer\\\
|
||||||
|
term.setCursorPos(1, h)\\\
|
||||||
|
term.setBackgroundColour(colours.black)\\\
|
||||||
|
term.setTextColour(colours.yellow)\\\
|
||||||
|
term.clearLine()\\\
|
||||||
|
term.write(fMessage)\\\
|
||||||
|
\\\
|
||||||
|
-- Colour Picker\\\
|
||||||
|
for i=1,16 do\\\
|
||||||
|
term.setCursorPos(w-1, i)\\\
|
||||||
|
term.setBackgroundColour( 2^(i-1) )\\\
|
||||||
|
term.write(\\\" \\\")\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
term.setCursorPos(w-1, 17)\\\
|
||||||
|
term.setBackgroundColour( canvasColour )\\\
|
||||||
|
term.setTextColour( colours.grey )\\\
|
||||||
|
term.write(\\\"\\\\127\\\\127\\\")\\\
|
||||||
|
\\\
|
||||||
|
-- Left and Right Selected Colours\\\
|
||||||
|
for i=18,18 do\\\
|
||||||
|
term.setCursorPos(w-1, i)\\\
|
||||||
|
if leftColour ~= nil then\\\
|
||||||
|
term.setBackgroundColour( leftColour )\\\
|
||||||
|
term.write(\\\" \\\")\\\
|
||||||
|
else\\\
|
||||||
|
term.setBackgroundColour( canvasColour )\\\
|
||||||
|
term.setTextColour( colours.grey )\\\
|
||||||
|
term.write(\\\"\\\\127\\\")\\\
|
||||||
|
end\\\
|
||||||
|
if rightColour ~= nil then\\\
|
||||||
|
term.setBackgroundColour( rightColour )\\\
|
||||||
|
term.write(\\\" \\\")\\\
|
||||||
|
else\\\
|
||||||
|
term.setBackgroundColour( canvasColour )\\\
|
||||||
|
term.setTextColour( colours.grey )\\\
|
||||||
|
term.write(\\\"\\\\127\\\")\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
-- Padding\\\
|
||||||
|
term.setBackgroundColour( canvasColour )\\\
|
||||||
|
for i=20,h-1 do\\\
|
||||||
|
term.setCursorPos(w-1, i)\\\
|
||||||
|
term.write(\\\" \\\")\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
--[[ \\\
|
||||||
|
Converts a single pixel of a single line of the canvas and draws it\\\
|
||||||
|
returns: nil\\\
|
||||||
|
]]\\\
|
||||||
|
local function drawCanvasPixel( x, y )\\\
|
||||||
|
local pixel = getCanvasPixel( x, y )\\\
|
||||||
|
if pixel then\\\
|
||||||
|
term.setBackgroundColour( pixel or canvasColour )\\\
|
||||||
|
term.setCursorPos(x, y)\\\
|
||||||
|
term.write(\\\" \\\")\\\
|
||||||
|
else\\\
|
||||||
|
term.setBackgroundColour( canvasColour )\\\
|
||||||
|
term.setTextColour( colours.grey )\\\
|
||||||
|
term.setCursorPos(x, y)\\\
|
||||||
|
term.write(\\\"\\\\127\\\")\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
--[[ \\\
|
||||||
|
Converts each colour in a single line of the canvas and draws it\\\
|
||||||
|
returns: nil\\\
|
||||||
|
]]\\\
|
||||||
|
local function drawCanvasLine( y )\\\
|
||||||
|
for x = 1, 4 do\\\
|
||||||
|
drawCanvasPixel( x, y )\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
--[[ \\\
|
||||||
|
Converts each colour in the canvas and draws it\\\
|
||||||
|
returns: nil\\\
|
||||||
|
]]\\\
|
||||||
|
local function drawCanvas()\\\
|
||||||
|
for y = 1, 3 do\\\
|
||||||
|
drawCanvasLine( y )\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
--[[\\\
|
||||||
|
Draws menu options and handles input from within the menu.\\\
|
||||||
|
returns: true if the program is to be exited; false otherwise\\\
|
||||||
|
]]\\\
|
||||||
|
local function accessMenu()\\\
|
||||||
|
-- Selected menu option\\\
|
||||||
|
local selection = 1\\\
|
||||||
|
\\\
|
||||||
|
term.setBackgroundColour(colours.black)\\\
|
||||||
|
while true do\\\
|
||||||
|
-- Draw the menu\\\
|
||||||
|
term.setCursorPos(1,h)\\\
|
||||||
|
term.clearLine()\\\
|
||||||
|
term.setTextColour(colours.white)\\\
|
||||||
|
for k,v in pairs(mChoices) do\\\
|
||||||
|
if selection==k then \\\
|
||||||
|
term.setTextColour(colours.yellow)\\\
|
||||||
|
local ox,_ = term.getCursorPos()\\\
|
||||||
|
term.write(\\\"[\\\"..string.rep(\\\" \\\",#v)..\\\"]\\\")\\\
|
||||||
|
term.setCursorPos(ox+1,h)\\\
|
||||||
|
term.setTextColour(colours.white)\\\
|
||||||
|
term.write(v)\\\
|
||||||
|
term.setCursorPos(term.getCursorPos()+1,h)\\\
|
||||||
|
else\\\
|
||||||
|
term.write(\\\" \\\"..v..\\\" \\\")\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
-- Handle input in the menu\\\
|
||||||
|
local id,key = os.pullEvent(\\\"key\\\")\\\
|
||||||
|
if id == \\\"key\\\" then\\\
|
||||||
|
-- S and E are shortcuts\\\
|
||||||
|
if key == keys.s then\\\
|
||||||
|
selection = 1\\\
|
||||||
|
key = keys.enter\\\
|
||||||
|
elseif key == keys.e then\\\
|
||||||
|
selection = 2\\\
|
||||||
|
key = keys.enter\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
if key == keys.right then\\\
|
||||||
|
-- Move right\\\
|
||||||
|
selection = selection + 1\\\
|
||||||
|
if selection > #mChoices then\\\
|
||||||
|
selection = 1\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
elseif key == keys.left and selection > 1 then\\\
|
||||||
|
-- Move left\\\
|
||||||
|
selection = selection - 1\\\
|
||||||
|
if selection < 1 then\\\
|
||||||
|
selection = #mChoices\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
elseif key == keys.enter then\\\
|
||||||
|
-- Select an option\\\
|
||||||
|
if mChoices[selection]==\\\"Save\\\" then \\\
|
||||||
|
if bReadOnly then \\\
|
||||||
|
fMessage = \\\"Access Denied\\\"\\\
|
||||||
|
return false\\\
|
||||||
|
end\\\
|
||||||
|
local success = save(sPath)\\\
|
||||||
|
if success then\\\
|
||||||
|
fMessage = \\\"Saved to \\\"..sPath\\\
|
||||||
|
else\\\
|
||||||
|
fMessage = \\\"Error saving to \\\"..sPath\\\
|
||||||
|
end\\\
|
||||||
|
return false\\\
|
||||||
|
elseif mChoices[selection]==\\\"Exit\\\" then \\\
|
||||||
|
return true\\\
|
||||||
|
end\\\
|
||||||
|
elseif key == keys.leftCtrl or keys == keys.rightCtrl then\\\
|
||||||
|
-- Cancel the menu\\\
|
||||||
|
return false \\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
--[[ \\\
|
||||||
|
Runs the main thread of execution. Draws the canvas and interface, and handles\\\
|
||||||
|
mouse and key events.\\\
|
||||||
|
returns: nil\\\
|
||||||
|
]]\\\
|
||||||
|
local function handleEvents()\\\
|
||||||
|
local programActive = true\\\
|
||||||
|
while programActive do\\\
|
||||||
|
local id,p1,p2,p3 = os.pullEvent()\\\
|
||||||
|
if id==\\\"mouse_click\\\" or id==\\\"mouse_drag\\\" then\\\
|
||||||
|
if p2 >= w-1 and p3 >= 1 and p3 <= 17 then\\\
|
||||||
|
if id ~= \\\"mouse_drag\\\" then\\\
|
||||||
|
-- Selecting an items in the colour picker\\\
|
||||||
|
if p3 <= 16 then\\\
|
||||||
|
if p1==1 then\\\
|
||||||
|
leftColour = 2^(p3-1)\\\
|
||||||
|
else\\\
|
||||||
|
rightColour = 2^(p3-1)\\\
|
||||||
|
end\\\
|
||||||
|
else\\\
|
||||||
|
if p1==1 then\\\
|
||||||
|
leftColour = nil\\\
|
||||||
|
else\\\
|
||||||
|
rightColour = nil\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
--drawCanvas()\\\
|
||||||
|
drawInterface()\\\
|
||||||
|
end\\\
|
||||||
|
elseif p2 <= 4 and p3 <= 3 then\\\
|
||||||
|
-- Clicking on the canvas\\\
|
||||||
|
local paintColour = nil\\\
|
||||||
|
if p1==1 then\\\
|
||||||
|
paintColour = leftColour\\\
|
||||||
|
elseif p1==2 then\\\
|
||||||
|
paintColour = rightColour\\\
|
||||||
|
end\\\
|
||||||
|
if not canvas[p3] then\\\
|
||||||
|
canvas[p3] = {}\\\
|
||||||
|
end\\\
|
||||||
|
canvas[p3][p2] = paintColour\\\
|
||||||
|
\\\
|
||||||
|
drawCanvasPixel( p2, p3 )\\\
|
||||||
|
end\\\
|
||||||
|
elseif id==\\\"key\\\" then\\\
|
||||||
|
if p1==keys.leftCtrl or p1==keys.rightCtrl then\\\
|
||||||
|
programActive = not accessMenu()\\\
|
||||||
|
drawInterface()\\\
|
||||||
|
end\\\
|
||||||
|
elseif id==\\\"term_resize\\\" then\\\
|
||||||
|
w,h = term.getSize()\\\
|
||||||
|
drawCanvas()\\\
|
||||||
|
drawInterface()\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
-- Init\\\
|
||||||
|
load(sPath)\\\
|
||||||
|
drawCanvas()\\\
|
||||||
|
drawInterface()\\\
|
||||||
|
\\\
|
||||||
|
-- Main loop\\\
|
||||||
|
handleEvents()\\\
|
||||||
|
\\\
|
||||||
|
-- Shutdown\\\
|
||||||
|
term.setBackgroundColour(colours.black)\\\
|
||||||
|
term.setTextColour(colours.white)\\\
|
||||||
|
term.clear()\\\
|
||||||
|
term.setCursorPos(1,1)\\\
|
||||||
|
\",\
|
||||||
|
[ \"homeplus.lua\" ] = \"\\\
|
||||||
|
--setup\\\
|
||||||
|
if not fs.exists(spk.getDataPath()..\\\"/icons/sphone.shell\\\") then\\\
|
||||||
|
local f = spk.open(\\\"icons/sphone.shell\\\",\\\"w\\\")\\\
|
||||||
|
f.write(\\\"4fff\\\\nf4ff\\\\n4f44\\\")\\\
|
||||||
|
f.close()\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
if not fs.exists(spk.getDataPath()..\\\"/config\\\") then\\\
|
||||||
|
local f = spk.open(\\\"config\\\",\\\"w\\\")\\\
|
||||||
|
f.write(\\\"{[1] = {\\\\\\\"Shell\\\\\\\", \\\\\\\"sphone.launch\\\\\\\"},}\\\")\\\
|
||||||
|
f.close()\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
local iconPos = { --Because i hate math (to rewrite), anyway this is for the standard pocket computer size\\\
|
||||||
|
[1] = {3,2,6,4},\\\
|
||||||
|
[2] = {9,2,12,4},\\\
|
||||||
|
[3] = {15,2,18,4},\\\
|
||||||
|
[4] = {21,2,24,4},\\\
|
||||||
|
[5] = {3,8,6,10},\\\
|
||||||
|
[6] = {9,8,12,10},\\\
|
||||||
|
[7] = {15,8,18,10},\\\
|
||||||
|
[8] = {21,8,24,10},\\\
|
||||||
|
[9] = {3,14,6,16},\\\
|
||||||
|
[10] = {9,14,12,16},\\\
|
||||||
|
[11] = {15,14,18,16},\\\
|
||||||
|
[12] = {21,14,24,16},\\\
|
||||||
|
}\\\
|
||||||
|
\\\
|
||||||
|
local objectsDesktop = {}\\\
|
||||||
|
local objCoords = {}\\\
|
||||||
|
\\\
|
||||||
|
local f = spk.open(\\\"config\\\",\\\"r\\\")\\\
|
||||||
|
local objectsDesktop = textutils.unserialise(f.readAll())\\\
|
||||||
|
f.close()\\\
|
||||||
|
\\\
|
||||||
|
local function getCoords(iconNumber)\\\
|
||||||
|
if iconPos[iconNumber] then\\\
|
||||||
|
local x, y, maxx, maxy\\\
|
||||||
|
x = iconPos[iconNumber][1]\\\
|
||||||
|
y = iconPos[iconNumber][2]\\\
|
||||||
|
maxx = iconPos[iconNumber][3]\\\
|
||||||
|
maxy = iconPos[iconNumber][4]\\\
|
||||||
|
return x,y,maxx,maxy\\\
|
||||||
|
end\\\
|
||||||
|
return false\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
function getProgram(x,y)\\\
|
||||||
|
for k,v in pairs(objCoords) do\\\
|
||||||
|
local px, py, pex, pey = v[1],v[2],v[3],v[4]\\\
|
||||||
|
if x >= px and y >= py and x <= pex and y <= pey then\\\
|
||||||
|
return objectsDesktop[k][1], objectsDesktop[k][2]\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
local function homeSettings()\\\
|
||||||
|
local menu = {\\\
|
||||||
|
\\\"Add app\\\",\\\
|
||||||
|
\\\"Remove app\\\",\\\
|
||||||
|
}\\\
|
||||||
|
while true do\\\
|
||||||
|
local _, id = sPhone.menu(menu,\\\"Home+\\\",\\\"X\\\")\\\
|
||||||
|
if id == 0 then\\\
|
||||||
|
break\\\
|
||||||
|
elseif id == 1 then\\\
|
||||||
|
local function redraw()\\\
|
||||||
|
term.setBackgroundColor(sPhone.theme[\\\"backgroundColor\\\"])\\\
|
||||||
|
term.setTextColor(sPhone.theme[\\\"text\\\"])\\\
|
||||||
|
term.clear()\\\
|
||||||
|
sPhone.header(\\\"Home+: Add\\\",\\\"X\\\")\\\
|
||||||
|
for k,v in pairs(iconPos) do\\\
|
||||||
|
paintutils.drawFilledBox(v[1],v[2]+1,v[3],v[4]+1,colors.red)\\\
|
||||||
|
end\\\
|
||||||
|
for k, v in pairs(objCoords) do\\\
|
||||||
|
paintutils.drawFilledBox(v[1],v[2]+1,v[3],v[4]+1,colors.lime)\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
redraw()\\\
|
||||||
|
local w, h = term.getSize()\\\
|
||||||
|
while true do\\\
|
||||||
|
redraw()\\\
|
||||||
|
local _,_,x,y = os.pullEvent(\\\"mouse_click\\\")\\\
|
||||||
|
if y == 1 and x == w then\\\
|
||||||
|
break\\\
|
||||||
|
else\\\
|
||||||
|
local a = getProgram(x-1,y-1)\\\
|
||||||
|
if not a then\\\
|
||||||
|
for k, v in pairs(iconPos) do\\\
|
||||||
|
if (x >= v[1] and y >= v[2]) and (x <= v[3] and y <= v[4]) then\\\
|
||||||
|
local iconPoss = k\\\
|
||||||
|
local ll = config.list(\\\"/.sPhone/config/spklist\\\")\\\
|
||||||
|
-- for k,v in pairs(ll) do\\\
|
||||||
|
-- if config.read\\\
|
||||||
|
-- end\\\
|
||||||
|
local spkID,name = sPhone.list(nil,{\\\
|
||||||
|
list = ll,\\\
|
||||||
|
pairs = true,\\\
|
||||||
|
title = \\\" Add App\\\"\\\
|
||||||
|
})\\\
|
||||||
|
if not spkID then\\\
|
||||||
|
return\\\
|
||||||
|
else\\\
|
||||||
|
local f = spk.open(\\\"config\\\",\\\"r\\\")\\\
|
||||||
|
local ics = textutils.unserialise(f.readAll())\\\
|
||||||
|
f.close()\\\
|
||||||
|
ics[iconPoss] = {name,spkID}\\\
|
||||||
|
objectsDesktop[iconPoss] = {name,spkID}\\\
|
||||||
|
local f = spk.open(\\\"config\\\",\\\"w\\\")\\\
|
||||||
|
f.write(textutils.serialize(ics))\\\
|
||||||
|
f.close()\\\
|
||||||
|
shell.run(spk.getPath()..\\\"/files/paint.lua\\\",spk.getDataPath()..\\\"/icons/\\\"..spkID)\\\
|
||||||
|
sPhone.winOk(\\\"Done!\\\")\\\
|
||||||
|
end\\\
|
||||||
|
break\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
break\\\
|
||||||
|
elseif id == 2 then\\\
|
||||||
|
local function redraw()\\\
|
||||||
|
term.setBackgroundColor(sPhone.theme[\\\"backgroundColor\\\"])\\\
|
||||||
|
term.setTextColor(sPhone.theme[\\\"text\\\"])\\\
|
||||||
|
term.clear()\\\
|
||||||
|
sPhone.header(\\\"Home+: Remove\\\",\\\"X\\\")\\\
|
||||||
|
for k,v in pairs(iconPos) do\\\
|
||||||
|
paintutils.drawFilledBox(v[1],v[2]+1,v[3],v[4]+1,colors.red)\\\
|
||||||
|
end\\\
|
||||||
|
for k, v in pairs(objCoords) do\\\
|
||||||
|
paintutils.drawFilledBox(v[1],v[2]+1,v[3],v[4]+1,colors.lime)\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
redraw()\\\
|
||||||
|
local w, h = term.getSize()\\\
|
||||||
|
while true do\\\
|
||||||
|
redraw()\\\
|
||||||
|
local _,_,x,y = os.pullEvent(\\\"mouse_click\\\")\\\
|
||||||
|
if y == 1 and x == w then\\\
|
||||||
|
break\\\
|
||||||
|
else\\\
|
||||||
|
local a = getProgram(x-1,y-1)\\\
|
||||||
|
if a then\\\
|
||||||
|
for k, v in pairs(iconPos) do\\\
|
||||||
|
if (x >= v[1] and y >= v[2]) and (x <= v[3] and y <= v[4]) then\\\
|
||||||
|
local iconPoss = k\\\
|
||||||
|
term.setBackgroundColor(sPhone.theme[\\\"backgroundColor\\\"])\\\
|
||||||
|
term.setTextColor(sPhone.theme[\\\"text\\\"])\\\
|
||||||
|
term.clear()\\\
|
||||||
|
local f = spk.open(\\\"config\\\",\\\"r\\\")\\\
|
||||||
|
local ics = textutils.unserialise(f.readAll())\\\
|
||||||
|
f.close()\\\
|
||||||
|
ics[iconPoss] = nil\\\
|
||||||
|
objectsDesktop[iconPoss] = nil\\\
|
||||||
|
local f = spk.open(\\\"config\\\",\\\"w\\\")\\\
|
||||||
|
f.write(textutils.serialize(ics))\\\
|
||||||
|
f.close()\\\
|
||||||
|
sPhone.winOk(\\\"Done!\\\")\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
break\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
local function footer()\\\
|
||||||
|
local menu = {\\\
|
||||||
|
\\\"Settings\\\",\\\
|
||||||
|
\\\"Home+ Settings\\\",\\\
|
||||||
|
\\\"Lock\\\",\\\
|
||||||
|
\\\"Info\\\",\\\
|
||||||
|
\\\"Shutdown\\\",\\\
|
||||||
|
\\\"Reboot\\\",\\\
|
||||||
|
}\\\
|
||||||
|
\\\
|
||||||
|
while true do\\\
|
||||||
|
local name, id = sPhone.menu(menu,\\\"Home+\\\",\\\"V\\\")\\\
|
||||||
|
if id == 0 then\\\
|
||||||
|
break\\\
|
||||||
|
elseif id == 1 then\\\
|
||||||
|
sPhone.launch(\\\"sphone.settings\\\")\\\
|
||||||
|
break\\\
|
||||||
|
elseif id == 2 then\\\
|
||||||
|
homeSettings()\\\
|
||||||
|
elseif id == 3 then\\\
|
||||||
|
sPhone.login()\\\
|
||||||
|
break\\\
|
||||||
|
elseif id == 4 then\\\
|
||||||
|
sPhone.launch(\\\"sphone.info\\\")\\\
|
||||||
|
break\\\
|
||||||
|
elseif id == 5 then\\\
|
||||||
|
os.shutdown()\\\
|
||||||
|
elseif id == 6 then\\\
|
||||||
|
os.reboot()\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
local function redraw()\\\
|
||||||
|
term.setBackgroundColor(sPhone.getTheme(\\\"backgroundColor\\\"))\\\
|
||||||
|
term.setTextColor(sPhone.getTheme(\\\"text\\\"))\\\
|
||||||
|
term.clear()\\\
|
||||||
|
term.setCursorPos(1,1)\\\
|
||||||
|
for k, v in pairs(objectsDesktop) do\\\
|
||||||
|
local x, y,endx,endy = getCoords(k)\\\
|
||||||
|
objCoords[k] = {x,y,endx,endy}\\\
|
||||||
|
local loI\\\
|
||||||
|
if not fs.exists(spk.getDataPath()..\\\"/icons/\\\"..v[2]) then\\\
|
||||||
|
loI = spk.getDataPath()..\\\"/icons/sphone.shell\\\"\\\
|
||||||
|
else\\\
|
||||||
|
loI = spk.getDataPath()..\\\"/icons/\\\"..v[2]\\\
|
||||||
|
end\\\
|
||||||
|
local icon = paintutils.loadImage(loI)\\\
|
||||||
|
paintutils.drawImage(icon,x,y)\\\
|
||||||
|
local name, sndName\\\
|
||||||
|
if #v[1] > 5 then\\\
|
||||||
|
term.setCursorPos(endx-3,endy+1)\\\
|
||||||
|
name = string.sub(objectsDesktop[k][1],1,5)\\\
|
||||||
|
sndName = string.sub(objectsDesktop[k][1],6,(10 or #v[1]))\\\
|
||||||
|
else\\\
|
||||||
|
name = objectsDesktop[k][1]\\\
|
||||||
|
term.setCursorPos(endx-3,endy+1)\\\
|
||||||
|
end\\\
|
||||||
|
term.setBackgroundColour(sPhone.getTheme(\\\"backgroundColor\\\"))\\\
|
||||||
|
write(name)\\\
|
||||||
|
if sndName then\\\
|
||||||
|
term.setCursorPos(endx-3,endy+2)\\\
|
||||||
|
write(sndName)\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
local w,h = term.getSize()\\\
|
||||||
|
paintutils.drawLine(1,h,w,h,sPhone.getTheme(\\\"header\\\"))\\\
|
||||||
|
term.setTextColor(sPhone.getTheme(\\\"headerText\\\"))\\\
|
||||||
|
term.setCursorPos(12,h)\\\
|
||||||
|
write(\\\"====\\\")\\\
|
||||||
|
term.setCursorPos(w-3,h)\\\
|
||||||
|
write(\\\"^^^\\\")\\\
|
||||||
|
term.setCursorPos(w-6,h)\\\
|
||||||
|
write(\\\"S\\\")\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
local function main()\\\
|
||||||
|
while true do\\\
|
||||||
|
redraw()\\\
|
||||||
|
local ev = {os.pullEvent()}\\\
|
||||||
|
if ev[1] == \\\"key\\\" and ev[2] == keys.leftAlt then\\\
|
||||||
|
sPhone.inHome = false\\\
|
||||||
|
term.setBackgroundColor(colors.black)\\\
|
||||||
|
term.setTextColor(colors.white)\\\
|
||||||
|
term.clear()\\\
|
||||||
|
term.setCursorPos(1,1)\\\
|
||||||
|
sleep(0.1)\\\
|
||||||
|
sPhone.launch(\\\"sphone.shell\\\")\\\
|
||||||
|
sPhone.inHome = true\\\
|
||||||
|
elseif ev[1] == \\\"mouse_click\\\" then\\\
|
||||||
|
local x, y = ev[3], ev[4]\\\
|
||||||
|
local w,h = term.getSize()\\\
|
||||||
|
if y == h then\\\
|
||||||
|
if x >= 12 and x <= 15 then\\\
|
||||||
|
sPhone.inHome = false\\\
|
||||||
|
sleep(0.1)\\\
|
||||||
|
sPhone.launch(\\\"sphone.appList\\\")\\\
|
||||||
|
sPhone.inHome = true\\\
|
||||||
|
elseif x == w-6 then\\\
|
||||||
|
sPhone.inHome = false\\\
|
||||||
|
term.setBackgroundColor(colors.black)\\\
|
||||||
|
term.setTextColor(colors.white)\\\
|
||||||
|
term.clear()\\\
|
||||||
|
term.setCursorPos(1,1)\\\
|
||||||
|
sleep(0.1)\\\
|
||||||
|
sPhone.launch(\\\"sphone.store\\\")\\\
|
||||||
|
sPhone.inHome = true\\\
|
||||||
|
elseif x <= w-1 and x >= w-3 then\\\
|
||||||
|
sPhone.inHome = false\\\
|
||||||
|
footer()\\\
|
||||||
|
sPhone.inHome = true\\\
|
||||||
|
end\\\
|
||||||
|
else\\\
|
||||||
|
local appName, appPath = getProgram(x,y)\\\
|
||||||
|
if appName then\\\
|
||||||
|
sPhone.inHome = false\\\
|
||||||
|
sPhone.launch(appPath)\\\
|
||||||
|
sPhone.inHome = true\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
local function clockUpdate()\\\
|
||||||
|
local w,h = term.getSize()\\\
|
||||||
|
while true do\\\
|
||||||
|
if sPhone.inHome then\\\
|
||||||
|
term.setCursorBlink(false)\\\
|
||||||
|
term.setBackgroundColor(sPhone.theme[\\\"header\\\"])\\\
|
||||||
|
term.setTextColor(sPhone.theme[\\\"headerText\\\"])\\\
|
||||||
|
term.setCursorPos(1,h)\\\
|
||||||
|
write(\\\" \\\")\\\
|
||||||
|
term.setCursorPos(1,h)\\\
|
||||||
|
write(\\\" \\\"..textutils.formatTime(os.time(),true))\\\
|
||||||
|
end\\\
|
||||||
|
sleep(0)\\\
|
||||||
|
end\\\
|
||||||
|
end\\\
|
||||||
|
\\\
|
||||||
|
parallel.waitForAll(main,clockUpdate)\\\
|
||||||
|
\",\
|
||||||
|
}",
|
||||||
|
config = "{\
|
||||||
|
type = \"home\",\
|
||||||
|
name = \"Home+\",\
|
||||||
|
version = 2,\
|
||||||
|
main = \"homeplus.lua\",\
|
||||||
|
id = \"ale32bit.homeplus\",\
|
||||||
|
author = \"Ale32bit\",\
|
||||||
|
hidden = true,\
|
||||||
|
}",
|
||||||
|
}
|
|
@ -15,11 +15,11 @@ os.pullEvent(\\\"key\\\")\\\
|
||||||
\",\
|
\",\
|
||||||
}",
|
}",
|
||||||
config = "{\
|
config = "{\
|
||||||
|
type = \"app\",\
|
||||||
main = \"exa.lua\",\
|
main = \"exa.lua\",\
|
||||||
name = \"SPK Example\",\
|
name = \"SPK Example\",\
|
||||||
id = \"sphone.examplespk\",\
|
id = \"sphone.examplespk\",\
|
||||||
author = \"BeaconNet\",\
|
|
||||||
version = 1.3,\
|
version = 1.3,\
|
||||||
type = \"app\",\
|
author = \"BeaconNet\",\
|
||||||
}",
|
}",
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ local kristUrl = \\\"https://raw.github.com/jakemroman/JakeHub/master/kstapi\\\"
|
||||||
local walletUrl = \\\"https://raw.github.com/jakemroman/QuantumPay/master/wallet.lua\\\"\\r\\\
|
local walletUrl = \\\"https://raw.github.com/jakemroman/QuantumPay/master/wallet.lua\\\"\\r\\\
|
||||||
local currentVersion = 1.2\\r\\\
|
local currentVersion = 1.2\\r\\\
|
||||||
if not fs.exists(spk.getDataPath()..'/kristapi') then\\r\\\
|
if not fs.exists(spk.getDataPath()..'/kristapi') then\\r\\\
|
||||||
|
print(\\\"Downloading resources...\\\")\\r\\\
|
||||||
f = spk.open(\\\"/kristapi\\\",\\\"w\\\")\\r\\\
|
f = spk.open(\\\"/kristapi\\\",\\\"w\\\")\\r\\\
|
||||||
f.writeLine(http.get(kristUrl).readAll())\\r\\\
|
f.writeLine(http.get(kristUrl).readAll())\\r\\\
|
||||||
f.close()\\r\\\
|
f.close()\\r\\\
|
||||||
|
@ -305,10 +306,11 @@ if not ok then\\r\\\
|
||||||
end\",\
|
end\",\
|
||||||
}",
|
}",
|
||||||
config = "{\
|
config = "{\
|
||||||
main = \"qpay.lua\",\
|
type = \"app\",\
|
||||||
|
author = \"jakejakey1208\",\
|
||||||
name = \"QPay\",\
|
name = \"QPay\",\
|
||||||
id = \"quantumtech.qpay\",\
|
id = \"quantumtech.qpay\",\
|
||||||
author = \"jakejakey1208\",\
|
|
||||||
version = 1.2,\
|
version = 1.2,\
|
||||||
|
main = \"qpay.lua\",\
|
||||||
}",
|
}",
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
{
|
{
|
||||||
["Ale32bit/bluecloud.spk"] = "BlueCloud",
|
["Ale32bit/bluecloud.spk"] = "BlueCloud",
|
||||||
["Ale32bit/beam.spk"] = "Beam",
|
["Ale32bit/beam.spk"] = "Beam",
|
||||||
|
["Ale32bit/homeplus.spk"] = "Home+",
|
||||||
["QuantumTech/qpay.spk"] = "QPay",
|
["QuantumTech/qpay.spk"] = "QPay",
|
||||||
["BeaconNet/example.spk"] = "SPK Example",
|
["BeaconNet/example.spk"] = "SPK Example",
|
||||||
|
["3d6/kristwallet.spk"] = "Krist Wallet",
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue