Chat markup (#441)

Enables you to use Skype/Discord style mark-up in OOC, LOOC, and IC chat.
This commit is contained in:
skull132
2016-06-23 16:44:33 +03:00
committed by GitHub
parent b70cbfac22
commit 83253fc1f7
7 changed files with 48 additions and 0 deletions
+25
View File
@@ -314,3 +314,28 @@ proc/TextPreview(var/string,var/len=40)
if(C && (C.prefs.toggles & CHAT_NOICONS))
return tagdesc
return "<IMG src='\ref[text_tag_icons.icon]' class='text_tag' iconstate='[tagname]'" + (tagdesc ? " alt='[tagdesc]'" : "") + ">"
// For processing simple markup, similar to what Skype and Discord use.
// Enabled from a config setting.
/proc/process_chat_markup(var/message, var/list/ignore_tags = list())
if (!config.allow_chat_markup)
return message
if (!message)
return ""
var/list/tags = list("*" = list("<b>", "</b>"),
"/" = list("<i>", "</i>"),
"_" = list("<i>", "</i>"))
if (ignore_tags && ignore_tags.len)
tags -= ignore_tags
for (var/tag in tags)
var/marker_begin = tags[tag][1]
var/marker_end = tags[tag][2]
var/regex/markup = new("(\\[tag])(\[^\\[tag]\]*)(\\[tag])", "g")
message = markup.Replace(message, "[marker_begin]$2[marker_end]")
return message
+6
View File
@@ -222,6 +222,9 @@ var/list/gamemode_cache = list()
var/client_warn_version = 0
var/client_warn_message = ""
//Mark-up enabling
var/allow_chat_markup = 0
/datum/configuration/New()
var/list/L = typesof(/datum/game_mode) - /datum/game_mode
for (var/T in L)
@@ -712,6 +715,9 @@ var/list/gamemode_cache = list()
if("client_warn_message")
config.client_warn_message = value
if("allow_chat_markup")
config.allow_chat_markup = 1
else
log_misc("Unknown setting in configuration: '[name]'")
+4
View File
@@ -49,6 +49,8 @@
if(holder.rights & R_ADMIN)
ooc_style = "admin"
msg = process_chat_markup(msg, list("*"))
for(var/client/target in clients)
if(target.prefs.toggles & CHAT_OOC)
var/display_name = src.key
@@ -113,6 +115,8 @@
if(source.stat != DEAD)
display_name = source.name
msg = process_chat_markup(msg, list("*"))
var/prefix
var/admin_stuff
for(var/client/target in clients)
+2
View File
@@ -144,6 +144,8 @@ proc/get_radio_key_from_channel(var/channel)
var/message_mode = parse_message_mode(message, "headset")
message = process_chat_markup(message)
switch(copytext(message,1,2))
if("*") return emote(copytext(message,2))
if("^") return custom_emote(1, copytext(message,2))
+2
View File
@@ -58,6 +58,8 @@
usr << "<span class='danger'>You have deadchat muted.</span>"
return
message = process_chat_markup(message)
say_dead_direct("[pick("complains","moans","whines","laments","blubbers")], <span class='message'>\"[message]\"</span>", src)
/mob/proc/say_understands(var/mob/other,var/datum/language/speaking = null)
+3
View File
@@ -388,3 +388,6 @@ STARLIGHT 0
#CLIENT_ERROR_MESSAGE Your version of BYOND is not supported. Please upgrade.
#CLIENT_WARN_VERSION 510
#CLIENT_WARN_MESSAGE BYOND is really close to releasing 510 beta as a stable release, please take time to try it out. Reports are that the client preforms better then the version you are using, and also handles network lag better. Shortly after it's release we will end up using 510 client features and you will be forced to update.
## Uncomment to enable simple Skype/Discord style markup over OOC, LOOC, and say.
#ALLOW_CHAT_MARKUP
+6
View File
@@ -0,0 +1,6 @@
author: Skull132
delete-after: True
changes:
- rscadd: "Adds Skype/Discord style mark-up to OOC, LOOC, and say. The tags that can be used are: *, /, and _. Bold is disabled by default over OOC channels."