Compare with Previous | Blame | View Log
-------------------------------------------------------------------------- -- ChatScroll.lua -------------------------------------------------------------------------- --[[ ChatScroll author: AnduinLothar <karlkfi@yahoo.com> -ChatFrame Mouse Wheel Scroll Change List v3.5 - Updates for WoW 8.0 v3.4 - Updates for WoW 4.0.1 v3.3 - Added a Scroll Speed slider (If you're not using Portfolio manually set ChatScroll_SavedVars.ScrollSpeed to a number > 0) v3.2 - Fixed Portfolio not being optional v3.1 - More aggressive button hiding - Now uses LibDefaults for variable initialization v3.0 - Updated for WoW 3.0 - Added Portfolio Options, Removed Khaos Options v2.2 - Added "Hide Chat Frame Scroll Buttons" Option - Cleaned up the code v2.1 - Prepared for Lua 5.1 - Removed Localization usage v2.0 - No longer uses hidden frames, now uses script element hooks - No longer supports PopUI or TransUI, I recomend using VisibilityOptions to hide the buttons. - Added Shift-MouseWheelUp to to to the top of the chat window - Added Shift-MouseWheelDown to to to the bottom of the chat window - Added Scroll to Top Binding v1.1 - Fixed negative framelevel bug in new patch - Updated the TOC to 1300. v1.1 - Initial Release $Date: 2007-07-03 21:22:03 -0500 (Tue, 03 Jul 2007) $ $Rev: 5009 $ ]]-- -- <= == == == == == == == == == == == == => -- => Function Definition -- <= == == == == == == == == == == == == => ChatScroll = {}; function ChatScroll.OnMouseWheel(chatframe, value) if ( ChatScroll_SavedVars and ChatScroll_SavedVars.EnableScrolling == "1" ) then if ( IsShiftKeyDown() ) then if ( value > 0 ) then chatframe:ScrollToTop() elseif ( value < 0 ) then chatframe:ScrollToBottom(); end else if ( value > 0 ) then -- FloatingChatFrame_OnMouseScroll already called ScrollUp once for i=2, ChatScroll_SavedVars.ScrollSpeed do chatframe:ScrollUp(); end elseif ( value < 0 ) then -- FloatingChatFrame_OnMouseScroll already called ScrollDown once for i=2, ChatScroll_SavedVars.ScrollSpeed do chatframe:ScrollDown(); end end end end end function ChatScroll.ScrollToTop() SELECTED_DOCK_FRAME:ScrollToTop(); end function ChatScroll.UpdateButtons() local hidden = ChatScroll_SavedVars and ChatScroll_SavedVars.HideChatButtons == "1" if hidden then ChatFrameMenuButton:Hide() else ChatFrameMenuButton:Show() end local frameName, button for i=1, NUM_CHAT_WINDOWS do frameName = "ChatFrame"..i button = _G[frameName.."ButtonFrame"] if hidden then button:Hide() else button:Show() end end end -- <= == == == == == == == == == == == == => -- => Init Hooks -- <= == == == == == == == == == == == == => local function ScrollButton_OnShow(self) if (ChatScroll_SavedVars and ChatScroll_SavedVars.HideChatButtons == "1") then self:Hide() end end hooksecurefunc(ChatFrameMenuButton, "Show", ScrollButton_OnShow) for i=1, NUM_CHAT_WINDOWS do hooksecurefunc(_G["ChatFrame"..i.."ButtonFrame"], "Show", ScrollButton_OnShow) end hooksecurefunc("FloatingChatFrame_OnMouseScroll", ChatScroll.OnMouseWheel) -- <= == == == == == == == == == == == == => -- => Portfolio GUI Config -- <= == == == == == == == == == == == == => local savedVarTableName = "ChatScroll_SavedVars" local Portfolio = LibStub("Portfolio", true) if (Portfolio) then local optionSet = { id="ChatScroll"; text=CHATSCROLL_CONFIG_HEADER; helptext=CHATSCROLL_CONFIG_HEADER_INFO; options={ { id="EnableScrolling"; text=CHATSCROLL_CONFIG_ENABLE; tooltipText=CHATSCROLL_CONFIG_ENABLE_INFO; type=CONTROLTYPE_CHECKBOX; defaultValue = "1"; }; { id="HideChatButtons"; text=CHATSCROLL_BUTTONS_HIDE; tooltipText=CHATSCROLL_BUTTONS_HIDE_INFO; type=CONTROLTYPE_CHECKBOX; callback=ChatScroll.UpdateButtons; defaultValue = "0"; }; { id="ScrollSpeed"; text=function(value) return CHATSCROLL_SCROLL_SPEED:format(value) end; tooltipText=CHATSCROLL_SCROLL_SPEED_INFO; minValue = 1; maxValue = 10; valueStep = 1; type=CONTROLTYPE_SLIDER; defaultValue = 1; }; }; savedVarTable = savedVarTableName, }; Portfolio.RegisterOptionSet(optionSet); else local loader = LibStub("LibDefaults") local addonName = "ChatScroll" local defaults = { EnableScrolling = "1"; HideChatButtons = "0"; ScrollSpeed = 1; } loader:SetDefault(addonName, savedVarTableName, defaults) loader:SetScript(addonName, ChatScroll.UpdateButtons) end