zzFeVeRzz123

Untitled

Apr 28th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.68 KB | None | 0 0
  1. local libraries = {
  2. buffer = "doubleBuffering",
  3. MineOSCore = "MineOSCore",
  4. GUI = "GUI",
  5. component = "component",
  6. computer = "computer",
  7. event = "event",
  8. fs = "filesystem",
  9. files = "files",
  10. unicode = "unicode",
  11. archive = "archive",
  12. serialization = "serialization",
  13. }
  14.  
  15. for library in pairs(libraries) do if not _G[library] then _G[library] = require(libraries[library]) end end; libraries = nil
  16.  
  17. ------------------------------------------------------------------------------------------------------------------
  18.  
  19. local colors = {
  20. topBar = 0xdddddd,
  21. main = 0xffffff,
  22. leftBar = 0xeeeeee,
  23. leftBarTransparency = 25,
  24. leftBarSelection = ecs.colors.blue,
  25. leftBarSelectionText = 0xFFFFFF,
  26. closes = {close = ecs.colors.red, hide = ecs.colors.orange, full = ecs.colors.green},
  27. topText = 0x262626,
  28. topButtons = 0xffffff,
  29. topButtonsText = 0x262626,
  30. leftBarHeader = 0x000000,
  31. leftBarList = 0x444444,
  32. selection = 0x555555,
  33. mainScrollBarPipe = 0x999999,
  34. }
  35.  
  36. local pathToComputerIcon = "MineOS/System/OS/Icons/Computer.pic"
  37. local pathToConfig = "MineOS/System/Finder/Config.cfg"
  38. local workPathHistory = {}
  39. local currentWorkPathHistoryElement = 1
  40.  
  41. local oldPixelsOfFullScreen, isFullScreen
  42. local scrollSpeed = 2
  43. local searchBarText
  44.  
  45. local currentNetworkAddress
  46. local port = 322
  47. local disks = {}
  48. local network = {}
  49. local sizes = {}
  50. local fileList = {}
  51. local config = {}
  52. local obj = {}
  53. local sortingMethods = {[0] = MineOSCore.localization.sortByTypeShort, [1] = MineOSCore.localization.sortByNameShort, [2] = MineOSCore.localization.sortByDateShort, [MineOSCore.localization.sortByTypeShort] = 0, [MineOSCore.localization.sortByNameShort] = 1, [MineOSCore.localization.sortByDateShort] = 2}
  54.  
  55. ------------------------------------------------------------------------------------------------------------------
  56.  
  57. --Сохраняем все настроечки вот тут вот
  58. local function saveConfig()
  59. files.saveTableToFile(pathToConfig, config)
  60. end
  61.  
  62. --Загрузка конфига
  63. local function loadConfig()
  64. if fs.exists(pathToConfig) then
  65. config = files.loadTableFromFile(pathToConfig)
  66. else
  67. config.favourites = {
  68. {name = "Root", path = ""},
  69. {name = "System", path = "MineOS/System/"},
  70. {name = "Libraries", path = "lib/"},
  71. {name = "Scripts", path = "bin/"},
  72. {name = "Desktop", path = "MineOS/Desktop/"},
  73. {name = "Applications", path = "MineOS/Applications/"},
  74. {name = "Pictures", path = "MineOS/Pictures/"},
  75. }
  76. config.showFileFormat = false
  77. config.showSystemFiles = false
  78. config.showHiddenFiles = false
  79. config.currentSortingMethod = 0
  80. saveConfig()
  81. end
  82. end
  83.  
  84. --Создание дисков для лефтбара
  85. local function createDisks()
  86. disks = {}
  87. local HDDs = ecs.getHDDs()
  88. for proxy, path in fs.mounts() do
  89. for i = 1, #HDDs do
  90. if proxy.address == HDDs[i].address and path ~= "/" then
  91. table.insert(disks, {path = path, name = unicode.sub(path, 2, -1)})
  92. end
  93. end
  94. end
  95. -- for proxy, path in fs.mounts() do
  96. -- if path ~= "/" then
  97. -- table.insert(disks, {path = path, name = path})
  98. -- end
  99. -- end
  100. end
  101.  
  102. --Получить файловый список
  103. local function getFileList()
  104. fileList = ecs.getFileList(workPathHistory[currentWorkPathHistoryElement])
  105. fileList = ecs.sortFiles(workPathHistory[currentWorkPathHistoryElement], fileList, config.currentSortingMethod, config.showHiddenFiles)
  106. if searchBarText then fileList = ecs.searchInArray(fileList, searchBarText) end
  107. end
  108.  
  109. --Перейти в какую-то папку
  110. local function changePath(path)
  111. for i = currentWorkPathHistoryElement, #workPathHistory do
  112. table.remove(workPathHistory, currentWorkPathHistoryElement + 1)
  113. end
  114.  
  115. sizes.yFileList = sizes.yFileListStartPoint
  116. searchBarText = nil
  117.  
  118. table.insert(workPathHistory, path)
  119. currentWorkPathHistoryElement = #workPathHistory
  120.  
  121. getFileList()
  122. end
  123.  
  124. --Считаем размеры всего
  125. local function calculateSizes(notPersistentXFinder, notPersistentYFinder)
  126. sizes.xSpaceBetweenIcons, sizes.ySpaceBetweenIcons = 2, 1
  127. sizes.finderWidth, sizes.finderHeight = math.floor(buffer.screen.width * 0.585), math.floor(buffer.screen.height * 0.52)
  128. sizes.leftBarWidth = math.floor(sizes.finderWidth * 0.22)
  129. sizes.topBarHeight = 3
  130. sizes.mainWidth, sizes.mainHeight = sizes.finderWidth - sizes.leftBarWidth - 1, sizes.finderHeight - sizes.topBarHeight - 1
  131. sizes.xFinder, sizes.yFinder = notPersistentXFinder or math.floor(buffer.screen.width / 2 - sizes.finderWidth / 2), notPersistentYFinder or math.floor(buffer.screen.height / 2 - sizes.finderHeight / 2)
  132. sizes.xFinderEnd, sizes.yFinderEnd = sizes.xFinder + sizes.finderWidth - 1, sizes.yFinder + sizes.finderHeight - 1
  133. sizes.xMain, sizes.yMain = sizes.xFinder + sizes.leftBarWidth, sizes.yFinder + sizes.topBarHeight
  134. sizes.xCountOfIcons, sizes.yCountOfIcons, sizes.totalCountOfIcons = MineOSCore.getParametersForDrawingIcons(sizes.mainWidth - 4, sizes.mainHeight, sizes.xSpaceBetweenIcons, sizes.ySpaceBetweenIcons)
  135. sizes.yFileListStartPoint = sizes.yMain + 1
  136. sizes.yFileList = sizes.yFileListStartPoint
  137. sizes.iconTotalHeight = MineOSCore.iconHeight + sizes.ySpaceBetweenIcons
  138. sizes.searchBarWidth = math.floor(sizes.finderWidth * 0.21)
  139. sizes.xSearchBar = sizes.xFinderEnd - sizes.searchBarWidth - 1
  140. obj.mainZone = GUI.object(sizes.xMain, sizes.yMain, sizes.mainWidth, sizes.mainHeight)
  141. obj.topBarZone = GUI.object(sizes.xFinder, sizes.yFinder, sizes.finderWidth, sizes.topBarHeight)
  142. end
  143.  
  144. --Рисем цветные кружочки слева вверху
  145. local function drawCloses()
  146. obj.windowActionButtons = GUI.windowActionButtons(sizes.xFinder + 1, sizes.yFinder):draw()
  147. end
  148.  
  149. local function drawSearchBar(justDrawNotEvent)
  150. local y = sizes.yFinder + 1
  151. local textColor = searchBarText and 0x262626 or 0xBBBBBB
  152. obj.search = GUI.object(sizes.xSearchBar, y, sizes.searchBarWidth, 1)
  153. buffer.square(sizes.xSearchBar, y, sizes.searchBarWidth, 1, 0xFFFFFF, textColor, " ")
  154. return GUI.input(sizes.xSearchBar + 1, y, sizes.searchBarWidth - 2, textColor, searchBarText or MineOSCore.localization.search, {justDrawNotEvent = justDrawNotEvent})
  155. end
  156.  
  157. local function drawTopBar()
  158. buffer.square(sizes.xFinder, sizes.yFinder, sizes.finderWidth, sizes.topBarHeight, _G.OSSettings.interfaceColor or colors.topBar)
  159. drawCloses()
  160. local x, y = sizes.xFinder + 2, sizes.yFinder + 1
  161. obj.historyBack = GUI.button(x, y, 3, 1, 0xffffff, 0x262626, 0xAAAAAA, 0x000000, "<"):draw(); x = x + obj.historyBack.width + 1
  162. obj.historyBack.colors.disabled.background, obj.historyBack.colors.disabled.text = 0xFFFFFF, 0xdddddd
  163. if currentWorkPathHistoryElement == 1 then obj.historyBack.disabled = true; obj.historyBack:draw() end
  164. obj.historyForward = GUI.button(x, y, 3, 1, 0xffffff, 0x262626, 0xAAAAAA, 0x000000, ">"):draw(); x = x + obj.historyForward.width + 2
  165. obj.historyForward.colors.disabled.background, obj.historyForward.colors.disabled.text = 0xFFFFFF, 0xdddddd
  166. if currentWorkPathHistoryElement == #workPathHistory then obj.historyForward.disabled = true; obj.historyForward:draw() end
  167.  
  168. local cyka = {
  169. {objName = "sortingMethod", text = sortingMethods[config.currentSortingMethod], active = false},
  170. {objName = "showFormat", text = MineOSCore.localization.showFileFormatShort, active = config.showFileFormat},
  171. {objName = "showHidden", text = MineOSCore.localization.showHiddenFilesShort, active = config.showHiddenFiles},
  172. }
  173. for i = 1, #cyka do
  174. obj[cyka[i].objName] = GUI.adaptiveButton(x, y, 1, 0, 0xFFFFFF, 0x262626, 0x262626, 0xFFFFFF, cyka[i].text):draw()
  175. if cyka[i].active then obj[cyka[i].objName]:press() end
  176. x = x + obj[cyka[i].objName].width + 1
  177. end
  178.  
  179. drawSearchBar(true)
  180. end
  181.  
  182. local function drawAndHiglightPath(y, arrayElement)
  183. -- GUI.error(workPathHistory[currentWorkPathHistoryElement] .. " - " .. tostring(arrayElement.path))
  184. local pathAreEquals = workPathHistory[currentWorkPathHistoryElement] == arrayElement.path
  185. if pathAreEquals then buffer.square(sizes.xFinder, y, sizes.leftBarWidth, 1, colors.leftBarSelection, colors.leftBarSelectionText, " ") end
  186. buffer.text(sizes.xFinder + 2, y, pathAreEquals and colors.leftBarSelectionText or colors.leftBarList, unicode.sub(arrayElement.name, 1, sizes.leftBarWidth - 3))
  187. local object = GUI.object(sizes.xFinder, y, sizes.leftBarWidth, 1)
  188. object.path = arrayElement.path
  189. table.insert(obj.leftBarItems, object)
  190. end
  191.  
  192. local function drawLeftBar()
  193. obj.leftBarItems = {}
  194. obj.network = {}
  195. buffer.setDrawLimit(sizes.xFinder, sizes.yMain, sizes.leftBarWidth, sizes.mainHeight + 1)
  196. buffer.paste(1, 1, oldPixelsOfFullScreen)
  197. buffer.square(sizes.xFinder, sizes.yMain, sizes.leftBarWidth, sizes.mainHeight + 1, _G.OSSettings.interfaceColor or colors.leftBar, 0x000000, " ", colors.leftBarTransparency)
  198.  
  199. local x, y = sizes.xFinder + 1, sizes.yMain
  200. --Фаворитсы
  201. if #config.favourites > 0 then
  202. buffer.text(x, y, colors.leftBarHeader, MineOSCore.localization.favourites); y = y + 1
  203. for i = 1, #config.favourites do
  204. drawAndHiglightPath(y, config.favourites[i])
  205. y = y + 1
  206. end
  207. y = y + 1
  208. end
  209. --Сеть
  210. if (function() local count = 0; for key in pairs(network) do count = count + 1 end; return count end)() > 0 then
  211. buffer.text(x, y, colors.leftBarHeader, MineOSCore.localization.network); y = y + 1
  212. for address in pairs(network) do
  213. buffer.text(sizes.xFinder + 2, y, colors.leftBarList, unicode.sub(address, 1, sizes.leftBarWidth - 4))
  214. obj.network[address] = GUI.object(sizes.xFinder + 2, y, sizes.leftBarWidth, 1)
  215. y = y + 1
  216. end
  217. y = y + 1
  218. end
  219. --Диски
  220. buffer.text(x, y, colors.leftBarHeader, MineOSCore.localization.disks); y = y + 1
  221. for i = 1, #disks do
  222. drawAndHiglightPath(y, disks[i])
  223. y = y + 1
  224. end
  225.  
  226. buffer.resetDrawLimit()
  227. end
  228.  
  229. local function clearMainZone()
  230. buffer.square(sizes.xMain, sizes.yMain, sizes.mainWidth + 1, sizes.mainHeight + 1, colors.main)
  231. end
  232.  
  233. local function drawNetwork()
  234. local x, y = math.floor(sizes.xMain + sizes.mainWidth / 2 - 4), math.floor(sizes.yMain + sizes.mainHeight / 2 - 4)
  235. local buttonWidth = 22
  236.  
  237. buffer.image(x, y, image.load(pathToComputerIcon)); y = y + 5
  238. local text = ecs.stringLimit("end", currentNetworkAddress, sizes.mainWidth - 4)
  239. buffer.text(math.floor(sizes.xMain + sizes.mainWidth / 2 - unicode.len(text) / 2), y, 0xAAAAAA, text); y = y + 2
  240. x = math.floor(sizes.xMain + sizes.mainWidth / 2 - buttonWidth / 2)
  241. obj.networkFile = GUI.button(x, y, buttonWidth, 1, 0xdddddd, 0x262626, 0x262626, 0xEEEEEE, MineOSCore.localization.sendFile):draw(); y = y + 2
  242. obj.networkMessage = GUI.button(x, y, buttonWidth, 1, 0xdddddd, 0x262626, 0x262626, 0xEEEEEE, MineOSCore.localization.sendMessage):draw(); y = y + 2
  243. end
  244.  
  245. local function drawFiles()
  246. --Ебашим раб стол
  247. buffer.setDrawLimit(sizes.xMain, sizes.yMain, sizes.mainWidth, sizes.mainHeight)
  248. local differenceByPixels = sizes.yFileListStartPoint - sizes.yFileList
  249. local differenceByIcons = math.floor(differenceByPixels / sizes.iconTotalHeight)
  250. sizes.fromIcon = differenceByIcons < 2 and 1 or math.floor((differenceByIcons - 1) * sizes.xCountOfIcons) + 1
  251. local finalY = differenceByIcons < 2 and sizes.yFileList or sizes.yFileList + math.floor((differenceByIcons - 1) * sizes.iconTotalHeight)
  252. local finalTotalCountOfIcons = sizes.totalCountOfIcons + 2 * sizes.xCountOfIcons
  253. obj.DesktopIcons = MineOSCore.drawIconField(sizes.xMain + 2, finalY, sizes.xCountOfIcons, sizes.yCountOfIcons, sizes.fromIcon, finalTotalCountOfIcons, sizes.xSpaceBetweenIcons, sizes.ySpaceBetweenIcons, workPathHistory[currentWorkPathHistoryElement], fileList, config.showFileFormat, 0x262626)
  254. buffer.resetDrawLimit()
  255. --Ебашим скроллбар
  256. buffer.scrollBar(sizes.xFinderEnd, sizes.yMain, 1, sizes.mainHeight, #fileList, sizes.fromIcon, 0xCCCCCC, 0x666666)
  257. end
  258.  
  259. local function drawMain(cyka)
  260. clearMainZone()
  261. if cyka then drawNetwork() else drawFiles() end
  262. end
  263.  
  264. --Рисуем нижнюю полосочку с путем
  265. local function drawBottomBar()
  266. --Подложка
  267. buffer.square(sizes.xMain, sizes.yFinderEnd, sizes.mainWidth + 1, 1, colors.leftBar, 0xffffff, " ")
  268. --Создаем переменную строки истории
  269. local historyString = workPathHistory[currentWorkPathHistoryElement]
  270. if historyString == "" or historyString == "/" then
  271. historyString = "Root"
  272. else
  273. historyString = string.gsub(historyString, "/", " ► ")
  274. if unicode.sub(historyString, -3, -1) == " ► " then
  275. historyString = "Root ► " .. unicode.sub(historyString, 1, -4)
  276. end
  277. end
  278. --Рисуем ее
  279. buffer.text(sizes.xMain + 1, sizes.yFinderEnd, colors.topText, ecs.stringLimit("start", historyString, sizes.mainWidth - 2))
  280. end
  281.  
  282. local function drawAll(force)
  283. drawTopBar()
  284. drawLeftBar()
  285. drawMain()
  286. drawBottomBar()
  287. buffer.draw(force)
  288. end
  289.  
  290. local function getListAndDrawAll()
  291. getFileList()
  292. drawAll()
  293. end
  294.  
  295. local function fullRefresh()
  296. getFileList()
  297. buffer.paste(1, 1, oldPixelsOfFullScreen)
  298. drawAll(true)
  299. end
  300.  
  301. local function openModem()
  302. if component.isAvailable("modem") then component.modem.open(port) end
  303. end
  304.  
  305. local function sendPersonalInfo(sendAgain)
  306. if component.isAvailable("modem") then component.modem.broadcast(port, sendAgain and "addMeToListToo" or "addMeToList") end
  307. end
  308.  
  309. local function sendMessageOrFileWindow(text1, text2)
  310. return ecs.universalWindow("auto", "auto", 36, 0x262626, true,
  311. {"EmptyLine"},
  312. {"CenterText", ecs.colors.orange, text1},
  313. {"EmptyLine"},
  314. {"Input", 0xFFFFFF, ecs.colors.orange, text2},
  315. {"EmptyLine"},
  316. {"Button", {ecs.colors.orange, 0xffffff, "OK"}, {0x999999, 0xffffff, MineOSCore.localization.cancel}}
  317. )
  318. end
  319.  
  320. local function sendFile(path, address)
  321. --Отправляем сообщение о том, что мы собираемся отправить файл
  322. component.modem.send(address, port, "FILESTARTED", fs.name(path))
  323. local maxPacketSize = component.modem.maxPacketSize() - 32
  324. local file = io.open(path, "rb")
  325. local fileSize = fs.size(path)
  326. local percent = 0
  327. local sendedBytes = 0
  328. local dataToSend
  329.  
  330. while true do
  331. dataToSend = file:read(maxPacketSize)
  332. if dataToSend then
  333. component.modem.send(address, port, "FILESEND", dataToSend, percent)
  334. sendedBytes = sendedBytes + maxPacketSize
  335. percent = math.floor(sendedBytes / fileSize * 100)
  336. else
  337. break
  338. end
  339. end
  340.  
  341. file:close()
  342. component.modem.send(address, port, "FILESENDEND")
  343. GUI.error(MineOSCore.localization.fileSuccessfullySent)
  344. end
  345.  
  346. ----------------------------------------------------------------------------------------------------------------------------------
  347.  
  348. local args = {...}
  349. -- buffer.start()
  350. -- buffer.clear(0xFF6666)
  351.  
  352. oldPixelsOfFullScreen = buffer.copy(1, 1, buffer.screen.width, buffer.screen.height)
  353. calculateSizes()
  354. loadConfig()
  355. createDisks()
  356. changePath(args[1] == "open" and (args[2] or "") or "")
  357. drawAll()
  358. openModem()
  359. sendPersonalInfo()
  360.  
  361. local xDrag, yDrag
  362. while true do
  363. local eventData = {event.pull()}
  364. if eventData[1] == "drag" and obj.topBarZone:isClicked(eventData[3], eventData[4]) then
  365. local xMove, yMove = eventData[3] - xDrag, eventData[4] - yDrag
  366. xDrag, yDrag = eventData[3], eventData[4]
  367. local xFinder, yFinder = sizes.xFinder + xMove, sizes.yFinder + yMove
  368. if xFinder >= 1 and yFinder >= 1 and xFinder + sizes.finderWidth - 1 <= buffer.screen.width and yFinder + sizes.finderHeight - 1 <= buffer.screen.height then
  369. calculateSizes(xFinder, yFinder)
  370. buffer.paste(1, 1, oldPixelsOfFullScreen)
  371. drawAll()
  372. end
  373. elseif eventData[1] == "touch" then
  374. xDrag, yDrag = eventData[3], eventData[4]
  375. local clickedAtEmptyArea = true
  376.  
  377. if clickedAtEmptyArea and obj.topBarZone:isClicked(eventData[3], eventData[4]) then
  378. if obj.historyBack:isClicked(eventData[3], eventData[4]) then
  379. obj.historyBack:pressAndRelease(0.2)
  380. currentWorkPathHistoryElement = currentWorkPathHistoryElement - 1
  381. sizes.yFileList = sizes.yFileListStartPoint
  382. getListAndDrawAll()
  383. elseif obj.historyForward:isClicked(eventData[3], eventData[4]) then
  384. obj.historyForward:pressAndRelease(0.2)
  385. currentWorkPathHistoryElement = currentWorkPathHistoryElement + 1
  386. sizes.yFileList = sizes.yFileListStartPoint
  387. getListAndDrawAll()
  388. elseif obj.search:isClicked(eventData[3], eventData[4]) then
  389. searchBarText = ""
  390. searchBarText = drawSearchBar(false)
  391. if searchBarText == "" then searchBarText = nil end
  392. sizes.yFileList = sizes.yFileListStartPoint
  393. getListAndDrawAll()
  394. elseif obj.windowActionButtons.close:isClicked(eventData[3], eventData[4]) then
  395. obj.windowActionButtons.close:pressAndRelease(0.2)
  396. return
  397. elseif obj.showFormat:isClicked(eventData[3], eventData[4]) then
  398. config.showFileFormat = not config.showFileFormat
  399. saveConfig()
  400. getListAndDrawAll()
  401. elseif obj.showHidden:isClicked(eventData[3], eventData[4]) then
  402. config.showHiddenFiles = not config.showHiddenFiles
  403. saveConfig()
  404. getListAndDrawAll()
  405. elseif obj.sortingMethod:isClicked(eventData[3], eventData[4]) then
  406. obj.sortingMethod:pressAndRelease(0.2)
  407. local data = ecs.universalWindow("auto", "auto", 36, 0x262626, true,
  408. {"EmptyLine"},
  409. {"CenterText", ecs.colors.orange, MineOSCore.localization.sortingMethod},
  410. {"EmptyLine"},
  411. {"Selector", 0xFFFFFF, ecs.colors.orange, MineOSCore.localization.sortByTypeShort, MineOSCore.localization.sortByNameShort, MineOSCore.localization.sortByDateShort},
  412. {"EmptyLine"},
  413. {"Button", {ecs.colors.orange, 0xffffff, "OK"}, {0x999999, 0xffffff, MineOSCore.localization.cancel}}
  414. )
  415. if data[2] == "OK" then
  416. config.currentSortingMethod = sortingMethods[data[1]]
  417. saveConfig()
  418. getListAndDrawAll()
  419. end
  420. end
  421.  
  422. clickedAtEmptyArea = false
  423. end
  424.  
  425. if clickedAtEmptyArea then
  426. if obj.networkMessage and obj.networkMessage:isClicked(eventData[3], eventData[4]) then
  427. obj.networkMessage:pressAndRelease(0.2)
  428. local data = sendMessageOrFileWindow(MineOSCore.localization.sendMessage, MineOSCore.localization.messageText)
  429. if data[2] == "OK" then
  430. component.modem.send(currentNetworkAddress, port, "hereIsMessage", data[1])
  431. end
  432. clickedAtEmptyArea = false
  433. elseif obj.networkFile and obj.networkFile:isClicked(eventData[3], eventData[4]) then
  434. obj.networkFile:pressAndRelease(0.2)
  435. local data = sendMessageOrFileWindow(MineOSCore.localization.sendFile, MineOSCore.localization.pathToFile)
  436. if data[2] == "OK" then
  437. if fs.exists(data[1]) then
  438. sendFile(data[1], currentNetworkAddress)
  439. else
  440. GUI.error("Файл не существует")
  441. end
  442. end
  443. clickedAtEmptyArea = false
  444. end
  445. end
  446.  
  447. if clickedAtEmptyArea then
  448. for _, item in pairs(obj.leftBarItems) do
  449. if item:isClicked(eventData[3], eventData[4]) then
  450. changePath(item.path)
  451. drawAll()
  452. clickedAtEmptyArea = false
  453. break
  454. end
  455. end
  456. end
  457.  
  458. if clickedAtEmptyArea then
  459. for address, item in pairs(obj.network) do
  460. if item:isClicked(eventData[3], eventData[4]) then
  461. currentNetworkAddress = address
  462. drawMain(true)
  463. buffer.draw()
  464. obj.DesktopIcons = nil
  465. clickedAtEmptyArea = false
  466. break
  467. end
  468. end
  469. end
  470.  
  471. if clickedAtEmptyArea and obj.DesktopIcons then
  472. for _, icon in pairs(obj.DesktopIcons) do
  473. if icon:isClicked(eventData[3], eventData[4]) then
  474. buffer.setDrawLimit(sizes.xMain, sizes.yMain, sizes.mainWidth, sizes.mainHeight)
  475. if MineOSCore.iconClick(icon, eventData, colors.selection, nil, 0xFFFFFF, 0.2, config.showFileFormat, {method = getListAndDrawAll, arguments = {}}, {method = fullRefresh, arguments = {}}, {method = changePath, arguments = {icon.path}}) then return end
  476. buffer.resetDrawLimit()
  477. drawTopBar()
  478. buffer.draw()
  479. clickedAtEmptyArea = false
  480. break
  481. end
  482. end
  483. end
  484.  
  485. if clickedAtEmptyArea and obj.DesktopIcons and eventData[5] == 1 and obj.mainZone:isClicked(eventData[3], eventData[4]) then
  486. MineOSCore.emptyZoneClick(eventData, workPathHistory[currentWorkPathHistoryElement], {method = getListAndDrawAll, arguments = {}})
  487. end
  488. elseif eventData[1] == "scroll" then
  489. if obj.mainZone:isClicked(eventData[3], eventData[4]) then
  490. if eventData[5] == 1 then
  491. if sizes.yFileList < sizes.yFileListStartPoint then
  492. sizes.yFileList = sizes.yFileList + scrollSpeed
  493. drawMain(); drawBottomBar(); buffer.draw()
  494. end
  495. else
  496. if sizes.fromIcon < #fileList - sizes.xCountOfIcons then
  497. sizes.yFileList = sizes.yFileList - scrollSpeed
  498. drawMain(); drawBottomBar(); buffer.draw()
  499. end
  500. end
  501. end
  502. elseif eventData[1] == "modem_message" then
  503. local localAddress, remoteAddress, remotePort, distance, message1, message2 = eventData[2], eventData[3], eventData[4], eventData[5], eventData[6], eventData[7]
  504. local truncatedRemoteAddress = unicode.sub(remoteAddress, 1, 5)
  505. if remotePort == port then
  506. if message1 == "addMeToList" then
  507. sendPersonalInfo(true)
  508. network[remoteAddress] = true
  509. drawAll()
  510. elseif message1 == "addMeToListToo" then
  511. network[remoteAddress] = true
  512. drawAll()
  513. elseif message1 == "hereIsMessage" then
  514. GUI.error(message2, {title = {color = 0xFFDB40, text = MineOSCore.localization.gotMessageFrom .. truncatedRemoteAddress}})
  515. elseif message1 == "FILESTARTED" then
  516. _G.finderFileReceiver = io.open("MineOS/System/Finder/tempFile.lua", "wb")
  517. elseif message1 == "FILESEND" then
  518. _G.finderFileReceiver:write(message2)
  519. elseif message1 == "FILESENDEND" then
  520. _G.finderFileReceiver:close()
  521. local data = sendMessageOrFileWindow(MineOSCore.localization.gotFileFrom .. truncatedRemoteAddress, MineOSCore.localization.pathToSave)
  522. if data[2] == "OK" and data[1] ~= "" then fs.rename("MineOS/System/Finder/tempFile.lua", data[1]); getListAndDrawAll() end
  523. end
  524. end
  525. end
  526. end
Advertisement
Add Comment
Please, Sign In to add comment