Added sPhone.list function and username can be changed
This commit is contained in:
parent
e4deff5856
commit
9b2932e99e
1 changed files with 111 additions and 100 deletions
|
@ -4,6 +4,7 @@ local pwChangeRep
|
||||||
local menu = {
|
local menu = {
|
||||||
"Update",
|
"Update",
|
||||||
"Edit Theme",
|
"Edit Theme",
|
||||||
|
"Change Username",
|
||||||
"Change Password",
|
"Change Password",
|
||||||
"Set Label",
|
"Set Label",
|
||||||
"Clear Label",
|
"Clear Label",
|
||||||
|
@ -17,6 +18,23 @@ local function clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function changeUsername()
|
||||||
|
term.setBackgroundColor(sPhone.theme["backgroundColor"])
|
||||||
|
term.clear()
|
||||||
|
term.setCursorPos(1,1)
|
||||||
|
sPhone.header(sPhone.user)
|
||||||
|
term.setTextColor(sPhone.theme["text"])
|
||||||
|
visum.align("center"," New Username",false,3)
|
||||||
|
term.setCursorPos(2,5)
|
||||||
|
write("Username: ")
|
||||||
|
local newUsername = read()
|
||||||
|
sPhone.user = newUsername
|
||||||
|
f = fs.open("/.sPhone/config/username","w")
|
||||||
|
f.write(sPhone.user)
|
||||||
|
f.close()
|
||||||
|
sPhone.winOk("Username","Changed")
|
||||||
|
end
|
||||||
|
|
||||||
local function changePassword()
|
local function changePassword()
|
||||||
while true do
|
while true do
|
||||||
term.setBackgroundColor(sPhone.theme["backgroundColor"])
|
term.setBackgroundColor(sPhone.theme["backgroundColor"])
|
||||||
|
@ -181,10 +199,8 @@ local function editTheme()
|
||||||
fs.copy("/.sPhone/config/theme", saveTheme)
|
fs.copy("/.sPhone/config/theme", saveTheme)
|
||||||
sPhone.winOk("Theme saved!")
|
sPhone.winOk("Theme saved!")
|
||||||
elseif id == 7 then
|
elseif id == 7 then
|
||||||
sPhone.header()
|
local loadTheme = sPhone.list()
|
||||||
visum.align("center", "Load Theme",false,3)
|
if loadTheme then
|
||||||
term.setCursorPos(2,5)
|
|
||||||
local loadTheme = read()
|
|
||||||
if fs.exists(loadTheme) and not fs.isDir(loadTheme) then
|
if fs.exists(loadTheme) and not fs.isDir(loadTheme) then
|
||||||
for k, v in pairs(sPhone.theme) do -- Load theme
|
for k, v in pairs(sPhone.theme) do -- Load theme
|
||||||
sPhone.theme[k] = config.read(loadTheme, k)
|
sPhone.theme[k] = config.read(loadTheme, k)
|
||||||
|
@ -194,12 +210,11 @@ local function editTheme()
|
||||||
end
|
end
|
||||||
sPhone.winOk("Theme loaded!")
|
sPhone.winOk("Theme loaded!")
|
||||||
else
|
else
|
||||||
sPhone.winok("Theme not found!")
|
sPhone.winOk("Theme not found!")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif id == 8 then
|
elseif id == 8 then
|
||||||
for k, v in pairs(sPhone.defaultTheme) do
|
fs.delete("/.sPhone/config/theme")
|
||||||
config.write("/.sPhone/config/theme", k, v)
|
|
||||||
end
|
|
||||||
sPhone.theme = sPhone.defaultTheme
|
sPhone.theme = sPhone.defaultTheme
|
||||||
sPhone.winOk("Removed Theme")
|
sPhone.winOk("Removed Theme")
|
||||||
end
|
end
|
||||||
|
@ -217,15 +232,9 @@ local function defaultApps()
|
||||||
elseif id == 1 then
|
elseif id == 1 then
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
clear()
|
local defaultHome = sPhone.list()
|
||||||
sPhone.header("Default Apps: Home")
|
|
||||||
visum.align("center","Set default home app",false,3)
|
|
||||||
term.setCursorPos(2,5)
|
|
||||||
print("Leave blank for default")
|
|
||||||
write(" Path: /")
|
|
||||||
local defaultHome = read()
|
|
||||||
|
|
||||||
if defaultHome == "" then
|
if not defaultHome then
|
||||||
sPhone.setDefaultApp("home","/.sPhone/apps/home")
|
sPhone.setDefaultApp("home","/.sPhone/apps/home")
|
||||||
sPhone.winOk("Done!","Reboot to apply")
|
sPhone.winOk("Done!","Reboot to apply")
|
||||||
break
|
break
|
||||||
|
@ -253,12 +262,14 @@ while true do
|
||||||
elseif id == 2 then
|
elseif id == 2 then
|
||||||
editTheme()
|
editTheme()
|
||||||
elseif id == 3 then
|
elseif id == 3 then
|
||||||
changePassword()
|
changeUsername()
|
||||||
elseif id == 4 then
|
elseif id == 4 then
|
||||||
changeLabel()
|
changePassword()
|
||||||
elseif id == 5 then
|
elseif id == 5 then
|
||||||
clearLabel()
|
changeLabel()
|
||||||
elseif id == 6 then
|
elseif id == 6 then
|
||||||
|
clearLabel()
|
||||||
|
elseif id == 7 then
|
||||||
defaultApps()
|
defaultApps()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue