diff --git a/game/engines/default/engine/Mouse.lua b/game/engines/default/engine/Mouse.lua index 3af59b7f875ba81a62cfbac0a6dc14662a01cd3a..5404d3be2c7e702f509a5267c89bf6ea679651f9 100644 --- a/game/engines/default/engine/Mouse.lua +++ b/game/engines/default/engine/Mouse.lua @@ -39,7 +39,7 @@ function _M:receiveMouse(button, x, y, isup) for i, m in ipairs(self.areas) do if (not m.mode or m.mode.button) and (x >= m.x1 and x < m.x2 and y >= m.y1 and y < m.y2) then - m.fct(button, x, y, nil, nil, x-m.x1, y-m.y1) + m.fct(button, x, y, nil, nil, x-m.x1, y-m.y1, "button") break end end @@ -48,7 +48,7 @@ end function _M:receiveMouseMotion(button, x, y, xrel, yrel) for i, m in ipairs(self.areas) do if (not m.mode or m.mode.move) and (x >= m.x1 and x < m.x2 and y >= m.y1 and y < m.y2) then - m.fct(button, x, y, xrel, yrel, x-m.x1, y-m.y1) + m.fct(button, x, y, xrel, yrel, x-m.x1, y-m.y1, "motion") break end end diff --git a/game/engines/default/engine/interface/PlayerMouse.lua b/game/engines/default/engine/interface/PlayerMouse.lua index 1f2985bdb30c6312ad5fea52662b21f9c1302497..1a1da4b4f9095fcd9d59c405dc733658ff630333 100644 --- a/game/engines/default/engine/interface/PlayerMouse.lua +++ b/game/engines/default/engine/interface/PlayerMouse.lua @@ -108,15 +108,15 @@ end -- </ul> -- @param key the Key object to which to pass the event if not treated, this should be your game default key handler probably -- @param allow_move true if this will allow player movement (you should use it to check that you are not in targetting mode) -function _M:mouseHandleDefault(key, allow_move, button, mx, my, xrel, yrel) +function _M:mouseHandleDefault(key, allow_move, button, mx, my, xrel, yrel, event) local tmx, tmy = game.level.map:getMouseTile(mx, my) -- Move - if button == "left" and not core.key.modState("shift") and not moving_around and not xrel and not yrel then + if button == "left" and not core.key.modState("shift") and not moving_around and not xrel and not yrel and event == "button" then if allow_move then self:mouseMove(tmx, tmy) end -- Move map around - elseif button == "left" and xrel and yrel and core.key.modState("shift") then + elseif button == "left" and xrel and yrel and core.key.modState("shift") and event == "motion" then self:mouseScrollMap(game.level.map, xrel, yrel) moving_around = true -- Zoom map @@ -125,7 +125,7 @@ function _M:mouseHandleDefault(key, allow_move, button, mx, my, xrel, yrel) -- elseif button == "wheeldown" then -- game.level.map:setZoom(-0.1, tmx, tmy) -- Pass any other buttons to the keybinder - elseif button ~= "none" and not xrel and not yrel then + elseif button ~= "none" and not xrel and not yrel and event == "button" then key:receiveKey(button, core.key.modState("ctrl") and true or false, core.key.modState("shift") and true or false, core.key.modState("alt") and true or false, core.key.modState("meta") and true or false, nil, false, true) end diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index 5e773371ea002e60f056775856516b2d7d0826d6..0ae079a7f1a6c23ffd5e2375a1a26075be78b77d 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -766,15 +766,15 @@ end function _M:setupMouse(reset) if reset then self.mouse:reset() end - self.mouse:registerZone(Map.display_x, Map.display_y, Map.viewport.width, Map.viewport.height, function(button, mx, my, xrel, yrel) + self.mouse:registerZone(Map.display_x, Map.display_y, Map.viewport.width, Map.viewport.height, function(button, mx, my, xrel, yrel, bx, by, event) -- Handle targeting if self:targetMouse(button, mx, my, xrel, yrel) then return end -- Handle Use menu - if button == "right" and not xrel and not yrel then self:mouseRightClick(mx, my) return end + if button == "right" and not xrel and not yrel and event == "button" then self:mouseRightClick(mx, my) return end -- Handle the mouse movement/scrolling - self.player:mouseHandleDefault(self.key, self.key == self.normal_key, button, mx, my, xrel, yrel) + self.player:mouseHandleDefault(self.key, self.key == self.normal_key, button, mx, my, xrel, yrel, event) end) -- Scroll message log self.mouse:registerZone(self.logdisplay.display_x, self.logdisplay.display_y, self.w, self.h, function(button) @@ -782,8 +782,8 @@ function _M:setupMouse(reset) if button == "wheeldown" then self.logdisplay:scrollUp(-1) end end, {button=true}) -- Use hotkeys with mouse - self.mouse:registerZone(self.hotkeys_display.display_x, self.hotkeys_display.display_y, self.w, self.h, function(button, mx, my, xrel, yrel) - self.hotkeys_display:onMouse(button, mx, my, not xrel, function(text) self.tooltip:displayAtMap(nil, nil, self.w, self.h, text) end) + self.mouse:registerZone(self.hotkeys_display.display_x, self.hotkeys_display.display_y, self.w, self.h, function(button, mx, my, xrel, yrel, bx, by, event) + self.hotkeys_display:onMouse(button, mx, my, event == "button", function(text) self.tooltip:displayAtMap(nil, nil, self.w, self.h, text) end) end) -- Use icons self.mouse:registerZone(self.icons.display_x, self.icons.display_y, self.icons.w, self.icons.h, function(button, mx, my, xrel, yrel, bx, by)