Commit 04c58692 authored by Danny SMc's avatar Danny SMc

Added all apps page, added fixed menu bar and home/menu code so it works, as...

Added all apps page, added fixed menu bar and home/menu code so it works, as well as added DA API for OS integration and added the alerts
parent bf7e7fd9
--[[
Name: apps.all
Desc: All apps screen function
--]]
\ No newline at end of file
Desc: Apps: All screen function
--]]
function program.apps.all(appslist, filter)
base.screen.colour("white")
program.draw.menubar("Apps: All")
local scroll = 0
base.draw.textc("Downloading Apps Listing...", 10, false, "red", "white")
status, appslist = Discover.Apps:List("apps")
base.draw.box(1, 51, 10, 1, " ", "white", "white")
base.draw.texta(" Categories | Versions ", 1, 3, false, "white", "lightGrey")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.texta(tostring("Total Apps: "..#appslist), 2, 19, false, "lightBlue", "grey")
base.draw.textr("Scroll Enabled ", 19, false, "orange", "grey")
local function fix(num)
if tostring(num):len() == 1 then
return " "..tostring(num)
elseif tostring(num):len() == 2 then
return " "..tostring(num)
else
return tostring(num)
end
end
local function run(scroll)
for i = 1, 13 do
if #appslist >= i + scroll then
base.draw.box(1, 51, i+4, 1, " ", "white", "white")
base.draw.textl(fix(i+scroll)..": "..tostring(appslist[i+scroll].name), i+4, false, "grey", "white")
end
end
end
run(scroll)
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
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])
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
program.apps.versions()
elseif (args[3] >= 1 and args[3] <= 51) and (args[4] >= 5 and args[4] <= 17) then
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
base.thread.switch(tname)
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 + 13 <= #appslist-1 then
scroll = scroll + 1
run(scroll)
end
end
end
end
end
\ No newline at end of file
......@@ -16,6 +16,7 @@ local paths = {
"core/core.init.lua";
"main/main.menu.lua";
"main/main.home.lua";
"main/main.alerts.lua";
"apps/apps.all.lua";
"account/account.login.lua";
"account/account.logout.lua";
......
......@@ -25,5 +25,16 @@ DiscoverApp = {
new = nil;
return true;
end;
};
};
Alerts = {
Create = function(atitle, amessage, afunction)
new = {
Title = atitle;
Message = amessage;
Function = afunction;
};
table.insert(Internal.Alerts, new)
return true;
end;
};
};
\ No newline at end of file
......@@ -9,7 +9,6 @@ program = {}; program.core = {}; program.apps = {}; program.snippets = {}; progr
Internal = {
Data = {
Notifications = {};
Apps = {};
Snippets = {};
};
......@@ -22,6 +21,10 @@ Internal = {
ActiveScreen = false;
};
Account = {};
Alerts = {};
Thread = {
History = {};
};
}
local screenx, screeny = term.getSize();
......
......@@ -57,21 +57,15 @@ function program.core.init()
local status, data = Discover.Notifications:List();
if not status then
log("Could not get notifications, " .. tostring(Discover.User:GetField("ErrorMsg")))
Internal.Data.Notifications = {};
else
Internal.Data.Notifications = data;
Internal.Alerts = data;
log("Added " .. tostring(#data) .. " alerts!");
end
end
-- Initialise Threads
base.thread.create("Home", program.main.home)
base.thread.create("Mail", program.main.home)
base.thread.create("Cloud", program.main.home)
base.thread.create("Apps", program.main.home)
base.thread.create("Snippets", program.main.home)
base.thread.create("Settings", program.main.home)
base.thread.create("BrowserX", program.main.home)
base.thread.switch("Home")
base.thread.run()
......
This diff is collapsed.
--[[
Name: main.alerts
Desc: System alerts function
--]]
function program.main.alerts()
base.screen.colour("white")
program.draw.menubar("Alerts")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textl(" " .. #Internal.Alerts .. " alert(s)", 19, false, "lightBlue", "grey")
local scroll = 0
local function run(scroll)
if #Internal.Alerts > 0 then
for i=1, 14 do
if #Internal.Alerts >= i + scroll then
base.draw.box(1, 51, i+3, 1, " ", "white", "white")
base.draw.texta(i+scroll .. ":", 1, i+3, false, "grey", "white")
base.draw.texta(Internal.Alerts[i+scroll].message:sub(1,35), 5, i+3, false, "cyan", "white")
base.draw.texta("X", 50, i+3, false, "red", "white")
else
break
end
end
else
base.draw.textc("You have no new alerts", 9, false, "red", "white")
end
end
run(scroll)
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Alerts")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Alerts", args[3], args[4])
elseif (args[3] >= 1 and args[3] <= 48) and (args[4] >= 4 and args[4] <= 17) then
local y = args[4]-3+scroll
if #Internal.Alerts >= y then
program.main.alerts_view(y)
end
elseif (args[3] == 50) then
local y = args[4]-3+scroll
if Discover.Notifications:Delete(Internal.Alerts[y].id) then
base.gui.alert("Deleted alert!")
status, Internal.Alerts = Discover.Notifications:List()
sleep(1)
program.main.alerts()
else
base.gui.alert("Could not delete alert!")
status, Internal.Alerts = Discover.Notifications:List()
sleep(1.5)
program.main.alerts_view(id)
end
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 < #Internal.Alerts then
scroll = scroll + 1
run(scroll)
end
end
end
end
end
function program.main.alerts_view(id)
base.screen.colour("white")
program.draw.menubar("Alerts: View")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.texta("Exit", 47, 19, false, "orange", "grey")
base.draw.texta("Delete", 2, 19, false, "lightBlue", "grey")
for k,v in ipairs(base.data.wordwrap(Internal.Alerts[id].message, 51)) do
base.draw.texta(v, 1, k+3, false, "cyan", "white")
end
base.draw.textc("Time Stamp: " .. tostring(Internal.Alerts[id].ntime), 18, false, "lightGrey", "white")
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Alerts: View")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Alerts: View", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and (args[4] == 19) then
program.main.alerts()
elseif (args[3] >= 2 and args[3] <= 7) and (args[4] == 19) then
if Discover.Notifications:Delete(Internal.Alerts[id].id) then
base.gui.alert("Deleted notification!")
status, Internal.Alerts = Discover.Notifications:List()
sleep(1)
program.main.alerts()
else
base.gui.alert("Could not delete notification!")
status, Internal.Alerts = Discover.Notifications:List()
sleep(1.5)
program.main.alerts_view(id)
end
end
end
end
end
\ No newline at end of file
--[[
Name: main.home
Desc: Home bar at the top of everything
--]]
function program.main.home()
if Internal.System.Platform == "Desktop" then
base.screen.colour("white")
......
--[[
Name: core.menu
Name: main.menu
Desc: Menu bar at the top of everything
--]]
local tasks_bar = false;
local menu_scroll = 0;
Internal.System.ActiveScreen = "Homepage";
......@@ -10,7 +11,7 @@ function program.draw.menubar(screen)
base.draw.box(1, 51, 1, 2, " ", "grey", "grey")
base.draw.textl("Discover App", 1, false, "cyan", "grey")
base.draw.textc(base.time.current(), 1, false, "lime", "grey")
base.draw.textr("(".. #Internal.Data.Notifications .. ") Alerts", 1, false, "lightGrey", "grey")
base.draw.textr("(".. #Internal.Alerts .. ") Alerts", 1, false, "lightGrey", "grey")
if tasks_bar then
program.draw.menu.tasks(true, false)
else
......@@ -20,67 +21,97 @@ end
function program.draw.menu.handler(screen, x, y)
local sx, sy = term.getSize();
if (x >= 1 and x <= sx) and (y >= 1 and y <= 2) then
if (x >= sx-6 and x <= sx) and (y == 2) then
if tasks_bar then
tasks_bar = false
program.draw.menu.tasks(false, true)
else
tasks_bar = true
program.draw.menu.tasks(true, true)
end
elseif (x == 1 and y == 2) then
if menu_scroll > 0 then
menu_scroll = menu_scroll - 1
program.draw.menu.tasks(tasks_bar, false)
end
elseif (x == 42 and y == 2) then
if #threads >= 4 + menu_scroll then
menu_scroll = menu_scroll + 1
program.draw.menu.tasks(tasks_bar, false)
end
elseif (x >= 3 and x <= 11) and (y == 2) then
local id = 1 + menu_scroll
if (threads[id]['name'] == currentThread['name']) then
if x == 3 then
base.thread.remove(threads[id]['name'])
if (x >= 1 and x <= 51) and (y >= 1 and y <= 2) then
if (y == 1) then
if (x >= 1 and x <= 14) then
if not base.thread.find("Home") then
base.thread.create("Home", program.main.home)
end
else
if (base.thread.find(threads[id]['name'])) then
base.thread.switch(threads[id]['name'])
base.thread.switch("Home")
elseif (x >= 46 and x <= 51) then
if not base.thread.find("Alerts") then
base.thread.create("Alerts", program.main.alerts)
end
base.thread.switch("Alerts")
end
elseif (x >= 13 and x <= 21) and (y == 2) then
local id = 2 + menu_scroll
if (threads[id]['name'] == currentThread['name']) then
if x == 3 then
base.thread.remove(threads[id]['name'])
elseif (y == 2) then
if (x == 1) then
if menu_scroll > 0 then
menu_scroll = menu_scroll - 1
program.draw.menu.tasks(tasks_bar, false)
end
else
if (base.thread.find(threads[id]['name'])) then
base.thread.switch(threads[id]['name'])
elseif (x >= 3 and x <= 11) then
local id = 1 + menu_scroll
if (threads[id]['name'] == currentThread['name']) then
if (x == 3) then
base.thread.remove(threads[id]['name'])
if not base.thread.find("Home") then
base.thread.create("Home", program.main.home)
end
base.thread.switch("Home")
end
else
if (base.thread.find(threads[id]['name'])) then
base.thread.switch(threads[id]['name'])
end
end
end
elseif (x >= 23 and x <= 31) and (y == 2) then
local id = 3 + menu_scroll
if (threads[id]['name'] == currentThread['name']) then
if x == 3 then
base.thread.remove(threads[id]['name'])
elseif (x >= 13 and x <= 21) then
local id = 2 + menu_scroll
if (threads[id]['name'] == currentThread['name']) then
if (x == 13) then
base.thread.remove(threads[id]['name'])
if not base.thread.find("Home") then
base.thread.create("Home", program.main.home)
end
base.thread.switch("Home")
end
else
if (base.thread.find(threads[id]['name'])) then
base.thread.switch(threads[id]['name'])
end
end
else
if (base.thread.find(threads[id]['name'])) then
base.thread.switch(threads[id]['name'])
elseif (x >= 23 and x <= 31) then
local id = 3 + menu_scroll
if (threads[id]['name'] == currentThread['name']) then
if (x == 23) then
base.thread.remove(threads[id]['name'])
if not base.thread.find("Home") then
base.thread.create("Home", program.main.home)
end
base.thread.switch("Home")
end
else
if (base.thread.find(threads[id]['name'])) then
base.thread.switch(threads[id]['name'])
end
end
end
elseif (x >= 33 and x <= 41) and (y == 2) then
local id = 4 + menu_scroll
if (threads[id]['name'] == currentThread['name']) then
if x == 3 then
base.thread.remove(threads[id]['name'])
elseif (x >= 33 and x <= 41) then
local id = 4 + menu_scroll
if (threads[id]['name'] == currentThread['name']) then
if (x == 33) then
base.thread.remove(threads[id]['name'])
if not base.thread.find("Home") then
base.thread.create("Home", program.main.home)
end
base.thread.switch("Home")
end
else
if (base.thread.find(threads[id]['name'])) then
base.thread.switch(threads[id]['name'])
end
end
elseif (x == 42) then
if #threads >= 4 + menu_scroll then
menu_scroll = menu_scroll + 1
program.draw.menu.tasks(tasks_bar, false)
end
else
if (base.thread.find(threads[id]['name'])) then
base.thread.switch(threads[id]['name'])
elseif (x >= 45 and x <= 51) then
if tasks_bar then
tasks_bar = false
program.draw.menu.tasks(false, true)
else
tasks_bar = true
program.draw.menu.tasks(true, true)
end
end
end
......
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