Commit 8cad4fec authored by Danny SMc's avatar Danny SMc 🎧

Added screenshots, added auto-updating abilities, amended a few bugs here and there.

parent 79d640db
ew0KICB7DQogICAgZmlsZW5hbWUgPSAiZmlsZW1hbmFnZXIubHVhIiwNCiAgICBuYW1lID0gIkZpbGVNYW5hZ2VyIiwNCiAgICByZWxlYXNlZCA9ICIxOC8wNy8yMDE2IiwNCiAgfSwNCn0=
\ No newline at end of file
--[[
Name: FileManager Plugin
Desc: A powerful file manager
Auth: DannySMc
]]
-- @base filemanager
-- @func entry
Plugin.filemanager = {};
function Plugin.filemanager.entry()
local filemanagericon = {
{"a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: "};
{"a:a: ","0:a:F","0:a:i","0:a:l","0:a:e","0:a: ","0:a: ","0:a: ","0:a: ","0:a: ","a:4: ","a:5: ","a:5: ","0:a: "};
{"a:a: ","0:a: ","0:a:M","0:a:a","0:a:n","0:a:a","0:a:g","0:a:e","0:a:r","0:a: ","0:4: ","a:4: ","a:4: ","a:a: "};
{"a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: "};
};
DiscoverApp.Register.MenuIcon("FileManager", filemanagericon);
DiscoverApp.Register.MenuEntry("FileManager", "filemanager", "main", "Files", false);
end
function program.filemanager.main()
base.screen.colour("white")
program.draw.menubar("Files: Main")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Exit ", 19, false, "red", "grey")
local scroll = 0;
local path = "/";
local history = {};
local fileList = {};
base.draw.textl(" < >", 3, false, "lightBlue", "white")
base.draw.texta("::" .. tostring(path):sub(1, 42), 6, 3, false, "lightGrey", "white")
local function parse(path)
if fs.exists(path) then
table.insert(history, path)
end
local list = fs.list(path)
local new = {}
for _,v in ipairs(list) do
if fs.isDir(fs.combine(path, v)) then
table.insert(new, "+" .. tostring(v))
end
end
for _,v in ipairs(list) do
if not fs.isDir(fs.combine(path, v)) then
table.insert(new, "-" .. tostring(v))
end
end
fileList = new;
return new;
end
local function render(data)
base.draw.texta("::" .. tostring(path):sub(1, 42), 6, 3, false, "lightGrey", "white")
for i=1, 13 do
base.draw.box(1, 30, i+4, 1, " ", "white", "white")
if i+scroll <= #data then
if data[i+scroll]:sub(1,1) == "+" then
base.draw.textl(" " .. tostring(data[i+scroll]:sub(2)), i+4, false, "blue", "white")
elseif data[i+scroll]:sub(1,1) == "-" then
base.draw.textl(" " .. tostring(data[i+scroll]:sub(2)), i+4, false, "lightGrey", "white")
end
end
end
end
render(parse(path));
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Files: Main")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Files: Main", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and (args[4] == 19) then
base.thread.remove("Files")
base.thread.switch("Home")
elseif (args[3] >= 2 and args[3] <= 40) and (args[4] >= 5 and args[4] <= 17) then
local id = args[4] - 4 + scroll
if #fileList >= id then
local newpath = fs.combine(path, fileList[id])
if fs.isDir(newpath) then
path = newpath;
render(parse(path))
else
end
end
end
elseif args[1] == "mouse_scroll" then
if args[2] == -1 then
if scroll > 0 then
scroll = scroll - 1
render(parse(path))
end
elseif args[2] == 1 then
if scroll+13 < #fileList then
scroll = scroll + 1
render(parse(path))
end
end
end
end
end
\ No newline at end of file
......@@ -4,15 +4,9 @@ Finder
Help FAQ
-> Document everything
Plugins
-> Create DiscoverApp Plugin Store
Chat Rooms
-> Add the screens into this
Core
-> Add auto-update support
DAPI
-> Add FAQ/Help Insertions
-> Add Credits Insertions
......
......@@ -276,7 +276,7 @@ function base.gui.input(text, mask)
base.colour.set("white", "cyan")
term.setCursorPos(3,11)
write("> ")
local input = tostring(base.io.limitRead(34, mask))
local input = tostring(base.io.limitRead(46, mask))
return input
end
......
......@@ -17,7 +17,7 @@ function program.chat.global()
base.draw.box(1, 51, 10, 1, " ", "white", "white")
for i=1, 14 do
if #messages >= i+scroll then
base.draw.textc
end
end
end
......
......@@ -14,15 +14,14 @@ Internal = {
Description = "Discover Network Application.";
Version = 7.0;
Build = 054;
Release = "Beta";
ReleaseKey = "47e748dcf1759597ddc91855f0e95673648d172bb72fdb820679735ca9ea5d47293ca7e5b26e91eb0e3dce660905d75c7617e12121306c4f79190cfef45fe7cd";
};
Config = {
ConfigFilePath = ".DiscoverConfig";
BlockTerminate = false;
EnablePlugins = true;
PluginsDirectory = "/DA_Plugins";
UseBetaUpdateStream = false;
AutoUpdate = false;
AutoUpdate = true;
PluginConfigFile = ".DiscoverAppPlugins";
};
Icons = {};
......
......@@ -5,24 +5,20 @@
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 ...")
log("Checking for new release ...")
local ok, err = Discover.Core:Update("check", Internal.Details.ReleaseKey, Internal.Details.Version)
if ok then
log("Update found! Downloading and installing ...")
if Discover.Core:Update("download", Internal.Details.ReleaseKey) then
log("Installed, Rebooting...")
sleep(1)
shell.run(shell.getRunningProgram())
else
log("No update, you are on the latest version!")
log("Unable to install new update...")
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
log("No update, you are on the latest version!")
sleep(0.5)
end
end
end
\ No newline at end of file
......@@ -19,6 +19,7 @@ Discover = {
Store = "http://api.dannysmc.com/store.php";
User = "http://api.dannysmc.com/user.php";
Projects = "http://api.dannysmc.com/projects.php";
Distribution = "http://api.dannysmc.com/distribution.php";
};
Headers = {
["User-Agent"] = "DiscoverAPI";
......@@ -66,6 +67,34 @@ Discover = {
GetLatestMessage = function( self )
return tostring(Discover.User.Data.CMessage);
end;
Update = function( self, ntype, key, version )
if ntype == "check" then
local query = "cmd=check-update&key=" .. textutils.urlEncode(tostring(key))
local req = http.post(Discover.Data.Urls.Distribution, query, Discover.Data.Headers)
req = textutils.unserialize(req.readAll())
if req.status then
if tonumber(req.data) > tonumber(version) then
return true;
else
return false;
end
else
return unpack({false, req.error});
end
elseif ntype == "download" then
local query = "cmd=download-update&key=" .. textutils.urlEncode(tostring(key))
local req = http.post(Discover.Data.Urls.Distribution, query, Discover.Data.Headers)
req = req.readAll();
if req then
local f = fs.open(shell.getRunningProgram(), "w")
f.write(req)
f.close()
return true;
else
return unpack({false, "An error occured while downloading the update"});
end
end
end;
};
Plugins = {
List = function( self )
......
......@@ -19,15 +19,14 @@ Internal = {
Description = "Discover Network Application.";
Version = 7.0;
Build = 054;
Release = "Beta";
ReleaseKey = "47e748dcf1759597ddc91855f0e95673648d172bb72fdb820679735ca9ea5d47293ca7e5b26e91eb0e3dce660905d75c7617e12121306c4f79190cfef45fe7cd";
};
Config = {
ConfigFilePath = ".DiscoverConfig";
BlockTerminate = false;
EnablePlugins = true;
PluginsDirectory = "/DA_Plugins";
UseBetaUpdateStream = false;
AutoUpdate = false;
AutoUpdate = true;
PluginConfigFile = ".DiscoverAppPlugins";
};
Icons = {};
......@@ -739,24 +738,20 @@ end
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 ...")
log("Checking for new release ...")
local ok, err = Discover.Core:Update("check", Internal.Details.ReleaseKey, Internal.Details.Version)
if ok then
log("Update found! Downloading and installing ...")
if Discover.Core:Update("download", Internal.Details.ReleaseKey) then
log("Installed, Rebooting...")
sleep(1)
shell.run(shell.getRunningProgram())
else
log("No update, you are on the latest version!")
log("Unable to install new update...")
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
log("No update, you are on the latest version!")
sleep(0.5)
end
end
end
......@@ -1947,7 +1942,7 @@ function program.main.help(name)
};
{
["name"] = "Command line interface?";
["content"] = "This will soon be finished, but to initiate the CLI, you will need to append help to the filename in the shell when running the program, here it will output all of the options available to you.";
["content"] = "This is a feature that will be added in the future, as I am looking at making it an extension for CraftOS.";
};
}
......@@ -5109,19 +5104,37 @@ function program.chat.global()
program.draw.menubar("Chat: Global")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Exit ", 19, false, "red", "grey")
local messages = {}; local scroll = 0; local counter = 0;
local messages = {};
local function render()
if #messages == 0 then
base.draw.textc("No messages to show!", 10, false, "red", "white")
else
base.draw.box(1, 51, 10, 1, " ", "white", "white")
for i=1, 14 do
if #messages >= i+scroll then
end
end
end
end
local function update()
local function parse()
end
render();
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Chat: Global")
if counter >= 10 then
Discover.Chat:List("global")
local counter = 0;
else
counter = counter + 1;
end
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Chat: Global", args[3], args[4])
......@@ -5129,6 +5142,10 @@ function program.chat.global()
base.thread.remove("Profile")
base.thread.switch("Home")
end
elseif args[1] == "http_failure" then
Discover.Chat:List("global")
elseif args[1] == "http_success" then
parse(); render();
end
end
end
......@@ -5423,7 +5440,7 @@ function program.plugins.info(screen)
base.draw.textr("Back ", 19, false, "red", "grey")
local scroll = 0;
local text = "Plugins are just files of code that extends the current DiscoverApp, you can create extended editions of the app, or even just add a new menu idea with a program you have made, maybe an in-built code editor, or an in-built file manager. Again the possibilities are endless. By default there is an example plugin that is installable, which showcases mostly all functions that are exposed by the DiscoverApp.";
local text = "Plugins are just files of code that extend the current DiscoverApp, you can create extended editions of the app, or even just add a new menu idea with a program you have made, maybe an in-built code editor, or an in-built file manager. Again the possibilities are endless. By default there is an example plugin that is installable, which showcases most functions that are exposed by the DiscoverApp.";
local content = base.data.wordwrap(text, 49);
local function render()
for i=1, 14 do
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -46,7 +46,7 @@ function program.main.help(name)
};
{
["name"] = "Command line interface?";
["content"] = "This will soon be finished, but to initiate the CLI, you will need to append help to the filename in the shell when running the program, here it will output all of the options available to you.";
["content"] = "This is a feature that will be added in the future, as I am looking at making it an extension for CraftOS.";
};
}
......
print('LOLOLOLOLO')
\ No newline at end of file
......@@ -54,7 +54,7 @@ function program.plugins.info(screen)
base.draw.textr("Back ", 19, false, "red", "grey")
local scroll = 0;
local text = "Plugins are just files of code that extends the current DiscoverApp, you can create extended editions of the app, or even just add a new menu idea with a program you have made, maybe an in-built code editor, or an in-built file manager. Again the possibilities are endless. By default there is an example plugin that is installable, which showcases mostly all functions that are exposed by the DiscoverApp.";
local text = "Plugins are just files of code that extend the current DiscoverApp, you can create extended editions of the app, or even just add a new menu idea with a program you have made, maybe an in-built code editor, or an in-built file manager. Again the possibilities are endless. By default there is an example plugin that is installable, which showcases most functions that are exposed by the DiscoverApp.";
local content = base.data.wordwrap(text, 49);
local function render()
for i=1, 14 do
......
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