Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local nft = require "cc.image.nft"
- local Ventana, LSApps
- local LSBotones = {}
- local MaxX,MaxY = term.getSize()
- local heldButton, hasDragged = 0, false
- local focusWindow, baseTerminal = nil, term.current()
- local queueProgram = nil
- function SystemData()
- --File system
- if (fs.exists("Apps") == false) then
- fs.makeDir("Apps")
- end
- if (fs.exists("SysData") == false) then
- fs.makeDir("SysData")
- if(fs.exists("SysData/os.json")) then
- fs.delete("SysData/os.json")
- end
- if(fs.exists("SysData/Background.nfp") == false) then
- local file = fs.open("SysData/Background.nfp", "w")
- file.close()
- end
- end
- local file = fs.open("SysData/os.json", "w")
- file.writeLine("1.0") --os Version
- file.close()
- --Auto install
- if (fs.exists("startup.lua") == false) then
- shell.execute("pastebin", "get", "FHjcaBvz", "startup.lua")
- end
- --Options
- if (fs.exists("SysData/options.txt") == false) then
- file = fs.open("SysData/options.txt", "w")
- file.writeLine(colors.blue) --Bar color
- file.writeLine(colors.yellow) --App color
- file.writeLine(colors.black) --Text color
- file.close()
- end
- file = fs.open("SysData/options.txt", "r")
- barColor = tonumber(file.readLine()) --Bar color
- appColor = tonumber(file.readLine()) --App color
- textColor = tonumber(file.readLine()) --Text color
- file.close()
- --Obligatory apps
- local LSApps ={
- {"Market", "rnCyVUc8"},
- {"Birb", "PEu7TMTy"},
- {"Files", "46VKqBfY"},
- {"Msgr", "gv8X2eVS"},
- {"Optns", "mn5XYW9f"}
- }
- for a=1,#LSApps,1 do
- if (fs.exists("Apps/" .. LSApps[a][1]) == false) then
- fs.delete("Apps/" .. LSApps[a][1])
- shell.execute("pastebin", "get", LSApps[a][2], "Apps/" .. LSApps[a][1] .. "/" .. LSApps[a][1] .. ".lua")
- local fUID = fs.open("Apps/" .. LSApps[a][1] .. "/UID.txt", "w")
- fUID.write(LSApps[a][2])
- fUID.close()
- end
- end
- end
- function LoadApps()
- LSBotones = {}
- LSApps = fs.list("Apps")
- local nApps = table.getn(LSApps)
- local x, y = 2, 2
- for i=1,nApps do
- local name = LSApps[i]
- local path = "Apps/" .. LSApps[i] .. "/" .. LSApps[i] .. ".lua"
- if (fs.exists("Apps/" .. LSApps[i] .. "/LOCATION.txt")) then
- local isX = true
- for line in io.lines("Apps/" .. LSApps[i] .. "/LOCATION.txt") do
- if (isX) then
- isX = false
- x = tonumber(line)
- else
- y = tonumber(line)
- end
- end
- elseif (y > 16) then
- y = 2
- x = x+5
- local file = fs.open("Apps/" .. LSApps[a][1] .. "/LOCATION.txt", "w")
- file.write(x .. "\n" .. y)
- file.close()
- end
- local i = table.getn(LSBotones) + 1
- LSBotones[i] = {x, y, x+1, y+1, name, path}
- y = y+3
- end
- end
- function PaintIcons()
- for i,b in ipairs(LSBotones) do
- local x,y = LSBotones[i][1], LSBotones[i][2]
- local name = LSBotones[i][5]
- paintutils.drawBox(x,y, x+1,y+1, appColor)
- term.setBackgroundColor(colors.white)
- term.setTextColor(textColor)
- term.setCursorPos(x-1,y+2)
- term.write(name)
- end
- end
- function OpenProgram(x, y)
- for o = 1,#LSBotones,1 do
- if (o > 6) then
- break
- end
- if (x >= LSBotones[o][1] and y >= LSBotones[o][2] and x <= LSBotones[o][3] and y <= LSBotones[o][4]) then
- local w,h = term.getSize()
- local window = window.create(term.native(), 1, 2, w, h-2)
- focusWindow = window
- queueProgram = LSBotones[o][6]
- end
- end
- end
- function PaintScreen()
- if (focusWindow ~= nil) then
- term.redirect(baseTerminal)
- local w,h = term.getSize()
- -- app top bar
- paintutils.drawLine(1, 1, w, 1, colors.orange)
- paintutils.drawPixel(w,1, colors.yellow)
- term.setTextColor(textColor)
- term.setCursorPos(w,1)
- term.write("x")
- -- task bar
- paintutils.drawLine(1, h, w, h, barColor)
- term.setTextColor(textColor)
- term.setCursorPos(3,h)
- term.write("DoorOS")
- -- time
- term.setCursorPos(w-7,h)
- term.write(textutils.formatTime(os.time(), false))
- -- menu button
- paintutils.drawLine(1, h, 2, h, colors.cyan)
- term.redirect(focusWindow)
- else
- local w,h = term.getSize()
- term.setBackgroundColor(colors.white)
- term.clear()
- if(fs.exists("SysData/Background.nfp")) then
- local image = paintutils.loadImage("SysData/Background.nfp")
- paintutils.drawImage(image, 1,1)
- end
- -- task bar
- paintutils.drawLine(1, h, w, h, barColor)
- term.setTextColor(textColor)
- term.setCursorPos(3,h)
- term.write("DoorOS")
- -- time
- term.setCursorPos(w-7,h)
- term.write(textutils.formatTime(os.time(), false))
- -- menu button
- paintutils.drawLine(1, h, 2, h, colors.cyan)
- PaintIcons()
- end
- end
- function WakeUpEffect()
- local delay = 0.3
- term.clear()
- term.setCursorPos(1,3)
- print(" #-#-#-#")sleep(delay)
- print(" # # #")sleep(delay)
- print(" # # #")sleep(delay)
- print(" # # #")sleep(delay)
- print(" #-#-#-# #")sleep(delay)
- print(" # #")sleep(delay)
- print(" # #")sleep(delay)
- print(" # #")sleep(delay5)
- print(" #-#-#-#")sleep(delay)
- print("")
- print("Industries.")
- sleep(2)
- end
- function ScreenSaver()
- term.setBackgroundColour(colors.black)
- term.setTextColour(colors.white)
- local txt = "Screensaver"
- local X,Y, vX,vY = 1,1, 1,1
- while (true) do
- parallel.waitForAny(function()
- term.clear()
- if (X<1) then
- X=2
- vX=vX*-1
- elseif (X > (MaxX - string.len(txt) + 1)) then
- X= (MaxX - string.len(txt))
- vX=vX*-1
- end
- if (Y<1) then
- Y=2
- vY=vY*-1
- elseif (Y > MaxY) then
- Y= MaxY-1
- vY=vY*-1
- end
- term.setCursorPos(X,Y)
- term.write(txt)
- X=X+vX
- Y=Y+vY
- sleep(0.2)
- end,
- function()
- local event, button, x, y = os.pullEvent("mouse_click")
- return
- end)
- end
- end
- --WakeUpEffect()
- SystemData()
- LoadApps()
- --main
- parallel.waitForAny(
- function()
- while (true) do
- PaintScreen()
- sleep(0.05)
- end
- end,
- function()
- while (true) do
- local event, button, x, y = os.pullEvent("mouse_click")
- for i,b in ipairs(LSBotones) do
- if (b[1]==x and b[2]==y) then
- heldButton = i
- break
- end
- end
- end
- end,
- function()
- while (true) do
- local event, button, x, y = os.pullEvent("mouse_drag")
- if (heldButton > 0) then
- hasDragged = true
- LSBotones[heldButton][1] = x
- LSBotones[heldButton][2] = y
- LSBotones[heldButton][3] = x+1
- LSBotones[heldButton][4] = y+1
- PaintScreen()
- end
- end
- end,
- function()
- while (true) do
- local event, button, x, y = os.pullEvent("mouse_up")
- if (focusWindow == nil) then
- if (hasDragged == false) then
- OpenProgram(x, y)
- else
- local file = fs.open("Apps/" .. LSBotones[heldButton][5] .. "/LOCATION.txt", "w")
- file.write(x .. "\n" .. y)
- file.close()
- end
- else
- local w,h = term.getSize()
- if (x == w and y == 1) then -- close window
- focusWindow.reposition(100, 100)
- --error("Terminate")
- term.redirect(baseTerminal)
- focusWindow = nil
- end
- end
- heldButton = 0
- hasDragged = false
- end
- end,
- function()
- while (true) do
- if (queueProgram ~= nil) then
- shell.execute(queueProgram)
- queueProgram = nil
- if (focusWindow ~= nil) then
- term.redirect(focusWindow)
- end
- end
- sleep(0.2)
- end
- end
- )
Advertisement
Add Comment
Please, Sign In to add comment