1
0
mirror of https://github.com/LDDestroier/CC/ synced 2025-01-31 19:29:11 +00:00

Update pain.lua

This commit is contained in:
LDDestroier 2019-05-26 04:47:17 -04:00 committed by GitHub
parent fdad83c5c7
commit 2898b0b95a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2281,6 +2281,7 @@ local blockEnlargeFrame = function(frameNo)
end end
local displayMenu = function() local displayMenu = function()
doRender = false
menuOptions = {"File","Edit","Window","Set","About","Exit"} menuOptions = {"File","Edit","Window","Set","About","Exit"}
local diss = " "..tableconcat(menuOptions," ") local diss = " "..tableconcat(menuOptions," ")
local cleary = scr_y-math.floor(#diss/scr_x) local cleary = scr_y-math.floor(#diss/scr_x)
@ -2291,7 +2292,6 @@ local displayMenu = function()
if paint.doGray then if paint.doGray then
output = convertToGrayscale(output) output = convertToGrayscale(output)
end end
doRender = true
if not plc.fileName then if not plc.fileName then
renderBottomBar("Save as: ") renderBottomBar("Save as: ")
local fnguess = read() local fnguess = read()
@ -2385,7 +2385,6 @@ local displayMenu = function()
else else
exportMode = getRightToIt exportMode = getRightToIt
end end
doRender = true
if exportMode == false then return false end if exportMode == false then return false end
local pe, exportName, writeIndent, result local pe, exportName, writeIndent, result
if exportMode == 4 then if exportMode == 4 then
@ -2464,12 +2463,10 @@ local displayMenu = function()
saveToUndoBuffer() saveToUndoBuffer()
barmsg = "Cleared frame "..frame.."." barmsg = "Cleared frame "..frame.."."
end end
doRender = true
end end
local editDelFrame = function() local editDelFrame = function()
local outcum = bottomPrompt("Thou art sure? (Y/N)",_,"yn",{keys.leftCtrl,keys.rightCtrl}) local outcum = bottomPrompt("Thou art sure? (Y/N)",_,"yn",{keys.leftCtrl,keys.rightCtrl})
doRender = true
if outcum == "y" then if outcum == "y" then
if #paintEncoded == 1 then if #paintEncoded == 1 then
return editClear(true) return editClear(true)
@ -2507,7 +2504,6 @@ local displayMenu = function()
saveToUndoBuffer() saveToUndoBuffer()
barmsg = "Cropped frame." barmsg = "Cropped frame."
end end
doRender = true
end end
local editBoxCharSelector = function() local editBoxCharSelector = function()
paint.c = boxCharSelector() paint.c = boxCharSelector()
@ -2618,7 +2614,6 @@ I recommend using NFT if you don't need multiple frames, NFP if you don't need t
local menuFunctions = { local menuFunctions = {
[1] = function() --File [1] = function() --File
while true do while true do
--renderAllPAIN()
local output, longestLen = makeSubMenu(1,cleary-1,{ local output, longestLen = makeSubMenu(1,cleary-1,{
"Save", "Save",
"Save As", "Save As",
@ -2626,7 +2621,6 @@ I recommend using NFT if you don't need multiple frames, NFP if you don't need t
"Open", "Open",
((peripheral.find("printer")) and "Print" or nil) ((peripheral.find("printer")) and "Print" or nil)
}) })
doRender = true
if output == 1 then -- Save if output == 1 then -- Save
local _fname = fileExport(_,plc.defaultSaveFormat,plc.fileName) local _fname = fileExport(_,plc.defaultSaveFormat,plc.fileName)
if _fname then if _fname then
@ -2643,6 +2637,7 @@ I recommend using NFT if you don't need multiple frames, NFP if you don't need t
plc.fileName = oldfilename plc.fileName = oldfilename
end end
barmsg = "Saved as '"..plc.fileName.."'" barmsg = "Saved as '"..plc.fileName.."'"
break
elseif output == 3 then --Export elseif output == 3 then --Export
local res = fileExport(longestLen+1) local res = fileExport(longestLen+1)
if res then if res then
@ -2664,7 +2659,6 @@ I recommend using NFT if you don't need multiple frames, NFP if you don't need t
plc.undoBuffer = {deepCopy(paintEncoded)} plc.undoBuffer = {deepCopy(paintEncoded)}
barmsg = "Opened '" .. fs.getName(newPath) .. "'" barmsg = "Opened '" .. fs.getName(newPath) .. "'"
paint.scrollX, paint.scrollY, paint.doGray = 1, 1, false paint.scrollX, paint.scrollY, paint.doGray = 1, 1, false
doRender = true
end end
end end
break break
@ -2690,7 +2684,6 @@ I recommend using NFT if you don't need multiple frames, NFP if you don't need t
"Cut Region", "Cut Region",
"Paste Region" "Paste Region"
}) })
doRender = true
if output == 1 then if output == 1 then
editDelFrame() editDelFrame()
elseif output == 2 then elseif output == 2 then
@ -2720,7 +2713,6 @@ I recommend using NFT if you don't need multiple frames, NFP if you don't need t
end end
end end
saveToUndoBuffer() saveToUndoBuffer()
doRender = true
barmsg = "Shrunk image." barmsg = "Shrunk image."
end end
elseif output == 7 then elseif output == 7 then
@ -2741,7 +2733,6 @@ I recommend using NFT if you don't need multiple frames, NFP if you don't need t
"Set Scroll XY", "Set Scroll XY",
"Set Grid Colors" "Set Grid Colors"
}) })
doRender = true
if output == 1 then if output == 1 then
windowSetScrSize() windowSetScrSize()
elseif output == 2 then elseif output == 2 then
@ -2749,7 +2740,6 @@ I recommend using NFT if you don't need multiple frames, NFP if you don't need t
elseif output == 3 then elseif output == 3 then
rendback.b = paint.b rendback.b = paint.b
rendback.t = paint.t rendback.t = paint.t
doRender = true
elseif output == false then elseif output == false then
return "nobreak" return "nobreak"
end end
@ -2794,14 +2784,12 @@ I recommend using NFT if you don't need multiple frames, NFP if you don't need t
"File Formats", "File Formats",
"Help!" "Help!"
}) })
doRender = true
if output == 1 then if output == 1 then
aboutPAIN() aboutPAIN()
elseif output == 2 then elseif output == 2 then
aboutFileFormats() aboutFileFormats()
elseif output == 3 then elseif output == 3 then
guiHelp() guiHelp()
doRender = true
end end
end, end,
[6] = function() --Exit [6] = function() --Exit
@ -2811,7 +2799,6 @@ I recommend using NFT if you don't need multiple frames, NFP if you don't need t
if outcum == "y" then if outcum == "y" then
return "exit" return "exit"
else else
doRender = true
return nil return nil
end end
else else
@ -2867,10 +2854,12 @@ I recommend using NFT if you don't need multiple frames, NFP if you don't need t
local res = menuFunctions[cursor]() local res = menuFunctions[cursor]()
resetInputState() resetInputState()
if res == "exit" then if res == "exit" then
doRender = true
return "exit" return "exit"
elseif res == "nobreak" then elseif res == "nobreak" then
reRenderPAIN(true) reRenderPAIN(true)
else else
doRender = true
return return
end end
elseif key == keys.leftCtrl or key == keys.rightCtrl then elseif key == keys.leftCtrl or key == keys.rightCtrl then
@ -2887,8 +2876,8 @@ I recommend using NFT if you don't need multiple frames, NFP if you don't need t
end end
elseif event == "mouse_click" or event == "mouse_up" then elseif event == "mouse_click" or event == "mouse_up" then
if y < cleary then if y < cleary then
doRender = true
resetInputState() resetInputState()
doRender = true
return return
elseif key == 1 and initial+clickdelay < os.time() then --key? more like button elseif key == 1 and initial+clickdelay < os.time() then --key? more like button
for a = 1, #menuPoses do for a = 1, #menuPoses do
@ -2900,6 +2889,7 @@ I recommend using NFT if you don't need multiple frames, NFP if you don't need t
os.queueEvent("queue") os.queueEvent("queue")
os.pullEvent("queue") os.pullEvent("queue")
resetInputState() resetInputState()
doRender = true
if res == "exit" then if res == "exit" then
return "exit" return "exit"
else else
@ -3000,7 +2990,7 @@ local listAllMonitors = function()
end end
local getInput = function() --gotta catch them all local getInput = function() --gotta catch them all
local drawEveryEvent = false
local doot = function() 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
@ -3463,17 +3453,25 @@ 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 if drawEveryEvent and doRender then
end
parallel.waitForAny(doot, function()
while true do
sleep(0.05)
if doRender then
renderAllPAIN() renderAllPAIN()
doRender = false doRender = false
end end
end end
end) end
if drawEveryEvent then
doot()
else
parallel.waitForAny(doot, function()
while true do
sleep(0.05)
if doRender then
renderAllPAIN()
doRender = false
end
end
end)
end
end end
runPainEditor = function(...) --needs to be cleaned up runPainEditor = function(...) --needs to be cleaned up