From b2681f9f5d72cd956fe7091c1d17cbcc9c890219 Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Tue, 12 Feb 2019 21:31:12 -0200 Subject: [PATCH] Fix mousewheel issue --- main.lua | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/main.lua b/main.lua index 31922d8..c89801a 100644 --- a/main.lua +++ b/main.lua @@ -102,10 +102,16 @@ local function markupdated(pos, redraw) end end +local function change_val(amt) + for i=math.min(visual_start or cp, cp), math.max(visual_start or cp, cp) do + imgt[i] = math.max(math.min(imgt[i] + amt, PAL_MAX), 0) + markupdated(i, true) + end +end + function love.wheelmoved(x, y) saved = nil - imgt[cp] = math.min(math.max(imgt[cp]+y, 0), PAL_MAX) - markupdated(cp, true) + change_val(y) end function setback(pos, highlight) @@ -196,19 +202,13 @@ function love.update(dt) end local function decr() saved = nil - local amt = (kt['lshift'] and 16 or 1) - 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 + local amt = -(kt['lshift'] and 16 or 1) + change_val(amt) end local function incr() saved = nil local amt = (kt['lshift'] and 16 or 1) - 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 + change_val(amt) end local function light_propagation_up() if visual_start then