From 6c5e7afb7ea53b5d31b2a28d05a251c5dea6b00f Mon Sep 17 00:00:00 2001 From: Smok1e <33802666+Smok1e@users.noreply.github.com> Date: Tue, 18 Jun 2024 11:54:41 +0300 Subject: [PATCH] Screenshots --- Libraries/English.lang | 127 +++++++++++++++++++++++++++++++++++++++ Libraries/Russian.lang | 127 +++++++++++++++++++++++++++++++++++++++ Libraries/System.lua | 131 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 385 insertions(+) create mode 100644 Libraries/English.lang create mode 100644 Libraries/Russian.lang diff --git a/Libraries/English.lang b/Libraries/English.lang new file mode 100644 index 00000000..40f5ec60 --- /dev/null +++ b/Libraries/English.lang @@ -0,0 +1,127 @@ +{ + downloading = "Downloading in progress", + CPUArchitecture = "CPU architecture", + RAMControl = "RAM control", + packageUnloading = "Automatic unloading", + networkFTPNewConnection = "FTP-connection", + networkFTPConnections = "FTP-connections", + networkFTPAddress = "Server address", + networkFTPPort = "Server port", + networkFTPUser = "User", + networkFTPPassword = "Password", + updatingFileList = "Updating file list...", + network = "Network", + networkTimeout = "Remote computer is not responding", + networkAccessDenied = "Access to the filesystem of the remote computer is denied. Contact it's owner to get appropriate privileges", + networkAllowReadAndWrite = "Filesystem access", + networkModemNotAvailable = "Attach modem to use network functions", + networkState = "Enable network mode", + networkComputers = "Network PCs options", + networkName = "Name of this PC", + networkSearchRadius = "Searching radius", + openWith = "Open with", + select = "Choose application…", + keepInDock = "Keep in dock", + closeAllWindows = "Close all windows", + closeWindow = "Close", + newWindow = "New window", + launch = "Launch", + launchWithArguments = "Launch with arguments", + dontShowAnymore = "Don't show again", + newName = "New name", + folderName = "Folder name", + fileName = "File name", + applicationName = "Application name", + file = "File", + notExists = "not exists", + alreadyExists = "already exists", + inDirectory = "in folder", + needReplace = "Replace it?", + yes = "Yes", + no = "No", + cancel = "Cancel", + open = "Open", + save = "Save", + applyToAll = "Apply to all", + toDirectory = "to folder", + copying = "Copying", + faylaBlyad = "file", + + areYouSure = "Are you sure?", + emptyTrash = "Empty trash", + type = "Type", + size = "Size", + date = "Date", + name = "Name", + path = "Path", + folder = "Folder", + unknown = "Unknown", + calculatingSize = "calculating…", + filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", + + properties = "Properties", + newFolderFromChosen = "New folder from chosen", + create = "New", + newFolder = "Folder", + newFile = "File", + newFileFromURL = "File from URL", + newImage = "Image", + newApplication = "MineOS application", + paste = "Paste", + copy = "Copy", + cut = "Cut", + edit = "Edit", + editInPhotoshop = "Edit in Photoshop", + rename = "Rename", + editShortcut = "Edit shortcut", + createShortcut = "Create shortcut", + deleteWithSource = "Delete with source", + addToDock = "Add to Dock", + removeFromDock = "Remove from Dock", + moveRight = "Move right", + moveLeft = "Move left", + archive = "Add to archive", + delete = "Delete", + addToFavourites = "Add to favourites", + removeFromFavourites = "Remove from favourites", + setAsWallpaper = "Set as wallpaper", + showPackageContent = "Show package content", + showContainingFolder = "Show containing folder", + flashEEPROM = "Flash to EEPROM", + flashingEEPROM = "Flashing in progress. Don't turn off computer...", + print3D = "Print model", + + sortBy = "Sort", + sortByType = "By type", + sortByName = "By name", + sortByDate = "By date", + + aboutSystem = "About system", + updates = "Updates", + update = "Refresh", + shutdown = "Shutdown", + logout = "Logout", + reboot = "Reboot", + takeScreenshot = "Take screenshot", + + shortcutIsCorrupted = "Shortcut is linked to non-existent file", + sortAutomatically = "Align to grid", + onDesktop = "On desktop", + inCurrentDirectory = "In current folder", + + errorWhileRunningProgram = "Error while running ", + yourContacts = "Your contacts", + additionalInfo = "Additional information", + stackTraceback = "Stack traceback", + + favourite = "Favourite", + search = "Search", + mounts = "Mounts", + + uploadToPastebin = "Upload to Pastebin", + pasteName = "Paste name", + uploading = "Uploading in progress...", + uploadingSuccess = "Uploaded to ", + uploadingFailure = "Uploading failed: ", +} \ No newline at end of file diff --git a/Libraries/Russian.lang b/Libraries/Russian.lang new file mode 100644 index 00000000..8e85e779 --- /dev/null +++ b/Libraries/Russian.lang @@ -0,0 +1,127 @@ +{ + downloading = "Идет загрузка файла", + CPUArchitecture = "Архитектура ЦП", + RAMControl = "Управление памятью", + packageUnloading = "Автоматическая выгрузка", + networkFTPNewConnection = "FTP-подключение", + networkFTPConnections = "FTP-подключения", + networkFTPAddress = "Адрес сервера", + networkFTPPort = "Порт сервера", + networkFTPUser = "Пользователь", + networkFTPPassword = "Пароль", + updatingFileList = "Обновление списка файлов...", + network = "Сеть", + networkTimeout = "Удаленный компьютер не ответил на запрос", + networkAccessDenied = "Доступ к файловой системе удаленного компьютера запрещен. Свяжитесь с его владельцем для предоставления соответствующих привилегий", + networkAllowReadAndWrite = "Доступ к файлам", + networkModemNotAvailable = "Подключите модем для использования сетевых функций", + networkState = "Включить сетевой режим", + networkComputers = "Параметры удаленных ПК", + networkName = "Имя данного ПК", + networkSearchRadius = "Радиус обнаружения", + openWith = "Открыть с помощью", + select = "Выбрать программу…", + keepInDock = "Оставить в Dock", + closeAllWindows = "Закрыть все окна", + closeWindow = "Закрыть", + newWindow = "Новое окно", + launch = "Запустить", + launchWithArguments = "Запустить с аргументами", + dontShowAnymore = "Больше не показывать", + newName = "Новое имя", + folderName = "Имя папки", + fileName = "Имя файла", + applicationName = "Имя приложения", + file = "Файл", + notExists = "не существует", + alreadyExists = "уже существует", + inDirectory = "в директории", + needReplace = "Заменить?", + yes = "Да", + no = "Нет", + cancel = "Отмена", + open = "Открыть", + save = "Сохранить", + applyToAll = "Применить ко всем", + toDirectory = "в директории", + copying = "Копирование", + faylaBlyad = "файла", + + areYouSure = "Вы уверены?", + emptyTrash = "Очистить корзину", + type = "Тип", + size = "Размер", + date = "Дата", + name = "Имя", + path = "Путь", + folder = "Папка", + unknown = "Неизвестно", + calculatingSize = "идет подсчет…", + filesWillBeRemovedPermanently = "файл(ов) будет удалено безвозвратно", + fileDeletingFailure = "Ошибка при удалении файла", + + properties = "Свойства", + newFolderFromChosen = "Новая папка из выбранного", + create = "Создать", + newFolder = "Папку", + newFile = "Файл", + newFileFromURL = "Файл по URL", + newImage = "Изображение", + newApplication = "Приложение MineOS", + paste = "Вставить", + copy = "Копировать", + cut = "Вырезать", + edit = "Редактировать", + editInPhotoshop = "Редактировать в Photoshop", + rename = "Переименовать", + editShortcut = "Редактировать ярлык", + createShortcut = "Создать ярлык", + deleteWithSource = "Удалить с источником", + addToDock = "Добавить в Dock", + removeFromDock = "Удалить из Dock", + moveRight = "Передвинуть правее", + moveLeft = "Передвинуть левее", + archive = "Добавить в архив", + delete = "Удалить", + addToFavourites = "Добавить в избранное", + removeFromFavourites = "Удалить из избранного", + setAsWallpaper = "Установить как обои", + showPackageContent = "Показать содержимое пакета", + showContainingFolder = "Открыть содержащую папку", + flashEEPROM = "Записать на EEPROM", + flashingEEPROM = "Идет запись на EEPROM. Не отключайте компьютер...", + print3D = "Распечатать модель", + + sortBy = "Упорядочить", + sortByType = "По типу", + sortByName = "По имени", + sortByDate = "По дате", + + aboutSystem = "О системе", + updates = "Обновления", + update = "Обновить", + shutdown = "Выключить", + logout = "Выйти", + reboot = "Перезагрузить", + takeScreenshot = "Сделать скриншот", + + shortcutIsCorrupted = "Ярлык ссылается на несуществующий файл", + sortAutomatically = "Привязать к сетке", + onDesktop = "На рабочем столе", + inCurrentDirectory = "В текущей директории", + + errorWhileRunningProgram = "Ошибка при выполнении ", + yourContacts = "Ваши контакты", + additionalInfo = "Дополнительная информация", + stackTraceback = "Стек ошибки", + + favourite = "Избранное", + search = "Поиск", + mounts = "Устройства", + + uploadToPastebin = "Загрузить на Pastebin", + pasteName = "Имя файла после загрузки", + uploading = "Идет загрузка файла...", + uploadingSuccess = "Загружено по ссылке ", + uploadingFailure = "Ошибка при загрузке: ", +} \ No newline at end of file diff --git a/Libraries/System.lua b/Libraries/System.lua index 778cd2d4..8966036e 100755 --- a/Libraries/System.lua +++ b/Libraries/System.lua @@ -325,6 +325,133 @@ end -------------------------------------------------------------------------------- +local function copyScreenToImage(x0, y0, width, height) + local screenWidth, screenHeight = screen.getResolution() + local img = {width, height} + + local backgrounds, foregrounds, chars, i = screen.getCurrentFrameTables() + for y = y0, y0 + height - 1 do + for x = x0, x0 + width - 1 do + i = screen.getIndex(x, y) + + table.insert(img, backgrounds[i]) + table.insert(img, foregrounds[i]) + table.insert(img, 0x0) + table.insert(img, chars[i]) + end + end + + return img +end + +function system.takeScreenshot() + local selection = workspace:addChild(GUI.object(1, 1, workspace.width, workspace.height)) + + selection.updateSelection = function(selection, x1, y1) + local x0, y0 = selection.startX, selection.startY + + if x0 > x1 then x0, x1 = x1, x0 end + if y0 > y1 then y0, y1 = y1, y0 end + + selection.selX, selection.selY = x0, y0 + selection.selWidth, selection.selHeight = x1 - x0 + 1, y1 - y0 + 1 + end + + selection.startX = math.floor(selection.width / 4) + selection.startY = math.floor(selection.height / 4) + selection:updateSelection(3 * selection.startX, 3 * selection.startY) + + local screenFrameBackgrounds, screenFrameForegrounds, screenFrameChars = screen.getNewFrameTables() + local screenBufferWidth, screenBufferHeight = screen.getResolution() + + local function drawBorder(x0, y0, width, height, char) + for x = x0, x0 + width - 1 do + for y = y0, y0 + height - 1 do + if x >= 1 and y >= 1 and x < screenBufferWidth and y < screenBufferHeight then + i = screen.getIndex(x, y) + screenFrameForegrounds[i], screenFrameChars[i] = 0xFFFFFF, char + end + end + end + end + + local function drawTextCentered(x, y, text) + screen.drawText(math.floor(x - #text / 2), y, 0xFFFFFF, text) + end + + local selectionOutsideTransparency = userSettings.interfaceTransparencyEnabled and 0.2 or nil + + local function fill(x, y, width, height) + screen.drawRectangle(x, y, width, height, 0, 0, " ", selectionOutsideTransparency) + end + + selection.draw = function(selection) + local + x, y, width, height, workspaceWidth, workspaceHeight = + selection.selX, selection.selY, selection.selWidth, selection.selHeight, selection.width, selection.height + + -- Fill area outside selection + fill(1, 1, x - 1, workspaceHeight ) + fill(x + width, 1, workspaceWidth - width - x + 1, workspaceHeight ) + fill(x, 1, width, y - 1 ) + fill(x, y + height, width, workspaceHeight - height - y + 2) + + -- Border + drawBorder(x, y - 1, width, 1, '⣀') + drawBorder(x, y + height, width, 1, '⠉') + drawBorder(x - 1, y, 1, height, '⢸') + drawBorder(x + width, y, 1, height, '⡇') + + drawTextCentered(x + width / 2, y + height + 1, ("%dx%d"):format(width, height)) + end + + selection.submit = function(selection) + selection:remove() + local img = copyScreenToImage(selection.selX, selection.selY, selection.selWidth, selection.selHeight) + + local filesystemDialog = GUI.addFilesystemDialog( + workspace, + false, + 50, + math.floor(workspace.height * 0.8), + localization.save, + localization.cancel, + localization.fileName, + "/" + ) + + filesystemDialog:setMode(GUI.IO_MODE_SAVE, GUI.IO_MODE_FILE) + filesystemDialog:addExtensionFilter(".pic") + filesystemDialog:expandPath(paths.user.desktop) + filesystemDialog.filesystemTree.selectedItem = paths.user.desktop + + filesystemDialog.onSubmit = function(path) + image.save(path, img) + computer.pushSignal("system", "updateFileList") + end + + filesystemDialog:show() + end + + selection.eventHandler = function(workspace, selection, eventType, _, e1, e2) + if eventType == "touch" then + selection.startX, selection.startY = e1, e2 + selection:updateSelection(e1, e2) + + elseif eventType == "drag" then + selection:updateSelection(e1, e2) + + elseif eventType == "key_down" then + if e2 == 28 then -- Enter + selection:submit() + elseif e2 == 15 then -- Tab + selection:remove() + end + end + end +end + +-------------------------------------------------------------------------------- local function addMainDesktopMenuItem(menu) local item = menu:addContextMenuItem("💻", 0xF0F0F0) @@ -380,6 +507,10 @@ local function addMainDesktopMenuItem(menu) system.execute(paths.system.applicationAppMarket, "updates") end + item:addItem("📸", localization.takeScreenshot).onTouch = function() + system.takeScreenshot() + end + item:addSeparator() local logoutItems = {"🥰", "😭", "😎", "🥺", "🤔", "🤓"}