mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 03:54:54 +02:00
Fix scrollbar
This commit is contained in:
@@ -55,8 +55,9 @@ local function updateValueDisplay(widget)
|
||||
if widget == nil then return end
|
||||
|
||||
if widget:getShowValue() then
|
||||
local valueLabel = widget:getChildById('valueLabel')
|
||||
local symbol = widget:getSymbol()
|
||||
widget:setText(widget:getValue()..(symbol and symbol or ''))
|
||||
valueLabel:setText(widget:getValue() .. (symbol or ''))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -171,7 +172,10 @@ end
|
||||
|
||||
function UIScrollBar:setMaximum(maximum)
|
||||
if maximum == self.maximum then return end
|
||||
self.maximum = maximum
|
||||
self.maximum = maximum
|
||||
if self.minimum > maximum then
|
||||
self:setMinimum(maximum)
|
||||
end
|
||||
if self.value > maximum then
|
||||
self:setValue(maximum)
|
||||
else
|
||||
@@ -182,6 +186,9 @@ end
|
||||
function UIScrollBar:setMinimum(minimum)
|
||||
if minimum == self.minimum then return end
|
||||
self.minimum = minimum
|
||||
if self.maximum < minimum then
|
||||
self:setMaximum(minimum)
|
||||
end
|
||||
if self.value < minimum then
|
||||
self:setValue(minimum)
|
||||
else
|
||||
|
@@ -127,6 +127,10 @@ function onItemBoxChecked(widget)
|
||||
selectedItem = item
|
||||
refreshItem(item)
|
||||
tradeButton:enable()
|
||||
|
||||
if getCurrentTradeType() == SELL then
|
||||
quantityScroll:setValue(quantityScroll:getMaximum())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -225,7 +229,8 @@ function clearSelectedItem()
|
||||
weightLabel:clearText()
|
||||
priceLabel:clearText()
|
||||
tradeButton:disable()
|
||||
quantityScroll:setMaximum(1)
|
||||
quantityScroll:setMinimum(0)
|
||||
quantityScroll:setMaximum(0)
|
||||
if selectedItem then
|
||||
radioItems:selectWidget(nil)
|
||||
selectedItem = nil
|
||||
@@ -293,22 +298,10 @@ function refreshItem(item)
|
||||
end
|
||||
local priceMaxCount = math.floor(playerMoney / getItemPrice(item, true))
|
||||
local finalCount = math.max(0, math.min(getMaxAmount(), math.min(priceMaxCount, capacityMaxCount)))
|
||||
quantityScroll:setMinimum(1)
|
||||
quantityScroll:setMaximum(finalCount)
|
||||
|
||||
if quantityScroll:getValue() > finalCount then
|
||||
quantityScroll:setValue(finalCount)
|
||||
end
|
||||
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:setMinimum(1)
|
||||
quantityScroll:setMaximum(math.max(0, math.min(getMaxAmount(), getSellQuantity(item.ptr))))
|
||||
end
|
||||
|
||||
@@ -481,7 +474,6 @@ function sellAll()
|
||||
local amount = getSellQuantity(item)
|
||||
if amount > 0 then
|
||||
g_game.sellItem(item, amount, ignoreEquipped:isChecked())
|
||||
print(amount)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user