From 83bb05f6160b221d0c4d15c00057baf382b1130d Mon Sep 17 00:00:00 2001 From: greenya Date: Tue, 23 May 2017 00:56:59 +0300 Subject: [PATCH] chat: add option to show channel names --- api/config.lua | 1 + modules/chat.lua | 16 +++++++++------- modules/gui.lua | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/api/config.lua b/api/config.lua index fc7bd47b..353240f1 100644 --- a/api/config.lua +++ b/api/config.lua @@ -172,6 +172,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("chat", "text", "timeformat", "%H:%M:%S") pfUI:UpdateConfig("chat", "text", "timebracket", "[]") pfUI:UpdateConfig("chat", "text", "timecolor", ".8,.8,.8,1") + pfUI:UpdateConfig("chat", "text", "channelnumonly", "1") pfUI:UpdateConfig("chat", "text", "detecturl", "1") pfUI:UpdateConfig("chat", "text", "classcolor", "1") pfUI:UpdateConfig("chat", "left", "width", "380") diff --git a/modules/chat.lua b/modules/chat.lua index a2bedf93..7a889983 100644 --- a/modules/chat.lua +++ b/modules/chat.lua @@ -702,13 +702,15 @@ pfUI:RegisterModule("chat", function () text = string.gsub(text, "|Hplayer:(.-)|h%[.-%]|h(.-:-)", "[|Hplayer:%1|h" .. Name .. "|h]" .. "%2") end - local pattern = "%]%s+(.*|Hplayer)" - 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") + if C.chat.text.channelnumonly == "1" then + local pattern = "%]%s+(.*|Hplayer)" + 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") + end end -- show timestamp in chat diff --git a/modules/gui.lua b/modules/gui.lua index cfa2a21a..f817571f 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -985,6 +985,7 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.chat, "Timestamp Format", C.chat.text, "timeformat") pfUI.gui:CreateConfig(pfUI.gui.chat, "Timestamp Brackets", C.chat.text, "timebracket") pfUI.gui:CreateConfig(pfUI.gui.chat, "Timestamp Color", C.chat.text, "timecolor", "color") + pfUI.gui:CreateConfig(pfUI.gui.chat, "Hide Channel Names", C.chat.text, "channelnumonly", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.chat, "Enable URL Detection", C.chat.text, "detecturl", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.chat, "Enable Class Colors", C.chat.text, "classcolor", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.chat, "Left Chat Width", C.chat.left, "width")