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:
parent
b61094c053
commit
88c59afb8c
|
@ -13,7 +13,6 @@ SpinBox < TextEdit
|
|||
image-clip: 0 0 10 10
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
@onPress: self:getParent():up()
|
||||
|
||||
$hover:
|
||||
image-clip: 0 10 10 10
|
||||
|
@ -28,7 +27,6 @@ SpinBox < TextEdit
|
|||
image-clip: 0 0 10 10
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
@onPress: self:getParent():down()
|
||||
|
||||
$hover:
|
||||
image-clip: 0 10 10 10
|
||||
|
|
|
@ -138,6 +138,15 @@ function table.findbyfield(t, fieldname, fieldvalue)
|
|||
return nil
|
||||
end
|
||||
|
||||
function table.size(t)
|
||||
local size = 0
|
||||
for i, n in pairs(table) do
|
||||
size = size + 1
|
||||
end
|
||||
|
||||
return size
|
||||
end
|
||||
|
||||
function table.tostring(t)
|
||||
local maxn = #t
|
||||
local str = ""
|
||||
|
|
|
@ -15,6 +15,11 @@ function UISpinBox.create()
|
|||
return spinbox
|
||||
end
|
||||
|
||||
function UISpinBox:onSetup()
|
||||
g_mouse.bindAutoPress(self:getChildById('up'), function() self:up() end, 300)
|
||||
g_mouse.bindAutoPress(self:getChildById('down'), function() self:down() end, 300)
|
||||
end
|
||||
|
||||
function UISpinBox:onMouseWheel(mousePos, direction)
|
||||
if direction == MouseWheelUp then
|
||||
self:up()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -250,6 +250,7 @@ MainWindow
|
|||
anchors.right: next.left
|
||||
anchors.bottom: parent.bottom
|
||||
margin-right: 10
|
||||
visible: false
|
||||
@onClick: modules.game_npctrade.sellAll()
|
||||
|
||||
Button
|
||||
|
|
Loading…
Reference in New Issue