minif

mos

Jan 25th, 2020
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. --Minif OS Main Core
  2.  
  3. osScreenSizeX, osScreenSizeY = term.getSize()
  4.  
  5. function osFillBG(selColor)
  6. paintutils.drawFilledBox(1,1,osScreenSizeX,osScreenSizeY,selColor)
  7. term.setCursorPos(1,1)
  8. term.setBackgroundColor(selColor)
  9. if selColor == colors.white then
  10. term.setTextColor(colors.black)
  11. else
  12. term.setTextColor(colors.white)
  13. end
  14. end
  15.  
  16. function osBSOD(message, cause, tips)
  17. osFillBG(colors.blue)
  18. print("Critical System Error!")
  19. print(message)
  20. print(cause)
  21. print(tips)
  22. print("")
  23. print("Press any key to continue.")
  24. sleep(2)
  25. local blank1, blank2 = os.pullEvent()
  26. end
  27.  
  28. function osDrawWindow(name)
  29. paintutils.drawFilledBox(3,3,osScreenSizeX-2,osScreenSizeY-2,colors.white)
  30. paintutils.drawBox(3,3,osScreenSizeX-2,5,colors.lightGray)
  31. term.setBackgroundColor(colors.white)
  32. term.setTextColor(colors.black)
  33. term.setCursorPos(4,4)
  34. term.write(name)
  35. end
  36.  
  37. function osConfirm(name,message,detail)
  38. osDrawWindow(name)
  39. term.setCursorPos(4,7)
  40. term.write(message)
  41. term.setCursorPos(4,8)
  42. term.write(detail)
  43. paintutils.drawBox(4,11,osScreenSizeX-3,11,colors.green)
  44. term.setCursorPos(5,11)
  45. term.write("Yes")
  46. paintutils.drawBox(4,13,osScreenSizeX-3,13,colors.red)
  47. term.setCursorPos(5,13)
  48. term.write("No")
  49. local choice = false
  50. while true do
  51. osPEvent, osPB, osPX, osPY = os.pullEvent("mouse_click")
  52. if osPX >= 3 and osPX <=osScreenSizeX-2 then
  53. if osPY == 11 then
  54. choice = true
  55. return true
  56. else if osPY == 13 then
  57. return false
  58. end
  59. end
  60. end
  61. end
  62. return choice
  63. end
  64.  
  65. function osDrawPerm(prog)
  66. paintutils.drawFilledBox(3,3,osScreenSizeX-2,osScreenSizeY-2,colors.white)
  67. paintutils.drawBox(3,3,osScreenSizeX-2,5,colors.lightGray)
  68. term.setCursorPos(4,4)
  69. term.setBackgroundColor(colors.white)
  70. term.setTextColor(colors.red)
  71. term.write("Permissions Error")
  72. term.setCursorPos(4,7)
  73. term.setTextColor(colors.black)
  74. term.write("You do not have permission")
  75. term.setCursorPos(4,8)
  76. term.write("To access the program: "..prog)
  77. term.setCursorPos(4,10)
  78. term.write("Press any key to exit.")
  79. while true do
  80. local event = os.pullEvent()
  81. if event == "mouse_click" or event == "key" then
  82. return
  83. end
  84. end
  85. end
  86.  
  87.  
  88. function osDrawDesktop()
  89. osFillBG(colors.cyan)
  90. if mos.osUserBGImageExists then
  91. paintutils.drawImage(os_UserBGImage,1,2)
  92. else
  93. if osBGImageExists then
  94. paintutils.drawImage(os_BGImage,1,1)
  95. end
  96. end
  97. end
  98.  
  99. function osDrawMenu()
  100. paintutils.drawBox(1,1,mos.osScreenSizeX,1,colors.blue)
  101. term.setBackgroundColor(colors.lightBlue)
  102. term.setTextColor(colors.black)
  103. term.setCursorPos(1,1)
  104. term.write("M >")
  105. term.setCursorPos(5,1)
  106. term.write("File >")
  107. term.setCursorPos(12,1)
  108. term.write("System >")
  109. end
  110.  
  111. function osDrawAll()
  112. term.setCursorBlink(false)
  113. osLoadPrefs()
  114. osDrawDesktop()
  115. osDrawMenu()
  116. end
  117.  
  118. function osLoadPrefs()
  119. local pref = fs.open("/system/user/"..mos.osEnteredUser.."/config", "r")
  120. local readFile = pref.readLine()
  121. if fs.exists(readFile) and not (fs.isDir(readFile)) then
  122. os_UserBGImage = paintutils.loadImage(readFile)
  123. mos.osUserBGImageExists = true
  124. end
  125. local readLine = pref.readLine()
  126. if readLine == "true" then
  127. mos.osUserAdmin = true
  128. end
  129. pref.close()
  130. end
Add Comment
Please, Sign In to add comment