From 1b6be92cad3f541e6121f57b1d2dffe0bd0c2fb1 Mon Sep 17 00:00:00 2001 From: BeniS Date: Fri, 11 Jan 2013 20:10:37 +1300 Subject: [PATCH] Minor fix to previous commit and added mouse scroll option to UIScrollBar class. --- modules/corelib/ui/uiscrollbar.lua | 13 ++++++++++++- modules/game_console/console.lua | 14 ++++++++++---- modules/game_hotkeys/hotkeys_manager.lua | 2 +- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/modules/corelib/ui/uiscrollbar.lua b/modules/corelib/ui/uiscrollbar.lua index 42a29fe4..73007029 100644 --- a/modules/corelib/ui/uiscrollbar.lua +++ b/modules/corelib/ui/uiscrollbar.lua @@ -108,6 +108,7 @@ function UIScrollBar.create() scrollbar.pixelsScroll = false scrollbar.showValue = false scrollbar.symbol = nil + scrollbar.mouseScroll = true return scrollbar end @@ -139,6 +140,8 @@ function UIScrollBar:onStyleApply(styleName, styleNode) self.showValue = true elseif name == 'symbol' then self.symbol = value + elseif name == 'mouse-scroll' then + self.mouseScroll = value end end end @@ -189,6 +192,10 @@ function UIScrollBar:setValue(value) end end +function UIScrollBar:setMouseScroll(scroll) + self.mouseScroll = scroll +end + function UIScrollBar:setStep(step) self.step = step end @@ -202,6 +209,9 @@ function UIScrollBar:onGeometryChange() end function UIScrollBar:onMouseWheel(mousePos, mouseWheel) + if not self.mouseScroll then + return false + end if mouseWheel == MouseWheelDown then if self.orientation == 'vertical' then self:decrement() @@ -224,4 +234,5 @@ function UIScrollBar:getValue() return math.round(self.value) end function UIScrollBar:getStep() return self.step end function UIScrollBar:getOrientation() return self.orientation end function UIScrollBar:getShowValue() return self.showValue end -function UIScrollBar:getSymbol() return self.symbol end \ No newline at end of file +function UIScrollBar:getSymbol() return self.symbol end +function UIScrollBar:getMouseScroll() return self.mouseScroll end \ No newline at end of file diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index c1872842..104df65b 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -359,10 +359,10 @@ function addTabText(text, speaktype, tab, creatureName) -- Overlay for consoleBuffer which shows highlighted words only local consoleBufferHighlight = panel:getChildById('consoleBufferHighlight') local labelHighlight = g_ui.createWidget('ConsoleLabel', consoleBufferHighlight) + labelHighlight:setId('consoleLabel' .. panel:getChildCount()) labelHighlight:setColor("#1f9ffe") - local player = g_game.getLocalPlayer() if speaktype.npcChat and (player:getName() ~= creatureName or player:getName() == 'Account Manager') then -- Check if it is the npc who is talking local highlightData = getHighlightedText(text) @@ -411,7 +411,9 @@ function addTabText(text, speaktype, tab, creatureName) labelHighlight:setText("") end - label.onMouseRelease = function (self, mousePos, mouseButton) processMessageMenu(mousePos, mouseButton, creatureName, text) end + label.onMouseRelease = function (self, mousePos, mouseButton) + processMessageMenu(mousePos, mouseButton, creatureName, text) + end if consoleBuffer:getChildCount() > MAX_LINES then consoleBuffer:getFirstChild():destroy() @@ -476,8 +478,12 @@ function sendCurrentMessage() if #message == 0 then return end consoleTextEdit:clearText() - -- get current channel - local tab = getCurrentTab() + -- send message + sendMessage(message) +end + +function sendMessage(message, tab) + local tab = tab or getCurrentTab() -- handling chat commands local originalMessage = message diff --git a/modules/game_hotkeys/hotkeys_manager.lua b/modules/game_hotkeys/hotkeys_manager.lua index 6d282131..bd1046fd 100644 --- a/modules/game_hotkeys/hotkeys_manager.lua +++ b/modules/game_hotkeys/hotkeys_manager.lua @@ -85,7 +85,7 @@ end function load() local hotkeySettings = g_settings.getNode('HotkeysManager') or {} - if hotkeySettings then + if hotkeySettings ~= nil then local playerHotkeySettings = hotkeySettings[g_game.getLocalPlayer():getName()] local hasCombos = false