Refactors sound toggle prefs away from legacy toggles, introduces a new sound pref for jukeboxes (#71040)

## About The Pull Request

Migrates sound toggle prefs away from legacy toggles, and changes all
related preference checks to the modern form. Cleans up unnecessary
defines linked to the old prefs. Increments the minimum save file
version so a piece of old sound related code can be neatly removed. (The
minimum version hasn't changed in two years anyone who hasn't played in
at least that long probably doesn't even remember they had prefs saved)

Splits off jukebox music into its own preference distinct from
instruments. (This was actually the change that brought about this whole
PR the rest of the igration just made sense to do at the same time)

## Why It's Good For The Game

More granularity in sound preferences is good. It is quite reasonable
for players to want to hear normal volume and largely unobtrusive
instruments, without also being subjected to the aural torture of the
jukebox. As implementing this wothout creating an unwelcome extra legacy
toggle already required setting up a non-legacy sound toggle, it is most
reasonable to migrate the other sounds at the same time.

## Changelog
🆑
qol: Jukebox music can be controlled by a new seperate preference, and
is no longer linked to the instrument sound preference option.
refactor: Sound related toggle preferences have been migrated away from
the legacy system. Pre-existing preferences should be safely migrated
but players are advised to check.
/🆑
This commit is contained in:
Thunder12345
2022-11-07 08:45:40 -08:00
committed by GitHub
parent 119ee30000
commit 762e9f06cf
22 changed files with 161 additions and 99 deletions
+1 -9
View File
@@ -3,15 +3,9 @@
// !!! DO NOT ADD ANY NEW ONES HERE !!!
// Use `/datum/preference/toggle` instead.
#define SOUND_ADMINHELP (1<<0)
#define SOUND_MIDI (1<<1)
#define SOUND_AMBIENCE (1<<2)
#define SOUND_LOBBY (1<<3)
#define MEMBER_PUBLIC (1<<4)
#define SOUND_INSTRUMENTS (1<<7)
#define SOUND_SHIP_AMBIENCE (1<<8)
#define SOUND_PRAYERS (1<<9)
#define ANNOUNCE_LOGIN (1<<10)
#define SOUND_ANNOUNCEMENTS (1<<11)
#define DISABLE_DEATHRATTLE (1<<12)
#define DISABLE_ARRIVALRATTLE (1<<13)
#define COMBOHUD_LIGHTING (1<<14)
@@ -20,12 +14,10 @@
#define DEADMIN_POSITION_HEAD (1<<17)
#define DEADMIN_POSITION_SECURITY (1<<18)
#define DEADMIN_POSITION_SILICON (1<<19)
#define SOUND_ENDOFROUND (1<<20)
#define ADMIN_IGNORE_CULT_GHOST (1<<21)
#define SOUND_COMBATMODE (1<<22)
#define SPLIT_ADMIN_TABS (1<<23)
#define TOGGLES_DEFAULT (SOUND_ADMINHELP|SOUND_MIDI|SOUND_AMBIENCE|SOUND_LOBBY|SOUND_ENDOFROUND|MEMBER_PUBLIC|SOUND_INSTRUMENTS|SOUND_SHIP_AMBIENCE|SOUND_PRAYERS|SOUND_ANNOUNCEMENTS|SOUND_COMBATMODE)
#define TOGGLES_DEFAULT (SOUND_ADMINHELP|MEMBER_PUBLIC|SOUND_PRAYERS)
// Legacy chat toggles.
// !!! DO NOT ADD ANY NEW ONES HERE !!!
+2 -2
View File
@@ -46,7 +46,7 @@
for(var/mob/target in players)
if(!isnewplayer(target) && target.can_hear())
to_chat(target, announcement)
if(target.client.prefs.toggles & SOUND_ANNOUNCEMENTS)
if(target.client.prefs.read_preference(/datum/preference/toggle/sound_announcements))
SEND_SOUND(target, sound_to_play)
/**
@@ -124,6 +124,6 @@
continue
to_chat(target, "[span_minorannounce("<font color = red>[title]</font color><BR>[message]")]<BR>")
if(target.client?.prefs.toggles & SOUND_ANNOUNCEMENTS)
if(target.client?.prefs.read_preference(/datum/preference/toggle/sound_announcements))
var/sound_to_play = sound_override || (alert ? 'sound/misc/notice1.ogg' : 'sound/misc/notice2.ogg')
SEND_SOUND(target, sound(sound_to_play))
+1 -1
View File
@@ -666,7 +666,7 @@ SUBSYSTEM_DEF(ticker)
///The reference to the end of round sound that we have chosen.
var/sound/end_of_round_sound_ref = sound(round_end_sound)
for(var/mob/M in GLOB.player_list)
if(M.client.prefs?.toggles & SOUND_ENDOFROUND)
if(M.client.prefs.read_preference(/datum/preference/toggle/sound_endofround))
SEND_SOUND(M.client, end_of_round_sound_ref)
text2file(login_music, "data/last_round_lobby_music.txt")
+1 -1
View File
@@ -194,7 +194,7 @@ SUBSYSTEM_DEF(vote)
new_voter.player_details.player_actions += voting_action
generated_actions += voting_action
if(current_vote.vote_sound && (new_voter.prefs.toggles & SOUND_ANNOUNCEMENTS))
if(current_vote.vote_sound && (new_voter.prefs.read_preference(/datum/preference/toggle/sound_announcements)))
SEND_SOUND(new_voter, sound(current_vote.vote_sound))
return TRUE
+1 -1
View File
@@ -455,7 +455,7 @@ GLOBAL_LIST_EMPTY(teleportlocs)
var/area/my_area = get_area(src)
if(!(client?.prefs.toggles & SOUND_SHIP_AMBIENCE) || !my_area.ambient_buzz)
if(!(client?.prefs.read_preference(/datum/preference/toggle/sound_ship_ambience)) || !my_area.ambient_buzz)
SEND_SOUND(src, sound(null, repeat = 0, wait = 0, channel = CHANNEL_BUZZ))
return
+2 -2
View File
@@ -454,13 +454,13 @@
var/sound/song_played = sound(selection.song_path)
for(var/mob/M in range(10,src))
if(!M.client || !(M.client.prefs.toggles & SOUND_INSTRUMENTS))
if(!M.client || !(M.client.prefs.read_preference(/datum/preference/toggle/sound_jukebox)))
continue
if(!(M in rangers))
rangers[M] = TRUE
M.playsound_local(get_turf(M), null, volume, channel = CHANNEL_JUKEBOX, sound_to_use = song_played, use_reverb = FALSE)
for(var/mob/L in rangers)
if(get_dist(src,L) > 10)
if(get_dist(src,L) > 10 || !(L.client.prefs.read_preference(/datum/preference/toggle/sound_jukebox)))
rangers -= L
if(!L || !L.client)
continue
+1 -1
View File
@@ -175,7 +175,7 @@
set waitfor = FALSE
UNTIL(SSticker.login_music) //wait for SSticker init to set the login music
if(prefs && (prefs.toggles & SOUND_LOBBY) && !CONFIG_GET(flag/disallow_title_music))
if(prefs && (prefs.read_preference(/datum/preference/toggle/sound_lobby)) && !CONFIG_GET(flag/disallow_title_music))
SEND_SOUND(src, sound(SSticker.login_music, repeat = 0, wait = 0, volume = vol, channel = CHANNEL_LOBBYMUSIC)) // MAD JAMS
/proc/get_rand_frequency()
+1 -1
View File
@@ -138,7 +138,7 @@
if(SOUND_EMITTER_GLOBAL)
hearing_mobs = GLOB.player_list.Copy()
for(var/mob/M in hearing_mobs)
if(M.client.prefs.toggles & SOUND_MIDI)
if(M.client.prefs.read_preference(/datum/preference/toggle/sound_midi))
M.playsound_local(M, sound_file, sound_volume, FALSE, channel = CHANNEL_ADMIN, pressure_affected = FALSE)
if(user)
log_admin("[ADMIN_LOOKUPFLW(user)] activated a sound emitter with file \"[sound_file]\" at [AREACOORD(src)]")
+2 -2
View File
@@ -36,7 +36,7 @@
message_admins("[key_name_admin(src)] played sound [S]")
for(var/mob/M in GLOB.player_list)
if(M.client.prefs.toggles & SOUND_MIDI)
if(M.client.prefs.read_preference(/datum/preference/toggle/sound_midi))
admin_sound.volume = vol * M.client.admin_music_volume
SEND_SOUND(M, admin_sound)
admin_sound.volume = vol
@@ -146,7 +146,7 @@
for(var/m in GLOB.player_list)
var/mob/M = m
var/client/C = M.client
if(C.prefs.toggles & SOUND_MIDI)
if(C.prefs.read_preference(/datum/preference/toggle/sound_midi))
if(!stop_web_sounds)
C.tgui_panel?.play_music(web_sound_url, music_extra_data)
else
+1 -1
View File
@@ -1192,7 +1192,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
winset(src, "default.ShiftUp", "is-disabled=true")
/client/proc/update_ambience_pref()
if(prefs.toggles & SOUND_AMBIENCE)
if(prefs.read_preference(/datum/preference/toggle/sound_ambience))
if(SSambience.ambience_listening_clients[src] > world.time)
return // If already properly set we don't want to reset the timer.
SSambience.ambience_listening_clients[src] = world.time + 10 SECONDS //Just wait 10 seconds before the next one aight mate? cheers.
@@ -20,15 +20,7 @@
"disable_deathrattle" = DISABLE_DEATHRATTLE,
"member_public" = MEMBER_PUBLIC,
"sound_adminhelp" = SOUND_ADMINHELP,
"sound_ambience" = SOUND_AMBIENCE,
"sound_announcements" = SOUND_ANNOUNCEMENTS,
"sound_combatmode" = SOUND_COMBATMODE,
"sound_endofround" = SOUND_ENDOFROUND,
"sound_instruments" = SOUND_INSTRUMENTS,
"sound_lobby" = SOUND_LOBBY,
"sound_midi" = SOUND_MIDI,
"sound_prayers" = SOUND_PRAYERS,
"sound_ship_ambience" = SOUND_SHIP_AMBIENCE,
"split_admin_tabs" = SPLIT_ADMIN_TABS,
)
@@ -110,14 +102,6 @@
else
preferences.toggles &= ~legacy_flag
// I know this looks silly, but this is the only one that cares
// and NO NEW LEGACY TOGGLES should ever be added.
if (legacy_flag == SOUND_LOBBY)
if (value && isnewplayer(user))
user.client?.playtitlemusic()
else
user.stop_sound_channel(CHANNEL_LOBBYMUSIC)
return TRUE
var/legacy_chat_flag = legacy_chat_toggles[preference]
@@ -0,0 +1,13 @@
/// Previously, sound preferences were legacy toggles.
/// PR #71040 changed these to modern toggles.
/// This migration transfers the player's existing preferences into the new toggles
/datum/preferences/proc/migrate_legacy_sound_toggles(savefile/savefile)
write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_ambience], toggles & 1<<2)
write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_announcements], toggles & 1<<11)
write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_combatmode], toggles & 1<<22)
write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_endofround], toggles & 1<<20)
write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_instruments], toggles & 1<<7)
write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_lobby], toggles & 1<<3)
write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_midi], toggles & 1<<1)
write_preference(GLOB.preference_entries[/datum/preference/toggle/sound_ship_ambience], toggles & 1<<8)
+63
View File
@@ -0,0 +1,63 @@
/// Controls hearing ambience
/datum/preference/toggle/sound_ambience
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "sound_ambience"
savefile_identifier = PREFERENCE_PLAYER
/// Controls hearing announcement sounds
/datum/preference/toggle/sound_announcements
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "sound_announcements"
savefile_identifier = PREFERENCE_PLAYER
/// Controls hearing the combat mode toggle sound
/datum/preference/toggle/sound_combatmode
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "sound_combatmode"
savefile_identifier = PREFERENCE_PLAYER
/// Controls hearing round end sounds
/datum/preference/toggle/sound_endofround
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "sound_endofround"
savefile_identifier = PREFERENCE_PLAYER
/// Controls hearing instruments
/datum/preference/toggle/sound_instruments
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "sound_instruments"
savefile_identifier = PREFERENCE_PLAYER
/// Controls hearing dance machines
/datum/preference/toggle/sound_jukebox
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "sound_jukebox"
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/toggle/sound_jukebox/apply_to_client_updated(client/client, value)
if (!value)
client.mob.stop_sound_channel(CHANNEL_JUKEBOX)
/// Controls hearing lobby music
/datum/preference/toggle/sound_lobby
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "sound_lobby"
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/toggle/sound_lobby/apply_to_client_updated(client/client, value)
if (value && isnewplayer(client.mob))
client.playtitlemusic()
else
client.mob.stop_sound_channel(CHANNEL_LOBBYMUSIC)
/// Controls hearing admin music
/datum/preference/toggle/sound_midi
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "sound_midi"
savefile_identifier = PREFERENCE_PLAYER
/// Controls hearing ship ambience
/datum/preference/toggle/sound_ship_ambience
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "sound_ship_ambience"
savefile_identifier = PREFERENCE_PLAYER
+4 -4
View File
@@ -5,7 +5,7 @@
// You do not need to raise this if you are adding new values that have sane defaults.
// Only raise this value when changing the meaning/format/name/layout of an existing value
// where you would want the updater procs below to run
#define SAVEFILE_VERSION_MAX 42
#define SAVEFILE_VERSION_MAX 43
/*
SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn
@@ -42,9 +42,6 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
//if your savefile is 3 months out of date, then 'tough shit'.
/datum/preferences/proc/update_preferences(current_version, savefile/S)
if(current_version < 33)
toggles |= SOUND_ENDOFROUND
if(current_version < 34)
write_preference(/datum/preference/toggle/auto_fit_viewport, TRUE)
@@ -103,6 +100,9 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
if (current_version < 42)
migrate_body_types(savefile)
if (current_version < 43)
migrate_legacy_sound_toggles(savefile)
/// checks through keybindings for outdated unbound keys and updates them
/datum/preferences/proc/check_keybindings()
if(!parent)
+1 -1
View File
@@ -25,7 +25,7 @@
sender_override = "Nanotrasen Meteorology Division")
for(var/V in GLOB.player_list)
var/mob/M = V
if((M.client.prefs.toggles & SOUND_MIDI) && is_station_level(M.z))
if((M.client.prefs.read_preference(/datum/preference/toggle/sound_midi)) && is_station_level(M.z))
M.playsound_local(M, 'sound/ambience/aurora_caelus.ogg', 20, FALSE, pressure_affected = FALSE)
/datum/round_event/aurora_caelus/start()
@@ -85,7 +85,7 @@
if(player && HAS_TRAIT(player, TRAIT_MUSICIAN) && isliving(M))
var/mob/living/L = M
L.apply_status_effect(/datum/status_effect/good_music)
if(!(M?.client?.prefs?.toggles & SOUND_INSTRUMENTS))
if(!(M?.client?.prefs.read_preference(/datum/preference/toggle/sound_instruments)))
continue
M.playsound_local(source, null, volume * using_instrument.volume_multiplier, sound_to_use = music_played)
// Could do environment and echo later but not for now
@@ -65,7 +65,7 @@
if(player && HAS_TRAIT(player, TRAIT_MUSICIAN) && isliving(M))
var/mob/living/L = M
L.apply_status_effect(/datum/status_effect/good_music)
if(!(M?.client?.prefs?.toggles & SOUND_INSTRUMENTS))
if(!(M?.client?.prefs.read_preference(/datum/preference/toggle/sound_instruments)))
continue
M.playsound_local(get_turf(parent), null, volume, FALSE, K.frequency, null, channel, null, copy)
// Could do environment and echo later but not for now
+1 -1
View File
@@ -89,7 +89,7 @@
combat_mode = new_mode
if(hud_used?.action_intent)
hud_used.action_intent.update_appearance()
if(silent || !(client?.prefs.toggles & SOUND_COMBATMODE))
if(silent || !(client?.prefs.read_preference(/datum/preference/toggle/sound_combatmode)))
return
if(combat_mode)
SEND_SOUND(src, sound('sound/misc/ui_togglecombat.ogg', volume = 25)) //Sound from interbay!
+1 -1
View File
@@ -153,7 +153,7 @@
stack_trace("[player_mob] ([player_mob.ckey]) has null prefs, which shouldn't be possible!")
continue
if(player_mob.can_hear() && (player_mob.client?.prefs.toggles & SOUND_ANNOUNCEMENTS))
if(player_mob.can_hear() && (player_mob.client?.prefs.read_preference(/datum/preference/toggle/sound_announcements)))
var/turf/T = get_turf(player_mob)
if(T.z == z_level)
SEND_SOUND(player_mob, voice)
+2
View File
@@ -2750,6 +2750,7 @@
#include "code\modules\client\preferences\screentips.dm"
#include "code\modules\client\preferences\security_department.dm"
#include "code\modules\client\preferences\skin_tone.dm"
#include "code\modules\client\preferences\sounds.dm"
#include "code\modules\client\preferences\species.dm"
#include "code\modules\client\preferences\statpanel.dm"
#include "code\modules\client\preferences\tgui.dm"
@@ -2769,6 +2770,7 @@
#include "code\modules\client\preferences\middleware\random.dm"
#include "code\modules\client\preferences\middleware\species.dm"
#include "code\modules\client\preferences\migrations\body_type_migration.dm"
#include "code\modules\client\preferences\migrations\legacy_sound_toggles_migration.dm"
#include "code\modules\client\preferences\migrations\tgui_prefs_migration.dm"
#include "code\modules\client\preferences\species_features\basic.dm"
#include "code\modules\client\preferences\species_features\ethereal.dm"
@@ -90,65 +90,12 @@ export const sound_adminhelp: FeatureToggle = {
component: CheckboxInput,
};
export const sound_ambience: FeatureToggle = {
name: 'Enable ambience',
category: 'SOUND',
component: CheckboxInput,
};
export const sound_announcements: FeatureToggle = {
name: 'Enable announcement sounds',
category: 'SOUND',
description: 'When enabled, hear sounds for command reports, notices, etc.',
component: CheckboxInput,
};
export const sound_combatmode: FeatureToggle = {
name: 'Enable combat mode sound',
category: 'SOUND',
description: 'When enabled, hear sounds when toggling combat mode.',
component: CheckboxInput,
};
export const sound_endofround: FeatureToggle = {
name: 'Enable end of round sounds',
category: 'SOUND',
description: 'When enabled, hear a sound when the server is rebooting.',
component: CheckboxInput,
};
export const sound_instruments: FeatureToggle = {
name: 'Enable instruments',
category: 'SOUND',
description: 'When enabled, be able hear instruments in game.',
component: CheckboxInput,
};
export const sound_lobby: FeatureToggle = {
name: 'Enable lobby music',
category: 'SOUND',
component: CheckboxInput,
};
export const sound_midi: FeatureToggle = {
name: 'Enable admin music',
category: 'SOUND',
description: 'When enabled, admins will be able to play music to you.',
component: CheckboxInput,
};
export const sound_prayers: FeatureToggle = {
name: 'Enable prayer sound',
category: 'ADMIN',
component: CheckboxInput,
};
export const sound_ship_ambience: FeatureToggle = {
name: 'Enable ship ambience',
category: 'SOUND',
component: CheckboxInput,
};
export const split_admin_tabs: FeatureToggle = {
name: 'Split admin tabs',
category: 'ADMIN',
@@ -0,0 +1,61 @@
import { CheckboxInput, FeatureToggle } from '../base';
export const sound_ambience: FeatureToggle = {
name: 'Enable ambience',
category: 'SOUND',
component: CheckboxInput,
};
export const sound_announcements: FeatureToggle = {
name: 'Enable announcement sounds',
category: 'SOUND',
description: 'When enabled, hear sounds for command reports, notices, etc.',
component: CheckboxInput,
};
export const sound_combatmode: FeatureToggle = {
name: 'Enable combat mode sound',
category: 'SOUND',
description: 'When enabled, hear sounds when toggling combat mode.',
component: CheckboxInput,
};
export const sound_endofround: FeatureToggle = {
name: 'Enable end of round sounds',
category: 'SOUND',
description: 'When enabled, hear a sound when the server is rebooting.',
component: CheckboxInput,
};
export const sound_instruments: FeatureToggle = {
name: 'Enable instruments',
category: 'SOUND',
description: 'When enabled, be able hear instruments in game.',
component: CheckboxInput,
};
export const sound_jukebox: FeatureToggle = {
name: 'Enable jukebox music',
category: 'SOUND',
description: 'When enabled, hear music for jukeboxes, dance machines, etc.',
component: CheckboxInput,
};
export const sound_lobby: FeatureToggle = {
name: 'Enable lobby music',
category: 'SOUND',
component: CheckboxInput,
};
export const sound_midi: FeatureToggle = {
name: 'Enable admin music',
category: 'SOUND',
description: 'When enabled, admins will be able to play music to you.',
component: CheckboxInput,
};
export const sound_ship_ambience: FeatureToggle = {
name: 'Enable ship ambience',
category: 'SOUND',
component: CheckboxInput,
};