npctrade reworked, still need skin changes, and grey shader for items
This commit is contained in:
parent
dc0ade2bd0
commit
8d0f07255d
|
@ -32,16 +32,16 @@ function UIGameMap:onDrop(widget, mousePos)
|
||||||
local tile = self:getTile(mousePos)
|
local tile = self:getTile(mousePos)
|
||||||
if not tile then return false end
|
if not tile then return false end
|
||||||
|
|
||||||
local item = widget.currentDragThing
|
local thing = widget.currentDragThing
|
||||||
local toPos = tile:getPosition()
|
local toPos = tile:getPosition()
|
||||||
|
|
||||||
local itemPos = item:getPosition()
|
local itemPos = thing:getPosition()
|
||||||
if itemPos.x == toPos.x and itemPos.y == toPos.y and itemPos.z == toPos.z then return false end
|
if itemPos.x == toPos.x and itemPos.y == toPos.y and itemPos.z == toPos.z then return false end
|
||||||
|
|
||||||
if item:getCount() > 1 then
|
if thing:asItem() and thing:getCount() > 1 then
|
||||||
GameInterface.moveStackableItem(item, toPos)
|
GameInterface.moveStackableItem(thing, toPos)
|
||||||
else
|
else
|
||||||
g_game.move(item, toPos, 1)
|
g_game.move(thing, toPos, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -1,33 +1,201 @@
|
||||||
NPCTrade = {}
|
NPCTrade = {}
|
||||||
|
|
||||||
|
-- private variables
|
||||||
|
local BUY = 1
|
||||||
|
local SELL = 2
|
||||||
|
local CURRENCY = 'gold'
|
||||||
|
local WEIGHT_UNIT = 'oz'
|
||||||
|
local LAST_INVENTORY = 10
|
||||||
|
|
||||||
local npcWindow
|
local npcWindow
|
||||||
local itemsPanel
|
local itemsPanel
|
||||||
local radioTabs
|
local radioTabs
|
||||||
local radioItems
|
local radioItems
|
||||||
local buyTab
|
|
||||||
local sellTab
|
|
||||||
local searchText
|
local searchText
|
||||||
local setupPanel
|
local setupPanel
|
||||||
local quantity
|
local quantity
|
||||||
local quantityScroll
|
local quantityScroll
|
||||||
local nameLabel
|
local nameLabel
|
||||||
local priceLabel
|
local priceLabel
|
||||||
local moneyGoods
|
|
||||||
local moneyLabel
|
local moneyLabel
|
||||||
local weightLabel
|
local weightLabel
|
||||||
local capacityLabel
|
local capacityLabel
|
||||||
local offerSelected
|
local tradeButton
|
||||||
local setupButton
|
local buyTab
|
||||||
local cacheItems
|
local sellTab
|
||||||
local cacheGoods
|
|
||||||
|
|
||||||
local buyWithBackpack = false
|
local buyWithBackpack
|
||||||
local ignoreCapacity = false
|
local ignoreCapacity
|
||||||
local ignoreEquipped = true
|
local ignoreEquipped
|
||||||
local showOnlyHolding = false
|
local showAllItems
|
||||||
|
|
||||||
local CURRENCY = 'gold'
|
local playerFreeCapacity
|
||||||
local WEIGHT_UNIT = 'oz'
|
local playerMoney
|
||||||
|
local tradeItems = {}
|
||||||
|
local playerItems
|
||||||
|
|
||||||
|
local selectedItem
|
||||||
|
|
||||||
|
-- private functions
|
||||||
|
local function clearSelectedItem()
|
||||||
|
nameLabel:clearText()
|
||||||
|
weightLabel:clearText()
|
||||||
|
priceLabel:clearText()
|
||||||
|
quantityLabel:clearText()
|
||||||
|
tradeButton:disable()
|
||||||
|
quantityScroll:setMaximum(1)
|
||||||
|
if selectedItem then
|
||||||
|
radioItems:selectWidget(nil)
|
||||||
|
selectedItem = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function getCurrentTradeType()
|
||||||
|
if tradeButton:getText() == tr('Buy') then
|
||||||
|
return BUY
|
||||||
|
else
|
||||||
|
return SELL
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function getItemPrice(item)
|
||||||
|
if getCurrentTradeType() == BUY then
|
||||||
|
if buyWithBackpack:isChecked() then
|
||||||
|
if item.ptr:isStackable() then
|
||||||
|
return item.price*quantityScroll:getValue() + 20;
|
||||||
|
else
|
||||||
|
return item.price*quantityScroll:getValue() + math.ceil(quantityScroll:getValue()/20)*20
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return item.price*quantityScroll:getValue()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function getSellQuantity(item)
|
||||||
|
if not playerItems[item.ptr:getId()] then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
local removeAmount = 0
|
||||||
|
if ignoreEquipped:isChecked() then
|
||||||
|
local localPlayer = g_game.getLocalPlayer()
|
||||||
|
for i=1,LAST_INVENTORY do
|
||||||
|
local inventoryItem = localPlayer:getInventoryItem(i)
|
||||||
|
if inventoryItem and inventoryItem:getId() == item.ptr:getId() then
|
||||||
|
removeAmount = removeAmount + inventoryItem:getCount()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return playerItems[item.ptr:getId()] - removeAmount
|
||||||
|
end
|
||||||
|
|
||||||
|
local function canTradeItem(item)
|
||||||
|
if getCurrentTradeType() == BUY then
|
||||||
|
return (ignoreCapacity:isChecked() or (not ignoreCapacity:isChecked() and playerFreeCapacity >= item.weight)) and playerMoney >= getItemPrice(item)
|
||||||
|
else
|
||||||
|
return getSellQuantity(item) > 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function refreshItem(item)
|
||||||
|
nameLabel:setText(item.name)
|
||||||
|
weightLabel:setText(string.format('%.2f', item.weight) .. ' ' .. WEIGHT_UNIT)
|
||||||
|
priceLabel:setText(getItemPrice(item) .. ' ' .. CURRENCY)
|
||||||
|
|
||||||
|
quantityLabel:setText(1)
|
||||||
|
quantityScroll:setValue(1)
|
||||||
|
|
||||||
|
if getCurrentTradeType() == BUY then
|
||||||
|
local capacityMaxCount = math.floor(playerFreeCapacity / item.weight)
|
||||||
|
if ignoreCapacity:isChecked() then
|
||||||
|
capacityMaxCount = 100
|
||||||
|
end
|
||||||
|
local priceMaxCount = math.floor(playerMoney / getItemPrice(item))
|
||||||
|
quantityScroll:setMaximum(math.max(0, math.min(100, math.min(priceMaxCount, capacityMaxCount))))
|
||||||
|
else
|
||||||
|
local removeAmount = 0
|
||||||
|
if ignoreEquipped:isChecked() then
|
||||||
|
local localPlayer = g_game.getLocalPlayer()
|
||||||
|
for i=1,LAST_INVENTORY do
|
||||||
|
local inventoryItem = localPlayer:getInventoryItem(i)
|
||||||
|
if inventoryItem and inventoryItem:getId() == item.ptr:getId() then
|
||||||
|
removeAmount = removeAmount + inventoryItem:getCount()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
quantityScroll:setMaximum(math.max(0, math.min(100, getSellQuantity(item))))
|
||||||
|
end
|
||||||
|
|
||||||
|
setupPanel:enable()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function refreshTradeItems()
|
||||||
|
local layout = itemsPanel:getLayout()
|
||||||
|
layout:disableUpdates()
|
||||||
|
|
||||||
|
clearSelectedItem()
|
||||||
|
|
||||||
|
searchText:clearText()
|
||||||
|
setupPanel:disable()
|
||||||
|
itemsPanel:destroyChildren()
|
||||||
|
|
||||||
|
if radioItems then
|
||||||
|
radioItems:destroy()
|
||||||
|
end
|
||||||
|
radioItems = RadioGroup.create()
|
||||||
|
|
||||||
|
local currentTradeItems = tradeItems[getCurrentTradeType()]
|
||||||
|
for key,item in pairs(currentTradeItems) do
|
||||||
|
local itemBox = createWidget('NPCItemBox', itemsPanel)
|
||||||
|
itemBox.item = item
|
||||||
|
itemBox:getChildById('item'):setItem(item.ptr)
|
||||||
|
itemBox:getChildById('nameLabel'):setText(item.name)
|
||||||
|
itemBox:getChildById('weightLabel'):setText(string.format('%.2f', item.weight) .. ' ' .. WEIGHT_UNIT)
|
||||||
|
itemBox:getChildById('priceLabel'):setText(item.price .. ' ' .. CURRENCY)
|
||||||
|
|
||||||
|
itemBox.onMouseRelease = NPCTrade.itemPopup
|
||||||
|
itemBox:getChildById('item').onMouseRelease = function(self, mousePosition, mouseButton) NPCTrade.itemPopup(itemBox, mousePosition, mouseButton) end
|
||||||
|
|
||||||
|
radioItems:addWidget(itemBox)
|
||||||
|
end
|
||||||
|
|
||||||
|
layout:enableUpdates()
|
||||||
|
layout:update()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function refreshPlayerGoods()
|
||||||
|
moneyLabel:setText(playerMoney .. ' ' .. CURRENCY)
|
||||||
|
capacityLabel:setText(string.format('%.2f', playerFreeCapacity) .. ' ' .. WEIGHT_UNIT)
|
||||||
|
|
||||||
|
local currentTradeType = getCurrentTradeType()
|
||||||
|
local searchFilter = searchText:getText()
|
||||||
|
local foundSelectedItem = false
|
||||||
|
|
||||||
|
local items = itemsPanel:getChildCount()
|
||||||
|
for i=1,items do
|
||||||
|
local itemWidget = itemsPanel:getChildByIndex(i)
|
||||||
|
local item = itemWidget.item
|
||||||
|
|
||||||
|
local canTrade = canTradeItem(item)
|
||||||
|
itemWidget:setEnabled(canTrade)
|
||||||
|
|
||||||
|
local searchCondition = (searchFilter == '') or (searchFilter ~= '' and string.find(item.name, searchFilter) ~= nil)
|
||||||
|
local showAllItemsCondition = (currentTradeType == BUY) or (showAllItems:isChecked()) or (currentTradeType == SELL and not showAllItems:isChecked() and canTrade)
|
||||||
|
itemWidget:setVisible(searchCondition and showAllItemsCondition)
|
||||||
|
|
||||||
|
if selectedItem == item and itemWidget:isEnabled() and itemWidget:isVisible() then
|
||||||
|
foundSelectedItem = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not foundSelectedItem then
|
||||||
|
clearSelectedItem()
|
||||||
|
end
|
||||||
|
|
||||||
|
if selectedItem then
|
||||||
|
refreshItem(selectedItem)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- public functions
|
-- public functions
|
||||||
function NPCTrade.init()
|
function NPCTrade.init()
|
||||||
|
@ -38,9 +206,7 @@ function NPCTrade.init()
|
||||||
npcWindow:setVisible(false)
|
npcWindow:setVisible(false)
|
||||||
|
|
||||||
itemsPanel = npcWindow:recursiveGetChildById('itemsPanel')
|
itemsPanel = npcWindow:recursiveGetChildById('itemsPanel')
|
||||||
buyTab = npcWindow:getChildById('buyTab')
|
searchText = npcWindow:recursiveGetChildById('searchText')
|
||||||
sellTab = npcWindow:getChildById('sellTab')
|
|
||||||
searchText = npcWindow:getChildById('searchText')
|
|
||||||
|
|
||||||
setupPanel = npcWindow:recursiveGetChildById('setupPanel')
|
setupPanel = npcWindow:recursiveGetChildById('setupPanel')
|
||||||
quantityLabel = setupPanel:getChildById('quantity')
|
quantityLabel = setupPanel:getChildById('quantity')
|
||||||
|
@ -50,18 +216,33 @@ function NPCTrade.init()
|
||||||
moneyLabel = setupPanel:getChildById('money')
|
moneyLabel = setupPanel:getChildById('money')
|
||||||
weightLabel = setupPanel:getChildById('weight')
|
weightLabel = setupPanel:getChildById('weight')
|
||||||
capacityLabel = setupPanel:getChildById('capacity')
|
capacityLabel = setupPanel:getChildById('capacity')
|
||||||
setupButton = setupPanel:getChildById('setupButton')
|
tradeButton = npcWindow:recursiveGetChildById('tradeButton')
|
||||||
|
|
||||||
|
buyWithBackpack = npcWindow:recursiveGetChildById('buyWithBackpack')
|
||||||
|
ignoreCapacity = npcWindow:recursiveGetChildById('ignoreCapacity')
|
||||||
|
ignoreEquipped = npcWindow:recursiveGetChildById('ignoreEquipped')
|
||||||
|
showAllItems = npcWindow:recursiveGetChildById('showAllItems')
|
||||||
|
|
||||||
|
buyTab = npcWindow:getChildById('buyTab')
|
||||||
|
sellTab = npcWindow:getChildById('sellTab')
|
||||||
|
|
||||||
radioTabs = RadioGroup.create()
|
radioTabs = RadioGroup.create()
|
||||||
radioTabs:addWidget(buyTab)
|
radioTabs:addWidget(buyTab)
|
||||||
radioTabs:addWidget(sellTab)
|
radioTabs:addWidget(sellTab)
|
||||||
radioTabs:selectWidget(buyTab)
|
radioTabs:selectWidget(buyTab)
|
||||||
radioTabs.onSelectionChange = NPCTrade.setList
|
radioTabs.onSelectionChange = NPCTrade.onTradeTypeChange
|
||||||
|
|
||||||
|
if g_game.isOnline() then -- event wont be sent again when reloading modules
|
||||||
|
playerFreeCapacity = g_game.getLocalPlayer():getFreeCapacity()
|
||||||
|
end
|
||||||
|
|
||||||
connect(g_game, { onGameEnd = NPCTrade.hide,
|
connect(g_game, { onGameEnd = NPCTrade.hide,
|
||||||
onOpenNpcTrade = NPCTrade.onOpenNpcTrade,
|
onOpenNpcTrade = NPCTrade.onOpenNpcTrade,
|
||||||
onPlayerGoods = NPCTrade.onPlayerGoods,
|
onCloseNpcTrade = NPCTrade.onCloseNpcTrade,
|
||||||
onCloseNpcTrade = NPCTrade.onCloseNpcTrade } )
|
onPlayerGoods = NPCTrade.onPlayerGoods } )
|
||||||
|
|
||||||
|
connect(LocalPlayer, { onFreeCapacityChange = NPCTrade.onFreeCapacityChange,
|
||||||
|
onInventoryChange = NPCTrade.onInventoryChange } )
|
||||||
end
|
end
|
||||||
|
|
||||||
function NPCTrade.terminate()
|
function NPCTrade.terminate()
|
||||||
|
@ -73,6 +254,8 @@ function NPCTrade.terminate()
|
||||||
buyButton = nil
|
buyButton = nil
|
||||||
sellButton = nil
|
sellButton = nil
|
||||||
searchText = nil
|
searchText = nil
|
||||||
|
buyTab = nil
|
||||||
|
sellTab = nil
|
||||||
|
|
||||||
setupPanel = nil
|
setupPanel = nil
|
||||||
quantityLabel = nil
|
quantityLabel = nil
|
||||||
|
@ -83,24 +266,28 @@ function NPCTrade.terminate()
|
||||||
weightLabel = nil
|
weightLabel = nil
|
||||||
capacityLabel = nil
|
capacityLabel = nil
|
||||||
offerSelected = nil
|
offerSelected = nil
|
||||||
setupButton = nil
|
tradeButton = nil
|
||||||
|
|
||||||
cacheItems = nil
|
|
||||||
cacheGoods = nil
|
|
||||||
buyTab = nil
|
|
||||||
sellTab = nil
|
|
||||||
|
|
||||||
disconnect(g_game, { onGameEnd = NPCTrade.hide,
|
disconnect(g_game, { onGameEnd = NPCTrade.hide,
|
||||||
onOpenNpcTrade = NPCTrade.onOpenNpcTrade,
|
onOpenNpcTrade = NPCTrade.onOpenNpcTrade,
|
||||||
|
onCloseNpcTrade = NPCTrade.onCloseNpcTrade,
|
||||||
onPlayerGoods = NPCTrade.onPlayerGoods,
|
onPlayerGoods = NPCTrade.onPlayerGoods,
|
||||||
onCloseNpcTrade = NPCTrade.onCloseNpcTrade } )
|
onFreeCapacityChange = NPCTrade.onFreeCapacityChange } )
|
||||||
|
|
||||||
|
disconnect(LocalPlayer, { onFreeCapacityChange = NPCTrade.onFreeCapacityChange,
|
||||||
|
onInventoryChange = NPCTrade.onInventoryChange } )
|
||||||
|
|
||||||
NPCTrade = nil
|
NPCTrade = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- private functions
|
|
||||||
function NPCTrade.show()
|
function NPCTrade.show()
|
||||||
if g_game.isOnline() then
|
if g_game.isOnline() then
|
||||||
|
if #tradeItems[BUY] > 0 then
|
||||||
|
radioTabs:selectWidget(buyTab)
|
||||||
|
else
|
||||||
|
radioTabs:selectWidget(sellTab)
|
||||||
|
end
|
||||||
|
|
||||||
npcWindow:show()
|
npcWindow:show()
|
||||||
npcWindow:raise()
|
npcWindow:raise()
|
||||||
end
|
end
|
||||||
|
@ -110,246 +297,132 @@ function NPCTrade.hide()
|
||||||
npcWindow:hide()
|
npcWindow:hide()
|
||||||
end
|
end
|
||||||
|
|
||||||
function NPCTrade.setList(radioTabs, selected, deselected)
|
function NPCTrade.onItemBoxChecked(widget)
|
||||||
setupButton:setText(selected:getText())
|
if widget:isChecked() then
|
||||||
|
local item = widget.item
|
||||||
|
selectedItem = item
|
||||||
|
refreshItem(item)
|
||||||
|
tradeButton:enable()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function NPCTrade.onQuantityValueChange(quantity)
|
||||||
|
if quantityLabel and selectedItem then
|
||||||
|
quantityLabel:setText(quantity)
|
||||||
|
weightLabel:setText(string.format('%.2f', selectedItem.weight*quantity) .. ' ' .. WEIGHT_UNIT)
|
||||||
|
priceLabel:setText(getItemPrice(selectedItem) .. ' ' .. CURRENCY)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function NPCTrade.onTradeTypeChange(radioTabs, selected, deselected)
|
||||||
|
tradeButton:setText(selected:getText())
|
||||||
selected:setOn(true)
|
selected:setOn(true)
|
||||||
deselected:setOn(false)
|
deselected:setOn(false)
|
||||||
NPCTrade.createItemsOnPanel()
|
|
||||||
|
|
||||||
NPCTrade.resetSetup()
|
local currentTradeType = getCurrentTradeType()
|
||||||
NPCTrade.refreshItemsPanel()
|
buyWithBackpack:setVisible(currentTradeType == BUY)
|
||||||
NPCTrade.refreshFilters()
|
ignoreCapacity:setVisible(currentTradeType == BUY)
|
||||||
|
ignoreEquipped:setVisible(currentTradeType == SELL)
|
||||||
|
showAllItems:setVisible(currentTradeType == SELL)
|
||||||
|
|
||||||
|
refreshTradeItems()
|
||||||
|
refreshPlayerGoods()
|
||||||
end
|
end
|
||||||
|
|
||||||
function NPCTrade.resetSetup()
|
function NPCTrade.onTradeClick()
|
||||||
nameLabel:clearText()
|
if getCurrentTradeType() == BUY then
|
||||||
weightLabel:clearText()
|
g_game.buyItem(selectedItem.ptr, quantityScroll:getValue(), buyWithBackpack:isChecked(), ignoreCapacity:isChecked())
|
||||||
priceLabel:clearText()
|
|
||||||
searchText:clearText()
|
|
||||||
if offerSelected then
|
|
||||||
radioItems.selectedWidget:setChecked(false)
|
|
||||||
offerSelected = nil
|
|
||||||
end
|
|
||||||
setupPanel:disable()
|
|
||||||
end
|
|
||||||
|
|
||||||
function NPCTrade.updateSetup()
|
|
||||||
if offerSelected then
|
|
||||||
if radioItems.selectedWidget:isEnabled() then
|
|
||||||
if setupButton:getText() == tr('Buy') then
|
|
||||||
local capacityMaxCount = math.floor(100*g_game.getLocalPlayer():getFreeCapacity()/offerSelected[3])
|
|
||||||
local priceMaxCount = math.floor(moneyGoods/NPCTrade.getOfferPrice(offerSelected))
|
|
||||||
quantityScroll:setMaximum(math.max(0, math.min(100, math.min(priceMaxCount, capacityMaxCount))))
|
|
||||||
else
|
else
|
||||||
if cacheGoods[offerSelected[1]:getId()] then -- list might be empty.
|
g_game.sellItem(selectedItem.ptr, quantityScroll:getValue(), ignoreEquipped:isChecked())
|
||||||
quantityScroll:setMaximum(math.max(0, math.min(100, cacheGoods[offerSelected[1]:getId()])))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
NPCTrade.resetSetup()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function NPCTrade.getOfferPrice(offer)
|
|
||||||
if setupButton:getText() == tr('Buy') then
|
|
||||||
local price = offer[4]
|
|
||||||
if buyWithBackpack then
|
|
||||||
if offer[1]:isStackable() then
|
|
||||||
return price*quantityScroll:getValue() + 20;
|
|
||||||
else
|
|
||||||
return price*quantityScroll:getValue() + math.ceil(quantityScroll:getValue()/20)*20
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return price*quantityScroll:getValue()
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return offer[5]*quantityScroll:getValue()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function NPCTrade.setItem(widget)
|
function NPCTrade.onSearchTextChange()
|
||||||
offerSelected = widget.offer
|
refreshPlayerGoods()
|
||||||
|
|
||||||
local offer = widget.offer
|
|
||||||
local price = NPCTrade.getOfferPrice(widget.offer)
|
|
||||||
local freeCapacity = g_game.getLocalPlayer():getFreeCapacity()
|
|
||||||
nameLabel:setText(offer[2])
|
|
||||||
weightLabel:setText(string.format('%.2f', offer[3]/100) .. ' ' .. WEIGHT_UNIT)
|
|
||||||
priceLabel:setText(price .. ' ' .. CURRENCY)
|
|
||||||
capacityLabel:setText(string.format('%.2f', freeCapacity) .. ' ' .. WEIGHT_UNIT)
|
|
||||||
|
|
||||||
quantityLabel:setText(1)
|
|
||||||
quantityScroll:setValue(1)
|
|
||||||
NPCTrade.updateSetup()
|
|
||||||
|
|
||||||
setupPanel:enable()
|
|
||||||
end
|
|
||||||
|
|
||||||
function NPCTrade.setQuantity(quantity)
|
|
||||||
if quantityLabel and offerSelected then
|
|
||||||
local price = NPCTrade.getOfferPrice(offerSelected)
|
|
||||||
quantityLabel:setText(quantity)
|
|
||||||
weightLabel:setText(string.format('%.2f', offerSelected[3]*quantity/100) .. ' ' .. WEIGHT_UNIT)
|
|
||||||
priceLabel:setText(price .. ' ' .. CURRENCY)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function NPCTrade.setupButton()
|
|
||||||
if setupButton:getText() == 'Buy' then
|
|
||||||
g_game.buyItem(offerSelected[1], quantityScroll:getValue(), buyWithBackpack, ignoreCapacity)
|
|
||||||
else
|
|
||||||
g_game.sellItem(offerSelected[1], quantityScroll:getValue(), ignoreEquipped)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function NPCTrade.onOpenNpcTrade(items)
|
|
||||||
-- items[item] = item
|
|
||||||
-- item[1] = ItemPtr
|
|
||||||
-- item[2] = name
|
|
||||||
-- item[3] = weight
|
|
||||||
-- item[4] = buyPrice
|
|
||||||
-- item[5] = sellPrice
|
|
||||||
|
|
||||||
cacheItems = items
|
|
||||||
|
|
||||||
NPCTrade.createItemsOnPanel()
|
|
||||||
|
|
||||||
NPCTrade.show()
|
|
||||||
end
|
|
||||||
|
|
||||||
function NPCTrade.switchBuyWithBackpack()
|
|
||||||
buyWithBackpack = not buyWithBackpack
|
|
||||||
if offerSelected then
|
|
||||||
priceLabel:setText(NPCTrade.getOfferPrice(offerSelected) .. ' ' .. CURRENCY)
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
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.offer[1]) end)
|
||||||
menu:addSeparator()
|
|
||||||
if setupButton:getText() == tr('Buy') then
|
|
||||||
menu:addOption((buyWithBackpack and tr('Buy no backpack') or tr('Buy with backpack')), NPCTrade.switchBuyWithBackpack)
|
|
||||||
menu:addOption((ignoreCapacity and tr('Consider capacity') or tr('Ignore capacity')), function() ignoreCapacity = not ignoreCapacity return true end)
|
|
||||||
else
|
|
||||||
menu:addOption((ignoreEquipped and tr('Consider equipped') or tr('Ignore equipped')), function() ignoreEquipped = not ignoreEquipped return true end)
|
|
||||||
menu:addOption((showOnlyHolding and tr('Show all items') or tr('Show only holding items')), function() showOnlyHolding = not showOnlyHolding NPCTrade.refreshFilters() return true end)
|
|
||||||
end
|
|
||||||
menu:display(mousePosition)
|
menu:display(mousePosition)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function NPCTrade.createItemsOnPanel()
|
function NPCTrade.onBuyWithBackpackChange()
|
||||||
local layout = itemsPanel:getLayout()
|
if selectedItem then
|
||||||
layout:disableUpdates()
|
refreshItem(selectedItem)
|
||||||
|
|
||||||
NPCTrade.resetSetup()
|
|
||||||
|
|
||||||
offerSelected = nil
|
|
||||||
itemsPanel:destroyChildren()
|
|
||||||
|
|
||||||
if radioItems then
|
|
||||||
radioItems:destroy()
|
|
||||||
end
|
|
||||||
radioItems = RadioGroup.create()
|
|
||||||
|
|
||||||
for i, v in pairs(cacheItems) do
|
|
||||||
local price = NPCTrade.getOfferPrice(v)
|
|
||||||
if price > 0 then
|
|
||||||
local itemBox = createWidget('NPCItemBox', itemsPanel)
|
|
||||||
itemBox.offer = v
|
|
||||||
itemBox:getChildById('item'):setItem(v[1])
|
|
||||||
itemBox:getChildById('nameLabel'):setText(v[2])
|
|
||||||
itemBox:getChildById('weightLabel'):setText(string.format('%.2f', v[3]/100) .. ' ' .. WEIGHT_UNIT)
|
|
||||||
itemBox:getChildById('priceLabel'):setText(price .. ' ' .. CURRENCY)
|
|
||||||
|
|
||||||
itemBox.onMouseRelease = NPCTrade.itemPopup
|
|
||||||
itemBox:getChildById('item').onMouseRelease = function (self, mousePosition, mouseButton) NPCTrade.itemPopup(itemBox, mousePosition, mouseButton) end
|
|
||||||
|
|
||||||
radioItems:addWidget(itemBox)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
layout:enableUpdates()
|
function NPCTrade.onIgnoreCapacityChange()
|
||||||
layout:update()
|
refreshPlayerGoods()
|
||||||
end
|
end
|
||||||
|
|
||||||
function NPCTrade.extraFilters(widget, showOnlyHolding)
|
function NPCTrade.onIgnoreEquippedChange()
|
||||||
if setupButton:getText() == tr('Sell') then
|
refreshPlayerGoods()
|
||||||
if not showOnlyHolding or cacheGoods[widget.offer[1]:getId()] then
|
end
|
||||||
return true
|
|
||||||
|
function NPCTrade.onShowAllItemsChange()
|
||||||
|
refreshPlayerGoods()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- hooked functions
|
||||||
|
function NPCTrade.onOpenNpcTrade(items)
|
||||||
|
tradeItems[BUY] = {}
|
||||||
|
tradeItems[SELL] = {}
|
||||||
|
|
||||||
|
for key,item in pairs(items) do
|
||||||
|
local newItem = {}
|
||||||
|
newItem.ptr = item[1]
|
||||||
|
newItem.name = item[2]
|
||||||
|
newItem.weight = item[3] / 100
|
||||||
|
|
||||||
|
if item[4] >= 0 then
|
||||||
|
newItem.price = item[4]
|
||||||
|
table.insert(tradeItems[BUY], newItem)
|
||||||
|
elseif item[5] >= 0 then
|
||||||
|
newItem.price = item[5]
|
||||||
|
table.insert(tradeItems[SELL], newItem)
|
||||||
else
|
else
|
||||||
return false
|
error("server error: item name " .. item[1] .. " has neither buy or sell price.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
refreshTradeItems()
|
||||||
end
|
addEvent(NPCTrade.show) -- player goods has not been parsed yet
|
||||||
|
|
||||||
function NPCTrade.refreshFilters()
|
|
||||||
local filter = searchText:getText()
|
|
||||||
local items = itemsPanel:getChildCount()
|
|
||||||
for i = 1, items do
|
|
||||||
local itemWidget = itemsPanel:getChildByIndex(i)
|
|
||||||
if filter ~= '' then
|
|
||||||
if string.find(itemWidget.offer[2], filter) and NPCTrade.extraFilters(itemWidget, showOnlyHolding) then
|
|
||||||
itemWidget:show()
|
|
||||||
else
|
|
||||||
itemWidget:hide()
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if NPCTrade.extraFilters(itemWidget, showOnlyHolding) then
|
|
||||||
itemWidget:show()
|
|
||||||
else
|
|
||||||
itemWidget:hide()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function NPCTrade.refreshItemsPanel()
|
|
||||||
if setupButton:getText() == tr('Buy') then
|
|
||||||
local items = itemsPanel:getChildCount()
|
|
||||||
for i = 1, items do
|
|
||||||
local itemWidget = itemsPanel:getChildByIndex(i)
|
|
||||||
if moneyGoods < NPCTrade.getOfferPrice(itemWidget.offer) then
|
|
||||||
itemWidget:disable()
|
|
||||||
else
|
|
||||||
itemWidget:enable()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local items = itemsPanel:getChildCount()
|
|
||||||
for i = 1, items do
|
|
||||||
local itemWidget = itemsPanel:getChildByIndex(i)
|
|
||||||
if cacheGoods[itemWidget.offer[1]:getId()] then
|
|
||||||
itemWidget:enable()
|
|
||||||
else
|
|
||||||
itemWidget:disable()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function NPCTrade.onPlayerGoods(money, goods)
|
|
||||||
moneyGoods = money
|
|
||||||
|
|
||||||
moneyLabel:setText(money .. ' ' .. CURRENCY)
|
|
||||||
local freeCapacity = g_game.getLocalPlayer():getFreeCapacity()
|
|
||||||
capacityLabel:setText(string.format('%.2f', freeCapacity) .. ' ' .. WEIGHT_UNIT)
|
|
||||||
|
|
||||||
cacheGoods = {}
|
|
||||||
for i,v in pairs(goods) do
|
|
||||||
cacheGoods[v[1]:getId()] = v[2]
|
|
||||||
end
|
|
||||||
|
|
||||||
NPCTrade.refreshItemsPanel()
|
|
||||||
NPCTrade.updateSetup()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function NPCTrade.onCloseNpcTrade()
|
function NPCTrade.onCloseNpcTrade()
|
||||||
NPCTrade.hide()
|
NPCTrade.hide()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function NPCTrade.onPlayerGoods(money, items)
|
||||||
|
playerMoney = money
|
||||||
|
|
||||||
|
playerItems = {}
|
||||||
|
for key,item in pairs(items) do
|
||||||
|
local id = item[1]:getId()
|
||||||
|
if not playerItems[id] then
|
||||||
|
playerItems[id] = item[2]
|
||||||
|
else
|
||||||
|
playerItems[id] = playerItems[id] + item[2]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
refreshPlayerGoods()
|
||||||
|
end
|
||||||
|
|
||||||
|
function NPCTrade.onFreeCapacityChange(localPlayer, freeCapacity, oldFreeCapacity)
|
||||||
|
playerFreeCapacity = freeCapacity
|
||||||
|
|
||||||
|
if npcWindow:isVisible() then
|
||||||
|
refreshPlayerGoods()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function NPCTrade.onInventoryChange(inventory, item, oldeItem)
|
||||||
|
if selectedItem then
|
||||||
|
refreshItem(selectedItem)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -4,21 +4,17 @@ NPCOfferLabel < Label
|
||||||
margin-left: 5
|
margin-left: 5
|
||||||
text-auto-resize: true
|
text-auto-resize: true
|
||||||
|
|
||||||
NPCPanel < ScrollablePanel
|
|
||||||
image-source: /core_styles/styles/images/panel_flat.png
|
|
||||||
image-border: 1
|
|
||||||
|
|
||||||
NPCItemBox < UICheckBox
|
NPCItemBox < UICheckBox
|
||||||
border-width: 1
|
border-width: 1
|
||||||
border-color: #000000
|
border-color: #000000
|
||||||
@onCheckChange: NPCTrade.setItem(self)
|
@onCheckChange: NPCTrade.onItemBoxChecked(self)
|
||||||
|
|
||||||
Item
|
Item
|
||||||
id: item
|
id: item
|
||||||
phantom: true
|
phantom: true
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
margin-top: 2
|
margin-top: 3
|
||||||
|
|
||||||
Label
|
Label
|
||||||
id: nameLabel
|
id: nameLabel
|
||||||
|
@ -26,7 +22,7 @@ NPCItemBox < UICheckBox
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
text-auto-resize: true
|
text-auto-resize: true
|
||||||
margin-top: 5
|
margin-top: 3
|
||||||
|
|
||||||
Label
|
Label
|
||||||
id: weightLabel
|
id: weightLabel
|
||||||
|
@ -34,7 +30,7 @@ NPCItemBox < UICheckBox
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
text-auto-resize: true
|
text-auto-resize: true
|
||||||
margin-top: 5
|
margin-top: 3
|
||||||
|
|
||||||
Label
|
Label
|
||||||
id: priceLabel
|
id: priceLabel
|
||||||
|
@ -42,7 +38,7 @@ NPCItemBox < UICheckBox
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
text-auto-resize: true
|
text-auto-resize: true
|
||||||
margin-top: 5
|
margin-top: 3
|
||||||
|
|
||||||
$checked:
|
$checked:
|
||||||
border-color: #FFFFFF
|
border-color: #FFFFFF
|
||||||
|
@ -53,7 +49,7 @@ NPCItemBox < UICheckBox
|
||||||
MainWindow
|
MainWindow
|
||||||
id: npcWindow
|
id: npcWindow
|
||||||
!text: tr('NPC Trade')
|
!text: tr('NPC Trade')
|
||||||
size: 550 550
|
size: 550 515
|
||||||
|
|
||||||
@onEscape: NPCTrade.hide()
|
@onEscape: NPCTrade.hide()
|
||||||
|
|
||||||
|
@ -79,40 +75,24 @@ MainWindow
|
||||||
margin-left: 5
|
margin-left: 5
|
||||||
margin-top: 5
|
margin-top: 5
|
||||||
|
|
||||||
Label
|
Panel
|
||||||
id: searchLabel
|
|
||||||
!text: tr('Search:')
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.top: prev.bottom
|
|
||||||
text-auto-resize: true
|
|
||||||
margin-top: 7
|
|
||||||
margin-left: 2
|
|
||||||
|
|
||||||
TextEdit
|
|
||||||
id: searchText
|
|
||||||
width: 200
|
|
||||||
anchors.left: prev.right
|
|
||||||
anchors.top: prev.top
|
|
||||||
margin-top: -2
|
|
||||||
margin-left: 5
|
|
||||||
@onTextChange: NPCTrade.refreshFilters()
|
|
||||||
|
|
||||||
NPCPanel
|
|
||||||
height: 250
|
height: 250
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
margin-top: 5
|
margin-top: 10
|
||||||
|
image-source: /core_styles/styles/images/panel_flat.png
|
||||||
|
image-border: 1
|
||||||
|
|
||||||
VerticalScrollBar
|
VerticalScrollBar
|
||||||
id: itemsPanelListScrollBar
|
id: itemsPanelListScrollBar
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
step: 14
|
step: 16
|
||||||
pixels-scroll: true
|
pixels-scroll: true
|
||||||
|
|
||||||
NPCPanel
|
ScrollablePanel
|
||||||
id: itemsPanel
|
id: itemsPanel
|
||||||
height: 250
|
height: 250
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
|
@ -120,6 +100,8 @@ MainWindow
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
vertical-scrollbar: itemsPanelListScrollBar
|
vertical-scrollbar: itemsPanelListScrollBar
|
||||||
|
margin-left: 5
|
||||||
|
margin-right: 5
|
||||||
layout:
|
layout:
|
||||||
type: grid
|
type: grid
|
||||||
cell-size: 160 90
|
cell-size: 160 90
|
||||||
|
@ -128,21 +110,76 @@ MainWindow
|
||||||
|
|
||||||
FlatPanel
|
FlatPanel
|
||||||
id: setupPanel
|
id: setupPanel
|
||||||
height: 150
|
height: 140
|
||||||
enabled: false
|
enabled: false
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.horizontalCenter
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
margin-top: 5
|
margin-top: 10
|
||||||
|
margin-right: 5
|
||||||
|
|
||||||
Label
|
Label
|
||||||
id: quantityLabel
|
!text: tr('Name:')
|
||||||
!text: tr('Quantity:')
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
text-auto-resize: true
|
|
||||||
margin-top: 5
|
margin-top: 5
|
||||||
margin-left: 2
|
margin-left: 5
|
||||||
|
width: 85
|
||||||
|
|
||||||
|
NPCOfferLabel
|
||||||
|
id: name
|
||||||
|
|
||||||
|
Label
|
||||||
|
!text: tr('Price:')
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.top: prev.bottom
|
||||||
|
margin-top: 5
|
||||||
|
margin-left: 5
|
||||||
|
width: 85
|
||||||
|
|
||||||
|
NPCOfferLabel
|
||||||
|
id: price
|
||||||
|
|
||||||
|
Label
|
||||||
|
!text: tr('Your Money:')
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.top: prev.bottom
|
||||||
|
margin-top: 5
|
||||||
|
margin-left: 5
|
||||||
|
width: 85
|
||||||
|
|
||||||
|
NPCOfferLabel
|
||||||
|
id: money
|
||||||
|
|
||||||
|
Label
|
||||||
|
!text: tr('Weight:')
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.top: prev.bottom
|
||||||
|
margin-top: 5
|
||||||
|
margin-left: 5
|
||||||
|
width: 85
|
||||||
|
|
||||||
|
NPCOfferLabel
|
||||||
|
id: weight
|
||||||
|
|
||||||
|
Label
|
||||||
|
!text: tr('Your Capacity:')
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.top: prev.bottom
|
||||||
|
margin-top: 5
|
||||||
|
margin-left: 5
|
||||||
|
width: 85
|
||||||
|
|
||||||
|
NPCOfferLabel
|
||||||
|
id: capacity
|
||||||
|
|
||||||
|
Label
|
||||||
|
!text: tr('Quantity:')
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.top: prev.bottom
|
||||||
|
margin-top: 5
|
||||||
|
margin-left: 5
|
||||||
|
width: 85
|
||||||
|
|
||||||
NPCOfferLabel
|
NPCOfferLabel
|
||||||
id: quantity
|
id: quantity
|
||||||
|
@ -152,80 +189,92 @@ MainWindow
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: prev.bottom
|
anchors.top: prev.bottom
|
||||||
margin-top: 2
|
margin-top: 5
|
||||||
|
margin-left: 5
|
||||||
|
margin-right: 5
|
||||||
minimum: 1
|
minimum: 1
|
||||||
maximum: 100
|
maximum: 100
|
||||||
value: 1
|
|
||||||
step: 1
|
step: 1
|
||||||
@onValueChange: NPCTrade.setQuantity(self:getValue())
|
@onValueChange: NPCTrade.onQuantityValueChange(self:getValue())
|
||||||
|
|
||||||
|
FlatPanel
|
||||||
|
id: buyOptions
|
||||||
|
height: 140
|
||||||
|
anchors.top: prev.top
|
||||||
|
anchors.left: parent.horizontalCenter
|
||||||
|
anchors.right: parent.right
|
||||||
|
margin-left: 5
|
||||||
|
|
||||||
Label
|
Label
|
||||||
id: nameLabel
|
id: searchLabel
|
||||||
!text: tr('Name:')
|
!text: tr('Search:')
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.top: prev.bottom
|
anchors.top: parent.top
|
||||||
margin-top: 5
|
text-auto-resize: true
|
||||||
margin-left: 2
|
margin-top: 7
|
||||||
width: 64
|
margin-left: 5
|
||||||
|
|
||||||
NPCOfferLabel
|
TextEdit
|
||||||
id: name
|
id: searchText
|
||||||
|
anchors.left: prev.right
|
||||||
|
anchors.top: prev.top
|
||||||
|
anchors.right: parent.right
|
||||||
|
margin-top: -2
|
||||||
|
margin-left: 5
|
||||||
|
margin-right: 5
|
||||||
|
@onTextChange: NPCTrade.onSearchTextChange()
|
||||||
|
|
||||||
Label
|
CheckBox
|
||||||
id: priceLabel
|
id: buyWithBackpack
|
||||||
!text: tr('Price:')
|
!text: tr('Buy with backpack')
|
||||||
|
anchors.top: searchText.bottom
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.top: prev.bottom
|
anchors.right: parent.right
|
||||||
|
margin-left: 5
|
||||||
margin-top: 5
|
margin-top: 5
|
||||||
margin-left: 2
|
@onCheckChange: NPCTrade.onBuyWithBackpackChange()
|
||||||
width: 64
|
|
||||||
|
|
||||||
NPCOfferLabel
|
CheckBox
|
||||||
id: price
|
id: ignoreCapacity
|
||||||
|
!text: tr('Ignore capacity')
|
||||||
Label
|
anchors.top: prev.bottom
|
||||||
id: moneyLabel
|
|
||||||
!text: tr('Money:')
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.top: prev.bottom
|
anchors.right: parent.right
|
||||||
|
margin-left: 5
|
||||||
margin-top: 5
|
margin-top: 5
|
||||||
margin-left: 2
|
@onCheckChange: NPCTrade.onIgnoreCapacityChange()
|
||||||
width: 64
|
|
||||||
|
|
||||||
NPCOfferLabel
|
CheckBox
|
||||||
id: money
|
id: ignoreEquipped
|
||||||
|
!text: tr('Ignore equipped')
|
||||||
Label
|
anchors.top: searchText.bottom
|
||||||
id: weightLabel
|
|
||||||
!text: tr('Weight:')
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.top: prev.bottom
|
anchors.right: parent.right
|
||||||
|
margin-left: 5
|
||||||
margin-top: 5
|
margin-top: 5
|
||||||
margin-left: 2
|
visible: false
|
||||||
width: 64
|
checked: true
|
||||||
|
@onCheckChange: NPCTrade.onIgnoreEquippedChange()
|
||||||
|
|
||||||
NPCOfferLabel
|
CheckBox
|
||||||
id: weight
|
id: showAllItems
|
||||||
|
!text: tr('Show all items')
|
||||||
Label
|
anchors.top: prev.bottom
|
||||||
id: capacityLabel
|
|
||||||
!text: tr('Capacity:')
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.top: prev.bottom
|
anchors.right: parent.right
|
||||||
|
margin-left: 5
|
||||||
margin-top: 5
|
margin-top: 5
|
||||||
margin-left: 2
|
visible: false
|
||||||
width: 64
|
@onCheckChange: NPCTrade.onShowAllItemsChange()
|
||||||
|
|
||||||
NPCOfferLabel
|
|
||||||
id: capacity
|
|
||||||
|
|
||||||
Button
|
Button
|
||||||
id: setupButton
|
id: tradeButton
|
||||||
!text: tr('Buy')
|
!text: tr('Buy')
|
||||||
width: 64
|
width: 64
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.right: next.left
|
||||||
anchors.top: prev.bottom
|
anchors.bottom: parent.bottom
|
||||||
@onClick: NPCTrade.setupButton()
|
margin-right: 10
|
||||||
|
@onClick: NPCTrade.onTradeClick()
|
||||||
|
|
||||||
Button
|
Button
|
||||||
!text: tr('Close')
|
!text: tr('Close')
|
||||||
|
@ -233,4 +282,3 @@ MainWindow
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
@onClick: NPCTrade.hide()
|
@onClick: NPCTrade.hide()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue