Хей, еу_томат, хей

This commit is contained in:
Igor Timofeev 2018-09-18 18:42:51 +03:00
parent 104233217a
commit d5bacbd379
2 changed files with 16 additions and 63 deletions

View File

@ -91,7 +91,7 @@ function MineOSCore.loadPropeties()
tasks = {},
timeUseRealTimestamp = true,
dateFormat = "%d %b %Y %H:%M:%S",
packageUnloading = true,
packageUnloading = false,
transparencyEnabled = true,
showApplicationIcons = true,
iconHorizontalSpaceBetween = 1,

View File

@ -1,76 +1,34 @@
-- CopyPizding from eu_tomat *meowderful* guide
local component = require("component")
local screenScale = {}
------------------------------------------------------------------------------------------------------
local function calculateAspect(screens)
if screens == 2 then
return 28
elseif screens > 2 then
return 28 + (screens - 2) * 16
else
return 12
end
end
function screenScale.getResolution(scale, debug)
if scale > 1 then
if not scale or scale > 1 then
scale = 1
elseif scale <= 0.01 then
scale = 0.01
elseif scale < 0.1 then
scale = 0.1
end
local xScreens, yScreens = component.proxy(component.gpu.getScreen()).getAspectRatio()
local xPixels, yPixels = calculateAspect(xScreens), calculateAspect(yScreens)
local proportion = xPixels / yPixels
local gpu = component.gpu
local sw, sh = component.proxy(gpu.getScreen()).getAspectRatio()
local sa = (sw * 2 - 0.5) / (sh - 0.25)
local xMax, yMax = component.gpu.maxResolution()
local newWidth, newHeight
if proportion >= 1 then
newWidth = xMax
newHeight = math.floor(newWidth / proportion / 2)
local gw, gh = gpu.maxResolution()
if sa > gw / gh then
gh = gw / sa
else
newHeight = yMax
newWidth = math.floor(newHeight * proportion * 2)
gw = gh * sa
end
local optimalNewWidth, optimalNewHeight = newWidth, newHeight
if optimalNewWidth > xMax then
local difference = newWidth / xMax
optimalNewWidth = xMax
optimalNewHeight = math.ceil(newHeight / difference)
end
if optimalNewHeight > yMax then
local difference = newHeight / yMax
optimalNewHeight = yMax
optimalNewWidth = math.ceil(newWidth / difference)
end
local finalNewWidth, finalNewHeight = math.floor(optimalNewWidth * scale), math.floor(optimalNewHeight * scale)
if debug then
print(" ")
print("Максимальное разрешение: "..xMax.."x"..yMax)
print("Пропорция монитора: "..xPixels.."x"..yPixels)
print("Коэффициент пропорции: "..proportion)
print(" ")
print("Теоретическое разрешение: "..newWidth.."x"..newHeight)
print("Оптимизированное разрешение: "..optimalNewWidth.."x"..optimalNewHeight)
print(" ")
print("Новое разрешение: "..finalNewWidth.."x"..finalNewHeight)
print(" ")
end
return finalNewWidth, finalNewHeight
return math.floor(gw * scale), math.floor(gh * scale)
end
--Установка масштаба монитора
function screenScale.set(scale, debug)
--Устанавливаем выбранное разрешение
component.gpu.setResolution(screenScale.getResolution(scale, debug))
function screenScale.set(scale)
component.gpu.setResolution(screenScale.getResolution(scale))
end
------------------------------------------------------------------------------------------------------
@ -80,8 +38,3 @@ end
------------------------------------------------------------------------------------------------------
return screenScale