Update settings.lua
This commit is contained in:
parent
48af2e273e
commit
601e51e404
1 changed files with 112 additions and 49 deletions
|
@ -3,53 +3,41 @@ local pwChangeRep
|
||||||
|
|
||||||
local menu = {
|
local menu = {
|
||||||
"Update",
|
"Update",
|
||||||
|
"Edit Theme",
|
||||||
"Change Password",
|
"Change Password",
|
||||||
"Set Label",
|
"Set Label",
|
||||||
"Clear Label",
|
"Clear Label",
|
||||||
}
|
}
|
||||||
|
|
||||||
local function clear()
|
local function clear()
|
||||||
term.setBackgroundColor(colors.white)
|
term.setBackgroundColor(sPhone.theme["backgroundColor"])
|
||||||
term.setTextColor(colors.black)
|
term.setTextColor(sPhone.theme["text"])
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function header()
|
|
||||||
clear()
|
|
||||||
local w, h = term.getSize()
|
|
||||||
paintutils.drawLine(1,1,w,1, colors.blue)
|
|
||||||
term.setTextColor(colors.white)
|
|
||||||
term.setCursorPos(1,1)
|
|
||||||
write(" "..sPhone.user)
|
|
||||||
term.setCursorPos(1,2)
|
|
||||||
term.setBackgroundColor(colors.white)
|
|
||||||
term.setTextColor(colors.black)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function changePassword()
|
local function changePassword()
|
||||||
while true do
|
while true do
|
||||||
|
term.setBackgroundColor(sPhone.theme["backgroundColor"])
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
paintutils.drawImage(paintutils.loadImage("/.sPhone/interfaces/login"),1,1)
|
sPhone.header(sPhone.user)
|
||||||
term.setTextColor(colors.white)
|
paintutils.drawBox(7,9,20,11,sPhone.theme["window.background"])
|
||||||
term.setBackgroundColor(colors.blue)
|
term.setBackgroundColor(sPhone.theme["backgroundColor"])
|
||||||
term.setCursorPos(1,1)
|
|
||||||
write(" "..sPhone.user)
|
|
||||||
if sPhone.wrongPassword then
|
if sPhone.wrongPassword then
|
||||||
term.setTextColor(colors.red)
|
term.setTextColor(colors.red)
|
||||||
term.setBackgroundColor(colors.white)
|
term.setBackgroundColor(sPhone.theme["backgroundColor"])
|
||||||
visum.align("center"," Wrong Password",false,13)
|
visum.align("center"," Wrong Password",false,13)
|
||||||
end
|
end
|
||||||
term.setTextColor(colors.black)
|
term.setTextColor(sPhone.theme["text"])
|
||||||
term.setBackgroundColor(colors.white)
|
term.setBackgroundColor(sPhone.theme["backgroundColor"])
|
||||||
visum.align("center"," Current Password",false,7)
|
visum.align("center"," Current Password",false,7)
|
||||||
local loginTerm = window.create(term.native(), 8,10,12,1, true)
|
local loginTerm = window.create(term.native(), 8,10,12,1, true)
|
||||||
term.redirect(loginTerm)
|
term.redirect(loginTerm)
|
||||||
term.setBackgroundColor(colors.white)
|
term.setBackgroundColor(sPhone.theme["backgroundColor"])
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
term.setTextColor(colors.black)
|
term.setTextColor(sPhone.theme["text"])
|
||||||
local password = read("*")
|
local password = read("*")
|
||||||
term.redirect(sPhone.mainTerm)
|
term.redirect(sPhone.mainTerm)
|
||||||
local fpw = fs.open("/.sPhone/config/.password","r")
|
local fpw = fs.open("/.sPhone/config/.password","r")
|
||||||
|
@ -64,46 +52,43 @@ local function changePassword()
|
||||||
|
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
|
term.setBackgroundColor(sPhone.theme["backgroundColor"])
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
paintutils.drawImage(paintutils.loadImage("/.sPhone/interfaces/login"),1,1)
|
sPhone.header(sPhone.user)
|
||||||
term.setTextColor(colors.white)
|
paintutils.drawBox(7,9,20,11,sPhone.theme["window.background"])
|
||||||
term.setBackgroundColor(colors.blue)
|
term.setBackgroundColor(sPhone.theme["backgroundColor"])
|
||||||
term.setCursorPos(1,1)
|
|
||||||
write(" "..sPhone.user)
|
|
||||||
if sPhone.wrongPassword then
|
if sPhone.wrongPassword then
|
||||||
term.setTextColor(colors.red)
|
term.setTextColor(colors.red)
|
||||||
term.setBackgroundColor(colors.white)
|
term.setBackgroundColor(sPhone.theme["backgroundColor"])
|
||||||
visum.align("center"," Wrong Password",false,13)
|
visum.align("center"," Wrong Password",false,13)
|
||||||
end
|
end
|
||||||
term.setTextColor(colors.black)
|
term.setTextColor(sPhone.theme["text"])
|
||||||
term.setBackgroundColor(colors.white)
|
term.setBackgroundColor(sPhone.theme["backgroundColor"])
|
||||||
visum.align("center"," New Password",false,7)
|
visum.align("center"," New Password",false,7)
|
||||||
local loginTerm = window.create(term.native(), 8,10,12,1, true)
|
local loginTerm = window.create(term.native(), 8,10,12,1, true)
|
||||||
term.redirect(loginTerm)
|
term.redirect(loginTerm)
|
||||||
term.setBackgroundColor(colors.white)
|
term.setBackgroundColor(sPhone.theme["backgroundColor"])
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
term.setTextColor(colors.black)
|
term.setTextColor(sPhone.theme["text"])
|
||||||
pwChange = read("*")
|
pwChange = read("*")
|
||||||
term.redirect(sPhone.mainTerm)
|
term.redirect(sPhone.mainTerm)
|
||||||
|
|
||||||
|
term.setBackgroundColor(sPhone.theme["backgroundColor"])
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
paintutils.drawImage(paintutils.loadImage("/.sPhone/interfaces/login"),1,1)
|
sPhone.header(sPhone.user)
|
||||||
term.setTextColor(colors.white)
|
paintutils.drawBox(7,9,20,11,sPhone.theme["window.background"])
|
||||||
term.setBackgroundColor(colors.blue)
|
term.setBackgroundColor(sPhone.theme["backgroundColor"])
|
||||||
term.setCursorPos(1,1)
|
term.setTextColor(sPhone.theme["text"])
|
||||||
write(" "..sPhone.user)
|
|
||||||
term.setTextColor(colors.black)
|
|
||||||
term.setBackgroundColor(colors.white)
|
|
||||||
visum.align("center"," Repeat Password",false,7)
|
visum.align("center"," Repeat Password",false,7)
|
||||||
local loginTerm = window.create(term.native(), 8,10,12,1, true)
|
local loginTerm = window.create(term.native(), 8,10,12,1, true)
|
||||||
term.redirect(loginTerm)
|
term.redirect(loginTerm)
|
||||||
term.setBackgroundColor(colors.white)
|
term.setBackgroundColor(sPhone.theme["backgroundColor"])
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
term.setTextColor(colors.black)
|
term.setTextColor(sPhone.theme["text"])
|
||||||
pwChangeRep = read("*")
|
pwChangeRep = read("*")
|
||||||
term.redirect(sPhone.mainTerm)
|
term.redirect(sPhone.mainTerm)
|
||||||
if sha256.sha256(pwChange) ~= sha256.sha256(pwChangeRep) then
|
if sha256.sha256(pwChange) ~= sha256.sha256(pwChangeRep) then
|
||||||
|
@ -119,15 +104,14 @@ local function changePassword()
|
||||||
f.write(sha256.sha256(pwChangeRep))
|
f.write(sha256.sha256(pwChangeRep))
|
||||||
f.close()
|
f.close()
|
||||||
end
|
end
|
||||||
header()
|
sPhone.header(sPhone.user)
|
||||||
term.setCursorPos(2,3)
|
visum.align("center", "All Set!", false, 3)
|
||||||
print("All Set!")
|
|
||||||
sleep(2)
|
sleep(2)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local function changeLabel()
|
local function changeLabel()
|
||||||
header()
|
sPhone.header(sPhone.user)
|
||||||
visum.align("center", "Set Label",false,3)
|
visum.align("center", "Set Label",false,3)
|
||||||
term.setCursorPos(2,5)
|
term.setCursorPos(2,5)
|
||||||
local newLabel = read()
|
local newLabel = read()
|
||||||
|
@ -140,6 +124,83 @@ local function clearLabel()
|
||||||
sPhone.winOk("Computer Label cleared")
|
sPhone.winOk("Computer Label cleared")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function editTheme()
|
||||||
|
local themeOptions = {
|
||||||
|
"Header Color",
|
||||||
|
"Header Text Color",
|
||||||
|
"Text Color",
|
||||||
|
"Background Color",
|
||||||
|
"Window Options",
|
||||||
|
"Save",
|
||||||
|
"Load",
|
||||||
|
"Reset",
|
||||||
|
}
|
||||||
|
local themeOptionsWindow = {
|
||||||
|
"Background",
|
||||||
|
"Side",
|
||||||
|
"Button",
|
||||||
|
"Text",
|
||||||
|
}
|
||||||
|
while true do
|
||||||
|
local _, id = sPhone.menu(themeOptions,"Theme","X")
|
||||||
|
if id == 0 then
|
||||||
|
return
|
||||||
|
elseif id == 1 then
|
||||||
|
sPhone.applyTheme("header", sPhone.colorPicker("Header",sPhone.getTheme("header")))
|
||||||
|
elseif id == 2 then
|
||||||
|
sPhone.applyTheme("headerText", sPhone.colorPicker("Header Text",sPhone.getTheme("headerText")))
|
||||||
|
elseif id == 3 then
|
||||||
|
sPhone.applyTheme("text", sPhone.colorPicker("Text",sPhone.getTheme("text")))
|
||||||
|
elseif id == 4 then
|
||||||
|
sPhone.applyTheme("backgroundColor", sPhone.colorPicker("Background Color",sPhone.getTheme("backgroundColor")))
|
||||||
|
elseif id == 5 then
|
||||||
|
while true do
|
||||||
|
local _, id = sPhone.menu(themeOptionsWindow,"Window Theme","X")
|
||||||
|
if id == 0 then
|
||||||
|
return
|
||||||
|
elseif id == 1 then
|
||||||
|
sPhone.applyTheme("window.background", sPhone.colorPicker("Background",sPhone.getTheme("window.background")))
|
||||||
|
elseif id == 2 then
|
||||||
|
sPhone.applyTheme("window.side", sPhone.colorPicker("Side",sPhone.getTheme("window.side")))
|
||||||
|
elseif id == 3 then
|
||||||
|
sPhone.applyTheme("window.button", sPhone.colorPicker("Button",sPhone.getTheme("window.button")))
|
||||||
|
elseif id == 4 then
|
||||||
|
sPhone.applyTheme("window.text", sPhone.colorPicker("Text",sPhone.getTheme("window.text")))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif id == 6 then
|
||||||
|
sPhone.header()
|
||||||
|
visum.align("center", "Save Theme",false,3)
|
||||||
|
term.setCursorPos(2,5)
|
||||||
|
local saveTheme = read()
|
||||||
|
if fs.exists(saveTheme) then
|
||||||
|
fs.delete(saveTheme)
|
||||||
|
end
|
||||||
|
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()
|
||||||
|
if fs.exists(loadTheme) and not fs.isDir(loadTheme) then
|
||||||
|
for k, v in pairs(sPhone.theme) do
|
||||||
|
sPhone.theme[k] = config.read("/.sPhone/config/theme", k)
|
||||||
|
end
|
||||||
|
sPhone.winOk("Theme loaded!")
|
||||||
|
else
|
||||||
|
sPhone.winok("Theme not found!")
|
||||||
|
end
|
||||||
|
elseif id == 8 then
|
||||||
|
for k, v in pairs(sPhone.defaultTheme) do
|
||||||
|
config.write("/.sPhone/config/theme", k, v)
|
||||||
|
end
|
||||||
|
sPhone.theme = sPhone.defaultTheme
|
||||||
|
sPhone.winOk("Removed Theme")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
clear()
|
clear()
|
||||||
sPhone.header("","X")
|
sPhone.header("","X")
|
||||||
|
@ -149,10 +210,12 @@ while true do
|
||||||
elseif id == 1 then
|
elseif id == 1 then
|
||||||
setfenv(loadstring(http.get("https://raw.githubusercontent.com/Sertex-Team/sPhone/master/src/installer.lua").readAll()),getfenv())()
|
setfenv(loadstring(http.get("https://raw.githubusercontent.com/Sertex-Team/sPhone/master/src/installer.lua").readAll()),getfenv())()
|
||||||
elseif id == 2 then
|
elseif id == 2 then
|
||||||
changePassword()
|
editTheme()
|
||||||
elseif id == 3 then
|
elseif id == 3 then
|
||||||
changeLabel()
|
changePassword()
|
||||||
elseif id == 4 then
|
elseif id == 4 then
|
||||||
|
changeLabel()
|
||||||
|
elseif id == 5 then
|
||||||
clearLabel()
|
clearLabel()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue