From fcf2dbfa02609bfee7a55437c1a38ad64508a86e Mon Sep 17 00:00:00 2001
From: tralezab <40974010+tralezab@users.noreply.github.com>
Date: Tue, 22 Oct 2019 20:19:21 -0700
Subject: [PATCH] [READY] Mime PDAs only accept emojis for messages, mime
cartridge comes with an emoji guidebook (#47177)
* relic file
* Revert "Merge branch 'master' of https://github.com/tralezab/tgstation"
This reverts commit 826916d87b421dbb0ebcfce7fad96e456b6d3674, reversing
changes made to a0f476d8746fa0d78f8a4b1363bd95fd265c2479.
* mime pda
* hey maybe it works
* some steps forward
* IT WORKS HAHAHA YAAAAAAAAAAAAAAAAA
* logged properly in everything
---
code/game/objects/items/devices/PDA/PDA.dm | 16 ++++++++--
.../objects/items/devices/PDA/PDA_types.dm | 28 +++++++++++++-----
code/game/objects/items/devices/PDA/cart.dm | 18 +++++++++++
code/modules/client/asset_cache.dm | 3 +-
code/modules/emoji/emoji_parse.dm | 21 ++++++++++++-
icons/pda_icons/pda_emoji.png | Bin 0 -> 2892 bytes
6 files changed, 75 insertions(+), 11 deletions(-)
create mode 100644 icons/pda_icons/pda_emoji.png
diff --git a/code/game/objects/items/devices/PDA/PDA.dm b/code/game/objects/items/devices/PDA/PDA.dm
index 6a86522e0bc..1785e22aded 100644
--- a/code/game/objects/items/devices/PDA/PDA.dm
+++ b/code/game/objects/items/devices/PDA/PDA.dm
@@ -64,6 +64,7 @@ GLOBAL_LIST_EMPTY(PDAs)
var/hidden = FALSE // Is the PDA hidden from the PDA list?
var/emped = FALSE
var/equipped = FALSE //used here to determine if this is the first time its been picked up
+ var/allow_emojis = FALSE //if the pda can send emojis and actually have them parsed as such
var/obj/item/card/id/id = null //Making it possible to slot an ID card into the PDA so it can function as both.
var/ownjob = null //related to above
@@ -270,6 +271,8 @@ GLOBAL_LIST_EMPTY(PDAs)
dat += "
[PDAIMG(medbot)]Bots Access"
if (cartridge.access & CART_JANITOR)
dat += "[PDAIMG(bucket)]Custodial Locator"
+ if(cartridge.access & CART_MIME)
+ dat += "[PDAIMG(emoji)]Emoji Guidebook"
if (istype(cartridge.radio))
dat += "[PDAIMG(signaler)]Signaler System"
if (cartridge.access & CART_NEWSCASTER)
@@ -634,7 +637,8 @@ GLOBAL_LIST_EMPTY(PDAs)
"name" = "[owner]",
"job" = "[ownjob]",
"message" = message,
- "targets" = string_targets
+ "targets" = string_targets,
+ "emojis" = allow_emojis,
))
if (picture)
signal.data["photo"] = picture
@@ -646,6 +650,10 @@ GLOBAL_LIST_EMPTY(PDAs)
return
var/target_text = signal.format_target()
+ if(allow_emojis)
+ message = emoji_parse(message)//already sent- this just shows the sent emoji as one to the sender in the to_chat
+ signal.data["message"] = emoji_parse(signal.data["message"])
+
// Log it in our logs
tnote += "→ To [target_text]:
[signal.format_message()]
"
// Show it to ghosts
@@ -687,7 +695,11 @@ GLOBAL_LIST_EMPTY(PDAs)
if(signal.data["automated"])
reply = "\[Automated Message\]"
- to_chat(L, "[icon2html(src)] Message from [hrefstart][signal.data["name"]] ([signal.data["job"]])[hrefend], [signal.format_message()] [reply]")
+ var/inbound_message = signal.format_message()
+ if(signal.data["emojis"] == TRUE)//so will not parse emojis as such from pdas that don't send emojis
+ inbound_message = emoji_parse(inbound_message)
+
+ to_chat(L, "[icon2html(src)] Message from [hrefstart][signal.data["name"]] ([signal.data["job"]])[hrefend], [inbound_message] [reply]")
update_icon()
add_overlay(icon_alert)
diff --git a/code/game/objects/items/devices/PDA/PDA_types.dm b/code/game/objects/items/devices/PDA/PDA_types.dm
index 2b3d8b94c33..8c7c3115fbf 100644
--- a/code/game/objects/items/devices/PDA/PDA_types.dm
+++ b/code/game/objects/items/devices/PDA/PDA_types.dm
@@ -17,6 +17,27 @@
if(istype(cart) && cart.charges < 5)
cart.charges++
+//Mime PDA sends "silent" messages.
+/obj/item/pda/mime
+ name = "mime PDA"
+ default_cartridge = /obj/item/cartridge/virus/mime
+ inserted_item = /obj/item/toy/crayon/mime
+ icon_state = "pda-mime"
+ desc = "A portable microcomputer by Thinktronic Systems, LTD. The hardware has been modified for compliance with the vows of silence."
+ allow_emojis = TRUE
+ silent = TRUE
+ ttone = "silence"
+
+/obj/item/pda/mime/msg_input(mob/living/U = usr)
+ if(emped || toff)
+ return
+ var/emojis = emoji_sanitize(stripped_input(U, "Please enter emojis", name))
+ if(!emojis)
+ return
+ if(!U.canUseTopic(src, BE_CLOSE))
+ return
+ return emojis
+
// Special AI/pAI PDAs that cannot explode.
/obj/item/pda/ai
icon = null
@@ -78,13 +99,6 @@
icon_state = "pda-science"
ttone = "boom"
-/obj/item/pda/mime
- name = "mime PDA"
- default_cartridge = /obj/item/cartridge/virus/mime
- inserted_item = /obj/item/toy/crayon/mime
- icon_state = "pda-mime"
- silent = TRUE
- ttone = "silence"
/obj/item/pda/heads
default_cartridge = /obj/item/cartridge/head
diff --git a/code/game/objects/items/devices/PDA/cart.dm b/code/game/objects/items/devices/PDA/cart.dm
index c23e8445635..57061bc07ae 100644
--- a/code/game/objects/items/devices/PDA/cart.dm
+++ b/code/game/objects/items/devices/PDA/cart.dm
@@ -1,3 +1,4 @@
+
#define CART_SECURITY (1<<0)
#define CART_ENGINE (1<<1)
#define CART_ATMOS (1<<2)
@@ -43,6 +44,7 @@
var/list/powermonitors = list()
var/message1 // used for status_displays
var/message2
+ var/emoji_preview = "" //which emoji will be sent to chat in a preview
var/list/stored_data = list()
var/current_channel
@@ -559,6 +561,17 @@ Code:
if (54) // Beepsky, Medibot, Floorbot, and Cleanbot access
menu = "[PDAIMG(medbot)] Bots Interlink
"
bot_control()
+ if (55) // Emoji Guidebook for mimes
+ menu = "[PDAIMG(emoji)] Emoji Guidebook
"
+ var/static/list/emoji_icon_states
+ var/breakcounter = FALSE
+ if(!emoji_icon_states)
+ emoji_icon_states = icon_states(icon('icons/emoji.dmi'))
+ menu += "
To use an emoji in a pda message, refer to the guide and add \":\" around the emoji. Click on any of the emojis to preview it.
"
+ for(var/emoji in emoji_icon_states)
+ var/preview_link = "[emoji]" //broken, on opening the menu it sends every single emoji because it is executing the proc to find the choice as soon as it is loaded
+ menu += "[breakcounter ? "
" : ""][preview_link][breakcounter ? " || " : "" ]"
+ breakcounter = !breakcounter
if (99) //Newscaster message permission error
menu = " ERROR : NOT AUTHORIZED [host_pda.id ? "" : "- ID SLOT EMPTY"]
"
@@ -647,6 +660,11 @@ Code:
host_pda.Topic(null,list("choice"=num2text(host_pda.mode)))
return
+ //emoji previews
+ if(href_list["emoji"])
+ var/parse = emoji_parse(":[href_list["emoji"]]:")
+ to_chat(usr, parse)
+
//Bot control section! Viciously ripped from radios for being laggy and terrible.
if(href_list["op"])
switch(href_list["op"])
diff --git a/code/modules/client/asset_cache.dm b/code/modules/client/asset_cache.dm
index 0d983098476..ff1eac08238 100644
--- a/code/modules/client/asset_cache.dm
+++ b/code/modules/client/asset_cache.dm
@@ -468,7 +468,8 @@ GLOBAL_LIST_EMPTY(asset_datums)
"scanner" = 'icons/pda_icons/pda_scanner.png',
"signaler" = 'icons/pda_icons/pda_signaler.png',
"status" = 'icons/pda_icons/pda_status.png',
- "dronephone" = 'icons/pda_icons/pda_dronephone.png'
+ "dronephone" = 'icons/pda_icons/pda_dronephone.png',
+ "emoji" = 'icons/pda_icons/pda_emoji.png'
)
/datum/asset/spritesheet/simple/paper
diff --git a/code/modules/emoji/emoji_parse.dm b/code/modules/emoji/emoji_parse.dm
index 2f4a84c6463..8e399d8ca18 100644
--- a/code/modules/emoji/emoji_parse.dm
+++ b/code/modules/emoji/emoji_parse.dm
@@ -1,4 +1,4 @@
-/proc/emoji_parse(text)
+/proc/emoji_parse(text) //turns :ai: into an emoji in text.
. = text
if(!CONFIG_GET(flag/emojis))
return
@@ -30,3 +30,22 @@
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/static/list/emojis = icon_states(icon('icons/emoji.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+1)
+ if(search)
+ final += lowertext(copytext(text, pos, search+1))
+ pos = search + 1
+ continue
+ break
+ return final
diff --git a/icons/pda_icons/pda_emoji.png b/icons/pda_icons/pda_emoji.png
new file mode 100644
index 0000000000000000000000000000000000000000..39f789f5207babf1a4cf8dc42aae5d8bd3830f09
GIT binary patch
literal 2892
zcmV-S3$yfzP)004&%004{+008|`004nN004b?008NW002DY000@xb3BE2000Uv
zX+uL$Nkc;*P;zf(X>4Tx07%E3mUmQC*A|D*y?1({%`gH|hTglt0MdJtUPWP;8DJ;_
z4l^{dA)*2iMMRn+NKnLp(NH8-M6nPQRImpm2q-ZaMN}+rM%Ih2ti1Q~^84egZ|$@9
zx%=$B&srA%lBX}1mj+7#kjfMAgFKw+5s^`J>;QlP9$S?PR%=$HTzo3l9?ED;xoI3-JvF1F8#m>QQXW*8-A
zz9>Nv%ZWK*kqtikEV84R*{M9Xh{ZXlvs2k(?iKO2Od&_ah_8qXGr62B5#JKAMv5?%
zE8;ie*i;TP0{|3BY!`4?i6S-;F^L}%f`(o2L0Dz>ZZynda
zx(`h}FNp#{x{a}MR#uh~m%}m=7xWMPPlvyuufAs_KJJh5&|Nw4Oks+EF0LCZEhSCJ
zr)Q)ySsc3IpNIG#2mW;)20@&74xhslMTCi_jLS<9wVTK03b<)JI+ypKn)naH{-njZ
z7KzgM5l~}{fYfy=Kz{89C<+lE(fh?+|D$id_%I-TdEqLPi*x_)H~nY9rQ#)noA5c#
zB`Ac>67n+__r%Wu$9dISw03U@r;Pdb`_%=KWKZEBGfDjQH
zqKX(I48#TTN1~8;gpaI8ijWGV0cl0Lkv`-mGK$O~Z&4T&1w}_0qHIx~s8AFOwFb2w
zRf4KU9Y%GadQmq~W2jlwM>H9&h}K8jpuNx$=mc~Yx)5D~ZbG-CFQRXwC(y4k7z_=g
zjj_UbVj?j~n6;P^%sxyT<{V}aGme?VVzKgAeXJeUAIroFu!Yzv>{0Al>=1SW`vynE
zso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