Commit 7d80d4a0 authored by Danny SMc's avatar Danny SMc

Added time in as test, add crash popup screen, added update screen, added some amends

parent 92b132aa
ewogIENvbmZpZyA9IHsKICAgIENvbmZpZ0ZpbGVQYXRoID0gIi5EaXNjb3ZlckNvbmZpZyIsCiAgICBCbG9ja1Rlcm1pbmF0ZSA9IGZhbHNlLAogICAgRW5hYmxlUGx1Z2lucyA9IHRydWUsCiAgICBQbHVnaW5zRGlyZWN0b3J5ID0gIi9EQV9QbHVnaW5zIiwKICB9LAogIEFjY291bnQgPSB7CiAgICBQYXNzd29yZCA9ICJhZDRmYWEyNTYzNjdjYTNlNzlkZmI0MDAwZDIxZDdlMjgzNDAwYmJmMjhjZjMyOGE3MDUxZGJiZmE0NThiN2Q4IiwKICAgIFVzZXJuYW1lID0gImRhbm55c21jOTUiLAogIH0sCn0=
\ No newline at end of file
ewogIENvbmZpZyA9IHsKICAgIFVzZUJldGFVcGRhdGVTdHJlYW0gPSBmYWxzZSwKICAgIFBsdWdpbnNEaXJlY3RvcnkgPSAiL0RBX1BsdWdpbnMiLAogICAgRW5hYmxlUGx1Z2lucyA9IHRydWUsCiAgICBDb25maWdGaWxlUGF0aCA9ICIuRGlzY292ZXJDb25maWciLAogICAgQmxvY2tUZXJtaW5hdGUgPSBmYWxzZSwKICB9LAogIEFjY291bnQgPSB7fSwKfQ==
\ No newline at end of file
Finder
-> Add click support
Home: Quit
-> Add popup for shutdown, shutdown pc, reboot, reboot pc
Help FAQ
-> Document everything
......
......@@ -920,18 +920,66 @@ userEvents = { -- okay
["mouse_drag"] = true;
["key"] = true;
["timer"] = true;
["key_up"] = true;
}
function base.thread.create(name, func)
function base.thread.create(name, func, xPos, yPos, width, height)
if xPos and yPos then
intx = xPos;
inty = yPos;
else
intx = 1;
inty = 1;
end
if width and height then
bufferWidth = width;
bufferHeight = height;
end
threads[#threads + 1] = {
name = name,
func = func,
co = coroutine.create(func),
buffer = window.create(parentTerm, 1, 1, bufferWidth, bufferHeight, false),
buffer = window.create(parentTerm, intx, inty, bufferWidth, bufferHeight, false),
filter = nil,
}
end
function base.thread.reset()
parentTerm = term.current(); thread = {};
bufferWidth, bufferHeight = parentTerm.getSize()
threads = {}
bgthreads = {};
currentThread = nil
userEvents = { -- okay
["char"] = true;
["mouse_click"] = true;
["mouse_scroll"] = true;
["mouse_drag"] = true;
["key"] = true;
["timer"] = true;
}
end
function base.thread.reposition(tName, xPos, yPos, xLen, yLen)
if not xPos and not yPos then
return unpack({false, "Please give all arguments"})
end
if base.thread.find(tName) then
for i, thread in ipairs(threads) do
if thread.name == tName then
if xLen and yLen then
thread.buffer.reposition(xPos, yPos, xLen, yLen)
else
thread.buffer.reposition(xPos, yPos)
end
break
end
end
else
return unpack({false, "Could not find window"})
end
end
function base.thread.createbg(name, func)
bgthreads[#bgthreads + 1] = {
name = name,
......@@ -1049,7 +1097,11 @@ function base.thread.run()
end
function base.thread.exit()
thread.quit = true
thread.quit = true;
end
function base.thread.start()
thread.quit = false;
end
--[[
################################ DRAW (base.draw) ################################
......
......@@ -13,11 +13,14 @@ local paths = {
"core/core.general.lua";
"core/core.icons.lua";
"core/core.dapi.lua";
"core/core.crash.lua";
"core/core.init.lua";
"core/core.update.lua";
"core/core.commandline.lua";
"main/main.menu.lua";
"main/main.home.lua";
"main/main.alerts.lua";
"main/main.details.lua";
"main/main.credits.lua";
"main/main.updates.lua";
"main/main.help.lua";
......
--[[
Name: core.crash
Desc: Base crash handler
--]]
function program.core.crash(errormsg)
if not errormsg then
errormsg = "Unknown error";
end
--base.screen.colour("white")
base.draw.box(8, 36, 4, 2, " ", "lightGrey", "lightGrey")
base.draw.box(8, 36, 6, 2, " ", "lightGrey", "lightGrey")
base.draw.box(8, 36, 8, 2, " ", "lightGrey", "lightGrey")
base.draw.box(8, 36, 10, 2, " ", "lightGrey", "lightGrey")
base.draw.box(8, 36, 12, 2, " ", "lightGrey", "lightGrey")
base.draw.box(8, 36, 14, 2, " ", "lightGrey", "lightGrey")
base.draw.box(44, 1, 5, 11, " ", "black", "black")
base.draw.box(9, 36, 16, 1, " ", "black", "black")
base.draw.box(8, 36, 4, 1, " ", "grey", "grey")
base.draw.textc("DiscoverApp::Crash", 4, false, "cyan", "grey")
local text = "Oh snap! Take down the error message and create a ticket for me to fix it!"
for k,v in ipairs(base.data.wordwrap(text, 33)) do
base.draw.textc(v, k+5, false, "white", "lightGrey")
end
for k,v in ipairs(base.data.wordwrap(errormsg, 33)) do
base.draw.textc(v, k+9, false, "red", "lightGrey")
end
base.draw.textc(" Reboot ", 14, false, "white", "orange")
while true do
local args = { os.pullEvent() }
if args[1] == "mouse_click" then
if (args[3] >= 20 and args[3] <= 30) and args[4] == 14 then
os.reboot();
end
end
end
end
\ No newline at end of file
......@@ -3,11 +3,11 @@
Desc: Sets the environment for the core application
--]]
tArgs = { ... }
program = {}; program.core = {}; program.apps = {}; program.snippets = {}; program.cloud = {}; program.mail = {}; program.feed = {}; program.draw = {}; program.main = {}; program.draw.menu = {}; program.chat = {}; program.account = {}; program.profile = {}; program.tickets = {};
Plugin = {};
local tArgs = { ... };
Internal = {
Details = {
Name = "Discover App";
......@@ -16,21 +16,20 @@ Internal = {
Build = 054;
Release = "Beta";
};
Data = {
Apps = {};
Snippets = {};
};
Config = {
ConfigFilePath = ".DiscoverConfig";
BlockTerminate = false;
EnablePlugins = true;
PluginsDirectory = "/DA_Plugins";
UseBetaUpdateStream = false;
AutoUpdate = false;
};
Icons = {};
System = {
Platform = false;
ActiveScreen = false;
};
Tasks = {};
Account = {};
Alerts = {};
Thread = {
......
......@@ -3,6 +3,39 @@
Desc: Used for general functions / setup for the core application
--]]
function program.core.options()
base.screen.colour("cyan")
base.draw.textl(" Discover Options ", 1, false, "white", "cyan")
base.draw.textl("----------------------", 2, false, "white", "cyan")
base.draw.textc("Exit Discover", 4, false, "orange", "cyan")
base.draw.textc("Restart Discover", 5, false, "orange", "cyan")
base.draw.textc("Reboot Computer", 6, false, "orange", "cyan")
base.draw.textc("Shutdown Computer", 7, false, "orange", "cyan")
while true do
local args = { os.pullEvent("mouse_click") }
if (args[3] >= 14 and args[3] <= 35) and (args[4] == 10) then
base.thread.create("Shutdown", program.core.shutdown, 1, 1, 51, 19)
base.thread.switch("Shutdown")
elseif (args[3] >= 14 and args[3] <= 35) and (args[4] == 11) then
base.thread.create("Reboot", program.core.reboot, 1, 1, 51, 19)
base.thread.switch("Reboot")
elseif (args[3] >= 14 and args[3] <= 35) and (args[4] == 12) then
base.screen.colour("cyan")
base.draw.textc("Restarting now...", 4, false, "white", "cyan");
base.draw.textc("See you soon!", 5, false, "white", "cyan");
sleep(1); os.reboot();
elseif (args[3] >= 14 and args[3] <= 35) and (args[4] == 13) then
base.screen.colour("cyan")
base.draw.textc("Shutting down...", 4, false, "white", "cyan");
base.draw.textc("Goodbye!", 5, false, "white", "cyan");
sleep(1); os.shutdown();
else
base.thread.remove("Power")
base.thread.switch("Home")
end
end
end
-- Run Shutdown Phase
function program.core.shutdown()
-- Draw screen
......@@ -24,11 +57,6 @@ function program.core.shutdown()
log("Running shutdown callbacks")
DiscoverApp.Callbacks.Run("Shutdown")
-- Remove all threads
log("Stopping processes")
threads = {};
base.thread.exit();
-- Log out DiscoverAPI
log("Logging out of Discover Network")
if Discover.User:LoggedIn() then
......@@ -41,9 +69,10 @@ function program.core.shutdown()
os.pullEvent = os.oldPullEvent
end
log("Clearing screen, returning")
term.clear();
term.setCursorPos(1,1)
-- Remove all threads
log("Stopping processes")
base.thread.exit();
threads = {};
end
-- Run Reboot Phase
......@@ -67,11 +96,6 @@ function program.core.reboot()
log("Running reboot callbacks")
DiscoverApp.Callbacks.Run("Reboot")
-- Remove all threads
log("Stopping processes")
threads = {};
base.thread.exit();
-- Log out DiscoverAPI
log("Logging out of Discover Network")
if Discover.User:LoggedIn() then
......@@ -85,8 +109,6 @@ function program.core.reboot()
end
log("Clearing screen, restarting")
term.clear();
term.setCursorPos(1,1)
program.core.init();
base.thread.reset();
Internal.Swap.Signal = "Reboot";
end
\ No newline at end of file
......@@ -101,5 +101,11 @@ Internal.Icons = {
{"5:5: ","f:5:U","f:5:p","f:5:d","f:5:a","f:5:t","f:5:e","5:5: ","5:5: ","5:5: ","0:f:1","0:f:.","0:f:0","5:5: "};
{"5:5: ","5:5: ","f:5:L","f:5:o","f:5:g","f:5:s","5:5: ","5:5: ","5:5: ","5:5: ","0:f:1","0:f:.","0:f:1","5:5: "};
{"5:5: ","5:5: ","5:5: ","5:5: ","5:5: ","5:5: ","5:5: ","5:5: ","5:5: ","5:5: ","5:5: ","5:5: ","5:5: ","5:5: "};
};
["sysInfo"] = {
{"f:6: ","f:6: ","f:6: ","f:6: ","f:6: ","f:6: ","f:6: ","f:6: ","f:6: ","f:6: ","f:6: ","f:6: ","f:6: ","f:6: "};
{"f:6: ","f:6:S","f:6:y","f:6:s","f:6:t","f:6:e","f:6:m","f:6: ","f:6: ","f:6: ","e:0:V","e:0::","e:0:1","f:6: "};
{"f:6: ","f:6: ","f:6:D","f:6:e","f:6:t","f:6:a","f:6:i","f:6:l","f:6:s","f:6: ","e:0:B","e:0::","e:0:9","f:6: "};
{"f:6: ","f:6: ","f:6: ","f:6: ","f:6: ","f:6: ","f:6: ","f:6: ","f:6: ","f:6: ","f:6: ","f:6: ","f:6: ","f:6: "};
}
}
......@@ -29,8 +29,17 @@ function program.core.init()
log("Running init sequence, please wait ...")
drawLoad();
--log("Checking for update, please wait ...")
--local ok, url = base.app.update("HASH", "VERSION");
-- Base Checks
log("Checking system requirements ...")
if not http then
error("Please enable HTTP in your CC config!")
end
if not term.isColour() then
error("Please use an advanced computer!")
end
-- Auto-Update Feature
program.core.update(log)
-- Check for app config
log("Searching for config ...")
......@@ -140,12 +149,14 @@ function program.core.init()
base.thread.switch("Home")
base.thread.run()
-- Shutdown Sequence
DiscoverApp.Callbacks.Run("Shutdown")
program.core.shutdown()
-- After Thread Closure, Check for reboot signal
if Internal.Swap.Signal == "Reboot" then
program.core.init();
end
term.clear(); term.setCursorPos(1, 1)
end)
if not ok then
error(":Discover: " ..tostring(err))
program.core.crash(err)
end
end
\ No newline at end of file
--[[
Name: core.update
Desc: Core auto-updating feature
--]]
function program.core.update(log)
if Internal.Config.AutoUpdate then
if Internal.Config.UseBetaUpdateStream then
log("Checking for beta update ...")
local ok, err = Discover.Core:Update("DiscoverApp", "Beta", Internal.Details.Version, Internal.Details.Build)
if ok then
log("Update found! Downloading and installing ...")
else
log("No update, you are on the latest version!")
end
else
log("Checking for new release ...")
local ok, err = Discover.Core:Update("DiscoverApp", "Release", Internal.Details.Version, Internal.Details.Build)
if ok then
log("Update found! Downloading and installing ...")
else
log("No update, you are on the latest version!")
end
end
end
end
\ No newline at end of file
This diff is collapsed.
......@@ -110,6 +110,13 @@ function program.main.home()
["thrd_name"] = "Updates";
["req_login"] = false;
};
{
["icon_name"] = "sysInfo";
["base_func"] = "main";
["func_name"] = "details";
["thrd_name"] = "SysInfo";
["req_login"] = false;
};
{
["icon_name"] = "help";
["base_func"] = "main";
......@@ -156,7 +163,7 @@ function program.main.home()
end
base.draw.textl(" Page: " .. tostring(page) .. " / " .. tostring(pages), screeny, false, "cyan", "grey")
base.draw.textr("Finder ", screeny, false, "orange", "grey")
base.draw.textc("Quit", screeny, false, "red", "grey")
base.draw.textc("Exit", screeny, false, "red", "grey")
end
render();
......@@ -177,8 +184,8 @@ function program.main.home()
end
base.thread.switch("Finder")
elseif (args[3] >= 22 and args[3] <= 28) and args[4] == 19 then
base.thread.create("Shutdown", program.core.shutdown)
base.thread.switch("Shutdown")
base.thread.create("Power", program.core.options, 15, 7, 22, 8)
base.thread.switch("Power")
elseif (args[3] >= 1 and args[3] <= screenx) and (args[4] >= 3 and args[4] <= screeny-1) then
local cpage = page * 9 - 9
if (args[3] >= 3 and args[3] <= 16) and (args[4] >= 4 and args[4] <= 7) then
......
......@@ -11,6 +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.textc(tostring(os.time()) .. ":" .. base.time.current(), 1, false, "lime", "grey")
base.draw.textr("(".. #Internal.Alerts .. ") Alerts", 1, false, "lightGrey", "grey")
if tasks_bar then
program.draw.menu.tasks(true, false)
......@@ -42,62 +43,70 @@ function program.draw.menu.handler(screen, x, y)
end
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)
if (id <= #threads) then
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
base.thread.switch("Home")
end
else
if (base.thread.find(threads[id]['name'])) then
base.thread.switch(threads[id]['name'])
end
end
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)
if (id <= #threads) then
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
base.thread.switch("Home")
end
else
if (base.thread.find(threads[id]['name'])) then
base.thread.switch(threads[id]['name'])
end
end
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)
if (id <= #threads) then
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
base.thread.switch("Home")
end
else
if (base.thread.find(threads[id]['name'])) then
base.thread.switch(threads[id]['name'])
end
end
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)
if (id <= #threads) then
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
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
......
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