Update various sound prefs for 516 compatibility (#3370)

## About The Pull Request

Updates our various sound prefs to be functional post upstream/516.

## Why It's Good For The Game

We can control sound as expected again.

## To-Do

- [x] Conditional preference sounds
- [x] Jukebox sound toggle
- [x] Jukebox volume override

## Changelog

🆑 LT3
fix: Sound prefs that went missing post-516 are restored
add: Jukebox volume slider in game preferences
/🆑

---------

Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com>
This commit is contained in:
LT3
2025-04-06 00:24:44 +00:00
committed by GitHub
co-authored by tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com>
parent 60e73702c6
commit 0e684db68a
7 changed files with 71 additions and 18 deletions
@@ -10,3 +10,8 @@
#define COMSIG_INSTRUMENT_REPEAT "instrument_repeat"
///sent to the instrument when tempo changes, skipped on new. (datum/song)
#define COMSIG_INSTRUMENT_TEMPO_CHANGE "instrument_tempo_change"
// /datum/jukebox signals
///sent to the jukebox when the volume preference is changed and applied
#define COMSIG_MOB_JUKEBOX_PREFERENCE_APPLIED "jukebox_pref_applied"
+12 -4
View File
@@ -100,7 +100,7 @@
var/datum/track/new_track = new()
new_track.song_path = file("[global.config.directory]/jukebox_music/sounds/[track_file]")
var/list/track_data = splittext(track_file, "+")
if(length(track_data) < 3) // BUBBER EDIT - This is fucking stupid - ORIGINAL: if(length(track_data) != 3)
if(length(track_data) < 3)
continue
new_track.song_name = track_data[1]
new_track.song_length = text2num(track_data[2])
@@ -215,9 +215,9 @@
RegisterSignal(new_listener, COMSIG_MOB_LOGIN, PROC_REF(listener_login))
return
RegisterSignal(new_listener, COMSIG_MOVABLE_MOVED, PROC_REF(listener_moved))
RegisterSignals(new_listener, list(COMSIG_MOVABLE_MOVED, COMSIG_MOB_JUKEBOX_PREFERENCE_APPLIED), PROC_REF(listener_moved))
RegisterSignals(new_listener, list(SIGNAL_ADDTRAIT(TRAIT_DEAF), SIGNAL_REMOVETRAIT(TRAIT_DEAF)), PROC_REF(listener_deaf))
var/pref_volume = new_listener.client?.prefs.read_preference(/datum/preference/numeric/volume/sound_instruments)
var/pref_volume = new_listener.client?.prefs.read_preference(/datum/preference/numeric/volume/sound_jukebox)
if(HAS_TRAIT(new_listener, TRAIT_DEAF) || !pref_volume)
listeners[new_listener] |= SOUND_MUTE
@@ -280,7 +280,7 @@
if((reason & MUTE_DEAF) && HAS_TRAIT(listener, TRAIT_DEAF))
return FALSE
var/pref_volume = listener.client?.prefs.read_preference(/datum/preference/numeric/volume/sound_instruments)
var/pref_volume = listener.client?.prefs.read_preference(/datum/preference/numeric/volume/sound_jukebox)
if((reason & MUTE_PREF) && !pref_volume)
return FALSE
@@ -309,6 +309,7 @@
COMSIG_MOB_LOGIN,
COMSIG_QDELETING,
COMSIG_MOVABLE_MOVED,
COMSIG_MOB_JUKEBOX_PREFERENCE_APPLIED,
SIGNAL_ADDTRAIT(TRAIT_DEAF),
SIGNAL_REMOVETRAIT(TRAIT_DEAF),
))
@@ -342,6 +343,13 @@
active_song_sound.x = new_x
active_song_sound.z = new_z
var/pref_volume = listener.client?.prefs.read_preference(/datum/preference/numeric/volume/sound_jukebox)
if(!pref_volume)
listeners[listener] |= SOUND_MUTE
else
unmute_listener(listener, MUTE_PREF)
active_song_sound.volume = volume * (pref_volume/100)
SEND_SOUND(listener, active_song_sound)
/// When the jukebox moves, we need to update all listeners.
+10 -3
View File
@@ -38,9 +38,16 @@
savefile_key = "sound_instruments"
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/numeric/volume/sound_instruments/apply_to_client_updated(client/client, value)
if (!value)
client.mob.stop_sound_channel(CHANNEL_JUKEBOX)
/// Controls jukebox track volume
/datum/preference/numeric/volume/sound_jukebox
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "sound_jukebox"
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/numeric/volume/sound_jukebox/apply_to_client_updated(client/client, value)
var/mob/client_mob = client.mob
if(!isnull(client_mob))
SEND_SIGNAL(client_mob, COMSIG_MOB_JUKEBOX_PREFERENCE_APPLIED)
/datum/preference/choiced/sound_tts
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
@@ -0,0 +1,5 @@
author: "LT3"
delete-after: True
changes:
- bugfix: "Jukebox volume preference applies to currently playing music"
- bugfix: "Jukebox volume no longer resets to 100% when adjusted from the object"
@@ -11,6 +11,7 @@
* frequency - playback speed of audio.
* channel - The channel the sound is played at.
* pressure_affected - Whether or not difference in pressure affects the sound (E.g. if you can hear in space).
* ignore_walls - Whether or not the sound can pass through walls.
* falloff_distance - Distance at which falloff begins. Sound is at peak volume (in regards to falloff) aslong as it is in this range.
* pref_to_check - the path of the pref that we want to check
*/
@@ -24,6 +25,7 @@
frequency = null,
channel = 0,
pressure_affected = TRUE,
ignore_walls = FALSE,
falloff_distance = SOUND_DEFAULT_FALLOFF_DISTANCE,
use_reverb = TRUE,
pref_to_check = /datum/preference/toggle/erp/sex_toy_sounds,
@@ -40,27 +42,45 @@
var/sound/sound_to_play = sound(get_sfx(soundin))
var/maxdistance = SOUND_RANGE + extrarange
var/source_z = turf_source.z
var/list/listeners = SSmobs.clients_by_zlevel[source_z].Copy()
. = list()//output everything that successfully heard the sound
var/turf/above_turf = GET_TURF_ABOVE(turf_source)
var/turf/below_turf = GET_TURF_BELOW(turf_source)
var/list/listeners = get_hearers_in_view(maxdistance, turf_source)
. = list()//output everything that successfully heard the sound
var/audible_distance = CALCULATE_MAX_SOUND_AUDIBLE_DISTANCE(vol, maxdistance, falloff_distance, falloff_exponent)
if(above_turf && istransparentturf(above_turf))
listeners += get_hearers_in_view(maxdistance, above_turf)
if(ignore_walls)
if(above_turf && istransparentturf(above_turf))
listeners += SSmobs.clients_by_zlevel[above_turf.z]
if(below_turf && istransparentturf(turf_source))
listeners += get_hearers_in_view(maxdistance, below_turf)
if(below_turf && istransparentturf(turf_source))
listeners += SSmobs.clients_by_zlevel[below_turf.z]
else //these sounds don't carry through walls
listeners = get_hearers_in_view(audible_distance, turf_source)
if(above_turf && istransparentturf(above_turf))
listeners += get_hearers_in_view(audible_distance, above_turf)
if(below_turf && istransparentturf(turf_source))
listeners += get_hearers_in_view(audible_distance, below_turf)
for(var/mob/listening_mob in listeners)
if(!listening_mob?.client?.prefs?.read_preference(pref_to_check))
continue
if(!(get_dist(listening_mob, turf_source) <= maxdistance))
continue
listening_mob.playsound_local(turf_source, soundin, vol, vary, frequency, falloff_exponent, channel, pressure_affected, sound_to_play, maxdistance, falloff_distance, 1, use_reverb)
var/client_volume_modifier = listening_mob?.client?.prefs?.read_preference(pref_to_check)
if(!client_volume_modifier)
continue
if(client_volume_modifier == 1) // binary on/off prefs get set to volume 100
client_volume_modifier = 100
client_volume_modifier = client_volume_modifier / 100
var/sound_volume_modifier = vol * client_volume_modifier
listening_mob.playsound_local(turf_source, soundin, sound_volume_modifier, vary, frequency, falloff_exponent, channel, pressure_affected, sound_to_play, maxdistance, falloff_distance, 1, use_reverb)
. += listening_mob
/// The looping sound datum but we check for prefs and use `conditional_pref_sound` instead of `playsound`
@@ -86,5 +106,6 @@
pressure_affected = pressure_affected,
falloff_distance = falloff_distance,
use_reverb = use_reverb,
ignore_walls = FALSE,
pref_to_check = pref_to_check
)
@@ -79,7 +79,7 @@
return ITEM_INTERACT_SUCCESS
/obj/structure/reagent_anvil/hammer_act(mob/living/user, obj/item/tool)
conditional_pref_sound(src, 'modular_skyrat/modules/reagent_forging/sound/forge.ogg', 50, TRUE, pref_to_check = /datum/preference/numeric/volume/sound_ambience_volume)
conditional_pref_sound(src, 'modular_skyrat/modules/reagent_forging/sound/forge.ogg', vol = 50, vary = TRUE, extrarange = MEDIUM_RANGE_SOUND_EXTRARANGE, ignore_walls = FALSE, pref_to_check = /datum/preference/numeric/volume/sound_ambience_volume)
//do we have an incomplete item to hammer out? if so, here is our block of code
var/obj/item/forging/incomplete/locate_incomplete = locate() in contents
@@ -56,6 +56,13 @@ export const sound_instruments: Feature<number> = {
component: FeatureSliderInput,
};
export const sound_jukebox: Feature<number> = {
name: 'Jukebox volume',
category: 'SOUND',
description: 'Volume of jukebox tracks.',
component: FeatureSliderInput,
};
export const sound_tts: FeatureChoiced = {
name: 'Enable TTS',
category: 'SOUND',