From 784b7cbeddcbe2cad38fc5cb48903ae993dc680d Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Tue, 10 Jul 2012 23:01:09 +0000
Subject: [PATCH] Mousing over an item in the log will show the tooltip

git-svn-id: http://svn.net-core.org/repos/t-engine4@5350 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/engines/default/engine/Entity.lua        |  4 +--
 game/engines/default/engine/LogDisplay.lua    | 32 +++++++++++++++++++
 .../default/engine/ui/TextzoneList.lua        |  4 +--
 game/modules/tome/class/uiset/Minimalist.lua  | 20 +++++++++++-
 .../tome/data/chats/player-inscription.lua    |  2 +-
 .../data/general/objects/world-artifacts.lua  |  2 +-
 .../tome/data/timed_effects/mental.lua        |  1 +
 7 files changed, 58 insertions(+), 7 deletions(-)

diff --git a/game/engines/default/engine/Entity.lua b/game/engines/default/engine/Entity.lua
index 55911cb9ee..e9539e50ff 100644
--- a/game/engines/default/engine/Entity.lua
+++ b/game/engines/default/engine/Entity.lua
@@ -410,13 +410,13 @@ end
 --- Get a string that will display in text the texture of this entity
 function _M:getDisplayString(tstr)
 	if tstr then
-		if core.display.FBOActive() then
+		if core.display.FBOActive() or true then
 			return tstring{{"uid", self.uid}}
 		else
 			return tstring{}
 		end
 	else
-		if core.display.FBOActive() then
+		if core.display.FBOActive() or true then
 			return "#UID:"..self.uid..":0#"
 		else
 			return ""
diff --git a/game/engines/default/engine/LogDisplay.lua b/game/engines/default/engine/LogDisplay.lua
index 57905fd927..d9f3c3df82 100644
--- a/game/engines/default/engine/LogDisplay.lua
+++ b/game/engines/default/engine/LogDisplay.lua
@@ -19,6 +19,7 @@
 
 require "engine.class"
 require "engine.ui.Base"
+local Mouse = require "engine.Mouse"
 local Slider = require "engine.ui.Slider"
 
 --- Module that handles message history in a mouse wheel scrollable zone
@@ -76,6 +77,11 @@ function _M:resize(x, y, w, h)
 	end
 
 	self.scrollbar = Slider.new{size=self.h - 20, max=1, inverse=true}
+
+	self.mouse = Mouse.new()
+	self.mouse.delegate_offset_x = self.display_x
+	self.mouse.delegate_offset_y = self.display_y
+	self.mouse:registerZone(0, 0, self.w, self.h, function(button, x, y, xrel, yrel, bx, by, event) self:mouseEvent(button, x, y, xrel, yrel, bx, by, event) end)
 end
 
 --- Returns the full log
@@ -134,6 +140,31 @@ function _M:getLines(number)
 	return lines
 end
 
+function _M:onMouse(fct)
+	self.on_mouse = fct
+end
+
+function _M:mouseEvent(button, x, y, xrel, yrel, bx, by, event)
+	if button == "wheelup" then self:scrollUp(1)
+	elseif button == "wheeldown" then self:scrollUp(-1)
+	else
+		if not self.on_mouse or not self.dlist then return end
+		local citem = nil
+		local ci
+		for i = 1, #self.dlist do
+			local item = self.dlist[i]
+			if item.dh and by >= item.dh - self.mouse.delegate_offset_y then citem = self.dlist[i] ci=i break end
+		end
+		if citem then
+			local sub_es = {}
+			for di = 1, #citem.item._dduids do sub_es[#sub_es+1] = citem.item._dduids[di].e end
+			self.on_mouse(citem, sub_es, button, event, x, y, xrel, yrel, bx, by)
+		else
+			self.on_mouse(nil, nil, button, event, x, y, xrel, yrel, bx, by)
+		end
+	end
+end
+
 function _M:display()
 	-- If nothing changed, return the same surface as before
 	if not self.changed then return end
@@ -183,6 +214,7 @@ function _M:toScreen()
 			else fade = 0 end
 		end
 
+		self.dlist[i].dh = h
 		if self.shadow then item._tex:toScreenFull(self.display_x+2, h+2, item.w, item.h, item._tex_w, item._tex_h, 0,0,0, self.shadow * fade) end
 		item._tex:toScreenFull(self.display_x, h, item.w, item.h, item._tex_w, item._tex_h, 1, 1, 1, fade)
 		for di = 1, #item._dduids do item._dduids[di].e:toScreen(nil, self.display_x + item._dduids[di].x, h, item._dduids[di].w, item._dduids[di].w, fade) end
