From 2e35ba90c06f31126630c31d9a0573ef51e144d2 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Sun, 8 Aug 2010 17:28:09 +0000
Subject: [PATCH] Test new tooltip fixed position

git-svn-id: http://svn.net-core.org/repos/t-engine4@998 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/engine/Tooltip.lua                 | 2 ++
 game/engine/interface/GameTargeting.lua | 7 +++++--
 game/modules/tome/class/Game.lua        | 2 +-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/game/engine/Tooltip.lua b/game/engine/Tooltip.lua
index 7443fd4068..d93c43d3ab 100644
--- a/game/engine/Tooltip.lua
+++ b/game/engine/Tooltip.lua
@@ -134,6 +134,8 @@ function _M:displayAtMap(tmx, tmy, mx, my)
 		my = my - self.h
 		if mx < 0 then mx = 0 end
 		if my < 0 then my = 0 end
+		if mx > game.w - self.w then mx = game.w - self.w end
+		if my > game.h - self.h then my = game.h - self.h end
 		self.surface:toScreenWithTexture(self.texture, mx, my)
 	end
 end
diff --git a/game/engine/interface/GameTargeting.lua b/game/engine/interface/GameTargeting.lua
index 44b05b116d..c96809dca6 100644
--- a/game/engine/interface/GameTargeting.lua
+++ b/game/engine/interface/GameTargeting.lua
@@ -41,11 +41,14 @@ function _M:targetOnTick()
 end
 
 --- Display the tooltip, if any
-function _M:targetDisplayTooltip()
+function _M:targetDisplayTooltip(dx, dy)
 	-- Tooltip is displayed over all else
 	if self.level and self.level.map and self.level.map.finished then
 		-- Display a tooltip if available
-		if self.tooltip_x then self.tooltip:displayAtMap(self.level.map:getMouseTile(self.tooltip_x , self.tooltip_y)) end
+		if self.tooltip_x then
+			local tmx, tmy = self.level.map:getMouseTile(self.tooltip_x , self.tooltip_y)
+			self.tooltip:displayAtMap(tmx, tmy, dx, dy)
+		end
 
 		-- Move target around
 		if self.old_tmx ~= tmx or self.old_tmy ~= tmy then
diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua
index 9caf2ba8c4..d9d47e1eb1 100644
--- a/game/modules/tome/class/Game.lua
+++ b/game/modules/tome/class/Game.lua
@@ -450,7 +450,7 @@ function _M:display()
 	if self.player then self.player.changed = false end
 
 	-- Tooltip is displayed over all else
-	self:targetDisplayTooltip()
+	self:targetDisplayTooltip(game.w, game.h)
 
 	engine.GameTurnBased.display(self)
 end
-- 
GitLab