This commit is contained in:
Igor Timofeev 2016-07-14 02:30:52 +03:00
parent f7101d0bb3
commit d6a3ca108e
9 changed files with 423 additions and 1738 deletions

View File

@ -267,12 +267,25 @@
----------------------------------------------------- Библиотеки -------------------------------------------------------------------------- ----------------------------------------------------- Библиотеки --------------------------------------------------------------------------
{
name="lib/MineOSCore.lua",
url="IgorTimofeev/OpenComputers/master/lib/MineOSCore.lua",
type="Library",
version=1.18,
},
{
name="lib/advancedLua.lua",
url="IgorTimofeev/OpenComputers/master/lib/advancedLua.lua",
type="Library",
preLoadFile=true,
version=1.00,
},
{ {
name="lib/ECSAPI.lua", name="lib/ECSAPI.lua",
url="IgorTimofeev/OpenComputers/master/lib/ECSAPI.lua", url="IgorTimofeev/OpenComputers/master/lib/ECSAPI.lua",
type="Library", type="Library",
preLoadFile=true, preLoadFile=true,
version=1.02, version=1.03,
}, },
{ {
name="lib/colorlib.lua", name="lib/colorlib.lua",
@ -295,17 +308,11 @@
preLoadFile=true, preLoadFile=true,
version=1.0, version=1.0,
}, },
{
name="lib/MineOSCore.lua",
url="IgorTimofeev/OpenComputers/master/lib/MineOSCore.lua",
type="Library",
version=1.17,
},
{ {
name="lib/GUI.lua", name="lib/GUI.lua",
url="IgorTimofeev/OpenComputers/master/lib/GUI.lua", url="IgorTimofeev/OpenComputers/master/lib/GUI.lua",
type="Library", type="Library",
version=1.11, version=1.12,
}, },
{ {
name="lib/serialization.lua", name="lib/serialization.lua",
@ -317,7 +324,7 @@
name="lib/rayEngine.lua", name="lib/rayEngine.lua",
url="IgorTimofeev/OpenComputers/master/lib/rayEngine.lua", url="IgorTimofeev/OpenComputers/master/lib/rayEngine.lua",
type="Library", type="Library",
version=1.32, version=1.33,
}, },
{ {
name="lib/doubleHeight.lua", name="lib/doubleHeight.lua",
@ -513,7 +520,7 @@
type="Application", type="Application",
icon="IgorTimofeev/OpenComputers/master/Applications/VK/Icon.pic", icon="IgorTimofeev/OpenComputers/master/Applications/VK/Icon.pic",
createShortcut="dock", createShortcut="dock",
version=1.2, version=1.21,
resources={ resources={
{ {
name="VKLogo.pic", name="VKLogo.pic",
@ -908,7 +915,7 @@
icon="IgorTimofeev/OpenComputers/master/Applications/AppMarket/Icon.pic", icon="IgorTimofeev/OpenComputers/master/Applications/AppMarket/Icon.pic",
createShortcut="dock", createShortcut="dock",
forceDownload=true, forceDownload=true,
version=1.44, version=1.45,
resources={ resources={
{ {
name="Localization/Russian.lang", name="Localization/Russian.lang",

View File

@ -3,6 +3,7 @@
-- _G.GUI = nil -- _G.GUI = nil
local libraries = { local libraries = {
advancedLua = "advancedLua",
buffer = "doubleBuffering", buffer = "doubleBuffering",
MineOSCore = "MineOSCore", MineOSCore = "MineOSCore",
image = "image", image = "image",
@ -128,7 +129,7 @@ local function getApplication(i)
if newApplications[i].about then if newApplications[i].about then
currentApps[i].description = getDescription(newApplications.GitHubUserURL .. newApplications[i].about .. _G.OSSettings.language .. ".txt") currentApps[i].description = getDescription(newApplications.GitHubUserURL .. newApplications[i].about .. _G.OSSettings.language .. ".txt")
currentApps[i].description = ecs.stringWrap({currentApps[i].description}, sizes.descriptionTruncateSize ) currentApps[i].description = string.wrap({currentApps[i].description}, sizes.descriptionTruncateSize )
else else
currentApps[i].description = {localization.descriptionNotAvailable} currentApps[i].description = {localization.descriptionNotAvailable}
end end
@ -328,7 +329,6 @@ local function updateAll()
changes = {} changes = {}
oldApplications = newApplications oldApplications = newApplications
saveOldApplications() saveOldApplications()
require("computer").shutdown(true)
end end
------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------

View File

@ -1,6 +1,7 @@
---------------------------------------------------- Библиотеки ---------------------------------------------------------------- ---------------------------------------------------- Библиотеки ----------------------------------------------------------------
local advancedLua = require("advancedLua")
local json = require("json") local json = require("json")
local serialization = require("serialization") local serialization = require("serialization")
local event = require("event") local event = require("event")
@ -507,7 +508,7 @@ local function messagesGUI()
if messages.response.items[i].attachments then table.insert(messageTextArray, getAttachments(messages.response.items[i])) end if messages.response.items[i].attachments then table.insert(messageTextArray, getAttachments(messages.response.items[i])) end
if messages.response.items[i].action == "chat_invite_user" then table.insert(messageTextArray, "Пользователь под ID " .. messages.response.items[i].from_id .. " пригласил в беседу пользователя под ID " .. messages.response.items[i].action_mid) end if messages.response.items[i].action == "chat_invite_user" then table.insert(messageTextArray, "Пользователь под ID " .. messages.response.items[i].from_id .. " пригласил в беседу пользователя под ID " .. messages.response.items[i].action_mid) end
messageTextArray = ecs.stringWrap(messageTextArray, cloudWidth - 4) messageTextArray = string.wrap(messageTextArray, cloudWidth - 4)
local peerID = getPeerIDFromMessageArray(messages.response.items[i]) local peerID = getPeerIDFromMessageArray(messages.response.items[i])
--Делаем дату пиздатой --Делаем дату пиздатой

View File

@ -1,975 +0,0 @@
{
GitHubUserURL = "https://raw.githubusercontent.com/",
GitHubApplicationListURL = "https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications.txt",
----------------------------------------------------- Все для ОС --------------------------------------------------------------------------
{
["name"]="OS.lua",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/OS.lua",
["type"]="Script",
["version"]=4.0,
},
{
["name"]="MineOS/Pictures/Dayeneris.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Wallpapers/Dayeneris.pic",
["type"]="Wallpaper",
["version"]=5.0,
},
{
["name"]="MineOS/Pictures/Catniss.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Wallpapers/Catniss.pic",
["type"]="Wallpaper",
["version"]=1.0,
},
{
["name"]="MineOS/Pictures/Harp.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Wallpapers/Harp.pic",
["type"]="Wallpaper",
["version"]=1.0,
},
{
["name"]="MineOS/Pictures/Afterlife.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Wallpapers/Afterlife.pic",
["type"]="Wallpaper",
["version"]=1.0,
},
{
["name"]="MineOS/Pictures/Nocturnal.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Wallpapers/Nocturnal.pic",
["type"]="Wallpaper",
["version"]=1.0,
},
{
["name"]="MineOS/Pictures/Ciri.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Wallpapers/Ciri.pic",
["type"]="Wallpaper",
["version"]=1.0,
},
{
["name"]="MineOS/Pictures/Liara.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Wallpapers/Liara.pic",
["type"]="Wallpaper",
["version"]=1.0,
},
{
["name"]="MineOS/Pictures/AhsokaTano.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Wallpapers/AhsokaTano.pic",
["type"]="Wallpaper",
["version"]=1.0,
},
{
["name"]="MineOS/Pictures/StarWars.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Wallpapers/StarWars.pic",
["type"]="Wallpaper",
["version"]=1.0,
},
{
["name"]="MineOS/Pictures/Girl.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Wallpapers/Girl.pic",
["type"]="Wallpaper",
["version"]=1.0,
},
{
["name"]="MineOS/Pictures/TemplarAssassin.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Wallpapers/TemplarAssassin.pic",
["type"]="Wallpaper",
["version"]=6.0,
},
{
["name"]="MineOS/Pictures/Invoker.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Wallpapers/Invoker.pic",
["type"]="Wallpaper",
["version"]=1.0,
},
{
["name"]="MineOS/Pictures/GrammarNazi.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Wallpapers/GrammarNazi.pic",
["type"]="Wallpaper",
["version"]=1.0,
},
{
["name"]="MineOS/Pictures/Jodie.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Wallpapers/Jodie.pic",
["type"]="Wallpaper",
["version"]=1.0,
},
{
["name"]="MineOS/Pictures/Luna.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Wallpapers/Luna.pic",
["type"]="Wallpaper",
["version"]=1.0,
},
{
["name"]="MineOS/Pictures/ChristmasTree.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Wallpapers/ChristmasTree.pic",
["type"]="Wallpaper",
["version"]=1.0,
},
{
["name"]="MineOS/System/OS/Languages/Russian.lang",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Languages/Russian.lang",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/OS/Languages/English.lang",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Languages/English.lang",
["type"]="Script",
["version"]=112.0,
},
----------------------------------------------------- Системные иконки --------------------------------------------------------------------------
{
["name"]="MineOS/System/OS/Icons/3DModel.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/3DModel.pic",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/OS/Icons/Computer.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/Computer.pic",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/OS/Icons/Robot.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/Robot.pic",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/OS/Icons/Tablet.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/Tablet.pic",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/OS/Icons/Pastebin.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/Pastebin.pic",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/OS/Icons/Love.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/Love.pic",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/OS/Icons/HDD.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/HDD.pic",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/OS/Icons/Floppy.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/Floppy.pic",
["type"]="Script",
["version"]=33.0,
},
{
["name"]="MineOS/System/OS/Icons/Steve.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/Steve.pic",
["type"]="Script",
["version"]=14.0,
},
{
["name"]="MineOS/System/OS/Icons/Folder.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/Folder.pic",
["type"]="Script",
["version"]=1.5,
},
{
["name"]="MineOS/System/OS/Icons/Finger.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/Finger.pic",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/OS/Icons/FileNotExists.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/FileNotExists.pic",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/OS/Icons/Script.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/Script.pic",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/OS/Icons/Text.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/Text.pic",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/OS/Icons/Update.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/Update.pic",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/OS/Icons/Security.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/Security.pic",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/OS/Icons/Config.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/Config.pic",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/OS/Icons/Image.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/Image.pic",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/OS/Icons/RawImage.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/RawImage.pic",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/OS/Icons/Lua.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/Lua.pic",
["type"]="Script",
["version"]=1.6,
},
{
["name"]="MineOS/System/OS/Icons/SampleIcon.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/SampleIcon.pic",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/OS/Icons/Archive.pic",
["url"]="IgorTimofeev/OpenComputers/master/MineOS/Icons/Archive.pic",
["type"]="Script",
["version"]=1.0,
},
----------------------------------------------------- Библиотеки --------------------------------------------------------------------------
{
["name"]="lib/MineOSCore.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/MineOSCore.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/GUI.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/GUI.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/serialization.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/serialization.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/rayEngine.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/rayEngine.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/doubleHeight.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/doubleHeight.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/json.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/json.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/filemanager.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/filemanager.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/modemConnection.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/modemConnection.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/bigLetters.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/bigLetters.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/files.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/files.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/libPNGImage.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/libPNGImage.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/crc32lua.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/crc32lua.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/deflatelua.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/deflatelua.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/tetris.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/tetris.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/unixtime.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/unixtime.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/context.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/context.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/syntax.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/syntax.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/palette.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/palette.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/doubleBuffering.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/doubleBuffering.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/thread.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/thread.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/archive.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/archive.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/xmlParser.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/xmlParser.lua",
["type"]="Library",
["version"]=1.0,
},
{
["name"]="lib/SHA2.lua",
["url"]="IgorTimofeev/OpenComputers/master/lib/SHA2.lua",
["type"]="Library",
["version"]=1.0,
},
----------------------------------------------------- Скрипты и дополнения к ним --------------------------------------------------------------------------
{
["name"]="init.lua",
["url"]="IgorTimofeev/OpenComputers/master/Applications/init.lua",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="etc/profile",
["url"]="IgorTimofeev/OpenComputers/master/etc/profile",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="bin/get.lua",
["url"]="IgorTimofeev/OpenComputers/master/Applications/get.lua",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="bin/event.lua",
["url"]="IgorTimofeev/OpenComputers/master/Applications/event.lua",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="bin/clear.lua",
["url"]="IgorTimofeev/OpenComputers/master/Applications/clear.lua",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="bin/scale.lua",
["url"]="IgorTimofeev/OpenComputers/master/Applications/scale.lua",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="usr/misc/greetings/English.txt",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Motd/English.txt",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="usr/misc/greetings/Russian.txt",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Motd/Russian.txt",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="etc/motd",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Motd/motd.lua",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="bin/archive.lua",
["url"]="IgorTimofeev/OpenComputers/master/Applications/archive.lua",
["type"]="Script",
["version"]=1.0,
},
----------------------------------------------------- Приложения без ресурсов --------------------------------------------------------------------------
{
["name"]="MineOS/Applications/Graph",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Graph/Graph.lua",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Graph/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/FlappyBlock",
["url"]="IgorTimofeev/OpenComputers/master/Applications/FlappyBlock/FlappyBlock.lua",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/FlappyBlock/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/MineCode",
["url"]="IgorTimofeev/OpenComputers/master/Applications/MineCode2/MineCode.lua",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/MineCode2/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/Battleship",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Battleship/Battleship.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/Battleship/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Battleship/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/Palette",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Palette/Palette.lua",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Palette/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/Radio",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Radio/Radio.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/Radio/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Radio/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/FuckTheRain",
["url"]="IgorTimofeev/OpenComputers/master/Applications/FuckTheRain/FuckTheRain.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/FuckTheRain/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/FuckTheRain/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/GuessWord",
["url"]="IgorTimofeev/OpenComputers/master/Applications/GuessWord/GuessWord.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/GuessWord/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/GuessWord/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/3DPrint",
["url"]="IgorTimofeev/OpenComputers/master/Applications/3DPrint/3DPrint.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/3DPrint/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/3DPrint/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/ForceAdmin",
["url"]="IgorTimofeev/OpenComputers/master/Applications/ForceAdmin/ForceAdmin.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/ForceAdmin/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/ForceAdmin/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/MineSweeper",
["url"]="IgorTimofeev/OpenComputers/master/Applications/MineSweeper/MineSweeper.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/MineSweeper/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/MineSweeper/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/DanceFloor",
["url"]="IgorTimofeev/OpenComputers/master/Applications/DanceFloor/DanceFloor.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/DanceFloor/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/DanceFloor/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/RunningString",
["url"]="IgorTimofeev/OpenComputers/master/Applications/RunningString/RunningString.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/RunningString/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/RunningString/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/QuantumCube",
["url"]="IgorTimofeev/OpenComputers/master/Applications/QuantumCube/QuantumCube.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/QuantumCube/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/QuantumCube/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/Photoshop",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Photoshop/Photoshop.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/Photoshop/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Photoshop/Icon.pic",
["createShortcut"]="dock",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/Shooting",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Shooting/Shooting.lua",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Shooting/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/Geoscan",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Geoscan/Geoscan.lua",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Geoscan/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/HoloClock",
["url"]="IgorTimofeev/OpenComputers/master/Applications/HoloClock/HoloClock.lua",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/HoloClock/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/Pastebin",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Pastebin/Pastebin.lua",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Pastebin/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/Finder",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Finder/Finder.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/Finder/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Finder/Icon.pic",
["createShortcut"]="dock",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/Control",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Control/Control.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/Control/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Control/Icon.pic",
["createShortcut"]="dock",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/Piano",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Piano/Piano.lua",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Piano/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/Calendar",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Calendar/Calendar.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/Calendar/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Calendar/Icon.pic",
["createShortcut"]="dock",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/Snake",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Snake/Snake.lua",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Snake/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/CodeDoor",
["url"]="IgorTimofeev/OpenComputers/master/Applications/CodeDoor/CodeDoor.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/CodeDoor/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/CodeDoor/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/Keyboard",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Keyboard/Keyboard.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/Keyboard/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Keyboard/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/Nano",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Nano/Nano.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/Nano/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Nano/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/Camera",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Camera/Camera.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/Camera/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Camera/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/Autorun",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Autorun/Autorun.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/Autorun/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Autorun/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/Matrix",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Matrix/Matrix.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/Matrix/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Matrix/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/HEX",
["url"]="IgorTimofeev/OpenComputers/master/Applications/HEX/HEX.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/HEX/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/HEX/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/Applications/ChristmasTree",
["url"]="IgorTimofeev/OpenComputers/master/Applications/ChristmasTree/ChristmasTree.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/ChristmasTree/About.txt",
["type"]="Application",
["createShortcut"]="desktop",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/ChristmasTree/Icon.pic",
["version"]=1.0,
},
-- Приложение InfoPanel
{
["name"]="MineOS/Applications/InfoPanel",
["url"]="IgorTimofeev/OpenComputers/master/Applications/InfoPanel/InfoPanel.lua",
["type"]="Application",
["about"]="IgorTimofeev/OpenComputers/master/Applications/InfoPanel/About.txt",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/InfoPanel/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/System/InfoPanel/Правила",
["url"]="IgorTimofeev/OpenComputers/master/Applications/InfoPanel/Rules.txt",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/InfoPanel/Главная",
["url"]="IgorTimofeev/OpenComputers/master/Applications/InfoPanel/Main.txt",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/InfoPanel/ССПИ",
["url"]="IgorTimofeev/OpenComputers/master/Applications/InfoPanel/SSPI.txt",
["type"]="Script",
["version"]=1.0,
},
{
["name"]="MineOS/System/InfoPanel/Приват",
["url"]="IgorTimofeev/OpenComputers/master/Applications/InfoPanel/Claims.txt",
["type"]="Script",
["version"]=1.0,
},
--Приложение Чат
{
["name"]="MineOS/Applications/Chat",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Chat/Chat.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/Chat/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Chat/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
},
{
["name"]="MineOS/System/Chat/Avatars/MyAvatar.pic",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Chat/MyAvatar.pic",
["type"]="Script",
["version"]=1.0,
},
----------------------------------------------------- Приложения с ресурсами --------------------------------------------------------------------------
{
["name"]="MineOS/Applications/Stargate",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Stargate/Stargate.lua",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Stargate/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
["resources"]={
{
["name"]="Gate.pic",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Stargate/Gate.pic",
},
{
["name"]="GateCore.pic",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Stargate/GateCore.pic",
},
},
},
{
["name"]="MineOS/Applications/VK",
["url"]="IgorTimofeev/OpenComputers/master/Applications/VK/VK.lua",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/VK/Icon.pic",
["createShortcut"]="dock",
["version"]=1.0,
["resources"]={
{
["name"]="VKLogo.pic",
["url"]="IgorTimofeev/OpenComputers/master/Applications/VK/VKLogo.pic",
},
},
},
{
["name"]="MineOS/Applications/TurretControl",
["url"]="IgorTimofeev/OpenComputers/master/Applications/TurretControl/TurretControl.lua",
["type"]="Application",
["about"]="IgorTimofeev/OpenComputers/master/Applications/TurretControl/About.txt",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/TurretControl/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
["resources"]={
{
["name"]="Turret.pic",
["url"]="IgorTimofeev/OpenComputers/master/Applications/TurretControl/Turret.pic",
},
},
},
{
["name"]="MineOS/Applications/FlappyBird",
["url"]="IgorTimofeev/OpenComputers/master/Applications/FlappyBird/FlappyBird.lua",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/FlappyBird/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
["resources"]={
{
["name"]="Flappy.pic",
["url"]="IgorTimofeev/OpenComputers/master/Applications/FlappyBird/Flappy.pic",
},
},
},
{
["name"]="MineOS/Applications/Crossword",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Crossword/Crossword.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/Crossword/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Crossword/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
["resources"]={
{
["name"]="CrosswordFile.txt",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Crossword/CrosswordFile.txt",
},
},
},
{
["name"]="MineOS/Applications/HoloEdit",
["url"]="IgorTimofeev/OpenComputers/master/Applications/HoloEdit/HoloEdit.lua",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/HoloEdit/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
["resources"]={
{
["name"]="Russian.lang",
["url"]="IgorTimofeev/OpenComputers/master/Applications/HoloEdit/Russian.lang",
},
{
["name"]="English.lang",
["url"]="IgorTimofeev/OpenComputers/master/Applications/HoloEdit/English.lang",
},
},
},
{
["name"]="MineOS/Applications/BufferDemo",
["url"]="IgorTimofeev/OpenComputers/master/Applications/BufferDemo/BufferDemo.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/BufferDemo/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/BufferDemo/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
["resources"]={
{
["name"]="Wallpaper.pic",
["url"]="IgorTimofeev/OpenComputers/master/Applications/BufferDemo/Wallpaper.pic",
},
},
},
{
["name"]="MineOS/Applications/Viewer",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Viewer/Viewer.lua",
["about"]="IgorTimofeev/OpenComputers/master/Applications/Viewer/About.txt",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Viewer/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
["resources"]={
{
["name"]="arrowLeft.pic",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Viewer/arrowLeft.pic",
},
{
["name"]="arrowRight.pic",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Viewer/arrowRight.pic",
},
{
["name"]="play.pic",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Viewer/play.pic",
},
},
},
{
["name"]="MineOS/Applications/RayWalk",
["url"]="IgorTimofeev/OpenComputers/master/Applications/RayWalk/RayWalk.lua",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
["resources"]={
{
["name"]="Day.scene",
["url"]="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Day.scene",
},
{
["name"]="Night.scene",
["url"]="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Night.scene",
},
},
},
{
["name"]="MineOS/Applications/Weather",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Weather/Weather.lua",
["type"]="Application",
["icon"]="IgorTimofeev/OpenComputers/master/Applications/Weather/Icon.pic",
["createShortcut"]="desktop",
["version"]=1.0,
["resources"]={
{
["name"]="Cloudy.pic",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Weather/Cloudy.pic",
},
{
["name"]="Cloudy.pic",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Weather/Cloudy.pic",
},
{
["name"]="Rainy.pic",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Weather/Rainy.pic",
},
{
["name"]="Snowy.pic",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Weather/Snowy.pic",
},
{
["name"]="Stormy.pic",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Weather/Stormy.pic",
},
{
["name"]="Sunny.pic",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Weather/Sunny.pic",
},
{
["name"]="SunnyWithClouds.pic",
["url"]="IgorTimofeev/OpenComputers/master/Applications/Weather/SunnyWithClouds.pic",
},
},
},
}

View File

@ -1,26 +1,20 @@
-- Адаптивная загрузка необходимых библиотек и компонентов -- Адаптивная загрузка необходимых библиотек и компонентов
local libraries = { local libraries = {
["component"] = "component", advancedLua = "advancedLua",
["term"] = "term", component = "component",
["unicode"] = "unicode", term = "term",
["event"] = "event", unicode = "unicode",
["fs"] = "filesystem", event = "event",
["shell"] = "shell", fs = "filesystem",
["keyboard"] = "keyboard", shell = "shell",
["computer"] = "computer", keyboard = "keyboard",
["serialization"] = "serialization", computer = "computer",
--["internet"] = "internet", serialization = "serialization",
--["image"] = "image",
} }
local components = { for library in pairs(libraries) do if not _G[library] then _G[library] = require(libraries[library]) end end; libraries = nil
["gpu"] = "gpu", _G.gpu = component.gpu
}
for library in pairs(libraries) do if not _G[library] then _G[library] = require(libraries[library]) end end
for comp in pairs(components) do if not _G[comp] then _G[comp] = _G.component[components[comp]] end end
libraries, components = nil, nil
local ecs = {} local ecs = {}
@ -154,7 +148,7 @@ function ecs.getScaledResolution(scale, debug)
local proportion = xPixels / yPixels local proportion = xPixels / yPixels
--Получаем максимально возможное разрешение данной видеокарты --Получаем максимально возможное разрешение данной видеокарты
local xMax, yMax = gpu.maxResolution() local xMax, yMax = component.gpu.maxResolution()
--Получаем теоретическое максимальное разрешение монитора с учетом его пропорции, но без учета лимита видеокарты --Получаем теоретическое максимальное разрешение монитора с учетом его пропорции, но без учета лимита видеокарты
local newWidth, newHeight local newWidth, newHeight
@ -204,11 +198,11 @@ end
--Установка масштаба монитора --Установка масштаба монитора
function ecs.setScale(scale, debug) function ecs.setScale(scale, debug)
--Устанавливаем выбранное разрешение --Устанавливаем выбранное разрешение
gpu.setResolution(ecs.getScaledResolution(scale, debug)) component.gpu.setResolution(ecs.getScaledResolution(scale, debug))
end end
function ecs.rebindGPU(address) function ecs.rebindGPU(address)
gpu.bind(address) component.gpu.bind(address)
end end
--Получаем всю инфу об оперативку в килобайтах --Получаем всю инфу об оперативку в килобайтах
@ -439,33 +433,33 @@ end
--Заливка всего экрана указанным цветом --Заливка всего экрана указанным цветом
function ecs.clearScreen(color) function ecs.clearScreen(color)
if color then gpu.setBackground(color) end if color then component.gpu.setBackground(color) end
term.clear() term.clear()
end end
--Установка пикселя нужного цвета --Установка пикселя нужного цвета
function ecs.setPixel(x,y,color) function ecs.setPixel(x,y,color)
gpu.setBackground(color) component.gpu.setBackground(color)
gpu.set(x,y," ") component.gpu.set(x,y," ")
end end
--Простая установка цветов в одну строку, ибо я ленивый --Простая установка цветов в одну строку, ибо я ленивый
function ecs.setColor(background, foreground) function ecs.setColor(background, foreground)
gpu.setBackground(background) component.gpu.setBackground(background)
gpu.setForeground(foreground) component.gpu.setForeground(foreground)
end end
--Цветной текст --Цветной текст
function ecs.colorText(x,y,textColor,text) function ecs.colorText(x,y,textColor,text)
gpu.setForeground(textColor) component.gpu.setForeground(textColor)
gpu.set(x,y,text) component.gpu.set(x,y,text)
end end
--Цветной текст с жопкой! --Цветной текст с жопкой!
function ecs.colorTextWithBack(x,y,textColor,backColor,text) function ecs.colorTextWithBack(x,y,textColor,backColor,text)
gpu.setForeground(textColor) component.gpu.setForeground(textColor)
gpu.setBackground(backColor) component.gpu.setBackground(backColor)
gpu.set(x,y,text) component.gpu.set(x,y,text)
end end
--Инверсия цвета --Инверсия цвета
@ -475,12 +469,12 @@ end
--Адаптивный текст, подстраивающийся под фон --Адаптивный текст, подстраивающийся под фон
function ecs.adaptiveText(x,y,text,textColor) function ecs.adaptiveText(x,y,text,textColor)
gpu.setForeground(textColor) component.gpu.setForeground(textColor)
x = x - 1 x = x - 1
for i=1,unicode.len(text) do for i=1,unicode.len(text) do
local info = {gpu.get(x+i,y)} local info = {component.gpu.get(x+i,y)}
gpu.setBackground(info[3]) component.gpu.setBackground(info[3])
gpu.set(x+i,y,unicode.sub(text,i,i)) component.gpu.set(x+i,y,unicode.sub(text,i,i))
end end
end end
@ -514,7 +508,7 @@ function ecs.smartText(x, y, text)
--Разбираем по кусочкам строку и получаем цвета --Разбираем по кусочкам строку и получаем цвета
local massiv = {} local massiv = {}
local iterator = 1 local iterator = 1
local currentColor = gpu.getForeground() local currentColor = component.gpu.getForeground()
while iterator <= sText do while iterator <= sText do
local symbol = unicode.sub(text, iterator, iterator) local symbol = unicode.sub(text, iterator, iterator)
if symbol == specialSymbol then if symbol == specialSymbol then
@ -528,8 +522,8 @@ function ecs.smartText(x, y, text)
end end
x = x - 1 x = x - 1
for i = 1, #massiv do for i = 1, #massiv do
if currentColor ~= massiv[i][2] then currentColor = massiv[i][2]; gpu.setForeground(massiv[i][2]) end if currentColor ~= massiv[i][2] then currentColor = massiv[i][2]; component.gpu.setForeground(massiv[i][2]) end
gpu.set(x + i, y, massiv[i][1]) component.gpu.set(x + i, y, massiv[i][1])
end end
end end
@ -548,14 +542,14 @@ function ecs.formattedText(x, y, text, limit)
--Если находим символ параграфа, то --Если находим символ параграфа, то
if symbols[i] == "§" then if symbols[i] == "§" then
--Меняем цвет текста на указанный --Меняем цвет текста на указанный
gpu.setForeground(tonumber("0x" .. symbols[i+1] .. symbols[i+2] .. symbols[i+3] .. symbols[i+4] .. symbols[i+5] .. symbols[i+6])) component.gpu.setForeground(tonumber("0x" .. symbols[i+1] .. symbols[i+2] .. symbols[i+3] .. symbols[i+4] .. symbols[i+5] .. symbols[i+6]))
--Увеличиваем лимит на 7, т.к. --Увеличиваем лимит на 7, т.к.
limit = limit + 7 limit = limit + 7
--Сдвигаем итератор цикла на 7 --Сдвигаем итератор цикла на 7
i = i + 7 i = i + 7
end end
--Рисуем символ на нужной позиции --Рисуем символ на нужной позиции
gpu.set(xPos, y, symbols[i]) component.gpu.set(xPos, y, symbols[i])
--Увеличиваем позицию курсора и итератор на 1 --Увеличиваем позицию курсора и итератор на 1
xPos = xPos + 1 xPos = xPos + 1
i = i + 1 i = i + 1
@ -564,7 +558,7 @@ end
--Инвертированный текст на основе цвета фона --Инвертированный текст на основе цвета фона
function ecs.invertedText(x,y,symbol) function ecs.invertedText(x,y,symbol)
local info = {gpu.get(x,y)} local info = {component.gpu.get(x,y)}
ecs.adaptiveText(x,y,symbol,ecs.invertColor(info[3])) ecs.adaptiveText(x,y,symbol,ecs.invertColor(info[3]))
end end
@ -586,34 +580,34 @@ end
--Обычный квадрат указанного цвета --Обычный квадрат указанного цвета
function ecs.square(x,y,width,height,color) function ecs.square(x,y,width,height,color)
gpu.setBackground(color) component.gpu.setBackground(color)
gpu.fill(x,y,width,height," ") component.gpu.fill(x,y,width,height," ")
end end
--Юникодовская рамка --Юникодовская рамка
function ecs.border(x, y, width, height, back, fore) function ecs.border(x, y, width, height, back, fore)
local stringUp = ""..string.rep("", width - 2).."" local stringUp = ""..string.rep("", width - 2)..""
local stringDown = ""..string.rep("", width - 2).."" local stringDown = ""..string.rep("", width - 2)..""
gpu.setForeground(fore) component.gpu.setForeground(fore)
gpu.setBackground(back) component.gpu.setBackground(back)
gpu.set(x, y, stringUp) component.gpu.set(x, y, stringUp)
gpu.set(x, y + height - 1, stringDown) component.gpu.set(x, y + height - 1, stringDown)
local yPos = 1 local yPos = 1
for i = 1, (height - 2) do for i = 1, (height - 2) do
gpu.set(x, y + yPos, "") component.gpu.set(x, y + yPos, "")
gpu.set(x + width - 1, y + yPos, "") component.gpu.set(x + width - 1, y + yPos, "")
yPos = yPos + 1 yPos = yPos + 1
end end
end end
--Кнопка в виде текста в рамке --Кнопка в виде текста в рамке
function ecs.drawFramedButton(x, y, width, height, text, color) function ecs.drawFramedButton(x, y, width, height, text, color)
ecs.border(x, y, width, height, gpu.getBackground(), color) ecs.border(x, y, width, height, component.gpu.getBackground(), color)
gpu.fill(x + 1, y + 1, width - 2, height - 2, " ") component.gpu.fill(x + 1, y + 1, width - 2, height - 2, " ")
x = x + math.floor(width / 2 - unicode.len(text) / 2) x = x + math.floor(width / 2 - unicode.len(text) / 2)
y = y + math.floor(width / 2 - 1) y = y + math.floor(width / 2 - 1)
gpu.set(x, y, text) component.gpu.set(x, y, text)
end end
--Юникодовский разделитель --Юникодовский разделитель
@ -624,14 +618,14 @@ end
--Автоматическое центрирование текста по указанной координате (x, y, xy) --Автоматическое центрирование текста по указанной координате (x, y, xy)
function ecs.centerText(mode,coord,text) function ecs.centerText(mode,coord,text)
local dlina = unicode.len(text) local dlina = unicode.len(text)
local xSize,ySize = gpu.getResolution() local xSize,ySize = component.gpu.getResolution()
if mode == "x" then if mode == "x" then
gpu.set(math.floor(xSize/2-dlina/2),coord,text) component.gpu.set(math.floor(xSize/2-dlina/2),coord,text)
elseif mode == "y" then elseif mode == "y" then
gpu.set(coord,math.floor(ySize/2),text) component.gpu.set(coord,math.floor(ySize/2),text)
else else
gpu.set(math.floor(xSize/2-dlina/2),math.floor(ySize/2),text) component.gpu.set(math.floor(xSize/2-dlina/2),math.floor(ySize/2),text)
end end
end end
@ -647,9 +641,9 @@ function ecs.drawCustomImage(x,y,pixels)
for i=1,pixelsHeight do for i=1,pixelsHeight do
for j=1,pixelsWidth do for j=1,pixelsWidth do
if pixels[i][j][3] ~= "#" then if pixels[i][j][3] ~= "#" then
if gpu.getBackground() ~= pixels[i][j][1] then gpu.setBackground(pixels[i][j][1]) end if component.gpu.getBackground() ~= pixels[i][j][1] then component.gpu.setBackground(pixels[i][j][1]) end
if gpu.getForeground() ~= pixels[i][j][2] then gpu.setForeground(pixels[i][j][2]) end if component.gpu.getForeground() ~= pixels[i][j][2] then component.gpu.setForeground(pixels[i][j][2]) end
gpu.set(x+j,y+i,pixels[i][j][3]) component.gpu.set(x+j,y+i,pixels[i][j][3])
end end
end end
end end
@ -659,7 +653,7 @@ end
--Корректировка стартовых координат. Core-функция для всех моих программ --Корректировка стартовых координат. Core-функция для всех моих программ
function ecs.correctStartCoords(xStart,yStart,xWindowSize,yWindowSize) function ecs.correctStartCoords(xStart,yStart,xWindowSize,yWindowSize)
local xSize,ySize = gpu.getResolution() local xSize,ySize = component.gpu.getResolution()
if xStart == "auto" then if xStart == "auto" then
xStart = math.floor(xSize/2 - xWindowSize/2) xStart = math.floor(xSize/2 - xWindowSize/2)
end end
@ -672,7 +666,7 @@ end
--Запомнить область пикселей и возвратить ее в виде массива --Запомнить область пикселей и возвратить ее в виде массива
function ecs.rememberOldPixels(x, y, x2, y2) function ecs.rememberOldPixels(x, y, x2, y2)
local newPNGMassiv = { ["backgrounds"] = {} } local newPNGMassiv = { ["backgrounds"] = {} }
local xSize, ySize = gpu.getResolution() local xSize, ySize = component.gpu.getResolution()
newPNGMassiv.x, newPNGMassiv.y = x, y newPNGMassiv.x, newPNGMassiv.y = x, y
--Перебираем весь массив стандартного PNG-вида по высоте --Перебираем весь массив стандартного PNG-вида по высоте
@ -685,7 +679,7 @@ function ecs.rememberOldPixels(x, y, x2, y2)
error("Can't remember pixel, because it's located behind the screen: x("..i.."), y("..j..") out of xSize("..xSize.."), ySize("..ySize..")\n") error("Can't remember pixel, because it's located behind the screen: x("..i.."), y("..j..") out of xSize("..xSize.."), ySize("..ySize..")\n")
end end
local symbol, fore, back = gpu.get(i, j) local symbol, fore, back = component.gpu.get(i, j)
newPNGMassiv["backgrounds"][back] = newPNGMassiv["backgrounds"][back] or {} newPNGMassiv["backgrounds"][back] = newPNGMassiv["backgrounds"][back] or {}
newPNGMassiv["backgrounds"][back][fore] = newPNGMassiv["backgrounds"][back][fore] or {} newPNGMassiv["backgrounds"][back][fore] = newPNGMassiv["backgrounds"][back][fore] or {}
@ -707,12 +701,12 @@ end
function ecs.drawOldPixels(massivSudaPihay) function ecs.drawOldPixels(massivSudaPihay)
--Перебираем массив с фонами --Перебираем массив с фонами
for back, backValue in pairs(massivSudaPihay["backgrounds"]) do for back, backValue in pairs(massivSudaPihay["backgrounds"]) do
gpu.setBackground(back) component.gpu.setBackground(back)
for fore, foreValue in pairs(massivSudaPihay["backgrounds"][back]) do for fore, foreValue in pairs(massivSudaPihay["backgrounds"][back]) do
gpu.setForeground(fore) component.gpu.setForeground(fore)
for pixel = 1, #massivSudaPihay["backgrounds"][back][fore] do for pixel = 1, #massivSudaPihay["backgrounds"][back][fore] do
if massivSudaPihay["backgrounds"][back][fore][pixel][3] ~= transparentSymbol then if massivSudaPihay["backgrounds"][back][fore][pixel][3] ~= transparentSymbol then
gpu.set(massivSudaPihay.x + massivSudaPihay["backgrounds"][back][fore][pixel][1] - 1, massivSudaPihay.y + massivSudaPihay["backgrounds"][back][fore][pixel][2] - 1, massivSudaPihay["backgrounds"][back][fore][pixel][3]) component.gpu.set(massivSudaPihay.x + massivSudaPihay["backgrounds"][back][fore][pixel][1] - 1, massivSudaPihay.y + massivSudaPihay["backgrounds"][back][fore][pixel][2] - 1, massivSudaPihay["backgrounds"][back][fore][pixel][3])
end end
end end
end end
@ -886,13 +880,13 @@ function ecs.drawTopBar(x, y, width, selectedObject, background, foreground, ...
for i = 1, #objects do for i = 1, #objects do
if i == selectedObject then if i == selectedObject then
ecs.square(xPos, y, unicode.len(objects[i][1]) + spaceBetween, 3, ecs.colors.blue) ecs.square(xPos, y, unicode.len(objects[i][1]) + spaceBetween, 3, ecs.colors.blue)
gpu.setForeground(0xffffff) component.gpu.setForeground(0xffffff)
else else
gpu.setBackground(background) component.gpu.setBackground(background)
gpu.setForeground(foreground) component.gpu.setForeground(foreground)
end end
gpu.set(xPos + spaceBetween / 2, y + 2, objects[i][1]) component.gpu.set(xPos + spaceBetween / 2, y + 2, objects[i][1])
gpu.set(xPos + math.ceil(unicode.len(objects[i][1]) / 2), y + 1, objects[i][2]) component.gpu.set(xPos + math.ceil(unicode.len(objects[i][1]) / 2), y + 1, objects[i][2])
xPos = xPos + unicode.len(objects[i][1]) + spaceBetween xPos = xPos + unicode.len(objects[i][1]) + spaceBetween
end end
@ -908,13 +902,13 @@ function ecs.drawTopMenu(x, y, width, color, selectedObject, ...)
for i = 1, #objects do for i = 1, #objects do
if i == selectedObject then if i == selectedObject then
ecs.square(xPos - 1, y, unicode.len(objects[i][1]) + spaceBetween, 1, ecs.colors.blue) ecs.square(xPos - 1, y, unicode.len(objects[i][1]) + spaceBetween, 1, ecs.colors.blue)
gpu.setForeground(0xffffff) component.gpu.setForeground(0xffffff)
gpu.set(xPos, y, objects[i][1]) component.gpu.set(xPos, y, objects[i][1])
gpu.setForeground(objects[i][2]) component.gpu.setForeground(objects[i][2])
gpu.setBackground(color) component.gpu.setBackground(color)
else else
if gpu.getForeground() ~= objects[i][2] then gpu.setForeground(objects[i][2]) end if component.gpu.getForeground() ~= objects[i][2] then component.gpu.setForeground(objects[i][2]) end
gpu.set(xPos, y, objects[i][1]) component.gpu.set(xPos, y, objects[i][1])
end end
objectsToReturn[objects[i][1]] = { xPos, y, xPos + unicode.len(objects[i][1]) - 1, y, i } objectsToReturn[objects[i][1]] = { xPos, y, xPos + unicode.len(objects[i][1]) - 1, y, i }
xPos = xPos + unicode.len(objects[i][1]) + spaceBetween xPos = xPos + unicode.len(objects[i][1]) + spaceBetween
@ -950,9 +944,9 @@ end
--Отрисовка оконной "тени" --Отрисовка оконной "тени"
function ecs.windowShadow(x,y,width,height) function ecs.windowShadow(x,y,width,height)
gpu.setBackground(ecs.windowColors.shadow) component.gpu.setBackground(ecs.windowColors.shadow)
gpu.fill(x+width,y+1,2,height," ") component.gpu.fill(x+width,y+1,2,height," ")
gpu.fill(x+1,y+height,width,1," ") component.gpu.fill(x+1,y+height,width,1," ")
end end
--Просто белое окошко с тенью --Просто белое окошко с тенью
@ -972,17 +966,17 @@ function ecs.emptyWindow(x,y,width,height,title)
local oldPixels = ecs.rememberOldPixels(x,y,x+width+1,y+height) local oldPixels = ecs.rememberOldPixels(x,y,x+width+1,y+height)
--ОКНО --ОКНО
gpu.setBackground(ecs.windowColors.background) component.gpu.setBackground(ecs.windowColors.background)
gpu.fill(x,y+1,width,height-1," ") component.gpu.fill(x,y+1,width,height-1," ")
--ТАБ СВЕРХУ --ТАБ СВЕРХУ
gpu.setBackground(ecs.windowColors.tab) component.gpu.setBackground(ecs.windowColors.tab)
gpu.fill(x,y,width,1," ") component.gpu.fill(x,y,width,1," ")
--ТИТЛ --ТИТЛ
gpu.setForeground(ecs.windowColors.title) component.gpu.setForeground(ecs.windowColors.title)
local textPosX = x + math.floor(width/2-unicode.len(title)/2) -1 local textPosX = x + math.floor(width/2-unicode.len(title)/2) -1
gpu.set(textPosX,y,title) component.gpu.set(textPosX,y,title)
--ТЕНЬ --ТЕНЬ
ecs.windowShadow(x,y,width,height) ecs.windowShadow(x,y,width,height)
@ -997,66 +991,6 @@ function ecs.getWordsArrayFromString(s)
return words return words
end end
--Функция по переносу слов на новую строку в зависимости от ограничения по ширине
function ecs.stringWrap(strings, limit)
local currentString = 1
while currentString <= #strings do
local words = ecs.getWordsArrayFromString(tostring(strings[currentString]))
local newStringThatFormedFromWords, oldStringThatFormedFromWords = "", ""
local word = 1
local overflow = false
while word <= #words do
oldStringThatFormedFromWords = oldStringThatFormedFromWords .. (word > 1 and " " or "") .. words[word]
if unicode.len(oldStringThatFormedFromWords) > limit then
--ЕБЛО
if unicode.len(words[word]) > limit then
local left = unicode.sub(oldStringThatFormedFromWords, 1, limit)
local right = unicode.sub(strings[currentString], unicode.len(left) + 1, -1)
overflow = true
strings[currentString] = left
if strings[currentString + 1] then
strings[currentString + 1] = right .. " " .. strings[currentString + 1]
else
strings[currentString + 1] = right
end
end
break
else
newStringThatFormedFromWords = oldStringThatFormedFromWords
end
word = word + 1
end
if word <= #words and not overflow then
local fuckToAdd = table.concat(words, " ", word, #words)
if strings[currentString + 1] then
strings[currentString + 1] = fuckToAdd .. " " .. strings[currentString + 1]
else
strings[currentString + 1] = fuckToAdd
end
strings[currentString] = newStringThatFormedFromWords
end
currentString = currentString + 1
end
return strings
-- local firstSlice, secondSlice
-- local i = 1
-- while i <= #strings do
-- if unicode.len(strings[i]) > limit then
-- firstSlice = unicode.sub(strings[i], 1, limit)
-- secondSlice = unicode.sub(strings[i], limit + 1, -1)
-- strings[i] = firstSlice
-- table.insert(strings, i + 1, secondSlice)
-- end
-- i = i + 1
-- end
-- return strings
end
--Моя любимая функция ошибки C: --Моя любимая функция ошибки C:
function ecs.error(...) function ecs.error(...)
local args = {...} local args = {...}
@ -1071,15 +1005,15 @@ function ecs.error(...)
else else
text = tostring(args[1]) text = tostring(args[1])
end end
ecs.universalWindow("auto", "auto", math.ceil(gpu.getResolution() * 0.45), ecs.windowColors.background, true, {"EmptyLine"}, {"CenterText", 0x880000, "Ошибка!"}, {"EmptyLine"}, {"WrappedText", 0x262626, text}, {"EmptyLine"}, {"Button", {0x880000, 0xffffff, "OK!"}}) ecs.universalWindow("auto", "auto", math.ceil(component.gpu.getResolution() * 0.45), ecs.windowColors.background, true, {"EmptyLine"}, {"CenterText", 0x880000, "Ошибка!"}, {"EmptyLine"}, {"WrappedText", 0x262626, text}, {"EmptyLine"}, {"Button", {0x880000, 0xffffff, "OK!"}})
end end
--Очистить экран, установить комфортные цвета и поставить курсок на 1, 1 --Очистить экран, установить комфортные цвета и поставить курсок на 1, 1
function ecs.prepareToExit(color1, color2) function ecs.prepareToExit(color1, color2)
term.setCursor(1, 1) term.setCursor(1, 1)
ecs.clearScreen(color1 or 0x333333) ecs.clearScreen(color1 or 0x333333)
gpu.setForeground(color2 or 0xffffff) component.gpu.setForeground(color2 or 0xffffff)
gpu.set(1, 1, "") component.gpu.set(1, 1, "")
end end
--Конвертация из юникода в символ. Вроде норм, а вроде и не норм. Но полезно. --Конвертация из юникода в символ. Вроде норм, а вроде и не норм. Но полезно.
@ -1125,9 +1059,9 @@ function ecs.inputText(x, y, limit, cheBiloVvedeno, background, foreground, just
background = background or 0xffffff background = background or 0xffffff
foreground = foreground or 0x000000 foreground = foreground or 0x000000
gpu.setBackground(background) component.gpu.setBackground(background)
gpu.setForeground(foreground) component.gpu.setForeground(foreground)
gpu.fill(x, y, limit, 1, " ") component.gpu.fill(x, y, limit, 1, " ")
local text = cheBiloVvedeno local text = cheBiloVvedeno
@ -1139,9 +1073,9 @@ function ecs.inputText(x, y, limit, cheBiloVvedeno, background, foreground, just
if xCursor > (x + limit - 1) then xCursor = (x + limit - 1) end if xCursor > (x + limit - 1) then xCursor = (x + limit - 1) end
if maskTextWith then if maskTextWith then
gpu.set(x, y, ecs.stringLimit("start", string.rep("", dlina), limit)) component.gpu.set(x, y, ecs.stringLimit("start", string.rep("", dlina), limit))
else else
gpu.set(x, y, ecs.stringLimit("start", text, limit)) component.gpu.set(x, y, ecs.stringLimit("start", text, limit))
end end
term.setCursor(xCursor, y) term.setCursor(xCursor, y)
@ -1159,7 +1093,7 @@ function ecs.inputText(x, y, limit, cheBiloVvedeno, background, foreground, just
if e[4] == 14 then if e[4] == 14 then
term.setCursorBlink(false) term.setCursorBlink(false)
text = unicode.sub(text, 1, -2) text = unicode.sub(text, 1, -2)
if unicode.len(text) < limit then gpu.set(x + unicode.len(text), y, " ") end if unicode.len(text) < limit then component.gpu.set(x + unicode.len(text), y, " ") end
draw() draw()
elseif e[4] == 28 then elseif e[4] == 28 then
term.setCursorBlink(false) term.setCursorBlink(false)
@ -1348,12 +1282,12 @@ function ecs.textField(x, y, width, height, lines, displayFrom, background, fore
ecs.square(x, y, width - 1, height, background) ecs.square(x, y, width - 1, height, background)
ecs.srollBar(x + width - 1, y, 1, height, sLines, displayFrom, scrollbarBackground, scrollbarForeground) ecs.srollBar(x + width - 1, y, 1, height, sLines, displayFrom, scrollbarBackground, scrollbarForeground)
gpu.setBackground(background) component.gpu.setBackground(background)
gpu.setForeground(foreground) component.gpu.setForeground(foreground)
local yPos = y local yPos = y
for i = displayFrom, (displayFrom + height - 1) do for i = displayFrom, (displayFrom + height - 1) do
if lines[i] then if lines[i] then
gpu.set(x + 1, yPos, lines[i]) component.gpu.set(x + 1, yPos, lines[i])
yPos = yPos + 1 yPos = yPos + 1
else else
break break
@ -1575,10 +1509,10 @@ end
-- Анимация затухания экрана -- Анимация затухания экрана
function ecs.fadeOut(startColor, targetColor, speed) function ecs.fadeOut(startColor, targetColor, speed)
local xSize, ySize = gpu.getResolution() local xSize, ySize = component.gpu.getResolution()
while startColor >= targetColor do while startColor >= targetColor do
gpu.setBackground(startColor) component.gpu.setBackground(startColor)
gpu.fill(1, 1, xSize, ySize, " ") component.gpu.fill(1, 1, xSize, ySize, " ")
startColor = startColor - 0x111111 startColor = startColor - 0x111111
os.sleep(speed or 0) os.sleep(speed or 0)
end end
@ -1586,10 +1520,10 @@ end
-- Анимация загорания экрана -- Анимация загорания экрана
function ecs.fadeIn(startColor, targetColor, speed) function ecs.fadeIn(startColor, targetColor, speed)
local xSize, ySize = gpu.getResolution() local xSize, ySize = component.gpu.getResolution()
while startColor <= targetColor do while startColor <= targetColor do
gpu.setBackground(startColor) component.gpu.setBackground(startColor)
gpu.fill(1, 1, xSize, ySize, " ") component.gpu.fill(1, 1, xSize, ySize, " ")
startColor = startColor + 0x111111 startColor = startColor + 0x111111
os.sleep(speed or 0) os.sleep(speed or 0)
end end
@ -1597,23 +1531,23 @@ end
-- Анимация выхода в олдскул-телевизионном стиле -- Анимация выхода в олдскул-телевизионном стиле
function ecs.TV(speed, targetColor) function ecs.TV(speed, targetColor)
local xSize, ySize = gpu.getResolution() local xSize, ySize = component.gpu.getResolution()
local xCenter, yCenter = math.floor(xSize / 2), math.floor(ySize / 2) local xCenter, yCenter = math.floor(xSize / 2), math.floor(ySize / 2)
gpu.setBackground(targetColor or 0x000000) component.gpu.setBackground(targetColor or 0x000000)
for y = 1, yCenter do for y = 1, yCenter do
gpu.fill(1, y - 1, xSize, 1, " ") component.gpu.fill(1, y - 1, xSize, 1, " ")
gpu.fill(1, ySize - y + 1, xSize, 1, " ") component.gpu.fill(1, ySize - y + 1, xSize, 1, " ")
os.sleep(speed or 0) os.sleep(speed or 0)
end end
for x = 1, xCenter - 1 do for x = 1, xCenter - 1 do
gpu.fill(x, yCenter, 1, 1, " ") component.gpu.fill(x, yCenter, 1, 1, " ")
gpu.fill(xSize - x + 1, yCenter, 1, 1, " ") component.gpu.fill(xSize - x + 1, yCenter, 1, 1, " ")
os.sleep(speed or 0) os.sleep(speed or 0)
end end
os.sleep(0.3) os.sleep(0.3)
gpu.fill(1, yCenter, xSize, 1, " ") component.gpu.fill(1, yCenter, xSize, 1, " ")
end end
@ -1695,7 +1629,7 @@ function ecs.universalWindow(x, y, width, background, closeWindowAfter, ...)
height = height + objects[i][2] height = height + objects[i][2]
elseif objectType == "wrappedtext" then elseif objectType == "wrappedtext" then
--Заранее парсим текст перенесенный --Заранее парсим текст перенесенный
objects[i].wrapped = ecs.stringWrap({objects[i][3]}, width - 4) objects[i].wrapped = string.wrap({objects[i][3]}, width - 4)
objects[i].height = #objects[i].wrapped objects[i].height = #objects[i].wrapped
height = height + objects[i].height height = height + objects[i].height
else else
@ -1708,8 +1642,8 @@ function ecs.universalWindow(x, y, width, background, closeWindowAfter, ...)
--Запоминаем инфу о том, что было нарисовано, если это необходимо --Запоминаем инфу о том, что было нарисовано, если это необходимо
local oldPixels, oldBackground, oldForeground local oldPixels, oldBackground, oldForeground
if closeWindowAfter then if closeWindowAfter then
oldBackground = gpu.getBackground() oldBackground = component.gpu.getBackground()
oldForeground = gpu.getForeground() oldForeground = component.gpu.getForeground()
oldPixels = ecs.rememberOldPixels(x, y, x + width - 1, y + height - 1) oldPixels = ecs.rememberOldPixels(x, y, x + width - 1, y + height - 1)
end end
--Считаем все координаты объектов --Считаем все координаты объектов
@ -1742,9 +1676,9 @@ function ecs.universalWindow(x, y, width, background, closeWindowAfter, ...)
if objectType == "centertext" then if objectType == "centertext" then
local xPos = x + math.floor(width / 2 - unicode.len(objects[number][3]) / 2) local xPos = x + math.floor(width / 2 - unicode.len(objects[number][3]) / 2)
gpu.setForeground(objects[number][2]) component.gpu.setForeground(objects[number][2])
gpu.setBackground(background) component.gpu.setBackground(background)
gpu.set(xPos, objects[number].y, objects[number][3]) component.gpu.set(xPos, objects[number].y, objects[number][3])
elseif objectType == "input" then elseif objectType == "input" then
@ -1757,7 +1691,7 @@ function ecs.universalWindow(x, y, width, background, closeWindowAfter, ...)
--Рамочка --Рамочка
ecs.border(x + 1, objects[number].y, width - 2, objectsHeights.input, background, objects[number][2]) ecs.border(x + 1, objects[number].y, width - 2, objectsHeights.input, background, objects[number][2])
--Текстик --Текстик
gpu.set(x + 3, objects[number].y + 1, ecs.stringLimit("start", objects[number][4], width - 6)) component.gpu.set(x + 3, objects[number].y + 1, ecs.stringLimit("start", objects[number][4], width - 6))
ecs.inputText(x + 3, objects[number].y + 1, width - 6, objects[number][4], background, objects[number][2], true, objects[number][5]) ecs.inputText(x + 3, objects[number].y + 1, width - 6, objects[number][4], background, objects[number][2], true, objects[number][5])
end end
@ -1803,12 +1737,12 @@ function ecs.universalWindow(x, y, width, background, closeWindowAfter, ...)
--Коробка для галочки --Коробка для галочки
ecs.border(x + 1, yPos, 5, 3, background, usualColor) ecs.border(x + 1, yPos, 5, 3, background, usualColor)
--Текст --Текст
gpu.set(x + 7, yPos + 1, objects[number][i]) component.gpu.set(x + 7, yPos + 1, objects[number][i])
--Галочка --Галочка
if objects[number].selectedData == (i - 3) then if objects[number].selectedData == (i - 3) then
ecs.colorText(x + 3, yPos + 1, selectionColor, symbol) ecs.colorText(x + 3, yPos + 1, selectionColor, symbol)
else else
gpu.set(x + 3, yPos + 1, " ") component.gpu.set(x + 3, yPos + 1, " ")
end end
obj["Selects"] = obj["Selects"] or {} obj["Selects"] = obj["Selects"] or {}
@ -1831,12 +1765,12 @@ function ecs.universalWindow(x, y, width, background, closeWindowAfter, ...)
local yPos = objects[number].y local yPos = objects[number].y
local function bordak(borderColor) local function bordak(borderColor)
gpu.setBackground(background) component.gpu.setBackground(background)
gpu.setForeground(borderColor) component.gpu.setForeground(borderColor)
gpu.set(x + 1, objects[number].y, topLine) component.gpu.set(x + 1, objects[number].y, topLine)
gpu.set(x + 1, objects[number].y + 1, midLine) component.gpu.set(x + 1, objects[number].y + 1, midLine)
gpu.set(x + 1, objects[number].y + 2, botLine) component.gpu.set(x + 1, objects[number].y + 2, botLine)
gpu.set(x + 3, objects[number].y + 1, ecs.stringLimit("start", objects[number].selectedElement, width - 6)) component.gpu.set(x + 3, objects[number].y + 1, ecs.stringLimit("start", objects[number].selectedElement, width - 6))
ecs.colorText(x + width - 4, objects[number].y + 1, arrowColor, "") ecs.colorText(x + width - 4, objects[number].y + 1, arrowColor, "")
end end
@ -1860,9 +1794,9 @@ function ecs.universalWindow(x, y, width, background, closeWindowAfter, ...)
local botLine = ""..string.rep("", selectorWidth - 2) .. "" local botLine = ""..string.rep("", selectorWidth - 2) .. ""
ecs.colorTextWithBack(xPos, yPos - 1, arrowColor, background, topLine) ecs.colorTextWithBack(xPos, yPos - 1, arrowColor, background, topLine)
for i = 1, spisokHeight - 1 do for i = 1, spisokHeight - 1 do
gpu.set(xPos, yPos + i - 1, midLine) component.gpu.set(xPos, yPos + i - 1, midLine)
end end
gpu.set(xPos, yPos + spisokHeight - 1, botLine) component.gpu.set(xPos, yPos + spisokHeight - 1, botLine)
--Элементы рисуем --Элементы рисуем
xPos = xPos + 2 xPos = xPos + 2
@ -1901,15 +1835,15 @@ function ecs.universalWindow(x, y, width, background, closeWindowAfter, ...)
elseif objectType == "textfield" then elseif objectType == "textfield" then
newObj("TextFields", number, x + 1, objects[number].y, x + width - 2, objects[number].y + objects[number][2] - 1) newObj("TextFields", number, x + 1, objects[number].y, x + width - 2, objects[number].y + objects[number][2] - 1)
if not objects[number].strings then objects[number].strings = ecs.stringWrap({objects[number][7]}, width - 3) end if not objects[number].strings then objects[number].strings = string.wrap({objects[number][7]}, width - 3) end
objects[number].displayFrom = objects[number].displayFrom or 1 objects[number].displayFrom = objects[number].displayFrom or 1
ecs.textField(x, objects[number].y, width, objects[number][2], objects[number].strings, objects[number].displayFrom, objects[number][3], objects[number][4], objects[number][5], objects[number][6]) ecs.textField(x, objects[number].y, width, objects[number][2], objects[number].strings, objects[number].displayFrom, objects[number][3], objects[number][4], objects[number][5], objects[number][6])
elseif objectType == "wrappedtext" then elseif objectType == "wrappedtext" then
gpu.setBackground(background) component.gpu.setBackground(background)
gpu.setForeground(objects[number][2]) component.gpu.setForeground(objects[number][2])
for i = 1, #objects[number].wrapped do for i = 1, #objects[number].wrapped do
gpu.set(x + 2, objects[number].y + i - 1, objects[number].wrapped[i]) component.gpu.set(x + 2, objects[number].y + i - 1, objects[number].wrapped[i])
end end
elseif objectType == "button" then elseif objectType == "button" then
@ -2007,8 +1941,8 @@ function ecs.universalWindow(x, y, width, background, closeWindowAfter, ...)
local function redrawBeforeClose() local function redrawBeforeClose()
if closeWindowAfter then if closeWindowAfter then
ecs.drawOldPixels(oldPixels) ecs.drawOldPixels(oldPixels)
gpu.setBackground(oldBackground) component.gpu.setBackground(oldBackground)
gpu.setForeground(oldForeground) component.gpu.setForeground(oldForeground)
end end
end end

View File

@ -1,553 +1 @@
stringWra
local libraries = {
buffer = "doubleBuffering",
unicode = "unicode",
event = "event",
}
for library in pairs(libraries) do if not _G[library] then _G[library] = require(libraries[library]) end end; libraries = nil
local GUI = {}
---------------------------------------------------- Универсальные методы --------------------------------------------------------
GUI.alignment = {
verticalCenter = 0,
horizontalCenter = 1,
horizontalAndVerticalCenter = 3,
}
GUI.directions = {
horizontal = 0,
vertical = 1,
}
GUI.buttonTypes = {
default = 0,
adaptive = 1,
framedDefault = 2,
framedAdaptive = 3,
}
GUI.colors = {
disabled = 0x888888,
disabledText = 0xAAAAAA,
}
-- Универсальный метод для проверки клика на прямоугольный объект
local function objectClicked(object, x, y)
if x >= object.x and y >= object.y and x <= object.x + object.width - 1 and y <= object.y + object.height - 1 and not object.disabled and not object.invisible ~= false then return true end
return false
end
local function objectSetDisabled(object, state)
object.disabled = state
end
--Создание базового примитива-объекта
function GUI.object(x, y, width, height)
return {
x = x,
y = y,
width = width,
height = height,
isClicked = objectClicked,
}
end
---------------------------------------------------- Кнопки --------------------------------------------------------------------
-- Универсальынй метод-рисоватор кнопки
local function drawButton(buttonObject, isPressed)
local textLength = unicode.len(buttonObject.text)
if textLength > buttonObject.width then buttonObject.text = unicode.sub(buttonObject.text, 1, buttonObject.width) end
local xText = math.floor(buttonObject.x + buttonObject.width / 2 - textLength / 2)
local yText = math.floor(buttonObject.y + buttonObject.height / 2)
local buttonColor = buttonObject.disabled and buttonObject.colors.disabled.button or (isPressed and buttonObject.colors.pressed.button or buttonObject.colors.default.button)
local textColor = buttonObject.disabled and buttonObject.colors.disabled.text or (isPressed and buttonObject.colors.pressed.text or buttonObject.colors.default.text)
if buttonObject.type == GUI.buttonTypes.default or buttonObject.type == GUI.buttonTypes.adaptive then
buffer.square(buttonObject.x, buttonObject.y, buttonObject.width, buttonObject.height, buttonColor, textColor, " ")
buffer.text(xText, yText, textColor, buttonObject.text)
elseif buttonObject.type == GUI.buttonTypes.framedDefault or buttonObject.type == GUI.buttonTypes.framedAdaptive then
buffer.frame(buttonObject.x, buttonObject.y, buttonObject.width, buttonObject.height, buttonColor)
buffer.text(xText, yText, textColor, buttonObject.text)
end
end
-- Метод-нажиматор кнопки
local function pressButton(buttonObject, pressTime)
drawButton(buttonObject, true)
buffer.draw()
os.sleep(pressTime or 0.2)
drawButton(buttonObject, false)
buffer.draw()
end
-- Создание таблицы кнопки со всеми необходимыми параметрами
local function createButtonObject(buttonType, x, y, width, height, buttonColor, textColor, buttonPressedColor, textPressedColor, text, disabledState)
local buttonObject = GUI.object(x, y, width, height)
buttonObject.colors = {
default = {
button = buttonColor,
text = textColor
},
pressed = {
button = buttonPressedColor,
text = textPressedColor
},
disabled = {
button = GUI.colors.disabled,
text = GUI.colors.disabledText,
}
}
buttonObject.disabled = disabledState
buttonObject.setDisabled = objectSetDisabled
buttonObject.type = buttonType
buttonObject.text = text
buttonObject.press = pressButton
buttonObject.draw = drawButton
return buttonObject
end
-- Кнопка фиксированных размеров
function GUI.button(x, y, width, height, buttonColor, textColor, buttonPressedColor, textPressedColor, text, disabledState)
local buttonObject = createButtonObject(GUI.buttonTypes.default, x, y, width, height, buttonColor, textColor, buttonPressedColor, textPressedColor, text, disabledState)
buttonObject:draw()
return buttonObject
end
-- Кнопка, подстраивающаяся под размер текста
function GUI.adaptiveButton(x, y, xOffset, yOffset, buttonColor, textColor, buttonPressedColor, textPressedColor, text, disabledState)
local buttonObject = createButtonObject(GUI.buttonTypes.adaptive, x, y, xOffset * 2 + unicode.len(text), yOffset * 2 + 1, buttonColor, textColor, buttonPressedColor, textPressedColor, text, disabledState)
buttonObject:draw()
return buttonObject
end
-- Кнопка в рамке
function GUI.framedButton(x, y, width, height, buttonColor, textColor, buttonPressedColor, textPressedColor, text, disabledState)
local buttonObject = createButtonObject(GUI.buttonTypes.framedDefault, x, y, width, height, buttonColor, textColor, buttonPressedColor, textPressedColor, text, disabledState)
buttonObject:draw()
return buttonObject
end
-- Кнопка в рамке, подстраивающаяся под размер текста
function GUI.adaptiveFramedButton(x, y, xOffset, yOffset, buttonColor, textColor, buttonPressedColor, textPressedColor, text, disabledState)
local buttonObject = createButtonObject(GUI.buttonTypes.framedAdaptive, x, y, xOffset * 2 + unicode.len(text), yOffset * 2 + 1, buttonColor, textColor, buttonPressedColor, textPressedColor, text, disabledState)
buttonObject:draw()
return buttonObject
end
-- Вертикальный или горизонтальный ряд кнопок
-- Каждая кнопка - это массив вида {enum GUI.buttonTypes.default или GUI.buttonTypes.adaptive, int ширина/отступ, int высота/отступ, int цвет кнопки, int цвет текста, int цвет нажатой кнопки, int цвет нажатого текста, string текст}
-- Метод возвращает обычный массив кнопочных объектов (см. выше)
function GUI.buttons(x, y, direction, spaceBetweenButtons, ...)
local buttons = {...}
local buttonObjects = {}
local function drawCorrectButton(i)
if buttons[i][1] == GUI.buttonTypes.default then
return GUI.button(x, y, buttons[i][2], buttons[i][3], buttons[i][4], buttons[i][5], buttons[i][6], buttons[i][7], buttons[i][8])
elseif buttons[i][1] == GUI.buttonTypes.adaptive then
return GUI.adaptiveButton(x, y, buttons[i][2], buttons[i][3], buttons[i][4], buttons[i][5], buttons[i][6], buttons[i][7], buttons[i][8])
elseif buttons[i][1] == GUI.buttonTypes.framedDefault then
return GUI.framedButton(x, y, buttons[i][2], buttons[i][3], buttons[i][4], buttons[i][5], buttons[i][6], buttons[i][7], buttons[i][8])
elseif buttons[i][1] == GUI.buttonTypes.framedAdaptive then
return GUI.adaptiveFramedButton(x, y, buttons[i][2], buttons[i][3], buttons[i][4], buttons[i][5], buttons[i][6], buttons[i][7], buttons[i][8])
else
error("Неподдерживаемый тип кнопки: " .. tostring(buttons[i][1]))
end
end
for i = 1, #buttons do
buttonObjects[i] = drawCorrectButton(i)
if direction == GUI.directions.horizontal then
x = x + buttonObjects[i].width + spaceBetweenButtons
elseif direction == GUI.directions.vertical then
y = y + buttonObjects[i].height + spaceBetweenButtons
else
error("Неподдерживаемое направление: " .. tostring(buttons[i][1]))
end
end
return buttonObjects
end
function GUI.menu(x, y, width, menuColor, ...)
local buttons = {...}
buffer.square(x, y, width, 1, menuColor)
x = x + 1
local menuObjects = {}
for i = 1, #buttons do
menuObjects[i] = GUI.adaptiveButton(x, y, 1, 0, menuColor, buttons[i].textColor, buttons[i].buttonPressedColor or 0x3366CC, buttons[i].textPressedColor or 0xFFFFFF, buttons[i].text)
x = x + menuObjects[i].width
end
return menuObjects
end
function GUI.windowActionButtons(x, y, fatSymbol)
local symbol = fatSymbol and "" or ""
local windowActionButtons, background = {}
background = buffer.get(x, y); windowActionButtons.close = GUI.button(x, y, 1, 1, background, 0xFF4940, background, 0x992400, symbol); x = x + 2
background = buffer.get(x, y); windowActionButtons.minimize = GUI.button(x, y, 1, 1, background, 0xFFB640, background, 0x996D00, symbol); x = x + 2
background = buffer.get(x, y); windowActionButtons.maximize = GUI.button(x, y, 1, 1, background, 0x00B640, background, 0x006D40, symbol); x = x + 2
return windowActionButtons
end
function GUI.toolbar(x, y, width, height, spaceBetweenElements, currentElement, toolbarColor, elementTextColor, activeElementColor, activeElementTextColor, ...)
local elements, objects, elementLength, isCurrent, elementWidth = {...}, {}
local totalWidth = 0; for i = 1, #elements do totalWidth = totalWidth + unicode.len(elements[i]) + 2 + spaceBetweenElements end; totalWidth = totalWidth - spaceBetweenElements
buffer.square(x, y, width, height, toolbarColor)
x = math.floor(x + width / 2 - totalWidth / 2)
local yText = math.floor(y + height / 2)
for i = 1, #elements do
elementLength, isCurrent = unicode.len(elements[i]), i == currentElement
elementWidth = elementLength + 2
if isCurrent then buffer.square(x, y, elementWidth, height, activeElementColor) end
buffer.text(x + 1, yText, isCurrent and activeElementTextColor or elementTextColor, elements[i])
table.insert(objects, GUI.object(x, y, elementWidth, height))
x = x + elementWidth + spaceBetweenElements
end
return objects
end
function GUI.progressBar(x, y, width, height, firstColor, secondColor, value, maxValue, thin)
local percent = value / maxValue
local activeWidth = math.floor(percent * width)
if thin then
buffer.text(x, y, firstColor, string.rep("", width))
buffer.text(x, y, secondColor, string.rep("", activeWidth))
else
buffer.square(x, y, width, height, firstColor)
buffer.square(x, y, activeWidth, height, secondColor)
end
end
function GUI.windowShadow(x, y, width, height, transparency)
buffer.square(x + width, y + 1, 2, height, 0x000000, 0x000000, " ", transparency)
buffer.square(x + 2, y + height, width - 2, 1, 0x000000, 0x000000, " ", transparency)
end
------------------------------------------------- Окна -------------------------------------------------------------------
-- Красивое окошко для отображения сообщения об ошибке. Аргумент errorWindowParameters может принимать следующие значения:
-- local errorWindowParameters = {
-- backgroundColor = 0x262626,
-- textColor = 0xFFFFFF,
-- truncate = 50,
-- title = {color = 0xFF8888, text = "Ошибочка"}
-- noAnimation = true,
-- }
function GUI.error(text, errorWindowParameters)
--Всякие константы, бла-бла
local backgroundColor = (errorWindowParameters and errorWindowParameters.backgroundColor) or 0x1b1b1b
local errorPixMap = {
{{0xffdb40 , 0xffffff,"#"}, {0xffdb40 , 0xffffff, "#"}, {backgroundColor, 0xffdb40, ""}, {backgroundColor, 0xffdb40, ""}, {0xffdb40 , 0xffffff, "#"}, {0xffdb40 , 0xffffff, "#"}},
{{0xffdb40 , 0xffffff,"#"}, {backgroundColor, 0xffdb40, ""}, {0xffdb40 , 0xffffff, " "}, {0xffdb40 , 0xffffff, " "}, {backgroundColor, 0xffdb40, ""}, {0xffdb40 , 0xffffff, "#"}},
{{backgroundColor, 0xffdb40,""}, {0xffdb40 , 0xffffff, "c"}, {0xffdb40 , 0xffffff, "y"}, {0xffdb40 , 0xffffff, "k"}, {0xffdb40 , 0xffffff, "a"}, {backgroundColor, 0xffdb40, ""}},
}
local textColor = (errorWindowParameters and errorWindowParameters.textColor) or 0xFFFFFF
local buttonWidth = 12
local verticalOffset = 2
local minimumHeight = verticalOffset * 2 + #errorPixMap
local height = 0
local widthOfText = math.floor(buffer.screen.width * 0.5)
--Ебемся с текстом, делаем его пиздатым во всех смыслах
if type(text) ~= "table" then
text = tostring(text)
text = (errorWindowParameters and errorWindowParameters.truncate) and unicode.sub(text, 1, errorWindowParameters.truncate) or text
text = { text }
end
text = GUI.stringWrap(text, widthOfText)
--Ебашим высоту правильнуюe
height = verticalOffset * 2 + #text + 1
if errorWindowParameters and errorWindowParameters.title then height = height + 2 end
if height < minimumHeight then height = minimumHeight end
--Ебашим стартовые коорды отрисовки
local x, y = math.ceil(buffer.screen.width / 2 - widthOfText / 2), math.ceil(buffer.screen.height / 2 - height / 2)
local OKButton = {}
local oldPixels = buffer.copy(1, y, buffer.screen.width, height)
--Отрисовочка
local function draw()
local yPos = y
--Подложка
buffer.square(1, yPos, buffer.screen.width, height, backgroundColor, 0x000000); yPos = yPos + verticalOffset
buffer.customImage(x - #errorPixMap[1] - 3, yPos, errorPixMap)
--Титл, епта!
if errorWindowParameters and errorWindowParameters.title then buffer.text(x, yPos, errorWindowParameters.title.color, errorWindowParameters.title.text); yPos = yPos + 2 end
--Текстус
for i = 1, #text do buffer.text(x, yPos, textColor, text[i]); yPos = yPos + 1 end; yPos = yPos + 1
--Кнопачка
OKButton = GUI.button(x + widthOfText - buttonWidth, y + height - 2, buttonWidth, 1, 0x3392FF, 0xFFFFFF, 0xFFFFFF, 0x262626, "OK")
--Атрисовачка
buffer.draw()
end
--Графонистый выход
local function quit()
OKButton:press(0.2)
buffer.paste(1, y, oldPixels)
buffer.draw()
end
--Онимацыя
if not (errorWindowParameters and errorWindowParameters.noAnimation) then for i = 1, height do buffer.setDrawLimit(1, math.floor(buffer.screen.height / 2) - i, buffer.screen.width, i * 2); draw(); os.sleep(0.05) end; buffer.resetDrawLimit() end
draw()
--Анализ говнища
while true do
local e = {event.pull()}
if e[1] == "key_down" then
if e[4] == 28 then
quit(); return
end
elseif e[1] == "touch" then
if OKButton:isClicked(e[3], e[4]) then
quit(); return
end
end
end
end
--------------------------------------------------------------------------------------------------------------------------------
-- local textFieldProperties = {
-- --Регурярное выражение, которому должны соответствовать вводимые данные. При несоответствии на выходе из функции выдается первоначальный текст, поданынй на выход функции
-- regex = "^%d+$",
-- --Отключает символ многоточия при выходе за пределы текстового поля
-- disableDots = true,
-- --Попросту отрисовывает всю необходимую информацию без активации нажатия на клавиши
-- justDrawNotEvent = true,
-- --Задержка между миганимем курсора
-- cursorBlinkDelay = 1.5,
-- --Цвет курсора
-- cursorColor = 0xFF7777,
-- --Символ, используемый для отрисовки курсора
-- cursorSymbol = "▌",
-- --Символ-маскировщик, на который будет визуально заменен весь вводимый текст. Полезно для полей ввода пароля
-- maskTextWithSymbol = "*",
-- }
function GUI.input(x, y, width, foreground, startText, textFieldProperties)
if not (y >= buffer.drawLimit.y and y <= buffer.drawLimit.y2) then return startText end
local text = startText
local textLength = unicode.len(text)
local cursorBlinkState = false
local cursorBlinkDelay = (textFieldProperties and textFieldProperties.cursorBlinkDelay) and textFieldProperties.cursorBlinkDelay or 0.5
local cursorColor = (textFieldProperties and textFieldProperties.cursorColor) and textFieldProperties.cursorColor or 0x00A8FF
local cursorSymbol = (textFieldProperties and textFieldProperties.cursorSymbol) and textFieldProperties.cursorSymbol or ""
local oldPixels = {}; for i = x, x + width - 1 do table.insert(oldPixels, { buffer.get(i, y) }) end
local function drawOldPixels()
for i = 1, #oldPixels do buffer.set(x + i - 1, y, oldPixels[i][1], oldPixels[i][2], oldPixels[i][3]) end
end
local function getTextLength()
textLength = unicode.len(text)
end
local function textFormat()
local formattedText = text
if textFieldProperties and textFieldProperties.maskTextWithSymbol then
formattedText = string.rep(textFieldProperties.maskTextWithSymbol or "*", textLength)
end
if textLength > width then
if textFieldProperties and textFieldProperties.disableDots then
formattedText = unicode.sub(formattedText, -width, -1)
else
formattedText = "" .. unicode.sub(formattedText, -width + 1, -1)
end
end
return formattedText
end
local function draw()
drawOldPixels()
buffer.text(x, y, foreground, textFormat())
if cursorBlinkState then
local cursorPosition = textLength < width and x + textLength or x + width - 1
local bg = buffer.get(cursorPosition, y)
buffer.set(cursorPosition, y, bg, cursorColor, cursorSymbol)
end
if not (textFieldProperties and textFieldProperties.justDrawNotEvent) then buffer.draw() end
end
local function backspace()
if unicode.len(text) > 0 then text = unicode.sub(text, 1, -2); getTextLength(); draw() end
end
local function quit()
cursorBlinkState = false
if textFieldProperties and textFieldProperties.regex and not string.match(text, textFieldProperties.regex) then
text = startText
draw()
return startText
end
draw()
return text
end
draw()
if textFieldProperties and textFieldProperties.justDrawNotEvent then return startText end
while true do
local e = { event.pull(cursorBlinkDelay) }
if e[1] == "key_down" then
if e[4] == 14 then
backspace()
elseif e[4] == 28 then
return quit()
else
local symbol = unicode.char(e[3])
if not keyboard.isControl(e[3]) then
text = text .. symbol
getTextLength()
draw()
end
end
elseif e[1] == "clipboard" then
text = text .. e[3]
getTextLength()
draw()
elseif e[1] == "touch" then
return quit()
else
cursorBlinkState = not cursorBlinkState
draw()
end
end
end
local function drawTextField(object, isFocused)
if not object.invisible then
local background = object.disabled and object.colors.disabled.textField or (isFocused and object.colors.focused.textField or object.colors.default.textField)
local foreground = object.disabled and object.colors.disabled.text or (isFocused and object.colors.focused.text or object.colors.default.text)
local y = math.floor(object.y + object.height / 2)
local text = isFocused and (object.text or "") or (object.text or object.placeholderText or "")
if background then buffer.square(object.x, object.y, object.width, object.height, background, foreground, " ") end
local resultText = GUI.input(object.x + 1, y, object.width - 2, foreground, text, {justDrawNotEvent = not isFocused})
object.text = isFocused and resultText or object.text
end
end
local function textFieldBeginInput(object)
drawTextField(object, true)
if object.text == "" then object.text = nil; drawTextField(object, false); buffer.draw() end
end
function GUI.textField(x, y, width, height, textFieldColor, textColor, textFieldFocusedColor, textFocusedColor, text, placeholderText, disabledState, invisibleState)
local object = GUI.object(x, y, width, height)
object.invisible = invisibleState
object.disabled = disabledState
object.colors = {
default = {
textField = textFieldColor,
text = textColor
},
focused = {
textField = textFieldFocusedColor,
text = textFocusedColor
},
disabled = {
textField = GUI.colors.disabled,
text = GUI.colors.disabledText,
}
}
object.text = text
object.placeholderText = placeholderText
object.isClicked = objectClicked
object.draw = drawTextField
object.input = textFieldBeginInput
object:draw()
return object
end
--------------------------------------------------------------------------------------------------------------------------------
--Функция по переносу слов на новую строку в зависимости от ограничения по ширине
function GUI.stringWrap(strings, limit)
local currentString = 1
while currentString <= #strings do
local words = {}; for word in string.gmatch(tostring(strings[currentString]), "[^%s]+") do table.insert(words, word) end
local newStringThatFormedFromWords, oldStringThatFormedFromWords = "", ""
local word = 1
local overflow = false
while word <= #words do
oldStringThatFormedFromWords = oldStringThatFormedFromWords .. (word > 1 and " " or "") .. words[word]
if unicode.len(oldStringThatFormedFromWords) > limit then
--ЕБЛО
if unicode.len(words[word]) > limit then
local left = unicode.sub(oldStringThatFormedFromWords, 1, limit)
local right = unicode.sub(strings[currentString], unicode.len(left) + 1, -1)
overflow = true
strings[currentString] = left
if strings[currentString + 1] then
strings[currentString + 1] = right .. " " .. strings[currentString + 1]
else
strings[currentString + 1] = right
end
end
break
else
newStringThatFormedFromWords = oldStringThatFormedFromWords
end
word = word + 1
end
if word <= #words and not overflow then
local fuckToAdd = table.concat(words, " ", word, #words)
if strings[currentString + 1] then
strings[currentString + 1] = fuckToAdd .. " " .. strings[currentString + 1]
else
strings[currentString + 1] = fuckToAdd
end
strings[currentString] = newStringThatFormedFromWords
end
currentString = currentString + 1
end
return strings
end
--------------------------------------------------------------------------------------------------------------------------------
function GUI.centeredText(centrationENUM, coordinate, color, text)
local textLength, x, y = unicode.len(text)
if centrationENUM == GUI.alignment.verticalCenter then
x, y = math.floor(buffer.screen.width / 2 - textLength / 2), coordinate
elseif centrationENUM == GUI.alignment.horizontalCenter then
x, y = coordinate, math.floor(buffer.screen.height / 2)
else
x, y = math.floor(buffer.screen.width / 2 - textLength / 2), math.floor(buffer.screen.height / 2)
end
buffer.text(x, y, color, text)
end
--------------------------------------------------------------------------------------------------------------------------------
return GUI

View File

@ -1,6 +1,7 @@
---------------------------------------------- Библиотеки ------------------------------------------------------------------------ ---------------------------------------------- Библиотеки ------------------------------------------------------------------------
local libraries = { local libraries = {
advancedLua = "advancedLua",
computer = "computer", computer = "computer",
ecs = "ECSAPI", ecs = "ECSAPI",
component = "component", component = "component",
@ -227,7 +228,7 @@ local function drawErrorWindow(path, programVersion, errorLine, reason, showSend
) )
--Стек --Стек
strings = GUI.stringWrap(MineOSCore.parseErrorMessage(reason, 4), stackWidth - 2) strings = string.wrap(MineOSCore.parseErrorMessage(reason, 4), stackWidth - 2)
x = x + codeWidth x = x + codeWidth
buffer.square(x, y, stackWidth, codeHeight, 0xFFFFFF) buffer.square(x, y, stackWidth, codeHeight, 0xFFFFFF)
x = x + 1 x = x + 1

268
lib/advancedLua.lua Normal file
View File

@ -0,0 +1,268 @@
--[[
Advanced Lua Library v1.0 by ECS
This library extends a lot of default Lua methods
and adds some really cool features that haven't been
implemented yet, such as fastest table serialization,
table binary searching, string wrapping, numbers rounding, etc.
]]
_G.filesystem = _G.filesystem or require("filesystem")
_G.unicode = _G.unicode or require("unicode")
-------------------------------------------------- Math extensions --------------------------------------------------
function math.round(num)
if num >= 0 then return math.floor(num + 0.5) else return math.ceil(num - 0.5) end
end
function math.roundToDecimalPlaces(num, decimalPlaces)
local mult = 10 ^ (decimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end
function math.doubleToString(num, digitCount)
return string.format("%." .. digitCount or 1 .. "f", num)
end
-------------------------------------------------- Table extensions --------------------------------------------------
local function doSerialize(array, text, prettyLook, indentationSymbol, oldIndentationSymbol, equalsSymbol)
text = {"{"}
table.insert(text, (prettyLook and "\n" or nil))
for key, value in pairs(array) do
local keyType, valueType, stringValue = type(key), type(value), tostring(value)
if keyType == "number" or keyType == "string" then
table.insert(text, (prettyLook and indentationSymbol or nil))
table.insert(text, "[")
table.insert(text, (keyType == "string" and table.concat({"\"", key, "\""}) or key))
table.insert(text, "]")
table.insert(text, equalsSymbol)
if valueType == "number" or valueType == "boolean" or valueType == "nil" then
table.insert(text, stringValue)
elseif valueType == "string" or valueType == "function" then
table.insert(text, "\"")
table.insert(text, stringValue)
table.insert(text, "\"")
elseif valueType == "table" then
table.insert(text, table.concat(doSerialize(value, text, prettyLook, table.concat({indentationSymbol, indentationSymbol}), table.concat({oldIndentationSymbol, indentationSymbol}), equalsSymbol)))
else
error("Unsupported table value type: " .. valueType)
end
table.insert(text, ",")
table.insert(text, (prettyLook and "\n" or nil))
else
error("Unsupported table key type: " .. keyType)
end
end
table.remove(text, (prettyLook and #text - 1 or #text))
table.insert(text, (prettyLook and oldIndentationSymbol or nil))
table.insert(text, "}")
return text
end
function table.serialize(array, prettyLook, indentationWidth, indentUsingTabs)
checkArg(1, array, "table")
indentationWidth = indentationWidth or 2
local indentationSymbol = indentUsingTabs and " " or " "
indentationSymbol, indentationSymbolHalf = string.rep(indentationSymbol, indentationWidth)
return table.concat(doSerialize(array, {}, prettyLook, indentationSymbol, "", prettyLook and " = " or "="))
end
function table.unserialize(serializedString)
checkArg(1, serializedString, "string")
local success, result = pcall(load("return " .. serializedString))
if success then return result else return nil, result end
end
function table.toFile(path, array, prettyLook, indentationWidth, indentUsingTabs, appendToFile)
checkArg(1, path, "string")
checkArg(2, array, "table")
filesystem.makeDirectory(filesystem.path(path) or "")
local file = io.open(path, appendToFile and "a" or "w")
file:write(table.serialize(array, prettyLook, indentationWidth, indentUsingTabs))
file:close()
end
function table.fromFile(path)
checkArg(1, path, "string")
if filesystem.exists(path) then
if filesystem.isDirectory(path) then
error("\"" .. path .. "\" is a directory")
else
local file = io.open(path, "r")
local data = table.unserialize(file:read("*a"))
file:close()
return data
end
else
error("\"" .. path .. "\" doesn't exists")
end
end
function table.copy(tableToCopy)
local function recursiveCopy(source, destination)
for key, value in pairs(source) do
if type(value) == "table" then
destination[key] = {}
recursiveCopy(source[key], destination[key])
else
destination[key] = value
end
end
end
local tableThatCopied = {}
recursiveCopy(tableToCopy, tableThatCopied)
return tableThatCopied
end
function table.binarySearch(t, requestedValue)
local function recursiveSearch(startIndex, endIndex)
local difference = endIndex - startIndex
local centerIndex = math.floor(difference / 2 + startIndex)
if difference > 1 then
if requestedValue >= t[centerIndex] then
return recursiveSearch(centerIndex, endIndex)
else
return recursiveSearch(startIndex, centerIndex)
end
else
if math.abs(requestedValue - t[startIndex]) > math.abs(t[endIndex] - requestedValue) then
return t[endIndex]
else
return t[startIndex]
end
end
end
return recursiveSearch(1, #t)
end
function table.size(t)
local size = 0
for key, value in pairs(t) do size = size + 1 end
return size
end
-------------------------------------------------- String extensions --------------------------------------------------
function string.unicodeFind(str, pattern, init, plain)
if init then
if init < 0 then
init = -#unicode.sub(str,init)
elseif init > 0 then
init = #unicode.sub(str, 1, init - 1) + 1
end
end
a, b = string.find(str, pattern, init, plain)
if a then
local ap, bp = str:sub(1, a - 1), str:sub(a,b)
a = unicode.len(ap) + 1
b = a + unicode.len(bp) - 1
return a, b
else
return a
end
end
function string.limit(text, size, fromLeft, noDots)
local length = unicode.len(text)
if length <= size then return text end
if fromLeft then
if noDots then
return unicode.sub(text, length - size + 1, -1)
else
return "" .. unicode.sub(text, length - size + 2, -1)
end
else
if noDots then
return unicode.sub(text, 1, size)
else
return unicode.sub(text, 1, size - 1) .. ""
end
end
end
function string.wrap(strings, limit)
strings = type(strings) == "string" and {strings} or strings
local currentString = 1
while currentString <= #strings do
local words = {}; for word in string.gmatch(tostring(strings[currentString]), "[^%s]+") do table.insert(words, word) end
local newStringThatFormedFromWords, oldStringThatFormedFromWords = "", ""
local word = 1
local overflow = false
while word <= #words do
oldStringThatFormedFromWords = oldStringThatFormedFromWords .. (word > 1 and " " or "") .. words[word]
if unicode.len(oldStringThatFormedFromWords) > limit then
if unicode.len(words[word]) > limit then
local left = unicode.sub(oldStringThatFormedFromWords, 1, limit)
local right = unicode.sub(strings[currentString], unicode.len(left) + 1, -1)
overflow = true
strings[currentString] = left
if strings[currentString + 1] then
strings[currentString + 1] = right .. " " .. strings[currentString + 1]
else
strings[currentString + 1] = right
end
end
break
else
newStringThatFormedFromWords = oldStringThatFormedFromWords
end
word = word + 1
end
if word <= #words and not overflow then
local fuckToAdd = table.concat(words, " ", word, #words)
if strings[currentString + 1] then
strings[currentString + 1] = fuckToAdd .. " " .. strings[currentString + 1]
else
strings[currentString + 1] = fuckToAdd
end
strings[currentString] = newStringThatFormedFromWords
end
currentString = currentString + 1
end
return strings
end
-------------------------------------------------- Playground --------------------------------------------------
-- local function safeCall(method, ...)
-- local arguments = {...}
-- return xpcall(function() return method(table.unpack(arguments)) end, debug.traceback)
-- end
-- local function safeCallString(str)
-- return safeCall(load(str))
-- end
-- local cyka = table.copy({123, 542, {abc = true, 16, 32, {cyka = false, haha = "abc"}}})
-- print(table.serialize(cyka, true))
-- print(safeCallString("return 123"))
------------------------------------------------------------------------------------------------------------------
return {loaded = true}

View File

@ -1,4 +1,5 @@
local libraries = { local libraries = {
advancedLua = "advancedLua",
colorlib = "colorlib", colorlib = "colorlib",
image = "image", image = "image",
buffer = "doubleBuffering", buffer = "doubleBuffering",
@ -18,7 +19,7 @@ rayEngine.horizonPosition = math.floor(buffer.screen.height / 2)
rayEngine.minimapEnabled = true rayEngine.minimapEnabled = true
rayEngine.compassEnabled = false rayEngine.compassEnabled = false
rayEngine.watchEnabled = false rayEngine.watchEnabled = false
rayEngine.drawFieldOfViewOnMinimap = true rayEngine.drawFieldOfViewOnMinimap = false
rayEngine.chatShowTime = 4 rayEngine.chatShowTime = 4
rayEngine.chatHistory = {} rayEngine.chatHistory = {}
rayEngine.chatPanelWidth, rayEngine.chatPanelHeight = math.floor(buffer.screen.width * 0.4), math.floor(buffer.screen.height * 0.4) rayEngine.chatPanelWidth, rayEngine.chatPanelHeight = math.floor(buffer.screen.width * 0.4), math.floor(buffer.screen.height * 0.4)
@ -319,7 +320,7 @@ function rayEngine.watch(x, y)
end end
local function addItemToChatHistory(text, color) local function addItemToChatHistory(text, color)
text = GUI.stringWrap({text}, rayEngine.chatPanelWidth - 2) text = string.wrap({text}, rayEngine.chatPanelWidth - 2)
table.insert(rayEngine.chatHistory, {color = color, text = text}) table.insert(rayEngine.chatHistory, {color = color, text = text})
if #rayEngine.chatHistory > rayEngine.chatHistoryLimit then table.remove(rayEngine.chatHistory, 1) end if #rayEngine.chatHistory > rayEngine.chatHistoryLimit then table.remove(rayEngine.chatHistory, 1) end
end end