mirror of
https://github.com/LDDestroier/CC/
synced 2025-01-19 13:42:54 +00:00
Slightly improved renderer
This commit is contained in:
parent
1cc951abaa
commit
fdad83c5c7
30
pain.lua
30
pain.lua
@ -3000,16 +3000,22 @@ local listAllMonitors = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local getInput = function() --gotta catch them all
|
local getInput = function() --gotta catch them all
|
||||||
|
|
||||||
|
local doot = function()
|
||||||
local button, x, y, oldmx, oldmy, origx, origy
|
local button, x, y, oldmx, oldmy, origx, origy
|
||||||
local isDragging = false
|
local isDragging = false
|
||||||
local proceed = false
|
local proceed = false
|
||||||
|
local evt, oldx, oldy = {}
|
||||||
|
local button, points, key, dir
|
||||||
renderBar(barmsg)
|
renderBar(barmsg)
|
||||||
while true do
|
while true do
|
||||||
doRender = false
|
evt = {getEvents("mouse_scroll","mouse_click", "mouse_drag","mouse_up","key","key_up",true)}
|
||||||
local oldx,oldy = paint.scrollX,paint.scrollY
|
|
||||||
local evt = {getEvents("mouse_scroll","mouse_click", "mouse_drag","mouse_up","key","key_up",true)}
|
--doRender = false
|
||||||
|
oldx, oldy = paint.scrollX,paint.scrollY
|
||||||
|
|
||||||
if (evt[1] == "mouse_scroll") and (not viewing) then
|
if (evt[1] == "mouse_scroll") and (not viewing) then
|
||||||
local dir = evt[2]
|
dir = evt[2]
|
||||||
if dir == 1 then
|
if dir == 1 then
|
||||||
if keysDown[keys.leftShift] or keysDown[keys.rightShift] then
|
if keysDown[keys.leftShift] or keysDown[keys.rightShift] then
|
||||||
paint.t = paint.t * 2
|
paint.t = paint.t * 2
|
||||||
@ -3066,7 +3072,7 @@ local getInput = function() --gotta catch them all
|
|||||||
dragPoses[1] = {x=x,y=y}
|
dragPoses[1] = {x=x,y=y}
|
||||||
end
|
end
|
||||||
dragPoses[2] = {x=x,y=y}
|
dragPoses[2] = {x=x,y=y}
|
||||||
local points = getDotsInLine(dragPoses[1].x,dragPoses[1].y,dragPoses[2].x,dragPoses[2].y)
|
points = getDotsInLine(dragPoses[1].x,dragPoses[1].y,dragPoses[2].x,dragPoses[2].y)
|
||||||
renderAllPAIN()
|
renderAllPAIN()
|
||||||
for a = 1, #points do
|
for a = 1, #points do
|
||||||
term.setCursorPos(points[a].x, points[a].y)
|
term.setCursorPos(points[a].x, points[a].y)
|
||||||
@ -3074,7 +3080,7 @@ local getInput = function() --gotta catch them all
|
|||||||
end
|
end
|
||||||
elseif (not dontDragThisTime) then
|
elseif (not dontDragThisTime) then
|
||||||
if evt[1] == "mouse_drag" then
|
if evt[1] == "mouse_drag" then
|
||||||
local points = getDotsInLine(linePoses[1].x,linePoses[1].y,linePoses[2].x,linePoses[2].y)
|
points = getDotsInLine(linePoses[1].x,linePoses[1].y,linePoses[2].x,linePoses[2].y)
|
||||||
for a = 1, #points do
|
for a = 1, #points do
|
||||||
putDotDown({x=points[a].x, y=points[a].y})
|
putDotDown({x=points[a].x, y=points[a].y})
|
||||||
end
|
end
|
||||||
@ -3100,12 +3106,12 @@ local getInput = function() --gotta catch them all
|
|||||||
end
|
end
|
||||||
elseif (evt[1] == "mouse_up") and (not viewing) and (not plc.isCurrentlyFilling) then
|
elseif (evt[1] == "mouse_up") and (not viewing) and (not plc.isCurrentlyFilling) then
|
||||||
origx,origy = 0,0
|
origx,origy = 0,0
|
||||||
local button = evt[2]
|
button = evt[2]
|
||||||
miceDown[button] = false
|
miceDown[button] = false
|
||||||
oldmx,oldmy = nil,nil
|
oldmx,oldmy = nil,nil
|
||||||
lastMX, lastMY = nil,nil
|
lastMX, lastMY = nil,nil
|
||||||
if isDragging then
|
if isDragging then
|
||||||
local points = getDotsInLine(dragPoses[1].x,dragPoses[1].y,dragPoses[2].x,dragPoses[2].y)
|
points = getDotsInLine(dragPoses[1].x,dragPoses[1].y,dragPoses[2].x,dragPoses[2].y)
|
||||||
for a = 1, #points do
|
for a = 1, #points do
|
||||||
putDotDown({x=points[a].x, y=points[a].y})
|
putDotDown({x=points[a].x, y=points[a].y})
|
||||||
end
|
end
|
||||||
@ -3115,7 +3121,7 @@ local getInput = function() --gotta catch them all
|
|||||||
saveToUndoBuffer()
|
saveToUndoBuffer()
|
||||||
isDragging = false
|
isDragging = false
|
||||||
elseif evt[1] == "key" then
|
elseif evt[1] == "key" then
|
||||||
local key = evt[2]
|
key = evt[2]
|
||||||
if (isDragging or not keysDown[keys.leftShift]) and (keysDown[keys.tab]) then
|
if (isDragging or not keysDown[keys.leftShift]) and (keysDown[keys.tab]) then
|
||||||
if key == keys.right and (not keysDown[keys.right]) then
|
if key == keys.right and (not keysDown[keys.right]) then
|
||||||
paint.scrollX = paint.scrollX + 1
|
paint.scrollX = paint.scrollX + 1
|
||||||
@ -3457,11 +3463,17 @@ local getInput = function() --gotta catch them all
|
|||||||
if (oldx~=paint.scrollX) or (oldy~=paint.scrollY) then
|
if (oldx~=paint.scrollX) or (oldy~=paint.scrollY) then
|
||||||
doRender = true
|
doRender = true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
parallel.waitForAny(doot, function()
|
||||||
|
while true do
|
||||||
|
sleep(0.05)
|
||||||
if doRender then
|
if doRender then
|
||||||
renderAllPAIN()
|
renderAllPAIN()
|
||||||
doRender = false
|
doRender = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
runPainEditor = function(...) --needs to be cleaned up
|
runPainEditor = function(...) --needs to be cleaned up
|
||||||
|
Loading…
Reference in New Issue
Block a user