diff --git a/game/engines/default/engine/ui/TextzoneList.lua b/game/engines/default/engine/ui/TextzoneList.lua
index 69e7034458..c8ba182a5e 100644
--- a/game/engines/default/engine/ui/TextzoneList.lua
+++ b/game/engines/default/engine/ui/TextzoneList.lua
@@ -74,8 +74,8 @@ function _M:createItem(item, text)
     
 	local max_display = math.floor(self.h / self.fh)
 
-		-- Draw the list items
-		local gen = self.font:draw(text:toString(), self.fw, 255, 255, 255)
+	-- Draw the list items
+	local gen = self.font:draw(text:toString(), self.fw, 255, 255, 255)
 
 	for i = 1, #gen do
 		if gen[i].line_extra then
diff --git a/game/modules/tome/class/uiset/Minimalist.lua b/game/modules/tome/class/uiset/Minimalist.lua
index da8ef511c1..07e3c01ae3 100644
--- a/game/modules/tome/class/uiset/Minimalist.lua
+++ b/game/modules/tome/class/uiset/Minimalist.lua
@@ -1536,7 +1536,7 @@ function _M:displayGameLog(scale, bx, by)
 				return
 			end
 
-			game.mouse:delegate(button, mx, my, xrel, yrel, nil, nil, event, "playmap", nil)
+			log:mouseEvent(button, mx, my, xrel, yrel, bx, by, event)
 		end
 		game.mouse:registerZone(bx, by, log.w, log.h, desc_fct, nil, "gamelog", true, scale)
 	end
@@ -1836,6 +1836,24 @@ function _M:display(nb_keyframes)
 end
 
 function _M:setupMouse(mouse)
+	-- Log tooltips
+	self.logdisplay:onMouse(function(item, sub_es, button, event, x, y, xrel, yrel, bx, by)
+		local mx, my = core.mouse.get()
+		if not item or not sub_es or #sub_es == 0 then game.mouse:delegate(button, mx, my, xrel, yrel, nil, nil, event, "playmap") return end
+
+		local str = tstring{}
+		for i, e in ipairs(sub_es) do
+			str:merge(e:tooltip():toTString())
+			if i < #sub_es then str:add(true, "---", true)
+			else str:add(true) end
+		end
+
+		local extra = {}
+		extra.log_str = str
+		game.tooltip.old_ttmx = -100
+		game.mouse:delegate(button, mx, my, xrel, yrel, nil, nil, event, "playmap", extra)
+	end)
+
 	-- Chat tooltips
 	profile.chat:onMouse(function(user, item, button, event, x, y, xrel, yrel, bx, by)
 		local mx, my = core.mouse.get()
diff --git a/game/modules/tome/data/chats/player-inscription.lua b/game/modules/tome/data/chats/player-inscription.lua
index 355d0b95fc..63813b147c 100644
--- a/game/modules/tome/data/chats/player-inscription.lua
+++ b/game/modules/tome/data/chats/player-inscription.lua
@@ -54,7 +54,7 @@ answers[#answers+1] = {"Cancel"}
 newChat{ id="welcome",
 	text = replace_same and [[You have too many of this type of inscription. You can only override an existing one. The old inscription will be lost.]]
 	or [[You have reached your maximum number of inscriptions(infusions/runes).
-If you have unassigned #{bold}#talent category point#{normal}# you can use one to create a new slot.
+If you have unassigned #{bold}#talent category point#{normal}# you can use one to create a new slot (up to 5).
 You can replace an existing one or cancel.
 The old inscription will be lost.]],
 	answers = answers,
diff --git a/game/modules/tome/data/general/objects/world-artifacts.lua b/game/modules/tome/data/general/objects/world-artifacts.lua
index bfae0eae67..1ca2da1c0c 100644
--- a/game/modules/tome/data/general/objects/world-artifacts.lua
+++ b/game/modules/tome/data/general/objects/world-artifacts.lua
@@ -1230,7 +1230,7 @@ newEntity{ base = "BASE_HELM", define_as = "HELM_KROLTAR",
 		self:specialSetAdd({"wielder","combat_physresist"}, 15)
 		game.logPlayer(who, "#GOLD#As the Kroltar helm approches the scale mail, they begin to emit fumes and fires.")
 	end,
-	o.on_set_broken = function(self, who)
+	on_set_broken = function(self, who)
 		game.logPlayer(who, "#GOLD#The funes and fires disappear.")
 	end,
 }
diff --git a/game/modules/tome/data/timed_effects/mental.lua b/game/modules/tome/data/timed_effects/mental.lua
index e1d191f3f1..c38c2aa22f 100644
--- a/game/modules/tome/data/timed_effects/mental.lua
+++ b/game/modules/tome/data/timed_effects/mental.lua
@@ -103,6 +103,7 @@ newEffect{
 	end,
 	deactivate = function(self, eff)
 		self:removeTemporaryValue("confused", eff.tmpid)
+		if self == game.player and self.updateMainShader then self:updateMainShader() end
 	end,
 }
 
-- 
GitLab