Skip to content
Snippets Groups Projects
Commit fb94d3c3 authored by dg's avatar dg
Browse files

talents dont activate with the mouse by just draging over, requires a mouse up

git-svn-id: http://svn.net-core.org/repos/t-engine4@596 51575b47-30f0-44d4-a5cc-537603b46e54
parent 93ae9071
No related branches found
No related tags found
No related merge requests found
......@@ -115,11 +115,11 @@ end
--- Call when a mouse event arrives in this zone
-- This is optional, only if you need mouse support
function _M:onMouse(button, mx, my)
function _M:onMouse(button, mx, my, click)
mx, my = mx - self.display_x, my - self.display_y
for i, zone in pairs(self.clics) do
if mx >= zone[1] and mx < zone[1] + zone[3] and my >= zone[2] and my < zone[2] + zone[4] then
if button == "left" then
if button == "left" and click then
self.actor:activateHotkey(i)
else
self.actor.changed = true
......
......@@ -25,6 +25,7 @@ module(..., package.seeall, class.make)
function _M:init()
self.areas = {}
self.status = {}
end
--- Called when a mouse is pressed
......@@ -33,6 +34,7 @@ end
-- @param y coordinate of the click
-- @param isup true if the key was released, false if pressed
function _M:receiveMouse(button, x, y, isup)
self.status[button] = not isup
if not isup then return end
for i, m in ipairs(self.areas) do
......
......@@ -30,6 +30,7 @@ local Target = require "engine.Target"
local Level = require "engine.Level"
local Birther = require "engine.Birther"
local Astar = require "engine.Astar"
local DirectPath = require "engine.DirectPath"
local Store = require "mod.class.Store"
local Trap = require "mod.class.Trap"
......@@ -699,7 +700,7 @@ function _M:setupMouse()
local path = a:calc(self.player.x, self.player.y, tmx, tmy, true)
-- No Astar path ? jsut be dumb and try direct line
if not path then
local d= DirectPath.new(self.level.map, self.player)
local d = DirectPath.new(self.level.map, self.player)
path = d:calc(self.player.x, self.player.y, tmx, tmy, true)
end
self.test_x = tmx
......@@ -718,7 +719,7 @@ function _M:setupMouse()
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)
self.hotkeys_display:onMouse(button, mx, my, not xrel)
end)
self.mouse:setCurrent()
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment