Created
January 18, 2014 17:19
-
-
Save anonymous/8493437 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
Bits and pieces I've gathered from several other addons | |
I don't pretend to have made anything in here from scratch | |
Most stuff is blatantly stolen, notably from wChat and rChat | |
--]] | |
--[[ | |
Channel name config | |
Don't add a space after letters/separator | |
Start separator with a space | |
Separator list | |
• | |
» | |
/ | |
. | |
--]] | |
-- Separator, what separates channel name and player name | |
local chSeparator = ' »' | |
-- Guild | |
local chGuild = 'g' | |
local chOfficer = 'o' | |
-- Raid | |
local chRaid = 'r' | |
local chRaidWarning = 'rw' | |
local chRaidLeader = 'R' | |
-- Party | |
local chParty = 'p' | |
local chPartyLeader = 'P' | |
local chPartyGuide = 'P' | |
-- Instance | |
local chInstance = 'i' | |
local chInstanceLeader = 'I' | |
-- Whisper | |
local chWhisperTo = 't' | |
local chWhisperFrom = 'f' | |
--[[ | |
Font settings | |
--]] | |
local font = 'Interface\\AddOns\\!opEngine\\media\\chatFont.otf' | |
local size = 12 | |
local style = 'OUTLINE' | |
--[[ | |
DONT TOUCH | |
--]] | |
local gsub = _G.string.gsub | |
--[[ | |
Small tweaks | |
--]] | |
-- Removes the dumb fading on the chat | |
for i=1,10 do | |
_G['ChatFrame'..i]:SetFading(false) | |
end | |
-- Move chat tabs | |
hooksecurefunc("FCF_SetTabPosition", function(chatFrame, x) | |
local chatTab = _G[chatFrame:GetName().."Tab"]; | |
chatTab:ClearAllPoints(); | |
chatTab:SetPoint("TOPLEFT", chatFrame:GetName().."Background", "BOTTOMLEFT", 0, -2) | |
end) | |
GENERAL_CHAT_DOCK:ClearAllPoints() | |
GENERAL_CHAT_DOCK:SetPoint("TOPLEFT", ChatFrame1, "BOTTOMLEFT", 0, -2) | |
GENERAL_CHAT_DOCK:SetWidth(ChatFrame1:GetWidth()) | |
-- Makes notifications stay on screen no matter what | |
BNToastFrame:SetClampedToScreen(true) | |
-- Stops tabs from flashing on new messages | |
FCF_FlashTab = function() end | |
FCFTab_UpdateAlpha = function() end | |
-- New Fade-In function | |
FCF_FadeInChatFrame = function(self) | |
self.hasBeenFaded = true | |
end--]] | |
-- New Fade-Out function | |
FCF_FadeOutChatFrame = function(self) | |
self.hasBeenFaded = false | |
end--]] | |
-- Style chat tabs | |
FCFTab_UpdateColors = function(self, selected) | |
if (selected) then | |
self:SetAlpha(0) | |
self.leftSelectedTexture:Show() | |
self.middleSelectedTexture:Show() | |
self.rightSelectedTexture:Show() | |
else | |
self:SetAlpha(0) | |
self.leftSelectedTexture:Hide() | |
self.middleSelectedTexture:Hide() | |
self.rightSelectedTexture:Hide() | |
end | |
end | |
for i = 1, NUM_CHAT_WINDOWS do | |
local color = CUSTOM_CLASS_COLORS[select(2, UnitClass('PLAYER'))] or RAID_CLASS_COLORS[select(2, UnitClass('PLAYER'))] | |
local name = _G["ChatFrame"..i]:GetName() | |
local tab = _G[name.."Tab"] | |
local tabFs = tab:GetFontString() | |
tabFs:SetFont(font, size, style) | |
tabFs:SetShadowOffset(0, 0) | |
tabFs:SetShadowColor(0,0,0,0) | |
tabFs:SetTextColor(color.r, color.g, color.b) | |
tab:SetScript('OnEnter', function(self) | |
UIFrameFadeIn(self, 0.3, 0, 0.7) | |
end) | |
tab:SetScript('OnLeave', function(self) | |
UIFrameFadeOut(self, 0.3, 0.7, 0) | |
end) | |
_G[name.."TabLeft"]:SetTexture(nil) | |
_G[name.."TabMiddle"]:SetTexture(nil) | |
_G[name.."TabRight"]:SetTexture(nil) | |
_G[name.."TabSelectedLeft"]:SetTexture(nil) | |
_G[name.."TabSelectedMiddle"]:SetTexture(nil) | |
_G[name.."TabSelectedRight"]:SetTexture(nil) | |
--_G[name.."TabGlow"]:SetTexture(nil) --do not hide this texture, it will glow when a whisper hits a hidden chat | |
--_G[name.."TabHighlightLeft"]:SetTexture(nil) | |
--_G[name.."TabHighlightMiddle"]:SetTexture(nil) | |
--_G[name.."TabHighlightRight"]:SetTexture(nil) | |
end | |
-- We want to use classic | |
-- "classic", The chat entry box will work as it previously did. There will be a single entry box always attached to the primary Chat Frame. | |
-- "im", When clicking the tab of a Chat Frame, the entry box will attach to it. Each window's entry box will maintain its own saved state and history. | |
SetCVar("chatStyle", "classic") | |
-- Dont touch | |
local function Hide(f) | |
f:SetScript('OnShow', f.Hide) | |
f:Hide() | |
end | |
local hideFunc = function(frame) frame:Hide() end | |
for i = 1, 10 do | |
-- We'll need these later | |
local eb = _G[format("%s%d%s", "ChatFrame", i, "EditBox")] | |
local cfs = _G[format("%s%d", "ChatFrame", i)] | |
local ab = _G[format("%s%d%s", "ChatFrame", i, "ButtonFrame")] | |
-- Moves the editbox to the top of the chat | |
eb:ClearAllPoints() | |
eb:SetPoint("CENTER", UIParent, "CENTER", 0, -250) | |
eb:SetBackdrop({ | |
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", | |
insets = { | |
left = -1, | |
right = -1, | |
top = -1, | |
bottom = -1, | |
}, | |
}) | |
eb:SetBackdropColor(0,0,0,0.8) | |
eb:SetWidth(400) | |
eb:SetHeight(24) | |
-- Enables arrow keys in the editbox | |
eb:SetAltArrowKeyMode(false) | |
-- Removes resizing limits | |
cfs:SetMinResize(100,10) | |
cfs:SetMaxResize(0,0) | |
-- Allow the chat frame to move to the end of the screen | |
cfs:SetClampRectInsets(0,0,0,0) | |
-- We dont want lowercase in the editbox | |
eb:SetFont('Interface\\AddOns\\!opEngine\\media\\chatFont.otf', size, style) | |
-- Hide buttons cause we hate them and they're ugly | |
ab:SetScript("OnShow", hideFunc) | |
ab:Hide() | |
ChatFrameMenuButton:SetScript("OnShow", hideFunc) | |
ChatFrameMenuButton:Hide() | |
FriendsMicroButton:SetScript("OnShow", hideFunc) | |
FriendsMicroButton:Hide() | |
end | |
-- Enables shift scrolling | |
FloatingChatFrame_OnMouseScroll = function(self, dir) | |
if(dir > 0) then | |
if(IsShiftKeyDown()) then | |
self:ScrollToTop() | |
else | |
self:ScrollUp() | |
end | |
else | |
if(IsShiftKeyDown()) then | |
self:ScrollToBottom() | |
else | |
self:ScrollDown() | |
end | |
end | |
end | |
--[[ | |
Sticky channels | |
0 = Disabled | |
1 = Enabled | |
--]] | |
ChatTypeInfo.SAY.sticky = 1 | |
ChatTypeInfo.PARTY.sticky = 1 | |
ChatTypeInfo.RAID.sticky = 1 | |
ChatTypeInfo.GUILD.sticky = 1 | |
ChatTypeInfo.OFFICER.sticky = 1 | |
ChatTypeInfo.YELL.sticky = 1 | |
ChatTypeInfo.WHISPER.sticky = 1 | |
ChatTypeInfo.EMOTE.sticky = 1 | |
ChatTypeInfo.RAID_WARNING.sticky = 1 | |
ChatTypeInfo.INSTANCE_CHAT.sticky = 1 | |
ChatTypeInfo.BN_WHISPER.sticky = 1 | |
--[[ | |
Apply font settings | |
--]] | |
for i = 1, 10 do | |
local cf = _G[format("%s%d", "ChatFrame", i)] | |
cf:SetFont(font, size, style) | |
cf:SetShadowOffset(0,0) | |
cf:SetShadowColor(0,0,0,0) | |
end | |
--[[ | |
Restyle editbox | |
--]] | |
for i = 1, NUM_CHAT_WINDOWS do | |
local editBoxleft = _G[format("%s%d%s", "ChatFrame", i, "EditBoxLeft")] | |
local editBoxright = _G[format("%s%d%s", "ChatFrame", i, "EditBoxRight")] | |
local editBoxmid = _G[format("%s%d%s", "ChatFrame", i, "EditBoxMid")] | |
editBoxleft:SetAlpha(0) | |
editBoxright:SetAlpha(0) | |
editBoxmid:SetAlpha(0) | |
end | |
--[[ | |
Channel name replacements | |
--]] | |
CHAT_GUILD_GET = "|Hchannel:GUILD|h"..chGuild..chSeparator.."|h %s: " | |
CHAT_OFFICER_GET = "|Hchannel:OFFICER|h"..chOfficer..chSeparator.."|h %s: " | |
CHAT_RAID_GET = "|Hchannel:RAID|h"..chRaid..chSeparator.."|h %s: " | |
CHAT_RAID_WARNING_GET = chRaidWarning..chSeparator.." %s: " | |
CHAT_RAID_LEADER_GET = "|Hchannel:RAID|h"..chRaidLeader..chSeparator.."|h %s: " | |
CHAT_PARTY_GET = "|Hchannel:PARTY|h"..chParty..chSeparator.."|h %s: " | |
CHAT_PARTY_LEADER_GET = "|Hchannel:PARTY|h"..chPartyLeader..chSeparator.."|h %s: " | |
CHAT_PARTY_GUIDE_GET = "|Hchannel:PARTY|h"..chPartyGuide..chSeparator.."|h %s: " | |
CHAT_INSTANCE_CHAT_GET = "|Hchannel:Battleground|h"..chInstance..chSeparator.."|h %s: " | |
CHAT_INSTANCE_CHAT_LEADER_GET = "|Hchannel:Battleground|h"..chInstanceLeader..chSeparator.."|h %s: " | |
CHAT_WHISPER_INFORM_GET = chWhisperTo..chSeparator.." %s: " | |
CHAT_BN_WHISPER_INFORM_GET = chWhisperTo..chSeparator.." %s: " | |
CHAT_WHISPER_GET = chWhisperFrom..chSeparator.." %s: " | |
CHAT_BN_WHISPER_GET = chWhisperFrom..chSeparator.." %s: " | |
CHAT_SAY_GET = "%s " | |
CHAT_YELL_GET = "%s " | |
CHAT_FLAG_AFK = "[AFK] " | |
CHAT_FLAG_DND = "[DND] " | |
CHAT_FLAG_GM = "[GM] " | |
for i = 1, NUM_CHAT_WINDOWS do | |
if ( i ~= 2 ) then | |
local f = _G["ChatFrame"..i] | |
local am = f.AddMessage | |
f.AddMessage = function(frame, text, ...) | |
return am(frame, text:gsub('|h%[(%d+)%. .-%]|h', '|h%1|h'), ...) | |
end | |
end | |
end | |
-- Taken from Roth so shit happens when we log in, otherwise doesn't work | |
local function fixStuffOnLogin() | |
for i = 1, NUM_CHAT_WINDOWS do | |
local chatlevelfix = _G[format("%s%d", "ChatFrame", i)] | |
local name = "ChatFrame"..i | |
local tab = _G[name.."Tab"] | |
tab:SetAlpha(0) | |
chatlevelfix:SetFrameLevel(4) | |
end | |
CombatLogQuickButtonFrame_Custom:HookScript("OnShow", CombatLogQuickButtonFrame_Custom.Hide) | |
CombatLogQuickButtonFrame_Custom:Hide() | |
CombatLogQuickButtonFrame_Custom:SetHeight(0) | |
end | |
local a = CreateFrame("Frame") | |
a:RegisterEvent("PLAYER_LOGIN") | |
a:RegisterEvent('PLAYER_ENTERING_WORLD') | |
a:SetScript("OnEvent", fixStuffOnLogin) | |
--[[ | |
URL Copy from wChat | |
--]] | |
local urlcolor = "ffffff" | |
local pattern = "[wWhH][wWtT][wWtT][\46pP]%S+[^%p%s]" | |
function string.color(text, urlcolor) | |
return "|cff"..urlcolor..text.."|r" | |
end | |
function string.link(text, type, value, color) | |
return "|H"..type..":"..tostring(value).."|h"..tostring(text):color(urlcolor or "ffffff").."|h" | |
end | |
StaticPopupDialogs["LINKME"] = { | |
text = "URL COPY", | |
button2 = CANCEL, | |
hasEditBox = true, | |
editBoxWidth = 400, | |
timeout = 0, | |
exclusive = 1, | |
hideOnEscape = 1, | |
EditBoxOnEscapePressed = function(self) self:GetParent():Hide() end, | |
whileDead = 1, | |
maxLetters = 255, | |
} | |
local function f(url) | |
return string.link("["..url.."]", "url", url, urlcolor) | |
end | |
local function hook(self, text, ...) | |
self:f(text:gsub(pattern, f), ...) | |
end | |
for i = 1, NUM_CHAT_WINDOWS do | |
if ( i ~= 2 ) then | |
local lframe = _G["ChatFrame"..i] | |
lframe.f = lframe.AddMessage | |
lframe.AddMessage = hook | |
end | |
end | |
local ur = ChatFrame_OnHyperlinkShow | |
function ChatFrame_OnHyperlinkShow(self, link, text, button) | |
local type, value = link:match("(%a+):(.+)") | |
if ( type == "url" ) then | |
local dialog = StaticPopup_Show("LINKME") | |
local editbox1 = _G[dialog:GetName().."EditBox"] | |
editbox1:SetText(value) | |
editbox1:SetFocus() | |
editbox1:HighlightText() | |
local button = _G[dialog:GetName().."Button2"] | |
button:ClearAllPoints() | |
button:SetPoint("CENTER", editbox1, "CENTER", 0, -30) | |
else | |
ur(self, link, text, button) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment