Added new market buttons: Close, Refresh Offers, and Reset Market.
* New refresh offers function. * Fixed Market.reset function.
This commit is contained in:
parent
2bd1e0f6c4
commit
c4c29be272
|
@ -92,6 +92,8 @@ function UITable:addHeaderRow(data)
|
||||||
col:setHeight(value)
|
col:setHeight(value)
|
||||||
elseif type == 'text' then
|
elseif type == 'text' then
|
||||||
col:setText(value)
|
col:setText(value)
|
||||||
|
elseif type == 'onClick' then
|
||||||
|
col.onClick = value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.insert(columns, col)
|
table.insert(columns, col)
|
||||||
|
|
|
@ -16,12 +16,9 @@
|
||||||
* Add offer table column ordering.
|
* Add offer table column ordering.
|
||||||
- Player Name, Amount, Total Price, Peice Price and Ends At
|
- Player Name, Amount, Total Price, Peice Price and Ends At
|
||||||
|
|
||||||
* Add simple close button.
|
|
||||||
|
|
||||||
* Extend information features
|
* Extend information features
|
||||||
- Hover over offers for purchase information (balance after transaction, etc)
|
- Hover over offers for purchase information (balance after transaction, etc)
|
||||||
|
- Display out of trend market offers based on their previous statistics (like cipsoft does)
|
||||||
* Display out of trend market offers based on their previous statistics (like cipsoft does)
|
|
||||||
|
|
||||||
* Make compatible with cipsoft 9.61 (has the protocol changed? creating offer not working)
|
* Make compatible with cipsoft 9.61 (has the protocol changed? creating offer not working)
|
||||||
]]
|
]]
|
||||||
|
@ -727,6 +724,7 @@ function init()
|
||||||
|
|
||||||
protocol.initProtocol()
|
protocol.initProtocol()
|
||||||
connect(g_game, { onGameEnd = Market.reset })
|
connect(g_game, { onGameEnd = Market.reset })
|
||||||
|
connect(g_game, { onGameEnd = Market.close })
|
||||||
marketWindow = g_ui.createWidget('MarketWindow', rootWidget)
|
marketWindow = g_ui.createWidget('MarketWindow', rootWidget)
|
||||||
marketWindow:hide()
|
marketWindow:hide()
|
||||||
|
|
||||||
|
@ -739,6 +737,7 @@ end
|
||||||
function terminate()
|
function terminate()
|
||||||
protocol.terminateProtocol()
|
protocol.terminateProtocol()
|
||||||
disconnect(g_game, { onGameEnd = Market.reset })
|
disconnect(g_game, { onGameEnd = Market.reset })
|
||||||
|
disconnect(g_game, { onGameEnd = Market.close })
|
||||||
|
|
||||||
if marketWindow then
|
if marketWindow then
|
||||||
marketWindow:destroy()
|
marketWindow:destroy()
|
||||||
|
@ -748,11 +747,10 @@ function terminate()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Market.reset()
|
function Market.reset()
|
||||||
Market.close(true)
|
|
||||||
balanceLabel:setColor('#bbbbbb')
|
balanceLabel:setColor('#bbbbbb')
|
||||||
categoryList:setCurrentOption(getMarketCategoryName(MarketCategory.First))
|
categoryList:setCurrentOption(getMarketCategoryName(MarketCategory.First))
|
||||||
clearFilters()
|
clearFilters()
|
||||||
clearItems()
|
Market.updateCurrentItems()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Market.clearSelectedItem()
|
function Market.clearSelectedItem()
|
||||||
|
@ -811,6 +809,7 @@ function Market.enableCreateOffer(enable)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Market.close(notify)
|
function Market.close(notify)
|
||||||
|
if notify == nil then notify = true end
|
||||||
marketWindow:hide()
|
marketWindow:hide()
|
||||||
marketWindow:unlock()
|
marketWindow:unlock()
|
||||||
Market.clearSelectedItem()
|
Market.clearSelectedItem()
|
||||||
|
@ -888,10 +887,13 @@ function Market.refreshItemsWidget(selectItem)
|
||||||
layout:update()
|
layout:update()
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
function Market.refreshOffers()
|
||||||
TODO: Optimize loading market items
|
if Market.isItemSelected() then
|
||||||
* Preload items to their categories
|
Market.onItemBoxChecked(selectedItem.ref)
|
||||||
]]
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function Market.loadMarketItems(category)
|
function Market.loadMarketItems(category)
|
||||||
if table.empty(marketItems[category]) then
|
if table.empty(marketItems[category]) then
|
||||||
initMarketItems(category)
|
initMarketItems(category)
|
||||||
|
@ -1031,9 +1033,7 @@ end
|
||||||
function Market.acceptMarketOffer(amount, timestamp, counter)
|
function Market.acceptMarketOffer(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)
|
||||||
|
Market.refreshOffers()
|
||||||
local spriteId = selectedItem.item.ptr:getId()
|
|
||||||
Market.refreshItemsWidget(spriteId)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
MarketWindow < MainWindow
|
MarketWindow < MainWindow
|
||||||
id: marketWindow
|
id: marketWindow
|
||||||
!text: tr('Market')
|
!text: tr('Market')
|
||||||
size: 700 510
|
size: 700 530
|
||||||
|
|
||||||
@onEscape: Market.close(true)
|
@onEscape: Market.close(true)
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ MarketWindow < MainWindow
|
||||||
padding: 3
|
padding: 3
|
||||||
border-width: 1
|
border-width: 1
|
||||||
border-color: #000000
|
border-color: #000000
|
||||||
|
margin-bottom: 20
|
||||||
|
|
||||||
Label
|
Label
|
||||||
id: balanceLabel
|
id: balanceLabel
|
||||||
|
@ -31,3 +32,30 @@ MarketWindow < MainWindow
|
||||||
text-offset: 0 2
|
text-offset: 0 2
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
||||||
|
Button
|
||||||
|
id: closeButton
|
||||||
|
!text: tr('Close')
|
||||||
|
anchors.top: mainTabContent.bottom
|
||||||
|
anchors.horizontalCenter: mainTabContent.horizontalCenter
|
||||||
|
margin-top: 5
|
||||||
|
width: 110
|
||||||
|
@onClick: Market.close()
|
||||||
|
|
||||||
|
Button
|
||||||
|
id: refreshOffersButton
|
||||||
|
!text: tr('Refresh Offers')
|
||||||
|
anchors.top: mainTabContent.bottom
|
||||||
|
anchors.right: mainTabContent.right
|
||||||
|
margin-top: 5
|
||||||
|
width: 110
|
||||||
|
@onClick: Market.refreshOffers()
|
||||||
|
|
||||||
|
Button
|
||||||
|
id: resetButton
|
||||||
|
!text: tr('Reset Market')
|
||||||
|
anchors.top: mainTabContent.bottom
|
||||||
|
anchors.left: mainTabContent.left
|
||||||
|
margin-top: 5
|
||||||
|
width: 110
|
||||||
|
@onClick: Market.reset()
|
Loading…
Reference in New Issue