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

Hotkey dislpay shows a tooltip for the mouseover

git-svn-id: http://svn.net-core.org/repos/t-engine4@1224 51575b47-30f0-44d4-a5cc-537603b46e54
parent 9057fdeb
No related branches found
No related tags found
No related merge requests found
......@@ -135,18 +135,30 @@ 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, click)
function _M:onMouse(button, mx, my, click, on_over)
local a = self.actor
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" and click then
self.actor:activateHotkey(i)
a:activateHotkey(i)
elseif button == "right" and click then
self.actor.hotkey[i] = nil
self.actor.changed = true
a.hotkey[i] = nil
a.changed = true
else
self.actor.changed = true
a.changed = true
self.cur_sel = i
if on_over then
local text = ""
if a.hotkey[i] and a.hotkey[i][1] == "talent" then
local t = self.actor:getTalentFromId(a.hotkey[i][2])
text = "#GOLD#"..t.name.."#LAST#\n"..self.actor:getTalentFullDescription(t)
elseif a.hotkey[i] and a.hotkey[i][1] == "inventory" then
local o = a:findInAllInventories(a.hotkey[i][2])
text = o:getDesc()
end
on_over(text)
end
end
return
end
......
......@@ -123,7 +123,6 @@ function _M:displayAtMap(tmx, tmy, mx, my, text)
if text ~= self.old_text then
self:set("%s", text)
self:display()
print("set", text)
self.old_text = text
end
else
......
......@@ -477,11 +477,11 @@ function util.findFreeGrid(sx, sy, radius, block, what)
local ok = true
if not game.level.map:isBound(x, y) then ok = false end
for w, _ in pairs(what) do
print("findFreeGrid test", x, y, w, ":=>", game.level.map(x, y, w))
-- print("findFreeGrid test", x, y, w, ":=>", game.level.map(x, y, w))
if game.level.map(x, y, w) then ok = false end
end
if game.level.map:checkEntity(x, y, game.level.map.TERRAIN, "block_move") then ok = false end
print("findFreeGrid", x, y, "from", sx,sy,"=>", ok)
-- print("findFreeGrid", x, y, "from", sx,sy,"=>", ok)
if ok then
gs[#gs+1] = {x, y, math.floor(core.fov.distance(sx, sy, x, y)), rng.range(1, 1000)}
end
......
......@@ -777,7 +777,7 @@ function _M:setupMouse(reset)
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)
self.hotkeys_display:onMouse(button, mx, my, not xrel, 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)
......
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