optimizations and bug fixes on npc trade

This commit is contained in:
AndreFaramir 2012-04-09 18:27:25 -03:00
parent b4940a6b33
commit dae7a8b5ad
2 changed files with 11 additions and 8 deletions

View File

@ -52,6 +52,7 @@ function NPCTrade.init()
radioTabs:addWidget(buyTab) radioTabs:addWidget(buyTab)
radioTabs:addWidget(sellTab) radioTabs:addWidget(sellTab)
radioTabs:selectWidget(buyTab) radioTabs:selectWidget(buyTab)
radioTabs.onSelectionChange = NPCTrade.setList
connect(g_game, { onOpenNpcTrade = NPCTrade.onOpenNpcTrade, connect(g_game, { onOpenNpcTrade = NPCTrade.onOpenNpcTrade,
onPlayerGoods = NPCTrade.onPlayerGoods, onPlayerGoods = NPCTrade.onPlayerGoods,
@ -99,9 +100,11 @@ function NPCTrade.hide()
npcWindow:hide() npcWindow:hide()
end end
function NPCTrade.setList(widget, checked) function NPCTrade.setList(radioTabs, selected, deselected)
setupButton:setText(widget:getText()) print("PASSO SETLIST")
widget:setOn(checked) setupButton:setText(selected:getText())
selected:setOn(true)
deselected:setOn(false)
NPCTrade.createItemsOnPanel() NPCTrade.createItemsOnPanel()
NPCTrade.resetSetup() NPCTrade.resetSetup()
@ -224,12 +227,12 @@ function NPCTrade.itemPopup(self, mousePosition, mouseButton)
end end
end end
function NPCTrade.createItemsOnPanel() function NPCTrade.createItemsOnPanel()
NPCTrade.resetSetup()
local layout = itemsPanel:getLayout() local layout = itemsPanel:getLayout()
layout:disableUpdates() layout:disableUpdates()
NPCTrade.resetSetup()
offerSelected = nil offerSelected = nil
itemsPanel:destroyChildren() itemsPanel:destroyChildren()

View File

@ -64,12 +64,13 @@ MainWindow
id: buyTab id: buyTab
tooltip: List of items that you're able to buy tooltip: List of items that you're able to buy
text: Buy text: Buy
checked: true
on: true
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.horizontalCenter anchors.right: parent.horizontalCenter
anchors.top: parent.top anchors.top: parent.top
margin-right: 5 margin-right: 5
margin-top: 5 margin-top: 5
@onCheckChange: NPCTrade.setList(self, self:isChecked())
TabButton TabButton
id: sellTab id: sellTab
@ -80,7 +81,6 @@ MainWindow
anchors.top: parent.top anchors.top: parent.top
margin-left: 5 margin-left: 5
margin-top: 5 margin-top: 5
@onCheckChange: NPCTrade.setList(self, self:isChecked())
Label Label
id: searchLabel id: searchLabel