Some minor fixes for the market.
* Max sell offer amount is now setting correctly. * Items widget is now clearing properly (tidy). * Depot will refresh when you sell items in the sell offers.
This commit is contained in:
parent
11387eb08f
commit
a5c3029e5b
|
@ -320,8 +320,9 @@ local function updateDetails(itemId, descriptions, purchaseStats, saleStats)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function updateSelectedItem(newItem)
|
local function updateSelectedItem(widget)
|
||||||
selectedItem.item = newItem
|
selectedItem.item = widget.item
|
||||||
|
selectedItem.ref = widget
|
||||||
|
|
||||||
Market.resetCreateOffer()
|
Market.resetCreateOffer()
|
||||||
if Market.isItemSelected() then
|
if Market.isItemSelected() then
|
||||||
|
@ -332,7 +333,7 @@ local function updateSelectedItem(newItem)
|
||||||
Market.enableCreateOffer(true)-- update offer types
|
Market.enableCreateOffer(true)-- update offer types
|
||||||
MarketProtocol.sendMarketBrowse(selectedItem.item.ptr:getId()) -- send browsed msg
|
MarketProtocol.sendMarketBrowse(selectedItem.item.ptr:getId()) -- send browsed msg
|
||||||
else
|
else
|
||||||
Market.Market.clearSelectedItem()
|
Market.clearSelectedItem()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -411,14 +412,21 @@ local function openAmountWindow(callback, type, actionText)
|
||||||
end
|
end
|
||||||
amountWindow = g_ui.createWidget('AmountWindow', rootWidget)
|
amountWindow = g_ui.createWidget('AmountWindow', rootWidget)
|
||||||
amountWindow:lock()
|
amountWindow:lock()
|
||||||
|
local max = selectedOffer[type]:getAmount()
|
||||||
|
if type == MarketAction.Sell then
|
||||||
|
local depot = Market.depotContains(selectedOffer[type]:getItem():getId())
|
||||||
|
if max > depot then
|
||||||
|
max = depot
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local spinbox = amountWindow:getChildById('amountSpinBox')
|
local spinbox = amountWindow:getChildById('amountSpinBox')
|
||||||
spinbox:setMaximum(selectedOffer[type]:getAmount())
|
spinbox:setMaximum(max)
|
||||||
spinbox:setMinimum(1)
|
spinbox:setMinimum(1)
|
||||||
spinbox:setValue(1)
|
spinbox:setValue(1)
|
||||||
|
|
||||||
local scrollbar = amountWindow:getChildById('amountScrollBar')
|
local scrollbar = amountWindow:getChildById('amountScrollBar')
|
||||||
scrollbar:setMaximum(selectedOffer[type]:getAmount())
|
scrollbar:setMaximum(max)
|
||||||
scrollbar:setMinimum(1)
|
scrollbar:setMinimum(1)
|
||||||
scrollbar:setValue(1)
|
scrollbar:setValue(1)
|
||||||
|
|
||||||
|
@ -482,7 +490,7 @@ local function onSelectBuyOffer(table, selectedRow, previousSelectedRow)
|
||||||
for _, offer in pairs(marketOffers[MarketAction.Buy]) do
|
for _, offer in pairs(marketOffers[MarketAction.Buy]) do
|
||||||
if offer:isEqual(selectedRow.ref) then
|
if offer:isEqual(selectedRow.ref) then
|
||||||
selectedOffer[MarketAction.Sell] = offer
|
selectedOffer[MarketAction.Sell] = offer
|
||||||
if Market.depotContains(offer:getItem():getId()) >= offer:getAmount() then
|
if Market.depotContains(offer:getItem():getId()) > 0 then
|
||||||
sellButton:setEnabled(true)
|
sellButton:setEnabled(true)
|
||||||
else
|
else
|
||||||
sellButton:setEnabled(false)
|
sellButton:setEnabled(false)
|
||||||
|
@ -729,11 +737,9 @@ function terminate()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Market.reset()
|
function Market.reset()
|
||||||
|
Market.close()
|
||||||
balanceLabel:setColor('#bbbbbb')
|
balanceLabel:setColor('#bbbbbb')
|
||||||
marketWindow:unlock()
|
|
||||||
marketWindow:hide()
|
|
||||||
categoryList:setCurrentOption(getMarketCategoryName(MarketCategory.First))
|
categoryList:setCurrentOption(getMarketCategoryName(MarketCategory.First))
|
||||||
Market.clearSelectedItem()
|
|
||||||
clearFilters()
|
clearFilters()
|
||||||
clearItems()
|
clearItems()
|
||||||
end
|
end
|
||||||
|
@ -749,6 +755,9 @@ function Market.clearSelectedItem()
|
||||||
radioItemSet:selectWidget(nil)
|
radioItemSet:selectWidget(nil)
|
||||||
nameLabel:setText('No item selected.')
|
nameLabel:setText('No item selected.')
|
||||||
selectedItem:setItem(nil)
|
selectedItem:setItem(nil)
|
||||||
|
selectedItem.item = nil
|
||||||
|
selectedItem.ref:setChecked(false)
|
||||||
|
selectedItem.ref = nil
|
||||||
|
|
||||||
detailsTable:clearData()
|
detailsTable:clearData()
|
||||||
buyStatsTable:clearData()
|
buyStatsTable:clearData()
|
||||||
|
@ -790,6 +799,16 @@ function Market.enableCreateOffer(enable)
|
||||||
nextAmountButton:setEnabled(enable)
|
nextAmountButton:setEnabled(enable)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Market.close(message)
|
||||||
|
local message = message or false
|
||||||
|
marketWindow:hide()
|
||||||
|
marketWindow:unlock()
|
||||||
|
Market.clearSelectedItem()
|
||||||
|
if message then
|
||||||
|
MarketProtocol.sendMarketLeave()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function Market.incrementAmount()
|
function Market.incrementAmount()
|
||||||
amountEdit:setValue(amountEdit:getValue() + 1)
|
amountEdit:setValue(amountEdit:getValue() + 1)
|
||||||
end
|
end
|
||||||
|
@ -850,6 +869,8 @@ function Market.refreshItemsWidget(selectItem)
|
||||||
radioItemSet:addWidget(itemBox)
|
radioItemSet:addWidget(itemBox)
|
||||||
end
|
end
|
||||||
if select then
|
if select then
|
||||||
|
selectedItem.item = select.item
|
||||||
|
selectedItem.ref = select
|
||||||
select:setChecked(true)
|
select:setChecked(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -962,7 +983,7 @@ function Market.createNewOffer()
|
||||||
MarketProtocol.sendMarketCreateOffer(type, spriteId, amount, piecePrice, anonymous)
|
MarketProtocol.sendMarketCreateOffer(type, spriteId, amount, piecePrice, anonymous)
|
||||||
if type == MarketAction.Sell then
|
if type == MarketAction.Sell then
|
||||||
--[[
|
--[[
|
||||||
This is require due to bot protected protocol (cannot update browse item without user input)
|
This is required due to bot protected protocol (cannot update browse item without user input)
|
||||||
normal way is to use the new retrieved depot items in onMarketEnter and refresh the items widget.
|
normal way is to use the new retrieved depot items in onMarketEnter and refresh the items widget.
|
||||||
]]
|
]]
|
||||||
updateDepotItemCount(spriteId, amount)
|
updateDepotItemCount(spriteId, amount)
|
||||||
|
@ -980,12 +1001,16 @@ end
|
||||||
function Market.sellMarketOffer(amount, timestamp, counter)
|
function Market.sellMarketOffer(amount, timestamp, counter)
|
||||||
if timestamp > 0 and amount > 0 then
|
if timestamp > 0 and amount > 0 then
|
||||||
MarketProtocol.sendMarketAcceptOffer(timestamp, counter, amount)
|
MarketProtocol.sendMarketAcceptOffer(timestamp, counter, amount)
|
||||||
|
|
||||||
|
local spriteId = selectedItem.item.ptr:getId()
|
||||||
|
updateDepotItemCount(spriteId, amount)
|
||||||
|
Market.refreshItemsWidget(spriteId)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Market.onItemBoxChecked(widget)
|
function Market.onItemBoxChecked(widget)
|
||||||
if widget:isChecked() then
|
if widget:isChecked() then
|
||||||
updateSelectedItem(widget.item)
|
updateSelectedItem(widget)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1020,8 +1045,7 @@ function Market.onMarketEnter(depotItems, offers, balance, vocation)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Market.onMarketLeave()
|
function Market.onMarketLeave()
|
||||||
marketWindow:unlock()
|
Market.close(false)
|
||||||
marketWindow:hide()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Market.onMarketDetail(itemId, descriptions, purchaseStats, saleStats)
|
function Market.onMarketDetail(itemId, descriptions, purchaseStats, saleStats)
|
||||||
|
|
|
@ -3,8 +3,7 @@ MarketWindow < MainWindow
|
||||||
!text: tr('Market')
|
!text: tr('Market')
|
||||||
size: 700 510
|
size: 700 510
|
||||||
|
|
||||||
@onEnter: self:hide() self:unlock() Market.clearSelectedItem() MarketProtocol.sendMarketLeave()
|
@onEscape: Market.close()
|
||||||
@onEscape: self:hide() self:unlock() Market.clearSelectedItem() MarketProtocol.sendMarketLeave()
|
|
||||||
|
|
||||||
// Main Panel Window
|
// Main Panel Window
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue