From dae7a8b5ad563cbeb0e413b18f4596567e004a3a Mon Sep 17 00:00:00 2001 From: AndreFaramir Date: Mon, 9 Apr 2012 18:27:25 -0300 Subject: [PATCH] optimizations and bug fixes on npc trade --- modules/game_npctrade/npctrade.lua | 15 +++++++++------ modules/game_npctrade/npctrade.otui | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/modules/game_npctrade/npctrade.lua b/modules/game_npctrade/npctrade.lua index 947103ad..8c047a40 100644 --- a/modules/game_npctrade/npctrade.lua +++ b/modules/game_npctrade/npctrade.lua @@ -52,6 +52,7 @@ function NPCTrade.init() radioTabs:addWidget(buyTab) radioTabs:addWidget(sellTab) radioTabs:selectWidget(buyTab) + radioTabs.onSelectionChange = NPCTrade.setList connect(g_game, { onOpenNpcTrade = NPCTrade.onOpenNpcTrade, onPlayerGoods = NPCTrade.onPlayerGoods, @@ -99,9 +100,11 @@ function NPCTrade.hide() npcWindow:hide() end -function NPCTrade.setList(widget, checked) - setupButton:setText(widget:getText()) - widget:setOn(checked) +function NPCTrade.setList(radioTabs, selected, deselected) + print("PASSO SETLIST") + setupButton:setText(selected:getText()) + selected:setOn(true) + deselected:setOn(false) NPCTrade.createItemsOnPanel() NPCTrade.resetSetup() @@ -224,12 +227,12 @@ function NPCTrade.itemPopup(self, mousePosition, mouseButton) end end -function NPCTrade.createItemsOnPanel() - NPCTrade.resetSetup() - +function NPCTrade.createItemsOnPanel() local layout = itemsPanel:getLayout() layout:disableUpdates() + NPCTrade.resetSetup() + offerSelected = nil itemsPanel:destroyChildren() diff --git a/modules/game_npctrade/npctrade.otui b/modules/game_npctrade/npctrade.otui index f38d5665..f267363f 100644 --- a/modules/game_npctrade/npctrade.otui +++ b/modules/game_npctrade/npctrade.otui @@ -64,12 +64,13 @@ MainWindow id: buyTab tooltip: List of items that you're able to buy text: Buy + checked: true + on: true anchors.left: parent.left anchors.right: parent.horizontalCenter anchors.top: parent.top margin-right: 5 margin-top: 5 - @onCheckChange: NPCTrade.setList(self, self:isChecked()) TabButton id: sellTab @@ -80,7 +81,6 @@ MainWindow anchors.top: parent.top margin-left: 5 margin-top: 5 - @onCheckChange: NPCTrade.setList(self, self:isChecked()) Label id: searchLabel