Advertisement
Nothy

BirchOS4Installer

Jul 25th, 2015
567
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 81.03 KB | None | 0 0
  1. --BIRCH OS INSTALLER, LITERALLY TAKES SECONDS.
  2. BIRCHOS_OS = [[
  3. shell.run("clear")
  4.  
  5. birch.oldUI = false
  6. --os.pullEvent = os.pullEventRaw
  7. l = 0
  8. local edge_boot_dir = "sys16/edge/"
  9. local OS_SYSTEM_VERSION = birch.osversion
  10. local OS_SYSTEM_CREATOR = "COMPUTERCRAFT_COMPUTER."..os.getComputerID()
  11. local OS_SHUTDOWN_MESSAGE = "SHUTTING DOWN"
  12. local OS_REBOOT_MESSAGE = "REBOOTING"
  13. local OS_UNLOCKED = settings.getVariable("system/settings","unlock")
  14. local OS_ROOTLOGIN = false
  15. local OS_BINARYBOOTCODE = settings.getVariable("system/settings","bootcode")
  16. local OS_BINARYBOOTCODE_CHECK = "01000001"
  17. local OS_ADMINLOGIN_PASSWORD = "01011"
  18. local OS_SYSTEM_PREBOOT_VENDOR = ""
  19. local bootPart = 0
  20. local testrows = {"{@} Desktop","","","","","","","","","","","","","","","","","",""} -- This is seriously not a good method for rendering the menu system, it looks cool though.
  21. local CTHEME = tonumber(settings.getVariable("system/api/thememanager/themes/theme.birchtheme","OS_DEFAULTBACKGROUNDCOLOR"))
  22. if settings.getVariable("system/settings","theme") == "dark" then
  23.     OS_GUI_COLOR = colors.gray
  24.     OS_TEXT_COLOR = colors.white
  25.     OS_WELCOME_COLOR = colors.white
  26.     OS_STARTMENU_SHUTDOWNCOLOR = colors.gray
  27.     OS_STARTMENU_LOGOUTCOLOR = colors.gray
  28.     OS_STARTMENU_REBOOTCOLOR = colors.gray
  29.     OS_STARTMENU_COLOR = colors.lightGray
  30.     OS_CMD_COLOR = colors.black
  31.     --OS_BAR_DESIGN = "-======["..formattedTime.."]======-"
  32.     --OS_BAR_BOTTOM_DESIGN = "-o================o-"
  33.     elseif settings.getVariable("system/settings","theme") == "bright" then
  34.     OS_GUI_COLOR = colors.white
  35.     OS_TEXT_COLOR = colors.black
  36.     OS_WELCOME_COLOR = colors.green
  37.     OS_STARTMENU_SHUTDOWNCOLOR = colors.red
  38.     OS_STARTMENU_LOGOUTCOLOR = colors.lime
  39.     OS_STARTMENU_REBOOTCOLOR = colors.yellow
  40.     OS_STARTMENU_COLOR = colors.lightGray
  41.     OS_CMD_COLOR = colors.black
  42.     --OS_BAR_DESIGN = "-======["..formattedTime.."]======-"
  43.     --OS_BAR_BOTTOM_DESIGN = "-o================o-"
  44.     elseif settings.getVariable("system/settings","theme") == "custom" then
  45.     OS_GUI_COLOR = tonumber(settings.getVariable("system/api/thememanager/themes/theme.birchtheme","OS_DEFAULTBACKGROUNDCOLOR"))
  46.     OS_TEXT_COLOR = tonumber(settings.getVariable("system/api/thememanager/themes/theme.birchtheme","OS_DEFAULTTEXTCOLOR"))
  47.     OS_WELCOME_COLOR = tonumber(settings.getVariable("system/api/thememanager/themes/theme.birchtheme","OS_LOGINSCREEN_WELCOMECOLOR"))
  48.     OS_STARTMENU_SHUTDOWNCOLOR = tonumber(settings.getVariable("system/api/thememanager/themes/theme.birchtheme","OS_STARTMENU_SHUTDOWNCOLOR"))
  49.     OS_STARTMENU_LOGOUTCOLOR = tonumber(settings.getVariable("system/api/thememanager/themes/theme.birchtheme","OS_STARTMENU_LOGOUTCOLOR"))
  50.     OS_STARTMENU_REBOOTCOLOR = tonumber(settings.getVariable("system/api/thememanager/themes/theme.birchtheme","OS_STARTMENU_REBOOTCOLOR"))
  51.     OS_STARTMENU_COLOR = tonumber(settings.getVariable("system/api/thememanager/themes/theme.birchtheme","OS_STARTMENU_COLOR"))
  52.     OS_CMD_COLOR = tonumber(settings.getVariable("system/api/thememanager/themes/theme.birchtheme","OS_CMD_BGCOLOR"))
  53.     --OS_BAR_DESIGN = "-======["..formattedTime.."]======-"
  54.     --OS_BAR_BOTTOM_DESIGN = "~o================o~"
  55. end
  56. if settings.getVariable("system/settings","theme") == nil then
  57.     OS_TEXT_COLOR = colors.white
  58.     OS_GUI_COLOR = colors.gray
  59. end
  60. state = ""
  61. state_dev = ""
  62. local menu = false -- COMPLETELY DEPRECATED UNLESS birch.oldUI is set to true (set to off by default)
  63. local desktop = false
  64. -- SYSTEM FUNCTIONS
  65.  
  66. function OS_DESKTOP()
  67.     PROGMENU = false
  68.     term.setCursorPos(1,1)
  69.     local day = os.day()
  70.     local systime = os.time()
  71.     if settings.getVariable("system/settings","timeformat") == "12" then
  72.         formattedTime = textutils.formatTime(systime, false)
  73.     else
  74.         formattedTime = textutils.formatTime(systime, true)
  75.     end
  76.     menu = false
  77.     birch.systemcheck()
  78.     term.setBackgroundColor(OS_GUI_COLOR)
  79.     birch.tclear()
  80.     if birch.oldUI == false then
  81.         shell.run("system/desktop_test.lua")
  82.     end
  83.     birch.aP("[>] MENU | Birch OS Ultimate ["..state..""..state_dev.."Day: "..day.."]",OS_TEXT_COLOR)
  84.  
  85.     while true do
  86.         systime = os.time()
  87.         day = os.day()
  88.         if settings.getVariable("system/settings","timeformat") == "12" then
  89.             formattedTime = textutils.formatTime(systime, false)
  90.         else
  91.             formattedTime = textutils.formatTime(systime, true)
  92.         end
  93.         state = birch.osstate
  94.         local event, button, x, y = os.pullEvent("mouse_click")
  95.         if dbg == true then
  96.             print("x:"..x..",y:"..y)
  97.         end
  98.         if x == 2 and y == 1 and button == 1 then
  99.             if not menu == true then
  100.                 term.setCursorPos(2,1)
  101.                 birch.aP("v",OS_TEXT_COLOR)
  102.                 menu = true
  103.                 birch.aP(tostring(OS_BAR_DESIGN),OS_TEXT_COLOR)
  104.                 birch.aP(" [S] SHUT DOWN",OS_STARTMENU_SHUTDOWNCOLOR)
  105.                 birch.aP(" [R] REBOOT",OS_STARTMENU_REBOOTCOLOR) --TODO: CHANGE COLOR
  106.                 birch.aP(" [L] LOG OUT",OS_STARTMENU_LOGOUTCOLOR)
  107.                 birch.aP(" [>] SYSTEM INFORMATION",OS_TEXT_COLOR)
  108.                 birch.aP(" [>] PROGRAMS",OS_TEXT_COLOR)
  109.                 birch.aP(" [>] MONITOR",OS_TEXT_COLOR)
  110.                 birch.aP(" [>] NEW GRAPHICS TEST",colors.red)
  111.                 birch.aP(" [!] This is only here for debug reasons.")
  112.  
  113.                 if OS_UNLOCKED == "true" then
  114.                     print("")
  115.                     birch.aP(" [>] ROOT",OS_TEXT_COLOR)
  116.                 end
  117.                 birch.aP(tostring(OS_BAR_BOTTOM_DESIGN),OS_TEXT_COLOR)
  118.                 else if menu == true then
  119.                     menu = false
  120.                     term.setCursorPos(2,1)
  121.                     term.setTextColor(OS_TEXT_COLOR)
  122.                     birch.aP(">",OS_TEXT_COLOR)
  123.                     OS_DESKTOP()
  124.                 end
  125.  
  126.             end
  127.         end
  128.  
  129.         if x == 3 and y == 3 and button == 1 and menu == true then
  130.             shell.run("system/desktop_test.lua")
  131.         end
  132.         if x == 3 and y == 4 and button == 1 and menu == true then
  133.             os.reboot()
  134.         end
  135.         if x == 2 and y == 5 and button == 1 and menu == true then
  136.             shell.run("system/desktop_test.lua")
  137.         end
  138.         if x == 3 and y == 6 and button == 1 and menu == true then
  139.             SYSTEM_INFO()
  140.         end
  141.         if x == 3 and y == 7 and button == 1 and menu == true then
  142.             --OS_SYSTEM_EDIT()
  143.                 if not PROGMENU == true then
  144.                     menu = false
  145.                     PROGMENU = true
  146.                     shell.run("clear")
  147.                     birch.aP("[v] MENU | Birch OS Ultimate ["..state..""..state_dev.."Day: "..day.."]",OS_TEXT_COLOR)
  148.                     birch.aP("-=[X]==["..formattedTime.."]======-",OS_TEXT_COLOR)
  149.                     birch.aP(" [o] SCRIPT EDITOR",OS_TEXT_COLOR)
  150.                     birch.aP(" [o] VIRTUAL OS",OS_TEXT_COLOR)
  151.                     birch.aP(" [o] CHAT",OS_TEXT_COLOR)
  152.                     birch.aP(" [o] API LOADER",OS_TEXT_COLOR)
  153.                     birch.aP("-= SYSTEM TOOLS =-",OS_TEXT_COLOR)
  154.                     birch.aP(" [o] SYSTEM DIAGNOSE",OS_TEXT_COLOR)
  155.                     birch.aP(" [o] OLD OS FILES",OS_TEXT_COLOR)
  156.                     birch.aP(" [o] UPDATE BIRCH OS",OS_TEXT_COLOR)
  157.                     birch.aP(" [o] CREATE FILE/SCRIPT",OS_TEXT_COLOR)
  158.                     birch.aP(" [o] OPEN PROGRAM",OS_TEXT_COLOR)
  159.  
  160.                 else if PROGMENU == true then
  161.                     PROGMENU = false
  162.                     shell.run("clear")
  163.                     OS_DESKTOP()
  164.                 end
  165.             end
  166.         end
  167.         if x == 4 and y == 2 and button == 1 and PROGMENU == true then
  168.             OS_DESKTOP()
  169.         end
  170.         if x == 3 and y == 8 and button == 1 and menu == true then
  171.             OS_PROGRAMS()
  172.         end
  173.         if x == 3 and y == 9 and button == 1 and menu == true then
  174.             shell.run("system/desktop_test.lua")
  175.         end
  176.         if x == 3 and y == 10 and button == 1 and menu == true and OS_ROOTLOGIN == true then
  177.             OS_SYSTEM_EDIT()
  178.         end
  179.         if x == 3 and y == 3 and button == 1 and PROGMENU == true then
  180.             print("ENTER DIRECTORY")
  181.             dir = read()
  182.             shell.run("edit "..dir)
  183.             return OS_DESKTOP()
  184.         end
  185.         if x == 3 and y == 4 and button == 1 and PROGMENU == true then
  186.             if fs.exists("system/api/source_api_programs/virtualos.lua") then
  187.                 term.clear()
  188.                 term.setBackgroundColor(colors.black)
  189.                 --term.reset()
  190.                 shell.run("system/api/source_api_programs/virtualos.lua")
  191.             else
  192.                 print("NO BOOTABLE OS FOUND.")
  193.             end
  194.         end
  195.         if x == 3 and y == 9 and button == 1 and PROGMENU == true then
  196.             shell.run("system/os.old_ass_file")
  197.         end
  198.         if x == 3 and y == 5 and button == 1 and PROGMENU == true then
  199.             shell.run("system/programs/chat.lua")
  200.         end
  201.         if x == 3 and y == 6 and button == 1 and PROGMENU == true then
  202.             print("ENTER DIRECTORY:")
  203.             d = read()
  204.             os.loadAPI(d)
  205.             print("Loaded successfully.")
  206.             sleep(1)
  207.             return OS_DESKTOP()
  208.         end
  209.         if x == 3 and y == 8 and button == 1 and PROGMENU == true then
  210.             systemdiag.diag("-s","-sa")
  211.         end
  212.         if x == 3 and y == 10 and button == 1 and PROGMENU == true then
  213.             shell.run("clear")
  214.             term.setBackgroundColor(colors.black)
  215.             term.clear()
  216.             birch.sysLog("Updating..")
  217.             shell.run("pastebin run UgSYtY4H")
  218.         end
  219.         if x == 3 and y == 11 and button == 1 and PROGMENU == true then
  220.             birch.aP("Directory:",OS_TEXT_COLOR)
  221.             term.setCursorPos(11,13)
  222.             local dir = io.read()
  223.             birch.aP("Enter data:",OS_TEXT_COLOR)
  224.             local data = io.read()
  225.             birch.createFile(dir,data)
  226.         end
  227.         if x == 3 and y == 12 and button == 1 and PROGMENU == true then
  228.             birch.aP("Directory:",OS_TEXT_COLOR)
  229.             term.setCursorPos(11,13)
  230.             local dir = io.read()
  231.             shell.run(dir)
  232.         end
  233.     end
  234. end
  235.  
  236. -- PROGRAMS
  237. function OS_LOGIN_SCREEN()
  238.     if fs.exists("system/desktop_test.lua") then
  239.     shell.run("system/desktop_test.lua")
  240.     else
  241.         birch.crash("Missing system files: %sysroot%/desktop_test.lua")
  242.     end
  243. end
  244. function SYSTEM_INFO()
  245.     birch.tclear()
  246.     term.setCursorPos(1,1)
  247.     birch.aP("[x]",colors.red)
  248.     term.setCursorPos(4,1)
  249.     birch.aP("            System information",OS_TEXT_COLOR)
  250.     term.setCursorPos(1,2)
  251.     birch.aP("___________________________________________________",OS_TEXT_COLOR)
  252.     birch.aP("SYSTEM VERSION: "..OS_SYSTEM_VERSION,OS_TEXT_COLOR)
  253.     birch.aP("SYSTEM VENDOR: "..OS_SYSTEM_CREATOR,OS_TEXT_COLOR)
  254.     birch.aP("BIRCH OS API VERSION: "..birch.apiversion,OS_TEXT_COLOR)
  255.     birch.aP("NETWORK API VERSION: "..network.apiversion,OS_TEXT_COLOR)
  256.     birch.aP("OPERATION API VERSION: "..operation.apiversion,OS_TEXT_COLOR)
  257.     birch.aP("USER NAME: "..settings.getVariable("system/settings","username"),OS_TEXT_COLOR)
  258.     birch.aP("PASSWORD: "..tostring(settings.getVariable("system/settings","loginkey")),OS_TEXT_COLOR)
  259.     birch.aP("",OS_TEXT_COLOR)
  260.     birch.aP("SYSTEM UNLOCKED: "..OS_UNLOCKED,colors.cyan)
  261.     birch.aP("SYSTEM DEFAULT COLORS: "..tostring(OS_GUI_COLOR).."+"..tostring(OS_TEXT_COLOR),colors.cyan)
  262.     birch.aP("OS ERRORS: "..state,colors.red)
  263.     print("")
  264.     while(1) do
  265.         local event, button, x, y = os.pullEvent("mouse_click")
  266.         if dbg == true then
  267.             print("x:"..x..",y:"..y)
  268.         end
  269.         if x == 2 and y == 1 and button == 1 then
  270.             shell.run("system/desktop_test.lua")--OS_DESKTOP()
  271.         end
  272.     end
  273.  
  274. end
  275. function NETWORK_CONNECTION_TEST()
  276.     --print("Attempting to connect..")
  277.     --rednet.open("right")
  278.     --rednet.broadcast("move_back")
  279.     --sleep(1)
  280.     --rednet.broadcast("turn_right")
  281.     --sleep(1)
  282.     --rednet.broadcast("move_forward")
  283.     --sleep(1)
  284.     --rednet.broadcast("move_back")
  285.     --sleep(1)
  286.     --rednet.broadcast("turn_left")
  287.     --print("Connected.")
  288.     --DISABLED SINCE ALPHA 4.0
  289. end
  290. function OS_FIRST_BOOT()
  291.     local CTHEME = tonumber(settings.getVariable("system/api/thememanager/themes/theme.birchtheme","OS_DEFAULTBACKGROUNDCOLOR"))
  292.     local usrnm = false
  293.     local thm = false
  294.     local tfm = false
  295.     shell.run("clear")
  296.     edge.button(1,1,16,19,colors.lightGray,OS_GUI_COLOR,"First Boot Setup")
  297.     edge.button(3,3,13,3,colors.gray,OS_GUI_COLOR,"Username")
  298.     edge.button(3,5,13,5,colors.gray,OS_GUI_COLOR,"Password")
  299.     edge.button(3,7,13,7,colors.lightGray,OS_GUI_COLOR,"Themes:")
  300.     edge.button(3,9,13,9,colors.gray,OS_GUI_COLOR,"Dark")
  301.     edge.button(3,11,13,11,colors.white,OS_GUI_COLOR,"Bright")
  302.     edge.button(3,13,13,13,CTHEME,OS_GUI_COLOR,"Custom")
  303.     edge.button(3,15,13,15,colors.lightGray,OS_GUI_COLOR,"Clock format:")
  304.     edge.button(2,17,7,17,colors.gray,OS_GUI_COLOR,"AM/PM")
  305.     edge.button(9,17,14,17,colors.gray,OS_GUI_COLOR,"24H")
  306.     edge.button(40,17,45,17,colors.gray,OS_GUI_COLOR,"Next")
  307.     edge.xprint("Welcome to Birch OS!",25,5,colors.black)
  308.     edge.xprint("Please pick your username and ",20,7,colors.black)
  309.     edge.xprint("password (pass is optional)!",20,8,colors.black)
  310.     edge.xprint("Pick a theme of your liking.",20,10,colors.black)
  311.     while(true) do
  312.         local event, button, x, y = os.pullEvent("mouse_click")
  313.         if x == 3 and y == 3 or x == 4 and y == 3 or x == 5 and y == 3 or x == 6 and y == 3 or x == 7 and y == 3 or x == 8 and y == 3 or x == 9 and y == 3 or x == 10 and y == 3 or x == 11 and y == 3 or x == 12 and y == 3 or x == 13 and y == 3 then
  314.             edge.button(3,3,13,3,colors.white,OS_GUI_COLOR,"")
  315.             term.setCursorPos(3,3)
  316.             term.setTextColor(colors.black)
  317.             local usr = io.read()
  318.             settings.setVariable("system/settings","username",usr)
  319.             usrnm = true
  320.             edge.button(3,3,13,3,colors.green,OS_GUI_COLOR,usr)
  321.         end
  322.         if x == 3 and y == 5 or x == 4 and y == 5 or x == 5 and y == 5 or x == 6 and y == 5 or x == 7 and y == 5 or x == 8 and y == 5 or x == 9 and y == 5 or x == 10 and y == 5 or x == 11 and y == 5 or x == 12 and y == 5 or x == 13 and y == 5 then
  323.             edge.button(3,5,13,5,colors.white,OS_GUI_COLOR,"")
  324.             term.setCursorPos(3,5)
  325.             term.setTextColor(colors.black)
  326.             local pass = read("*")
  327.             settings.setVariable("system/settings","loginkey",pass)
  328.             edge.button(3,5,13,5,colors.green,OS_GUI_COLOR,"Pass set!")
  329.         end
  330.         if x == 3 and y == 9 or x == 4 and y == 9 or x == 5 and y == 9 or x == 6 and y == 9 or x == 7 and y == 9 or x == 8 and y == 9 or x == 9 and y == 9 or x == 10 and y == 9 or x == 11 and y == 9 or x == 12 and y == 9 or x == 13 and y == 9 then
  331.             edge.button(3,9,13,9,colors.gray,OS_GUI_COLOR,"Theme set!")
  332.             settings.setVariable("system/settings","theme","dark")
  333.             thm = true
  334.         end
  335.         if x == 3 and y == 11 or x == 4 and y == 11 or x == 5 and y == 11 or x == 6 and y == 11 or x == 7 and y == 11 or x == 8 and y == 11 or x == 9 and y == 11 or x == 10 and y == 11 or x == 11 and y == 11 or x == 12 and y == 11 or x == 13 and y == 11 then
  336.             edge.button(3,11,13,11,colors.white,OS_GUI_COLOR,"Theme set!")
  337.             settings.setVariable("system/settings","theme","bright")
  338.             thm = true
  339.         end
  340.         if x == 3 and y == 13 or x == 4 and y == 13 or x == 5 and y == 13 or x == 6 and y == 13 or x == 7 and y == 13 or x == 8 and y == 13 or x == 9 and y == 13 or x == 10 and y == 13 or x == 11 and y == 13 or x == 12 and y == 13 or x == 13 and y == 13 then
  341.             edge.button(3,13,13,13,CTHEME,OS_GUI_COLOR,"Theme set!")
  342.             settings.setVariable("system/settings","theme","custom")
  343.             thm = true
  344.         end
  345.         if x == 2 and y == 17 or x == 3 and y == 17 or x == 4 and y == 17 or x == 5 and y == 17 or x == 6 and y == 17 or x == 7 and y == 17 then
  346.             edge.button(2,17,7,17,colors.green,OS_GUI_COLOR,"AM/PM")
  347.             settings.setVariable("system/settings","timeformat","12")
  348.             tfm = true
  349.         end
  350.         if x == 9 and y == 17 or x == 10 and y == 17 or x == 11 and y == 17 or x == 12 and y == 17 or x == 13 and y == 17 or x == 14 and y == 17 then
  351.             edge.button(9,17,14,17,colors.green,OS_GUI_COLOR,"24H")
  352.             settings.setVariable("system/settings","timeformat","24")
  353.             tfm = true
  354.         end
  355.         if x == 40 and y == 17 or x == 41 and y == 17 or x == 42 and y == 17 or x == 43 and y == 17 or x == 44 and y == 17 or x == 45 and y == 17 then
  356.             if tfm == true and thm == true and usrnm == true then
  357.                 os.reboot()
  358.             else
  359.                 if tfm == false then
  360.                     edge.xprint("Pick time format!",20,17,colors.red)
  361.                 end
  362.                 if thm == false then
  363.                     edge.xprint("Pick a theme!",20,11,colors.red)
  364.                 end
  365.                 if usrnm == false then
  366.                     edge.xprint("Pick your username!",20,3,colors.red)
  367.                 end
  368.                 sleep(3)
  369.                 OS_FIRST_BOOT()
  370.             end
  371.         end
  372.     end
  373.     --sleep(999)
  374. end
  375.  
  376. function OS_PROGRAMS()
  377.     -- THIS WAS SUPPOSED TO BE A PROGRAM LIST.
  378.     birch.sysLog("Started monitor setup")
  379.     shell.run("clear")
  380.     birch.printcenter("SIDE: ",2)
  381.     side = read()
  382.     shell.run("monitor "..side.." startup")
  383.     return OS_DESKTOP()
  384. end
  385.  
  386. function OS_DEBUG()
  387.     shell.run("clear")
  388.     print("[X] CLEAR LOGS")
  389.     print("[X] FORCE SHUTDOWN")
  390.     print("[X] REINSTALL BIRCHOS")
  391.     print("[X] DISABLE THEMES")
  392.     print("[X] RESET BIRCHOS TO FACTORY SETTINGS")
  393.     print("[X] INSTALL EXPERIMENTAL VERSION")
  394.     print("[X] COMMAND PROMPT")
  395.     print("[X] UNINSTALL BIRCH OS ULTIMATE")
  396.     print("")
  397.     print("[X] EXIT")
  398.     local event, button, x, y = os.pullEvent("mouse_click")
  399.     while(true) do
  400.         if x == 2 and y == 1 and button == 1 then
  401.             fs.delete("system/log.txt")
  402.             fs.delete("system/crashlog")
  403.             os.reboot()
  404.         end
  405.         if x == 2 and y == 2 and button == 1 then
  406.             os.shutdown()
  407.         end
  408.         if x == 2 and y == 3 and button == 1 then
  409.             shell.run("pastebin run UgSYtY4H")
  410.         end
  411.         if x == 2 and y == 4 and button == 1 then
  412.             settings.setVariable("system/settings","theme","dark")
  413.             return OS_DEBUG()
  414.         end
  415.         if x == 2 and y == 5 and button == 1 then
  416.             settings.setVariable("system/settings","username","nil")
  417.             settings.setVariable("system/settings","loginkey","nil")
  418.             return OS_DEBUG()
  419.         end
  420.         if x == 2 and y == 6 and button == 1 then
  421.             shell.run("pastebin run haULzXdY")
  422.         end
  423.         if x == 2 and y == 7 and button == 1 then
  424.             OS_COMMANDLINE()
  425.         end
  426.         if x == 2 and y == 8 and button == 1 then
  427.             shell.run("rm system")
  428.             shell.run("rm startup")
  429.             shell.run("rm beta")
  430.             print("BirchOS has been uninstalled.")
  431.             sleep(2)
  432.             os.reboot()
  433.         end
  434.         if x == 2 and y == 10 and button == 1 then
  435.             BOOT_ANIMATION()
  436.         end
  437.     end
  438. end
  439. function AdvanceBoot()
  440.     if bootPart == 0 then
  441.         term.setBackgroundColor(OS_GUI_COLOR)
  442.         term.setTextColor(OS_TEXT_COLOR)
  443.         shell.run("clear")
  444.         if birch.release == false then
  445.             birch.printcenter("PRE-RELEASE PRODUCT",18)
  446.             birch.printcenter(birch.osversion,19)
  447.         end
  448.         if fs.exists("beta/birchtwo") then
  449.         os.loadAPI("beta/birchtwo")
  450.         else
  451.             birch.crash("MISSING_API: BETA/BIRCHTWO")
  452.         end
  453.         birch.printcenter("Birch OS",8)
  454.         birch.printcenter("[==        ]",10)
  455.         sleep(0.3)
  456.         shell.run("clear")
  457.         if birch.release == false then
  458.             birch.printcenter("PRE-RELEASE PRODUCT",18)
  459.             birch.printcenter(birch.osversion,19)
  460.         end
  461.         if fs.exists("system/api/sc") then
  462.         os.loadAPI("system/api/sc")
  463.         else
  464.             birch.crash("MISSING_API: API/SC")
  465.         end
  466.         birch.printcenter("Birch OS",8)
  467.         birch.printcenter("[====      ]",10)
  468.         sleep(0.05)
  469.         shell.run("clear")
  470.         if birch.release == false then
  471.             birch.printcenter("PRE-RELEASE PRODUCT",18)
  472.             birch.printcenter(birch.osversion,19)
  473.         end
  474.         if fs.exists("system/api/network") then
  475.         os.loadAPI("system/api/network")
  476.         else
  477.             birch.crash("MISSING_API: API/NETWORK")
  478.         end
  479.         birch.printcenter("Birch OS",8)
  480.         birch.printcenter("[======    ]",10)
  481.         sleep(0.17)
  482.         shell.run("clear")
  483.         if birch.release == false then
  484.             birch.printcenter("PRE-RELEASE PRODUCT",18)
  485.             birch.printcenter(birch.osversion,19)
  486.         end
  487.         if fs.exists("system/api/operation") then
  488.         os.loadAPI("system/api/operation")
  489.         else
  490.             birch.crash("MISSING_API: API/OPERATION")
  491.         end
  492.         birch.printcenter("Birch OS",8)
  493.         birch.printcenter("[========  ]",10)
  494.         sleep(0.1)
  495.         shell.run("clear")
  496.         if birch.release == false then
  497.             birch.printcenter("PRE-RELEASE PRODUCT",18)
  498.             birch.printcenter(birch.osversion,19)
  499.         end
  500.         if fs.exists("beta/systemdiag") then
  501.         os.loadAPI("beta/systemdiag")
  502.         else
  503.             birch.crash("MISSING_API: BETA/SYSTEMDIAG")
  504.         end
  505.         birch.printcenter("Birch OS",8)
  506.         birch.printcenter("[==========]",10)
  507.         sleep(0.2)
  508.         shell.run("clear")
  509.         if birch.release == false then
  510.             birch.printcenter("PRE-RELEASE PRODUCT",18)
  511.             birch.printcenter(birch.osversion,19)
  512.         end
  513.         if fs.exists("system/api/edge") then
  514.         os.loadAPI("system/api/edge")
  515.         else
  516.             birch.crash("MISSING_API: Edge Graphics API")
  517.         end
  518.         birch.printcenter("Birch OS",8)
  519.         --birch.printcenter("[ULTIMATE]",9)
  520.         birch.printcenter("[==========]",10)
  521.         birch.sysLog("Finished loading")
  522.         sleep(0.3)
  523.         if settings.getVariable("system/settings","username") == "nil"  then
  524.             OS_FIRST_BOOT()
  525.         end
  526.         term.setBackgroundColor(OS_GUI_COLOR)
  527.         OS_LOGIN_SCREEN()
  528.     end
  529. end
  530. -- BOOT STUFF
  531. if not http then
  532.     birch.crash("HTTP_NOT_ENABLED")
  533. end
  534.  
  535. -- LOAD SYSTEM FILES --
  536.  
  537. -- There are literally no APIS to load, since they're loaded in /startup
  538.  
  539.  
  540. -- SET UP SYSTEM --
  541. --print("[OS] Setting up system")
  542. if settings.getVariable("system/settings","autoupdate") == nil then
  543.     settings.setVariable("system/settings","autoupdate","false")
  544. end
  545. os.setComputerLabel("[BirchOS]")
  546. birch.sysLog("System initialized!")
  547. if fs.exists("system/crashlog") then
  548.     if settings.getVariable("system/crashlog","crash") == "true" then
  549.         print("RECENT SYSTEM CRASH PROMPT ON LOGIN.")
  550.     end
  551. end
  552. if settings.getVariable("system/settings","unlock") == "true" then
  553.     --birch.aP("[ROOT] System is unlocked",colors.green)
  554.     birch.sysLog("System is unlocked, enabling root access.")
  555.     OS_ROOTLOGIN = true
  556. end
  557.  
  558. if OS_BINARYBOOTCODE == OS_BINARYBOOTCODE_CHECK then
  559.         --sleep(0.001)
  560.     else
  561.     if OS_BINARYBOOTCODE == 01000101 then
  562.         settings.setVariable("system/settings","debug",true)
  563.         birch.sysLog("DEBUG IS ENABLED")
  564.     else
  565.         birch.sysLog("ERROR!! BOOT CODE IS INVALID.")
  566.         birch.crash("INVALID BOOT CODE")
  567.         print(OS_BINARYBOOTCODE)
  568.         print("+")
  569.         print(OS_BINARYBOOTCODE_CHECK)
  570.         print("DOES NOT MATCH")
  571.         while(true) do
  572.             sleep(1)
  573.         end
  574.     end
  575. end
  576.  
  577. if settings.getVariable("system/crashlog","reason") then
  578.   r = settings.getVariable("system/crashlog","reason")
  579. end
  580.  
  581. if settings.getVariable("system/settings","debug") == "true" then
  582.   dbg = true
  583. end
  584. if settings.getVariable("system/crashlog","crash") == "true" then
  585.   c = true
  586. end
  587. if settings.getVariable("system/settings","edgebeta") == "true" then
  588.     shell.run("clear")
  589.     birch.sysLog("BIRCH EDGE BETA NOT FOUND")
  590. end
  591. if settings.getVariable("system/settings","disablebootan") == "true" then
  592.     os.loadAPI("system/api/birch")
  593.     os.loadAPI("system/api/settings")
  594.     os.loadAPI("system/api/sc")
  595.     os.loadAPI("system/api/operation")
  596.     os.loadAPI("system/api/edge")
  597.     os.loadAPI("system/api/network")
  598.     shell.run("system/desktop_test.lua")
  599. else
  600.     AdvanceBoot()
  601. end
  602.  
  603. ]]
  604. BIRCHOS_DESKTOP = [[
  605. shell.run("clear")
  606. birch.systemcheck()
  607. birch.oldUI = false
  608. os.pullEvent = os.pullEventRaw
  609. l = 0
  610. local edge_boot_dir = "sys16/edge/"
  611. local OS_SYSTEM_VERSION = birch.osversion
  612. local OS_SYSTEM_CREATOR = "COMPUTERCRAFT_COMPUTER."..os.getComputerID()
  613. local OS_SHUTDOWN_MESSAGE = "SHUTTING DOWN"
  614. local OS_REBOOT_MESSAGE = "REBOOTING"
  615. local OS_UNLOCKED = settings.getVariable("system/settings","unlock")
  616. local OS_ROOTLOGIN = false
  617. local OS_BINARYBOOTCODE = settings.getVariable("system/settings","bootcode")
  618. local OS_BINARYBOOTCODE_CHECK = "01000001"
  619. local OS_ADMINLOGIN_PASSWORD = "01011"
  620. local OS_SYSTEM_PREBOOT_VENDOR = ""
  621. local bootPart = 0
  622.  -- This is seriously not a good method for rendering the menu system, it looks cool though.
  623. local CTHEME = tonumber(settings.getVariable("system/api/thememanager/themes/theme.birchtheme","OS_DEFAULTBACKGROUNDCOLOR"))
  624. if settings.getVariable("system/settings","theme") == "dark" then
  625.     OS_GUI_COLOR = colors.gray
  626.     OS_TEXT_COLOR = colors.white
  627.     OS_WELCOME_COLOR = colors.white
  628.     OS_STARTMENU_SHUTDOWNCOLOR = colors.gray
  629.     OS_STARTMENU_LOGOUTCOLOR = colors.gray
  630.     OS_STARTMENU_REBOOTCOLOR = colors.gray
  631.     OS_STARTMENU_COLOR = colors.lightGray
  632.     OS_CMD_COLOR = colors.black
  633.     --OS_BAR_DESIGN = "-======["..formattedTime.."]======-"
  634.     --OS_BAR_BOTTOM_DESIGN = "-o================o-"
  635.     elseif settings.getVariable("system/settings","theme") == "bright" then
  636.     OS_GUI_COLOR = colors.white
  637.     OS_TEXT_COLOR = colors.black
  638.     OS_WELCOME_COLOR = colors.green
  639.     OS_STARTMENU_SHUTDOWNCOLOR = colors.red
  640.     OS_STARTMENU_LOGOUTCOLOR = colors.lime
  641.     OS_STARTMENU_REBOOTCOLOR = colors.yellow
  642.     OS_STARTMENU_COLOR = colors.lightGray
  643.     OS_CMD_COLOR = colors.black
  644.     --OS_BAR_DESIGN = "-======["..formattedTime.."]======-"
  645.     --OS_BAR_BOTTOM_DESIGN = "-o================o-"
  646.     elseif settings.getVariable("system/settings","theme") == "custom" then
  647.     OS_GUI_COLOR = tonumber(settings.getVariable("system/api/thememanager/themes/theme.birchtheme","OS_DEFAULTBACKGROUNDCOLOR"))
  648.     OS_TEXT_COLOR = tonumber(settings.getVariable("system/api/thememanager/themes/theme.birchtheme","OS_DEFAULTTEXTCOLOR"))
  649.     OS_WELCOME_COLOR = tonumber(settings.getVariable("system/api/thememanager/themes/theme.birchtheme","OS_LOGINSCREEN_WELCOMECOLOR"))
  650.     OS_STARTMENU_SHUTDOWNCOLOR = tonumber(settings.getVariable("system/api/thememanager/themes/theme.birchtheme","OS_STARTMENU_SHUTDOWNCOLOR"))
  651.     OS_STARTMENU_LOGOUTCOLOR = tonumber(settings.getVariable("system/api/thememanager/themes/theme.birchtheme","OS_STARTMENU_LOGOUTCOLOR"))
  652.     OS_STARTMENU_REBOOTCOLOR = tonumber(settings.getVariable("system/api/thememanager/themes/theme.birchtheme","OS_STARTMENU_REBOOTCOLOR"))
  653.     OS_STARTMENU_COLOR = tonumber(settings.getVariable("system/api/thememanager/themes/theme.birchtheme","OS_STARTMENU_COLOR"))
  654.     OS_CMD_COLOR = tonumber(settings.getVariable("system/api/thememanager/themes/theme.birchtheme","OS_CMD_BGCOLOR"))
  655.     --OS_BAR_DESIGN = "-======["..formattedTime.."]======-"
  656.     --OS_BAR_BOTTOM_DESIGN = "~o================o~"
  657. end
  658. function desktop()
  659.     term.clear()
  660.     birch.systemcheck()
  661.  
  662.  
  663.     --edge.button(3,3,12,4,colors.blue,OS_GUI_COLOR,"Home")
  664.     --edge.button(14,3,23,4,colors.orange,OS_GUI_COLOR,"Settings")
  665.     --edge.button(3,6,12,7,colors.red,OS_GUI_COLOR,"Shut down")
  666.     --edge.button(3,9,12,10,colors.green,OS_GUI_COLOR,"Log Out")
  667.     edge.xprint(">",1,9,OS_TEXT_COLOR)
  668.     edge.xprint("<",51,9,OS_TEXT_COLOR)
  669.     --edge.button(50,1,52,1,colors.lightGray,OS_GUI_COLOR,"X")
  670.     edge.xprint("BirchOS/"..settings.getVariable("system/settings","username").."/",1,1,OS_TEXT_COLOR)
  671.     edge.xprint(birch.osstate,1,2,OS_TEXT_COLOR)
  672.     edge.xprint("c",51,1,OS_TEXT_COLOR)
  673.  
  674.  
  675.     --edge.xprint("[EDGE DESKTOP SYSTEM API]",1,19,colors.cyan)
  676.     --edge.xprint("Home",3,3,colors.black)
  677.     --edge.xprint("Settings",14,3,colors.black)
  678.  
  679.     while(true) do
  680.  
  681.         if settings.getVariable("system/settings","timeformat") == "12" then
  682.             --edge.xtime(42,1)
  683.             edge.xtime(term.getSize() / 2 - 3,1)
  684.         else
  685.             edge.xtime(term.getSize() / 2 - 3,1)
  686.         end
  687.         local event, button, x, y = os.pullEvent("mouse_click")
  688.         --if x == 3 and y == 3 or x == 4 and y == 3 or x == 5 and y == 3 or x == 6 and y == 3 or x == 7 and y == 3 or x == 8 and y == 3 or x == 9 and y == 3 or x == 10 and y == 3 or x == 11 and y == 3 or x == 12 and y == 3 or x == 3 and y == 4 or x == 4 and y == 4 or x == 5 and y == 4 or x == 6 and y == 4 or x == 7 and y == 4 or x == 8 and y == 4 or x == 9 and y == 4 or x == 10 and y == 4 or x == 11 and y == 4 or x == 12 and y == 4 then
  689.         --  return OS_DESKTOP()
  690.         --end
  691.         --if x == 14 and y == 3 or x == 15 and y == 3 or x == 16 and y == 3 or x == 17 and y == 3 or x == 18 and y == 3 or x == 19 and y == 3 or x == 20 and y == 3 or x == 21 and y == 3 or x == 14 and y == 4 or x == 15 and y == 4 or x == 16 and y == 4 or x == 17 and y == 4 or x == 18 and y == 4 or x == 19 and y == 4 or x == 20 and y == 4 or x == 21 and y == 4 then
  692.         --  shell.run("clear")
  693.         --  edge.setbgColor(colors.black)
  694.         --  return OS_SYSTEM_EDIT()
  695.         --end
  696.         --if x == 3 and y == 6 or x == 4 and y == 6 or x == 5 and y == 6 or x == 6 and y == 6 or x == 7 and y == 6 or x == 8 and y == 6 or x == 9 and y == 6 or x == 10 and y == 6 or x == 11 and y == 6 or x == 12 and y == 6 or x == 3 and y == 7 or x == 4 and y == 7 or x == 5 and y == 7 or x == 6 and y == 7 or x == 7 and y == 7 or x == 8 and y == 7 or x == 9 and y == 7 or x == 10 and y == 7 or x == 11 and y == 7 or x == 12 and y == 7 then
  697.             --edge.setbgColor(colors.black)
  698.             --return OS_SHUTDOWN_REBOOT("SHUTDOWN")--edge.shutdown(0)
  699.         --end
  700.         if x == 51 and y == 1 and button == 1 or button == 2 then
  701.             commandline()
  702.         end
  703.         if x == 51 and y == 9 and button == 1 then
  704.             edge.button(37,1,51,19,OS_STARTMENU_COLOR,OS_GUI_COLOR,"")
  705.             edge.button(51,8,51,8,OS_STARTMENU_COLOR,OS_GUI_COLOR,"+")
  706.             edge.button(51,10,51,10,OS_STARTMENU_COLOR,OS_GUI_COLOR,"+")
  707.             edge.button(39,2,50,2,OS_STARTMENU_COLOR,OS_GUI_COLOR,"Day: "..os.day())
  708.             edge.button(39,4,49,4,colors.gray,OS_GUI_COLOR,"VirtualOS")
  709.             edge.button(39,6,49,6,colors.gray,OS_GUI_COLOR,"New file")
  710.             if fs.exists(tostring(settings.getVariable("system/desktopcfg","customprogram"))) then
  711.                 if tostring(settings.getVariable("system/desktopcfg","customprogram")) == "system/api/source_api_programs/bootloader" then
  712.                     edge.button(39,8,49,8,colors.gray,OS_GUI_COLOR,"SettEdit")
  713.                 elseif tostring(settings.getVariable("system/desktopcfg","customprogram")) == "system/os.lua" then
  714.                     edge.button(39,8,49,8,colors.gray,OS_GUI_COLOR,"Kernel")
  715.                 elseif tostring(settings.getVariable("system/desktopcfg","customprogram")) == "system/desktop_test.lua" then
  716.                     edge.button(39,8,49,8,colors.gray,OS_GUI_COLOR,"Desktop")
  717.                 else
  718.                     edge.button(39,8,49,8,colors.gray,OS_GUI_COLOR,string.sub(settings.getVariable("system/desktopcfg","customprogram"),-8,-5))
  719.                 end
  720.             end
  721.             if fs.exists(tostring(settings.getVariable("system/desktopcfg","customprogramtwo"))) then
  722.                 if settings.getVariable("system/desktopcfg","customprogramtwo") == "system/api/source_api_programs/bootloader" then
  723.                     edge.button(39,10,49,10,colors.gray,OS_GUI_COLOR,"SettEdit")
  724.                 elseif tostring(settings.getVariable("system/desktopcfg","customprogramtwo")) == "system/os.lua" then
  725.                     edge.button(39,10,49,10,colors.gray,OS_GUI_COLOR,"Kernel")
  726.                 elseif tostring(settings.getVariable("system/desktopcfg","customprogramtwo")) == "system/desktop_test.lua" then
  727.                     edge.button(39,10,49,10,colors.gray,OS_GUI_COLOR,"Desktop")
  728.                 else
  729.                     edge.button(39,10,49,10,colors.gray,OS_GUI_COLOR,string.sub(settings.getVariable("system/desktopcfg","customprogramtwo"),1,-5))
  730.                 end
  731.             end
  732.             --edge.xtime(38,4)
  733.             edge.xprint(">",36,9,OS_TEXT_COLOR)
  734.  
  735.             while(true) do
  736.                 local event, button, x, y = os.pullEvent("mouse_click")
  737.                 if x == 51 and y == 8 then
  738.                     edge.button(39,8,49,8,colors.white,OS_GUI_COLOR,"")
  739.                     term.setCursorPos(39,8)
  740.                     term.setTextColor(colors.black)
  741.                     local customp = io.read()
  742.                     settings.setVariable("system/desktopcfg","customprogram",customp)
  743.                     edge.button(39,8,49,8,colors.white,OS_GUI_COLOR,"Program set")
  744.                 end
  745.                 if x == 51 and y == 10 then
  746.                     edge.button(39,10,49,10,colors.white,OS_GUI_COLOR,"")
  747.                     term.setCursorPos(39,10)
  748.                     term.setTextColor(colors.black)
  749.                     local customp = io.read()
  750.                     settings.setVariable("system/desktopcfg","customprogramtwo",customp)
  751.                     edge.button(39,10,49,10,colors.white,OS_GUI_COLOR,"Program set")
  752.                 end
  753.                 if settings.getVariable("system/settings","debug") == "false" then
  754.                     os.setComputerLabel("[BirchOS "..settings.getVariable("system/settings","username").."]")
  755.                 else
  756.                     os.setComputerLabel("x:"..x.." , y:"..y)
  757.                 end
  758.                 if x == 36 and y == 9 then
  759.                     desktop()
  760.                 end
  761.                 if x >= 39 and x <= 49 and y == 4 then
  762.                     virtualos()
  763.                 end
  764.                 if x >= 39 and x <= 49 and y == 8 then
  765.                     if fs.exists(settings.getVariable("system/desktopcfg","customprogram")) then
  766.                         shell.run(tostring(settings.getVariable("system/desktopcfg","customprogram")))
  767.                     end
  768.                 end
  769.                 if x >= 39 and x <= 49 and y == 10 then
  770.                     if fs.exists(settings.getVariable("system/desktopcfg","customprogramtwo")) then
  771.                         shell.run(tostring(settings.getVariable("system/desktopcfg","customprogramtwo")))
  772.                     end
  773.                 end
  774.                 if x >= 39 and x <= 49 and y == 6 then
  775.                     edge.button(39,6,49,6,colors.white,OS_GUI_COLOR,"")
  776.                     term.setCursorPos(39,6)
  777.                     term.setTextColor(colors.black)
  778.                     local file = io.read()
  779.                     local cfile = fs.open(file,"w")
  780.                     cfile.close()
  781.                     term.setTextColor(colors.white)
  782.                     shell.run("edit "..file)
  783.                     return desktop()
  784.                 end
  785.             end
  786.         end
  787.         if x == 1 and y == 9 and button == 1 then
  788.             -- search function
  789.             edge.xprint("<",16,9,OS_TEXT_COLOR)
  790.             edge.button(1,1,15,19,OS_STARTMENU_COLOR,OS_GUI_COLOR,"    Search")
  791.             edge.button(3,3,13,3,colors.white,OS_GUI_COLOR,"Search..")
  792.             edge.button(3,5,13,5,colors.gray,OS_GUI_COLOR,"Monitor")
  793.             edge.button(3,7,13,7,colors.gray,OS_GUI_COLOR,"Info")
  794.             edge.button(3,9,13,9,colors.gray,OS_GUI_COLOR,"Settings")
  795.             edge.button(3,14,13,14,OS_STARTMENU_SHUTDOWNCOLOR,OS_GUI_COLOR,"Shut down")
  796.             edge.button(3,16,13,16,OS_STARTMENU_LOGOUTCOLOR,OS_GUI_COLOR,"Log out")
  797.             edge.button(3,18,13,18,OS_STARTMENU_REBOOTCOLOR,OS_GUI_COLOR,"Reboot")
  798.             --term.setCursorPos(3,3)
  799.             --term.setTextColor(colors.black)
  800.             --searhquery = io.read()
  801.             --term.setTextColor(colors.white)
  802.             while(true) do
  803.                 local event, button, x, y = os.pullEvent("mouse_click")
  804.                 --if x == 3 and y == 16 or x == 4 and y == 16 or x == 5 and y == 16 or x == 6 and y == 16 or x == 7 and y == 16 or x == 8 and y == 16 or x == 9 and y == 16 or x == 10 and y == 16 or x == 12 and y == 16 or x == 13 and y == 16 then
  805.                     --edge.textColor(OS_TEXT_COLOR)
  806.                     --return OS_LOGIN_SCREEN()
  807.                 --end
  808.                 --if x == 3 and y == 14 or x == 4 and y == 14 or x == 5 and y == 14 or x == 6 and y == 14 or x == 7 and y == 14 or x == 8 and y == 14 or x == 9 and y == 14 or x == 10 and y == 14 or x == 12 and y == 14 or x == 13 and y == 14 then
  809.                     --edge.textColor(OS_TEXT_COLOR)
  810.                     --birch.off()
  811.                 --end
  812.                 if x == 3 and y == 7 or x == 4 and y == 7 or x == 5 and y == 7 or x == 6 and y == 7 or x == 7 and y == 7 or x == 8 and y == 7 or x == 9 and y == 7 or x == 10 and y == 7 or x == 12 and y == 7 or x == 13 and y == 7 then
  813.                     edge.button(1,1,15,19,OS_STARTMENU_COLOR,OS_GUI_COLOR,"     Info")
  814.                     birch.sysLog("Rendering")
  815.                     --edge.button(3,3,13,3,colors.gray,OS_GUI_COLOR,"< BACK")
  816.                     edge.button(3,3,13,3,colors.gray,OS_GUI_COLOR,"System")
  817.                     edge.button(3,5,13,5,colors.gray,OS_GUI_COLOR,"Edition")
  818.                     edge.button(3,7,13,7,colors.gray,OS_GUI_COLOR,"Changelog")
  819.                     while(true) do
  820.                         local event, button, x, y = os.pullEvent("mouse_click")
  821.                             if x == 16 and y == 9 then
  822.                                 desktop()
  823.                             end
  824.                             if x >= 3 and x <= 13 and y == 7 then
  825.                                 edge.button(15,1,52,19,colors.gray,OS_GUI_COLOR,"   Changelog")
  826.                                 edge.button(17,5,17,5,colors.gray,OS_GUI_COLOR,"Version 1.1:")
  827.                                 edge.button(18,6,18,6,colors.gray,OS_GUI_COLOR,"Added custom buttons")
  828.                             end
  829.                             if x == 3 and y == 3 or x == 4 and y == 3 or x == 5 and y == 3 or x == 6 and y == 3 or x == 7 and y == 3 or x == 8 and y == 3 or x == 9 and y == 3 or x == 10 and y == 3 or x == 11 and y == 3 or x == 12 and y == 3 or x == 13 and y == 3 then
  830.                                 edge.button(15,1,52,19,colors.gray,OS_GUI_COLOR,"   System Information")
  831.                                 edge.button(17,3,25,3,colors.gray,OS_GUI_COLOR,"System version: "..tostring(birch.osversion))
  832.                                 edge.button(17,5,25,3,colors.gray,OS_GUI_COLOR,"BirchAPI version: "..tostring(birch.apiversion))
  833.                                 edge.button(17,7,25,3,colors.gray,OS_GUI_COLOR,"EdgeAPI version: "..tostring(edge.version))
  834.                                 edge.button(17,11,25,3,colors.gray,OS_GUI_COLOR,"Username: "..tostring(settings.getVariable("system/settings","username")))
  835.                                 if fs.getFreeSpace("") / 1024 <= 1 then
  836.                                     edge.button(17,15,25,3,colors.gray,OS_GUI_COLOR,"Free space: "..tostring(math.floor(fs.getFreeSpace("/")/1024)).."KB [Low]")
  837.                                 else
  838.                                     edge.button(17,15,25,3,colors.gray,OS_GUI_COLOR,"Free space: "..tostring(math.floor(fs.getFreeSpace("/")/1024)).."KB")
  839.                                 end
  840.                                 if fs.exists("system/") and fs.exists("system/api") and fs.exists("beta") and fs.exists("startup") then
  841.                                     edge.button(17,18,25,3,colors.gray,OS_GUI_COLOR,"System: Healthy")
  842.                                 else
  843.                                     edge.button(17,18,25,3,colors.gray,OS_GUI_COLOR,"System: Severely damaged")
  844.                                 end
  845.                                 edge.xprint("<",16,9,OS_TEXT_COLOR)
  846.                             end
  847.                             if x == 3 and y == 5 or x == 4 and y == 5 or x == 5 and y == 5 or x == 6 and y == 5 or x == 7 and y == 5 or x == 8 and y == 5 or x == 9 and y == 5 or x == 10 and y == 5 or x == 11 and y == 5 or x == 12 and y == 5 or x == 13 and y == 5 then
  848.                                 edge.button(15,1,52,19,colors.gray,OS_GUI_COLOR,"   System Edition")
  849.                                 edge.button(17,3,25,3,colors.gray,OS_GUI_COLOR,"Standard_Edition_"..tostring(birch.osversion))
  850.                                 edge.button(17,18,25,18,colors.gray,OS_GUI_COLOR,"BirchOS by Nothy")
  851.                                 edge.xprint("<",16,9,OS_TEXT_COLOR)
  852.                             end
  853.                             if x == 4 and y == 1 then
  854.                                 edge.button(15,1,52,19,colors.gray,OS_GUI_COLOR,"     EDGE BETA")
  855.                                 edge.button(23,6,35,6,colors.gray,OS_GUI_COLOR,"EDGE BETA CODE:")
  856.                                 edge.button(25,7,35,7,colors.white,OS_GUI_COLOR,"")
  857.                                 edge.xprint("<",16,9,OS_TEXT_COLOR)
  858.                                 while(true) do
  859.                                         local event, button, x, y = os.pullEvent("mouse_click")
  860.                                         if x == 16 and y == 9 then
  861.                                             desktop()
  862.                                         end
  863.                                         if x == 25 and y == 7 or x == 26 and y == 7 or x == 27 and y == 7 or x == 28 and y == 7 or x == 29 and y == 7 or x == 29 and y == 7 or x == 30 and y == 7 or x == 31 and y == 7 or x == 32 and y == 7 or x == 33 and y == 7 or x == 34 and y == 7 then
  864.                                             edge.button(25,7,35,7,colors.white,OS_GUI_COLOR,"")
  865.                                             term.setCursorPos(25,7)
  866.                                             term.setTextColor(colors.black)
  867.                                             code = io.read()
  868.                                             if code == "EDGEBETA" or code == "CM9R2F" or code == "CM10R1G" or code == "NOTHYISBEST" then
  869.                                                 settings.setVariable("system/settings","edgebeta","true")
  870.                                                 edge.button(20,6,35,6,colors.gray,OS_GUI_COLOR,"EDGE BETA will be downloaded on reboot.") --ADD EDGE BETA DOWNLOAD IN BOOT DIR
  871.                                                 sleep(5)
  872.                                                 desktop()
  873.                                                 end
  874.                                             end
  875.                                     end
  876.                             end
  877.                     end
  878.                     --edge.button(15,1,52,19,colors.gray,OS_GUI_COLOR," System information")
  879.                 end
  880.                 if x == 16 and y == 9 then
  881.                     desktop()
  882.                 end
  883.                 if x == 3 and y == 14 or x == 4 and y == 14 or x == 5 and y == 14 or x == 6 and y == 14 or x == 7 and y == 14 or x == 8 and y == 14 or x == 9 and y == 14 or x == 10 and y == 14 or x == 11 and y == 14 or x == 12 and y == 14 or x == 13 and y == 14 then
  884.                         os.shutdown()
  885.                 end
  886.                 if x == 3 and y == 16 or x == 4 and y == 16 or x == 5 and y == 16 or x == 6 and y == 16 or x == 7 and y == 16 or x == 8 and y == 16 or x == 9 and y == 16 or x == 10 and y == 16 or x == 11 and y == 16 or x == 12 and y == 16 or x == 13 and y == 16 then
  887.                     return OS_LOGIN_SCREEN()
  888.                 end
  889.                 if x == 3 and y == 18 or x == 4 and y == 18 or x == 5 and y == 18 or x == 6 and y == 18 or x == 7 and y == 18 or x == 8 and y == 18 or x == 9 and y == 18 or x == 10 and y == 18 or x == 11 and y == 18 or x == 12 and y == 18 or x == 13 and y == 18 then
  890.                         os.reboot()
  891.                 end
  892.                 if x == 3 and y == 9 or x == 4 and y == 9 or x == 5 and y == 9 or x == 6 and y == 9 or x == 7 and y == 9 or x == 8 and y == 9 or x == 9 and y == 9 or x == 10 and y == 9 or x == 11 and y == 9 or x == 12 and y == 9 or x == 13 and y == 9 then
  893.                     --shell.run("clear")
  894.                     edge.button(1,1,15,19,OS_STARTMENU_COLOR,OS_GUI_COLOR,"  Settings")
  895.                     edge.button(3,3,13,3,colors.gray,OS_GUI_COLOR,"Theme")
  896.                     edge.button(3,5,13,5,colors.gray,OS_GUI_COLOR,"Password")
  897.                     edge.button(3,7,13,7,colors.gray,OS_GUI_COLOR,"Username")
  898.                     edge.button(3,9,13,9,colors.gray,OS_GUI_COLOR,"Updates")
  899.                     --edge.button(3,9,13,9,colors.gray,OS_GUI_COLOR,"TestSetting2")
  900.                     edge.button(3,14,13,14,OS_STARTMENU_SHUTDOWNCOLOR,OS_GUI_COLOR,"Shut down")
  901.                     edge.button(3,16,13,16,OS_STARTMENU_LOGOUTCOLOR,OS_GUI_COLOR,"Log out")
  902.                     edge.button(3,18,13,18,OS_STARTMENU_REBOOTCOLOR,OS_GUI_COLOR,"Reboot")
  903.                     edge.xprint("<",16,9,OS_TEXT_COLOR)
  904.                     while(true) do
  905.                         local event, button, x, y = os.pullEvent("mouse_click")
  906.                         if x == 16 and y == 9 then
  907.                             desktop()
  908.                             birch.sysLog("User closed MenuItem1")
  909.                         end
  910.                         if x == 3 and y == 14 or x == 4 and y == 14 or x == 5 and y == 14 or x == 6 and y == 14 or x == 7 and y == 14 or x == 8 and y == 14 or x == 9 and y == 14 or x == 10 and y == 14 or x == 11 and y == 14 or x == 12 and y == 14 or x == 13 and y == 14 then
  911.                                 os.shutdown()
  912.                         end
  913.                         if x == 3 and y == 16 or x == 4 and y == 16 or x == 5 and y == 16 or x == 6 and y == 16 or x == 7 and y == 16 or x == 8 and y == 16 or x == 9 and y == 16 or x == 10 and y == 16 or x == 11 and y == 16 or x == 12 and y == 16 or x == 13 and y == 16 then
  914.                             return OS_LOGIN_SCREEN()
  915.                         end
  916.                         if x == 3 and y == 18 or x == 4 and y == 18 or x == 5 and y == 18 or x == 6 and y == 18 or x == 7 and y == 18 or x == 8 and y == 18 or x == 9 and y == 18 or x == 10 and y == 18 or x == 11 and y == 18 or x == 12 and y == 18 or x == 13 and y == 18 then
  917.                                 os.reboot()
  918.                         end
  919.  
  920.                         if x == 3 and y == 9 or x == 4 and y == 9 or x == 5 and y == 9 or x == 6 and y == 9 or x == 7 and y == 9 or x == 8 and y == 9 or x == 9 and y == 9 or x == 10 and y == 9 or x == 11 and y == 9 or x == 12 and y == 9 or x == 13 and y == 9 then
  921.                             edge.button(1,1,15,19,OS_STARTMENU_COLOR,OS_GUI_COLOR,"   Updates")
  922.                             edge.button(2,3,13,3,colors.lightGray,OS_GUI_COLOR,"Install:")
  923.                             edge.button(3,5,13,5,colors.gray,OS_GUI_COLOR,"Latest")
  924.                             edge.button(3,7,13,7,colors.gray,OS_GUI_COLOR,"Experimental")
  925.                             if settings.getVariable("system/settings","autoupdate") == "true" then
  926.                                 edge.button(2,8,5,8,OS_STARTMENU_COLOR,OS_GUI_COLOR,"Auto Updates")
  927.                                 edge.button(6,9,6,8,colors.lightGray,OS_GUI_COLOR," ON")
  928.                                 edge.button(3,9,5,9,colors.green,OS_GUI_COLOR,"")
  929.                                 edge.button(3,9,4,9,colors.gray,OS_GUI_COLOR,"")
  930.                             elseif settings.getVariable("system/settings","autoupdate") == "false" then
  931.                                 edge.button(2,8,5,8,OS_STARTMENU_COLOR,OS_GUI_COLOR,"Auto Updates")
  932.                                 edge.button(6,9,6,8,colors.lightGray,OS_GUI_COLOR," OFF")
  933.                                 edge.button(3,9,5,9,colors.gray,OS_GUI_COLOR,"")
  934.                                 edge.button(3,9,3,9,colors.red,OS_GUI_COLOR,"")
  935.                             end
  936.                             while(true) do
  937.                                 local event, button, x, y = os.pullEvent("mouse_click")
  938.  
  939.                                 if x == 16 and y == 9 then
  940.                                     desktop()
  941.                                 end
  942.                                 if x == 3 and y == 9 or x == 4 and y == 9 or x == 5 and y == 9 then
  943.                                     if settings.getVariable("system/settings","autoupdate") == true then
  944.                                         settings.setVariable("system/settings","autoupdate","false")
  945.                                         edge.button(2,8,5,8,OS_STARTMENU_COLOR,OS_GUI_COLOR,"Auto Updates")
  946.                                         edge.button(6,9,6,8,colors.lightGray,OS_GUI_COLOR," OFF")
  947.                                         edge.button(3,9,5,9,colors.gray,OS_GUI_COLOR,"")
  948.                                         edge.button(3,9,3,9,colors.red,OS_GUI_COLOR,"")
  949.                                         birch.sysLog("success.")
  950.                                     end
  951.                                     if settings.getVariable("system/settings","autoupdate") == false then
  952.                                         settings.setVariable("system/settings","autoupdate","true")
  953.                                         edge.button(2,8,5,8,OS_STARTMENU_COLOR,OS_GUI_COLOR,"Auto Updates")
  954.                                         edge.button(6,9,6,8,colors.lightGray,OS_GUI_COLOR," ON ")
  955.                                         edge.button(3,9,5,9,colors.green,OS_GUI_COLOR,"")
  956.                                         edge.button(3,9,4,9,colors.gray,OS_GUI_COLOR,"")
  957.                                     end
  958.                                 end
  959.                                 if x == 3 and y == 5 or x == 4 and y == 5 or x == 5 and y == 5 or x == 6 and y == 5 or x == 7 and y == 5 or x == 8 and y == 5 or x == 9 and y == 5 or x == 10 and y == 5 or x == 11 and y == 5 or x == 12 and y == 5 or x == 13 and y == 5 then
  960.                                     shell.run("pastebin run UgSYtY4H")
  961.                                 end
  962.                                 if x == 3 and y == 7 or x == 4 and y == 7 or x == 5 and y == 7 or x == 6 and y == 7 or x == 7 and y == 7 or x == 8 and y == 7 or x == 9 and y == 7 or x == 10 and y == 7 or x == 12 and y == 7 or x == 13 and y == 7 then
  963.                                     shell.run("pastebin run haULzXdY")
  964.                                 end
  965.                             end
  966.                         end
  967.                         if x == 3 and y == 5 or x == 4 and y == 5 or x == 5 and y == 5 or x == 6 and y == 5 or x == 7 and y == 5 or x == 8 and y == 5 or x == 9 and y == 5 or x == 10 and y == 5 or x == 11 and y == 5 or x == 12 and y == 5 or x == 13 and y == 5 then
  968.                             edge.button(3,5,13,5,colors.white,colors.white,"")
  969.                             term.setCursorPos(3,5)
  970.                             term.setTextColor(colors.black)
  971.                             newp = read("*")
  972.                             settings.setVariable("system/settings","loginkey",newp)
  973.                             desktop()
  974.                         end
  975.                         if x == 3 and y == 3 or x == 4 and y == 3 or x == 5 and y == 3 or x == 6 and y == 3 or x == 7 and y == 3 or x == 8 and y == 3 or x == 9 and y == 3 or x == 10 and y == 3 or x == 11 and y == 3 or x == 12 and y == 3 or x == 13 and y == 3 then
  976.                             edge.button(1,1,15,19,OS_STARTMENU_COLOR,OS_GUI_COLOR,"   Theme")
  977.                             edge.button(2,3,15,3,OS_STARTMENU_COLOR,OS_GUI_COLOR,"Pick a theme:")
  978.                             edge.button(3,5,13,5,colors.gray,OS_GUI_COLOR,"Dark")
  979.                             edge.button(3,7,13,7,colors.white,OS_GUI_COLOR,"Bright")
  980.                             edge.button(3,9,13,9,CTHEME,OS_GUI_COLOR,"Custom")
  981.                             if settings.getVariable("system/settings","theme") == "bright" then
  982.                                 edge.button(14,7,14,7,OS_STARTMENU_COLOR,OS_GUI_COLOR,"<")
  983.                             end
  984.                             if settings.getVariable("system/settings","theme") == "dark" then
  985.                                 edge.button(14,5,14,5,OS_STARTMENU_COLOR,OS_GUI_COLOR,"<")
  986.                             end
  987.                             if settings.getVariable("system/settings","theme") == "custom" then
  988.                                 edge.button(14,9,14,9,OS_STARTMENU_COLOR,OS_GUI_COLOR,"<")
  989.                             end
  990.                             --edge.button(3,11,13,11,colors.gray,OS_GUI_COLOR,"Edit Custom")
  991.                             while(true) do
  992.                                 local event, button, x, y = os.pullEvent("mouse_click")
  993.                                 if x == 16 and y == 9 then
  994.                                     desktop()
  995.                                 end
  996.  
  997.                                 if x == 3 and y == 9 or x == 4 and y == 9 or x == 5 and y == 9 or x == 6 and y == 9 or x == 7 and y == 9 or x == 8 and y == 9 or x == 9 and y == 9 or x == 10 and y == 9 or x == 11 and y == 9 or x == 12 and y == 9 or x == 13 and y == 9 then
  998.                                     settings.setVariable("system/settings","theme","custom")
  999.                                     edge.button(3,9,13,9,CTHEME,OS_GUI_COLOR,"Theme set!")
  1000.                                     end
  1001.                                 if x == 3 and y == 5 or x == 4 and y == 5 or x == 5 and y == 5 or x == 6 and y == 5 or x == 7 and y == 5 or x == 8 and y == 5 or x == 9 and y == 5 or x == 10 and y == 5 or x == 11 and y == 5 or x == 12 and y == 5 or x == 13 and y == 5 then
  1002.                                     settings.setVariable("system/settings","theme","dark")
  1003.                                     edge.button(3,5,13,5,colors.gray,OS_GUI_COLOR,"Theme set!")
  1004.                                 end
  1005.                                 if x == 3 and y == 7 or x == 4 and y == 7 or x == 5 and y == 7 or x == 6 and y == 7 or x == 7 and y == 7 or x == 8 and y == 7 or x == 9 and y == 7 or x == 10 and y == 7 or x == 11 and y == 7 or x == 12 and y == 7 or x == 13 and y == 7 then
  1006.                                     settings.setVariable("system/settings","theme","bright")
  1007.                                     edge.button(3,7,13,7,colors.white,OS_GUI_COLOR,"Theme set!")
  1008.                                 end
  1009.                                 if x == 3 and y == 11 or x == 4 and y == 11 or x == 5 and y == 11 or x == 6 and y == 11 or x == 7 and y == 11 or x == 8 and y == 11 or x == 9 and y == 11 or x == 10 and y == 11 or x == 11 and y == 11 or x == 12 and y == 7 or x == 13 and y == 11 then
  1010.                                     edge.button(15,1,52,19,colors.gray,OS_GUI_COLOR,"  Edit Theme")
  1011.                                     edge.xprint("WIP",20,5,colors.red)
  1012.                                     sleep(5)
  1013.                                     desktop()
  1014.                                 end
  1015.                             end
  1016.                             --term.setCursorPos(3,3)
  1017.                             --term.setTextColor(colors.black)
  1018.                             --thm = read()
  1019.                             --settings.setVariable("system/settings","theme",thm)
  1020.                             --desktop()
  1021.                         end
  1022.                         if x == 3 and y == 7 or x == 4 and y == 7 or x == 5 and y == 7 or x == 6 and y == 7 or x == 7 and y == 7 or x == 8 and y == 7 or x == 9 and y == 7 or x == 10 and y == 7 or x == 11 and y == 7 or x == 12 and y == 7 or x == 13 and y == 7 then
  1023.                             edge.button(3,7,13,7,colors.white,colors.white,"")
  1024.                             term.setCursorPos(3,7)
  1025.                             term.setTextColor(colors.black)
  1026.                             usr = read()
  1027.                             settings.setVariable("system/settings","username",usr)
  1028.                             desktop()
  1029.                         end
  1030.                     end
  1031.                 end
  1032.                 if x == 3 and y == 5 or x == 4 and y == 5 or x == 5 and y == 5 or x == 6 and y == 5 or x == 7 and y == 5 or x == 8 and y == 5 or x == 9 and y == 5 or x == 10 and y == 5 or x == 11 and y == 5 or x == 12 and y == 5 or x == 13 and y == 5 then
  1033.                     edge.button(3,5,13,5,colors.white,colors.white,"Side:")
  1034.                     term.setCursorPos(3+5,5)
  1035.                     term.setTextColor(colors.black)
  1036.                     side = io.read()
  1037.                     term.setTextColor(colors.white)
  1038.                     if peripheral.isPresent(side) == true then
  1039.                         shell.run("monitor "..side.." startup")
  1040.                     else
  1041.                         edge.button(3,5,13,5,colors.red,colors.white,"No monitor")
  1042.                     end
  1043.                 end
  1044.                 if x == 3 and y == 3 or x == 4 and y == 3 or x == 5 and y == 3 or x == 6 and y == 3 or x == 7 and y == 3 or x == 8 and y == 3 or x == 9 and y == 3 or x == 10 and y == 3 or x == 11 and y == 3 or x == 12 and y == 3 or x == 13 and y == 3 then
  1045.                     edge.button(3,3,13,3,colors.white,colors.white,"")
  1046.                     term.setCursorPos(3,3)
  1047.                     term.setTextColor(colors.black)
  1048.  
  1049.                     searhquery = io.read()
  1050.                     if searhquery == "home" then
  1051.                         term.setTextColor(colors.white)
  1052.                         return OS_DESKTOP()
  1053.                     elseif searhquery == "log out" then
  1054.                         return OS_LOGIN_SCREEN()
  1055.                     elseif searhquery == "info" then
  1056.                         return SYSTEM_INFO()
  1057.                     elseif searhquery == "shut down" then
  1058.                         birch.off()
  1059.                     elseif searhquery == "restart" then
  1060.                         birch.restart()
  1061.                     elseif searhquery == "delete" then
  1062.                         edge.button(3,3,13,3,colors.white,colors.white,"File:")
  1063.                         term.setCursorPos(8,3)
  1064.                         term.setTextColor(colors.black)
  1065.                         local dir = io.read()
  1066.                         edge.makeFile(dir)
  1067.                         shell.run("rm "..dir)
  1068.                     elseif searhquery == "cmd" then
  1069.                         desktop() -- 420 blaze it
  1070.                     elseif searhquery == "force oldUISys" then
  1071.                         birch.oldUI = true
  1072.                         return OS_DESKTOP()
  1073.                     elseif searhquery == "force noBoot" then
  1074.                         settings.setVariable("system/settings","disablebootan","true")
  1075.                     elseif searhquery == "force Boot" then
  1076.                         settings.setVariable("system/settings","disablebootan","false")
  1077.                     elseif searhquery == "create" then
  1078.                         edge.button(3,3,13,3,colors.white,colors.white,"Dir:")
  1079.                         term.setCursorPos(7,3)
  1080.                         term.setTextColor(colors.black)
  1081.                         local dir = io.read()
  1082.                         edge.makeFile(dir)
  1083.                         shell.run("edit "..dir)
  1084.                     elseif searhquery == "run" then
  1085.                         edge.button(3,3,13,3,colors.white,colors.white,"Dir:")
  1086.                         term.setCursorPos(7,3)
  1087.                         term.setTextColor(colors.black)
  1088.                         local dir = io.read()
  1089.                         shell.run(dir)
  1090.                     else
  1091.                     term.setTextColor(colors.white)
  1092.                     if searchquery == "update" or fs.exists(searhquery) then
  1093.                         shell.run("edit "..searhquery)
  1094.                         return desktop()
  1095.                         else
  1096.                         desktop()
  1097.                     end
  1098.                     --if x == 3 and y == 7
  1099.                     --end
  1100.                 end
  1101.             end
  1102.         end --????
  1103.         end
  1104.     end
  1105. end
  1106. function OS_LOGIN_SCREEN()
  1107.     if fs.exists("system/crashlog") then
  1108.         if settings.getVariable("system/crashlog","crash") == "true" then
  1109.             term.setTextColor(colors.white)
  1110.             edge.button(1,1,42,5,OS_STARTMENU_COLOR,OS_GUI_COLOR,"[x] SYSTEM CRASH REPORT")
  1111.             edge.button(5,2,42,5,OS_STARTMENU_COLOR,OS_GUI_COLOR,"BirchOS has recently crashed due to")
  1112.             edge.button(5,3,42,5,OS_STARTMENU_COLOR,OS_GUI_COLOR,"missing files or errors in the system.")
  1113.             edge.button(5,4,42,5,OS_STARTMENU_COLOR,OS_GUI_COLOR,"Reason: "..tostring(settings.getVariable("system/crashlog","crash_reason")))
  1114.             term.setTextColor(OS_TEXT_COLOR)
  1115.             while(true) do
  1116.                 local event, button, x, y = os.pullEvent("mouse_click")
  1117.                 if x == 2 and y == 1 then
  1118.                     settings.setVariable("system/crashlog","crash","false")
  1119.                     OS_LOGIN_SCREEN()
  1120.                 end
  1121.             end
  1122.         end
  1123.     end
  1124.     term.clear()
  1125.     birch.sysLog("Login screen loaded.")
  1126.     local time = os.time()
  1127.     if settings.getVariable("system/settings","timeformat") == "12" then
  1128.         formattedTime = textutils.formatTime(time, false)
  1129.     else
  1130.         formattedTime = textutils.formatTime(time, true)
  1131.     end
  1132.     local day = os.day()
  1133.     shell.run("clear")
  1134.     edge.button(1,1,1,1,OS_GUI_COLOR,OS_GUI_COLOR,"BirchOS")
  1135.   edge.button(term.getSize() / 2 - 10,5,term.getSize() / 2 + 12,10,OS_STARTMENU_COLOR,OS_GUI_COLOR,"")
  1136.     edge.button(term.getSize() /2 + 10,5,term.getSize() / 2 + 12,5,OS_STARTMENU_COLOR,OS_GUI_COLOR,"[x]")
  1137.     edge.button(term.getSize() / 2 - 8,6,term.getSize() / 2 + 12,6,OS_STARTMENU_COLOR,OS_GUI_COLOR,"Username")
  1138.     edge.button(term.getSize() / 2 - 8,7,term.getSize() / 2 + 2,7,colors.white,OS_GUI_COLOR,"")
  1139.     edge.button(term.getSize() / 2 - 8,8,term.getSize() / 2 + 12,8,OS_STARTMENU_COLOR,OS_GUI_COLOR,"Password")
  1140.     edge.button(term.getSize() / 2 - 8,9,term.getSize() / 2 + 2,9,colors.white,OS_GUI_COLOR,"")
  1141.     edge.xtime(term.getSize() / 2 - 3,1)
  1142.     --print("")
  1143.     --term.setTextColor(OS_TEXT_COLOR)
  1144.     --birch.printcenter(formattedTime..", Day: "..day,19)
  1145.     --birch.printcenter("Login",8)
  1146.     --term.setCursorPos(21,9)
  1147.     --print("[>] "..settings.getVariable("system/settings","username").."")
  1148.     while(1) do
  1149.         local event, button, x, y = os.pullEvent("mouse_click")
  1150.         --birch.aP(x.."+"..y,colors.red)
  1151.         if x == 36 and y == 5 then
  1152.             shell.run("clear")
  1153.             edge.button(1,1,1,1,OS_GUI_COLOR,OS_GUI_COLOR,"BirchOS")
  1154.             edge.xtime(term.getSize() / 2 - 3,1)
  1155.             local tx, ty = term.getSize()
  1156.             edge.button(tx / 2 - 6,ty /2,tx / 2 + 12,ty / 2,OS_GUI_COLOR,OS_GUI_COLOR,"Shutting down.")
  1157.             sleep(2)
  1158.             os.shutdown()
  1159.         end
  1160.         if x == 14 and y == 7 or x == 18 and y == 7 or x == 19 and y == 7 or x == 20 and y == 7 or x == 21 and y == 7 or x == 22 and y == 7 or x == 23 and y == 7 or x == 24 and y == 7 or x == 25 and y == 7 or x == 26 and y == 7 or x == 27 and y == 7 then
  1161.             edge.button(term.getSize() / 2 - 8,7,term.getSize() / 2 + 2,7,colors.white,OS_GUI_COLOR,"")
  1162.             term.setCursorPos(term.getSize() / 2 - 8,7)
  1163.             term.setTextColor(colors.black)
  1164.  
  1165.             username = io.read()
  1166.             if username == "root_nocredentials" then
  1167.                 edge.button(term.getSize() / 2 - 8,8,term.getSize() / 2 + 12,8,OS_STARTMENU_COLOR,OS_GUI_COLOR,"Password")
  1168.                 edge.button(term.getSize() / 2 - 8,9,term.getSize() / 2 + 2,9,colors.white,OS_GUI_COLOR,"")
  1169.                 term.setCursorPos(term.getSize() / 2 -8 ,9)
  1170.                 term.setTextColor(colors.black)
  1171.                 p = read("*")
  1172.                 if p == "root_sysLoginAdm" then
  1173.                     desktop()
  1174.                 else
  1175.                     edge.button(term.getSize() / 2 - 8,9,term.getSize() / 2 + 2,9,colors.red,OS_GUI_COLOR,"")
  1176.                 end
  1177.             end
  1178.             if username == settings.getVariable("system/settings","username") then
  1179.                 if settings.getVariable("system/settings","loginkey") == "nil" then
  1180.                     desktop()
  1181.                 end
  1182.                 edge.button(term.getSize() / 2 - 8,8,term.getSize() / 2 + 12,8,OS_STARTMENU_COLOR,OS_GUI_COLOR,"Password")
  1183.                 edge.button(term.getSize() / 2 - 8,9,term.getSize() / 2 + 2,9,colors.white,OS_GUI_COLOR,"")
  1184.                 term.setCursorPos(term.getSize() / 2 -8 ,9)
  1185.                 term.setTextColor(colors.black)
  1186.                 p = read("*")
  1187.                 if p == settings.getVariable("system/settings","loginkey") then
  1188.                     desktop()
  1189.                 else
  1190.                     edge.button(term.getSize() / 2 - 8,9,term.getSize() / 2 + 2,9,colors.red,OS_GUI_COLOR,"")
  1191.                 end
  1192.             else
  1193.                 edge.button(term.getSize() / 2 - 8,7,term.getSize() / 2 + 2,7,colors.red,OS_GUI_COLOR,"")
  1194.             end
  1195.         end
  1196.     end
  1197. end
  1198. function virtualos()
  1199.     edge.button(1,1,15,19,OS_STARTMENU_COLOR,OS_GUI_COLOR," VirtualOS")
  1200.     edge.button(3,5,13,5,colors.gray,OS_GUI_COLOR,"Boot")
  1201.     while(true) do
  1202.         local event, button, x, y = os.pullEvent("mouse_click")
  1203.         if x >= 3 and x <= 13 and y == 5 then
  1204.             if fs.exists("system/api/source_api_programs/virtualos.lua") then
  1205.                 shell.run("system/api/source_api_programs/virtualos.lua")
  1206.             else
  1207.                 edge.button(term.getSize() / 2 - 10,5,term.getSize() / 2 + 12,10,colors.cyan,OS_GUI_COLOR," Uh oh!")
  1208.                 edge.button(term.getSize() /2 -8,7,term.getSize() / 2 + 1, 7,colors.cyan,OS_GUI_COLOR,"BirchOS was unable")
  1209.                 edge.button(term.getSize() /2 -8,8,term.getSize() / 2 +1 , 8, colors.cyan,OS_GUI_COLOR,"to load VirtualOS")
  1210.                 edge.button(term.getSize() /2 -8,9,term.getSize() / 2 +1 , 9, colors.cyan,OS_GUI_COLOR,"ERR:0x1 NO LIB")
  1211.                 edge.button(term.getSize() /2 - 1, 10, term.getSize() / 2 + 0, 10, colors.gray,OS_GUI_COLOR,"OK.")
  1212.                 birch.sysLog("MissingLibraryException: VirtualOS libraries not found")
  1213.                 while(true) do
  1214.                     local event, button, x, y = os.pullEvent("mouse_click")
  1215.                     if x >= term.getSize() / 2 - 1 and x <= term.getSize() / 2 + 0 and y == 10 then
  1216.                         desktop()
  1217.                     end
  1218.                 end
  1219.             end
  1220.         end
  1221.     end
  1222. end
  1223. function commandline()
  1224.     print("not yet implemented ya lil shit yo")
  1225. end
  1226. edge.button(1,10,51,15,OS_STARTMENU_COLOR,OS_GUI_COLOR,"[x]")
  1227. edge.button(25,11,25,11,OS_STARTMENU_COLOR,OS_GUI_COLOR,"Upgrade BirchOS now!")
  1228. edge.button(1,12,1,12,OS_STARTMENU_COLOR,OS_GUI_COLOR,"The same familiar interface, faster and packed with features!")
  1229. edge.button(term.getSize() /2 - 4, 15, term.getSize() / 2 + 0, 15, colors.gray,OS_GUI_COLOR,"UPGRADE")
  1230. local event, button, x, y = os.pullEvent("mouse_click")
  1231. if y == 10 then
  1232.     OS_LOGIN_SCREEN()
  1233. end
  1234. if y == 15 then
  1235.     shell.run("pastebin run eMqb3wXt")
  1236. end
  1237. OS_LOGIN_SCREEN()
  1238.  
  1239. ]]
  1240. BIRCHOS_EDGE = [[
  1241. version = "2.0"
  1242. -- Do not store OS version in an API. Never again.
  1243. -- EDGE API MADE BY NOTHY
  1244.  
  1245. function makeFile(dir,data)
  1246.   local f = fs.open(dir,"w")
  1247.   f.writeLine(data)
  1248.   f.close()
  1249. end
  1250.  
  1251. function killFile(dir) end
  1252.  
  1253. function makeDir(dir) end
  1254.  
  1255. function cprint(str,y)
  1256.   local x = term.getSize()
  1257.   local centerXPos = ( x - string.len(str) ) / 2
  1258.   term.setCursorPos( centerXPos, y )
  1259.   write( str )
  1260. end
  1261.  
  1262. function aprint(string , color)
  1263.     term.setTextColor(color)
  1264.     print(string)
  1265.     term.setTextColor(colors.white)
  1266. end
  1267. function shutdown(timer)
  1268.     sleep(timer)
  1269.     os.shutdown()
  1270. end
  1271.  
  1272. function reboot(timer)
  1273.     sleep(timer)
  1274.     os.reboot()
  1275. end
  1276. function setbgColor(color)
  1277.     term.setBackgroundColor(color)
  1278. end
  1279. function textColor(color)
  1280.     term.setTextColor(color)
  1281. end
  1282. function button(x,y,sx,sy,color,defaultcolor,name)
  1283.     paintutils.drawFilledBox(x,y,sx,sy,color)
  1284.     xprint(name,x,y,colors.black)
  1285.     setbgColor(defaultcolor)
  1286. end
  1287. function xprint(str,x,y,color)
  1288.     term.setCursorPos(x,y)
  1289.     aprint(str,color)
  1290.     term.setCursorPos(1,1)
  1291. end
  1292. function xtime(x,y)
  1293.     local systime = os.time()
  1294.     if settings.getVariable("system/settings","timeformat") == "12" then
  1295.         formattedTime = textutils.formatTime(systime, false)
  1296.     else
  1297.         formattedTime = textutils.formatTime(systime, true)
  1298.     end
  1299.     xprint(formattedTime,x,y,colors.black)
  1300. end
  1301. --1337!
  1302. ]]
  1303. BIRCHOS_BIRCHAPI = [[
  1304. --systemcheckMissing()
  1305.     osversion = "REL 1.1"
  1306.     osstate = ""
  1307.     apiversion = "BIRCH2A5"
  1308.     dis = false
  1309.     release = true
  1310.     oldUI = false
  1311. function init()
  1312.     if not dis == true then
  1313.         print("BirchOS SYSTEM API initialized!")
  1314.     end
  1315. end
  1316. function disableinitmessage()
  1317.     dis = true
  1318. end
  1319. function off()
  1320.     tclear()
  1321.     printcenter(osversion,1)
  1322.     printcenter("Shutting down",5)
  1323.     sleep(1)
  1324.     os.shutdown()
  1325. end
  1326. function restart()
  1327.     tclear()
  1328.     printcenter(osversion,1)
  1329.     printcenter("Restarting",5)
  1330.     sleep(1)
  1331.     os.reboot()
  1332. end
  1333. function systemcheck()
  1334.     --print("feature removed.")
  1335.     if not fs.exists("system") then
  1336.         osstate = "SYSTEM FILES MISSING"
  1337.     end
  1338.     if not fs.exists("system/api") then
  1339.         osstate = "API MISSING"
  1340.     end
  1341.     if not fs.exists("startup") then
  1342.         osstate = "STARTUP SCRIPT MISSING"
  1343.     end
  1344.     if settings.getVariable("system/crashlog","crash") == true then
  1345.         osstate = settings.getVariable("system/crashlog","crashreason")
  1346.     end
  1347. end
  1348.  
  1349.  
  1350.  
  1351. function tclear()
  1352.     term.clear()
  1353.     term.setCursorPos(1,1)
  1354. end
  1355.  
  1356. function crash(reason)
  1357.     term.clear()
  1358.     term.setCursorPos(1,1)
  1359.     term.setBackgroundColor(colors.blue)
  1360.     term.setTextColor(colors.white)
  1361.     term.clear()
  1362.     print("Uh oh!")
  1363.     print("Something went wrong, Please contact BirchOS Devs about this!")
  1364.     print("Useful information:")
  1365.     print("Crash reason:")
  1366.     print(reason)
  1367.     print("")
  1368.     print("A log file has been placed in:")
  1369.     print("system/log.txt")
  1370.     sysLog("!!!! CRASH !!!!")
  1371.     sysLog("CRASH INFORMATION:")
  1372.     sysLog(tostring(reason))
  1373.     sysLog(tostring(osversion))
  1374.     sysLog(tostring(apiversion)) -- 1337 (2015-12-21)
  1375.     sysLog("Username: "..settings.getVariable("system/settings","username"))
  1376.     --syslog("Release: "..tostring(release))
  1377.     --syslog("oldUI: "..tostring(oldUI))
  1378.     sleep(10)
  1379.     --fs.makeDir("system/crashlog")
  1380.     settings.setVariable("system/crashlog","crash","true")
  1381.     settings.setVariable("system/crashlog","crash_reason",tostring(reason))
  1382.     os.shutdown()
  1383. end
  1384. function systemcheckMissing()
  1385.     if not fs.exists("system") then
  1386.         local sysm = true
  1387.     end
  1388.     if not fs.exists("api") then
  1389.         local apim = true
  1390.     end
  1391.     if not fs.exists("startup") then
  1392.         local startupm = true
  1393.     end
  1394.     os.reboot()
  1395. end
  1396. function printcenter( text, y )
  1397.   local x = term.getSize()
  1398.   local centerXPos = ( x - string.len(text) ) / 2
  1399.   term.setCursorPos( centerXPos, y )
  1400.   write( text )
  1401. end
  1402.  
  1403. function aP(str , c)
  1404.     term.setTextColor(tonumber(c))
  1405.     print(str)
  1406.     term.setTextColor(colors.white)
  1407. end
  1408. --function advancedPrintCenter(string , color, y)
  1409. --  local x = term.getSize()
  1410. --      local centerXPos = ( x - string.len(text) ) / 2
  1411. --      term.setCursorPos( centerXPos, y )
  1412. --  term.setTextColor(colors.""..color)
  1413. --  print(string)
  1414. --  term.setTextColor(colors.white)
  1415. --end
  1416. function birchOS2()
  1417.     print("Placeholder function for BirchOS2.")
  1418. end
  1419. function update() -- Downloads updates.
  1420.     --shell.run("pastebin run UgSYtY4H")
  1421. end
  1422. function createFile(dir,data)
  1423.     local file = fs.open(dir,"w")
  1424.     file.write(data)
  1425.     file.close()
  1426.     print("File created at: "..dir)
  1427. end
  1428. function sysLog(string)
  1429. --Logs system activity, highly useful for debugging.
  1430. local time = os.time()
  1431. if not fs.exists("system/log.txt") then
  1432.     logfile = fs.open("system/log.txt","w")
  1433.     logfile.close()
  1434. end
  1435. logfile = fs.open("system/log.txt","a")
  1436. logfile.writeLine("["..time.."]: "..string.."\n")
  1437. logfile.close()
  1438. end
  1439.  
  1440. ]]
  1441. BIRCHOS_SETTINGS_API = [[
  1442. local function getLines(filename)
  1443.     if not fs.exists(filename) then return end
  1444.  
  1445.     local t = {}
  1446.     for line in io.lines(filename) do
  1447.         table.insert(t, line)
  1448.     end
  1449.  
  1450.     return t
  1451. end
  1452. local function writeSettings(filename, settingsTable)
  1453.     if not fs.exists(filename) then return false end
  1454.  
  1455.     file = fs.open(filename, "w")
  1456.     for _,item in ipairs(settingsTable) do
  1457.         if item == settingsTable[table.getn(settingsTable)] then --om sista entry
  1458.             file.write(item)
  1459.         else
  1460.             file.writeLine(item)
  1461.         end
  1462.     end
  1463.     file.close()
  1464.  
  1465.     return true
  1466. end
  1467.  
  1468. function getVariable(filename, variableName)
  1469.     if not fs.exists(filename) then return false end
  1470.  
  1471.     local lns = getLines(filename)
  1472.     for _,item in ipairs(lns) do
  1473.         local var, val = string.match(item, "(.+)%s*=%s*(.+)")
  1474.         if var == variableName then
  1475.             return val
  1476.         end
  1477.     end
  1478.  
  1479.     return false
  1480. end
  1481.  
  1482. function setVariable(filename, variableName, value)
  1483.     local file
  1484.     if not fs.exists(filename) then
  1485.         file = fs.open(filename, "w")
  1486.         file.write(variableName.."="..value)
  1487.         file.close()
  1488.         return true
  1489.     end
  1490.  
  1491.     local alreadyExists = false
  1492.     local lns = getLines(filename)
  1493.     local x = 1
  1494.     for _,item in ipairs(lns) do
  1495.         local var, val = string.match(item, "(.+)%s*=%s*(.+)")
  1496.         if var == variableName then
  1497.             --print("already exists, replacing")
  1498.             lns[x] = var.."="..value
  1499.             alreadyExists = true
  1500.         end
  1501.         x = x + 1
  1502.     end
  1503.  
  1504.     if alreadyExists == false then
  1505.         table.insert(lns, variableName.."="..value)
  1506.     end
  1507.  
  1508.     writeSettings(filename,lns)
  1509.     return true
  1510. end
  1511.  
  1512. function removeVariable(filename, variableName)
  1513.     if not fs.exists(filename) then return false end
  1514.  
  1515.     local lns = getLines(filename)
  1516.     local x = 1
  1517.     for _,item in ipairs(lns) do
  1518.         local var, val = string.match(item, "(%w+)%s*=%s*(%w+)")
  1519.         if var == variableName then
  1520.             table.remove(lns, x)
  1521.         end
  1522.         x = x + 1
  1523.     end
  1524.  
  1525.     writeSettings(filename,lns)
  1526.     return true
  1527. end
  1528. ]]
  1529. BIRCHOS_NETWORK_API = [[
  1530.  
  1531. apiversion = "1.0"
  1532. mmsg = false
  1533. msg = ""
  1534. idd = 0
  1535. dis = false
  1536. function init()
  1537.     if not dis == true then
  1538.     print("BirchOS Network API initialized!")
  1539.     end
  1540. end
  1541. function disableinitmessage()
  1542.     dis = true
  1543. end
  1544. function connect()
  1545.     rednet.open("right")
  1546. end
  1547.  
  1548. function disconnect()
  1549.     rednet.close()
  1550. end
  1551.  
  1552. function send(i,m)
  1553.         rednet.send(i,m)
  1554. end
  1555.  
  1556. function rec()
  1557.         id, message = rednet.receive()
  1558.         if rednet.receive() then
  1559.             mssg = true
  1560.         end
  1561.         print("[IM]("..id.."): "..message)
  1562. end
  1563.  
  1564. function block(blocked_id)
  1565.     while(true) do
  1566.         id, message = rednet.receive()
  1567.         if blocked_id == id then
  1568.             print("Message from '"..blocked_id.."' was blocked.",1)
  1569.         end
  1570.     end
  1571. end
  1572. function networkGUI()
  1573.     while(true) do
  1574.         local event = os.pullEvent()
  1575.  
  1576.         birch.tclear()
  1577.         print("Connected.")
  1578.         if event == "rednet_receive" then
  1579.             id, message = rednet.receive()
  1580.             print("[IM]("..id.."): "..message)
  1581.         end
  1582.         print("Enter message:")
  1583.         msg = io.read()
  1584.         print("To ID:")
  1585.         idd = io.read()
  1586.         send(id,msg)
  1587.         mssg = false
  1588.     end
  1589. end
  1590. ]]
  1591. BIRCHOS_OPERATION_API = [[
  1592.  
  1593. apiversion = "1.0"
  1594. function init()
  1595.     if not dis == true then
  1596.     print("Background Operation API Initialized!")
  1597.     end
  1598. end
  1599. function disableinitmessage()
  1600.     dis = true
  1601. end
  1602. function performance_Test(num) -- performance test
  1603.     while(1) do
  1604.     num = num + 1
  1605.     print(num)
  1606.     --settings.setVariable("system/settings","count",num)
  1607.     if num >= 10000 then
  1608.         print("Performance test successful.")
  1609.         print("AUTOMATIC REBOOT IN 10 SECONDS")
  1610.         sleep(10)
  1611.         os.reboot()
  1612.         break
  1613.     end
  1614.     end
  1615. end
  1616. function createBackGroundOperation(operation_name,operation_task,operation_Executable)
  1617.  
  1618.  
  1619. end
  1620. function advancedTermination(task_name,task_Executable)
  1621.  
  1622.  
  1623.  
  1624. end
  1625. function forceReboot()
  1626.     term.clear()
  1627.     os.reboot()
  1628. end
  1629.  
  1630. ]]
  1631. BIRCHOS_SC_API =[[
  1632.  
  1633. dis = false
  1634. function init()
  1635.     if not dis == true then
  1636.     print("BirchOS Source API [BETA] initialized!")
  1637.     end
  1638. end
  1639. function disableinitmessage()
  1640.     dis = true
  1641. end
  1642. function gameload(saveDir,gameProperties,bool)
  1643.  
  1644.  
  1645. end
  1646.  
  1647.  
  1648. function gameinitialize()
  1649.     -- This is literally used for initializing games. Literally nothing else. Game engine coming soon instead of this massive pile of shit.
  1650.  
  1651.  
  1652. end
  1653.  
  1654. function toolkit()
  1655.  
  1656.  
  1657.  
  1658. end
  1659.  
  1660. function advanced_toolkit()
  1661.  
  1662.  
  1663.  
  1664. end
  1665.  
  1666. function toolkit_crash()
  1667.  
  1668.  
  1669. term.setBackgroundColor(colors.white)
  1670. term.setTextColor(colors.black)
  1671. term.clear()
  1672. print("SOURCEAPI TOOLKIT HAS CRASHED")
  1673. print("REBOOTING IN 10 SECONDS")
  1674. sleep(1)
  1675. birch.crash("TOOLKIT CRASH")
  1676. --os.reboot()
  1677. end
  1678.  
  1679. function color(c)
  1680.     term.setTextColor(c)
  1681. end
  1682. ]]
  1683. BIRCHOS_BOOTLOADER = [[
  1684. term.setTextColor(colors.black)
  1685. function Loop()
  1686.  
  1687.     birch.tclear()
  1688.     --settings.setVariable("system/settings","unlock","true")
  1689.     print("BirchOS Bootloader (POWERED BY VICK'S SETTINGS API)")
  1690.     print("[NOTE: OS REBOOTS AFTER CHANGE]")
  1691.     print("[V] Environment variables")
  1692.     while true do
  1693.         local event, button, x, y = os.pullEvent("mouse_click")
  1694.         local term = os.pullEventRaw()
  1695.         if term == "terminate" then
  1696.             shell.run("system/os.lua")
  1697.         end
  1698.         if x == 2 and y == 3 and button == 1 then
  1699.             if not page == true then
  1700.             page = true
  1701.             print("birchos.system.settings.modified."..settings.getVariable("system/settings","test"))
  1702.             --print()
  1703.             print("birchos.system.settings.isvalid."..settings.getVariable("system/settings","isvalid"))
  1704.             --print()
  1705.             print("birchos.system.settings.disablebootan."..settings.getVariable("system/settings","disablebootan"))
  1706.             print("birchos.system.settings.test."..settings.getVariable("system/settings","test"))
  1707.             print("birchos.unlock."..settings.getVariable("system/settings","unlock"))
  1708.             print("[X] [NYI] | [X] EDIT")
  1709.             elseif not page == false then
  1710.                 page = false
  1711.                 Loop()
  1712.             end
  1713.         end
  1714.         if x == 14 and y == 9 and button == 1 and page == true then
  1715.             print("ENTER VARIABLE NAME")
  1716.             varName = io.read()
  1717.             print("VALUE:")
  1718.             varVal = io.read()
  1719.             settings.setVariable("system/settings",varName,varVal)
  1720.             os.reboot()
  1721.         end
  1722.         --if x == 2 and y == 9 and button == 1 and page == true then
  1723.         --  print("ENTER VARIABLE TO EDIT (only type the last part of the var (not true/false part))")
  1724.         --  ed = io.read()
  1725.         --  if ed == string.lower("modified") then
  1726.         --      print("True or false?")
  1727.         --      ed = io.read()
  1728.         --      if ed == string.lower("true") then
  1729.         --          settings.setVariable("system/settings","test","true")
  1730.         --          os.reboot()
  1731.         --      elseif ed == string.lower("false") then
  1732.         --          settings.setVariable("system/settings","test","false")
  1733.         --          os.reboot()
  1734.         --      end
  1735.         --  elseif ed == string.lower("disablebootan") then
  1736.         --      print("True or false?")
  1737.         --      ed = io.read()
  1738.         --      if ed == string.lower("true") then
  1739.         --          settings.setVariable("system/settings","disablebootan","true")
  1740.         --          os.reboot()
  1741.         --      elseif ed == string.lower("false") then
  1742.         --          settings.setVariable("system/settings","disablebootan","false")
  1743.         --          os.reboot()
  1744.         --      end
  1745.         --  end
  1746.         --end
  1747.     end
  1748. end
  1749. Loop()
  1750.  
  1751. ]]
  1752. BIRCHOS_STARTUP = [[
  1753. local BOOTLOADER_TAG = "[BOOT]"
  1754. local edge_boot_dir = "sys16/edge/"
  1755. os.pullEvent = os.pullEventRaw
  1756. --shell.run("pastebin run eMqb3wXt")
  1757. function boot_de_faking_os(file_name)
  1758.     --print("Birch OS is loading files..")
  1759.     if fs.exists(file_name) then
  1760.         os.loadAPI("system/api/settings")
  1761.         --sleep(0.1)
  1762.         os.loadAPI("system/api/birch")
  1763.         --birch.init()
  1764.         --sleep(0.1)
  1765.         --os.loadAPI("beta/birchtwo")
  1766.         --sleep(0.1)
  1767.         --os.loadAPI("system/api/sc")
  1768.         --sc.init()
  1769.         --sleep(0.1)
  1770.         --os.loadAPI("system/api/network")
  1771.         --network.init()
  1772.         --sleep(0.1)
  1773.         --os.loadAPI("system/api/operation")
  1774.         --operation.init()
  1775.         --sleep(0.1)
  1776.         --os.loadAPI("beta/systemdiag")
  1777.         --sleep(0.1)
  1778.         --print(BOOTLOADER_TAG..": SYSTEM INITIALIZED")
  1779.         shell.run(file_name)
  1780.     else
  1781.         os.loadAPI("system/api/settings")
  1782.         os.loadAPI("system/api/birch")
  1783.         os.loadAPI("beta/birchtwo")
  1784.         os.loadAPI("system/api/sc")
  1785.         os.loadAPI("system/api/network")
  1786.         os.loadAPI("system/api/operation")
  1787.         os.loadAPI("beta/systemdiag")
  1788.         birch.crash(BOOTLOADER_TAG..": FILE NOT FOUND")
  1789.     end
  1790. end
  1791. shell.run("clear")
  1792. boot_de_faking_os("system/api/source_api_programs/settingsChecker")
  1793.  
  1794. ]]
  1795. BIRCHOS_CHAT = [[
  1796. function printCenter(text)
  1797. term.setCursorPos(sizeX/2-#text/2,1)
  1798. print(text)
  1799. end
  1800.  
  1801. function fill(color)
  1802. for line=1,sizeY do
  1803. paintutils.drawLine(1,line,sizeX,line,colors[color])
  1804. end
  1805. end
  1806.  
  1807. function updateChatHud()
  1808. term.clear()
  1809. fill("black")
  1810.  
  1811.  
  1812. paintutils.drawPixel(sizeX,1,colors.red)
  1813. term.setCursorPos(sizeX,1)
  1814. io.write("X")
  1815.  
  1816. paintutils.drawPixel(sizeX-1,1,colors.blue)
  1817. term.setCursorPos(sizeX-1,1)
  1818. io.write("U")
  1819.  
  1820. paintutils.drawLine(1,sizeY,sizeX,sizeY,colors[user.color])
  1821. paintutils.drawLine(sizeX/2-(11+#user.room)/2-1,1,sizeX/2-(11+#user.room)/2+11+#user.room,1,colors[user.color])
  1822.  
  1823. printCenter("Chatroom : "..user.room)
  1824. term.setCursorPos(1,2)
  1825. io.write("Color : "..user.color.." ")
  1826.  
  1827. for i=1,sizeY-3 do
  1828. local disp = chats[#chats-(i-3)]
  1829. if disp ~= nil then
  1830. term.setCursorPos(1,sizeY-i)
  1831. io.write(disp)
  1832. end
  1833. end
  1834.  
  1835. term.setCursorPos(1,sizeY)
  1836. io.write("\\\\>")
  1837. end
  1838.  
  1839. function send(userName,room,input)
  1840. local package = userName..";"..room..";"..input
  1841. --chats[#chats+1] = (userName ~= "Cont." and (user.userName.." : ") or "")..input
  1842. print(package)
  1843. rednet.broadcast(package)
  1844. updateChatHud()
  1845. end
  1846.  
  1847. user = {
  1848. color = "black",
  1849. room = "Default",
  1850. }
  1851.  
  1852. sizeX,sizeY = term.getSize()
  1853. chats = {}
  1854. version = "v1.0"
  1855.  
  1856. for _,side in pairs({"left","right","top","bottom","front","back"}) do
  1857. if peripheral.getType(side) == "modem" then
  1858. rednet.open(side)
  1859. break
  1860. end
  1861. end
  1862. if not term.isColor() then
  1863. for i,v in pairs(paintutils) do
  1864. paintutils[i] = function() return 0 end
  1865. end
  1866. end
  1867.  
  1868. term.clear()
  1869. printCenter("CCChat "..version.." by TeamDman")
  1870. io.write("Enter your username : ")
  1871. user.userName = io.read()
  1872.  
  1873. term.clear()
  1874. updateChatHud()
  1875.  
  1876. while true do
  1877. local event,arg1,arg2,arg3 = os.pullEvent()
  1878. if event == "rednet_message" then
  1879. local name,room,message = arg2:match("(.*);(.*);(.*)")
  1880. if name == "Cont." and room == user.room then
  1881. chats[#chats+1] = message
  1882. elseif room == user.room then
  1883. chats[#chats+1] = name.." : "..message
  1884. end
  1885. updateChatHud()
  1886. elseif event == "mouse_click" or event == "key" then
  1887. if (event == "mouse_click" and arg3 == sizeY) or (event == "key" and keys.getName(arg1) == "t") then
  1888. sleep(0.1)
  1889. term.setCursorPos(4,sizeY)
  1890. local input = io.read()
  1891. if #input+#user.userName+3 > sizeX then
  1892. send(user.userName,user.room,input:sub(1,sizeX-(#user.userName+3)))
  1893. input = input:sub(sizeX-(#input+#user.userName+3)+1)
  1894. repeat
  1895. send("Cont.",user.room,input:sub(1,sizeX))
  1896. input = input:sub(sizeX+1)
  1897. until #input == 0
  1898. else
  1899. send(user.userName,user.room,input)
  1900. end
  1901. elseif event == "mouse_click" and (arg3 == 2 or arg3 == 1) then
  1902. if arg3 == 1 then
  1903. if arg2 == sizeX then -- Close
  1904. shell.run("system/os.lua")
  1905. break
  1906. elseif arg2 == sizeX-1 then -- Update
  1907. --fs.delete("chat")
  1908. --shell.run("pastebin","get","H0YpZjhK","/chat")
  1909. shell.run("startup")
  1910. break
  1911. else
  1912. term.setCursorPos(sizeX/2-(11+#user.room)/2,1)
  1913. term.clearLine()
  1914. io.write("Chatroom : ")
  1915. user.room = io.read()
  1916. end
  1917. else
  1918. term.setCursorPos(1,2)
  1919. term.clearLine()
  1920. io.write("Color : ")
  1921. user.color = io.read()
  1922. end
  1923. updateChatHud()
  1924. end
  1925. end
  1926. end
  1927. ]]
  1928. BIRCHOS_SETTINGS_FILE = [[
  1929. test=false
  1930. isvalid=false
  1931. disablebootan=false
  1932. unlock=false
  1933. performanceMode=false
  1934. username=nil
  1935. debug=false
  1936. loginkey=nil
  1937. bootcode=01000001
  1938. theme=bright
  1939. timeformat=24
  1940. edgebeta=false
  1941. customprogram=nil
  1942. -- PACKAGED SETTINGS.
  1943. autoupdate=false
  1944. pdate=false
  1945.  
  1946. ]]
  1947. BIRCHOS_SETTINGS_CHECKER = [[
  1948.  
  1949. if fs.exists("system/settings") then
  1950.     shell.run("system/os.lua")
  1951. else
  1952.     settings.setVariable("system/settings","test","true")
  1953.     settings.setVariable("system/settings","isvalid","true")
  1954.     settings.setVariable("system/settings","disablebootan","false")
  1955.     settings.setVariable("system/settings","unlock","true")
  1956.     settings.setVariable("system/settings","performanceMode","false")
  1957.     --mod = settings.getVariable("system/settings","test")
  1958.     --valid = settings.getVariable("system/settings","isvalid")
  1959.     shell.run("system/os.lua")
  1960. end
  1961. ]]
  1962. BIRCHOS_THEME = [[
  1963. OS_DEFAULTBACKGROUNDCOLOR=8
  1964. OS_DEFAULTTEXTCOLOR=128
  1965. OS_STARTMENU_SHUTDOWNCOLOR=16384
  1966. OS_STARTMENU_LOGOUTCOLOR=32
  1967. OS_STARTMENU_REBOOTCOLOR=16
  1968. OS_STARTMENU_COLOR=512
  1969. OS_STARTMENU_BG=2048
  1970. OS_LOGINSCREEN_WELCOMECOLOR=2
  1971. OS_CMD_BGCOLOR=1
  1972. ]]
  1973. BIRCHOS_SYSTEMDIAG = [[
  1974. local os_ = nil
  1975. local api = nil
  1976. local system = nil
  1977. local apiprog = nil
  1978. local function launchdiag(s,sa,a)
  1979.     sleep(0.5)
  1980.     if s == "-s" then
  1981.         if fs.exists("system") then
  1982.             sleep(0.5)
  1983.             system = true
  1984.             else
  1985.             system = false
  1986.         end
  1987.     end
  1988.     if sa == "-sa" then
  1989.         if fs.exists("system/api/source_api_programs/bootloader") and fs.exists("system/api/source_api_programs/settingsChecker") and fs.exists("system/api/source_api_programs/virtualos.lua") then
  1990.             apiprog = true
  1991.             else
  1992.             apiprog = false
  1993.         end
  1994.     end
  1995.         if fs.exists("system/os.lua") then
  1996.             sleep(0.5)
  1997.             os_ = true
  1998.             else
  1999.             os_ = false
  2000.         end
  2001.         if fs.exists("system/api") then
  2002.         sleep(0.5)
  2003.             if fs.exists("system/api/birch") and fs.exists("system/api/network") and fs.exists("system/api/operation") and fs.exists("system/api/sc") and fs.exists("system/api/settings") then
  2004.                 sleep(0.5)
  2005.                 api = true
  2006.                 else
  2007.                 api = false
  2008.             end
  2009.         end
  2010.     result()
  2011. end
  2012. function result()
  2013.         print("")
  2014.         print("RESULT:")
  2015.         if apiprog == true then
  2016.             print("API PROGRAMS: OK")
  2017.         else
  2018.             term.setTextColor(colors.red)
  2019.             print("API PROGRAMS: MISSING")
  2020.             term.setTextColor(colors.white)
  2021.         end
  2022.         if api == true then
  2023.             sleep(0.1)
  2024.             print("API: OK")
  2025.         else
  2026.             term.setTextColor(colors.red)
  2027.             print("API: MISSING")
  2028.             term.setTextColor(colors.white)
  2029.         end
  2030.         if system == true then
  2031.             sleep(0.1)
  2032.             print("SYSTEM: OK")
  2033.             else
  2034.             term.setTextColor(colors.red)
  2035.             print("SYSTEM: MISSING")
  2036.             term.setTextColor(colors.white)
  2037.         end
  2038.         if os_ == true then
  2039.             sleep(0.1)
  2040.             print("OS: OK")
  2041.             else
  2042.             term.setTextColor(colors.red)
  2043.             print("OS: MISSING")
  2044.             term.setTextColor(colors.white)
  2045.         end
  2046. end
  2047. function diag(arg1,arg2,arg3)
  2048.     print("LAUNCHING SYSTEM DIAGNOSE")
  2049.     sleep(0.2)
  2050.     print("WAITING FOR RESULTS...")
  2051.     launchdiag(arg1,arg2,arg3)
  2052. end
  2053. ]]
  2054. BIRCHTWO = [[
  2055. apiversion = "8.6"
  2056. osversion = birch.osversion
  2057. dis = false
  2058. function init()
  2059.     if not dis == true then
  2060.         print("BirchOS Ultimate API initialized!")
  2061.     end
  2062. end
  2063. function disableinitmessage()
  2064.     dis = true
  2065. end
  2066. function clear()
  2067.     term.clear()
  2068.     term.setCursorPos(1,1)
  2069. end
  2070. function crash(reason)
  2071.     term.clear()
  2072.     term.setCursorPos(1,1)
  2073.     print("ERROR"..osversion..apiversion.."x"..tostring(math.random(1000000,9127830)))
  2074.  
  2075.     sleep(1)
  2076.     term.clear()
  2077.     term.setCursorPos(1,1)
  2078.     term.setBackgroundColor(colors.blue)
  2079.     term.setTextColor(colors.white)
  2080.     term.clear()
  2081.     print("BIRCH OS HAS RUN INTO AN ERROR AND HAD TO TERMINATE TO PREVENT ERROR")
  2082.     print("IF YOU SEE THIS FREQUENTLY PLEASE CONTACT THE DEVELOPERS OF BIRCH OS")
  2083.     print("[INFORMATION]")
  2084.     print("CRASH_REASON:")
  2085.     print(reason)
  2086.     sleep(10)
  2087.     --fs.makeDir("system/crashlog")
  2088.     settings.setVariable("system/crashlog","crash","true")
  2089.     settings.setVariable("system/crashlog","crash_reason",tostring(reason))
  2090.     os.reboot()
  2091. end
  2092. function systemcheckMissing()
  2093.     if not fs.exists("system") then
  2094.         local sysm = true
  2095.     end
  2096.     if not fs.exists("api") then
  2097.         local apim = true
  2098.     end
  2099.     if not fs.exists("startup") then
  2100.         local startupm = true
  2101.     end
  2102.     os.reboot()
  2103. end
  2104. function printcenter( text, y, col )
  2105.   term.setTextColor(col)
  2106.   local x = term.getSize()
  2107.   local centerXPos = ( x - string.len(text) ) / 2
  2108.   term.setCursorPos( centerXPos, y )
  2109.   write( text )
  2110.   term.setTextColor(colors.white)
  2111. end
  2112. function aP(str , c)
  2113.     term.setTextColor(c)
  2114.     print(str)
  2115.     term.setTextColor(colors.white)
  2116. end
  2117. ]]
  2118. function Install()
  2119.     if not fs.exists("system/settings") then
  2120.         if fs.getFreeSpace("/") <= 80000 then
  2121.             printcenter(math.floor(fs.getFreeSpace("/")/1024) .."KB out of required 80KB",9)
  2122.             printcenter("Birch OS",8)
  2123.             printcenter("Not enough space on disk! :(",10)
  2124.             sleep(10)
  2125.             os.reboot()
  2126.         end
  2127.     end
  2128.     --fs.delete("*/*")
  2129.     term.setBackgroundColor(colors.white)
  2130.     term.setTextColor(colors.black)
  2131.     shell.run("clear")
  2132.     printcenter("Birch OS",8)
  2133.     printcenter("[=        ]",10)
  2134.     btheme = fs.open("system/api/thememanager/themes/theme.birchtheme","w")
  2135.     term.setCursorPos(1,2)
  2136.     btheme.write(BIRCHOS_THEME)
  2137.     btheme.close()
  2138.     term.setBackgroundColor(colors.white)
  2139.     shell.run("clear")
  2140.     printcenter("Birch OS",8)
  2141.     printcenter("[=         ]",10)
  2142.     sleep(0.1)
  2143.      bsettch = fs.open("system/api/source_api_programs/settingsChecker","w")
  2144.     term.setBackgroundColor(colors.white)
  2145.     shell.run("clear")
  2146.     printcenter("Birch OS",8)
  2147.     printcenter("[==        ]",10)
  2148.     bsettch.write(BIRCHOS_SETTINGS_CHECKER)
  2149.     bsettch.close()
  2150.     if not fs.exists("system/settings") then
  2151.         term.setBackgroundColor(colors.white)
  2152.         shell.run("clear")
  2153.         printcenter("Birch OS",8)
  2154.         printcenter("[===       ]",10)
  2155.          bsettf = fs.open("system/settings","w")
  2156.         sleep(0.25)
  2157.         bsettf.write(BIRCHOS_SETTINGS_FILE)
  2158.         bsettf.close()
  2159.     end
  2160.      bchat = fs.open("system/programs/chat.lua","w")
  2161.     term.setBackgroundColor(colors.white)
  2162.     shell.run("clear")
  2163.     printcenter("Birch OS",8)
  2164.     printcenter("[====      ]",10)
  2165.     sleep(0.1)
  2166.     bchat.write(BIRCHOS_CHAT)
  2167.     bchat.close()
  2168.      bos = fs.open("system/os.lua","w")
  2169.     term.setBackgroundColor(colors.white)
  2170.     shell.run("clear")
  2171.     printcenter("Birch OS",8)
  2172.     printcenter("[======    ]",10)
  2173.     sleep(0.1)
  2174.     bos.write(BIRCHOS_OS)
  2175.     bos.close()
  2176.      startup = fs.open("startup","w")
  2177.     term.setBackgroundColor(colors.white)
  2178.     shell.run("clear")
  2179.     printcenter("Birch OS",8)
  2180.     printcenter("[========  ]",10)
  2181.     sleep(0.1)
  2182.     startup.write(BIRCHOS_STARTUP)
  2183.     startup.close()
  2184.      bootl = fs.open("system/api/source_api_programs/bootloader","w")
  2185.     term.setBackgroundColor(colors.white)
  2186.     shell.run("clear")
  2187.     printcenter("Birch OS",8)
  2188.     printcenter("[========= ]",10)
  2189.     sleep(0.1)
  2190.     bootl.write(BIRCHOS_BOOTLOADER)
  2191.     bootl.close()
  2192.      scapi = fs.open("system/api/sc","w")
  2193.     term.setBackgroundColor(colors.white)
  2194.     shell.run("clear")
  2195.     printcenter("Birch OS",8)
  2196.     printcenter("[==========]",10)
  2197.     --printcenter("Finishing up...",12)
  2198.     sleep(0.1)
  2199.     scapi.write(BIRCHOS_SC_API)
  2200.     scapi.close()
  2201.      birchapi = fs.open("system/api/birch","w")
  2202.     birchapi.write(BIRCHOS_BIRCHAPI)
  2203.     birchapi.close()
  2204.      operationapi = fs.open("system/api/operation","w")
  2205.     sleep(0.1)
  2206.     operationapi.write(BIRCHOS_OPERATION_API)
  2207.     operationapi.close()
  2208.      settingsapi = fs.open("system/api/settings","w")
  2209.     settingsapi.write(BIRCHOS_SETTINGS_API)
  2210.     settingsapi.close()
  2211.      networkapi = fs.open("system/api/network","w")
  2212.     networkapi.write(BIRCHOS_NETWORK_API)
  2213.     networkapi.close()
  2214.      sysdiag = fs.open("beta/systemdiag","w")
  2215.     sysdiag.write(BIRCHOS_SYSTEMDIAG)
  2216.     sysdiag.close()
  2217.      b2 = fs.open("beta/birchtwo","w")
  2218.     b2.write(BIRCHTWO)
  2219.     b2.close()
  2220.      edge = fs.open("system/api/edge","w")
  2221.     edge.write(BIRCHOS_EDGE)
  2222.     edge.close()
  2223.      desktop = fs.open("system/desktop_test.lua","w")
  2224.     desktop.write(BIRCHOS_DESKTOP)
  2225.     desktop.close()
  2226.     sleep(1)
  2227.     os.reboot()
  2228. end
  2229. function aP(str , c)
  2230.     term.setTextColor(c)
  2231.     print(str)
  2232.     term.setTextColor(colors.white)
  2233. end
  2234. function printcenter( text, y )
  2235.   local x = term.getSize()
  2236.   local centerXPos = ( x - string.len(text) ) / 2
  2237.   term.setCursorPos( centerXPos, y )
  2238.   write( text )
  2239. end
  2240. function Main()
  2241.  
  2242.     term.setBackgroundColor(colors.white)
  2243.     term.setTextColor(colors.black)
  2244.     shell.run("clear")
  2245.     if fs.exists("system/os.lua") and fs.exists("system/desktop_test.lua") then
  2246.         printcenter("Do you want to update BirchOS?",1)
  2247.     else
  2248.         printcenter("Do you want to install BirchOS?",1)
  2249.     end
  2250.  
  2251.     term.setCursorPos(1,2)
  2252.     print("")
  2253.     if fs.exists("system/os.lua") and fs.exists("system/settings") and fs.exists("system/desktop_test.lua") then
  2254.         aP("[X] Update",colors.green)
  2255.         print("")
  2256.         aP("[X] Exit",colors.red)
  2257.     else
  2258.         aP("[X] Yes",colors.green)
  2259.         print("")
  2260.         aP("[X] No",colors.red)
  2261.     end
  2262.     if fs.exists("system/settings") then
  2263.             term.setCursorPos(14,3)
  2264.        aP("[X] Repair",colors.orange)
  2265.              term.setCursorPos(1,6)
  2266.     end
  2267.     term.setTextColor(colors.black)
  2268.     print("")
  2269.     print("Changes in PRE-RELEASE 1.1:")
  2270.     print("  + Added HTTP detection")
  2271.     print("  + Added update notifications")
  2272.     print("  - Removed verification features")
  2273.     print("  * Working towards a more open OS")
  2274.     print("  Be open. Be free. - Nothy")
  2275.     print("Changes in Beta 1.4:")
  2276.     print("  * New installer")
  2277.     print("  + Added repair option to installer")
  2278.     print("  + VirtualOS is back! :D")
  2279.     print("  * Trying out window features")
  2280.     print("  (Big step towards multitasking)")
  2281.     while(true) do
  2282.         local event, button, x, y = os.pullEvent("mouse_click")
  2283.         if x == 2 and y == 3 then
  2284.             shell.run("clear")
  2285.             Install()
  2286.         end
  2287.         if x == 15 and y == 3 then
  2288.           shell.run("rm system")
  2289.             shell.run("rm beta")
  2290.             shell.run("rm startup")
  2291.             Install()
  2292.         end
  2293.         if x == 2 and y == 5 then
  2294.             shell.run("clear")
  2295.             print("Goodbye!")
  2296.             sleep(1)
  2297.             os.shutdown()
  2298.         end
  2299.     end
  2300. end
  2301. if not term.isColor() then
  2302.     shell.run("clear")
  2303.     printcenter("Birch OS Error",5)
  2304.     printcenter("The current terminal is not supported.",6)
  2305.     sleep(5)
  2306.     os.shutdown()
  2307. else
  2308.     Install()
  2309. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement