Advertisement
Guest User

sf

a guest
Dec 7th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.66 KB | None | 0 0
  1.  
  2. local GUI = require("GUI")
  3. local system = require("System")
  4. local io = require("filesystem")
  5. local component = require("component")
  6.  
  7. ---------------------------------------------------------------------------------
  8.  
  9. local currentScriptDirectory = io.path(system.getCurrentScript())
  10. local localization = system.getLocalization(currentScriptDirectory .. "Localizations/")
  11.  
  12. local workspace, window, menu = system.addWindow(GUI.titledWindow(1, 1, 60, 20, "EFI CardWriter", true))
  13.  
  14. --local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 60, 20, 0xF0F0F0))
  15. --layout:addChild(GUI.text(1, 1, 0x4B4B4B, "EFI CardWriter"))
  16.  
  17. local layout = window:addChild(GUI.layout(1, 1, window.width, window.height, 1, 1))
  18.  
  19. layout:setMargin(1, 1, 0, -1)
  20. ---------------------------------------------------------------------------------
  21.  
  22.  
  23. local name = layout:addChild(GUI.input(1, 1, 36, 3, 0xFFFFFF, 0x444444, 0xAAAAAA, 0xFFFFFF, 0x2D2D2D, "", localization.eepromname))
  24.  
  25. local filesystemChooser = layout:addChild(GUI.filesystemChooser(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0xD2D2D2, 0xA5A5A5, nil, localization.open, localization.close, localization.choose, "/"))
  26.  
  27. local flash = layout:addChild(GUI.roundedButton(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x696969, 0xE1E1E1, localization.flash))
  28.  
  29. layout:addChild(GUI.textBox(1, 1, 36, 1, nil, 0xA5A5A5, {localization.description}, 1, 0, 0, true, true))
  30.  
  31. flash.onTouch = function()
  32.  
  33.   if component.isAvailable("OSCardWriter") then
  34.     local writer = component.OSCardWriter
  35.  
  36.     if FB_flashFile ~= nil then
  37.       writer.flash(FB_flashFile, name.text, false)
  38.       GUI.alert(localization.flashed)
  39.     else
  40.       GUI.alert(localization.texterror)
  41.     end
  42.  
  43.   elseif component.isAvailable("os_cardwriter") then
  44.     local writer = component.os_cardwriter
  45.  
  46.     if FB_flashFile ~= nil then
  47.       writer.flash(FB_flashFile, name.text, false)
  48.       GUI.alert(localization.flashed)
  49.     else
  50.       GUI.alert(localization.texterror)
  51.     end
  52.  
  53.   end
  54.  
  55. end
  56.  
  57. filesystemChooser.onSubmit = function(path)
  58.     local file = io.open(path, "r")
  59.     FB_flashFile = file:read("*a")
  60. end
  61.  
  62. window.onResize = function(newWidth, newHeight)
  63.   window.backgroundPanel.width, window.backgroundPanel.height = newWidth, newHeight
  64.   window.titlePanel.width, window.titleLabel.width = newWidth, newWidth
  65.   layout.width, layout.height = newWidth, newHeight
  66. end
  67.  
  68. ---------------------------------------------------------------------------------
  69.  
  70. workspace:draw()
  71.  
  72. if component.isAvailable("OSCardWriter") then
  73.   local check = nil
  74. elseif component.isAvailable("os_cardwriter") then
  75.   local check = nil
  76. else
  77.   name.disabled = true
  78.   filesystemChooser.disabled = true
  79.   flash.disabled = true
  80.   GUI.alert(localization.BlockConnectCardWrite);
  81. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement