From cb42481edd2a566247afdb7d34d1b9ebd12fb13f Mon Sep 17 00:00:00 2001 From: BeniS Date: Wed, 13 Feb 2013 05:14:16 +1300 Subject: [PATCH] Market fix, and a few other things: * Added 'button' param to g_mouse.bindPress * Added 'lower' param to table.contains * UIComboBox:onOptionChange should signalcall? * Changed the experience bar color * Market buy/sell 'amount' window will now show the cost of the amount you are selecting --- modules/client_options/options.lua | 1 + modules/corelib/mouse.lua | 9 ++-- modules/corelib/table.lua | 4 +- modules/corelib/ui/uicombobox.lua | 10 ++-- modules/game_cooldown/cooldown.otui | 4 +- modules/game_healthinfo/healthinfo.otui | 4 +- modules/game_market/market.lua | 26 +++++---- .../game_market/ui/general/amountwindow.otui | 54 ++++++++++--------- modules/game_market/ui/marketoffers.otui | 2 +- .../game_market/ui/marketoffers/browse.otui | 3 +- 10 files changed, 65 insertions(+), 52 deletions(-) diff --git a/modules/client_options/options.lua b/modules/client_options/options.lua index 5b724ee2..ab3a0545 100644 --- a/modules/client_options/options.lua +++ b/modules/client_options/options.lua @@ -200,6 +200,7 @@ function setOption(key, value) audioButton:setIcon('/images/topbuttons/audio_mute') end end) + panel = audioPanel elseif key == 'enableMusicSound' then g_sounds.getChannel(SoundChannels.Music):setEnabled(value) elseif key == 'musicSoundVolume' then diff --git a/modules/corelib/mouse.lua b/modules/corelib/mouse.lua index 3aa33f55..d46314e6 100644 --- a/modules/corelib/mouse.lua +++ b/modules/corelib/mouse.lua @@ -25,9 +25,12 @@ function g_mouse.bindPressMove(widget, callback) end }) end -function g_mouse.bindPress(widget, callback) +function g_mouse.bindPress(widget, callback, button) connect(widget, { onMousePress = function(widget, mousePos, mouseButton) - callback(mousePos, mouseButton) - return true + if not button or button == mouseButton then + callback(mousePos, mouseButton) + return true + end + return false end }) end diff --git a/modules/corelib/table.lua b/modules/corelib/table.lua index 0b6af889..8c7babc7 100644 --- a/modules/corelib/table.lua +++ b/modules/corelib/table.lua @@ -65,8 +65,8 @@ function table.findbykey(t, key, lowercase) end end -function table.contains(t, value) - return table.find(t, value) ~= nil +function table.contains(t, value, lowercase) + return table.find(t, value, lowercase) ~= nil end function table.findkey(t, key) diff --git a/modules/corelib/ui/uicombobox.lua b/modules/corelib/ui/uicombobox.lua index 8198b967..e08eaaea 100644 --- a/modules/corelib/ui/uicombobox.lua +++ b/modules/corelib/ui/uicombobox.lua @@ -31,7 +31,7 @@ function UIComboBox:setCurrentOption(text) if v.text == text and self.currentIndex ~= i then self.currentIndex = i self:setText(text) - self:onOptionChange(text, v.data) + signalcall(self.onOptionChange, self, text, v.data) return end end @@ -43,7 +43,7 @@ function UIComboBox:setCurrentOptionByData(data) if v.data == data and self.currentIndex ~= i then self.currentIndex = i self:setText(v.text) - self:onOptionChange(v.text, v.data) + signalcall(self.onOptionChange, self, v.text, v.data) return end end @@ -54,7 +54,7 @@ function UIComboBox:setCurrentIndex(index) local v = self.options[index] self.currentIndex = index self:setText(v.text) - self:onOptionChange(v.text, v.data) + signalcall(self.onOptionChange, self, v.text, v.data) end end @@ -140,7 +140,3 @@ end function UIComboBox:canMouseScroll() return self.mouseScroll end - -function UIComboBox:onOptionChange(optionText, optionData) - -- nothing todo -end diff --git a/modules/game_cooldown/cooldown.otui b/modules/game_cooldown/cooldown.otui index 80cae0c6..56e0d6a9 100644 --- a/modules/game_cooldown/cooldown.otui +++ b/modules/game_cooldown/cooldown.otui @@ -96,8 +96,6 @@ MiniWindow anchors.top: groupIconSpecial.bottom anchors.left: parent.left anchors.right: parent.right - //border-width: 1 - //border-color: #00000077 background-color: #ffffff11 - \ No newline at end of file + diff --git a/modules/game_healthinfo/healthinfo.otui b/modules/game_healthinfo/healthinfo.otui index 550ea3f1..81948319 100644 --- a/modules/game_healthinfo/healthinfo.otui +++ b/modules/game_healthinfo/healthinfo.otui @@ -15,11 +15,13 @@ ManaBar < ProgressBar ExperienceBar < ProgressBar id: experienceBar - background-color: yellow + background-color: #B6E866 anchors.top: prev.bottom anchors.left: parent.left anchors.right: parent.right margin-top: 3 + //margin-top: 6 + //height: 12 SoulLabel < GameLabel id: soulLabel diff --git a/modules/game_market/market.lua b/modules/game_market/market.lua index f76be950..bd9fca05 100644 --- a/modules/game_market/market.lua +++ b/modules/game_market/market.lua @@ -408,34 +408,40 @@ local function openAmountWindow(callback, type, actionText) end amountWindow = g_ui.createWidget('AmountWindow', rootWidget) amountWindow:lock() - local max = selectedOffer[type]:getAmount() + local item = selectedOffer[type]:getItem() + + local max = selectedOffer[type]:getAmount(item:getId()) if type == MarketAction.Sell then - local depot = Market.depotContains(selectedOffer[type]:getItem():getId()) + local depot = Market.depotContains() if max > depot then max = depot end end - local spinbox = amountWindow:getChildById('amountSpinBox') - spinbox:setMaximum(max) - spinbox:setMinimum(1) - spinbox:setValue(1) + local itembox = amountWindow:getChildById('item') + itembox:setItemId(item:getId()) + itembox:setText(1) local scrollbar = amountWindow:getChildById('amountScrollBar') + scrollbar:setText(tostring(selectedOffer[type]:getPrice())..'gp') scrollbar:setMaximum(max) scrollbar:setMinimum(1) scrollbar:setValue(1) - scrollbar.onValueChange = function(self, value) spinbox:setValue(value) end - spinbox.onValueChange = function(self, value) scrollbar:setValue(value) end + scrollbar.onValueChange = function(widget, value) + widget:setText(tostring(value*selectedOffer[type]:getPrice())..'gp') + itembox:setText(tostring(value)) + end local okButton = amountWindow:getChildById('buttonOk') - if actionText ~= '' then okButton:setText(actionText) end + if actionText ~= '' then + okButton:setText(actionText) + end local okFunc = function() local counter = selectedOffer[type]:getCounter() local timestamp = selectedOffer[type]:getTimeStamp() - callback(spinbox:getValue(), timestamp, counter) + callback(scrollbar:getValue(), timestamp, counter) okButton:getParent():destroy() amountWindow = nil end diff --git a/modules/game_market/ui/general/amountwindow.otui b/modules/game_market/ui/general/amountwindow.otui index 69289882..b526696f 100644 --- a/modules/game_market/ui/general/amountwindow.otui +++ b/modules/game_market/ui/general/amountwindow.otui @@ -1,39 +1,45 @@ AmountWindow < MainWindow id: amountWindow !text: tr('Amount') - size: 196 112 + size: 196 80 - Label - !text: tr('Amount:') - width: 64 + Item + id: item + text-offset: 0 22 + text-align: right anchors.left: parent.left anchors.top: parent.top margin-top: 2 - - SpinBox - id: amountSpinBox - anchors.left: prev.right - anchors.right: parent.right - anchors.top: parent.top + margin-left: -4 + focusable: false + virtual: true HorizontalScrollBar id: amountScrollBar - anchors.left: parent.left + anchors.left: prev.right anchors.right: parent.right - anchors.top: prev.bottom - margin-top: 8 - - Button - id: buttonOk - !text: tr('Ok') - width: 64 - anchors.right: next.left - anchors.bottom: parent.bottom - margin-right: 5 + anchors.top: prev.top + margin-left: 10 + margin-top: -2 + focusable: false Button id: buttonCancel !text: tr('Cancel') - width: 64 - anchors.right: parent.right - anchors.bottom: parent.bottom + height: 20 + anchors.left: amountScrollBar.horizontalCenter + anchors.right: amountScrollBar.right + anchors.top: amountScrollBar.bottom + margin-top: 7 + focusable: false + + Button + id: buttonOk + !text: tr('Ok') + height: 20 + anchors.right: amountScrollBar.horizontalCenter + anchors.left: amountScrollBar.left + anchors.top: amountScrollBar.bottom + margin-top: 7 + margin-right: 6 + focusable: false diff --git a/modules/game_market/ui/marketoffers.otui b/modules/game_market/ui/marketoffers.otui index b69411ee..bd927469 100644 --- a/modules/game_market/ui/marketoffers.otui +++ b/modules/game_market/ui/marketoffers.otui @@ -176,7 +176,7 @@ Panel margin-bottom: 6 @onSetup: self:setChecked(false) height: 16 - width: 70 + width: 90 Label id: feeLabel diff --git a/modules/game_market/ui/marketoffers/browse.otui b/modules/game_market/ui/marketoffers/browse.otui index c245c79a..41565c2d 100644 --- a/modules/game_market/ui/marketoffers/browse.otui +++ b/modules/game_market/ui/marketoffers/browse.otui @@ -8,7 +8,8 @@ MarketItemBox < UICheckBox Item id: item phantom: true - text-offset: 0 13 + virtual: true + text-offset: 0 22 text-align: right anchors.top: parent.top anchors.horizontalCenter: parent.horizontalCenter