mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-28 07:38:05 +01:00
## About The Pull Request This adds a button next to sound emotes in the emote panel, allowing you to preview the emote sound without actually having to do said emote. The sound just plays for the user - nobody else hears it, it's just a `SEND_SOUND` https://github.com/user-attachments/assets/d4774769-c4ff-4d2a-98c9-2c8095b66998 (im not sure how nicely to fix that issue with the "Gasp (Shock)" button, tho) also cleaned up emote panel tgui a bit. ## Why It's Good For The Game Makes it easier to know what emote sounds like what without confusing people about why you're making 50 different sounds lol ## Changelog 🆑 qol: You can now preview what different emotes sound like via the emote panel. /🆑
68 lines
2.2 KiB
Plaintext
68 lines
2.2 KiB
Plaintext
/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, max_length = MAX_MESSAGE_LEN)
|
|
ui.user.emote(emote_key, message = emote_param, intentional = TRUE)
|
|
if("preview_sound")
|
|
var/emote_key = params["emote_key"]
|
|
if(isnull(emote_key) || !GLOB.emote_list[emote_key])
|
|
return
|
|
var/datum/emote/emote = GLOB.emote_list[emote_key][1]
|
|
var/emote_sound = get_sfx(emote.get_sound(ui.user))
|
|
if(!emote_sound)
|
|
to_chat(ui.user, span_warning("Couldn't get a preview sound for [emote.name]."), type = MESSAGE_TYPE_INFO)
|
|
return
|
|
SEND_SOUND(ui.user, sound(emote_sound, volume = 75))
|
|
to_chat(ui.user, span_warning("Previewed sound for [emote.name]."), type = MESSAGE_TYPE_INFO)
|
|
|
|
/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.set_autoupdate(FALSE)
|
|
ui.open()
|
|
|
|
/datum/emote_panel/ui_state(mob/user)
|
|
return GLOB.always_state
|