Commit 79d640db authored by Danny SMc's avatar Danny SMc

Added some amends to most pages

parent 7d80d4a0
ewogIENvbmZpZyA9IHsKICAgIFVzZUJldGFVcGRhdGVTdHJlYW0gPSBmYWxzZSwKICAgIFBsdWdpbnNEaXJlY3RvcnkgPSAiL0RBX1BsdWdpbnMiLAogICAgRW5hYmxlUGx1Z2lucyA9IHRydWUsCiAgICBDb25maWdGaWxlUGF0aCA9ICIuRGlzY292ZXJDb25maWciLAogICAgQmxvY2tUZXJtaW5hdGUgPSBmYWxzZSwKICB9LAogIEFjY291bnQgPSB7fSwKfQ==
\ No newline at end of file
ewogIENvbmZpZyA9IHsKICAgIFVzZUJldGFVcGRhdGVTdHJlYW0gPSBmYWxzZSwKICAgIFBsdWdpbnNEaXJlY3RvcnkgPSAiL0RBX1BsdWdpbnMiLAogICAgRW5hYmxlUGx1Z2lucyA9IHRydWUsCiAgICBFeGFtcGxlU2V0dGluZyA9IHRydWUsCiAgICBDb25maWdGaWxlUGF0aCA9ICIuRGlzY292ZXJDb25maWciLAogICAgQmxvY2tUZXJtaW5hdGUgPSBmYWxzZSwKICAgIFBsdWdpbkNvbmZpZ0ZpbGUgPSAiLkRpc2NvdmVyQXBwUGx1Z2lucyIsCiAgICBBdXRvVXBkYXRlID0gZmFsc2UsCiAgfSwKICBBY2NvdW50ID0gewogICAgUGFzc3dvcmQgPSAiYWQ0ZmFhMjU2MzY3Y2EzZTc5ZGZiNDAwMGQyMWQ3ZTI4MzQwMGJiZjI4Y2YzMjhhNzA1MWRiYmZhNDU4YjdkOCIsCiAgICBVc2VybmFtZSA9ICJkYW5ueXNtYzk1IiwKICB9LAp9
\ No newline at end of file
......@@ -44,8 +44,12 @@ local Internal = {
--[[
################################ CORE (base.core) ################################
--]]
function base.core.getVersion()
return tostring("BaseAPI (Version: " .. Internal.Version .. ":" .. Internal.Build .. ")");
function base.core.getVersion(format)
if not format then
return tostring("BaseAPI (Version: " .. Internal.Version .. ":" .. Internal.Build .. ")");
else
return tostring(Internal.Version .. ":" .. Internal.Build);
end
end
Internal.Headers = {
["User-Agent"] = tostring(Internal.Name);
......@@ -920,7 +924,7 @@ userEvents = { -- okay
["mouse_drag"] = true;
["key"] = true;
["timer"] = true;
["key_up"] = true;
["mouse_up"] = true;
}
function base.thread.create(name, func, xPos, yPos, width, height)
......@@ -941,6 +945,18 @@ function base.thread.create(name, func, xPos, yPos, width, height)
co = coroutine.create(func),
buffer = window.create(parentTerm, intx, inty, bufferWidth, bufferHeight, false),
filter = nil,
hidden = false,
}
end
function base.thread.createbg(name, func)
threads[#threads + 1] = {
name = name,
func = func,
co = coroutine.create(func),
buffer = window.create(parentTerm, 1, 1, 1, 1, false),
filter = nil,
hidden = true,
}
end
......@@ -960,6 +976,16 @@ function base.thread.reset()
}
end
function base.thread.list()
local new = {};
for _,v in ipairs(threads) do
if not v.hidden then
table.insert(new, v)
end
end
return new;
end
function base.thread.reposition(tName, xPos, yPos, xLen, yLen)
if not xPos and not yPos then
return unpack({false, "Please give all arguments"})
......@@ -980,36 +1006,6 @@ function base.thread.reposition(tName, xPos, yPos, xLen, yLen)
end
end
function base.thread.createbg(name, func)
bgthreads[#bgthreads + 1] = {
name = name,
func = func,
co = coroutine.create(func),
buffer = window.create(parentTerm, 1, 1, bufferWidth, bufferHeight, false),
filter = nil,
}
end
function base.thread.removebg(name)
local toRemove = {}
for i, thread in ipairs(bgthreads) do
if thread.name == name then
toRemove[#toRemove + 1] = i
end
end
for i = #toRemove, 1, -1 do
table.remove(bgthreads, toRemove[i])
end
end
function base.thread.findbg(name)
for i, thread in ipairs(bgthreads) do
if thread.name == name then
return true
end
end
end
function base.thread.remove(name)
local toRemove = {}
for i, thread in ipairs(threads) do
......
......@@ -51,6 +51,10 @@ local paths = {
"chat/chat.group.lua";
"chat/chat.global.lua";
"chat/chat.info.lua";
"plugins/plugins.main.lua";
"plugins/plugins.view.lua";
"plugins/plugins.info.lua";
"plugins/plugins.installed.lua";
"tickets/tickets.main.lua";
"tickets/tickets.list.lua";
"tickets/tickets.create.lua";
......
......@@ -8,19 +8,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
base.draw.textc
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])
......@@ -28,6 +46,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
\ No newline at end of file
......@@ -27,7 +27,7 @@ function program.chat.main()
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Chat: Main", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
base.thread.remove("Profile")
base.thread.remove("Chat")
base.thread.switch("Home")
elseif (args[3] >= 2 and args[3] <= 6) and args[4] == 19 then
program.chat.info()
......
......@@ -87,6 +87,32 @@ DiscoverApp = {
return threads;
end;
};
Tasks = {
Create = function( name, func )
if type(name) == "string" and type(func) == "function" then
local new = {};
new.name = tostring(name)
new.func = func;
table.insert(Internal.Tasks, new)
base.thread.createbg(new.name, new.func)
return true;
else
return unpack({false, "Expecting string, function"})
end
end;
Remove = function( name )
for k,v in ipairs(Internal.Tasks) do
if v.name == name then
table.remove(Internal.Tasks, k)
if base.thread.find(name) then
base.thread.remove(name)
end
return true;
end
end
return unpack({false, "Could not find task"});
end;
};
Callbacks = {
Register = function( ntype, namespace, func )
if ntype == "shutdown" then
......
......@@ -3,7 +3,7 @@
Desc: Sets the environment for the core application
--]]
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 = {};
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 = {}; program.plugins = {};
local tArgs = { ... };
......@@ -23,12 +23,14 @@ Internal = {
PluginsDirectory = "/DA_Plugins";
UseBetaUpdateStream = false;
AutoUpdate = false;
PluginConfigFile = ".DiscoverAppPlugins";
};
Icons = {};
System = {
Platform = false;
ActiveScreen = false;
};
Plugins = {};
Tasks = {};
Account = {};
Alerts = {};
......
......@@ -107,5 +107,11 @@ Internal.Icons = {
{"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: "};
};
["PluginsManager"] = {
{"f:d: ","f:d: ","f:d: ","f:d: ","f:d: ","f:d: ","f:d: ","f:d: ","f:d: ","f:d: ","f:d: ","f:d: ","f:d: ","f:d: "};
{"f:d: ","f:d:P","f:d:l","f:d:u","f:d:g","f:d:i","f:d:n","f:d:s","f:d: ","f:d: ","e:0:|","e:0:-","e:0:|","f:d: "};
{"f:d: ","f:d: ","f:d:M","f:d:a","f:d:n","f:d:a","f:d:g","f:d:e","f:d:r","f:d: ","e:0:-","e:0:|","e:0:-","f:d: "};
{"f:d: ","f:d: ","f:d: ","f:d: ","f:d: ","f:d: ","f:d: ","f:d: ","f:d: ","f:d: ","f:d: ","f:d: ","f:d: ","f:d: "};
}
}
......@@ -60,6 +60,7 @@ function program.core.init()
Internal.Controls.InstallConfig()
-- Install Plugins
Plugin = {};
if Internal.Config.EnablePlugins then
log("Checking for plugins, please wait ...")
if fs.exists(Internal.Config.PluginsDirectory) then
......@@ -94,6 +95,7 @@ function program.core.init()
if ok then
return "Success";
else
print(err); sleep(10000)
return "Fail";
end
end
......
......@@ -67,6 +67,38 @@ Discover = {
return tostring(Discover.User.Data.CMessage);
end;
};
Plugins = {
List = function( self )
local query = "cmd=get-plugins";
local req = http.post(Discover.Data.Urls.Store, query, Discover.Data.Headers)
req = textutils.unserialize(req.readAll())
if req.status then
return unpack({true,req.data});
else
return unpack({false,req.error});
end
end;
Download = function( self, id, path, filename )
local query = "cmd=download-plugin&id=" .. textutils.urlEncode(tostring(id));
local req = http.post(Discover.Data.Urls.Store, query, Discover.Data.Headers);
req = req.readAll();
if req == "false" then
return unpack({false, "An error occured"});
else
if not fs.exists(path) then
fs.makeDir(path)
else
if not fs.isDir(path) then
return unpack({false,"Path is already used and not a directory, cancelling."});
end
end
local f = fs.open(fs.combine(path, filename), "w")
f.write(req)
f.close()
return true;
end
end;
};
User = {
Data = {
Username = nil;
......
This diff is collapsed.
--[[
Name: main.details
Desc: System details screen function
--]]
function program.main.details()
base.screen.colour("white")
program.draw.menubar("System: Details")
local text = "When giving bug reports it\'s always good to give as much information as possible. Below is a list of the versions, builds etc for the Discover API, the Base API and the Discover App. If you can include the versions for each in every bug report. Formatted like Version:Build.";
for k,v in ipairs(base.data.wordwrap(text, 49)) do
base.draw.textl(" " .. tostring(v), k+3, false, "lightGrey", "white")
end
base.draw.texta("DiscoverAPI: ", 2, 12, false, "grey", "white")
base.draw.texta("Base API: ", 2, 14, false, "grey", "white")
base.draw.texta("DiscoverApp: ", 2, 16, false, "grey", "white")
base.draw.texta("->", 20, 12, false, "lightGrey", "white")
base.draw.texta("->", 20, 14, false, "lightGrey", "white")
base.draw.texta("->", 20, 16, false, "lightGrey", "white")
base.draw.texta(tostring(Discover.Core.Internal.Version .. ":" .. Discover.Core.Internal.Build), 24, 12, false, "cyan", "white")
base.draw.texta(tostring(base.core.getVersion(true)), 24, 14, false, "cyan", "white")
base.draw.texta(tostring(Internal.Details.Version .. ":" .. Internal.Details.Build), 24, 16, false, "cyan", "white")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Exit ", 19, false, "orange", "grey")
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("System: Details")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("System: Details", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
base.thread.remove("SysInfo")
base.thread.switch("Home")
end
end
end
end
\ No newline at end of file
......@@ -96,6 +96,13 @@ function program.main.home()
["thrd_name"] = "Tickets";
["req_login"] = true;
};
{
["icon_name"] = "PluginsManager";
["base_func"] = "plugins";
["func_name"] = "main";
["thrd_name"] = "Plugins";
["req_login"] = false;
};
{
["icon_name"] = "settings";
["base_func"] = "main";
......
......@@ -11,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.textc(tostring(os.time()) .. ":" .. 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)
......@@ -22,6 +22,7 @@ end
function program.draw.menu.handler(screen, x, y)
local sx, sy = term.getSize();
local thread_list = base.thread.list();
if (x >= 1 and x <= 51) and (y >= 1 and y <= 2) then
if (y == 1) then
if (x >= 1 and x <= 14) then
......@@ -43,74 +44,74 @@ function program.draw.menu.handler(screen, x, y)
end
elseif (x >= 3 and x <= 11) then
local id = 1 + menu_scroll
if (id <= #threads) then
if (threads[id]['name'] == currentThread['name']) then
if (id <= #thread_list) then
if (thread_list[id]['name'] == currentThread['name']) then
if (x == 3) then
base.thread.remove(threads[id]['name'])
base.thread.remove(thread_list[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'])
if (base.thread.find(thread_list[id]['name'])) then
base.thread.switch(thread_list[id]['name'])
end
end
end
elseif (x >= 13 and x <= 21) then
local id = 2 + menu_scroll
if (id <= #threads) then
if (threads[id]['name'] == currentThread['name']) then
if (id <= #thread_list) then
if (thread_list[id]['name'] == currentThread['name']) then
if (x == 13) then
base.thread.remove(threads[id]['name'])
base.thread.remove(thread_list[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'])
if (base.thread.find(thread_list[id]['name'])) then
base.thread.switch(thread_list[id]['name'])
end
end
end
elseif (x >= 23 and x <= 31) then
local id = 3 + menu_scroll
if (id <= #threads) then
if (threads[id]['name'] == currentThread['name']) then
if (id <= #thread_list) then
if (thread_list[id]['name'] == currentThread['name']) then
if (x == 23) then
base.thread.remove(threads[id]['name'])
base.thread.remove(thread_list[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'])
if (base.thread.find(thread_list[id]['name'])) then
base.thread.switch(thread_list[id]['name'])
end
end
end
elseif (x >= 33 and x <= 41) then
local id = 4 + menu_scroll
if (id <= #threads) then
if (threads[id]['name'] == currentThread['name']) then
if (id <= #thread_list) then
if (thread_list[id]['name'] == currentThread['name']) then
if (x == 33) then
base.thread.remove(threads[id]['name'])
base.thread.remove(thread_list[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'])
if (base.thread.find(thread_list[id]['name'])) then
base.thread.switch(thread_list[id]['name'])
end
end
end
elseif (x == 42) then
if #threads >= 4 + menu_scroll then
if #thread_list >= 4 + menu_scroll then
menu_scroll = menu_scroll + 1
program.draw.menu.tasks(tasks_bar, false)
end
......@@ -128,6 +129,7 @@ function program.draw.menu.handler(screen, x, y)
end
function program.draw.menu.tasks(open, animate)
local thread_list = base.thread.list();
if open then
if animate then
for i=51, 1, -3 do
......@@ -142,14 +144,14 @@ function program.draw.menu.tasks(open, animate)
base.draw.texta(">", 42, 2, false, "red", "lightGrey")
for k,v in ipairs(chars) do
if (#threads >= k + menu_scroll) then
if (threads[k+menu_scroll]['name'] == currentThread['name']) then
if (#thread_list >= k + menu_scroll) then
if (thread_list[k+menu_scroll]['name'] == currentThread['name']) then
base.draw.texta(" ", chars[k], 2, false, "lightGrey", "lightGrey")
base.draw.texta('x', chars[k], 2, false, "red", "lightGrey")
base.draw.texta(tostring(threads[k+menu_scroll]['name']:sub(1,6)), chars[k]+2, 2, false, "lightBlue", "lightGrey")
base.draw.texta(tostring(thread_list[k+menu_scroll]['name']:sub(1,6)), chars[k]+2, 2, false, "lightBlue", "lightGrey")
else
base.draw.texta(" ", chars[k], 2, false, "lightGrey", "lightGrey")
base.draw.texta(tostring(threads[k+menu_scroll]['name']:sub(1,8)), chars[k], 2, false, "lightBlue", "lightGrey")
base.draw.texta(tostring(thread_list[k+menu_scroll]['name']:sub(1,8)), chars[k], 2, false, "lightBlue", "lightGrey")
end
if animate then
sleep(0.01)
......@@ -164,14 +166,14 @@ function program.draw.menu.tasks(open, animate)
base.draw.box(1, x, 2, 1, " ", "lightGrey", "lightGrey")
base.draw.textr("Close >", 2, false, "white", "lightGrey")
for k,v in ipairs(chars) do
if (#threads >= k + menu_scroll) then
if (threads[k+menu_scroll]['name'] == currentThread['name']) then
if (#thread_list >= k + menu_scroll) then
if (thread_list[k+menu_scroll]['name'] == currentThread['name']) then
base.draw.texta(" ", chars[k], 2, false, "lightGrey", "lightGrey")
base.draw.texta('x', chars[k], 2, false, "red", "lightGrey")
base.draw.texta(tostring(threads[k+menu_scroll]['name']:sub(1,6)), chars[k]+2, 2, false, "lightBlue", "lightGrey")
base.draw.texta(tostring(thread_list[k+menu_scroll]['name']:sub(1,6)), chars[k]+2, 2, false, "lightBlue", "lightGrey")
else
base.draw.texta(" ", chars[k], 2, false, "lightGrey", "lightGrey")
base.draw.texta(tostring(threads[k+menu_scroll]['name']:sub(1,8)), chars[k], 2, false, "lightBlue", "lightGrey");
base.draw.texta(tostring(thread_list[k+menu_scroll]['name']:sub(1,8)), chars[k], 2, false, "lightBlue", "lightGrey");
end
end
end
......
--[[
Name: plugins.info
Desc: Plugins info screen
--]]
function program.plugins.info(screen)
if screen == "create" then
base.screen.colour("white")
program.draw.menubar("Plugins: Info")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Back ", 19, false, "red", "grey")
local scroll = 0;
local text = "Creating a plugin is very simple once you understand the API. The API extends core functions allowing you to do code upgrades and addons for the app. The DiscoverApp comes with an example plugin you can edit yourself to understand how to make one. In the plugins manager, click on ExamplePlugin and install it, then navigate to your plugins folder (DA_Plugins) by default, and then edit it with your favourite editor. This is useful as it allows you to add more to the Discover App with ease.";
local content = base.data.wordwrap(text, 49);
local function render()
for i=1, 14 do
if #content >= i+scroll then
base.draw.box(1, 51, i+3, 1, " ", "white", "white")
base.draw.textl(" " .. tostring(content[i+scroll]), i+3, false, "cyan", "white")
end
end
end
render();
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Plugins: Info")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Plugins: Info", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
program.plugins.main()
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 < #content then
scroll = scroll + 1
render();
end
end
end
end
elseif screen == "about" then
base.screen.colour("white")
program.draw.menubar("Plugins: Info")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
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 content = base.data.wordwrap(text, 49);
local function render()
for i=1, 14 do
if #content >= i+scroll then
base.draw.box(1, 51, i+3, 1, " ", "white", "white")
base.draw.textl(" " .. tostring(content[i+scroll]), i+3, false, "cyan", "white")
end
end
end
render();
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Plugins: Info")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Plugins: Info", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
program.plugins.main()
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 < #content then
scroll = scroll + 1
render();
end
end
end
end
end
end
\ No newline at end of file
--[[
Name: plugins.installed
Desc: Installed plugins screen
--]]
function program.plugins.installed()
base.screen.colour("white")
program.draw.menubar("Plugins: Installed")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Back ", 19, false, "red", "grey")
local scroll = 0;
if fs.exists(Internal.Config.PluginConfigFile) then
local f = fs.open(Internal.Config.PluginConfigFile, "r")
local pconf = textutils.unserialize(base.base64.decode(f.readAll()))
f.close();
else
base.gui.alert("No plugin config file exists")
sleep(1.5)
program.plugins.main();
end
local function render()
for i=1, 14 do
if #pconf >= i+scroll then
base.draw.box(1, 51, i+3, 1, " ", "white", "white")
base.draw.textl(" " .. tostring(i+scroll) .. ": " .. tostring(pconf[i+scroll]['name']:sub(1, 40)), i+3, false, "cyan", "white")
base.draw.textr("Uninstall ", i+3, false, "red", "white")
end
end
end
render();
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Plugins: Installed")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Plugins: Installed", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
program.plugins.main()
elseif (args[3] >= 42 and args[3] <= 50) and (args[4] >= 4 and args[4] <= 17) then
local id = args[4] - 3 + scroll
if id <= #pconf then
local info = pconf[id];
if fs.exists(fs.combine(Internal.Config.PluginsDirectory, info.filename)) then
fs.delete(fs.combine(Internal.Config.PluginsDirectory, info.filename))
base.gui.alert("File found and removed, removing meta...")
table.remove(pconf, id)
sleep(1);
local f = fs.open(Internal.Config.PluginConfigFile, "w")
f.write(base.base64.encode(textutils.serialize(pconf)))
f.close();
program.plugins.installed()
else
base.gui.alert("No file found, removing meta...")
table.remove(pconf, id)
sleep(1);
local f = fs.open(Internal.Config.PluginConfigFile, "w")
f.write(base.base64.encode(textutils.serialize(pconf)))
f.close();
program.plugins.installed()
end
if fs.exists(Internal.Config.PluginsDirectory) then
local list = fs.list(Internal.Config.PluginsDirectory)
if #list == 0 then
fs.delete(Internal.Config.PluginsDirectory)
end
end
end
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 < #pconf then
scroll = scroll + 1