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

tooltip in stores

git-svn-id: http://svn.net-core.org/repos/t-engine4@3547 51575b47-30f0-44d4-a5cc-537603b46e54
parent 70a2ece7
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,7 @@ require "engine.class"
local Entity = require "engine.Entity"
local Dialog = require "engine.ui.Dialog"
local Inventory = require "engine.interface.ActorInventory"
local ShowStore = require "engine.dialogs.ShowStore"
local ShowStore = require_first("mod.dialogs.ShowStore", "engine.dialogs.ShowStore")
local GetQuantity = require "engine.dialogs.GetQuantity"
module(..., package.seeall, class.inherit(Entity, Inventory))
......
......@@ -300,11 +300,11 @@ function _M:setupUI(resizex, resizey, on_resize, addmw, addmh)
end
-- print("===", mw, addw)
mw = mw + addw + 5 * 2 + (addmw or 0)
-- print("===", mw, addw)
local tw, th = self.font_bold:size(self.title)
mw = math.max(tw + 6, mw)
mh = mh + addh + 5 + 22 + 3 + (addmh or 0) + th
if on_resize then on_resize(resizex and mw or self.w, resizey and mh or self.h) end
......@@ -389,7 +389,7 @@ function _M:getUIElement(id)
end
if type(id) == "table" then return end
end
return self.uis[id]
end
......
......@@ -203,32 +203,3 @@ function _M:interact(who, name)
who:sortInven()
Store.interact(self, who, name)
end
--- Display tooltips
function _M:on_select(item)
if item.last_display_x then
game.tooltip_x, game.tooltip_y = {}, 1
game.tooltip:displayAtMap(nil, nil, item.last_display_x, item.last_display_y, item.desc)
if not item.object or item.object.wielded then game.tooltip2_x = nil return end
local winven = item.object:wornInven()
winven = winven and game.player:getInven(winven)
if not winven then game.tooltip2_x = nil return end
local str = tstring{{"font", "bold"}, {"color", "GREY"}, "Currently equiped:", {"font", "normal"}, {"color", "LAST"}, true}
local ok = false
for i = 1, #winven do
str:merge(winven[i]:getDesc())
if i < #winven then str:add{true, "---", true} end
ok = true
end
if ok then
game.tooltip2_x, game.tooltip2_y = {}, 1
game.tooltip2:displayAtMap(nil, nil, 1, item.last_display_y, str)
game.tooltip2.last_display_x = game.tooltip.last_display_x - game.tooltip2.w
last = item
else
game.tooltip2_x = nil
end
end
end
-- TE4 - T-Engine 4
-- Copyright (C) 2009, 2010, 2011 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
require "engine.class"
local Base = require "engine.dialogs.ShowStore"
module(..., package.seeall, class.inherit(Base))
function _M:init(...)
Base.init(self, ...)
-- Add tooltips
self.on_select = function(item)
if item.last_display_x and item.object then
game.tooltip_x, game.tooltip_y = {}, 1
game.tooltip:displayAtMap(nil, nil, item.last_display_x, item.last_display_y, item.object:getDesc({do_color=true}, game.player:getInven(item.object:wornInven())))
end
end
self.key.any_key = function(sym)
-- Control resets the tooltip
if sym == self.key._LCTRL or sym == self.key._RCTRL then local i = self.cur_item self.cur_item = nil self:select(i) end
end
end
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