[MIRROR] Refactors sound toggle prefs away from legacy toggles, introduces a new sound pref for jukeboxes [MDB IGNORE] (#17413)

* Refactors sound toggle prefs away from legacy toggles, introduces a new sound pref for jukeboxes

* Update living_defense.dm

* fix

* Update deprivation_helmet.dm

Co-authored-by: Thunder12345 <Thunder12345@users.noreply.github.com>
Co-authored-by: Zonespace <41448081+Zonespace27@users.noreply.github.com>
This commit is contained in:
SkyratBot
2022-11-10 14:27:14 -08:00
committed by GitHub
co-authored by Thunder12345 Zonespace
parent d4601ae5bc
commit fd699e46ce
27 changed files with 167 additions and 279 deletions
+1 -1
View File
@@ -1230,7 +1230,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)
@@ -104,6 +101,9 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
// migrate_body_types(savefile) // SKYRAT EDIT - This'll fuck up savefiles
migrate_mentor() // SKYRAT EDIT - Make mentors alive again
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)