Advertisement
electronic_steve

ESB

Nov 16th, 2016
841
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.23 KB | None | 0 0
  1. local e=require("component").eeprom
  2. local c=[[local com,FL,b,C,AK,M={},{},"─",{w=0xFFFFFF,d=0,g=0x2A2A2A,dg=0x151515},{[200]={0,-1},[208]={0,1},[203]={-1,0},[205]={1,0}}for a,k in pairs(component.list())do com[k]=component.proxy(a)end local N,K=com.eeprom.getData,com.eeprom.setData computer.getBootAddress=N computer.setBootAddress=K local gpu=com.gpu or {} local S,F,fg,bg=gpu.set,gpu.fill,gpu.setForeground,gpu.setBackground local function TL(address)local fs=component.proxy(address)if not fs then return end local H,r=fs.open("/init.lua")if not H then return v,r end local B=""repeat local d,r=fs.read(H,9999)if not d and r then return v,r end B=B..(d or "")until not d fs.close(H)return load(B,"=init")end local function NL()local I,r if N()then I,r=TL(N())end if not I then for a in component.list("filesystem")do I,r=TL(a)if I then K(a)break end end end if not I then error("no bootable medium found "..tostring(r))end computer.beep(1000,0.2)I()end if not com.gpu or not com.screen then NL()end local function drawButton(x,y)local s=M[y][x]if s then fg(C.w)bg(C.g)S(s[1]+1,s[2],s[3])fg(C.g)bg(C.dg)S(s[1],s[2],"◀")S(s[1]+unicode.len(s[3])+1,s[2],"▶")end end local function CS(fx,fy)local ox,oy=M.s.x,M.s.y local x,y=ox+fx,oy+fy if M[y]and M[y][x]then drawButton(ox,oy)M.s={x=x,y=y}local s=M[y][x]fg(C.d)bg(C.w)S(s[1]+1,s[2],s[3])fg(C.w)bg(C.dg)S(s[1],s[2],"◀")S(s[1]+unicode.len(s[3])+1,s[2],"▶")if x==0 then F(2,3,1,13," ")F(4,18,52,6," ")S(2,y+2,"╭")F(2,y+3,1,13-y,"│")local a=FL[y]local p=component.proxy(a)S(4,18,"название: "..(p.getLabel()or"none"))S(4,19,"адрес: "..a)S(4,20,"только чтение: <"..(p.isReadOnly()and"♦"or" ")..">")S(4,21,"занято: "..p.spaceUsed().."/"..p.spaceTotal().." "..math.floor(p.spaceUsed()/p.spaceTotal()*100).."%")end end end local function drawM()local w,h=gpu.maxResolution()gpu.setResolution(math.min(w,80),math.min(h,25))bg(C.dg)fg(C.g)F(1,1,80,25,"█")F(2,2,56,23," ")F(59,2,21,21," ")F(59,24,21,1," ")S(2,2,"◤")S(59,2,"◤")S(57,2,"◥")S(79,2,"◥")S(2,24,"◣")S(59,22,"◣")S(57,24,"◢")S(57,24,"◢")S(79,22,"◢")S(60,24,"ElectronicSteveBIOS")fg(C.dg)bg(C.g)S(59,24,"◀")S(79,h-1,"▶")for y=1,#M do for x=0,#M[y]do drawButton(x,y)end end fg(C.w)bg(C.dg)CS(0,0)F(4,17,52,8,b)F(3,18,54,6,"│")F(4,18,52,6," ")S(2,13,"┊")S(2,14,"┆")S(2,15,"╎")S(3,17,"├")S(2,16,"╰╮")S(3,24,"╰")S(56,17,"╮")S(56,24,"╯")S(4,18,"[▴] [▸] [▾] [◂] - выбор действий")S(4,19,"[Enter] - действие")S(4,20,"значок ◃ означает что данная ФС выбрана для загрузки")S(4,21,"значок ♦ означает что данная ФС готова к загрузке")S(4,22,"если загрузка с выбранной ФС не возможна то")S(4,23,"производится поиск подходяшей для загрузки ФС")end local function SFS(a) y=FL[N()] if y then M[y][0][3]=M[y][0][3]:sub(1,-4)F(3,y+2,55,1," ")drawButton(0,y)end K(a)M[M.s.y][0][3]=M[M.s.y][0][3].."◃"drawButton(0,M.s.y)CS(0,0)end local function RE()local i=0 FL={}for a,_ in component.list("filesystem")do i=i+1 FL[i]=a end table.sort(FL)for i,a in ipairs(FL)do FL[a]=i if not M[i]then M[i]={}end local I=TL(a)M[i][0]={3,i+2,"файловая система "..(component.proxy(a).getLabel()or"none").." ("..a:sub(1,4)..")"..(I and"♦"or"")..(a==computer.getBootAddress()and"◃"or""),SFS,a}end drawM()end M={s={x=1,y=1},{{64,3,"загрузка",NL}},{{60,5,"обновить  список",RE}},{{60,7,"перезапустить ПК",computer.shutdown,true}},{{62,9,"выключить ПК",computer.shutdown}}}if gpu and com.screen then gpu.bind(com.screen.address)else NL()end fg(0xFFFFFF)S(20,11,"╭"..b:rep(40).."╮")S(20,12,"│нажмите любую кнопку, чтобы зайти в меню│")S(20,13,"╰"..b:rep(40).."╯")if computer.pullSignal(1.5)==v then NL()end RE()while true do n,_,_,k=computer.pullSignal()if n=="key_down"then if AK[k]then CS(table.unpack(AK[k]))end if k==28 then local s=M[M.s.y][M.s.x]if s[4]then s[4](s[5])end end end end]]
  3. local _,r=e.set(c)
  4. e.setLabel("ES BIOS")
  5. e.makeReadonly(e.getChecksum())
  6. if r then
  7.     print(r)
  8. else
  9.     print("спасибо за установку Electronic_Steve's BIOS!")
  10. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement