mirror of
https://github.com/LDDestroier/CC/
synced 2025-03-06 19:48:11 +00:00
Will not draw unchanged rows
This commit is contained in:
parent
aa16749037
commit
d575a3b660
@ -104,7 +104,10 @@ local cwrite = function(text, y, terminal)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- start up lddterm (I'm starting to think I should've used window API)
|
-- start up lddterm (I'm starting to think I should've used window API)
|
||||||
local lddterm = {}
|
local lddterm = {
|
||||||
|
FULL_IMAGE = false,
|
||||||
|
OLD_IMAGE = false,
|
||||||
|
}
|
||||||
lddterm.alwaysRender = false -- renders after any and all screen-changing functions.
|
lddterm.alwaysRender = false -- renders after any and all screen-changing functions.
|
||||||
lddterm.useColors = true -- normal computers do not allow color, but this variable doesn't do anything yet
|
lddterm.useColors = true -- normal computers do not allow color, but this variable doesn't do anything yet
|
||||||
lddterm.baseTerm = term.current() -- will draw to this terminal
|
lddterm.baseTerm = term.current() -- will draw to this terminal
|
||||||
@ -263,23 +266,26 @@ local fixCursorPos = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- renders the screen with optional transformation function
|
-- renders the screen with optional transformation function
|
||||||
lddterm.render = function(transformation, drawFunction)
|
lddterm.render = function(transformation, drawFunction, forceDraw)
|
||||||
-- determine new screen size and change lddterm screen to fit
|
-- determine new screen size and change lddterm screen to fit
|
||||||
old_scr_x, old_scr_y = scr_x, scr_y
|
old_scr_x, old_scr_y = scr_x, scr_y
|
||||||
determineScreenSize()
|
determineScreenSize()
|
||||||
if old_scr_x ~= scr_x or old_scr_y ~= scr_y then
|
if old_scr_x ~= scr_x or old_scr_y ~= scr_y then
|
||||||
lddterm.baseTerm.clear()
|
lddterm.baseTerm.clear()
|
||||||
end
|
end
|
||||||
local image = lddterm.screenshot()
|
lddterm.OLD_IMAGE = lddterm.FULL_IMAGE or {{},{},{}}
|
||||||
|
lddterm.FULL_IMAGE = lddterm.screenshot()
|
||||||
if type(transformation) == "function" then
|
if type(transformation) == "function" then
|
||||||
image = transformation(image)
|
lddterm.FULL_IMAGE = transformation(lddterm.FULL_IMAGE)
|
||||||
end
|
end
|
||||||
if drawFunction then
|
if drawFunction then
|
||||||
drawFunction(image, lddterm.baseTerm)
|
drawFunction(lddterm.FULL_IMAGE, lddterm.baseTerm)
|
||||||
else
|
else
|
||||||
for y = 1, #image[1] do
|
for y = 1, #lddterm.FULL_IMAGE[1] do
|
||||||
lddterm.baseTerm.setCursorPos(1 + lddterm.adjustX, y + lddterm.adjustY)
|
if forceDraw or (lddterm.FULL_IMAGE[1][y] ~= lddterm.OLD_IMAGE[1][y]) or (lddterm.FULL_IMAGE[2][y] ~= lddterm.OLD_IMAGE[2][y]) or (lddterm.FULL_IMAGE[3][y] ~= lddterm.OLD_IMAGE[3][y]) then
|
||||||
lddterm.baseTerm.blit(image[1][y], image[2][y], image[3][y])
|
lddterm.baseTerm.setCursorPos(1 + lddterm.adjustX, y + lddterm.adjustY)
|
||||||
|
lddterm.baseTerm.blit(lddterm.FULL_IMAGE[1][y], lddterm.FULL_IMAGE[2][y], lddterm.FULL_IMAGE[3][y])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if doDrawWorkspaceIndicator then
|
if doDrawWorkspaceIndicator then
|
||||||
@ -493,7 +499,7 @@ lddterm.newWindow = function(width, height, x, y, meta)
|
|||||||
window.x = math.floor(x or window.x)
|
window.x = math.floor(x or window.x)
|
||||||
window.y = math.floor(y or window.y)
|
window.y = math.floor(y or window.y)
|
||||||
if lddterm.alwaysRender then
|
if lddterm.alwaysRender then
|
||||||
lddterm.render(lddterm.transformation, lddterm.drawFunction)
|
lddterm.render(lddterm.transformation, lddterm.drawFunction, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
window.handle.setPaletteColor = function(slot, r, g, b)
|
window.handle.setPaletteColor = function(slot, r, g, b)
|
||||||
@ -1124,8 +1130,9 @@ local main = function()
|
|||||||
|
|
||||||
-- if true, timer events won't be accepted by instances (unless it's an extraEvent)
|
-- if true, timer events won't be accepted by instances (unless it's an extraEvent)
|
||||||
local banTimerEvent, evt
|
local banTimerEvent, evt
|
||||||
local doRedraw = false -- redraw screen after resuming every instance
|
local doRedraw = false -- redraw screen after resuming every instance
|
||||||
local doTick = true -- check for key inputs and whatnot
|
local doForceRedraw = false -- redraw screen without checking for changes in screen
|
||||||
|
local doTick = true -- check for key inputs and whatnot
|
||||||
|
|
||||||
local checkIfExtraEvents = function()
|
local checkIfExtraEvents = function()
|
||||||
for y = gridMinY, gridHeight do
|
for y = gridMinY, gridHeight do
|
||||||
@ -1145,6 +1152,7 @@ local main = function()
|
|||||||
while isRunning do
|
while isRunning do
|
||||||
gridWidth, gridHeight, gridMinX, gridMinY = getMapSize()
|
gridWidth, gridHeight, gridMinX, gridMinY = getMapSize()
|
||||||
doRedraw = false
|
doRedraw = false
|
||||||
|
doForceRedraw = false
|
||||||
doTick = true
|
doTick = true
|
||||||
|
|
||||||
evt = {os.pullEventRaw()}
|
evt = {os.pullEventRaw()}
|
||||||
@ -1160,6 +1168,7 @@ local main = function()
|
|||||||
doDrawWorkspaceIndicator = false
|
doDrawWorkspaceIndicator = false
|
||||||
banTimerEvent = true
|
banTimerEvent = true
|
||||||
doRedraw = true
|
doRedraw = true
|
||||||
|
doForceRedraw = true
|
||||||
else
|
else
|
||||||
if evt[2] == tID then
|
if evt[2] == tID then
|
||||||
doRedraw = true
|
doRedraw = true
|
||||||
@ -1374,7 +1383,7 @@ local main = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if doRedraw then
|
if doRedraw then
|
||||||
lddterm.render()
|
lddterm.render(nil, nil, doForceRedraw)
|
||||||
end
|
end
|
||||||
|
|
||||||
lddterm.selectedWindow = instances[focus[2]][focus[1]].window.layer
|
lddterm.selectedWindow = instances[focus[2]][focus[1]].window.layer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user