Advertisement
PolskiWisnia

MineCore Hybrid OS Menu

May 1st, 2019
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.59 KB | None | 0 0
  1. -- Skroty do komend --
  2. local function s(...) return sleep(...) end
  3. local function w(...) return write(...) end
  4. local function p(...) return print(...) end
  5. local function tw(...) return term.write(...) end
  6. local function scp(...) return term.setCursorPos(...) end
  7. local function sbc(...) return term.setBackgroundColor(...) end
  8. local function stc(...) return term.setTextColor(...) end
  9. local function tc(...) return term.clear(...) end
  10. local function tcl(...) return term.clearLine(...) end
  11. local function r(...) return shell.run(...) end
  12. local function sp(...) return textutils.slowPrint(...) end
  13. local function sw(...) return textutils.slowWrite(...) end
  14. local function fse(...) return fs.exists(...) end
  15. local function pul(...) return paintutils.loadImage(...) end
  16. local function pud(...) return paintutils.drawImage(...) end
  17. local function pfb(...) return paintutils.drawFilledBox(...) end
  18. local function su(...) return os.shutdown(...) end
  19. local function re(...) return os.reboot(...) end
  20. local function pdp(...) return paintutils.drawPixel(...) end
  21.  
  22. function tlo()
  23.  if fs.exists("/os/.pulpit") then
  24.   local pul = fs.open("/os/.pulpit", "r")
  25.   tloo = pul.readLine(1)
  26.   pul.close()
  27.  else
  28.  local pul = fs.open("/os/.pulpit", "w")
  29.  tlo = "Nowe"
  30.  pul.writeLine(tlo)
  31.  pul.close()
  32. end
  33. if tloo == "Nowe" then styl = "Klasyczne" end
  34. if tloo == "Klasyczne" then styl = "Nowe" end
  35. end
  36. function zmien()
  37.  if tloo == "Nowe" then r("rm /os/.pulpit")  local pul = fs.open("/os/.pulpit", "w")  tlo = "Klasyczne"  pul.writeLine(tlo) pul.close()  elseif tloo == "Klasyczne" then r("rm /os/.pulpit") local pul = fs.open("/os/.pulpit", "w")  tlo = "Nowe"  pul.writeLine(tlo) pul.close() end
  38. s(2)
  39. re()
  40. end
  41. function logobraz()
  42. pfb(1, 1, 51, 5, colors.blue)
  43. pfb(1, 6, 51, 14, colors.lightBlue)
  44. pfb(1, 15, 51, 19, colors.blue)
  45. pfb(15, 7, 17, 9, colors.gray)
  46. stc(colors.white)
  47. scp(1,1)
  48. p("Logowanie MineCore")
  49. scp(1,2)
  50. p("Wybierz uzytkownika, a nastepnie wpisz haslo.")
  51. end
  52. -- Funkcja do otrzymywania rozmiaru folderu/pliku --
  53. function getSize(path)
  54.   local size = 0
  55.   for _, file in ipairs(fs.list(path)) do
  56.     if fs.isDir(fs.combine(path, file)) then
  57.       size = size + getSize(fs.combine(path, file))
  58.     else
  59.       size = size + fs.getSize(fs.combine(path, file))
  60.     end
  61.   end
  62.   return size
  63. end
  64. local data = os.day()
  65. -- Odczytywanie wersji systemu --
  66. function wersja()
  67.  local ver = fs.open("/os/ver/.ver", "r")
  68.  wer = ver.readLine(1)
  69. end
  70. -- Funkcja wyswietlania pulpitu --
  71. function obraz()
  72. if tloo == "Nowe" then
  73.  tc()
  74.  pfb(1, 1, 51, 1, colors.brown)
  75.  pfb(2, 2, 50, 17, colors.black)
  76.  pfb(1, 1, 1, 18, colors.brown)
  77.  pfb(1, 18, 51, 18, colors.brown)
  78.  pfb(51, 1, 51, 18, colors.brown)
  79.  pfb(1, 19, 5, 19, colors.green)
  80.  pfb(6, 19, 49, 19, colors.blue)
  81.  pdp(50, 19, colors.red)
  82.  pdp(51, 19, colors.orange)
  83.  sbc(colors.green)
  84.  stc(colors.white)
  85.  scp(1,19)
  86.  w("Start")
  87.  sbc(colors.brown)
  88.  stc(colors.white)
  89.  scp(1,1)
  90.  p("Informacje")
  91.  time = os.time()
  92.  time = textutils.formatTime(time, true)
  93.  sbc(colors.blue)
  94.  stc(colors.white)
  95.  scp(45,19)
  96.  write(time)
  97.  scp(30,19)
  98.  w("Dzien: ", data)
  99. elseif tloo == "Klasyczne" then
  100. sbc(colors.white)
  101. tc()
  102. sbc(colors.white)
  103. pdp(50, 19, colors.red)
  104. pdp(51, 19, colors.orange)
  105. pfb(1, 19, 51, 19, colors.blue)
  106. sbc(colors.blue)
  107. stc(colors.white)
  108. scp(1,1)
  109. p("Microcraft MineCore Hybrid OS")
  110. scp(1,19)
  111. w("Start")
  112. time = os.time()
  113. time = textutils.formatTime(time, true)
  114. sbc(colors.blue)
  115. stc(colors.white)
  116. scp(45,1)
  117. p(time)
  118. scp(30,19)
  119. w("Dzien: ", data)
  120. end
  121. end
  122. -- Odczytywanie danych do logowania --
  123. function pliki()
  124.  local u = fs.open("/os/.log1", "r")
  125.  user = u.readLine(1)
  126.  u.close()
  127.  local h = fs.open("/os/.log2", "r")
  128.  pass = h.readLine(1)
  129.  h.close()
  130. end
  131. -- Logowanie --
  132. function log()
  133. sbc(colors.lightBlue)
  134. stc(colors.white)
  135. scp(18,7)
  136. p(user)
  137. scp(18,8)
  138. w("")
  139. haslo = read()
  140. if haslo == pass then ok = 1 else scp(18,9) stc(colors.red) p("Bledne haslo") s(2) re() end
  141. end
  142. -- Menu Start
  143. function start()
  144.  pfb(1, 15, 10, 18, colors.white)
  145.  pfb(1, 14, 10, 14, colors.blue)
  146.  scp(1,14)
  147.  stc(colors.white)
  148.  p("Start")
  149.  stc(colors.black)
  150.  sbc(colors.white)
  151.  scp(1,15)
  152.  p("Ustawienia")
  153.  scp(1,16)
  154.  p("Programy")
  155.  scp(1,17)
  156.  p("CraftOS")
  157.  scp(1,18)
  158.  p("/run")
  159.  point2()
  160. end
  161. -- Zakladka informacje --
  162. function info()
  163.  pfb(1, 2, 20, 6, colors.lightGray)
  164.  stc(colors.white)
  165.  sbc(colors.lightGray)
  166.  scp(1,2)
  167.  p("MineCore Hybrid OS")
  168.  p("Wolne miejsce:")
  169.  p(fs.getFreeSpace("/")/1024, "KB")
  170.  p("Kompilacja: 1300A")
  171.  p("17.07.2019")
  172.  local event, click, x, y = os.pullEvent("mouse_click")
  173. end
  174. -- Wykrywanie wcisniecia --
  175. function point()
  176. local event, click, x, y = os.pullEvent("mouse_click")
  177. if tloo == "Nowe" then
  178.  if x>0 and x<6 and y == 19 then start() end
  179.  if x == 50 and y == 19 then su() end
  180.  if x == 51 and y == 19 then re() end
  181.  if x>0 and x<11 and y == 1 then info() end
  182. elseif tloo == "Klasyczne" then
  183.  if x>0 and x<6 and y == 19 then start() end
  184.  if x == 50 and y == 19 then su() end
  185.  if x == 51 and y == 19 then re() end
  186. end
  187. end
  188. -- to co wyzej, ale jeszcze raz --
  189. function point2()
  190.  local event, click, x, y = os.pullEvent("mouse_click")
  191.  if x>0 and x<9 and y == 16 then programy() end
  192.  if x>0 and x<9 and y == 17 then error("Opuszczono MineUI 4.1") end
  193.  if x>0 and x<11 and y == 15 then set() end
  194.  if x>0 and x<9 and y == 18 then scp(2,2)
  195.  stc(colors.white)
  196.  sbc(colors.black)
  197.  w("Wpisz nazwe pliku: ")
  198.  plik = read()
  199.  if fs.exists(plik) then r(plik) else error("Brak oczekiwanego pliku.") end
  200. end
  201. end
  202. -- Menu Programy --
  203. function programy()
  204.  pfb(11, 14, 19, 17, colors.white)
  205.  scp(12,14)
  206.  p(">2048")
  207.  scp(12,15)
  208.  p("LuaIDE")
  209.  scp(12,16)
  210.  p("Snake")
  211.  scp(12,17)
  212.  p("Paint")
  213.  local event, click, x, y = os.pullEvent("mouse_click")
  214.  if x>10 and x<20 and y == 14 then r("/os/.2048") end
  215.  if x>10 and x<20 and y == 15 then scp(2,2) sbc(colors.black) stc(colors.white) w("Wpisz nazwe pliku: ") plik = read() r("edit", plik) end
  216.  if x>10 and x<20 and y == 16 then sbc(colors.black) r("worm") end
  217.  if x>10 and x<20 and y == 17 then r("/os/.paint") end
  218. end
  219. -- Ustawienia --
  220. function set()
  221.  tc()
  222.  pfb(1, 1, 51, 1, colors.blue)
  223.  pfb(1, 2, 51, 19, colors.white)
  224.  scp(1,1)
  225.  sbc(colors.blue)
  226.  stc(colors.white)
  227.  p("Ustawienia")
  228.  sbc(colors.white)
  229.  stc(colors.black)
  230.  scp(1,2)
  231.  sbc(colors.green)
  232.  p("[Informacje ogolne]")
  233.  p("MineCore Hybrid OS")
  234.  wolne = math.ceil(fs.getFreeSpace("/")/1024)
  235.  sbc(colors.purple)
  236.  p("Wolne miejsce na dysku:", wolne, "KB")
  237.  zajete = getSize("/os/")/1024
  238.  lacznie = fs.getFreeSpace("/") + zajete
  239.  sbc(colors.orange)
  240.  print(math.ceil(zajete/1024), "KB uzyte z ", lacznie, "KB")
  241.  p("[Zarzadzanie komputerem]")
  242.  p("Nazwa komputera: ", os.getComputerLabel())
  243.  p("Zmien nazwe komputera")
  244.  local ver = fs.open("/os/ver/.ver", "r")
  245.  wer = ver.readLine(1)
  246.  sbc(colors.red)
  247.  p("Wersja: ", wer)
  248.  p("Nazwa uzytkownika:", user)
  249.  sbc(colors.cyan)
  250.  p("Aktualizuj system")
  251.  p("Zainstaluj wersje testowa")
  252.  sbc(colors.yellow)
  253.  p("MineCore Hybrid OS - system niewspierany.")
  254.  p(tloo)
  255.  p("Dostepne style (nacisnij, aby zmienic):")
  256.  p(styl)
  257.  p("Wlaczone logowanie (kliknij, aby przelaczyc)?")
  258.  w("Tak")
  259.  local event, click, x, y = os.pullEvent("mouse_click")
  260.  if x>0 and x<20 and y == 7 then scp(1,8) sbc(colors.white) stc(colors.black) w("Wpisz nowa nazwe: ") nazwa = read() os.setComputerLabel(nazwa) end
  261.  if x>0 and x<20 and y == 11 then r("/os/.update") end
  262.  if x>0 and x<20 and y == 12 then r("/os/.tupdate") end
  263.  if x>0 and x<20 and y == 17 then zmien() end
  264.  if x>0 and x<20 and y == 19 then zmien2() end
  265. end
  266. -- Kolejnosc funkcji --
  267. function system()
  268. tlo()
  269. while true do
  270. obraz()
  271. point()
  272. end
  273. end
  274. system()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement