mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-18 19:44:58 +01:00
Adds linking datums in asay (#65154)
This commit is contained in:
@@ -967,3 +967,36 @@ GLOBAL_DATUM_INIT(admin_help_ui_handler, /datum/admin_help_ui_handler, new)
|
||||
if(length(admins_to_ping))
|
||||
admins_to_ping[ADMINSAY_PING_UNDERLINE_NAME_INDEX] = jointext(msglist, " ") // without tuples, we must make do!
|
||||
return admins_to_ping
|
||||
|
||||
/**
|
||||
* Checks a given message to see if any of the words contain a memory ref for a datum. Said ref should not have brackets around it
|
||||
*
|
||||
* Returns nothing if no refs are found, otherwise returns an associative list with ckey -> client
|
||||
* Also modifies msg to underline and linkify the [ref] so other admins can click on the address to open the VV entry for said datum
|
||||
*
|
||||
* Arguments:
|
||||
* * msg - the message being scanned
|
||||
*/
|
||||
/proc/check_memory_refs(msg)
|
||||
if(!findtext(msg, GLOB.is_memref))
|
||||
return
|
||||
|
||||
//explode the input msg into a list
|
||||
var/list/msglist = splittext(msg, " ")
|
||||
var/list/datums_to_ref = list()
|
||||
|
||||
var/i = 0
|
||||
for(var/word in msglist)
|
||||
i++
|
||||
if(!length(word))
|
||||
continue
|
||||
var/word_with_brackets = "\[[word]\]" // the actual memory address lookups need the bracket wraps
|
||||
var/datum/check_datum = locate(word_with_brackets)
|
||||
if(!istype(check_datum))
|
||||
continue
|
||||
msglist[i] = "<u><a href='?_src_=vars;[HrefToken(TRUE)];Vars=[word_with_brackets]'>[word_with_brackets]</A></u>"
|
||||
datums_to_ref[word] = word
|
||||
|
||||
if(length(datums_to_ref))
|
||||
datums_to_ref[ADMINSAY_LINK_DATUM_REF] = jointext(msglist, " ") // without tuples, we must make do!
|
||||
return datums_to_ref
|
||||
|
||||
@@ -21,6 +21,12 @@
|
||||
window_flash(iter_admin_client)
|
||||
SEND_SOUND(iter_admin_client.mob, sound('sound/misc/asay_ping.ogg'))
|
||||
|
||||
|
||||
var/list/linked_datums = check_memory_refs(msg)
|
||||
if(length(linked_datums) && linked_datums[ADMINSAY_LINK_DATUM_REF])
|
||||
msg = linked_datums[ADMINSAY_LINK_DATUM_REF]
|
||||
linked_datums -= ADMINSAY_LINK_DATUM_REF
|
||||
|
||||
mob.log_talk(msg, LOG_ASAY)
|
||||
msg = keywords_lookup(msg)
|
||||
var/asay_color = prefs.read_preference(/datum/preference/color/asay_color)
|
||||
|
||||
@@ -42,9 +42,15 @@
|
||||
sprite_text = no_icon? "\[NO ICON\]" : "<img src='vv[hash].png'></td><td>"
|
||||
var/list/header = islist(D)? list("<b>/list</b>") : D.vv_get_header()
|
||||
|
||||
var/ref_line = copytext(refid, 2, -1) // get rid of the brackets
|
||||
|
||||
var/marked_line
|
||||
if(holder && holder.marked_datum && holder.marked_datum == D)
|
||||
marked_line = VV_MSG_MARKED
|
||||
var/tagged_line
|
||||
if(holder && LAZYFIND(holder.tagged_datums, D))
|
||||
var/tag_index = LAZYFIND(holder.tagged_datums, D)
|
||||
tagged_line = VV_MSG_TAGGED(tag_index)
|
||||
var/varedited_line
|
||||
if(!islist && (D.datum_flags & DF_VAR_EDITED))
|
||||
varedited_line = VV_MSG_EDITED
|
||||
@@ -211,7 +217,9 @@
|
||||
</table>
|
||||
<div align='center'>
|
||||
<b><font size='1'>[formatted_type]</font></b>
|
||||
<br><b><font size='1'>[ref_line]</font></b>
|
||||
<span id='marked'>[marked_line]</span>
|
||||
<span id='tagged'>[tagged_line]</span>
|
||||
<span id='varedited'>[varedited_line]</span>
|
||||
<span id='deleted'>[deleted_line]</span>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user