From c7ff744dcdde6295a8f988b68d2bb416350dc162 Mon Sep 17 00:00:00 2001 From: BeniS Date: Wed, 23 Jan 2013 22:23:28 +1300 Subject: [PATCH] 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) --- data/styles/20-spinboxes.otui | 1 + modules/game_npctrade/npctrade.lua | 20 ++++++++++++++++++-- modules/game_npctrade/npctrade.otui | 9 +++++---- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/data/styles/20-spinboxes.otui b/data/styles/20-spinboxes.otui index aa7f27ff..9f8c72d6 100644 --- a/data/styles/20-spinboxes.otui +++ b/data/styles/20-spinboxes.otui @@ -1,6 +1,7 @@ SpinBox < TextEdit __class: UISpinBox size: 86 20 + padding: 0 Button id: up diff --git a/modules/game_npctrade/npctrade.lua b/modules/game_npctrade/npctrade.lua index 0b7bfec2..3ba18d67 100644 --- a/modules/game_npctrade/npctrade.lua +++ b/modules/game_npctrade/npctrade.lua @@ -33,6 +33,8 @@ tradeItems = {} playerItems = nil selectedItem = nil +mouseWidget = nil + function init() npcWindow = g_ui.displayUI('npctrade') npcWindow:setVisible(false) @@ -63,6 +65,11 @@ function init() radioTabs:selectWidget(buyTab) radioTabs.onSelectionChange = onTradeTypeChange + mouseWidget = g_ui.createWidget('UIButton') + mouseWidget:setVisible(false) + mouseWidget:setFocusable(false) + mouseWidget.cancelNextRelease = false + if g_game.isOnline() then playerFreeCapacity = g_game.getLocalPlayer():getFreeCapacity() end @@ -150,11 +157,21 @@ function onSearchTextChange() end function itemPopup(self, mousePosition, mouseButton) + if mouseWidget.cancelNextRelease then + mouseWidget.cancelNextRelease = false + return false + end + if mouseButton == MouseRightButton then local menu = g_ui.createWidget('PopupMenu') menu:addOption(tr('Look'), function() return g_game.inspectNpcTrade(self:getItem()) end) menu:display(mousePosition) 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 return false end @@ -339,7 +356,7 @@ function refreshPlayerGoods() local item = itemWidget.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 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) end end - diff --git a/modules/game_npctrade/npctrade.otui b/modules/game_npctrade/npctrade.otui index 2b1623bb..2d2bf1a5 100644 --- a/modules/game_npctrade/npctrade.otui +++ b/modules/game_npctrade/npctrade.otui @@ -17,15 +17,16 @@ NPCItemBox < UICheckBox phantom: true anchors.top: parent.top anchors.horizontalCenter: parent.horizontalCenter + image-color: #ffffffff margin-top: 5 - $checked: + $checked on: border-color: #ffffff - $hover !checked: - border-color: #aaaaaa + $!checked: + border-color: #000000 - $disabled: + $!on: image-color: #ffffff88 color: #aaaaaa88