[MIRROR] Makes TTS blips/enabled into one pref [MDB IGNORE] (#22633)

* Makes TTS blips/enabled into one pref (#76558)

## About The Pull Request

![image](https://github.com/tgstation/tgstation/assets/53777086/6b06c212-060e-415f-b1fd-a6ac9f651627)

I actually do not know how to test this locally as I don't know how to
set TTS up, hope it works.

## Why It's Good For The Game

It's 2 buttons, one only works depending on the other, I don't think it
makes sense.

## Changelog

🆑
qol: The TTS and TTS Blips option is now one choiced preference.
/🆑

* Makes TTS blips/enabled into one pref

---------

Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-07-24 16:36:44 -04:00
committed by GitHub
co-authored by John Willard
parent 65290ccaac
commit 87458d1109
7 changed files with 43 additions and 24 deletions
+6
View File
@@ -0,0 +1,6 @@
///TTS preference is disbaled entirely, no sound will be played.
#define TTS_SOUND_OFF "Disabled"
///TTS preference is enabled, and will give full text-to-speech.
#define TTS_SOUND_ENABLED "Enabled"
///TTS preference is set to only play blips of a sound, rather than speech.
#define TTS_SOUND_BLIPS "Blips Only"
+5 -5
View File
@@ -108,14 +108,14 @@ SUBSYSTEM_DEF(tts)
var/channel = SSsounds.random_available_channel()
for(var/mob/listening_mob in listeners | SSmobs.dead_players_by_zlevel[turf_source.z])//observers always hear through walls
var/volume_to_play_at = listening_mob.client?.prefs.read_preference(/datum/preference/numeric/sound_tts_volume)
var/use_blips = listening_mob.client?.prefs.read_preference(/datum/preference/toggle/sound_tts_blips)
if(volume_to_play_at == 0 || !listening_mob.client?.prefs.read_preference(/datum/preference/toggle/sound_tts))
var/tts_pref = listening_mob.client?.prefs.read_preference(/datum/preference/choiced/sound_tts)
if(volume_to_play_at == 0 || (tts_pref == TTS_SOUND_OFF))
continue
var/sound_volume = ((listening_mob == target)? 60 : 85) + volume_offset
sound_volume = sound_volume * (volume_to_play_at / 100)
var/datum/language_holder/holder = listening_mob.get_language_holder()
var/audio_to_use = use_blips ? audio_blips : audio
var/audio_to_use = (tts_pref == TTS_SOUND_BLIPS) ? audio_blips : audio
if(!holder.has_language(language))
continue
if(get_dist(listening_mob, turf_source) <= range)
@@ -361,9 +361,9 @@ SUBSYSTEM_DEF(tts)
/datum/tts_request/proc/start_requests()
if(istype(target, /client))
var/client/current_client = target
use_blips = current_client?.prefs.read_preference(/datum/preference/toggle/sound_tts_blips)
use_blips = (current_client?.prefs.read_preference(/datum/preference/choiced/sound_tts) == TTS_SOUND_BLIPS)
else if(istype(target, /mob))
use_blips = target.client?.prefs.read_preference(/datum/preference/toggle/sound_tts_blips)
use_blips = (target.client?.prefs.read_preference(/datum/preference/choiced/sound_tts) == TTS_SOUND_BLIPS)
if(local)
if(use_blips)
request_blips.begin_async()
@@ -0,0 +1,12 @@
/// Previously, tts enabled/blip were individual buttons
/// PR #76558 changed them to one dropdown choice.
/// This migration transfers the player's existing preferences into the new dropdown
/datum/preferences/proc/update_tts_blip_prefs()
var/sound_blips_enabled = savefile.get_entry("sound_tts_blips")
if(sound_blips_enabled)
write_preference(GLOB.preference_entries[/datum/preference/choiced/sound_tts], TTS_SOUND_BLIPS)
return
var/tts_enabled = savefile.get_entry("sound_tts")
if(!tts_enabled)
write_preference(GLOB.preference_entries[/datum/preference/choiced/sound_tts], TTS_SOUND_OFF)
+6 -6
View File
@@ -28,16 +28,16 @@
savefile_key = "sound_instruments"
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/toggle/sound_tts
/datum/preference/choiced/sound_tts
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "sound_tts"
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/toggle/sound_tts_blips
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "sound_tts_blips"
savefile_identifier = PREFERENCE_PLAYER
default_value = FALSE
/datum/preference/choiced/sound_tts/init_possible_values()
return list(TTS_SOUND_ENABLED, TTS_SOUND_BLIPS, TTS_SOUND_OFF)
/datum/preference/choiced/sound_tts/create_default_value()
return TTS_SOUND_ENABLED
/datum/preference/numeric/sound_tts_volume
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
+4 -1
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 43
#define SAVEFILE_VERSION_MAX 44
/*
SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn
@@ -91,6 +91,9 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
if (current_version < 41)
migrate_preferences_to_tgui_prefs_menu()
if (current_version < 44)
update_tts_blip_prefs()
/datum/preferences/proc/update_character(current_version, list/save_data)
if (current_version < 41)
migrate_character_to_tgui_prefs_menu()
+2
View File
@@ -231,6 +231,7 @@
#include "code\__DEFINES\toys.dm"
#include "code\__DEFINES\traits.dm"
#include "code\__DEFINES\tram.dm"
#include "code\__DEFINES\tts.dm"
#include "code\__DEFINES\turbine_defines.dm"
#include "code\__DEFINES\turfs.dm"
#include "code\__DEFINES\typeids.dm"
@@ -3265,6 +3266,7 @@
#include "code\modules\client\preferences\migrations\convert_to_json_savefile.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\migrations\tts_blip_migration.dm"
#include "code\modules\client\preferences\species_features\basic.dm"
#include "code\modules\client\preferences\species_features\ethereal.dm"
#include "code\modules\client\preferences\species_features\felinid.dm"
@@ -1,4 +1,5 @@
import { CheckboxInput, FeatureToggle, Feature, FeatureNumberInput } from '../base';
import { multiline } from 'common/string';
import { CheckboxInput, FeatureChoiced, FeatureDropdownInput, FeatureToggle, Feature, FeatureNumberInput } from '../base';
export const sound_ambience: FeatureToggle = {
name: 'Enable ambience',
@@ -34,19 +35,14 @@ export const sound_instruments: FeatureToggle = {
component: CheckboxInput,
};
export const sound_tts: FeatureToggle = {
export const sound_tts: FeatureChoiced = {
name: 'Enable TTS',
category: 'SOUND',
description: 'When enabled, be able to hear text-to-speech sounds in game.',
component: CheckboxInput,
};
export const sound_tts_blips: FeatureToggle = {
name: 'Use Blips instead of TTS',
category: 'SOUND',
description:
'When enabled, text to speech will be replaced with blip sounds based on the voice. Does nothing if you disable TTS.',
component: CheckboxInput,
description: multiline`
When enabled, be able to hear text-to-speech sounds in game.
When set to "Blips", text to speech will be replaced with blip sounds based on the voice.
`,
component: FeatureDropdownInput,
};
export const sound_tts_volume: Feature<number> = {