Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: TTS Рандомизация голоса заспавненного гуманоида #885

Merged
merged 9 commits into from
Jan 9, 2024
2 changes: 2 additions & 0 deletions code/game/objects/structures/mirror.dm
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@
if(voice_choice)
curse(user)

tts_choose(choice, H) // SS220 ADD

/obj/structure/mirror/magic/ui_close(mob/user)
curse(user)

Expand Down
2 changes: 2 additions & 0 deletions code/modules/admin/verbs/gimmick_team.dm
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
if(is_syndicate)
SSticker.mode.traitors |= H.mind //Adds them to extra antag list

H.change_voice(H) // SS220 ADD

players_spawned++
if(players_spawned >= teamsize)
break
Expand Down
2 changes: 1 addition & 1 deletion modular_ss220/text_to_speech/_tts.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/datum/modpack/example
PhantornRU marked this conversation as resolved.
Show resolved Hide resolved
/datum/modpack/tts
name = "Text-To-Speech"
desc = "Озвучка фраз."
author = "furior"
10 changes: 8 additions & 2 deletions modular_ss220/text_to_speech/code/base_seeds/mobs/_base.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
//Fallback values for TTS voices

/mob/living
tts_seed = "Angel"
/mob/living/Initialize()
. = ..()
if(!tts_seed)
tts_seed = get_random_tts_seed_gender()

/mob/living/carbon/human/Initialize(mapload, datum/species/new_species)
. = ..()
if(dna)
dna.tts_seed_dna = tts_seed
6 changes: 6 additions & 0 deletions modular_ss220/text_to_speech/code/base_seeds/mobs/other.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
/mob/living/simple_animal/bot
tts_seed = null

/mob/living/simple_animal/bot/mulebot
tts_seed = "Training_robot"

/mob/living/simple_animal/bot/honkbot
tts_seed = "Training_robot"

/mob/living/simple_animal/slime
tts_seed = "Chen"

Expand Down
8 changes: 8 additions & 0 deletions modular_ss220/text_to_speech/code/base_seeds/objs/objs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@

/obj/item/ttsdevice
tts_seed = "Xenia"

/obj/structure/mirror/magic/Initialize(mapload, newdir, building)
. = ..()
options |= list("Voice TTS")

/obj/structure/mirror/magic/proc/tts_choose(choice, mob/living/carbon/human/human_to_update)
if(choice == "Voice TTS")
human_to_update.change_voice(human_to_update, TRUE)
5 changes: 3 additions & 2 deletions modular_ss220/text_to_speech/code/tts_preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@

/datum/character_save/copy_to(mob/living/carbon/human/character)
. = ..()
character.tts_seed = tts_seed
character.dna.tts_seed_dna = tts_seed
if(tts_seed)
character.tts_seed = tts_seed
character.dna.tts_seed_dna = tts_seed

/datum/ui_module/tts_seeds_explorer
name = "Эксплорер TTS голосов"
Expand Down
44 changes: 34 additions & 10 deletions modular_ss220/text_to_speech/code/tts_seed.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,23 @@
var/static/tts_test_str = "Так звучит мой голос."

var/tts_seeds
var/tts_gender = get_converted_tts_seed_gender(user.gender)
var/list/list_genders = SStts220.tts_list_names_gender[tts_gender]
if(user && (check_rights(R_ADMIN, FALSE, user) || override))
tts_seeds = SStts220.tts_seeds_names
tts_seeds = list_genders
else
tts_seeds = SStts220.get_available_seeds(src)

var/new_tts_seed = input(user || src, "Выберите голос:", "Настройка персонажа", tts_seed) as null|anything in tts_seeds
var/list/not_available_tts_seeds = list_genders - SStts220.get_available_seeds(src)
tts_seeds = list_genders - not_available_tts_seeds

var/datum/character_save/active_character = user?.client?.prefs.active_character
var/new_tts_seed
if(active_character.tts_seed && (user.gender == active_character.gender))
if(alert(user || src, "Оставляем голос вашего персонажа [active_character.real_name]?", "Выбор голоса", "Нет", "Да") == "Да")
new_tts_seed = active_character.tts_seed
if(!new_tts_seed)
return null
new_tts_seed = input(user, "Выберите голос вашего персонажа", "Преобразуем голос") as null|anything in tts_seeds
if(!new_tts_seed)
return null
if(!silent_target && ismob(src) && src != user)
INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(tts_cast), null, src, tts_test_str, new_tts_seed, FALSE)
if(user)
Expand All @@ -41,11 +50,6 @@
tts_seed = new_tts_seed
return new_tts_seed

/mob/living/carbon/human/Initialize(mapload, datum/species/new_species)
. = ..()
if(dna)
dna.tts_seed_dna = tts_seed

/mob/living/carbon/human/change_dna(datum/dna/new_dna, include_species_change, keep_flavor_text)
. = ..()
tts_seed = dna.tts_seed_dna
Expand All @@ -61,6 +65,26 @@
set category = "Subsystems"
change_voice()

/atom/proc/get_converted_tts_seed_gender()
switch(gender)
if(MALE)
return TTS_GENDER_MALE
if(FEMALE)
return TTS_GENDER_FEMALE
else
return TTS_GENDER_ANY

/atom/proc/pick_tts_seed_gender()
var/tts_gender = get_converted_tts_seed_gender()
return pick(SStts220.tts_list_names_gender[tts_gender])

/atom/proc/get_random_tts_seed_gender()
var/tts_choice = pick_tts_seed_gender(gender)
var/datum/tts_seed/seed = SStts220.tts_seeds[tts_choice]
if(!seed)
return null
return seed.name
PhantornRU marked this conversation as resolved.
Show resolved Hide resolved

/**
* Surgery to change the voice of TTS.
* Below are the operations for organics and IPC.
Expand Down
3 changes: 3 additions & 0 deletions modular_ss220/text_to_speech/code/tts_subsystem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ SUBSYSTEM_DEF(tts220)
var/list/tts_seeds_names_by_donator_levels = list()
var/list/datum/tts_provider/tts_providers = list()

var/list/tts_list_names_gender = list(TTS_GENDER_ANY = list(), TTS_GENDER_MALE = list(), TTS_GENDER_FEMALE = list())

var/list/tts_local_channels_by_owner = list()

var/list/tts_requests_queue = list()
Expand Down Expand Up @@ -182,6 +184,7 @@ SUBSYSTEM_DEF(tts220)
tts_seeds[seed.name] = seed
tts_seeds_names += seed.name
tts_seeds_names_by_donator_levels["[seed.required_donator_level]"] += list(seed.name)
tts_list_names_gender[seed.gender] += seed.name
tts_seeds_names = sortTim(tts_seeds_names, /proc/cmp_text_asc)

/datum/controller/subsystem/tts220/Initialize(start_timeofday)
Expand Down