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

NPC & Player portrait will appear in chat boxes

git-svn-id: http://svn.net-core.org/repos/t-engine4@4835 51575b47-30f0-44d4-a5cc-537603b46e54
parent e79d6428
No related branches found
No related tags found
No related merge requests found
......@@ -22,9 +22,12 @@ local Dialog = require "engine.ui.Dialog"
local VariableList = require "engine.ui.VariableList"
local Textzone = require "engine.ui.Textzone"
local Separator = require "engine.ui.Separator"
local ActorFrame = require "engine.ui.ActorFrame"
module(..., package.seeall, class.inherit(Dialog))
show_portraits = false
function _M:init(chat, id)
self.cur_id = id
self.chat = chat
......@@ -32,19 +35,32 @@ function _M:init(chat, id)
self.player = chat.player
Dialog.init(self, self.npc.name, 500, 400)
local xoff = 0
if self.show_portraits then
xoff = 64
end
self:generateList()
self.c_desc = Textzone.new{width=self.iw - 10, height=1, auto_height=true, text=self.text.."\n"}
self.c_desc = Textzone.new{width=self.iw - 10 - xoff, height=1, auto_height=true, text=self.text.."\n"}
self:generateList()
self.c_list = VariableList.new{width=self.iw - 10, list=self.list, fct=function(item) self:use(item) end, select=function(item) self:select(item) end}
self.c_list = VariableList.new{width=self.iw - 10 - xoff, list=self.list, fct=function(item) self:use(item) end, select=function(item) self:select(item) end}
self:loadUI{
local uis = {
{left=0, top=0, ui=self.c_desc},
{left=0, bottom=0, ui=self.c_list},
{left=5, top=self.c_desc.h - 10, ui=Separator.new{dir="vertical", size=self.iw - 10}},
}
if self.show_portraits then
uis[#uis+1] = {right=0, top=0, ui=ActorFrame.new{actor=self.npc, w=64, h=64}}
uis[#uis+1] = {left=0, bottom=0, ui=ActorFrame.new{actor=self.player, w=64, h=64}}
uis[2].left = nil uis[2].right = 0
uis[3].top = math.max(self.c_desc.h, uis[4].ui.h) - 10
end
self:loadUI(uis)
self:setFocus(self.c_list)
self:setupUI(false, true)
......
-- 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.ui.Base"
local Tiles = require "engine.Tiles"
module(..., package.seeall, class.inherit(Base))
function _M:init(t)
self.actor = assert(t.actor, "no actorframe actor")
self.w = assert(t.w, "no actorframe w")
self.h = assert(t.h, "no actorframe h")
self.tiles = t.tiles or Tiles.new(w, h, nil, nil, true, nil)
Base.init(self, t)
end
function _M:generate()
end
function _M:display(x, y, nb_keyframes, ox, oy)
local o = self.actor
if o and o.toScreen then
if o.image then
o:toScreen(self.tiles, x, y, self.w, self.h)
elseif o.image and o.add_mos then
o:toScreen(self.tiles, x, y - h, self.w, self.h * 2)
end
end
self.last_display_x = ox
self.last_display_y = oy
end
......@@ -271,6 +271,9 @@ Birther:loadDefinition("/data/birth/descriptors.lua")
-- Stores
Store:loadStores("/data/general/stores/basic.lua")
-- Configure chat dialogs
require("engine.dialogs.Chat").show_portraits = true
-- Inventory tabs
InventoryUI.default_tabslist = function(self)
local tabslist = {
......
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