diff --git a/lib/ECSAPI.lua b/lib/ECSAPI.lua index 6d241462..101c9276 100644 --- a/lib/ECSAPI.lua +++ b/lib/ECSAPI.lua @@ -207,7 +207,7 @@ function ECSAPI.getFileFromUrl(url, path) local sContent = "" local result, response = pcall(internet.request, url) if not result then - ECSAPI.error("Could not connect to this Url.") + ECSAPI.error("Could not connect to to URL address \"" .. url .. "\"") return end @@ -738,11 +738,49 @@ end --Ожидание клика либо нажатия какой-либо клавиши function ECSAPI.waitForTouchOrClick() while true do - local e = {event.pull()} + local e = { event.pull() } if e[1] == "key_down" or e[1] == "touch" then break end end end +--То же самое, но в сокращенном варианте +function ECSAPI.wait() + ECSAPI.waitForTouchOrClick() +end + +--Нарисовать кнопочки закрытия окна +function ECSAPI.drawCloses(x, y, active) + local symbol = "⮾" + ecs.colorText(x, y , (active == 1 and ECSAPI.colors.blue) or 0xCC4C4C, symbol) + ecs.colorText(x + 2, y , (active == 2 and ECSAPI.colors.blue) or 0xDEDE6C, symbol) + ecs.colorText(x + 4, y , (active == 3 and ECSAPI.colors.blue) or 0x57A64E, symbol) +end + +--Нарисовать верхнюю оконную панель с выбором объектов +function ECSAPI.drawTopBar(x, y, width, selectedObject, background, foreground, ...) + local objects = { ... } + ECSAPI.square(x, y, width, 3, background) + local widthOfObjects = 0 + local spaceBetween = 2 + for i = 1, #objects do + widthOfObjects = widthOfObjects + unicode.len(objects[i][1]) + spaceBetween + end + local xPos = x + math.floor(width / 2 - widthOfObjects / 2) + for i = 1, #objects do + if i == selectedObject then + ECSAPI.square(xPos, y, unicode.len(objects[i][1]) + spaceBetween, 3, ecs.colors.blue) + gpu.setForeground(0xffffff) + else + gpu.setBackground(background) + gpu.setForeground(foreground) + end + 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]) + + xPos = xPos + unicode.len(objects[i][1]) + spaceBetween + end +end + --Функция отрисовки кнопки указанной ширины function ECSAPI.drawButton(x,y,width,height,text,backColor,textColor) x,y = ECSAPI.correctStartCoords(x,y,width,height) diff --git a/lib/image.lua b/lib/image.lua index 9b105bbc..5fc7ea46 100644 --- a/lib/image.lua +++ b/lib/image.lua @@ -382,7 +382,7 @@ function image.draw(x, y, rawPicture) --Получаем временную репрезентацию xPos, yPos, alpha, symbol = picture[background][foreground][i], picture[background][foreground][i + 1], picture[background][foreground][i + 2], picture[background][foreground][i + 3] --Если альфа имеется, но она не совсем прозрачна - if alpha > 0x00 and alpha < 0xFF then + if (alpha > 0x00 and alpha < 0xFF) or (alpha == 0xFF and symbol ~= " ")then _, _, currentBackground = gpu.get(x + xPos, y + yPos) currentBackground = alphaBlend(currentBackground, background, alpha) gpu.setBackground(currentBackground)