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

When more than one party member has access to inventory you get the option to...

When more than one party member has access to inventory you get the option to transfer an item in the inventory


git-svn-id: http://svn.net-core.org/repos/t-engine4@6085 51575b47-30f0-44d4-a5cc-537603b46e54
parent 8bf57813
No related branches found
No related tags found
No related merge requests found
......@@ -133,6 +133,14 @@ function _M:findMember(filter)
end
end
function _M:countInventoryAble()
local nb = 0
for i, actor in ipairs(self.m_list) do
if not actor.no_inventory_access then nb = nb + 1 end
end
return nb
end
function _M:setDeathTurn(actor, turn)
local def = self.members[actor]
if not def then return end
......
-- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009, 2010, 2011, 2012 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"
require "engine.ui.Dialog"
local List = require "engine.ui.List"
module(..., package.seeall, class.inherit(engine.ui.Dialog))
function _M:init(source, o, inven, item, on_end)
self:generateList()
self.on_end = on_end
self.source = source
self.inven = inven
self.item = item
self.o = o
engine.ui.Dialog.init(self, "Give item to a party member", 1, 1)
local list = List.new{width=400, nb_items=#self.list, list=self.list, fct=function(item) self:use(item) end}
self:loadUI{
{left=0, top=0, ui=list},
}
self:setupUI(true, true)
self.key:addCommands{ __TEXTINPUT = function(c) if self.list and self.list.chars[c] then self:use(self.list[self.list.chars[c]]) end end}
end
function _M:on_register()
game:onTickEnd(function() self.key:unicodeInput(true) end)
end
function _M:use(item)
if not item then return end
game:unregisterDialog(self)
self.source:removeObject(self.inven, self.item)
self.source:sortInven(self.inven)
item.actor:addObject(item.actor.INVEN_INVEN, self.o)
item.actor:sortInven(item.actor.INVEN_INVEN)
game.log("You give %s to %s.", self.o:getName{do_color=true}, item.actor.name)
self.on_end()
end
function _M:generateList()
local list = {}
for i, act in ipairs(game.party.m_list) do
if not act.no_inventory_access and act ~= game.player then
list[#list+1] = {name=act.name, actor=act}
end
end
local chars = {}
for i, v in ipairs(list) do
v.name = self:makeKeyChar(i)..") "..v.name
chars[self:makeKeyChar(i)] = i
end
list.chars = chars
self.list = list
end
......@@ -22,6 +22,7 @@ require "engine.ui.Dialog"
local List = require "engine.ui.List"
local Savefile = require "engine.Savefile"
local Map = require "engine.Map"
local PartySendItem = require "mod.dialogs.PartySendItem"
module(..., package.seeall, class.inherit(engine.ui.Dialog))
......@@ -78,6 +79,10 @@ function _M:use(item)
elseif act == "takeoff" then
self.actor:doTakeoff(self.inven, self.item, self.object)
self.onuse(self.inven, self.item, self.object, false)
elseif act == "transfer" then
game:registerDialog(PartySendItem.new(self.actor, self.object, self.inven, self.item, function()
self.onuse(self.inven, self.item, self.object, false)
end))
elseif act == "transmo" then
self:yesnoPopup("Transmogrify", "Really transmogrify "..self.object:getName{}, function(ret)
if not ret then return end
......@@ -105,6 +110,7 @@ function _M:generateList()
if self.inven == self.actor.INVEN_INVEN and self.object:wornInven() and self.actor:getInven(self.object:wornInven()) then list[#list+1] = {name="Wield/Wear", action="wear"} end
if not self.object.__transmo then if self.inven ~= self.actor.INVEN_INVEN and self.object:wornInven() then list[#list+1] = {name="Take off", action="takeoff"} end end
if self.inven == self.actor.INVEN_INVEN then list[#list+1] = {name="Drop", action="drop"} end
if self.inven == self.actor.INVEN_INVEN and game.party:countInventoryAble() >= 2 then list[#list+1] = {name="Transfer to party", action="transfer"} end
if self.inven == self.actor.INVEN_INVEN and transmo_chest and self.actor:transmoFilter(self.object) then list[#list+1] = {name="Transmogrify now", action="transmo"} end
if profile.auth and profile.hash_valid then list[#list+1] = {name="Link item in chat", action="chat-link"} 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