mirror of
https://github.com/Citadel-Station-13/Citadel-Station-13-RP.git
synced 2026-08-30 16:56:45 +01:00
refactors the asset subsystem to make it much more managed adds support for 'deferred' assets for tgui, which will be later used for things like tgui character setup and admin panels. deferred means that it'll be 'sent in a timely manner after the ui opens', as opposed to 'sent before the ui opens' --------- Co-authored-by: silicons <no@you.cat>
60 lines
2.0 KiB
Plaintext
60 lines
2.0 KiB
Plaintext
// todo: redo this, it should be tgui-native
|
|
/proc/emoji_parse(text) //turns :ai: into an emoji in text.
|
|
. = text
|
|
if(!CONFIG_GET(flag/emojis))
|
|
return
|
|
var/parsed = ""
|
|
var/pos = 1
|
|
var/search = 0
|
|
var/emoji = ""
|
|
while(1)
|
|
search = findtext(text, ":", pos)
|
|
parsed += copytext(text, pos, search)
|
|
if(search)
|
|
pos = search
|
|
search = findtext(text, ":", pos + length(text[pos]))
|
|
if(search)
|
|
emoji = lowertext(copytext(text, pos + length(text[pos]), search))
|
|
var/isthisapath = (emoji[1] == "/") && text2path(emoji)
|
|
var/datum/asset_pack/spritesheet/sheet = SSassets.ready_asset_pack(/datum/asset_pack/spritesheet/chat)
|
|
var/tag = sheet.icon_tag("emoji-[emoji]")
|
|
if(tag)
|
|
parsed += SPAN_TOOLTIP(":[emoji]:", "<i style='width:16px !important;height:16px !important;'>[tag]</i>") //evil way of enforcing 16x16
|
|
pos = search + length(text[pos])
|
|
else if(ispath(isthisapath, /atom)) //path
|
|
var/atom/thisisanatom = isthisapath
|
|
parsed += SPAN_TOOLTIP(":[isthisapath]:", "[icon2html(initial(thisisanatom.icon), world, initial(thisisanatom.icon_state))]")
|
|
pos = search + length(text[pos])
|
|
else
|
|
parsed += copytext(text, pos, search)
|
|
pos = search
|
|
emoji = ""
|
|
continue
|
|
else
|
|
parsed += copytext(text, pos, search)
|
|
break
|
|
return parsed
|
|
|
|
/proc/emoji_sanitize(text) //cuts any text that would not be parsed as an emoji
|
|
. = text
|
|
if(!CONFIG_GET(flag/emojis))
|
|
return
|
|
var/list/emojis = icon_states(icon('icons/ui_icons/emoji/emoji.dmi'))
|
|
emojis |= icon_states(icon('icons/ui_icons/emoji/emoji32.dmi'))
|
|
var/final = "" //only tags are added to this
|
|
var/pos = 1
|
|
var/search = 0
|
|
while(1)
|
|
search = findtext(text, ":", pos)
|
|
if(search)
|
|
pos = search
|
|
search = findtext(text, ":", pos + length(text[pos]))
|
|
if(search)
|
|
var/word = lowertext(copytext(text, pos + length(text[pos]), search))
|
|
if(word in emojis)
|
|
final += lowertext(copytext(text, pos, search + length(text[search])))
|
|
pos = search + length(text[search])
|
|
continue
|
|
break
|
|
return final
|