Added 'sell all' tooltip to show items you can sell

* Now 'sell all' button with enable/disable
* Fixed display issue with 'sell all' button
* Also changed spinbox button click
This commit is contained in:
BeniS
2013-02-20 23:08:03 +13:00
parent b61094c053
commit 88c59afb8c
5 changed files with 53 additions and 2 deletions

View File

@@ -436,6 +436,21 @@ function onPlayerGoods(money, items)
end
end
local first = true
local info = ''
for key, amount in pairs(playerItems) do
if amount > 0 then
local data = getTradeItemData(key, SELL)
if data then
info = info..(not first and "\n" or "")..amount.." "..data.name.." ("..data.price*amount.." gold)"
if first then first = false end
end
end
end
if info ~= '' then
sellAllButton:setTooltip(info)
end
refreshPlayerGoods()
end
@@ -453,6 +468,29 @@ function onInventoryChange(inventory, item, oldItem)
end
end
function getTradeItemData(id, type)
if table.empty(tradeItems[type]) then
return false
end
if type then
for key,item in pairs(tradeItems[type]) do
if item.ptr and item.ptr:getId() == id then
return item
end
end
else
for _,items in pairs(tradeItems) do
for key,item in pairs(items) do
if item.ptr and item.ptr:getId() == id then
return item
end
end
end
end
return false
end
function formatCurrency(amount)
if CURRENCY_DECIMAL then
return string.format("%.02f", amount/100.0) .. ' ' .. CURRENCY

View File

@@ -250,6 +250,7 @@ MainWindow
anchors.right: next.left
anchors.bottom: parent.bottom
margin-right: 10
visible: false
@onClick: modules.game_npctrade.sellAll()
Button