Added new market buttons: Close, Refresh Offers, and Reset Market.

* New refresh offers function.
* Fixed Market.reset function.
master
BeniS 12 years ago
parent 2bd1e0f6c4
commit c4c29be272

@ -21,4 +21,4 @@ Window < UIWindow
opacity: 0.8
MainWindow < Window
anchors.centerIn: parent
anchors.centerIn: parent

@ -5,4 +5,4 @@ function UIButton.create()
local button = UIButton.internalCreate()
button:setFocusable(false)
return button
end
end

@ -92,6 +92,8 @@ function UITable:addHeaderRow(data)
col:setHeight(value)
elseif type == 'text' then
col:setText(value)
elseif type == 'onClick' then
col.onClick = value
end
end
table.insert(columns, col)

@ -16,12 +16,9 @@
* Add offer table column ordering.
- Player Name, Amount, Total Price, Peice Price and Ends At
* Add simple close button.
* Extend information features
- 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)
]]
@ -727,6 +724,7 @@ function init()
protocol.initProtocol()
connect(g_game, { onGameEnd = Market.reset })
connect(g_game, { onGameEnd = Market.close })
marketWindow = g_ui.createWidget('MarketWindow', rootWidget)
marketWindow:hide()
@ -739,6 +737,7 @@ end
function terminate()
protocol.terminateProtocol()
disconnect(g_game, { onGameEnd = Market.reset })
disconnect(g_game, { onGameEnd = Market.close })
if marketWindow then
marketWindow:destroy()
@ -748,11 +747,10 @@ function terminate()
end
function Market.reset()
Market.close(true)
balanceLabel:setColor('#bbbbbb')
categoryList:setCurrentOption(getMarketCategoryName(MarketCategory.First))
clearFilters()
clearItems()
Market.updateCurrentItems()
end
function Market.clearSelectedItem()
@ -811,6 +809,7 @@ function Market.enableCreateOffer(enable)
end
function Market.close(notify)
if notify == nil then notify = true end
marketWindow:hide()
marketWindow:unlock()
Market.clearSelectedItem()
@ -888,10 +887,13 @@ function Market.refreshItemsWidget(selectItem)
layout:update()
end
--[[
TODO: Optimize loading market items
* Preload items to their categories
]]
function Market.refreshOffers()
if Market.isItemSelected() then
Market.onItemBoxChecked(selectedItem.ref)
end
end
function Market.loadMarketItems(category)
if table.empty(marketItems[category]) then
initMarketItems(category)
@ -1031,9 +1033,7 @@ end
function Market.acceptMarketOffer(amount, timestamp, counter)
if timestamp > 0 and amount > 0 then
MarketProtocol.sendMarketAcceptOffer(timestamp, counter, amount)
local spriteId = selectedItem.item.ptr:getId()
Market.refreshItemsWidget(spriteId)
Market.refreshOffers()
end
end

@ -1,7 +1,7 @@
MarketWindow < MainWindow
id: marketWindow
!text: tr('Market')
size: 700 510
size: 700 530
@onEscape: Market.close(true)
@ -23,6 +23,7 @@ MarketWindow < MainWindow
padding: 3
border-width: 1
border-color: #000000
margin-bottom: 20
Label
id: balanceLabel
@ -30,4 +31,31 @@ MarketWindow < MainWindow
font: verdana-11px-rounded
text-offset: 0 2
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…
Cancel
Save