--SimSoft Yellow -  Copyright by Simlor (http://www.computercraft.info/forums2/index.php?/user/55655-simlor/)

--SystemStart


	--Funktionen


--Clear

function Clear()
	term.clear()
	term.setCursorPos(1,1)
end
 
 
--Set Cursorposition

function CP(x,y)
	term.setCursorPos(x,y)
end
 
 
--Set Background Color

function BC(farbe)
	term.setBackgroundColor(farbe)
end
 
 
--Set Text Color

function TC(farbe)
	term.setTextColor(farbe)
end


--Versions Abfrage

function VersionsAbfrage()
	file = fs.open("SimSoft/Data/Version","r")
	local fileData = {}
	local line = file.readLine()
	repeat
	table.insert(fileData,line)
	line = file.readLine()
	until line == nil
	file.close()
	SystemVersion = fileData[3]
	Sprache = fileData[4]
end

	--System

--FlshDep

BC(32768)
Clear()
sleep(0.1)
BC(128)
Clear()
sleep(0.1)
BC(256)
Clear()
sleep(0.1)
BC(1)
Clear()
sleep(0.1)
	
	
--Aussehen

BC(1)
Clear()

file = fs.open("SimSoft/Data/UserData","r")
local fileData = {}
local line = file.readLine()
repeat
table.insert(fileData,line)
line = file.readLine()
until line == nil
file.close()

Rname = fileData[3]
Rpass = fileData[4]
IsPass = fileData[5]

if IsPass == true or IsPass == "true" then

	file = fs.open("SimSoft/Data/SystemColor","r")
	local fileData = {}
	local line = file.readLine()
	repeat
	table.insert(fileData,line)
	line = file.readLine()
	until line == nil
	file.close()

	SystemColor = fileData[3]

	SystemColor = ((SystemColor-1)+1)

	w, h = term.getSize()

	wC = 0
	hC = 1
	
	while true do

		wC = (wC+1)
	
		CP(wC, hC)
		BC(SystemColor)
		write(" ")
	
		if wC == w then
			if hC == 3 then
				break
			else
				hC = (hC+1)
				wC = 0
			end
		end
	
	end

	anzeige = "SimSoft Yellow"

	TC(1)
	CP(((w/2)-((#anzeige)/2)),2)

	print(anzeige)	
	
	BC(1)

	TC(SystemColor)
	CP(4,8)
	write("Username ")
	TC(128)
	print("- ")

	TC(128)
	CP(4,10)
	write("Password ")
	TC(SystemColor)
	print("- ")
	
	
	CP(15,8)
	TC(SystemColor)
	
	Ename = read()
	
	
	TC(128)
	CP(4,8)
	write("Username ")
	TC(SystemColor)
	write("- ")
	TC(128)
	print(Ename)

	TC(SystemColor)
	CP(4,10)
	write("Password ")
	TC(128)
	print("- ")
	
	
	CP(15,10)
	TC(SystemColor)
	
	Epass = read("#")
	
	
	TC(128)
	CP(4,10)
	write("Password ")
	TC(SystemColor)
	write("- ")
	TC(128)
	print("#######                             ")
	
	CP(2,12)
	TC(SystemColor)
	print("Please Wait...")
	
	if Ename == Rname then
		if Epass == Rpass then
			CP(2,12)
			TC(SystemColor)
			print("Name And Password Are Correct!")
		else
			CP(2,12)
			TC(SystemColor)
			print("Name Or Password Are Incorrect!")
			sleep(1)
			os.reboot()
		end
	
	else
	
		CP(2,12)
		TC(SystemColor)
		print("Name Or Password Are Incorrect!")
		sleep(1)
		os.reboot()
	
	end
	
end

shell.run("SimSoft/System/Desktop")


--end