Fix scrollbar

This commit is contained in:
Henrique Santiago
2013-02-19 21:34:06 -03:00
parent e87e669c87
commit 6d456994f4
5 changed files with 31 additions and 19 deletions

View File

@@ -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

View File

@@ -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