--Var
orbitv = "0097"
_ms = 0
_ms1 = 0
backColor = colors.gray
wpaper = paintutils.loadImage("/bin/nexos/wallpapers/default")
running = true

--Func

function drawMenu1()
  term.setCursorPos(5,2)
  term.setBackgroundColor(colors.lightGray)
  term.setTextColor(colors.gray)
  term.setCursorPos(5,2)
  print("             ")
  term.setCursorPos(5,3)
  print(" LuaIDE      ")
  term.setCursorPos(5,4)
  print(" Files       ")
  term.setCursorPos(5,5)
  print(" Sketch      ")
  term.setCursorPos(5,6)
  print(" Ink         ")
  term.setCursorPos(5,7)
  print(" Mineception ")
  term.setCursorPos(5,8)
  print(" Firewolf    ")
  term.setCursorPos(5,9)
  print(" Dynet       ")
  term.setCursorPos(5,10)
  print(" CraftEngine ")
  term.setCursorPos(5,11)
  print("             ")
end

function drawMenu0()
	term.setCursorPos(1,2)
	term.setBackgroundColor(colors.lightGray)
	term.setTextColor(colors.gray)
	print("          ")
	print(" Settings ")
	print(" Shutdown ")
	print(" Reboot   ")
	print("          ")
end

function clear()
	term.clear()
	term.setCursorPos(1,1)
end 

term.setBackgroundColor(backColor)
term.clear()

function drawBar()
   term.setCursorPos(1,1)
   term.setBackgroundColor(colors.lightGray)
   term.setTextColor(colors.gray)
   term.clearLine()
   term.setCursorPos(1,1)
   print(" [] [Apps]")
end

function drawDesktop()
	term.setBackgroundColor(colors.gray)
	clear()
	paintutils.drawImage(wpaper,1,1)
end

function runtime()
  while running do
  	event, button, x, y = os.pullEvent("mouse_click")
  	if _ms == 0 and button == 1 and x < 3 and y == 1 then
  		_ms = 1
  		drawMenu0()
  	elseif _ms == 1 and button == 1 and x < 3 and y == 1 then
  		_ms = 0
  		term.clear()
  		term.setCursorPos(1,1)
  		term.setBackgroundColor(colors.gray)
  		init()
  	elseif _ms == 1 and button == 1 and x < 10 and y == 4 then
  		os.shutdown()
   	elseif _ms == 1 and button == 1 and x < 10 and y == 5 then
  		os.reboot()
  	elseif _ms == 1 and button == 1 and x < 10 and y == 3 then
  	    _ms = 0
  	    term.setBackgroundColor(colors.gray)
  	    term.clear()
  	    drawBar()
  	    term.setCursorPos(1,3)
  	    term.setBackgroundColor(colors.gray)
  	    term.setTextColor(colors.lightGray)
  	    print(" NexOS Build #", nexosv)
  	    print(" Orbit Desktop Build #", orbitv)
  	    print(" VCS: ", libvcsR)
  	elseif _ms1 == 0 and button == 1 and x > 4 and y == 1 and x < 15 then
        drawMenu1()
        _ms1 = 1
    elseif _ms1 == 1 and button == 1 and x > 4 and y == 1 and x < 15 then
        _ms1 = 0
        init()
    elseif _ms1 == 1 and button == 1 and x > 5 and y == 3 and x < 15 then
        _ms1 = 0
        shell.run("/bin/apps/luaide")
        init()
    elseif _ms1 == 1 and button == 1 and x > 5 and y == 4 and x < 15 then
        _ms1 = 0
        shell.run("/bin/apps/lemon")
        init()
    elseif _ms1 == 1 and button == 1 and x > 5 and y == 5 and x < 15 then
        _ms1 = 0
        shell.run("/bin/apps/sketch")
        init()
    elseif _ms1 == 1 and button == 1 and x > 5 and y == 6 and x < 15 then
        _ms1 = 0
        shell.run("/bin/apps/ink")
        init()
    elseif _ms1 == 1 and button == 1 and x > 5 and y == 7 and x < 15 then
        _ms1 = 0
        shell.run("/bin/apps/minecraft")
        init()
    elseif _ms1 == 1 and button == 1 and x > 5 and y == 8 and x < 15 then
        _ms1 = 0
        shell.run("/bin/apps/firewolf/client")
        init()
    elseif _ms1 == 1 and button == 1 and x > 5 and y == 9 and x < 15 then
        _ms1 = 0
        shell.run("/dynet/client")
        init()
    elseif _ms1 == 1 and button == 1 and x > 5 and y == 10 and x < 15 then
        _ms1 = 0
        shell.run("/bin/apps/ce")
        init()
  	end
  end
end

function init()
  drawDesktop()
  drawBar()
  runtime()
end

init()


