From 8018a54e20939884ab020e4e96c20f37d2c344da Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Fri, 1 Nov 2024 20:57:20 +0300 Subject: [PATCH] TTS interrupt signal (#1612) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Что этот PR делает Добавляет поддержку для отмены произведения ТТСа по сигналу ## Почему это хорошо для игры ГБСы не должны говорить ТТСом на языке щелк-щелк --- modular_ss220/text_to_speech/code/_defines.dm | 5 ++++- modular_ss220/text_to_speech/code/tts_atom.dm | 3 +++ modular_ss220/text_to_speech/code/~undefs/~undefs.dm | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/modular_ss220/text_to_speech/code/_defines.dm b/modular_ss220/text_to_speech/code/_defines.dm index 1e46ef58ef60..0b79803da0d2 100644 --- a/modular_ss220/text_to_speech/code/_defines.dm +++ b/modular_ss220/text_to_speech/code/_defines.dm @@ -83,9 +83,12 @@ //from base of atom/change_tts_seed(): (mob/chooser, override, fancy_voice_input_tgui) #define COMSIG_ATOM_TTS_SEED_CHANGE "atom_tts_seed_change" -//called for tts_component: (atom/speaker, mob/listener, message, atom/location, is_local, effect, traits, preSFX, postSFX) +//called for tts_component: (mob/listener, message, atom/location, is_local, effect, traits, preSFX, postSFX) #define COMSIG_ATOM_TTS_CAST "atom_tts_cast" //from base of atom/tts_trait_add(): (atom/user, trait) #define COMSIG_ATOM_TTS_TRAIT_ADD "atom_tts_trait_add" //from base of atom/tts_trait_remove(): (atom/user, trait) #define COMSIG_ATOM_TTS_TRAIT_REMOVE "atom_tts_trait_remove" +//from base of atom/cast_tts(): (mob/listener, message, atom/location, is_local, effect, traits, preSFX, postSFX) +#define COMSIG_ATOM_PRE_TTS_CAST "atom_pre_tts_cast" + #define COMPONENT_TTS_INTERRUPT (1<<0) diff --git a/modular_ss220/text_to_speech/code/tts_atom.dm b/modular_ss220/text_to_speech/code/tts_atom.dm index 5acd5bb55d75..f90af41c3eba 100644 --- a/modular_ss220/text_to_speech/code/tts_atom.dm +++ b/modular_ss220/text_to_speech/code/tts_atom.dm @@ -6,6 +6,9 @@ add_tts_component() /atom/proc/cast_tts(mob/listener, message, atom/location, is_local = TRUE, effect = SOUND_EFFECT_NONE, traits = TTS_TRAIT_RATE_FASTER, preSFX, postSFX) + SHOULD_CALL_PARENT(TRUE) + if(SEND_SIGNAL(src, COMSIG_ATOM_PRE_TTS_CAST, listener, message, location, is_local, effect, traits, preSFX, postSFX) & COMPONENT_TTS_INTERRUPT) + return SEND_SIGNAL(src, COMSIG_ATOM_TTS_CAST, listener, message, location, is_local, effect, traits, preSFX, postSFX) // TODO: Do it better? diff --git a/modular_ss220/text_to_speech/code/~undefs/~undefs.dm b/modular_ss220/text_to_speech/code/~undefs/~undefs.dm index c09e423220c4..23d9103a46fd 100644 --- a/modular_ss220/text_to_speech/code/~undefs/~undefs.dm +++ b/modular_ss220/text_to_speech/code/~undefs/~undefs.dm @@ -41,5 +41,7 @@ #undef COMSIG_ATOM_TTS_SEED_CHANGE #undef COMSIG_ATOM_TTS_CAST +#undef COMSIG_ATOM_PRE_TTS_CAST + #undef COMPONENT_TTS_INTERRUPT #undef COMSIG_ATOM_TTS_TRAIT_ADD #undef COMSIG_ATOM_TTS_TRAIT_REMOVE