mirror of
https://github.com/LDDestroier/CC/
synced 2025-02-09 15:40:03 +00:00
Merge pull request #2 from LDDestroier/filltool
Added delete functionality to fill tool
This commit is contained in:
commit
8e7c5969a0
32
pain.lua
32
pain.lua
@ -1698,7 +1698,7 @@ local reRenderPAIN = function(overrideRenderBar)
|
|||||||
doRenderBar = _reallyDoRenderBar
|
doRenderBar = _reallyDoRenderBar
|
||||||
end
|
end
|
||||||
|
|
||||||
local fillTool = function(_frame,cx,cy,dot) -- "_frame" is the frame NUMBER
|
local fillTool = function(_frame,cx,cy,dot,isDeleting) -- "_frame" is the frame NUMBER
|
||||||
local maxX, maxY = 0, 0
|
local maxX, maxY = 0, 0
|
||||||
local minX, minY = 0, 0
|
local minX, minY = 0, 0
|
||||||
paintEncoded = clearAllRedundant(paintEncoded)
|
paintEncoded = clearAllRedundant(paintEncoded)
|
||||||
@ -1767,12 +1767,12 @@ local fillTool = function(_frame,cx,cy,dot) -- "_frame" is the frame NUMBER
|
|||||||
end
|
end
|
||||||
local doBreak
|
local doBreak
|
||||||
local step = 0
|
local step = 0
|
||||||
local currentlyOnScreen
|
local currentlyOnScreen
|
||||||
while true do
|
while true do
|
||||||
doBreak = true
|
doBreak = true
|
||||||
for chY, v in pairs(check) do
|
for chY, v in pairs(check) do
|
||||||
for chX, isTrue in pairs(v) do
|
for chX, isTrue in pairs(v) do
|
||||||
currentlyOnScreen = (chX-paint.scrollX >= 1 and chX-paint.scrollX <= scr_x and chY-paint.scrollY >= 1 and chY-paint.scrollY <= scr_y)
|
currentlyOnScreen = (chX-paint.scrollX >= 1 and chX-paint.scrollX <= scr_x and chY-paint.scrollY >= 1 and chY-paint.scrollY <= scr_y)
|
||||||
if isTrue and (not touched[chY][chX]) then
|
if isTrue and (not touched[chY][chX]) then
|
||||||
step = step + 1
|
step = step + 1
|
||||||
if doFillAnimation then
|
if doFillAnimation then
|
||||||
@ -1780,13 +1780,17 @@ local fillTool = function(_frame,cx,cy,dot) -- "_frame" is the frame NUMBER
|
|||||||
reRenderPAIN(true)
|
reRenderPAIN(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
frame[#frame+1] = {
|
if isDeleting then
|
||||||
x = chX,
|
deleteDot(chX, chY)
|
||||||
y = chY,
|
else
|
||||||
c = dot.c,
|
frame[#frame+1] = {
|
||||||
t = dot.t,
|
x = chX,
|
||||||
b = dot.b
|
y = chY,
|
||||||
}
|
c = dot.c,
|
||||||
|
t = dot.t,
|
||||||
|
b = dot.b
|
||||||
|
}
|
||||||
|
end
|
||||||
touched[chY][chX] = true
|
touched[chY][chX] = true
|
||||||
-- check adjacent
|
-- check adjacent
|
||||||
if chkpos(chX+1, chY) then
|
if chkpos(chX+1, chY) then
|
||||||
@ -2966,14 +2970,14 @@ local getInput = function() --gotta catch them all
|
|||||||
local mevt
|
local mevt
|
||||||
repeat
|
repeat
|
||||||
mevt = {os.pullEvent()}
|
mevt = {os.pullEvent()}
|
||||||
until (mevt[1] == "key" and mevt[2] == keys.x) or (mevt[1] == "mouse_click" and mevt[2] == 1 and (mevt[4] or scr_y) < scr_y-(renderBlittle and 0 or doRenderBar))
|
until (mevt[1] == "key" and mevt[2] == keys.x) or (mevt[1] == "mouse_click" and mevt[2] <= 2 and (mevt[4] or scr_y) < scr_y-(renderBlittle and 0 or doRenderBar))
|
||||||
if not (mevt[1] == "key" and mevt[2] == keys.x) then
|
if not (mevt[1] == "key" and mevt[2] == keys.x) then
|
||||||
local x,y = mevt[3],mevt[4]
|
local x,y = mevt[3],mevt[4]
|
||||||
if renderBlittle then
|
if renderBlittle then
|
||||||
x = 2*x
|
x = 2*x
|
||||||
y = 3*y
|
y = 3*y
|
||||||
end
|
end
|
||||||
os.queueEvent("filltool_async", frame, x, y, paint)
|
os.queueEvent("filltool_async", frame, x, y, paint, mevt[2] == 2)
|
||||||
miceDown = {}
|
miceDown = {}
|
||||||
keysDown = {}
|
keysDown = {}
|
||||||
end
|
end
|
||||||
@ -3160,10 +3164,10 @@ runPainEditor = function(...) --needs to be cleaned up
|
|||||||
local event, frameNo, x, y, dot
|
local event, frameNo, x, y, dot
|
||||||
isCurrentlyFilling = false
|
isCurrentlyFilling = false
|
||||||
while true do
|
while true do
|
||||||
event, frameNo, x, y, dot = os.pullEvent("filltool_async")
|
event, frameNo, x, y, dot, isDeleting = os.pullEvent("filltool_async")
|
||||||
isCurrentlyFilling = true
|
isCurrentlyFilling = true
|
||||||
renderBottomBar("Filling area...")
|
renderBottomBar("Filling area...")
|
||||||
fillTool(frameNo, x, y, dot)
|
fillTool(frameNo, x, y, dot, isDeleting)
|
||||||
isCurrentlyFilling = false
|
isCurrentlyFilling = false
|
||||||
reRenderPAIN(false)
|
reRenderPAIN(false)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user