From c4c29be2725426739b18776b04ade71ce10a1916 Mon Sep 17 00:00:00 2001 From: BeniS Date: Wed, 15 Aug 2012 23:56:29 +1200 Subject: [PATCH] Added new market buttons: Close, Refresh Offers, and Reset Market. * New refresh offers function. * Fixed Market.reset function. --- .../skins/default/styles/windows.otui | 2 +- modules/corelib/ui/uibutton.lua | 2 +- modules/corelib/ui/uitable.lua | 2 ++ modules/game_market/market.lua | 26 +++++++-------- modules/game_market/market.otui | 32 +++++++++++++++++-- 5 files changed, 47 insertions(+), 17 deletions(-) diff --git a/modules/client_skins/skins/default/styles/windows.otui b/modules/client_skins/skins/default/styles/windows.otui index 5ba2a60c..c68a3ef7 100644 --- a/modules/client_skins/skins/default/styles/windows.otui +++ b/modules/client_skins/skins/default/styles/windows.otui @@ -21,4 +21,4 @@ Window < UIWindow opacity: 0.8 MainWindow < Window - anchors.centerIn: parent + anchors.centerIn: parent \ No newline at end of file diff --git a/modules/corelib/ui/uibutton.lua b/modules/corelib/ui/uibutton.lua index d0529955..1b91f9df 100644 --- a/modules/corelib/ui/uibutton.lua +++ b/modules/corelib/ui/uibutton.lua @@ -5,4 +5,4 @@ function UIButton.create() local button = UIButton.internalCreate() button:setFocusable(false) return button -end +end \ No newline at end of file diff --git a/modules/corelib/ui/uitable.lua b/modules/corelib/ui/uitable.lua index 0ba3c05b..098bd091 100644 --- a/modules/corelib/ui/uitable.lua +++ b/modules/corelib/ui/uitable.lua @@ -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) diff --git a/modules/game_market/market.lua b/modules/game_market/market.lua index 54d27890..04501fbb 100644 --- a/modules/game_market/market.lua +++ b/modules/game_market/market.lua @@ -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 diff --git a/modules/game_market/market.otui b/modules/game_market/market.otui index d43a2dad..ab59b99b 100644 --- a/modules/game_market/market.otui +++ b/modules/game_market/market.otui @@ -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 \ No newline at end of file + 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() \ No newline at end of file