Commit 710ab6d0 authored by Danny SMc's avatar Danny SMc

Updated settings for dynamic settings, added some amends to the way...

Updated settings for dynamic settings, added some amends to the way DiscoverApp handles settings, added settings manager inside the Discover Plugin API, and added a few updates to the icons, as well as a few screen updates and an update to the store.php file using the diamond operator for MySQL
parent f28bac86
ewogIFBsdWdpbnMgPSB7CiAgICBQYXRoID0gIkRBX1BsdWdpbnMiLAogICAgRW5hYmxlZCA9IHRydWUsCiAgfSwKICBBY2NvdW50ID0ge30sCiAgQ29uZmlnID0gewogICAgUGF0aCA9ICIuRGlzY292ZXJDb25maWciLAogICAgQmxvY2sgPSB0cnVlLAogIH0sCn0=
\ No newline at end of file
ewogIENvbmZpZyA9IHsKICAgIENvbmZpZ0ZpbGVQYXRoID0gIi5EaXNjb3ZlckNvbmZpZyIsCiAgICBCbG9ja1Rlcm1pbmF0ZSA9IHRydWUsCiAgICBFbmFibGVQbHVnaW5zID0gdHJ1ZSwKICAgIFBsdWdpbnNEaXJlY3RvcnkgPSAiL0RBX1BsdWdpbnMiLAogIH0sCiAgQWNjb3VudCA9IHsKICAgIFBhc3N3b3JkID0gImFkNGZhYTI1NjM2N2NhM2U3OWRmYjQwMDBkMjFkN2UyODM0MDBiYmYyOGNmMzI4YTcwNTFkYmJmYTQ1OGI3ZDgiLAogICAgVXNlcm5hbWUgPSAiZGFubnlzbWM5NSIsCiAgfSwKfQ==
\ No newline at end of file
......@@ -65,10 +65,10 @@ function program.account.login()
if status then
if status then
-- Create Config
local f = fs.open(Internal.Config.Path, "w")
local f = fs.open(Internal.Config.ConfigFilePath, "w")
Internal.Account.Username = username
Internal.Account.Password = Discover.Crypto:Sha256(password)
local config = { ["Account"]=Internal.Account; ["Config"]=Internal.Config; ["Plugins"]=Internal.Plugins; }
local config = { ["Account"]=Internal.Account; ["Config"]=Internal.Config; }
f.write(Discover.Crypto:Base64("encode", textutils.serialize(config)))
f.close();
end
......
......@@ -5,7 +5,7 @@
function program.apps.categories()
base.screen.colour("white")
program.draw.menubar("Categories")
program.draw.menubar("Apps: Categories")
base.draw.box(21, 1, 5, 13, "|", "lightGrey", "white")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
......@@ -17,7 +17,7 @@ function program.apps.categories()
local lselect = ""
local status, allapps = Discover.Apps:List('apps');
base.draw.texta("Total Categories: "..#allapps, 2, 19, false, "lightBlue", "grey")
base.draw.texta("Total Categories: "..#ldata, 2, 19, false, "lightBlue", "grey")
base.draw.textr("SCroll Enabled", 19, false, "orange", "grey")
base.draw.texta(" All | Versions ", 1, 3, false, "white", "lightGrey")
......@@ -50,10 +50,10 @@ function program.apps.categories()
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Categories")
program.draw.menubar("Apps: 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])
program.draw.menu.handler("Apps: 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
......
--[[
Name: apps.downloads
Desc: Apps listed by download count screen function
--]]
\ No newline at end of file
--]]
function program.apps.downloads()
base.screen.colour("white")
program.draw.menubar("App: Downloads")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Exit ", 19, false, "red", "grey")
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Apps: Downloads")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Apps: Downloads", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
program.apps.main();
end
end
end
end
\ No newline at end of file
......@@ -78,7 +78,7 @@ function program.apps.main()
program.apps.main()
elseif (args[3] >= 27 and args[3] <= 50) and (args[4] == 17) then
if not Discover.User:LoggedIn() then
base.gui.alert("You need to be logged in to view this!");
base.gui.alert("You need to be logged in and staff to view this!");
sleep(1);
program.apps.main();
end
......
--[[
Name: apps.packages
Desc: Apps listed by packages, example the Microsoft Package, Ink, Sketch, etc
--]]
\ No newline at end of file
--]]
function program.apps.packages()
base.screen.colour("white")
program.draw.menubar("App: Packages")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Exit ", 19, false, "red", "grey")
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Apps: Packages")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Apps: Packages", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
program.apps.main();
end
end
end
end
\ No newline at end of file
......@@ -5,7 +5,7 @@
function program.apps.versions(version)
base.screen.colour("white")
program.draw.menubar("Versions")
program.draw.menubar("Apps: Versions")
base.draw.box(21, 1, 5, 13, "|", "lightGrey", "white")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
......@@ -17,7 +17,7 @@ function program.apps.versions(version)
local lselect = ""
local status, allapps = Discover.Apps:List("apps");
base.draw.texta("Total Versions: "..#allapps, 2, 19, false, "lightBlue", "grey")
base.draw.texta("Total Versions: "..#ldata, 2, 19, false, "lightBlue", "grey")
base.draw.textr("SCroll Enabled", 19, false, "orange", "grey")
base.draw.texta(" All | Categories ", 1, 3, false, "white", "lightGrey")
......@@ -50,10 +50,10 @@ function program.apps.versions(version)
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Versions")
program.draw.menubar("Apps: 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])
program.draw.menu.handler("Apps: 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
......
-- Intialize the DiscoverApp API.
-- Intialize the DiscoverApp Plugin API.
Internal.MenuEntries = {};
DiscoverApp = {
......@@ -27,15 +27,15 @@ DiscoverApp = {
end;
};
MenuBar = {
Render = function( self, name )
Render = function( name )
program.draw.menubar(name)
end;
Handler = function( self, name, x, y )
Handler = function( name, x, y )
program.draw.menu.handler(name, x, y)
end;
};
Alerts = {
Create = function(atitle, amessage, afunction)
Create = function ( atitle, amessage, afunction )
new = {
Title = atitle;
Message = amessage;
......@@ -45,4 +45,24 @@ DiscoverApp = {
return true;
end;
};
Settings = {
Create = function( key, value )
if Internal.Config[tostring(key)] == nil then
Internal.Config[tostring(key)] = value;
return true;
else
return unpack({false, "Setting name already used!"})
end
end;
Retrieve = function( key )
return Internal.Config[tostring(key)];
end;
Save = function( )
local f = fs.open(Internal.Config.ConfigFilePath, "w")
local config = { ["Account"]=Internal.Account; ["Config"]=Internal.Config; }
f.write(Discover.Crypto:Base64("encode", textutils.serialize(config)))
f.close();
return true;
end;
};
};
\ No newline at end of file
......@@ -14,18 +14,17 @@ Internal = {
Description = "Discover Network Application.";
Version = 7.0;
Build = 054;
Release = "Beta";
};
Data = {
Apps = {};
Snippets = {};
};
Config = {
Path = ".DiscoverConfig";
Block = true;
};
Plugins = {
Enabled = true;
Path = "DA_Plugins";
ConfigFilePath = ".DiscoverConfig";
BlockTerminate = true;
EnablePlugins = true;
PluginsDirectory = "/DA_Plugins";
};
Icons = {};
System = {
......
......@@ -33,7 +33,7 @@ function program.core.shutdown()
-- Unlock os.pullEvent
log("Unlock termination block")
if Internal.Config.Block then
if Internal.Config.BlockTerminate then
os.pullEvent = os.oldPullEvent
end
......@@ -72,7 +72,7 @@ function program.core.reboot()
-- Unlock os.pullEvent
log("Unlock termination block")
if Internal.Config.Block then
if Internal.Config.BlockTerminate then
os.pullEvent = os.oldPullEvent
end
......
......@@ -32,7 +32,7 @@ Internal.Icons = {
};
["credits"] = {
{"f:4: ","f:4: ","f:4: ","f:4: ","f:4: ","f:4: ","f:4: ","f:4: ","f:4: ","7:8:-","7:8:-","7:8: ","f:4: ","f:4: "};
{"f:4:C","f:4:r","f:4:e","f:4:d","f:4:i","f:4:t","f:4:s","f:4: ","f:4: ","7:8:-","7:8:-","7:8:-","f:4: ","f:4: "};
{"f:4: ","f:4:C","f:4:r","f:4:e","f:4:d","f:4:i","f:4:t","f:4:s","f:4: ","7:8:-","7:8:-","7:8:-","f:4: ","f:4: "};
{"f:4: ","f:4: ","f:4: ","f:4: ","f:4: ","f:4: ","f:4: ","f:4: ","f:4: ","7:8:-","7:8: ","7:8: ","f:4: ","f:4: "};
{"f:4: ","f:4: ","f:4: ","f:4: ","f:4: ","f:4: ","f:4: ","f:4: ","f:4: ","7:8:-","7:8:-","7:8: ","f:4: ","f:4: "};
};
......
......@@ -34,21 +34,24 @@ function program.core.init()
-- Check for app config
log("Searching for config ...")
if fs.exists(Internal.Config.Path) then
local f = fs.open(Internal.Config.Path, "r")
if fs.exists(Internal.Config.ConfigFilePath) then
local f = fs.open(Internal.Config.ConfigFilePath, "r")
local d = f.readAll()
f.close()
local config = textutils.unserialize(Discover.Crypto:Base64("decode", d))
Internal.Account = config.Account;
Internal.Config = config.Config;
Internal.Plugins = config.Plugins;
local config = textutils.unserialize(Discover.Crypto:Base64("decode", d));
for k,v in pairs(config.Config) do
Internal.Config[k] = v;
end
for k,v in pairs(config.Account) do
Internal.Account[k] = v;
end
end
-- Install Plugins
if Internal.Plugins.Enabled then
if Internal.Config.EnablePlugins then
log("Checking for plugins, please wait ...")
if fs.exists(Internal.Plugins.Path) then
local list = fs.list(Internal.Plugins.Path)
if fs.exists(Internal.Config.PluginsDirectory) then
local list = fs.list(Internal.Config.PluginsDirectory)
local function install(filepath)
local ok, err = pcall(function()
if fs.exists(filepath) then
......@@ -79,13 +82,11 @@ function program.core.init()
if ok then
return "Success";
else
print(err)
sleep(1000)
return "Fail";
end
end
for k,v in ipairs(list) do
log("Installing plugins: " .. tostring(k) .. "/" .. tostring(#list) .. " :: " .. tostring(tostring(install(fs.combine(Internal.Plugins.Path, v)))))
log("Installing plugins: " .. tostring(k) .. "/" .. tostring(#list) .. " :: " .. tostring(tostring(install(fs.combine(Internal.Config.PluginsDirectory, v)))))
drawLoad();
end
end
......@@ -93,7 +94,7 @@ function program.core.init()
-- Check for termination blocking
log("Checking for blocking method ...")
if Internal.Config.Block then
if Internal.Config.BlockTerminate then
os.oldPullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
end
......
This diff is collapsed.
......@@ -49,7 +49,7 @@ function program.main.finder()
end
end
local text = "On the left is all functions inside the DiscoverApp. To run one please click the function, if you wish to run with arguments, right click it instead. Run with caution, as these should only be run needed when by the application, meaning you may cause instability.";
local text = "On the left is all functions inside the DiscoverApp. To run one please click the function, if you wish to run with arguments, right click it instead. Run with caution, as these should only be run when needed by the application, meaning you may cause instability.";
for k,v in ipairs(base.data.wordwrap(text, 29)) do
base.draw.texta(v, 21, k+3, false, "orange", "white");
end
......
......@@ -3,62 +3,130 @@
Desc: System settings function
--]]
function program.main.settings()
base.screen.colour("white")
program.draw.menubar("Settings: Menu")
function program.main.settings(screen)
if screen == "help" then
base.screen.colour("white")
program.draw.menubar("Settings: About")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Back ", 19, false, "red", "grey")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Exit ", 19, false, "red", "grey")
base.draw.textl(" Setting Names | Value / Enabled | Edit |", 3, false, "lightGrey", "white")
-- Prevent Termination
base.draw.texta("Block Termination", 2, 6, false, "lightBlue", "white")
base.draw.texta("Enabled", 24, 6, false, "green", "white")
base.draw.texta(" Edit ", 45, 6, false, "red", "white")
-- Config File
base.draw.texta("Config File Path", 2, 7, false, "lightBlue", "white")
base.draw.texta(tostring(Internal.Config.Path):sub(1, 20), 24, 7, false, "green", "white")
base.draw.texta(" Edit ", 45, 7, false, "red", "white")
local text = "The settings are basically a collection of all options controlled by DiscoverApp. This includes some base configurations, but best of all it contains all a plugins settings, the plugin API for DiscoverApp, has settings management, which works with the internal settings, so you can edit/change any/all settings saved by a plugin. Settings are either 1 of 2 options they are a boolean or a string, even numbers are stored as strings, so please remember to tonumber() the string when you receive it again. To change a setting scroll (if needed) to the setting, and click the edit button, this will then bring up an Accept / Yes and Decline / No option for booleans to either enable or disable an option or for strings it will popup with an input box for you to write your own config value. Please note when making plugins, a plugin should ALWAYS check for a config option first before writing it, as otherwise you could create a new setting which gets saved to file then when you restart DiscoverApp and it loads the configuration file, you will then overwrite the option as plugins are loaded after the config file being loaded. So always check for this.";
local scroll = 0; local content = base.data.wordwrap(text, 49)
local function render()
for i=1, 14 do
if scroll+i <= #content 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
-- Plugins Enabled
base.draw.texta("Plugins Enabled", 2, 8, false, "lightBlue", "white")
base.draw.texta(tostring(Internal.Plugins.Enabled):sub(1, 20), 24, 8, false, "green", "white")
base.draw.texta(" Edit ", 45, 8, false, "red", "white")
render();
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Settings: About")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Settings: About", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
program.main.settings()
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 #content > 14+scroll then
scroll = scroll + 1
render();
end
end
end
end
else
base.screen.colour("white")
program.draw.menubar("Settings: Menu")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Exit ", 19, false, "red", "grey")
base.draw.textl(" About", 19, false, "lightBlue", "grey")
base.draw.textc("Refresh", 19, false, "orange", "grey")
base.draw.textl(" Setting Names | Value / Enabled | Edit |", 3, false, "lightGrey", "white")
local scroll = 0; local options = {};
for k,v in pairs(Internal.Config) do table.insert(options, k); end
-- Plugins Folder
base.draw.texta("Plugins Folder Path", 2, 9, false, "lightBlue", "white")
base.draw.texta(tostring(Internal.Plugins.Path):sub(1, 20), 24, 9, false, "green", "white")
base.draw.texta(" Edit ", 45, 9, false, "red", "white")
local function render()
for i=1, 13 do
if #options >= i+scroll then
local key = options[i+scroll]
base.draw.box(1, 51, i+4, 1, " ", "white", "white")
base.draw.texta(tostring(key:sub(1, 20)), 2, i+4, false, "cyan", "white")
if Internal.Config[key] == true then
base.draw.texta(tostring(Internal.Config[key]):sub(1, 20), 24, i+4, false, "green", "white")
elseif Internal.Config[key] == false then
base.draw.texta(tostring(Internal.Config[key]):sub(1, 20), 24, i+4, false, "red", "white")
else
base.draw.texta(tostring(Internal.Config[key]):sub(1, 20), 24, i+4, false, "blue", "white")
end
base.draw.texta(tostring("Edit"), 46, i+4, false, "orange", "white")
end
end
end
local function saveConfig()
local f = fs.open(Internal.Config.Path, "w")
local config = { ["Account"]=Internal.Account; ["Config"]=Internal.Config; ["Plugins"]=Internal.Plugins; }
f.write(Discover.Crypto:Base64("encode", textutils.serialize(config)))
f.close();
end
local function saveConfig()
local f = fs.open(Internal.Config.ConfigFilePath, "w")
local config = { ["Account"]=Internal.Account; ["Config"]=Internal.Config; }
f.write(Discover.Crypto:Base64("encode", textutils.serialize(config)))
f.close();
base.gui.alert("Setting was changed!"); sleep(0.5);
for i=4, 18 do base.draw.box(1, 51, i, 1, " ", "white", "white"); end
render();
end
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Settings: Menu")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Settings: Menu", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
base.thread.remove("Settings");
if not base.thread.find("Home") then
base.thread.create("Home", program.main.home)
render();
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Settings: Menu")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Settings: Menu", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
base.thread.remove("Settings");
if not base.thread.find("Home") then
base.thread.create("Home", program.main.home)
end
base.thread.switch("Home")
elseif (args[3] >= 20 and args[3] <= 30) and args[4] == 19 then
render();
elseif (args[3] >= 2 and args[3] <= 6) and args[4] == 19 then
program.main.settings("help")
elseif (args[3] >= 46 and args[3] <= 49) and (args[4] >= 5 and args[4] <= 17) then
local key = args[4] - 4 + scroll;
if #options >= key then
if Internal.Config[options[key]] == true or Internal.Config[options[key]] == false then
Internal.Config[options[key]] = base.gui.confirm("Enable / Disable " .. tostring(options[key]))
saveConfig();
else
Internal.Config[options[key]] = base.gui.input("Change " .. tostring(options[key]) .. " to")
saveConfig();
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 #options > 13+scroll then
scroll = scroll + 1
render();
end
end
base.thread.switch("Home")
elseif (args[3] >= 45 and args[3] <= 50) and args[4] == 6 then
local new = base.gui.confirm("Enable / Disable Termination Blocking?")
Internal.Config.Block = new;
print(textutils.serialize(Internal.Config)); sleep(10000)
saveConfig();
base.gui.alert("Changed!")
sleep(0.5)
program.main.settings();
end
end
end
......
......@@ -32,9 +32,21 @@ function program.snippets.main()
elseif (args[3] >= 2 and args[3] <= 21) and (args[4] == 4) then
program.snippets.all()
elseif (args[3] >= 2 and args[3] <= 21) and (args[4] == 6) then
program.snippets.upload()
if Discover.User:LoggedIn() then
program.snippets.upload()
else
base.gui.alert("You need to be logged in to view this!");
sleep(1);
program.snippets.main()
end
elseif (args[3] >= 2 and args[3] <= 21) and (args[4] == 8) then
program.snippets.owned()
if Discover.User:LoggedIn() then
program.snippets.owned()
else
base.gui.alert("You need to be logged in to view this!");
sleep(1);
program.snippets.main()
end
elseif (args[3] >= 2 and args[3] <= 21) and (args[4] == 10) then
base.thread.remove("Snippets")
if not base.thread.find("Home") then
......
......@@ -32,7 +32,7 @@
switch ($cmd) {
case 'list_apps':
$sql = "SELECT * FROM `$store`";
$sql = "SELECT * FROM `$store` WHERE `appstatus` <> 'private'";
$result = $conn->query($sql);
$datanorm = $result->fetch_all(MYSQLI_ASSOC);
$data = array_reverse($datanorm, true);
......
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