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 = {
|
||||
"Update",
|
||||
"Edit Theme",
|
||||
"Change Username",
|
||||
"Change Password",
|
||||
"Set Label",
|
||||
"Clear Label",
|
||||
|
@ -17,6 +18,23 @@ local function clear()
|
|||
term.setCursorPos(1,1)
|
||||
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()
|
||||
while true do
|
||||
term.setBackgroundColor(sPhone.theme["backgroundColor"])
|
||||
|
@ -181,10 +199,8 @@ local function editTheme()
|
|||
fs.copy("/.sPhone/config/theme", saveTheme)
|
||||
sPhone.winOk("Theme saved!")
|
||||
elseif id == 7 then
|
||||
sPhone.header()
|
||||
visum.align("center", "Load Theme",false,3)
|
||||
term.setCursorPos(2,5)
|
||||
local loadTheme = read()
|
||||
local loadTheme = sPhone.list()
|
||||
if loadTheme then
|
||||
if fs.exists(loadTheme) and not fs.isDir(loadTheme) then
|
||||
for k, v in pairs(sPhone.theme) do -- Load theme
|
||||
sPhone.theme[k] = config.read(loadTheme, k)
|
||||
|
@ -194,12 +210,11 @@ local function editTheme()
|
|||
end
|
||||
sPhone.winOk("Theme loaded!")
|
||||
else
|
||||
sPhone.winok("Theme not found!")
|
||||
sPhone.winOk("Theme not found!")
|
||||
end
|
||||
end
|
||||
elseif id == 8 then
|
||||
for k, v in pairs(sPhone.defaultTheme) do
|
||||
config.write("/.sPhone/config/theme", k, v)
|
||||
end
|
||||
fs.delete("/.sPhone/config/theme")
|
||||
sPhone.theme = sPhone.defaultTheme
|
||||
sPhone.winOk("Removed Theme")
|
||||
end
|
||||
|
@ -217,15 +232,9 @@ local function defaultApps()
|
|||
elseif id == 1 then
|
||||
|
||||
while true do
|
||||
clear()
|
||||
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()
|
||||
local defaultHome = sPhone.list()
|
||||
|
||||
if defaultHome == "" then
|
||||
if not defaultHome then
|
||||
sPhone.setDefaultApp("home","/.sPhone/apps/home")
|
||||
sPhone.winOk("Done!","Reboot to apply")
|
||||
break
|
||||
|
@ -253,12 +262,14 @@ while true do
|
|||
elseif id == 2 then
|
||||
editTheme()
|
||||
elseif id == 3 then
|
||||
changePassword()
|
||||
changeUsername()
|
||||
elseif id == 4 then
|
||||
changeLabel()
|
||||
changePassword()
|
||||
elseif id == 5 then
|
||||
clearLabel()
|
||||
changeLabel()
|
||||
elseif id == 6 then
|
||||
clearLabel()
|
||||
elseif id == 7 then
|
||||
defaultApps()
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue