fixes to npctrade

master
Henrique Santiago 12 years ago
parent 8d0f07255d
commit 170d4fd365

@ -148,13 +148,15 @@ local function refreshTradeItems()
for key,item in pairs(currentTradeItems) do for key,item in pairs(currentTradeItems) do
local itemBox = createWidget('NPCItemBox', itemsPanel) local itemBox = createWidget('NPCItemBox', itemsPanel)
itemBox.item = item itemBox.item = item
itemBox:getChildById('item'):setItem(item.ptr)
itemBox:getChildById('nameLabel'):setText(item.name) local name = item.name
itemBox:getChildById('weightLabel'):setText(string.format('%.2f', item.weight) .. ' ' .. WEIGHT_UNIT) local weight = string.format('%.2f', item.weight) .. ' ' .. WEIGHT_UNIT
itemBox:getChildById('priceLabel'):setText(item.price .. ' ' .. CURRENCY) local price = item.price .. ' ' .. CURRENCY
itemBox:setText(name .. '\n' .. weight .. '\n' .. price)
itemBox.onMouseRelease = NPCTrade.itemPopup local itemWidget = itemBox:getChildById('item')
itemBox:getChildById('item').onMouseRelease = function(self, mousePosition, mouseButton) NPCTrade.itemPopup(itemBox, mousePosition, mouseButton) end itemWidget:setItem(item.ptr)
itemWidget.onMouseRelease = NPCTrade.itemPopup
radioItems:addWidget(itemBox) radioItems:addWidget(itemBox)
end end
@ -344,9 +346,11 @@ end
function NPCTrade.itemPopup(self, mousePosition, mouseButton) function NPCTrade.itemPopup(self, mousePosition, mouseButton)
if mouseButton == MouseRightButton then if mouseButton == MouseRightButton then
local menu = createWidget('PopupMenu') local menu = createWidget('PopupMenu')
menu:addOption(tr('Look'), function() return g_game.inspectNpcTrade(self.offer[1]) end) menu:addOption(tr('Look'), function() return g_game.inspectNpcTrade(self:getItem()) end)
menu:display(mousePosition) menu:display(mousePosition)
return true
end end
return false
end end
function NPCTrade.onBuyWithBackpackChange() function NPCTrade.onBuyWithBackpackChange()

@ -7,6 +7,9 @@ NPCOfferLabel < Label
NPCItemBox < UICheckBox NPCItemBox < UICheckBox
border-width: 1 border-width: 1
border-color: #000000 border-color: #000000
color: #aaaaaa
text-align: center
text-offset: 0 20
@onCheckChange: NPCTrade.onItemBoxChecked(self) @onCheckChange: NPCTrade.onItemBoxChecked(self)
Item Item
@ -14,37 +17,17 @@ NPCItemBox < UICheckBox
phantom: true phantom: true
anchors.top: parent.top anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
margin-top: 3 margin-top: 5
Label
id: nameLabel
phantom: true
anchors.top: prev.bottom
anchors.horizontalCenter: parent.horizontalCenter
text-auto-resize: true
margin-top: 3
Label
id: weightLabel
phantom: true
anchors.top: prev.bottom
anchors.horizontalCenter: parent.horizontalCenter
text-auto-resize: true
margin-top: 3
Label
id: priceLabel
phantom: true
anchors.top: prev.bottom
anchors.horizontalCenter: parent.horizontalCenter
text-auto-resize: true
margin-top: 3
$checked: $checked:
border-color: #FFFFFF border-color: #ffffff
$hover !checked: $hover !checked:
border-color: #AAAAAA border-color: #aaaaaa
$disabled:
image-color: #ffffff88
color: #aaaaaa88
MainWindow MainWindow
id: npcWindow id: npcWindow

Loading…
Cancel
Save