/
## Author: AnduinLothar |
## OptionalDeps: Portfolio |
## SavedVariables: ChatScroll_SavedVars |
## Version: 3.1 |
## X-Date: Oct 25 2008 |
## Version: 3.0 |
## X-Date: Oct 14 2008 |
## X-Category: Chat |
## X-Website: http://www.wowinterface.com/downloads/info5359-ChatScroll.html |
## X-Email: karlkfi@yahoo.com |
## X-Localizations: enUS, deDE, frFR |
## X-CompatibleLocales: enUS, enGB, deDE, frFR |
Loader.xml |
localization.en.lua |
localization.de.lua |
localization.fr.lua |
ChatScroll.lua |
-ChatFrame Mouse Wheel Scroll |
Change List |
v3.1 |
- More agressive button hiding |
- Better saved variable initialization |
v3.0 |
- Updated for WoW 3.0 |
- Added Portfolio Options, Removed Khaos Options |
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_SavedVars and ChatScroll_SavedVars.EnableScrolling == "1" ) then |
if ( ChatScroll.Enabled ) then |
if ( IsShiftKeyDown() ) then |
if ( value > 0 ) then |
chatframe:ScrollToTop() |
SELECTED_DOCK_FRAME:ScrollToTop(); |
end |
function ChatScroll.UpdateButtons() |
local hidden = ChatScroll_SavedVars and ChatScroll_SavedVars.HideChatButtons == "1" |
if hidden then |
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, up, down, bottom |
local frameName |
for i=1, NUM_CHAT_WINDOWS do |
frameName = "ChatFrame"..i |
up = getglobal(frameName.."UpButton") |
down = getglobal(frameName.."DownButton") |
bottom = getglobal(frameName.."BottomButton") |
if hidden then |
up:Hide() |
down:Hide() |
bottom:Hide() |
if (toggle) then |
getglobal(frameName.."UpButton"):Hide() |
getglobal(frameName.."DownButton"):Hide() |
getglobal(frameName.."BottomButton"):Hide() |
else |
up:Show() |
down:Show() |
bottom:Show() |
getglobal(frameName.."UpButton"):Show() |
getglobal(frameName.."DownButton"):Show() |
getglobal(frameName.."BottomButton"):Show() |
end |
end |
end |
function ChatScroll.SetScrollEnabled(toggle) |
ChatScroll.Enabled = toggle; |
end |
-- <= == == == == == == == == == == == == => |
-- => Init Hooks |
-- => Execution |
-- <= == == == == == == == == == == == == => |
local function ScrollButton_OnShow(self) |
if (ChatScroll_SavedVars and ChatScroll_SavedVars.HideChatButtons) then |
self:Hide() |
end |
end |
hooksecurefunc(ChatFrameMenuButton, "Show", ScrollButton_OnShow) |
-- Set up hooks |
for i=1, NUM_CHAT_WINDOWS do |
local frameName = "ChatFrame"..i |
hooksecurefunc(_G[frameName.."UpButton"], "Show", ScrollButton_OnShow) |
hooksecurefunc(_G[frameName.."DownButton"], "Show", ScrollButton_OnShow) |
hooksecurefunc(_G[frameName.."BottomButton"], "Show", ScrollButton_OnShow) |
local frame = _G[frameName]; |
local frame = getglobal("ChatFrame"..i); |
frame:EnableMouseWheel(1); |
if (type(frame:GetScript("OnMouseWheel")) == "function") then |
frame:HookScript("OnMouseWheel", ChatScroll.OnMouseWheel); |
frame:SetScript("OnMouseWheel", ChatScroll.OnMouseWheel); |
end |
end |
hooksecurefunc("FCF_UpdateButtonSide", ChatScroll.UpdateScrollButtons); |
-- <= == == == == == == == == == == == == => |
-- => Portfolio GUI Config |
-- <= == == == == == == == == == == == == => |
-- Update Button Visibility |
ChatScroll.SetScrollButtonVisibility(ChatScroll.Hide_Buttons) |
local savedVarTableName = "ChatScroll_SavedVars" |
local Portfolio = LibStub("Portfolio") |
-- Register with Portfolio |
if (Portfolio) then |
local optionSet = { |
id="ChatScroll"; |
options={ |
{ |
id="EnableScrolling"; |
text=CHATSCROLL_CONFIG_ENABLE; |
tooltipText=CHATSCROLL_CONFIG_ENABLE_INFO; |
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=ChatScroll.UpdateButtons; |
callback=function(value) ChatScroll.SetScrollButtonVisibility(value=="1") end; |
defaultValue = "0"; |
}; |
}; |
savedVarTable = savedVarTableName, |
savedVarTable = "ChatScroll_SavedVars", |
loadVars = true, |
}; |
Portfolio.RegisterOptionSet(optionSet); |
else |
local loader = LibStub("LibDefaults") |
local addonName = "ChatScroll" |
loader:SetDefault(addonName, savedVarTableName, "EnableScrolling", "1") |
loader:SetDefault(addonName, savedVarTableName, "HideChatButtons", "0") |
loader:SetScript(addonName, ChatScroll.UpdateButtons) |
end |