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

Added tooltips to the character screen

git-svn-id: http://svn.net-core.org/repos/t-engine4@1290 51575b47-30f0-44d4-a5cc-537603b46e54
parent 900d8239
No related branches found
No related tags found
No related merge requests found
......@@ -298,7 +298,7 @@ function _M:keyCommands(t, b)
if b then self.key:addBinds(b) end
end
function _M:mouseZones(t)
function _M:mouseZones(t, no_new)
-- Offset the x and y with the window position and window title
if not t.norestrict then
for i, z in ipairs(t) do
......@@ -309,7 +309,7 @@ function _M:mouseZones(t)
end
end
self.mouse = engine.Mouse.new()
if not no_new then self.mouse = engine.Mouse.new() end
self.mouse:registerZones(t)
end
......
......@@ -257,6 +257,7 @@ getmetatable(tmps).__index.drawColorString = function(s, font, str, x, y, r, g,
local oldr, oldg, oldb = r, g, b
local max_h = 0
local sw = 0
local bx, by = x, y
for i, v in ipairs(list) do
local nr, ng, nb = lpeg.match("#" * lpeg.C(Pcolorcode) * lpeg.C(Pcolorcode) * lpeg.C(Pcolorcode) * "#", v)
local col = lpeg.match("#" * lpeg.C(Pcolorname) * "#", v)
......@@ -305,7 +306,7 @@ getmetatable(tmps).__index.drawColorString = function(s, font, str, x, y, r, g,
if stop then break end
end
end
return r, g, b, max_h
return r, g, b, sw, max_h, bx, by
end
getmetatable(tmps).__index.drawColorStringCentered = function(s, font, str, dx, dy, dw, dh, r, g, b, alpha_from_texture, limit_w)
......@@ -324,6 +325,7 @@ getmetatable(tmps).__index.drawColorStringBlended = function(s, font, str, x, y,
local oldr, oldg, oldb = r, g, b
local max_h = 0
local sw = 0
local bx, by = x, y
for i, v in ipairs(list) do
local nr, ng, nb = lpeg.match("#" * lpeg.C(Pcolorcode) * lpeg.C(Pcolorcode) * lpeg.C(Pcolorcode) * "#", v)
local col = lpeg.match("#" * lpeg.C(Pcolorname) * "#", v)
......@@ -372,7 +374,7 @@ getmetatable(tmps).__index.drawColorStringBlended = function(s, font, str, x, y,
if stop then break end
end
end
return r, g, b, max_h
return r, g, b, sw, max_h, bx, by
end
getmetatable(tmps).__index.drawColorStringBlendedCentered = function(s, font, str, dx, dy, dw, dh, r, g, b, alpha_from_texture, limit_w)
......
......@@ -41,11 +41,80 @@ function _M:init(actor)
end,
})
self:mouseZones{
{ x=0, y=0, w=game.w, h=game.h, mode={button=true}, norestrict=true, fct=function(button) if button ~= "none" then game:unregisterDialog(self) end end},
}
end
function _M:mouseTooltip(text, _, _, _, w, h, x, y)
self:mouseZones({
{ x=x, y=y, w=w, h=h, fct=function(button) game.tooltip:displayAtMap(nil, nil, game.w, game.h, text) end},
}, true)
end
local TOOLTIP_LIFE = [[#GOLD#Life#LAST#
This is your life force, when you take damage this is reduced more and more.
If it reaches below zero you die.
Death is usualy permanent so beware!
It is increased by Constitution.]]
local TOOLTIP_STAMINA = [[#GOLD#Stamina#LAST#
Stamina represents your physical fatigue. Each physical ability used reduces it.
It regenerates slowly over time or when resting.
It is increased by Willpower.]]
local TOOLTIP_MANA = [[#GOLD#Mana#LAST#
Mana represents your reserve of magical energies. Each spell cast consumes mana and each sustained spell reduces your maximum mana.
It is increased by Willpower.]]
local TOOLTIP_POSITIVE = [[#GOLD#Positive#LAST#
Positive energy represents your reserve of positive "divine" power.
It slowly decreases and is replenished by using some talents.
]]
local TOOLTIP_NEGATIVE = [[#GOLD#Negative#LAST#
Negative energy represents your reserve of negative "divine" power.
It slowly decreases and is replenished by using some talents.
]]
local TOOLTIP_VIM = [[#GOLD#Vim#LAST#
Vim represents the amount of life energy/souls you have stolen. Each corruption talent requires some.
]]
local TOOLTIP_EQUILIBRIUM = [[#GOLD#Equilibrium#LAST#
Equilibrium represents your standing in the grand balance of nature.
The closer it is to 0 the more in-balance you are. Being out of equilibrium will negatively affect your ability to use Wild Gifts.
]]
local TOOLTIP_LEVEL = [[#GOLD#Level and experience#LAST#
Each time you kill a creature that is over your own level - 5 you gain some experience.
When you reach enough experience you advance to the next level. There is a maximum of 50 levels you can gain.
Each time you level you gain stats and talents points to use to improve your character.
]]
local TOOLTIP_STR = [[#GOLD#Strength#LAST#
Strength defines your character's ability to apply physical force. It increases your melee damage, damage done with heavy weapons, your chance to resist physical effects, and carrying capacity.
]]
local TOOLTIP_DEX = [[#GOLD#Dexterity#LAST#
Dexterity defines your character's ability to be agile and alert. It increases your chance to hit, your ability to avoid attacks, and your damage with light weapons.
]]
local TOOLTIP_CON = [[#GOLD#Constitution#LAST#
Constitution defines your character's ability to withstand and resist damage. It increases your maximum life and physical resistance.
]]
local TOOLTIP_MAG = [[#GOLD#Magic#LAST#
Magic defines your character's ability to manipulate the magical energy of the world. It increases your spell power, and the effect of spells and other magic items.
]]
local TOOLTIP_WIL = [[#GOLD#Willpower#LAST#
Willpower defines your character's ability to concentrate. It increases your mana and stamina capacity, and your chance to resist mental attacks.
]]
local TOOLTIP_CUN = [[#GOLD#Cunning#LAST#
Cunning defines your character's ability to learn, think, and react. It allows you to learn many worldly abilities, and increases your mental resistance, armor penetration, and critical chance.
]]
function _M:drawDialog(s)
self.mouse:reset()
self:mouseZones({
{ x=0, y=0, w=game.w, h=game.h, mode={button=true}, norestrict=true, fct=function(button) if button == "left" then game:unregisterDialog(self) end end},
}, true)
local player = self.actor
local cur_exp, max_exp = player.exp, player:getExpChart(player.level+1)
......@@ -55,39 +124,39 @@ function _M:drawDialog(s)
s:drawStringBlended(self.font, "Race: "..(player.descriptor.subrace or player.type:capitalize()), w, h, 0, 200, 255) h = h + self.font_h
s:drawStringBlended(self.font, "Class: "..(player.descriptor.subclass or player.subtype:capitalize()), w, h, 0, 200, 255) h = h + self.font_h
h = h + self.font_h
s:drawColorStringBlended(self.font, "Level: #00ff00#"..player.level, w, h, 255, 255, 255) h = h + self.font_h
s:drawColorStringBlended(self.font, ("Exp: #00ff00#%2d%%"):format(100 * cur_exp / max_exp), w, h, 255, 255, 255) h = h + self.font_h
self:mouseTooltip(TOOLTIP_LEVEL, s:drawColorStringBlended(self.font, "Level: #00ff00#"..player.level, w, h, 255, 255, 255)) h = h + self.font_h
self:mouseTooltip(TOOLTIP_LEVEL, s:drawColorStringBlended(self.font, ("Exp: #00ff00#%2d%%"):format(100 * cur_exp / max_exp), w, h, 255, 255, 255)) h = h + self.font_h
s:drawColorStringBlended(self.font, ("Gold: #00ff00#%0.2f"):format(player.money), w, h, 255, 255, 255) h = h + self.font_h
h = h + self.font_h
s:drawColorStringBlended(self.font, ("#c00000#Life: #00ff00#%d/%d"):format(player.life, player.max_life), w, h, 255, 255, 255) h = h + self.font_h
self:mouseTooltip(TOOLTIP_LIFE, s:drawColorStringBlended(self.font, ("#c00000#Life: #00ff00#%d/%d"):format(player.life, player.max_life), w, h, 255, 255, 255)) h = h + self.font_h
if player:knowTalent(player.T_STAMINA_POOL) then
s:drawColorStringBlended(self.font, ("#ffcc80#Stamina: #00ff00#%d/%d"):format(player:getStamina(), player.max_stamina), w, h, 255, 255, 255) h = h + self.font_h
self:mouseTooltip(TOOLTIP_STAMINA, s:drawColorStringBlended(self.font, ("#ffcc80#Stamina: #00ff00#%d/%d"):format(player:getStamina(), player.max_stamina), w, h, 255, 255, 255)) h = h + self.font_h
end
if player:knowTalent(player.T_MANA_POOL) then
s:drawColorStringBlended(self.font, ("#7fffd4#Mana: #00ff00#%d/%d"):format(player:getMana(), player.max_mana), w, h, 255, 255, 255) h = h + self.font_h
self:mouseTooltip(TOOLTIP_MANA, s:drawColorStringBlended(self.font, ("#7fffd4#Mana: #00ff00#%d/%d"):format(player:getMana(), player.max_mana), w, h, 255, 255, 255)) h = h + self.font_h
end
if player:knowTalent(player.T_POSITIVE_POOL) then
s:drawColorStringBlended(self.font, ("#7fffd4#Positive:#00ff00#%d/%d"):format(player:getPositive(), player.max_positive), w, h, 255, 255, 255) h = h + self.font_h
self:mouseTooltip(TOOLTIP_POSITIVE, s:drawColorStringBlended(self.font, ("#7fffd4#Positive:#00ff00#%d/%d"):format(player:getPositive(), player.max_positive), w, h, 255, 255, 255)) h = h + self.font_h
end
if player:knowTalent(player.T_NEGATIVE_POOL) then
s:drawColorStringBlended(self.font, ("#7fffd4#Negative:#00ff00#%d/%d"):format(player:getNegative(), player.max_negative), w, h, 255, 255, 255) h = h + self.font_h
self:mouseTooltip(TOOLTIP_NEGATIVE, s:drawColorStringBlended(self.font, ("#7fffd4#Negative:#00ff00#%d/%d"):format(player:getNegative(), player.max_negative), w, h, 255, 255, 255)) h = h + self.font_h
end
if player:knowTalent(player.T_VIM_POOL) then
s:drawColorStringBlended(self.font, ("#904010#Vim: #00ff00#%d/%d"):format(player:getVim(), player.max_vim), w, h, 255, 255, 255) h = h + self.font_h
self:mouseTooltip(TOOLTIP_VIM, s:drawColorStringBlended(self.font, ("#904010#Vim: #00ff00#%d/%d"):format(player:getVim(), player.max_vim), w, h, 255, 255, 255)) h = h + self.font_h
end
if player:knowTalent(player.T_EQUILIBRIUM_POOL) then
s:drawColorStringBlended(self.font, ("#00ff74#Equi: #00ff00#%d"):format(player:getEquilibrium()), w, h, 255, 255, 255) h = h + self.font_h
self:mouseTooltip(TOOLTIP_EQUILIBRIUM, s:drawColorStringBlended(self.font, ("#00ff74#Equi: #00ff00#%d"):format(player:getEquilibrium()), w, h, 255, 255, 255)) h = h + self.font_h
end
h = h + self.font_h
s:drawColorStringBlended(self.font, ("STR: #00ff00#%3d"):format(player:getStr()), w, h, 255, 255, 255) h = h + self.font_h
s:drawColorStringBlended(self.font, ("DEX: #00ff00#%3d"):format(player:getDex()), w, h, 255, 255, 255) h = h + self.font_h
s:drawColorStringBlended(self.font, ("MAG: #00ff00#%3d"):format(player:getMag()), w, h, 255, 255, 255) h = h + self.font_h
s:drawColorStringBlended(self.font, ("WIL: #00ff00#%3d"):format(player:getWil()), w, h, 255, 255, 255) h = h + self.font_h
s:drawColorStringBlended(self.font, ("CUN: #00ff00#%3d"):format(player:getCun()), w, h, 255, 255, 255) h = h + self.font_h
s:drawColorStringBlended(self.font, ("CON: #00ff00#%3d"):format(player:getCon()), w, h, 255, 255, 255) h = h + self.font_h
self:mouseTooltip(TOOLTIP_STR, s:drawColorStringBlended(self.font, ("STR: #00ff00#%3d"):format(player:getStr()), w, h, 255, 255, 255)) h = h + self.font_h
self:mouseTooltip(TOOLTIP_DEX, s:drawColorStringBlended(self.font, ("DEX: #00ff00#%3d"):format(player:getDex()), w, h, 255, 255, 255)) h = h + self.font_h
self:mouseTooltip(TOOLTIP_MAG, s:drawColorStringBlended(self.font, ("MAG: #00ff00#%3d"):format(player:getMag()), w, h, 255, 255, 255)) h = h + self.font_h
self:mouseTooltip(TOOLTIP_WIL, s:drawColorStringBlended(self.font, ("WIL: #00ff00#%3d"):format(player:getWil()), w, h, 255, 255, 255)) h = h + self.font_h
self:mouseTooltip(TOOLTIP_CUN, s:drawColorStringBlended(self.font, ("CUN: #00ff00#%3d"):format(player:getCun()), w, h, 255, 255, 255)) h = h + self.font_h
self:mouseTooltip(TOOLTIP_CON, s:drawColorStringBlended(self.font, ("CON: #00ff00#%3d"):format(player:getCon()), w, h, 255, 255, 255)) h = h + self.font_h
h = 0
w = 200
......
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