commit bf1ead5837b42731103488b3138d24b72bf72033 Author: KlazHTT Date: Thu Feb 29 00:23:53 2024 -0500 Init diff --git a/Core/Localization.lua b/Core/Localization.lua new file mode 100644 index 0000000..ae6a6a6 --- /dev/null +++ b/Core/Localization.lua @@ -0,0 +1,51 @@ +local addon, ns = ... +local L = {} +ns.L = L + +-------------------------------------------------------------------------------- +-- // CORE > LOCALIZATION +-------------------------------------------------------------------------------- + +setmetatable(L, { __index = function(t, k) + local v = tostring(k) + t[k] = v + return v +end }) + +-- ## ENGLISH +-------------------------------------------------------------------------------- + +L.SHORT_INSTANCE = 'I' +L.SHORT_INSTANCE_LEADER = 'IL' +L.SHORT_PARTY = 'P' +L.SHORT_PARTY_LEADER = 'PL' +L.SHORT_WHISPER_FROM = 'From' +L.SHORT_GUILD = 'G' +L.SHORT_OFFICER = 'O' +L.SHORT_RAID = 'R' +L.SHORT_RAID_LEADER = 'R' +L.SHORT_RAID_WARNING = 'RW' + +L.SHORT_FLAG_AFK = '[AFK]' +L.SHORT_FLAG_DND = '[DND]' +L.SHORT_FLAG_GM = '[GM]' + +L.SHORT_STATUS_ONLINE = '|cff00ff00+|r' +L.SHORT_STATUS_OFFLINE = '|cffff0000-|r' + +local locale = GetLocale() +if locale == 'en_GB' or locale == 'en_US' then return end -- ENGLISH + +-- ## OTHER +-------------------------------------------------------------------------------- + +-- if locale == 'esMX' then return end -- SPANISH (MEXICO) +-- if locale == 'pt_BR' then return end -- PORTUGEUSE +-- if locale == 'de_DE' then return end -- GERMAN +-- if locale == 'es_ES' then return end -- SPANISH (SPAIN) +-- if locale == 'fr_FR' then return end -- FRENCH +-- if locale == 'it_IT' then return end -- ITALIAN +-- if locale == 'ru_RU' then return end -- RUSSIAN +-- if locale == 'ko_KR' then return end -- KOREAN +-- if locale == 'zh_TW' then return end -- CHINESE (TRADITIONAL) +-- if locale == 'zh_CN' then return end -- CHINESE (SIMPLIFIED) diff --git a/KlazChat.toc b/KlazChat.toc new file mode 100644 index 0000000..23c3f6a --- /dev/null +++ b/KlazChat.toc @@ -0,0 +1,11 @@ +## Interface: 100205 +## Title: Klaz|cff1994ffChat|r +## Author: Klaz +## Notes: Styles default chat frames. +## IconTexture: Interface\AddOns\KlazChat\Media\KlazAddOnIcon.blp + +Core\Localization.lua + +Modules\CopyLinks.lua +Modules\ShortChannelNames.lua +Modules\Style.lua diff --git a/Media/KlazAddOnIcon.blp b/Media/KlazAddOnIcon.blp new file mode 100644 index 0000000..f65d211 Binary files /dev/null and b/Media/KlazAddOnIcon.blp differ diff --git a/Modules/CopyLinks.lua b/Modules/CopyLinks.lua new file mode 100644 index 0000000..1c41d5e --- /dev/null +++ b/Modules/CopyLinks.lua @@ -0,0 +1,52 @@ +-------------------------------------------------------------------------------- +-- # MODULES > COPY LINKS +-------------------------------------------------------------------------------- + +local patterns = { + '(https://%S+%.%S+)', + '(http://%S+%.%S+)', + '(www%.%S+%.%S+)', + '(%d+%.%d+%.%d+%.%d+:?%d*/?%S*)' +} + +for _, event in next, { + 'CHAT_MSG_SAY', + 'CHAT_MSG_YELL', + 'CHAT_MSG_WHISPER', + 'CHAT_MSG_WHISPER_INFORM', + 'CHAT_MSG_GUILD', + 'CHAT_MSG_OFFICER', + 'CHAT_MSG_PARTY', + 'CHAT_MSG_PARTY_LEADER', + 'CHAT_MSG_RAID', + 'CHAT_MSG_RAID_LEADER', + 'CHAT_MSG_RAID_WARNING', + 'CHAT_MSG_INSTANCE_CHAT', + 'CHAT_MSG_INSTANCE_CHAT_LEADER', + 'CHAT_MSG_BN_WHISPER', + 'CHAT_MSG_BN_WHISPER_INFORM', + 'CHAT_MSG_CHANNEL', + 'CHAT_MSG_SYSTEM' +} do + ChatFrame_AddMessageEventFilter(event, function(_, event, str, ...) + for _, pattern in pairs(patterns) do + local result, match = string.gsub(str, pattern, '|cff1994ff|Hurl:%1|h[%1]|h|r') + if match > 0 then + return false, result, ... + end + end + end) +end + +local SetHyperlink = _G.ItemRefTooltip.SetHyperlink +function _G.ItemRefTooltip:SetHyperlink(link, ...) + if link and (strsub(link, 1, 3) == 'url') then + local editbox = ChatEdit_ChooseBoxForSend() + ChatEdit_ActivateChat(editbox) + editbox:Insert(string.sub(link, 5)) + editbox:HighlightText() + return + end + + SetHyperlink(self, link, ...) +end diff --git a/Modules/ShortChannelNames.lua b/Modules/ShortChannelNames.lua new file mode 100644 index 0000000..c988d45 --- /dev/null +++ b/Modules/ShortChannelNames.lua @@ -0,0 +1,51 @@ +local addon, ns = ... +local L = ns.L + +-------------------------------------------------------------------------------- +-- # MODULES > SHORT CHANNEL NAMES +-------------------------------------------------------------------------------- + +_G.CHAT_INSTANCE_CHAT_GET = '|Hchannel:INSTANCE_CHAT|h['..L.SHORT_INSTANCE..']|h %s:\32' +_G.CHAT_INSTANCE_CHAT_LEADER_GET = '|Hchannel:INSTANCE_CHAT|h['..L.SHORT_INSTANCE_LEADER..']|h %s:\32' +_G.CHAT_BN_WHISPER_GET = L.SHORT_WHISPER_FROM..' %s:\32' +_G.CHAT_GUILD_GET = '|Hchannel:GUILD|h['..L.SHORT_GUILD..']|h %s:\32' +_G.CHAT_OFFICER_GET = '|Hchannel:OFFICER|h['..L.SHORT_OFFICER..']|h %s:\32' +_G.CHAT_PARTY_GET = '|Hchannel:PARTY|h['..L.SHORT_PARTY..']|h %s:\32' +_G.CHAT_PARTY_LEADER_GET = '|Hchannel:PARTY|h['..L.SHORT_PARTY_LEADER..']|h %s:\32' +_G.CHAT_RAID_GET = '|Hchannel:RAID|h['..L.SHORT_RAID..']|h %s:\32' +_G.CHAT_RAID_LEADER_GET = '|Hchannel:RAID|h['..L.SHORT_RAID_LEADER..']|h %s:\32' +_G.CHAT_RAID_WARNING_GET = '['..L.SHORT_RAID_WARNING..'] %s:\32' +_G.CHAT_SAY_GET = '%s:\32' +_G.CHAT_WHISPER_GET = L.SHORT_WHISPER_FROM..' %s:\32' +_G.CHAT_YELL_GET = '%s:\32' +_G.CHAT_FLAG_AFK = '|cffE7E716'..L.SHORT_FLAG_AFK..'|r ' +_G.CHAT_FLAG_DND = '|cffFF0000'..L.SHORT_FLAG_DND..'|r ' +_G.CHAT_FLAG_GM = '|cff4154F5'..L.SHORT_FLAG_GM..'|r ' +_G.ERR_FRIEND_ONLINE_SS = '|Hplayer:%s|h%s|h '..L.SHORT_STATUS_ONLINE +_G.ERR_FRIEND_OFFLINE_S = '%s '..L.SHORT_STATUS_OFFLINE + +local f = CreateFrame('Frame') +f:RegisterEvent('PLAYER_ENTERING_WORLD') +f:SetScript('OnEvent', function(self, event) + + local origs = {} + + local function Strip(info, name) + return string.format('|Hplayer:%s|h[%s]|h', info, name:gsub('%-[^|]+', '')) + end + + local AddMessage = function(self, text, ...) + if type(text) == 'string' then + text = text:gsub('|h%[(%d+)%. .-%]|h', '|h[%1]|h') + text = text:gsub('|Hplayer:(.-)|h%[(.-)%]|h', Strip) + end + return origs[self](self, text, ...) + end + + for i = 1, NUM_CHAT_WINDOWS do + if i ~= 2 then + origs[_G['ChatFrame' .. i]] = _G['ChatFrame' .. i].AddMessage + _G['ChatFrame' .. i].AddMessage = AddMessage + end + end +end) diff --git a/Modules/Style.lua b/Modules/Style.lua new file mode 100644 index 0000000..59ce38b --- /dev/null +++ b/Modules/Style.lua @@ -0,0 +1,115 @@ +-------------------------------------------------------------------------------- +-- # MODULES > STYLE +-------------------------------------------------------------------------------- + +-- add additional font sizes +CHAT_FONT_HEIGHTS = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} + +-- fade chat frame and tabs +CHAT_FRAME_FADE_TIME = .5 +CHAT_TAB_SHOW_DELAY = 0 +CHAT_TAB_HIDE_DELAY = .5 +CHAT_FRAME_FADE_OUT_TIME = .5 +CHAT_FRAME_TAB_NORMAL_MOUSEOVER_ALPHA = 1 +CHAT_FRAME_TAB_NORMAL_NOMOUSE_ALPHA = .2 +CHAT_FRAME_TAB_SELECTED_MOUSEOVER_ALPHA = 1 +CHAT_FRAME_TAB_SELECTED_NOMOUSE_ALPHA = .8 +CHAT_FRAME_TAB_ALERTING_MOUSEOVER_ALPHA = 1 +CHAT_FRAME_TAB_ALERTING_NOMOUSE_ALPHA = 1 + +local f = CreateFrame('Frame') +f:RegisterEvent('PLAYER_ENTERING_WORLD') +f:SetScript('OnEvent', function(self, event) + + -- hide social button + QuickJoinToastButton:HookScript('OnShow', QuickJoinToastButton.Hide) + QuickJoinToastButton:Hide() + + -- hide shortcut button for emotes/languages/etc + ChatFrameMenuButton:HookScript('OnShow', ChatFrameMenuButton.Hide) + ChatFrameMenuButton:Hide() + + -- hide voice deafen button + ChatFrameToggleVoiceDeafenButton:HookScript('OnShow', ChatFrameToggleVoiceDeafenButton.Hide) + ChatFrameToggleVoiceDeafenButton:Hide() + + -- hide voice mute button + ChatFrameToggleVoiceMuteButton:HookScript('OnShow', ChatFrameToggleVoiceMuteButton.Hide) + ChatFrameToggleVoiceMuteButton:Hide() + ChatFrameChannelButton:HookScript('OnShow', ChatFrameChannelButton.Hide) + ChatFrameChannelButton:Hide() + + -- keep track of frames we have already seen + local frames = {} + + local function SkinChatFrames(frame) + if frames[frame] then return end + local name = frame:GetName() + local editbox = _G[name..'EditBox'] + + -- hide button frame + _G[name..'ButtonFrame']:Hide() + + -- strip edit box textures + for k = 3, 8 do + select(k, editbox:GetRegions()):SetTexture(nil) + end + + -- allow arrow keys in edit box + editbox:SetAltArrowKeyMode(false) + + -- create backdrop for edit box + Mixin(editbox, BackdropTemplateMixin) + editbox:SetBackdrop( { + bgFile = "Interface\\ChatFrame\\ChatFrameBackground", + edgeFile = "Interface\\Buttons\\WHITE8x8", + tile = true, + tileEdge = true, + tileSize = 8, + edgeSize = 1, + insets = { left = 1, right = 1, top = 1, bottom = 1 }, + }) + editbox:SetBackdropColor(0, 0, 0, .5) + editbox:SetBackdropBorderColor(0, 0, 0, .8) + + -- adjust edit box border based on active chat channel + hooksecurefunc("ChatEdit_UpdateHeader", function(editBox) + local chatType = editBox:GetAttribute("chatType") + if not chatType then + return + end + + local info = ChatTypeInfo[chatType] + editbox:SetBackdropBorderColor(info.r, info.g, info.b, .5) + end) + + -- reposition edit box + editbox:ClearAllPoints() + editbox:SetPoint('TOPLEFT', ChatFrame1, 'BOTTOMLEFT', -3, -8) + editbox:SetPoint('TOPRIGHT', ChatFrame1, 'BOTTOMRIGHT', 16, -8) + + -- hide chat tabs textures + local tab = _G[name..'Tab'] + for i = 1, select('#', tab:GetRegions()) do + local texture = select(i, tab:GetRegions()) + if texture and texture:GetObjectType() == 'Texture' then + texture:SetTexture(nil) + end + end + + frames[frame] = true + end + + -- retrieve all permanent chat windows and apply skin + for i = 1, NUM_CHAT_WINDOWS do + SkinChatFrames(_G['ChatFrame' .. i]) + end + + -- set up a dirty hook to catch temporary windows to apply skin on them + local old_OpenTemporaryWindow = FCF_OpenTemporaryWindow + FCF_OpenTemporaryWindow = function(...) + local frame = old_OpenTemporaryWindow(...) + SkinChatFrames(frame) + return frame + end +end) diff --git a/README.md b/README.md new file mode 100644 index 0000000..d975316 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# KlazChat + +A World of Warcraft add-on that styles the default chat frames. + +There are no in-game options. All settings are hard-coded. + +## Features + +- Strip clutter from default chat frames + - Remove social buttons + - Remove chat tab textures +- Allow copying URL links +- Short channel names (e.g. Guild -> G, Party -> P) + +## Installation + +1. Backup `World of Warcraft\_retail_\Interface` and `World of Warcraft\_retail_\WTF` folders. Just in case. +2. Download and extract folder. +3. Place extracted folder in `World of Warcraft\_retail_\Interface\AddOns\` directory. +4. Restart World of Warcraft client.