Kodos

[OC] Component Viewer

Dec 24th, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.14 KB | None | 0 0
  1. local component = require("component")
  2. local fs = require("filesystem")
  3. local process = require("process")
  4. local event = require("event")
  5. local keyboard = require("keyboard")
  6. local shell = require("shell")
  7. local term = require("term")
  8. local text = require("text")
  9. local unicode = require("unicode")
  10. local sides = require("sides")
  11. local colors=require("colors")
  12.  
  13. -- The following code added by Michiyo, to check if:
  14. -- A.) The computer has HTTP access, and
  15. -- B.) if the required files exist to run this program.
  16. -- C.) And to download them if it can.
  17. --#~#~#~#~#~#~#~ CHANGE THE FOLLOWING VARIABLE TO FALSE TO DISABLE AUTOUPDATE CHECKING~#~#~#~#~#~#~#
  18. autoUpdate = true
  19.  
  20. local cpath = fs.path(shell.resolve(process.running(),nil))
  21. local oldDirectory = os.getenv("PWD");
  22. shell.setWorkingDirectory(cpath)
  23.  
  24. --Thanks Gopher!
  25. function compareVersions(v1,v2)
  26.   local pat="(%d+)"
  27.   local iter1,iter2=v1:gmatch(pat),v2:gmatch(pat)
  28.   while true do
  29.     local n1,n2=iter1(), iter2()
  30.     n1,n2=n1 and tonumber(n1),n2 and tonumber(n2)
  31.     if n1==nil then
  32.       if n2==nil then
  33.         return 0
  34.       else
  35.         return -1
  36.       end
  37.     elseif n2==nil then
  38.       return 1
  39.     end
  40.     if n1~=n2 then
  41.       return n1-n2
  42.     end
  43.   end
  44. end
  45.  
  46.   function file_check(file_name)
  47.     local file = fs.open(file_name)
  48.     if file ~= nil then
  49.       file:close()
  50.       return true
  51.     else
  52.       return false
  53.     end
  54.   end
  55.  
  56.   wget = loadfile("/bin/wget.lua")
  57.  
  58.   function downloadFile(remotename, filename)
  59.     wget("-fq", "https://raw.github.com/OpenPrograms/Kenny-Programs/master/CompViewer/" .. remotename, fs.concat(cpath, filename))
  60.   end
  61.  
  62.   function remoteVersion()
  63.     for line in internet.request("https://raw.github.com/OpenPrograms/Kenny-Programs/master/CompViewer/compviewer-version.txt") do
  64.       if line ~= "not found" then
  65.         return text.trim(line)
  66.       else
  67.         return "0"
  68.       end
  69.     end
  70.   end
  71.  
  72.   function localVersion()
  73.     if not file_check(cpath.."compviewer-version.txt") then
  74.       return "0"
  75.     else
  76.       local f = io.open(cpath.."compviewer-version.txt", "rb")
  77.       local content = f:read("*all")
  78.       f:close()
  79.       return content
  80.     end
  81.   end
  82.  
  83.   function doUpdate(watdo)
  84.     if (watdo == "update") then
  85.       if autoUpdate == true then
  86.         print("A new version " .. remoteVersion() .. " is available, would you like to download it? Yes/No")
  87.         doTehUpdate = io.read()
  88.         doTehUpdate = string.lower(doTehUpdate)
  89.         if doTehUpdate == "yes" then
  90.           print("Cleaning up previous install")
  91.           fs.remove(cpath .. "default.gss")
  92.           fs.remove(cpath .. "cv.gss")
  93.           fs.remove(cpath .. "gml.lua")
  94.           fs.remove(cpath .. "gfxbuffer.lua")
  95.           fs.remove(cpath .. "colorutils.lua")
  96.           fs.remove(cpath .. "colorutils.lua")
  97.           fs.remove(cpath .. "compviewer-version.txt")
  98.           currFile = process.running()
  99.           fs.remove(currFile)
  100.           if not file_check(cpath .. currFile) then
  101.             print("Downloading CompViewer.lua")
  102.             downloadFile("CompViewer.lua", currFile)
  103.           end
  104.         end
  105.         else print("Skipping update, you will be reminded next time")
  106.         end
  107.       end
  108.       print("Downloading latest versions of required files")
  109.       if not file_check(cpath .. "default.gss") then
  110.         print("Downloading default.gss")
  111.         downloadFile("default.gss","default.gss")
  112.         downloaded = true
  113.       end
  114.       if not file_check(cpath .. "cv.gss") then
  115.         print("Downloading cv.gss")
  116.         downloadFile("cv.gss","cv.gss")
  117.         downloaded = true
  118.       end
  119.       if not file_check(cpath .. "gml.lua") then
  120.         print("Downloading gml.lua")
  121.         downloadFile("gml.lua","gml.lua")
  122.         downloaded = true
  123.       end
  124.       if not file_check(cpath .. "gfxbuffer.lua") then
  125.         print("Downloading gfxbuffer.lua")
  126.         downloadFile("gfxbuffer.lua","gfxbuffer.lua")
  127.         downloaded = true
  128.       end
  129.       if not file_check(cpath .. "colorutils.lua") then
  130.         print("Downloading colorutils.lua")
  131.         downloadFile("colorutils.lua","colorutils.lua")
  132.         downloaded = true
  133.       end
  134.       if not file_check(cpath .. "compviewer-version.txt") then
  135.         print("Downloading compviewer-version.txt")
  136.         downloadFile("compviewer-version.txt","compviewer-version.txt")
  137.       end
  138.       if downloaded == true then
  139.         print("Please run the program again")
  140.         shell.setWorkingDirectory(oldDirectory)
  141.         os.exit()
  142.       end
  143.     end
  144.  
  145.     if not component.isAvailable("internet") then
  146.       if not file_check(cpath .. "gml.lua") or not file_check(cpath .. "cv.gss") or not file_check(cpath .. "default.gss") or not file_check(cpath .. "gfxbuffer.lua") or not file_check(cpath .. "colorutils.lua") then
  147.         io.stderr:write("You are missing one or more of the required files 'gml.lua', 'colorutils.lua', 'gfxbuffer.lua', 'default.gss', or 'cv.gss' and do not have internet access to download them automaticly!\n")
  148.         return
  149.       end
  150.     else
  151. --We load the internet API here so we don't die on computers without internet cards.
  152. internet = require("internet")
  153. if not file_check(cpath .. "compviewer-version.txt") then
  154.   print("Setting up version cache")
  155.   downloadFile("compviewer-version.txt","compviewer-version.txt")
  156. end
  157. --Check if this is a fresh download, or a update 0 is fresh, > 0 is update.
  158. newVersion = remoteVersion()
  159. if (compareVersions(newVersion, localVersion()) == 0) then
  160.   doUpdate("fresh")
  161.   elseif(compareVersions(newVersion, localVersion()) > 0) then
  162.     doUpdate("update")
  163.   end
  164.   --print("Updating Component Info file, One moment please")
  165.   --fs.remove(cpath .. "CompInfo.txt")
  166.   os.sleep(1)
  167.   --downloadFile("CompInfo.txt")
  168. end
  169. --We've checked for gml, and downloaded it if it was available, so we can load gml now.
  170. local gml=require("gml")
  171. --We now return you to the previous code by Kenny.
  172. local function spaces(cnt)
  173.   return string.rep(string.char(32), cnt)
  174. end
  175.  
  176. local function spChar(letter, cnt)
  177.   return string.rep(unicode.char(letter), cnt)
  178. end
  179.  
  180. local OC_1 = "   "..spChar(0x2584,3).."  "..spChar(0x2584,4).."  "..spChar(0x2584,5).." "..spChar(0x2584,1).."   "..spChar(0x2584,1).."  "..spChar(0x2584,4).."  "..spChar(0x2584,3).."  "..spChar(0x2584,1).."   "..spChar(0x2584,1).." "..spChar(0x2584,4).."  "..spChar(0x2584,1).."   "..spChar(0x2584,1).." "..spChar(0x2584,5).." "..spChar(0x2584,5).." "..spChar(0x2584,4).."   "..spChar(0x2584,4).."  "
  181. local OC_2 = "  "..spChar(0x2588,1).."   "..spChar(0x2588,1).." "..spChar(0x2588,1).."   "..spChar(0x2588,1).." "..spChar(0x2588,1).."     "..spChar(0x2588,1)..spChar(0x2584,1).."  "..spChar(0x2588,1).." "..spChar(0x2588,1).."     "..spChar(0x2588,1).."   "..spChar(0x2588,1).." "..spChar(0x2588,1)..spChar(0x2580,1)..spChar(0x2584,1)..spChar(0x2580,1)..spChar(0x2588,1).." "..spChar(0x2588,1).."   "..spChar(0x2588,1).." "..spChar(0x2588,1).."   "..spChar(0x2588,1).."   "..spChar(0x2588,1).."   "..spChar(0x2588,1).."     "..spChar(0x2588,1).."   "..spChar(0x2588,1).." "..spChar(0x2588,1).."  "
  182. local OC_3 = "  "..spChar(0x2588,1).."   "..spChar(0x2588,1).." "..spChar(0x2588,1)..spChar(0x2580,3).."  "..spChar(0x2588,1)..spChar(0x2580,2).."   "..spChar(0x2588,1).." "..spChar(0x2588,1).." "..spChar(0x2588,1).." "..spChar(0x2588,1).."     "..spChar(0x2588,1).."   "..spChar(0x2588,1).." "..spChar(0x2588,1).."   "..spChar(0x2588,1).." "..spChar(0x2588,1)..spChar(0x2580,3).."  "..spChar(0x2588,1).."   "..spChar(0x2588,1).."   "..spChar(0x2588,1).."   "..spChar(0x2588,1)..spChar(0x2580,2).."   "..spChar(0x2588,1)..spChar(0x2580,1)..spChar(0x2588,1)..spChar(0x2580,1).."   "..spChar(0x2580,2)..spChar(0x2584,1).."  "
  183. local OC_4 = "  "..spChar(0x2588,1).."   "..spChar(0x2588,1).." "..spChar(0x2588,1).."     "..spChar(0x2588,1).."     "..spChar(0x2588,1).."  "..spChar(0x2588,2).." "..spChar(0x2588,1).."     "..spChar(0x2588,1).."   "..spChar(0x2588,1).." "..spChar(0x2588,1).."   "..spChar(0x2588,1).." "..spChar(0x2588,1).."     "..spChar(0x2588,1).."   "..spChar(0x2588,1).."   "..spChar(0x2588,1).."   "..spChar(0x2588,1).."     "..spChar(0x2588,1).."  "..spChar(0x2588,1).."      "..spChar(0x2588,1).."  "
  184. local OC_5 = "   "..spChar(0x2580,3).."  "..spChar(0x2580,1).."     "..spChar(0x2580,5).." "..spChar(0x2580,1).."   "..spChar(0x2580,1).."  "..spChar(0x2580,4).."  "..spChar(0x2580,3).."  "..spChar(0x2580,1).."   "..spChar(0x2580,1).." "..spChar(0x2580,1).."      "..spChar(0x2580,3).."    "..spChar(0x2580,1).."   "..spChar(0x2580,5).." "..spChar(0x2580,1).."   "..spChar(0x2580,1).." "..spChar(0x2580,4).."  "
  185.  
  186. local gpu = component.gpu
  187. local Tier1 = 1
  188. local Tier2 = 4
  189. local Tier3 = 8
  190.  
  191. local menuList = {}
  192.  
  193. local compList = {}
  194. local tmpList = {}
  195. local sentStr = {}
  196. local compLen = 1
  197.  
  198. --local fname = "CompInfo.txt"
  199. --local filename = shell.resolve(cpath..fname)
  200.  
  201. local w, h = gpu.getResolution()
  202.  
  203. local guiRow = 1
  204. local guiWidth = 1
  205. local guiHeight = 1
  206. local guiContentsLabelCol = 1
  207. local guiContentsLabelWidth = 1
  208. local menuDirWidth = 1
  209. local menuDirHeight = 1
  210. local functionsCol = 1
  211. local functionsWidth = 1
  212. local functionsHeight = 1
  213. local infoGuiWidth = 1
  214. local infoGuiHeight = 1
  215. local infoFunctionsLabelWidth = 1
  216. local infoListboxWidth = 1
  217. local infoListboxHeight = 1
  218.  
  219. local function table_count(tt, item)
  220.   local count
  221.   count = 0
  222.   for ii,xx in pairs(tt) do
  223.     if item == xx then count = count + 1 end
  224.   end
  225.   return count
  226. end
  227.  
  228. local function table_unique(tt)
  229.   local newtable = {}
  230.   for ii,xx in ipairs(tt) do
  231.     if table_count(newtable, xx) == 0 then
  232.       newtable[#newtable+1] = xx
  233.     end
  234.   end
  235.   return newtable
  236. end
  237.  
  238. local function isAdvanced()
  239.   return gpu.getDepth()
  240. end
  241.  
  242. local function setColors(fore, back)
  243.   gpu.setForeground(fore)
  244.   gpu.setBackground(back)
  245. end
  246.  
  247. local function setCursor(col, row)
  248.   term.setCursor(col, row)
  249. end
  250.  
  251. local function getSize()
  252.   return gpu.getResolution()
  253. end
  254.  
  255. local function drawBox(col, row, wid, hgt, fore, back, opt)
  256.   local ul = {0x250C, 0x2554}
  257.   local ur = {0x2510, 0x2557}
  258.   local ll = {0x2514, 0x255A}
  259.   local lr = {0x2518, 0x255D}
  260.   local sl = {0x2502, 0x2551}
  261.   local al = {0x2500, 0x2550}
  262.   setColors(fore, back)
  263.   gpu.set(col, row, unicode.char(ul[opt])..spChar(al[opt], wid - 2)..unicode.char(ur[opt]))
  264.   for a = 1, hgt - 2 do
  265.     gpu.set(col, row + a, unicode.char(sl[opt])..spaces(wid - 2)..unicode.char(sl[opt]))
  266.   end
  267.   gpu.set(col, row + hgt - 2, unicode.char(ll[opt])..spChar(al[opt], wid - 2)..unicode.char(lr[opt]))
  268.   setCursor(col, row)
  269. end
  270.  
  271. local function printXY(col, row, menuSel)
  272.   gpu.set(col, row, menuSel)
  273. end
  274.  
  275. local function printDocXY(col, row, menuSel)
  276.   setCursor(col, row)
  277.   print(menuSel)
  278. end
  279.  
  280.  
  281. local function centerText(row, msg)
  282.   local w, h = getSize()
  283.   local len = string.len(msg)
  284.   gpu.set((w - len)/2, row, msg)
  285. end
  286.  
  287. local function centerIntroText(row, msg)
  288.   local msg1 = "   *   * *   * *     **  * *     *   * * * * *   * *   *   *   *     *   * *     "
  289.   local w, h = getSize()
  290.   local len = string.len(msg1)
  291.   gpu.set((w - len)/2, row, msg)
  292. end
  293.  
  294.  
  295. local defaultTheme = {        -- Water Theme
  296.   textColor = 0xFFFFFF,
  297.   background = 0x000099,
  298.   introText = 0xFF0000,
  299.   introBackground = 0x000000,
  300.   menuHintText = 0xFFFF00,
  301.   menuHint = 0x000000,
  302.   prompt = 0xBBBB00,
  303.   promptHighlight = 0x000000,
  304.   fancyDots = 0xAAFFCC,
  305.   fancyBackground = 0x113322
  306.   }
  307.  
  308. local normalTheme = {       -- Water Theme
  309.   textColor = 0xFFFFFF,
  310.   background = 0x000000,
  311.   prompt = 0x000000,
  312.   promptHighlight = 0xFFFFFF,
  313.   }
  314.  
  315. term.clear()
  316. local w, h = gpu.getResolution()
  317.  
  318. local function intro()
  319.   local w, h = gpu.getResolution()
  320.   local msg1 = "   *   * *   * *     **  * *     *   * * * * *   * *   *   *   *     *   * *     "
  321.   local len = string.len(msg1) + 1
  322.  
  323.   drawBox(1, 3, w, h - 3, theme.textColor, theme.background, 2)
  324.   drawBox((w - len)/2 - 2, 5, len + 4, 10, theme.introText, theme.introBackground, 1)
  325.  
  326.   centerIntroText(6, OC_1)
  327.   centerIntroText(7, OC_2)
  328.   centerIntroText(8, OC_3)
  329.   centerIntroText(9, OC_4)
  330.   centerIntroText(10, OC_5)
  331.   centerText(12, "Component Viewer")
  332. end
  333.  
  334. local gpuDepth = gpu.getDepth()
  335. if (gpuDepth >= Tier2) then
  336.   theme = defaultTheme
  337. else
  338.   theme = normalTheme
  339. end
  340.  
  341.  
  342. if (gpuDepth == Tier3) then
  343.   guiRow = 15
  344.   guiWidth = 80
  345.   guiHeight = 30
  346.   guiContentsLabelCol = 30
  347.   guiContentsLabelWidth = 31
  348.   menuDirWidth = 24
  349.   menuDirHeight = 25
  350.   functionsCol = 30
  351.   functionsWidth = 50
  352.   functionsHeight = 25
  353.   infoGuiWidth = 160
  354.   infoGuiHeight = 50
  355.   infoFunctionsLabelWidth = 50
  356.   infoListboxWidth = 160
  357.   infoListboxHeight = 42
  358.   intro()
  359. elseif (gpuDepth == Tier2) then
  360.   guiRow = "center"
  361.   guiWidth = 50
  362.   guiHeight = 16
  363.   guiContentsLabelCol = 18
  364.   guiContentsLabelWidth = 31
  365.   menuDirWidth = 16
  366.   menuDirHeight = 11
  367.   functionsCol = 20
  368.   functionsWidth = 30
  369.   functionsHeight = 11
  370.   infoGuiWidth = 80
  371.   infoGuiHeight = 25
  372.   infoFunctionsLabelWidth = 30
  373.   infoListboxWidth = 80
  374.   infoListboxHeight = 16
  375. else
  376.   guiRow = "center"
  377.   guiWidth = 50
  378.   guiHeight = 16
  379.   guiContentsLabelCol = 18
  380.   guiContentsLabelWidth = 31
  381.   menuDirWidth = 16
  382.   menuDirHeight = 11
  383.   functionsCol = 20
  384.   functionsWidth = 30
  385.   functionsHeight = 11
  386.   infoGuiWidth = 50
  387.   infoGuiHeight = 16
  388.   infoFunctionsLabelWidth = 30
  389.   infoListboxWidth = 50
  390.   infoListboxHeight = 10
  391. end
  392.  
  393. local function strripos(s, delim)
  394.   return s:match('^.*()'..delim)
  395. end
  396.  
  397. local gui=gml.create("center", guiRow, guiWidth, guiHeight)
  398. gui.style=gml.loadStyle("cv.gss")
  399.  
  400. gui:addLabel(2,1,14,"Component")
  401. local contentsLabel=gui:addLabel(guiContentsLabelCol,1, guiContentsLabelWidth, "contents of")
  402.  
  403.  
  404. local function getMenuList()
  405.   menuList = {}
  406.   local tmpName = ""
  407.   for address, name in component.list() do
  408.     table.insert(menuList,name)
  409.     for k, v in pairs(component.proxy(address)) do
  410.       tmpName = name.."."..k
  411.       table.insert(compList,tmpName)
  412.     end
  413.   end
  414.   table.sort(menuList)
  415. end
  416.  
  417. function loadInfoData(select)
  418.   local lineLen, lineHeight = 0, 0
  419.   local lineCnt = 0
  420.   local optName = "["..string.upper(select).."]"
  421.   local optNameEnd = "["..string.upper(select).."_END]"
  422.   local optNameStart, optNameLast = 0,0
  423.   local w, h = gpu.getResolution()
  424.   local tmpLine = {}
  425.   local tmpStr = ""
  426.   sentStr = {}
  427.   lineLen = w - 8
  428.   local stuffDone = false
  429.  
  430.   --[[do
  431.     local f = io.open(filename)
  432.       if f then
  433.         for line in f:lines() do
  434.           lineCnt = lineCnt + 1
  435.           if text.trim(line) == optName then
  436.             optNameStart = lineCnt + 1
  437.           end
  438.           if text.trim(line) == optNameEnd then
  439.             optNameLast = lineCnt - 1
  440.           end
  441.           table.insert(tmpLine, line)
  442.         end
  443.       f:close()
  444.     end
  445.   end]]
  446.   do
  447.     local ccomp = component.getPrimary(select)
  448.     if ccomp and optNameStart < 2 then
  449.       for i in pairs(component.methods(ccomp.address)) do
  450.         local cStr = tostring(ccomp[i])
  451.         if cStr and string.len(cStr)>0 then
  452.           if optNameLast < 1 then
  453.             optNameLast = optNameLast + 1
  454.           end
  455.           local ch = ";"
  456.           if not string.find(cStr, ";") then
  457.             ch = "%-%-"
  458.           end
  459.           local ccStr = string.gsub(cStr,"(.*)"..ch..".*",i.." - %1")
  460.           cStr = string.gsub(cStr,".*"..ch.."(.*)","%1")
  461.           table.insert(tmpLine,optNameLast,ccStr)
  462.           optNameLast = optNameLast + 1
  463.           table.insert(tmpLine,optNameLast,cStr)
  464.           optNameLast = optNameLast + 1
  465.           lineCnt = lineCnt + 3
  466.           stuffDone = true
  467.         end
  468.       end
  469.     end
  470.   end
  471.   if optNameStart < 2 and not stuffDone then
  472.     table.insert(sentStr, "No information available for "..select)
  473.   else
  474.     table.insert(sentStr, tostring(select))
  475.   end
  476.   if lineCnt > 2 then
  477.     local tStr = ""
  478.     for k, v in pairs(tmpLine) do
  479.       if k >= optNameStart and k <= optNameLast then
  480.           v = text.trim(v)
  481.           local dspace = 6
  482.           if string.find(v,"function%(.*%)") then
  483.             dspace = 3
  484.           end
  485.         if string.len(v) > lineLen then
  486.           while string.len(v) > lineLen do
  487.             v = spaces(dspace)..v
  488.             tmpStr = string.sub(v, 1, lineLen)
  489.             if string.len(tmpStr) < lineLen then
  490.               tStr = string.sub(tmpStr, 1, string.len(tmpStr) - 1)
  491.             else
  492.               delimPos = strripos(tmpStr, " ")
  493.               tStr = string.sub(tmpStr, 1, delimPos - 1)
  494.             end
  495.             table.insert(sentStr, tStr)
  496.             v = string.sub(v, delimPos + 1)
  497.           end
  498.           if string.len(v) < lineLen then
  499.             table.insert(sentStr, spaces(dspace)..text.trim(v))
  500.           end
  501.         elseif string.sub(v, 1, string.len(select)) == select then
  502.           table.insert(sentStr, v)
  503.         else
  504.           table.insert(sentStr, spaces(dspace)..v)
  505.         end
  506.       end
  507.     end
  508.   end
  509.   for a = 1, #sentStr do
  510.     if string.sub(sentStr[a], 1, string.len(select)) == select then
  511.       sentStr[a] = string.sub(sentStr[a], string.len(select) + 2, string.len(sentStr[a]))
  512.     end
  513.   end
  514. end
  515.  
  516. getMenuList()
  517.  
  518. local menuDirList=gui:addListBox(2, 2, menuDirWidth, menuDirHeight, menuList)
  519. local functionsList=gui:addListBox(functionsCol, 2, functionsWidth, functionsHeight, tmpList)
  520.  
  521. local function updateMenuList()
  522.   getMenuList()
  523.   menuDirList:updateList(menuList)
  524. end
  525.  
  526. local function updateFunctionsList(comp)
  527.   local tLen = 1
  528.   local sPos = 1
  529.   local sTmp = ""
  530.   local tmpList = {}
  531.  
  532.   contentsLabel.text="Functions for "..comp
  533.   contentsLabel:draw()
  534.  
  535.   for len = 1, #compList do
  536.     sPos = string.find(compList[len], ".", 1, true)
  537.     if (string.sub(compList[len], 1, sPos - 1) == comp) then
  538.       sTmp = string.sub(compList[len], sPos + 1, string.len(compList[len]))
  539.       table.insert(tmpList, sTmp)
  540.     end
  541.   end
  542.   table.sort(tmpList)
  543.   tmpList = table_unique(tmpList)
  544.   functionsList:updateList(tmpList)
  545. end
  546.  
  547. function newListBox()
  548.   local infoGUI=gml.create("center", "center", infoGuiWidth, infoGuiHeight)
  549.   select = menuDirList:getSelected()
  550.   loadInfoData(select)
  551.   term.clear()
  552.   local labelText = "Functions explanation for "
  553.   local infoLabel=infoGUI:addLabel(math.max(1,math.floor((infoGuiWidth-string.len(labelText))/2)), 1, infoFunctionsLabelWidth, labelText)
  554.   local infoLabel2=infoGUI:addLabel(math.max(1,math.floor((infoGuiWidth-string.len(select))/2)), 2, infoFunctionsLabelWidth, select)
  555.   local infoList=infoGUI:addListBox(1, -5, infoListboxWidth, infoListboxHeight, sentStr)
  556.   infoGUI:addButton("center",-1,12,2,"Close",infoGUI.close)
  557.   infoGUI:run()
  558.   term.clear()
  559.   if (gpuDepth == Tier3) then
  560.     intro()
  561.   end
  562.   gui:draw()
  563. end
  564.  
  565. gui:addButton(-20,-1,8,1,"Info", newListBox)
  566. gui:addButton(-11,-1,8,1,"Reload", updateMenuList)
  567. gui:addButton(-2,-1,8,1,"Close",gui.close)
  568.  
  569. local function onMenuSelect(lb,prevIndex,selIndex)
  570.   updateFunctionsList(menuDirList:getSelected())
  571. end
  572.  
  573. menuDirList.onChange=onMenuSelect
  574.  
  575. menuDirList.onDoubleClick=function()
  576.   updateFunctionsList(menuDirList:getSelected())
  577. end
  578.  
  579. updateFunctionsList(menuDirList:getSelected())
  580.  
  581. gui:run()
  582. term.setCursor(1,1)
  583. gpu.setForeground(0xFFFFFF)
  584. gpu.setBackground(0x000000)
  585.  
  586. term.clear()
  587. shell.setWorkingDirectory(oldDirectory)
Add Comment
Please, Sign In to add comment