mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2026-01-17 16:42:39 +01:00
Фиксы слайдера и хуйнины этой
This commit is contained in:
parent
bcf574f073
commit
b04d685455
@ -235,6 +235,12 @@
|
||||
type="Library",
|
||||
version=1.08,
|
||||
},
|
||||
{
|
||||
path="/lib/scale.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/scale.lua",
|
||||
type="Library",
|
||||
version=1.08,
|
||||
},
|
||||
{
|
||||
path="/lib/MineOSInterface.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/MineOSInterface.lua",
|
||||
@ -292,7 +298,6 @@
|
||||
path="/lib/FormatModules/OCAF.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/FormatModules/OCAF.lua",
|
||||
type="Library",
|
||||
preloadFile=true,
|
||||
version=1.01,
|
||||
},
|
||||
{
|
||||
@ -319,7 +324,7 @@
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/GUI.lua",
|
||||
type="Library",
|
||||
preloadFile=true,
|
||||
version=2.15,
|
||||
version=2.16,
|
||||
},
|
||||
{
|
||||
path="/lib/rayEngine.lua",
|
||||
@ -842,7 +847,7 @@
|
||||
type="Application",
|
||||
icon="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/Applications/RunningString/Icon.pic",
|
||||
createShortcut=true,
|
||||
version=1.01,
|
||||
version=1.02,
|
||||
},
|
||||
{
|
||||
path="/MineOS/Applications/Graph2",
|
||||
|
||||
BIN
Applications/RunningString/Icon.pic
Normal file → Executable file
BIN
Applications/RunningString/Icon.pic
Normal file → Executable file
Binary file not shown.
@ -1,63 +1,47 @@
|
||||
local ecs = require("ECSAPI")
|
||||
local event = require("event")
|
||||
local gpu = require("component").gpu
|
||||
local MineOSInterface = require("MineOSInterface")
|
||||
local GUI = require("GUI")
|
||||
local buffer = require("doubleBuffering")
|
||||
local scale = require("scale")
|
||||
local unicode = require("unicode")
|
||||
local keyboard = require("keyboard")
|
||||
local event = require("event")
|
||||
|
||||
local str,freq,speed,scale,bg,fg
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- gpu.setResolution(gpu.maxResolution())
|
||||
-- ecs.prepareToExit()
|
||||
local container = MineOSInterface.addUniversalContainer(MineOSInterface.mainContainer, "Running string setup")
|
||||
|
||||
local data = ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true,
|
||||
{"EmptyLine"},
|
||||
{"CenterText", 0x880000, "Бегущая строка"},
|
||||
{"EmptyLine"},
|
||||
{"CenterText", 0x000000, "Для выхода из программы"},
|
||||
{"CenterText", 0x000000, "удерживайте Enter"},
|
||||
{"EmptyLine"},
|
||||
{"Input", 0x262626, 0x880000, "Программист за работой, не мешай, сука!"},
|
||||
{"Color", "Цвет фона", 0x000000},
|
||||
{"Color", "Цвет текста", 0xFFFFFF},
|
||||
{"Slider", 0x262626, 0x880000, 1, 100, 1, "Масштаб: ", "%"},
|
||||
{"Slider", 0x262626, 0x880000, 1, 100, 40, "Скорость: ", "/100 FPS"},
|
||||
{"EmptyLine"},
|
||||
{"Button", {0xbbbbbb, 0xffffff, "OK"}, {0x999999, 0xffffff, "Отмена"}}
|
||||
)
|
||||
local textInput = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xFFFFFF, 0x696969, 0xB4B4B4, 0xFFFFFF, 0x2D2D2D, "Working on cool things, don't distract me", "Type text here", true))
|
||||
local backgroundColorSelector = container.layout:addChild(GUI.colorSelector(1, 1, 36, 3, 0x0, "Background color"))
|
||||
local textColorSelector = container.layout:addChild(GUI.colorSelector(1, 1, 36, 3, 0xFFFFFF, "Text color"))
|
||||
local scaleSlider = container.layout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, 1, 1000, 100, false, "Scale: ", ""))
|
||||
local delaySlider = container.layout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, 0, 500, 50, false, "Delay: ", " ms"))
|
||||
local spacingSlider = container.layout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, 1, 50, 10, false, "Spacing: ", " char(s)"))
|
||||
scaleSlider.roundValues, delaySlider.roundValues, spacingSlider.roundValues = true, true, true
|
||||
spacingSlider.height = 2
|
||||
|
||||
-- ecs.error(table.unpack(data))
|
||||
if data[6] == "OK" then
|
||||
str = data[1] or "Где текст, сука?"
|
||||
bg = tonumber(data[2]) or 0x000000
|
||||
fg = tonumber(data[3]) or 0xFFFFFF
|
||||
scale = tonumber(data[4])/100 or 0.1
|
||||
speed = tonumber(data[5])/100 or 0.4
|
||||
freq = 5
|
||||
else
|
||||
return
|
||||
end
|
||||
|
||||
local xOld, yOld = gpu.getResolution()
|
||||
ecs.setScale(scale)
|
||||
local xSize, ySize = gpu.getResolution()
|
||||
gpu.setBackground(bg)
|
||||
gpu.setForeground(fg)
|
||||
gpu.fill(1, 1, xSize, ySize, " ")
|
||||
|
||||
str = " " .. str .. string.rep(" ", freq)
|
||||
|
||||
while true do
|
||||
str = unicode.sub(str, 2, -1) .. unicode.sub(str, 1, 1)
|
||||
gpu.set(math.ceil(xSize / 2 - unicode.len(str) / 2), math.ceil(ySize / 2), str)
|
||||
container.layout:addChild(GUI.button(1, 1, 36, 3, 0x2D2D2D, 0xFFFFFF, 0x0, 0xFFFFFF, "OK")).onTouch = function()
|
||||
local text = textInput.text .. string.rep(" ", math.round(spacingSlider.value))
|
||||
local gpu = buffer.getGPUProxy()
|
||||
|
||||
if keyboard.isKeyDown(28) then
|
||||
gpu.setResolution(xOld, yOld)
|
||||
ecs.prepareToExit()
|
||||
return
|
||||
scale.set(scaleSlider.value / 1000)
|
||||
local width, height = gpu.getResolution()
|
||||
local y = math.round(height / 2)
|
||||
|
||||
gpu.setBackground(backgroundColorSelector.color)
|
||||
gpu.setForeground(textColorSelector.color)
|
||||
gpu.fill(1, 1, width, height, " ")
|
||||
|
||||
while true do
|
||||
local eventData = {event.pull(delaySlider.value / 1000)}
|
||||
if eventData[1] == "touch" or eventData[1] == "key_down" then
|
||||
break
|
||||
end
|
||||
|
||||
text = unicode.sub(text, 2, -1) .. unicode.sub(text, 1, 1)
|
||||
gpu.set(1, y, text)
|
||||
end
|
||||
|
||||
local e = event.pull(speed)
|
||||
if e == "key_down" or e == "touch" then return end
|
||||
buffer.setResolution(buffer.getResolution())
|
||||
MineOSInterface.OSDraw()
|
||||
end
|
||||
|
||||
|
||||
|
||||
@ -1661,18 +1661,18 @@ local function sliderDraw(object)
|
||||
buffer.text(math.floor(object.x + object.width / 2 - unicode.len(stringCurrentValue) / 2), object.y + 1, object.colors.value, stringCurrentValue)
|
||||
end
|
||||
|
||||
local activeWidth = math.floor(object.width - ((object.maximumValue - object.value) * object.width / (object.maximumValue - object.minimumValue)))
|
||||
local activeWidth = math.round((object.value - object.minimumValue) / (object.maximumValue - object.minimumValue) * object.width)
|
||||
buffer.text(object.x, object.y, object.colors.passive, string.rep("━", object.width))
|
||||
buffer.text(object.x, object.y, object.colors.active, string.rep("━", activeWidth))
|
||||
buffer.text(object.x + activeWidth - 1, object.y, object.colors.pipe, "⬤")
|
||||
buffer.text(object.x + activeWidth, object.y, object.colors.pipe, "⬤")
|
||||
|
||||
return object
|
||||
end
|
||||
|
||||
local function sliderEventHandler(mainContainer, object, eventData)
|
||||
if eventData[1] == "touch" or eventData[1] == "drag" then
|
||||
local clickPosition = eventData[3] - object.x + 1
|
||||
object.value = object.minimumValue + (clickPosition * (object.maximumValue - object.minimumValue) / object.width)
|
||||
local clickPosition = eventData[3] - object.x
|
||||
object.value = object.minimumValue + (clickPosition / object.width * (object.maximumValue - object.minimumValue))
|
||||
mainContainer:draw()
|
||||
buffer.draw()
|
||||
callMethod(object.onValueChanged, object.value, eventData)
|
||||
|
||||
@ -17,8 +17,8 @@ end
|
||||
function screenScale.getResolution(scale, debug)
|
||||
if scale > 1 then
|
||||
scale = 1
|
||||
elseif scale < 0.1 then
|
||||
scale = 0.1
|
||||
elseif scale <= 0.01 then
|
||||
scale = 0.01
|
||||
end
|
||||
|
||||
local xScreens, yScreens = component.proxy(component.gpu.getScreen()).getAspectRatio()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user