Commit 8883dffb authored by Danny SMc's avatar Danny SMc

Added apps functions and feed functions

parent 98b1bf0d
......@@ -44,7 +44,7 @@ function program.apps.all(appslist, filter)
program.draw.menubar("Apps: All")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menubar_input("Apps: All", args[3], args[4])
program.draw.menu.handler("Apps: All", args[3], args[4])
elseif (args[3] >= 1 and args[3] <= 25) and (args[4] == 3) then
program.apps.categories()
elseif (args[3] >= 26 and args[3] <= 51) and (args[4] == 3) then
......@@ -53,8 +53,8 @@ function program.apps.all(appslist, filter)
local curid = args[4] - 4 + scroll
local tname = "View"..tostring(appslist[curid].id)
base.thread.create(tname, program.apps.view)
viewapps[1] = appslist[curid].id
viewapps[2] = appslist
Internal.Swap.Viewer[1] = appslist[curid].id
Internal.Swap.Viewer[2] = appslist
base.thread.switch(tname)
end
elseif args[1] == "mouse_scroll" then
......
--[[
Name: apps.categories
Desc: App categories screen function
--]]
\ No newline at end of file
--]]
function program.apps.categories()
base.screen.colour("white")
program.draw.menubar("Categories")
base.draw.box(21, 1, 5, 13, "|", "lightGrey", "white")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
-- Vars
local lscroll = 0
local rscroll = 0
local status, ldata = Discover.Apps:List('categories');
local rdata = {}
local lselect = ""
local status, allapps = Discover.Apps:List('apps');
base.draw.texta("Total Categories: "..#allapps, 2, 19, false, "lightBlue", "grey")
base.draw.textr("SCroll Enabled", 19, false, "orange", "grey")
base.draw.texta(" All | Versions ", 1, 3, false, "white", "lightGrey")
local function lrun(lscroll)
for i=1, 13 do
if #ldata >= i + lscroll then
if lselect == ldata[i+lscroll] then
base.draw.box(1, 19, i+4, 1, " ", "white", "white")
base.draw.texta(ldata[i+lscroll], 1, i+4, false, "grey", "white")
else
base.draw.box(1, 19, i+4, 1, " ", "white", "white")
base.draw.texta(ldata[i+lscroll], 1, i+4, false, "cyan", "white")
end
end
end
end
local function rrun(rscroll)
for i=1, 13 do
if #rdata >= i + rscroll then
base.draw.box(22, 29, i+4, 1, " ", "white", "white")
base.draw.texta(rdata[i+rscroll].name:sub(1, 25), 23, i+4, false, "grey", "white")
end
end
end
lrun(lscroll)
rrun(rscroll)
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Categories")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Categories", args[3], args[4])
elseif (args[3] >= 1 and args[3] <= 25) and (args[4] == 3) then
program.apps.all()
elseif (args[3] >= 26 and args[3] <= 51) and (args[4] == 3) then
program.apps.versions()
elseif (args[3] >= 1 and args[3] <= 20) and (args[4] >= 5 and args[4] <= 17) then
-- Choose
local cid = args[4] - 4 + lscroll
if #ldata >= cid then
lselect = ldata[cid]
rdata = {}
for k,v in ipairs(allapps) do
if v.category == lselect then
rdata[#rdata+1] = v
end
end
for i=1, 14 do
base.draw.box(22, 29, i+3, 1, false, "white", "white")
end
rscroll = 0
rrun(rscroll)
lrun(lscroll)
end
elseif (args[3] >= 22 and args[3] <= 51) and (args[4] >= 5 and args[4] <= 17) then
-- View app
local cid = args[4] - 4 + rscroll
if #rdata >= cid then
Internal.Swap.Viewer[1] = rdata[cid].id
Internal.Swap.Viewer[2] = allapps
if not base.thread.find("View"..tostring(rdata[cid].id)) then
base.thread.create("View"..tostring(rdata[cid].id), program.apps.view)
end
base.thread.switch("View"..tostring(rdata[cid].id))
end
end
elseif args[1] == "mouse_scroll" then
if args[2] == -1 then
if (args[3] >= 1 and args[3] <= 20) and (args[4] >= 4 and args[4] <= 17) then
if lscroll > 0 then
lscroll = lscroll - 1
lrun(lscroll)
end
elseif (args[3] >= 22 and args[3] <= 51) and (args[4] >= 4 and args[4] <= 17) then
if rscroll > 0 then
rscroll = rscroll - 1
rrun(rscroll)
end
end
elseif args[2] == 1 then
if (args[3] >= 1 and args[3] <= 20) and (args[4] >= 4 and args[4] <= 17) then
if lscroll + 14 <= #ldata-1 then
lscroll = lscroll + 1
lrun(lscroll)
end
elseif (args[3] >= 22 and args[3] <= 51) and (args[4] >= 4 and args[4] <= 17) then
if rscroll + 14 <= #rdata-1 then
rscroll = rscroll + 1
rrun(rscroll)
end
end
end
end
end
end
\ No newline at end of file
function program.apps.download()
base.screen.colour("white")
program.draw.menubar("Download")
local appid = Internal.Swap.Download
local text = "You are attempting to download an app, please choose a name for the file download";
local function run()
for k,v in ipairs(base.data.wordwrap(text, 45)) do
base.draw.textc(v, k+3, false, "grey", "white")
end
base.draw.texta("File Name / Path:", 8, 8, false, "lightGrey", "white")
base.draw.box(8, 36, 9, 1, " ", "cyan", "cyan")
base.draw.texta(" Download ", 8, 12, false, "white", "cyan")
base.draw.texta(" Cancel ", 36, 12, false, "white", "cyan")
end
run()
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Download")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Download", args[3], args[4])
elseif (args[3] >= 8 and args[3] <= 17) and (args[4] == 12) then
if filepath then
local status = Discover.Apps:Download(appid, filepath)
base.gui.alert("Saved!")
sleep(1)
base.thread.remove("Download" .. tostring(appid))
if not base.thread.find("Apps") then
base.thread.create("Apps", program.apps.all)
end
base.thread.switch("Apps")
else
base.draw.box(1, 51, 14, 1, " ", "white", "white")
base.draw.textc("Please supply a file path / name!", 14, false, "lightGrey", "white")
end
elseif (args[3] >= 36 and args[3] <= 43) and (args[4] == 12) then
base.thread.remove("Download"..tostring(appid))
base.thread.switch("Home")
elseif (args[3] >= 8 and args[3] <= 43) and (args[4] == 9) then
base.draw.box(8, 36, 9, 1, " ", "cyan", "cyan")
base.colour.set("white", "cyan")
term.setCursorPos(8, 9)
write(": ")
filepath = tostring(base.io.limitRead(34))
end
end
end
end
\ No newline at end of file
--[[
Name: apps.downloads
Desc: Versions listing screen function
--]]
\ No newline at end of file
--]]
function program.apps.versions(version)
base.screen.colour("white")
program.draw.menubar("Versions")
base.draw.box(21, 1, 5, 13, "|", "lightGrey", "white")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
-- Vars
local lscroll = 0
local rscroll = 0
local status, ldata = Discover.Apps:List("versions");
local rdata = {}
local lselect = ""
local status, allapps = Discover.Apps:List("apps");
base.draw.texta("Total Versions: "..#allapps, 2, 19, false, "lightBlue", "grey")
base.draw.textr("SCroll Enabled", 19, false, "orange", "grey")
base.draw.texta(" All | Categories ", 1, 3, false, "white", "lightGrey")
local function lrun(lscroll)
for i=1, 13 do
if #ldata >= i + lscroll then
if lselect == ldata[i+lscroll] then
base.draw.box(1, 19, i+4, 1, " ", "white", "white")
base.draw.texta(ldata[i+lscroll], 1, i+4, false, "grey", "white")
else
base.draw.box(1, 19, i+4, 1, " ", "white", "white")
base.draw.texta(ldata[i+lscroll], 1, i+4, false, "cyan", "white")
end
end
end
end
local function rrun(rscroll)
for i=1, 13 do
if #rdata >= i + rscroll then
base.draw.box(22, 29, i+4, 1, " ", "white", "white")
base.draw.texta(rdata[i+rscroll].name:sub(1, 25), 23, i+4, false, "grey", "white")
end
end
end
lrun(lscroll)
rrun(rscroll)
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Versions")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Versions", args[3], args[4])
elseif (args[3] >= 1 and args[3] <= 25) and (args[4] == 3) then
program.apps.all()
elseif (args[3] >= 26 and args[3] <= 51) and (args[4] == 3) then
program.apps.categories()
elseif (args[3] >= 1 and args[3] <= 20) and (args[4] >= 5 and args[4] <= 17) then
-- Choose
local cid = args[4] - 4 + lscroll
if #ldata >= cid then
lselect = ldata[cid]
rdata = {}
for k,v in ipairs(allapps) do
if v.version == lselect then
rdata[#rdata+1] = v
end
end
for i=1, 13 do
base.draw.box(22, 29, i+3, 1, false, "white", "white")
end
rscroll = 0
rrun(rscroll)
lrun(lscroll)
end
elseif (args[3] >= 22 and args[3] <= 51) and (args[4] >= 5 and args[4] <= 17) then
-- View app
local cid = args[4] - 4 + rscroll
if #rdata >= cid then
Internal.Swap.Viewer[1] = rdata[cid].id
Internal.Swap.Viewer[2] = allapps
if not base.thread.find("View"..tostring(rdata[cid].id)) then
base.thread.create("View"..tostring(rdata[cid].id), program.apps.view)
end
base.thread.switch("View"..tostring(rdata[cid].id))
end
end
elseif args[1] == "mouse_scroll" then
if args[2] == -1 then
if (args[3] >= 1 and args[3] <= 20) and (args[4] >= 5 and args[4] <= 17) then
if lscroll > 0 then
lscroll = lscroll - 1
lrun(lscroll)
end
elseif (args[3] >= 22 and args[3] <= 51) and (args[4] >= 5 and args[4] <= 17) then
if rscroll > 0 then
rscroll = rscroll - 1
rrun(rscroll)
end
end
elseif args[2] == 1 then
if (args[3] >= 1 and args[3] <= 20) and (args[4] >= 5 and args[4] <= 17) then
if lscroll + 13 <= #ldata-1 then
lscroll = lscroll + 1
lrun(lscroll)
end
elseif (args[3] >= 22 and args[3] <= 51) and (args[4] >= 5 and args[4] <= 17) then
if rscroll + 13 <= #rdata-1 then
rscroll = rscroll + 1
rrun(rscroll)
end
end
end
end
end
end
\ No newline at end of file
function program.apps.view()
base.screen.colour("white")
base.draw.textc("Loading...", 9, false, "grey", "white")
local scroll = 0
local appid = Internal.Swap.Viewer[1]
local appslist = Internal.Swap.Viewer[2]
for k,v in ipairs(appslist) do
if tonumber(v.id) == tonumber(appid) then
apppos = k
break
end
end
local appdesc = base.data.wordwrap(appslist[apppos].description, 49)
base.screen.colour("white")
program.draw.menubar("View App "..tostring(appslist[apppos].id))
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.texta("Comments", 2, 19, false, "lightBlue", "grey")
local function drawdesc(scroll)
for i = 1, 7 do
if #appdesc >= i + scroll then
base.draw.box(1, 51, i+9, 1, " ", "white", "white")
base.draw.textl(appdesc[i+scroll], i+9, false, "grey", "white")
end
end
end
local function run()
base.draw.textl("Name (ID):", 4, false, "lightGrey", "white")
base.draw.texta(appslist[apppos].name.." ("..appslist[apppos].id..")", 12, 4, false, "grey", "white")
base.draw.textl("Category:", 5, false, "lightGrey", "white")
base.draw.texta(appslist[apppos].category, 12, 5, false, "grey", "white")
base.draw.textl("Version:", 6, false, "lightGrey", "white")
base.draw.texta(appslist[apppos].version, 12, 6, false, "grey", "white")
base.draw.textl("Creator:", 7, false, "lightGrey", "white")
base.draw.texta(appslist[apppos].creator, 12, 7, false, "grey", "white")
base.draw.textl("App Hash:", 18, false, "lightGrey", "white")
base.draw.texta(appslist[apppos].hash, 11, 18, false, "grey", "white")
base.draw.textl("Description", 9, false, "lightGrey", "white")
base.draw.textr(appslist[apppos].downloads.." download(s) ", 19, false, "orange", "grey")
drawdesc(scroll)
base.draw.texta(" Download ", 41, 5, false, "white", "cyan")
base.draw.texta(" App! ", 41, 6, false, "white", "cyan")
end
run()
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("View App "..tostring(appslist[apppos].id))
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Help / FAQ", args[3], args[4])
elseif (args[3] >= 41 and args[3] <= 50) and (args[4] >= 5 and args[4] <= 6) then
Internal.Swap.Download = appslist[apppos].id
base.thread.create("Download"..tostring(appslist[apppos].id), program.apps.download)
base.thread.switch("Download"..tostring(appslist[apppos].id))
elseif (args[3] >= 2 and args[3] <= 9) and args[4] == 19 then
program.apps.comments(appslist[apppos].id)
base.screen.colour("white")
program.draw.menubar("View App "..tostring(appslist[apppos].id))
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.texta("Comments", 2, 19, false, "lightBlue", "grey")
run()
end
elseif args[1] == "mouse_scroll" then
if args[2] == -1 then
if scroll > 0 then
scroll = scroll - 1
run(scroll)
end
elseif args[2] == 1 then
if scroll + 14 <= #appdesc then
scroll = scroll + 1
run(scroll)
end
end
end
end
end
\ No newline at end of file
......@@ -18,6 +18,9 @@ local paths = {
"main/main.home.lua";
"main/main.alerts.lua";
"apps/apps.all.lua";
"apps/apps.view.lua";
"apps/apps.download.lua";
"feed/feed.view.lua";
"account/account.login.lua";
"account/account.logout.lua";
"apps/apps.categories.lua";
......
......@@ -25,6 +25,9 @@ Internal = {
Thread = {
History = {};
};
Swap = {
Viewer = {};
};
}
local screenx, screeny = term.getSize();
......
This diff is collapsed.
function program.feed.view(page)
base.screen.colour("white")
program.draw.menubar("Feed")
local feed = {}; local scroll = 0;
base.draw.textc("Downloading feed, please wait...", 10, false, "red", "white")
local status, feeddata = Discover.Feed:List()
if not status then
base.gui.alert("Could not download feed")
sleep(1)
base.thread.remove("Feed")
base.thread.switch("Home")
end
base.draw.box(1, 51, 10, 1, " ", "white", "white")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textl(" Create Post", 19, false, "lightBlue", "grey")
base.draw.textr("Refresh ", 19, false, "lightBlue", "grey")
local function parse()
feed = {}; table.insert(feed, ":B:")
for k,v in ipairs(feeddata) do
table.insert(feed, ":A:" .. v.author)
for i, j in ipairs(base.data.wordwrap(v.message, 45)) do
table.insert(feed, ":M:" .. j)
end
table.insert(feed, ":T:" .. v.sent_time)
table.insert(feed, ":B:")
end
end
local function render()
for i=3, 18 do base.draw.box(1, 51, i, 1, " ", "white", "white") end
base.draw.textc("No feed posts to show", 10, false, "red", "white")
if #feed > 0 then
for i=1, 14 do
if i+scroll <= #feed then
base.draw.box(1, 51, i+3, 1, " ", "white","white")
if feed[i+scroll]:sub(1,3) == ":A:" then
base.draw.textl(" " .. feed[i+scroll]:sub(4), i+3, false, "red", "white")
elseif feed[i+scroll]:sub(1,3) == ":M:" then
base.draw.textl(" " .. feed[i+scroll]:sub(4), i+3, false, "cyan", "white")
elseif feed[i+scroll]:sub(1,3) == ":T:" then
base.draw.textr(feed[i+scroll]:sub(4) .. " ", i+3, false, "orange", "white")
elseif feed[i+scroll]:sub(1,3) == ":B:" then
base.draw.textc("- - - - - - - - - - - - - - - - - - - - - - - -", i+3, false, "lightGrey", "white")
else
-- Leave space
end
end
end
else
for i=3, 18 do base.draw.box(1, 51, i, 1, " ", "white", "white") end
base.draw.textc("No feed posts to show", 10, false, "red", "white")
end
end
parse(); render();
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Feed")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Feed", args[3], args[4])
elseif (args[3] >= 2 and args[3] <= 12) and args[4] == 19 then
local message = base.gui.input("What do you want to say?")
local status = Discover.Feed:Create(message)
if not status then
base.gui.alert("Could not create new post")
sleep(1)
store.social.feed()
end
base.gui.alert("Submitted!"); sleep(0.5);
base.gui.alert("Updating feed..."); sleep(0.5)
status, feeddata = Discover.Feed:List()
if not status then
base.gui.alert("Could not download feed")
sleep(1)
base.thread.remove("Feed")
base.thread.switch("Home")
end
parse(); render();
elseif (args[3] >= 44 and args[3] <= 50) and args[4] == 19 then
base.gui.alert("Downloading feed, please wait..."); sleep(0.5)
status, feeddata = Discover.Feed:List()
if not status then
base.gui.alert("Could not download feed")
sleep(1)
base.thread.remove("Feed")
base.thread.switch("Home")
end
parse(); render();
end
elseif args[1] == "mouse_scroll" then
if args[2] == -1 then
if scroll > 0 then
scroll = scroll - 1
render();
end
elseif args[2] == 1 then
if (scroll + 14) < #feed then
scroll = scroll + 1
render();
end
end
end
end
end
\ No newline at end of file
......@@ -121,10 +121,11 @@ end
function program.draw.menu.tasks(open, animate)
if open then
if animate then
for i=51, 1, -2 do
base.draw.box(i, 2, 2, 1, " ", "lightGrey", "lightGrey")
for i=51, 1, -3 do
base.draw.box(i, 3, 2, 1, " ", "lightGrey", "lightGrey")
sleep(0.001)
end
base.draw.box(1, 51, 2, 1, " ", "lightGrey", "lightGrey")
base.draw.textr("Close >", 2, false, "white", "lightGrey")
local chars = {3, 13, 23, 33}
local text = {"Dash", "Apps", "Cloud", "Mail", "Settings", "CronTab"}
......@@ -170,10 +171,11 @@ function program.draw.menu.tasks(open, animate)
end
else
if animate then
for i=1, 51, 2 do
base.draw.box(i, 2, 2, 1, " ", "grey", "grey")
for i=1, 51, 3 do
base.draw.box(i, 3, 2, 1, " ", "grey", "grey")
sleep(0.001)
end
base.draw.box(1, 51, 2, 1, " ", "grey", "grey")
os.startTimer(1);
end
base.draw.textl(Internal.System.ActiveScreen, 2, false, "black", "grey");
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment