From 2a3466cbbb91f2859f68ee170cd784fff1867d77 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Wed, 15 Nov 2023 01:38:01 +0100 Subject: [PATCH] [MIRROR] [NO GBP] Emote Panel TGUI, now should be fixed [MDB IGNORE] (#25021) * [NO GBP] Emote Panel TGUI, now should be fixed (#79481) * [NO GBP] Emote Panel TGUI, now should be fixed --------- Co-authored-by: larentoun <31931237+larentoun@users.noreply.github.com> --- code/datums/emotes.dm | 5 + code/modules/emote_panel/emote_panel.dm | 64 +++++ code/modules/mob/living/carbon/emote.dm | 1 + code/modules/mob/living/emote.dm | 4 + tgstation.dme | 1 + tgui/packages/tgui/interfaces/EmotePanel.tsx | 283 +++++++++++++++++++ 6 files changed, 358 insertions(+) create mode 100644 code/modules/emote_panel/emote_panel.dm create mode 100644 tgui/packages/tgui/interfaces/EmotePanel.tsx diff --git a/code/datums/emotes.dm b/code/datums/emotes.dm index 88db5948d53..9a4a2f263e6 100644 --- a/code/datums/emotes.dm +++ b/code/datums/emotes.dm @@ -14,6 +14,8 @@ var/key = "" /// This will also call the emote. var/key_third_person = "" + /// Needed for more user-friendly emote names, so emotes with keys like "aflap" will show as "flap angry". Defaulted to key. + var/name = "" /// Message displayed when emote is used. var/message = "" /// Message displayed if the user is a mime. @@ -77,6 +79,9 @@ mob_type_blacklist_typecache = typecacheof(mob_type_blacklist_typecache) mob_type_ignore_stat_typecache = typecacheof(mob_type_ignore_stat_typecache) + if(!name) + name = key + /** * Handles the modifications and execution of emotes. * diff --git a/code/modules/emote_panel/emote_panel.dm b/code/modules/emote_panel/emote_panel.dm new file mode 100644 index 00000000000..72caf05e92b --- /dev/null +++ b/code/modules/emote_panel/emote_panel.dm @@ -0,0 +1,64 @@ +/datum/emote_panel + var/list/blacklisted_emotes = list("me", "help") + +/datum/emote_panel/ui_static_data(mob/user) + var/list/data = list() + + var/list/emotes = list() + var/list/keys = list() + + for(var/key in GLOB.emote_list) + for(var/datum/emote/emote in GLOB.emote_list[key]) + if(emote.key in keys) + continue + if(emote.key in blacklisted_emotes) + continue + if(emote.can_run_emote(user, status_check = FALSE, intentional = FALSE)) + keys += emote.key + emotes += list(list( + "key" = emote.key, + "name" = emote.name, + "hands" = emote.hands_use_check, + "visible" = emote.emote_type & EMOTE_VISIBLE, + "audible" = emote.emote_type & EMOTE_AUDIBLE, + "sound" = !isnull(emote.get_sound(user)), + "use_params" = emote.message_param, + )) + + data["emotes"] = emotes + + return data + +/datum/emote_panel/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) + . = ..() + if(.) + return + switch(action) + if("play_emote") + var/emote_key = params["emote_key"] + if(isnull(emote_key) || !GLOB.emote_list[emote_key]) + return + var/use_params = params["use_params"] + var/datum/emote/emote = GLOB.emote_list[emote_key][1] + var/emote_param + if(emote.message_param && use_params) + emote_param = tgui_input_text(ui.user, "Add params to the emote...", emote.message_param) + ui.user.emote(emote_key, message = emote_param, intentional = TRUE) + +/datum/emote_panel/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "EmotePanel") + ui.open() + +/datum/emote_panel/ui_state(mob/user) + return GLOB.always_state + +/mob/living/verb/emote_panel() + set name = "Emote Panel" + set category = "IC" + + var/static/datum/emote_panel/emote_panel + if(isnull(emote_panel)) + emote_panel = new + emote_panel.ui_interact(src) diff --git a/code/modules/mob/living/carbon/emote.dm b/code/modules/mob/living/carbon/emote.dm index 10005fd1601..8d1599d0e80 100644 --- a/code/modules/mob/living/carbon/emote.dm +++ b/code/modules/mob/living/carbon/emote.dm @@ -13,6 +13,7 @@ /datum/emote/living/carbon/blink_r key = "blink_r" + name = "blink (Rapid)" message = "blinks rapidly." //SKYRAT EDIT REMOVAL BEGIN - EMOTES - (Moved to modular_skyrat/modules/emotes/code/emotes.dm as /datum/emote/living/clap) diff --git a/code/modules/mob/living/emote.dm b/code/modules/mob/living/emote.dm index a434f894082..5b91f400f4c 100644 --- a/code/modules/mob/living/emote.dm +++ b/code/modules/mob/living/emote.dm @@ -167,6 +167,7 @@ /datum/emote/living/flap/aflap key = "aflap" key_third_person = "aflaps" + name = "flap (Angry)" message = "flaps their wings ANGRILY!" hands_use_check = TRUE wing_time = 10 @@ -194,6 +195,7 @@ /datum/emote/living/gasp_shock key = "gaspshock" key_third_person = "gaspsshock" + name = "gasp (Shock)" message = "gasps in shock!" message_mime = "gasps in silent shock!" emote_type = EMOTE_VISIBLE | EMOTE_AUDIBLE @@ -529,6 +531,7 @@ /datum/emote/living/twitch_s key = "twitch_s" + name = "twitch (Slight)" message = "twitches." /datum/emote/living/twitch_s/run_emote(mob/living/user, params, type_override, intentional) @@ -553,6 +556,7 @@ /datum/emote/living/wsmile key = "wsmile" key_third_person = "wsmiles" + name = "smile (Weak)" message = "smiles weakly." /// The base chance for your yawn to propagate to someone else if they're on the same tile as you diff --git a/tgstation.dme b/tgstation.dme index db2c9bcac64..6ff7ccb515f 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -3822,6 +3822,7 @@ #include "code\modules\economy\account.dm" #include "code\modules\economy\holopay.dm" #include "code\modules\emoji\emoji_parse.dm" +#include "code\modules\emote_panel\emote_panel.dm" #include "code\modules\error_handler\error_handler.dm" #include "code\modules\error_handler\error_viewer.dm" #include "code\modules\escape_menu\details.dm" diff --git a/tgui/packages/tgui/interfaces/EmotePanel.tsx b/tgui/packages/tgui/interfaces/EmotePanel.tsx new file mode 100644 index 00000000000..81df0512362 --- /dev/null +++ b/tgui/packages/tgui/interfaces/EmotePanel.tsx @@ -0,0 +1,283 @@ +import { useBackend, useLocalState } from '../backend'; +import { Window } from '../layouts'; +import { Button, Section, Flex, Icon, Box } from '../components'; +import { BooleanLike } from '../../common/react'; +import { SearchBar } from './Fabrication/SearchBar'; +import { capitalizeFirst } from '../../common/string'; + +type Emote = { + key: string; + name: string; + hands: BooleanLike; + visible: BooleanLike; + audible: BooleanLike; + sound: BooleanLike; + use_params: BooleanLike; +}; + +type EmotePanelData = { + emotes: Emote[]; +}; + +export const EmotePanelContent = (props, context) => { + const { act, data } = useBackend(context); + const { emotes } = data; + + const [filterVisible, toggleVisualFilter] = useLocalState( + context, + 'filterVisible', + false + ); + + const [filterAudible, toggleAudibleFilter] = useLocalState( + context, + 'filterAudible', + false + ); + + const [filterSound, toggleSoundFilter] = useLocalState( + context, + 'filterSound', + false + ); + + const [filterHands, toggleHandsFilter] = useLocalState( + context, + 'filterHands', + false + ); + + const [filterUseParams, toggleUseParamsFilter] = useLocalState( + context, + 'filterUseParams', + false + ); + + const [useParams, toggleUseParams] = useLocalState( + context, + 'useParams', + false + ); + + const [searchText, setSearchText] = useLocalState( + context, + 'search_text', + '' + ); + + const [showNames, toggleShowNames] = useLocalState( + context, + 'showNames', + true + ); + + const [showIcons, toggleShowIcons] = useLocalState( + context, + 'showIcons', + false + ); + + return ( +
+
+
+
0 + ? `Search results of "${searchText}"` + : `All Emotes` + } + buttons={ + + + + + + + + + + }> + + + {emotes + .filter( + (emote) => + emote.key && + (searchText.length > 0 + ? emote.key + .toLowerCase() + .includes(searchText.toLowerCase()) || + emote.name.toLowerCase().includes(searchText.toLowerCase()) + : true) && + (filterVisible ? emote.visible : true) && + (filterAudible ? emote.audible : true) && + (filterSound ? emote.sound : true) && + (filterHands ? emote.hands : true) && + (filterUseParams ? emote.use_params : true) + ) + .sort((a, b) => (a.name > b.name ? 1 : -1)) + .map((emote) => ( + + ))} + + +
+
+ ); +}; + +const EmoteIcons = (props, context) => { + const { visible, audible, sound, hands, use_params, margin } = props; + + return ( + + + + + + + + ); +}; + +export const EmotePanel = (props, context) => { + return ( + + + + + + ); +};