-------------------------------------------------------------------------- |
-- ChatScroll.lua |
-------------------------------------------------------------------------- |
--[[ |
ChatScroll |
|
author: AnduinLothar <karlkfi@cosmosui.org> |
|
-ChatFrame Mouse Wheel Scroll |
|
Change List |
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 = {}; |
|
-- For manually changing settings use these two variables (these will not override Khaos settings) |
ChatScroll.Enabled = true; |
ChatScroll.Hide_Buttons = false; |
|
function ChatScroll.OnMouseWheel(chatframe, value) |
if ( ChatScroll.Enabled ) then |
if ( IsShiftKeyDown() ) then |
if ( value > 0 ) then |
chatframe:ScrollToTop() |
elseif ( value < 0 ) then |
chatframe:ScrollToBottom(); |
end |
else |
if ( value > 0 ) then |
chatframe:ScrollUp(); |
elseif ( value < 0 ) then |
chatframe:ScrollDown(); |
end |
end |
else |
if ( value > 0 ) then |
ActionBar_PageUp(); |
elseif ( value < 0 ) then |
ActionBar_PageDown(); |
end |
end |
end |
|
function ChatScroll.ScrollToTop() |
SELECTED_DOCK_FRAME:ScrollToTop(); |
end |
|
function ChatScroll.UpdateScrollButtons() |
ChatScroll.SetScrollButtonVisibility(ChatScroll.Hide_Buttons) |
end |
|
function ChatScroll.SetScrollButtonVisibility(toggle) |
if (toggle) then |
ChatScroll.Hide_Buttons = true; |
ChatFrameMenuButton:Hide() |
else |
ChatScroll.Hide_Buttons = false; |
ChatFrameMenuButton:Show() |
end |
|
local frameName |
for i=1, NUM_CHAT_WINDOWS do |
frameName = "ChatFrame"..i |
if (toggle) then |
getglobal(frameName.."UpButton"):Hide() |
getglobal(frameName.."DownButton"):Hide() |
getglobal(frameName.."BottomButton"):Hide() |
else |
getglobal(frameName.."UpButton"):Show() |
getglobal(frameName.."DownButton"):Show() |
getglobal(frameName.."BottomButton"):Show() |
end |
end |
end |
|
function ChatScroll.SetScrollEnabled(toggle) |
ChatScroll.Enabled = toggle; |
end |
|
-- <= == == == == == == == == == == == == => |
-- => Execution |
-- <= == == == == == == == == == == == == => |
|
-- Set up hooks |
for i=1, NUM_CHAT_WINDOWS do |
local frame = getglobal("ChatFrame"..i); |
frame:EnableMouseWheel(1); |
if (type(frame:GetScript("OnMouseWheel")) == "function") then |
frame:HookScript("OnMouseWheel", ChatScroll.OnMouseWheel); |
else |
frame:SetScript("OnMouseWheel", ChatScroll.OnMouseWheel); |
end |
end |
hooksecurefunc("FCF_UpdateButtonSide", ChatScroll.UpdateScrollButtons); |
|
-- Update Button Visibility |
ChatScroll.SetScrollButtonVisibility(ChatScroll.Hide_Buttons) |
|
-- Register with Portfolio |
if (Portfolio) then |
local optionSet = { |
id="ChatScroll"; |
text=CHATSCROLL_CONFIG_HEADER; |
helptext=CHATSCROLL_CONFIG_HEADER_INFO; |
options={ |
{ |
id="EnableScrolling"; |
tvar="Enabled"; |
text= CHATSCROLL_CONFIG_ENABLE; |
tooltipText= CHATSCROLL_CONFIG_ENABLE_INFO; |
type=CONTROLTYPE_CHECKBOX; |
callback=function(value) ChatScroll.SetScrollEnabled(value=="1") end; |
defaultValue = "1"; |
}; |
{ |
id="HideChatButtons"; |
tvar="Hide_Buttons"; |
text=CHATSCROLL_BUTTONS_HIDE; |
tooltipText=CHATSCROLL_BUTTONS_HIDE_INFO; |
type=CONTROLTYPE_CHECKBOX; |
callback=function(value) ChatScroll.SetScrollButtonVisibility(value=="1") end; |
defaultValue = "0"; |
}; |
}; |
savedVarTable = "ChatScroll_SavedVars", |
loadVars = true, |
}; |
Portfolio.RegisterOptionSet(optionSet); |
end |