mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2026-09-14 11:06:16 +05:00
Фича закрытия всех открытых окон
This commit is contained in:
parent
e9f09fceda
commit
08bbce5b53
@ -5,7 +5,7 @@
|
||||
about="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Localization/About/",
|
||||
type="Script",
|
||||
forceDownload=true,
|
||||
version=3.93,
|
||||
version=3.94,
|
||||
},
|
||||
{
|
||||
path="/MineOS/Pictures/MoonTouch.pic",
|
||||
@ -257,7 +257,7 @@
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/web.lua",
|
||||
type="Library",
|
||||
preloadFile=true,
|
||||
version=1.05,
|
||||
version=1.06,
|
||||
},
|
||||
{
|
||||
path="/lib/event.lua",
|
||||
@ -347,7 +347,7 @@
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/doubleBuffering.lua",
|
||||
type="Library",
|
||||
preloadFile=true,
|
||||
version=1.32,
|
||||
version=1.33,
|
||||
},
|
||||
{
|
||||
path="/lib/compressor.lua",
|
||||
@ -844,7 +844,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/Graph2/Icon.pic",
|
||||
createShortcut=true,
|
||||
version=1.00,
|
||||
version=1.01,
|
||||
},
|
||||
{
|
||||
path="/MineOS/Applications/Battleship",
|
||||
|
||||
@ -15,15 +15,15 @@ local xOffset, yOffset, xDrag, yDrag, points = 0, 0, 1, 1
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
|
||||
window.backgroundPanel.localPosition.y, window.backgroundPanel.height = 4, window.backgroundPanel.height - 3
|
||||
local titlePanel = window:addChild(GUI.panel(1, 1, window.width, 3, 0x2D2D2D, 0.1))
|
||||
local titlePanel = window:addChild(GUI.panel(1, 1, window.width, 3, 0x2D2D2D))
|
||||
local layout = window:addChild(GUI.layout(1, 1, window.width, 3, 1, 1))
|
||||
layout:setCellDirection(1, 1, GUI.directions.horizontal)
|
||||
layout:setCellSpacing(1, 1, 3)
|
||||
|
||||
local switchAndLabel = layout:addChild(GUI.switchAndLabel(1, 1, 16, 6, 0x66DB80, 0x1D1D1D, 0xEEEEEE, 0x999999, "Quants:", false))
|
||||
local scaleSlider = layout:addChild(GUI.slider(1, 1, 12, 0x66DB80, 0x0, 0xFFFFFF, 0x999999, 1, 1000, 400, false, "Scale: ", "%"))
|
||||
local rangeSlider = layout:addChild(GUI.slider(1, 1, 12, 0x66DB80, 0x0, 0xFFFFFF, 0x999999, 5, 60, 25, false, "Range: ", ""))
|
||||
local precisionSlider = layout:addChild(GUI.slider(1, 1, 12, 0x66DB80, 0x0, 0xFFFFFF, 0x999999, 10, 100, 72, false, "Precision: ", ""))
|
||||
local switchAndLabel = layout:addChild(GUI.switchAndLabel(1, 1, 16, 6, 0x66DB80, 0x1D1D1D, 0xE1E1E1, 0xBBBBBB, "Quants:", false))
|
||||
local scaleSlider = layout:addChild(GUI.slider(1, 1, 12, 0x66DB80, 0x0, 0xFFFFFF, 0xBBBBBB, 1, 1000, 400, false, "Scale: ", "%"))
|
||||
local rangeSlider = layout:addChild(GUI.slider(1, 1, 12, 0x66DB80, 0x0, 0xFFFFFF, 0xBBBBBB, 2, 60, 25, false, "Range: ", ""))
|
||||
local precisionSlider = layout:addChild(GUI.slider(1, 1, 12, 0x66DB80, 0x0, 0xFFFFFF, 0xBBBBBB, 10, 99, 72, false, "Step: 0.", ""))
|
||||
local functionButton = window:addChild(GUI.button(1, 1, 1, 3, 0xE1E1E1, 0x3C3C3C, 0xCCCCCC, 0x3C3C3C, ""))
|
||||
|
||||
window.actionButtons:moveToFront()
|
||||
@ -103,6 +103,8 @@ end
|
||||
rangeSlider.onValueChanged = scaleSlider.onValueChanged
|
||||
precisionSlider.onValueChanged = scaleSlider.onValueChanged
|
||||
|
||||
scaleSlider.roundValues, rangeSlider.roundValues, precisionSlider.roundValues = true, true, true
|
||||
|
||||
window.onResize = function(width, height)
|
||||
window.backgroundPanel.width, window.backgroundPanel.height = width, height - 3
|
||||
graph.width, graph.height = width, height - 3
|
||||
|
||||
8
OS.lua
8
OS.lua
@ -368,6 +368,14 @@ local function createOSWindow()
|
||||
moveDockIcon(indexOf, -1)
|
||||
end
|
||||
menu:addSeparator()
|
||||
if icon.windows then
|
||||
menu:addItem(MineOSCore.localization.closeAllWindows).onTouch = function()
|
||||
for window in pairs(icon.windows) do
|
||||
window:close()
|
||||
end
|
||||
MineOSInterface.OSDraw()
|
||||
end
|
||||
end
|
||||
if icon.keepInDock then
|
||||
if #MineOSInterface.mainContainer.dockContainer.children > 1 then
|
||||
menu:addItem(MineOSCore.localization.removeFromDock).onTouch = function()
|
||||
|
||||
@ -176,7 +176,7 @@ function buffer.paste(x, y, copyArray)
|
||||
end
|
||||
end
|
||||
|
||||
function buffer.line(x1, y1, x2, y2, background, foreground, alpha, symbol)
|
||||
function buffer.rasterizeLine(x1, y1, x2, y2, method)
|
||||
local inLoopValueFrom, inLoopValueTo, outLoopValueFrom, outLoopValueTo, isReversed, inLoopValueDelta, outLoopValueDelta = x1, x2, y1, y2, false, math.abs(x2 - x1), math.abs(y2 - y1)
|
||||
if inLoopValueDelta < outLoopValueDelta then
|
||||
inLoopValueFrom, inLoopValueTo, outLoopValueFrom, outLoopValueTo, isReversed, inLoopValueDelta, outLoopValueDelta = y1, y2, x1, x2, true, outLoopValueDelta, inLoopValueDelta
|
||||
@ -191,9 +191,9 @@ function buffer.line(x1, y1, x2, y2, background, foreground, alpha, symbol)
|
||||
local outLoopValueTrigger = outLoopValueTriggerIncrement
|
||||
for inLoopValue = inLoopValueFrom, inLoopValueTo, inLoopValueFrom < inLoopValueTo and 1 or -1 do
|
||||
if isReversed then
|
||||
buffer.set(outLoopValue, inLoopValue, background, foreground, alpha, symbol)
|
||||
method(outLoopValue, inLoopValue)
|
||||
else
|
||||
buffer.set(inLoopValue, outLoopValue, background, foreground, alpha, symbol)
|
||||
method(inLoopValue, outLoopValue)
|
||||
end
|
||||
|
||||
outLoopValueCounter = outLoopValueCounter + 1
|
||||
@ -203,6 +203,12 @@ function buffer.line(x1, y1, x2, y2, background, foreground, alpha, symbol)
|
||||
end
|
||||
end
|
||||
|
||||
function buffer.line(x1, y1, x2, y2, background, foreground, alpha, symbol)
|
||||
buffer.rasterizeLine(x1, y1, x2, y2, function(x, y)
|
||||
buffer.set(x, y, background, foreground, alpha, symbol)
|
||||
end)
|
||||
end
|
||||
|
||||
function buffer.text(x, y, textColor, text, transparency)
|
||||
local index, sText = buffer.getIndexByCoordinates(x, y), unicode.len(text)
|
||||
|
||||
@ -332,30 +338,9 @@ function buffer.semiPixelSquare(x, y, width, height, color)
|
||||
end
|
||||
|
||||
function buffer.semiPixelLine(x1, y1, x2, y2, color)
|
||||
local inLoopValueFrom, inLoopValueTo, outLoopValueFrom, outLoopValueTo, isReversed, inLoopValueDelta, outLoopValueDelta = x1, x2, y1, y2, false, math.abs(x2 - x1), math.abs(y2 - y1)
|
||||
if inLoopValueDelta < outLoopValueDelta then
|
||||
inLoopValueFrom, inLoopValueTo, outLoopValueFrom, outLoopValueTo, isReversed, inLoopValueDelta, outLoopValueDelta = y1, y2, x1, x2, true, outLoopValueDelta, inLoopValueDelta
|
||||
end
|
||||
|
||||
if outLoopValueFrom > outLoopValueTo then
|
||||
outLoopValueFrom, outLoopValueTo = outLoopValueTo, outLoopValueFrom
|
||||
inLoopValueFrom, inLoopValueTo = inLoopValueTo, inLoopValueFrom
|
||||
end
|
||||
|
||||
local outLoopValue, outLoopValueCounter, outLoopValueTriggerIncrement = outLoopValueFrom, 1, inLoopValueDelta / outLoopValueDelta
|
||||
local outLoopValueTrigger = outLoopValueTriggerIncrement
|
||||
for inLoopValue = inLoopValueFrom, inLoopValueTo, inLoopValueFrom < inLoopValueTo and 1 or -1 do
|
||||
if isReversed then
|
||||
buffer.semiPixelSet(outLoopValue, inLoopValue, color)
|
||||
else
|
||||
buffer.semiPixelSet(inLoopValue, outLoopValue, color)
|
||||
end
|
||||
|
||||
outLoopValueCounter = outLoopValueCounter + 1
|
||||
if outLoopValueCounter > outLoopValueTrigger then
|
||||
outLoopValue, outLoopValueTrigger = outLoopValue + 1, outLoopValueTrigger + outLoopValueTriggerIncrement
|
||||
end
|
||||
end
|
||||
buffer.rasterizeLine(x1, y1, x2, y2, function(x, y)
|
||||
buffer.semiPixelSet(x, y, color)
|
||||
end)
|
||||
end
|
||||
|
||||
function buffer.semiPixelCircle(xCenter, yCenter, radius, color)
|
||||
|
||||
108
lib/web.lua
108
lib/web.lua
@ -1,35 +1,42 @@
|
||||
|
||||
----------------------------------------- Libraries -----------------------------------------
|
||||
|
||||
local fs = require("filesystem")
|
||||
local component = require("component")
|
||||
local web = {}
|
||||
|
||||
----------------------------------------- Main methods -----------------------------------------
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
function web.request(url)
|
||||
local pcallSuccess, requestHandle, requestReason = pcall(component.internet.request, url)
|
||||
|
||||
-- Если функция компонента была вызвана верно, то идем дальше
|
||||
if pcallSuccess then
|
||||
-- Если компонент вернул там хендл соединения, то читаем ответ из него
|
||||
-- Хендл может не вернуться в случае хуевой урл-ки, которая не нравится компоненту
|
||||
if requestHandle then
|
||||
local responseData = ""
|
||||
-- Читаем данные из хендла по кусочкам
|
||||
while true do
|
||||
local data, reason = requestHandle.read(math.huge)
|
||||
-- Если прочтение удалость, то записываем кусочек в буфер
|
||||
if data then
|
||||
responseData = responseData .. data
|
||||
local function rawRequest(url, postData, headers, chunkHandler)
|
||||
local stringPostData
|
||||
if postData then
|
||||
if type(postData) == "table" then
|
||||
stringPostData = ""
|
||||
for key, value in pairs(postData) do
|
||||
if type(value) == "table" then
|
||||
for i = 1, #value do
|
||||
stringPostData = stringPostData .. "&" .. key .. "[" .. (i - 1) .. "]=" .. value[i]
|
||||
end
|
||||
else
|
||||
stringPostData = stringPostData .. "&" .. key .. "=" .. value
|
||||
end
|
||||
end
|
||||
elseif type(postData) == "string" then
|
||||
stringPostData = postData
|
||||
end
|
||||
end
|
||||
|
||||
local pcallSuccess, requestHandle, requestReason = pcall(component.internet.request, url, stringPostData, headers)
|
||||
if pcallSuccess then
|
||||
if requestHandle then
|
||||
while true do
|
||||
local chunk, reason = requestHandle.read(math.huge)
|
||||
if chunk then
|
||||
chunkHandler(chunk)
|
||||
else
|
||||
-- Если чтение не удалось, и существует некий прочитанный кусочек, то в нем стопудова содержится ошибка чтения
|
||||
requestHandle:close()
|
||||
if reason then
|
||||
return false, reason
|
||||
-- А если кусочка нет, то это значит, что соединение можно закрывать с чистой совестью и возвращать всю инфу
|
||||
else
|
||||
return responseData
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -41,20 +48,40 @@ function web.request(url)
|
||||
end
|
||||
end
|
||||
|
||||
function web.downloadFile(url, path)
|
||||
local result, reason = web.request(url)
|
||||
if result then
|
||||
fs.makeDirectory(fs.path(path) or "")
|
||||
local file = io.open(path, "w")
|
||||
file:write(result)
|
||||
file:close()
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
return result
|
||||
function web.request(url, postData, headers)
|
||||
local data = ""
|
||||
local success, reason = rawRequest(url, postData, headers, function(chunk)
|
||||
data = data .. chunk
|
||||
end)
|
||||
|
||||
if success then
|
||||
return data
|
||||
else
|
||||
return false, "Could not connect to to URL-address \"" .. tostring(url) .. "\", the reason is \"" .. tostring(reason) .. "\""
|
||||
return false, reason
|
||||
end
|
||||
end
|
||||
|
||||
function web.downloadFile(url, path)
|
||||
fs.makeDirectory(fs.path(path) or "")
|
||||
local file, reason = io.open(path, "w")
|
||||
if file then
|
||||
local success, reason = rawRequest(url, nil, nil, function(chunk)
|
||||
file:write(chunk)
|
||||
end)
|
||||
|
||||
file:close()
|
||||
if success then
|
||||
return true
|
||||
else
|
||||
return false, "Could not connect to to URL-address \"" .. tostring(url) .. "\", the reason is \"" .. tostring(reason) .. "\""
|
||||
end
|
||||
else
|
||||
return false, "Failed to open file for writing: " .. tostring(reason)
|
||||
end
|
||||
end
|
||||
|
||||
function web.runScript(url)
|
||||
local result, reason = web.request(url)
|
||||
if success then
|
||||
@ -108,20 +135,17 @@ function web.downloadMineOSApplication(application, language)
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------------
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
-- web.downloadMineOSApplication({
|
||||
-- path="/MineOS/Applications/3DTest",
|
||||
-- url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/3DTest/3DTest.lua",
|
||||
-- about="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/3DTest/About/",
|
||||
-- type="Application",
|
||||
-- icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/3DTest/Icon.pic",
|
||||
-- createShortcut="desktop",
|
||||
-- forceDownload=true,
|
||||
-- version=1.16,
|
||||
-- })
|
||||
-- print(web.request("http://94.242.34.251:8888/MineOS/AppMarket/test.php", {
|
||||
-- abc = "siski",
|
||||
-- def = {"meow", "sex", "pizda"},
|
||||
-- ghi = 123
|
||||
-- }))
|
||||
|
||||
----------------------------------------- Cyka -----------------------------------------
|
||||
-- web.downloadFile("https://github.com/IgorTimofeev/OpenComputers/raw/master/Wallpapers/CloudyEvening.pic", "Clouds.pic")
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
return web
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user