Fix to spin box button fit and npc trade:

* Fit spin box buttons properly
* NPC trade you can now look at items you can sell/buy
(Waiting for ed to implement a way to set item image color before its completed)
This commit is contained in:
BeniS 2013-01-23 22:23:28 +13:00
parent a2ddb472f5
commit c7ff744dcd
3 changed files with 24 additions and 6 deletions

View File

@ -1,6 +1,7 @@
SpinBox < TextEdit SpinBox < TextEdit
__class: UISpinBox __class: UISpinBox
size: 86 20 size: 86 20
padding: 0
Button Button
id: up id: up

View File

@ -33,6 +33,8 @@ tradeItems = {}
playerItems = nil playerItems = nil
selectedItem = nil selectedItem = nil
mouseWidget = nil
function init() function init()
npcWindow = g_ui.displayUI('npctrade') npcWindow = g_ui.displayUI('npctrade')
npcWindow:setVisible(false) npcWindow:setVisible(false)
@ -63,6 +65,11 @@ function init()
radioTabs:selectWidget(buyTab) radioTabs:selectWidget(buyTab)
radioTabs.onSelectionChange = onTradeTypeChange radioTabs.onSelectionChange = onTradeTypeChange
mouseWidget = g_ui.createWidget('UIButton')
mouseWidget:setVisible(false)
mouseWidget:setFocusable(false)
mouseWidget.cancelNextRelease = false
if g_game.isOnline() then if g_game.isOnline() then
playerFreeCapacity = g_game.getLocalPlayer():getFreeCapacity() playerFreeCapacity = g_game.getLocalPlayer():getFreeCapacity()
end end
@ -150,11 +157,21 @@ function onSearchTextChange()
end end
function itemPopup(self, mousePosition, mouseButton) function itemPopup(self, mousePosition, mouseButton)
if mouseWidget.cancelNextRelease then
mouseWidget.cancelNextRelease = false
return false
end
if mouseButton == MouseRightButton then if mouseButton == MouseRightButton then
local menu = g_ui.createWidget('PopupMenu') local menu = g_ui.createWidget('PopupMenu')
menu:addOption(tr('Look'), function() return g_game.inspectNpcTrade(self:getItem()) end) menu:addOption(tr('Look'), function() return g_game.inspectNpcTrade(self:getItem()) end)
menu:display(mousePosition) menu:display(mousePosition)
return true return true
elseif ((g_mouse.isPressed(MouseLeftButton) and mouseButton == MouseRightButton)
or (g_mouse.isPressed(MouseRightButton) and mouseButton == MouseLeftButton)) then
mouseWidget.cancelNextRelease = true
g_game.inspectNpcTrade(self:getItem())
return true
end end
return false return false
end end
@ -339,7 +356,7 @@ function refreshPlayerGoods()
local item = itemWidget.item local item = itemWidget.item
local canTrade = canTradeItem(item) local canTrade = canTradeItem(item)
itemWidget:setEnabled(canTrade) itemWidget:setOn(canTrade)
local searchCondition = (searchFilter == '') or (searchFilter ~= '' and string.find(item.name:lower(), searchFilter) ~= nil) local searchCondition = (searchFilter == '') or (searchFilter ~= '' and string.find(item.name:lower(), searchFilter) ~= nil)
local showAllItemsCondition = (currentTradeType == BUY) or (showAllItems:isChecked()) or (currentTradeType == SELL and not showAllItems:isChecked() and canTrade) local showAllItemsCondition = (currentTradeType == BUY) or (showAllItems:isChecked()) or (currentTradeType == SELL and not showAllItems:isChecked() and canTrade)
@ -426,4 +443,3 @@ function onInventoryChange(inventory, item, oldItem)
refreshItem(selectedItem) refreshItem(selectedItem)
end end
end end

View File

@ -17,15 +17,16 @@ NPCItemBox < UICheckBox
phantom: true phantom: true
anchors.top: parent.top anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
image-color: #ffffffff
margin-top: 5 margin-top: 5
$checked: $checked on:
border-color: #ffffff border-color: #ffffff
$hover !checked: $!checked:
border-color: #aaaaaa border-color: #000000
$disabled: $!on:
image-color: #ffffff88 image-color: #ffffff88
color: #aaaaaa88 color: #aaaaaa88