mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-10-19 22:23:28 +02:00
Version 2.2 - retro layout + bug fixes
This commit is contained in:
@@ -32,7 +32,7 @@ ignoreCapacity = nil
|
||||
ignoreEquipped = nil
|
||||
showAllItems = nil
|
||||
sellAllButton = nil
|
||||
|
||||
sellAllWithDelayButton = nil
|
||||
playerFreeCapacity = 0
|
||||
playerMoney = 0
|
||||
tradeItems = {}
|
||||
@@ -41,6 +41,8 @@ selectedItem = nil
|
||||
|
||||
cancelNextRelease = nil
|
||||
|
||||
sellAllWithDelayEvent = nil
|
||||
|
||||
function init()
|
||||
npcWindow = g_ui.displayUI('npctrade')
|
||||
npcWindow:setVisible(false)
|
||||
@@ -65,7 +67,7 @@ function init()
|
||||
ignoreEquipped = npcWindow:recursiveGetChildById('ignoreEquipped')
|
||||
showAllItems = npcWindow:recursiveGetChildById('showAllItems')
|
||||
sellAllButton = npcWindow:recursiveGetChildById('sellAllButton')
|
||||
|
||||
sellAllWithDelayButton = npcWindow:recursiveGetChildById('sellAllWithDelayButton')
|
||||
buyTab = npcWindow:getChildById('buyTab')
|
||||
sellTab = npcWindow:getChildById('sellTab')
|
||||
|
||||
@@ -95,7 +97,8 @@ end
|
||||
function terminate()
|
||||
initialized = false
|
||||
npcWindow:destroy()
|
||||
|
||||
removeEvent(sellAllWithDelayEvent)
|
||||
|
||||
disconnect(g_game, { onGameEnd = hide,
|
||||
onOpenNpcTrade = onOpenNpcTrade,
|
||||
onCloseNpcTrade = onCloseNpcTrade,
|
||||
@@ -120,6 +123,8 @@ function show()
|
||||
end
|
||||
|
||||
function hide()
|
||||
removeEvent(sellAllWithDelayEvent)
|
||||
|
||||
npcWindow:hide()
|
||||
|
||||
local layout = itemsPanel:getLayout()
|
||||
@@ -171,12 +176,14 @@ function onTradeTypeChange(radioTabs, selected, deselected)
|
||||
ignoreEquipped:setVisible(currentTradeType == SELL)
|
||||
showAllItems:setVisible(currentTradeType == SELL)
|
||||
sellAllButton:setVisible(currentTradeType == SELL)
|
||||
|
||||
sellAllWithDelayButton:setVisible(currentTradeType == SELL)
|
||||
|
||||
refreshTradeItems()
|
||||
refreshPlayerGoods()
|
||||
end
|
||||
|
||||
function onTradeClick()
|
||||
removeEvent(sellAllWithDelayEvent)
|
||||
if getCurrentTradeType() == BUY then
|
||||
g_game.buyItem(selectedItem.ptr, quantityScroll:getValue(), ignoreCapacity:isChecked(), buyWithBackpack:isChecked())
|
||||
else
|
||||
@@ -414,7 +421,6 @@ end
|
||||
function onOpenNpcTrade(items)
|
||||
tradeItems[BUY] = {}
|
||||
tradeItems[SELL] = {}
|
||||
|
||||
for key,item in pairs(items) do
|
||||
if item[4] > 0 then
|
||||
local newItem = {}
|
||||
@@ -502,6 +508,8 @@ end
|
||||
function checkSellAllTooltip()
|
||||
sellAllButton:setEnabled(true)
|
||||
sellAllButton:removeTooltip()
|
||||
sellAllWithDelayButton:setEnabled(true)
|
||||
sellAllWithDelayButton:removeTooltip()
|
||||
|
||||
local total = 0
|
||||
local info = ''
|
||||
@@ -527,8 +535,10 @@ function checkSellAllTooltip()
|
||||
if info ~= '' then
|
||||
info = info.."\nTotal: "..total.." gold"
|
||||
sellAllButton:setTooltip(info)
|
||||
sellAllWithDelayButton:setTooltip(info)
|
||||
else
|
||||
sellAllButton:setEnabled(false)
|
||||
sellAllWithDelayButton:setEnabled(false)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -547,14 +557,23 @@ function getMaxAmount()
|
||||
return 100
|
||||
end
|
||||
|
||||
function sellAll()
|
||||
for itemid,item in pairs(playerItems) do
|
||||
local item = Item.create(itemid)
|
||||
local amount = getSellQuantity(item)
|
||||
while amount > 0 do
|
||||
local maxAmount = math.min(amount, getMaxAmount())
|
||||
g_game.sellItem(item, maxAmount, ignoreEquipped:isChecked())
|
||||
amount = amount - maxAmount
|
||||
function sellAll(delayed)
|
||||
removeEvent(sellAllWithDelayEvent)
|
||||
local queue = {}
|
||||
for _,entry in ipairs(tradeItems[SELL]) do
|
||||
local sellQuantity = getSellQuantity(entry.ptr)
|
||||
while sellQuantity > 0 do
|
||||
local maxAmount = math.min(sellQuantity, getMaxAmount())
|
||||
if delayed then
|
||||
g_game.sellItem(entry.ptr, maxAmount, ignoreEquipped:isChecked())
|
||||
sellAllWithDelayEvent = scheduleEvent(function() sellAll(true) end, 1100)
|
||||
return
|
||||
end
|
||||
table.insert(queue, {entry.ptr, maxAmount, ignoreEquipped:isChecked()})
|
||||
sellQuantity = sellQuantity - maxAmount
|
||||
end
|
||||
end
|
||||
for _, entry in ipairs(queue) do
|
||||
g_game.sellItem(entry[1], entry[2], entry[3])
|
||||
end
|
||||
end
|
||||
|
@@ -254,9 +254,19 @@ MainWindow
|
||||
checked: true
|
||||
@onCheckChange: modules.game_npctrade.onShowAllItemsChange()
|
||||
|
||||
Button
|
||||
id: sellAllWithDelayButton
|
||||
!text: tr('Sell all with delay')
|
||||
width: 128
|
||||
anchors.right: next.left
|
||||
anchors.bottom: parent.bottom
|
||||
margin-right: 10
|
||||
visible: false
|
||||
@onClick: modules.game_npctrade.sellAll(true)
|
||||
|
||||
Button
|
||||
id: sellAllButton
|
||||
!text: tr('Sell All')
|
||||
!text: tr('Sell all')
|
||||
width: 64
|
||||
anchors.right: next.left
|
||||
anchors.bottom: parent.bottom
|
||||
|
Reference in New Issue
Block a user