2012-05-01 02:20:27 +02:00
|
|
|
PlayerTrade = {}
|
|
|
|
|
2012-05-01 15:06:38 +02:00
|
|
|
-- g_game.inspectTrade(counterOffer, index)
|
|
|
|
-- g_game.acceptTrade()
|
|
|
|
-- g_game.rejectTrade()
|
|
|
|
|
|
|
|
local tradeWindow
|
|
|
|
|
|
|
|
local function createTrade()
|
|
|
|
if tradeWindow then
|
|
|
|
tradeWindow:destroy()
|
|
|
|
tradeWindow = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
tradeWindow = createWidget('TradeWindow', rootWidget)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function onOwnTrade(name, items)
|
|
|
|
local firstItem = items[1]
|
|
|
|
|
|
|
|
local tradeItemWidget = tradeWindow:getChildById('tradeItem')
|
|
|
|
tradeItemWidget:setItem(firstItem)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function onCounterTrade(name, items)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
local function onCloseTrade()
|
|
|
|
tradeWindow:destroy()
|
|
|
|
tradeWindow = nil
|
|
|
|
end
|
|
|
|
|
2012-05-01 02:20:27 +02:00
|
|
|
function PlayerTrade.init()
|
2012-05-01 15:06:38 +02:00
|
|
|
importStyle 'tradewindow.otui'
|
|
|
|
|
|
|
|
connect(g_game, { onOwnTrade = onGameOwnTrade,
|
|
|
|
onCounterTrade = onGameCounterTrade,
|
|
|
|
onCloseTrade = onGameCloseTrade })
|
2012-05-01 02:20:27 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function PlayerTrade.terminate()
|
2012-05-01 15:06:38 +02:00
|
|
|
disconnect(g_game, { onOwnTrade = onGameOwnTrade,
|
|
|
|
onCounterTrade = onGameCounterTrade,
|
|
|
|
onCloseTrade = onGameCloseTrade })
|
2012-05-01 02:20:27 +02:00
|
|
|
end
|