diff --git a/game/engines/default/engine/dialogs/Chat.lua b/game/engines/default/engine/dialogs/Chat.lua index 86e2ad1a9dae5b87267bd8c29bf911dac0715a7b..b3502ed131d77fee632d257f25c4f45fd510549a 100644 --- a/game/engines/default/engine/dialogs/Chat.lua +++ b/game/engines/default/engine/dialogs/Chat.lua @@ -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) diff --git a/game/engines/default/engine/ui/ActorFrame.lua b/game/engines/default/engine/ui/ActorFrame.lua new file mode 100644 index 0000000000000000000000000000000000000000..1df4bdc95f80c7a799a5da26e50bcdaafda36989 --- /dev/null +++ b/game/engines/default/engine/ui/ActorFrame.lua @@ -0,0 +1,50 @@ +-- 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 diff --git a/game/modules/tome/load.lua b/game/modules/tome/load.lua index 31316e29cb883e973a5446e90a9e5447e40b3c69..464896976a3477c66409df209721b1f57a8456c8 100644 --- a/game/modules/tome/load.lua +++ b/game/modules/tome/load.lua @@ -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 = {