From 44b376849be968e83fb876815cd8c770a142f36d Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Mon, 2 May 2011 09:35:57 +0000
Subject: [PATCH] Buttons will provide a visual feedback when clicked

git-svn-id: http://svn.net-core.org/repos/t-engine4@3291 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/engines/default/engine/ui/Button.lua          | 14 +++++++++++---
 game/modules/tome/class/interface/TooltipsData.lua | 14 +++++++-------
 game/modules/tome/dialogs/CharacterSheet.lua       |  2 +-
 src/core_lua.c                                     |  5 +++--
 4 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/game/engines/default/engine/ui/Button.lua b/game/engines/default/engine/ui/Button.lua
index ff0480b882..ce2bf803f9 100644
--- a/game/engines/default/engine/ui/Button.lua
+++ b/game/engines/default/engine/ui/Button.lua
@@ -65,12 +65,20 @@ function _M:generate()
 	self.h = self.h + 6
 end
 
-function _M:display(x, y, nb_keyframes)
+function _M:display(x, y, nb_keyframes, ox, oy)
 	x = x + 3
 	y = y + 3
+	ox = ox + 3
+	oy = oy + 3
+	local mx, my, button = core.mouse.get()
 	if self.focused then
-		self:drawFrame(self.frame_sel, x, y)
-		self.tex[1]:toScreenFull(x-frame_ox1, y-frame_oy1, self.rw, self.rh, self.tex[2], self.tex[3])
+			if button == 1 and mx > ox and mx < ox+self.w and my > oy and my < oy+self.h then
+				self:drawFrame(self.frame, x, y, 0, 1, 0, 1)
+				self.tex[1]:toScreenFull(x-frame_ox1, y-frame_oy1, self.rw, self.rh, self.tex[2], self.tex[3])
+			else
+				self:drawFrame(self.frame_sel, x, y)
+				self.tex[1]:toScreenFull(x-frame_ox1, y-frame_oy1, self.rw, self.rh, self.tex[2], self.tex[3])
+			end
 	else
 		self:drawFrame(self.frame, x, y)
 		if self.focus_decay then
diff --git a/game/modules/tome/class/interface/TooltipsData.lua b/game/modules/tome/class/interface/TooltipsData.lua
index d6a6784792..8c9714cead 100644
--- a/game/modules/tome/class/interface/TooltipsData.lua
+++ b/game/modules/tome/class/interface/TooltipsData.lua
@@ -46,7 +46,7 @@ TOOLTIP_LIFE_REGEN = [[#GOLD#Life Regeneration#LAST#
 How many life you regenerate per turn.
 This value can be improved with spells, talents, infusions, equipment.]]
 
-TOOLTIP_LIFE = [[#GOLD#Healing mod#LAST#
+TOOLTIP_HEALING_MOD = [[#GOLD#Healing mod#LAST#
 This represents how effective is healing for you.
 All healing values are multiplied by this value (including life regeneration).]]
 
@@ -130,18 +130,18 @@ It represents how much "energy" you get per game turn, once you reach a certain
 I.E: at 200% global speed you get twice as much energy per game turn and thus can act twice when other creatures only act once.
 ]]
 TOOLTIP_SPEED_MOVEMENT = [[#GOLD#Movement Speed#LAST#
-The time it takes you to move.
-It represents how many movements you can do in the same time.
+The additional time you have to move.
+It represents how many more movements you can do in the same time.
 I.E: at 100% you will be able to do 100% more movements (aka twice as many) in the same time it would have taken you to do one at 0% speed.
 ]]
 TOOLTIP_SPEED_SPELL = [[#GOLD#Spell Speed#LAST#
-The time it takes you to cast a spell.
-It represents how many spells you can do in the same time.
+The additional time you have cast a spell.
+It represents how many more spells you can cast in the same time.
 I.E: at 100% you will be able to cast 100% more spells (aka twice as many) in the same time it would have taken you to do one at 0% speed.
 ]]
 TOOLTIP_SPEED_ATTACK = [[#GOLD#Attack Speed#LAST#
-The time it takes you to attack (in melee or ranged).
-It represents how many attacks you can do in the same time.
+The additional time you have to attack (in melee or ranged).
+It represents how many more attacks you can do in the same time.
 I.E: at 100% you will be able to do 100% more attacks (aka twice as many) in the same time it would have taken you to do one at 0% speed.
 ]]
 
diff --git a/game/modules/tome/dialogs/CharacterSheet.lua b/game/modules/tome/dialogs/CharacterSheet.lua
index d3ae83d7a0..60e930f00c 100644
--- a/game/modules/tome/dialogs/CharacterSheet.lua
+++ b/game/modules/tome/dialogs/CharacterSheet.lua
@@ -198,7 +198,7 @@ function _M:drawDialog(kind)
 		local StatVal = self.actor:getStr(nil, nil, true)
 		local StatTxt = ""
 		if StatVal > player:getStr() then
-			StatTxt = ("Strength    : #ff0000#%3d / %3"):format(player:getStr(nil, nil, true), player:getStr())
+			StatTxt = ("Strength    : #ff0000#%3d / %d"):format(player:getStr(nil, nil, true), player:getStr())
 		else
 			StatTxt = ("Strength    : #00ff00#%3d / %d"):format(player:getStr(nil, nil, true), player:getStr())
 		end
diff --git a/src/core_lua.c b/src/core_lua.c
index c4b8d9064d..9d2d5ca98a 100644
--- a/src/core_lua.c
+++ b/src/core_lua.c
@@ -45,12 +45,13 @@
 static int lua_get_mouse(lua_State *L)
 {
 	int x = 0, y = 0;
-	(void)SDL_GetMouseState(&x, &y);
+	int buttons = SDL_GetMouseState(&x, &y);
 
 	lua_pushnumber(L, x);
 	lua_pushnumber(L, y);
+	lua_pushnumber(L, SDL_BUTTON(buttons));
 
-	return 2;
+	return 3;
 }
 static int lua_set_mouse(lua_State *L)
 {
-- 
GitLab