From cd5f33439fa0b9afd5a8e8b23b4f972b8f66bcc6 Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 22 Apr 2018 14:35:36 +0200 Subject: [PATCH] chat: add option to customize default brackets --- api/config.lua | 1 + env/translations_deDE.lua | 3 ++- env/translations_enUS.lua | 3 ++- env/translations_esES.lua | 5 +++-- env/translations_frFR.lua | 5 +++-- env/translations_koKR.lua | 5 +++-- env/translations_ruRU.lua | 5 +++-- env/translations_zhCN.lua | 5 +++-- env/translations_zhTW.lua | 5 +++-- modules/chat.lua | 39 ++++++++++++++++++++++----------------- modules/gui.lua | 1 + 11 files changed, 46 insertions(+), 31 deletions(-) diff --git a/api/config.lua b/api/config.lua index 10add26a..2d7c3198 100644 --- a/api/config.lua +++ b/api/config.lua @@ -557,6 +557,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("chat", "text", "input_width", "0") pfUI:UpdateConfig("chat", "text", "input_height", "0") pfUI:UpdateConfig("chat", "text", "outline", "1") + pfUI:UpdateConfig("chat", "text", "bracket", "[]") pfUI:UpdateConfig("chat", "text", "time", "0") pfUI:UpdateConfig("chat", "text", "timeformat", "%H:%M:%S") pfUI:UpdateConfig("chat", "text", "timebracket", "[]") diff --git a/env/translations_deDE.lua b/env/translations_deDE.lua index c0cc9e31..d04e079c 100644 --- a/env/translations_deDE.lua +++ b/env/translations_deDE.lua @@ -58,6 +58,7 @@ pfUI_translation["deDE"] = { ["Chat Border Color"] = nil, ["Chat Border Size"] = nil, ["Chat Bubble Transparency"] = nil, + ["Chat Default Brackets"] = nil, ["Chat"] = nil, ["Class"] = nil, ["Clear Rolls"] = nil, @@ -379,9 +380,9 @@ pfUI_translation["deDE"] = { ["Show Players Only"] = nil, ["Show Procs as Buff Indicators"] = nil, ["Show Procs of all Classes"] = nil, - ["Show Totems as Buff Indicators"] = nil, ["Show PvP Icon"] = nil, ["Show Self in Group Frames"] = nil, + ["Show Totems as Buff Indicators"] = nil, ["Skins"] = nil, ["Slow"] = nil, ["Small"] = nil, diff --git a/env/translations_enUS.lua b/env/translations_enUS.lua index 1d3ec9fe..44890f70 100644 --- a/env/translations_enUS.lua +++ b/env/translations_enUS.lua @@ -58,6 +58,7 @@ pfUI_translation["enUS"] = { ["Chat Border Color"] = nil, ["Chat Border Size"] = nil, ["Chat Bubble Transparency"] = nil, + ["Chat Default Brackets"] = nil, ["Chat"] = nil, ["Class"] = nil, ["Clear Rolls"] = nil, @@ -379,9 +380,9 @@ pfUI_translation["enUS"] = { ["Show Players Only"] = nil, ["Show Procs as Buff Indicators"] = nil, ["Show Procs of all Classes"] = nil, - ["Show Totems as Buff Indicators"] = nil, ["Show PvP Icon"] = nil, ["Show Self in Group Frames"] = nil, + ["Show Totems as Buff Indicators"] = nil, ["Skins"] = nil, ["Slow"] = nil, ["Small"] = nil, diff --git a/env/translations_esES.lua b/env/translations_esES.lua index e5f5381b..ee6c7b54 100644 --- a/env/translations_esES.lua +++ b/env/translations_esES.lua @@ -58,6 +58,7 @@ pfUI_translation["esES"] = { ["Chat Border Color"] = "Color del Borde de Chat", ["Chat Border Size"] = "Tamaño del Borde de Chat", ["Chat Bubble Transparency"] = "Transparencia del Bocadillo de Chat", + ["Chat Default Brackets"] = nil, ["Chat"] = nil, ["Class"] = "Clase", ["Clear Rolls"] = "Borrar los dados", @@ -379,9 +380,9 @@ pfUI_translation["esES"] = { ["Show Players Only"] = "Solamente Mostrar Jugadores", ["Show Procs as Buff Indicators"] = "Mostrar Ocurrencias aleatorias programadas (Procs) como Indicadores de Buffs", ["Show Procs of all Classes"] = "Mostrar Ocurrencias aleatorias programadas (Procs) de Todas las Clases", - ["Show Totems as Buff Indicators"] = nil, ["Show PvP Icon"] = "Mostrar Icono de JcJ", ["Show Self in Group Frames"] = "Mostrar a ti Mismo en los Marcos del Grupo", + ["Show Totems as Buff Indicators"] = nil, ["Skins"] = "Piel", ["Slow"] = "Lento", ["Small"] = "Pequeño", @@ -403,7 +404,7 @@ pfUI_translation["esES"] = { ["Text Colors"] = "Color del Texto", ["Thirdparty"] = "Tercero", ["This Session"] = "Esta Sesión", - ["Timestamp Brackets"] = "Corchetes del Sello de Tiempo", + ["Timestamp Brackets"] = nil, ["Timestamp Color"] = "Color del Sello de Tiempo", ["Timestamp Format"] = "Formato del Sello de Tiempo", ["Time"] = "Tiempo", diff --git a/env/translations_frFR.lua b/env/translations_frFR.lua index 9388ef51..8d73af97 100644 --- a/env/translations_frFR.lua +++ b/env/translations_frFR.lua @@ -59,6 +59,7 @@ pfUI_translation["frFR"] = { ["Chat Border Size"] = "Taille de la bordure du chat", ["Chat Bubble Transparency"] = nil, ["Chat"] = "Chat", + ["Chat Default Brackets"] = nil, ["Class"] = "Classe", ["Clear Rolls"] = nil, ["Click Action"] = "Action au clic", @@ -379,9 +380,9 @@ pfUI_translation["frFR"] = { ["Show Players Only"] = "Afficher les joueurs uniquement", ["Show Procs as Buff Indicators"] = "Afficher les procs en tant qu'indicateur d'amélioration", ["Show Procs of all Classes"] = "Afficher les procs de chaque classe", - ["Show Totems as Buff Indicators"] = nil, ["Show PvP Icon"] = "Afficher l'icône JcJ", ["Show Self in Group Frames"] = "S'afficher dans l'UI Groupe", + ["Show Totems as Buff Indicators"] = nil, ["Skins"] = nil, ["Slow"] = "Doucement", ["Small"] = nil, @@ -404,7 +405,7 @@ pfUI_translation["frFR"] = { ["Thirdparty"] = "Autres addons", ["This Session"] = "Session Actuelle", ["Time"] = "Heure", - ["Timestamp Brackets"] = "Format des horaires des messages", + ["Timestamp Brackets"] = nil, ["Timestamp Color"] = "Couleur des horaires des messages", ["Timestamp Format"] = "Format des horaires des messages", ["Tiny (PixelPerfect)"] = nil, diff --git a/env/translations_koKR.lua b/env/translations_koKR.lua index 6a71879d..cc6a7baf 100644 --- a/env/translations_koKR.lua +++ b/env/translations_koKR.lua @@ -59,6 +59,7 @@ pfUI_translation["koKR"] = { ["Chat Border Color"] = "채팅 테두리 색상", ["Chat Border Size"] = "채팅 테두리 크기", ["Chat Bubble Transparency"] = nil, + ["Chat Default Brackets"] = nil, ["Class"] = "클래스(직업)", ["Clear Rolls"] = nil, ["Click Action"] = "클릭 액션", @@ -379,9 +380,9 @@ pfUI_translation["koKR"] = { ["Show Players Only"] = "플레이어만 보기", ["Show Procs as Buff Indicators"] = "무기활성화버프 버프표시기에 보기", ["Show Procs of all Classes"] = "모든 클래스 무기활성화 버프 보기", - ["Show Totems as Buff Indicators"] = nil, ["Show PvP Icon"] = "PvP아이콘 표시", ["Show Self in Group Frames"] = nil, + ["Show Totems as Buff Indicators"] = nil, ["Skins"] = nil, ["Slow"] = "느린", ["Small"] = nil, @@ -404,7 +405,7 @@ pfUI_translation["koKR"] = { ["Thirdparty"] = "서드파티", ["This Session"] = "이번 세션", ["Time"] = "시간", - ["Timestamp Brackets"] = "시간표시 괄호", + ["Timestamp Brackets"] = nil, ["Timestamp Color"] = "시간표시 색상", ["Timestamp Format"] = "시간표시 형식", ["Tiny (PixelPerfect)"] = nil, diff --git a/env/translations_ruRU.lua b/env/translations_ruRU.lua index 94ffdd13..f7b83eb9 100644 --- a/env/translations_ruRU.lua +++ b/env/translations_ruRU.lua @@ -58,6 +58,7 @@ pfUI_translation["ruRU"] = { ["Chat Border Color"] = "Цвет бордюра чата", ["Chat Border Size"] = "Размер бордюра чата", ["Chat Bubble Transparency"] = "Прозрачность пузыря чата", + ["Chat Default Brackets"] = nil, ["Chat"] = "Чат", ["Class"] = "Класс", ["Clear Rolls"] = "Очистить броски", @@ -379,9 +380,9 @@ pfUI_translation["ruRU"] = { ["Show Players Only"] = "Показать только игроков", ["Show Procs as Buff Indicators"] = "Показать проки (Procs) как индикаторы баффов", ["Show Procs of all Classes"] = "Показать проки (Procs) всех классов", - ["Show Totems as Buff Indicators"] = nil, ["Show PvP Icon"] = "Показать PvP иконку", ["Show Self in Group Frames"] = "Показать себя в окне группы", + ["Show Totems as Buff Indicators"] = nil, ["Skins"] = "Оболочки", ["Slow"] = "Медленно", ["Small"] = "Маленький", @@ -403,7 +404,7 @@ pfUI_translation["ruRU"] = { ["Text Colors"] = "Цвета текста", ["Thirdparty"] = "Другие аддоны", ["This Session"] = "Эта сессия", - ["Timestamp Brackets"] = "Скобки отметок времени", + ["Timestamp Brackets"] = nil, ["Timestamp Color"] = "Цвет отметок времени", ["Timestamp Format"] = "Формат отметок времени", ["Time"] = "Время", diff --git a/env/translations_zhCN.lua b/env/translations_zhCN.lua index 741a65ce..ec9cfa99 100644 --- a/env/translations_zhCN.lua +++ b/env/translations_zhCN.lua @@ -58,6 +58,7 @@ pfUI_translation["zhCN"] = { ["Chat Border Color"] = "聊天窗口边框颜色", ["Chat Border Size"] = "聊天窗口边框大小", ["Chat Bubble Transparency"] = nil, + ["Chat Default Brackets"] = nil, ["Chat"] = "聊天窗口", ["Class"] = "职业", ["Clear Rolls"] = "清除Roll点", @@ -379,9 +380,9 @@ pfUI_translation["zhCN"] = { ["Show Players Only"] = "仅显示自己", ["Show Procs as Buff Indicators"] = "在框架的Buff指示器显示触发效果", ["Show Procs of all Classes"] = "显示所有职业的触发效果", - ["Show Totems as Buff Indicators"] = nil, ["Show PvP Icon"] = "显示PVP图标", ["Show Self in Group Frames"] = "在小队列表中显示自己", + ["Show Totems as Buff Indicators"] = nil, ["Skins"] = "皮肤", ["Slow"] = "慢速", ["Small"] = nil, @@ -403,7 +404,7 @@ pfUI_translation["zhCN"] = { ["Text Colors"] = nil, ["Thirdparty"] = "第三方插件接口", ["This Session"] = "本次登录收益", - ["Timestamp Brackets"] = "时间戳括弧", + ["Timestamp Brackets"] = nil, ["Timestamp Color"] = "时间戳颜色", ["Timestamp Format"] = "时间戳格式", ["Time"] = "计时器", diff --git a/env/translations_zhTW.lua b/env/translations_zhTW.lua index 31a5974f..c192de26 100644 --- a/env/translations_zhTW.lua +++ b/env/translations_zhTW.lua @@ -58,6 +58,7 @@ pfUI_translation["zhTW"] = { ["Chat Border Color"] = "聊天窗口邊框顏色", ["Chat Border Size"] = "聊天窗口邊框大小", ["Chat Bubble Transparency"] = nil, + ["Chat Default Brackets"] = nil, ["Chat"] = "聊天窗口", ["Class"] = "職業", ["Clear Rolls"] = "清除Roll點", @@ -379,9 +380,9 @@ pfUI_translation["zhTW"] = { ["Show Players Only"] = "僅顯示自己", ["Show Procs as Buff Indicators"] = "在框架的Buff指示器顯示觸發效果", ["Show Procs of all Classes"] = "顯示所有職業的觸發效果", - ["Show Totems as Buff Indicators"] = nil, ["Show PvP Icon"] = "顯示PVP圖示", ["Show Self in Group Frames"] = "在小隊清單中顯示自己", + ["Show Totems as Buff Indicators"] = nil, ["Skins"] = nil, ["Slow"] = "慢速", ["Small"] = nil, @@ -403,7 +404,7 @@ pfUI_translation["zhTW"] = { ["Text Colors"] = nil, ["Thirdparty"] = "協力廠商外掛程式介面", ["This Session"] = "本次登錄收益", - ["Timestamp Brackets"] = "時間戳記括弧", + ["Timestamp Brackets"] = nil, ["Timestamp Color"] = "時間戳記顏色", ["Timestamp Format"] = "時間戳記格式", ["Time"] = "計時器", diff --git a/modules/chat.lua b/modules/chat.lua index b4d155eb..6c721cbb 100644 --- a/modules/chat.lua +++ b/modules/chat.lua @@ -741,19 +741,27 @@ pfUI:RegisterModule("chat", function () cr, cg, cb = tonumber(cr), tonumber(cg), tonumber(cb) wcol = string.format("%02x%02x%02x",cr * 255,cg * 255, cb * 255) + -- read and parse chat bracket settings + local left = string.sub(C.chat.text.bracket, 1, 1) + local right = string.sub(C.chat.text.bracket, 2, 2) + + -- read and parse chat time bracket settings + local tleft = string.sub(C.chat.text.timebracket, 1, 1) + local tright = string.sub(C.chat.text.timebracket, 2, 2) + -- shorten chat channel indicators local default = " " .. "%s" .. "|r:" .. "\32" _G.CHAT_CHANNEL_GET = "%s" .. "|r:" .. "\32" - _G.CHAT_GUILD_GET = '[G]' .. default - _G.CHAT_OFFICER_GET = '[O]'.. default - _G.CHAT_PARTY_GET = '[P]' .. default - _G.CHAT_RAID_GET = '[R]' .. default - _G.CHAT_RAID_LEADER_GET = '[RL]' .. default - _G.CHAT_RAID_WARNING_GET = '[RW]' .. default - _G.CHAT_BATTLEGROUND_GET = '[BG]' .. default - _G.CHAT_BATTLEGROUND_LEADER_GET = '[BL]' .. default - _G.CHAT_SAY_GET = '[S]' .. default - _G.CHAT_YELL_GET = '[Y]' .. default + _G.CHAT_GUILD_GET = left .. "G" .. right .. default + _G.CHAT_OFFICER_GET = left .. "O" .. right .. default + _G.CHAT_PARTY_GET = left .. "P" .. right .. default + _G.CHAT_RAID_GET = left .. "R" .. right .. default + _G.CHAT_RAID_LEADER_GET = left .. "RL" .. right .. default + _G.CHAT_RAID_WARNING_GET = left .. "RW" .. right .. default + _G.CHAT_BATTLEGROUND_GET = left .. "BG" .. right .. default + _G.CHAT_BATTLEGROUND_LEADER_GET = left .. "BL" .. right .. default + _G.CHAT_SAY_GET = left .. "S" .. right .. default + _G.CHAT_YELL_GET = left .. "Y" .. right ..default if C.chat.global.whispermod == "1" then _G.CHAT_WHISPER_GET = '|cff' .. wcol .. '[W]' .. default @@ -793,29 +801,26 @@ pfUI:RegisterModule("chat", function () Name = "|cff" .. Color .. Name .. "|r" end end - text = string.gsub(text, "|Hplayer:(.-)|h%[.-%]|h(.-:-)", "[|Hplayer:%1|h" .. Name .. "|h]" .. "%2") + text = string.gsub(text, "|Hplayer:(.-)|h%[.-%]|h(.-:-)", "|r" .. left .. "|Hplayer:%1|h" .. Name .. "|h|r" .. right .. "%2") end -- reduce channel name to number if C.chat.text.channelnumonly == "1" then local pattern = "%]%s+(.*|Hplayer)" - local channel = string.gsub(text, ".*%[(.-)" .. pattern ..".+", "%1") + local channel = string.gsub(text, ".*%[(.-)" .. pattern .. ".+", "%1") if string.find(channel, "%d+%. ") then channel = string.gsub(channel, "(%d+)%..*", "channel%1") channel = string.gsub(channel, "channel", "") pattern = "%[%d+%..-" .. pattern - text = string.gsub(text, pattern, "["..channel.."] ".."%1") + text = string.gsub(text, pattern, left .. channel .. right .. " %1") end end -- show timestamp in chat if C.chat.text.time == "1" then - local left = string.sub(C.chat.text.timebracket, 1, 1) - local right = string.sub(C.chat.text.timebracket, 2, 2) - local r,g,b,a = strsplit(",", C.chat.text.timecolor) local chex = string.format("%02x%02x%02x%02x", a*255, r*255, g*255, b*255) - text = "|c" .. chex .. left .. date(C.chat.text.timeformat) .. right .. "|r " .. text + text = "|c" .. chex .. tleft .. date(C.chat.text.timeformat) .. tright .. "|r " .. text end if C.chat.global.whispermod == "1" then diff --git a/modules/gui.lua b/modules/gui.lua index 774ecd8b..62947c66 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -1129,6 +1129,7 @@ pfUI:RegisterModule("gui", function () CreateConfig(nil, this, T["Inputbox Width"], C.chat.text, "input_width") CreateConfig(nil, this, T["Inputbox Height"], C.chat.text, "input_height") CreateConfig(nil, this, T["Enable Text Shadow"], C.chat.text, "outline", "checkbox") + CreateConfig(nil, this, T["Chat Default Brackets"], C.chat.text, "bracket", nil, nil, nil, nil, "STRING") CreateConfig(nil, this, T["Enable Timestamps"], C.chat.text, "time", "checkbox") CreateConfig(nil, this, T["Timestamp Format"], C.chat.text, "timeformat", nil, nil, nil, nil, "STRING") CreateConfig(nil, this, T["Timestamp Brackets"], C.chat.text, "timebracket", nil, nil, nil, nil, "STRING")