Improvements to visual mode

This commit is contained in:
SoniEx2 2019-02-11 00:51:30 -02:00
parent e4b088170f
commit 7207821080
1 changed files with 21 additions and 3 deletions

View File

@ -142,7 +142,7 @@ function love.update(dt)
local function decr()
saved = nil
local amt = (kt['lshift'] and 16 or 1)
for i=visual_start or cp, cp do
for i=math.min(visual_start or cp, cp), math.max(visual_start or cp, cp) do
imgt[i] = math.max(imgt[i] - amt, 0)
markupdated(i, true)
end
@ -150,7 +150,7 @@ function love.update(dt)
local function incr()
saved = nil
local amt = (kt['lshift'] and 16 or 1)
for i=visual_start or cp, cp do
for i=math.min(visual_start or cp, cp), math.max(visual_start or cp, cp) do
imgt[i] = math.min(imgt[i] + amt, PAL_MAX)
markupdated(i, true)
end
@ -267,6 +267,13 @@ function love.update(dt)
end
local function visual()
visual_start = not visual_start and cp
if not visual_start then
for i=1,255 do
setback(i, false)
end
setback(cp, true)
backimage:replacePixels(backimagedata)
end
end
ktup('i', imgup)
ktup('up', imgup)
@ -283,6 +290,16 @@ function love.update(dt)
ktup('w', save)
ktup('p', palette)
ktup('v', visual)
if visual_start then
-- TODO optimize visual mode
for i=1,255 do
setback(i, false)
end
for i=math.min(visual_start, cp), math.max(visual_start, cp) do
setback(i, true)
end
backimage:replacePixels(backimagedata)
end
end
local quad
@ -325,7 +342,8 @@ end
function love.draw()
love.graphics.draw(image, quad, 576, 0, 0, 8)
love.graphics.draw(backimage, backquad, 0, 0, 0, mul)
love.graphics.print((visual_start and tostring(visual_start) .. ":" or "") .. tostring(cp), 0, 588)
local min, max = math.min(visual_start or cp, cp), math.max(visual_start or cp, cp)
love.graphics.print((visual_start and tostring(min) .. ":" or "") .. tostring(max), 0, 588)
love.graphics.draw(batch, 2, 2)
end