mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-11 01:13:18 +00:00
Makes the code compatible with 515.1594+
Few simple changes and one very painful one.
Let's start with the easy:
* puts call behind `LIBCALL` define, so call_ext is properly used in 515
* Adds `NAMEOF_STATIC(_,X)` macro for nameof in static definitions since
src is now invalid there.
* Fixes tgui and devserver. From 515 onward the tmp3333{procid} cache
directory is not appened to base path in browser controls so we don't
check for it in base js and put the dev server dummy window file in
actual directory not the byond root.
* Renames the few things that had /final/ in typepath to ultimate since
final is a new keyword
And the very painful change:
`.proc/whatever` format is no longer valid, so we're replacing it with
new nameof() function. All this wrapped in three new macros.
`PROC_REF(X)`,`TYPE_PROC_REF(TYPE,X)`,`GLOBAL_PROC_REF(X)`. Global is
not actually necessary but if we get nameof that does not allow globals
it would be nice validation.
This is pretty unwieldy but there's no real alternative.
If you notice anything weird in the commits let me know because majority
was done with regex replace.
@tgstation/commit-access Since the .proc/stuff is pretty big change.
Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
51 lines
2.1 KiB
Plaintext
51 lines
2.1 KiB
Plaintext
/**
|
|
* Component that allows for highlighting of words or phrases in chat based on regular expressions.
|
|
*
|
|
* Hooks into the parent's COMSIG_MOVABLE_HEAR signal to wrap every regex match in the message
|
|
* between <span class=''></span> tags with the provided span class. This modifies the output that
|
|
* is sent to the parent's chat window.
|
|
*
|
|
* Removal of this component should be done by calling [GetComponents(/datum/component/codeword_hearing)]
|
|
* on the parent and then iterating through all components calling [delete_if_from_source(source)].
|
|
*/
|
|
/datum/component/codeword_hearing
|
|
dupe_mode = COMPONENT_DUPE_ALLOWED
|
|
|
|
/// Regex for matching words or phrases you want highlighted.
|
|
var/regex/replace_regex
|
|
/// The <span class=''> to use for highlighting matches.
|
|
var/span_class
|
|
/// The source of this component. Used to identify the source in delete_if_from_source since this component is COMPONENT_DUPE_ALLOWED.
|
|
var/source
|
|
|
|
/datum/component/codeword_hearing/Initialize(regex/codeword_regex, highlight_span_class, component_source)
|
|
if(!ismovable(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
|
|
replace_regex = codeword_regex
|
|
span_class = highlight_span_class
|
|
source = component_source
|
|
return ..()
|
|
|
|
/datum/component/codeword_hearing/RegisterWithParent()
|
|
RegisterSignal(parent, COMSIG_MOVABLE_HEAR, PROC_REF(handle_hearing))
|
|
|
|
/datum/component/codeword_hearing/UnregisterFromParent()
|
|
UnregisterSignal(parent, COMSIG_MOVABLE_HEAR)
|
|
|
|
/// Callback for COMSIG_MOVABLE_HEAR which highlights syndicate code phrases in chat.
|
|
/datum/component/codeword_hearing/proc/handle_hearing(datum/source, list/hearing_args)
|
|
SIGNAL_HANDLER
|
|
|
|
var/message = hearing_args[HEARING_RAW_MESSAGE]
|
|
message = replace_regex.Replace(message, "<span class='[span_class]'>$1</span>")
|
|
hearing_args[HEARING_RAW_MESSAGE] = message
|
|
|
|
/// Since a parent can have multiple of these components on them simultaneously, this allows a datum to delete components from a specific source.
|
|
/datum/component/codeword_hearing/proc/delete_if_from_source(component_source)
|
|
if(source == component_source)
|
|
qdel(src)
|
|
return TRUE
|
|
|
|
return FALSE
|