diff --git a/OpenRA.Game/GameRules/VoiceInfo.cs b/OpenRA.Game/GameRules/VoiceInfo.cs index 80da5bb745..3d43414f0b 100644 --- a/OpenRA.Game/GameRules/VoiceInfo.cs +++ b/OpenRA.Game/GameRules/VoiceInfo.cs @@ -11,35 +11,33 @@ using System.Collections.Generic; using System.Linq; using OpenRA.FileFormats; +using System; namespace OpenRA.GameRules { public class VoiceInfo { public readonly Dictionary Variants; + public readonly Dictionary Voices; public readonly string DefaultVariant = ".aud" ; - public readonly string[] Select = { }; - public readonly string[] Move = { }; - public readonly string[] Attack = null; - public readonly string[] Die = { }; + public readonly string[] DisableVariants = { }; + + Func> Load = (y,name) => (y.Nodes.ContainsKey(name))? y.Nodes[name].Nodes.ToDictionary(a => a.Key, + a => (string[])FieldLoader.GetValue( "(value)", typeof(string[]), a.Value.Value )) + : new Dictionary(); public readonly Lazy> Pools; public VoiceInfo( MiniYaml y ) { - FieldLoader.LoadFields(this, y.Nodes, new string[] { "Select", "Move", "Attack", "Die" }); - Variants = (y.Nodes.ContainsKey("Variants"))? y.Nodes["Variants"].Nodes.ToDictionary(a => a.Key, - a => (string[])FieldLoader.GetValue( "(value)", typeof(string[]), a.Value.Value )) - : new Dictionary(); - - Pools = Lazy.New(() => - new Dictionary - { - { "Select", new VoicePool(Select) }, - { "Move", new VoicePool(Move) }, - { "Attack", new VoicePool( Attack ?? Move ) }, - { "Die", new VoicePool(Die) }, - }); + FieldLoader.LoadFields(this, y.Nodes, new string[] { "DisableVariants" }); + Variants = Load(y, "Variants"); + Voices = Load(y, "Voices"); + + if (!Voices.ContainsKey("Attack")) + Voices.Add("Attack", Voices["Move"]); + + Pools = Lazy.New(() => Voices.ToDictionary( a => a.Key, a => new VoicePool(a.Value) )); } } diff --git a/OpenRA.Game/Sound.cs b/OpenRA.Game/Sound.cs index 49133c07ae..79a5784909 100644 --- a/OpenRA.Game/Sound.cs +++ b/OpenRA.Game/Sound.cs @@ -184,6 +184,7 @@ namespace OpenRA // Returns true if it played a phrase public static bool PlayVoice(string phrase, Actor voicedUnit, string variant) { + Console.WriteLine(" Foo: `{0}`", phrase); if (voicedUnit == null) return false; if (phrase == null) return false; @@ -196,20 +197,8 @@ namespace OpenRA var clip = vi.Pools.Value[phrase].GetNext(); if (clip == null) return false; - - if (clip.Contains(".")) /* no variants! */ - { - Play(clip); - return true; - } - if (vi.Variants.Count == 0) - { - Play(clip + vi.DefaultVariant); - return true; - } - - var variantext = vi.Variants.ContainsKey(variant)? + var variantext = (vi.Variants.ContainsKey(variant) && !vi.DisableVariants.Contains(phrase))? vi.Variants[variant][voicedUnit.ActorID % vi.Variants.Count] : vi.DefaultVariant; Play(clip + variantext); return true; diff --git a/mods/cnc/voices.yaml b/mods/cnc/voices.yaml index a089b6bede..10df335f33 100644 --- a/mods/cnc/voices.yaml +++ b/mods/cnc/voices.yaml @@ -2,27 +2,33 @@ GenericVoice: Variants: nod: .v01,.v03 gdi: .v01,.v03 - Select: await1,ready,report1,yessir1 - Move: ackno,affirm1,noprob,ritaway,roger,ugotit - Die: nuyell1.aud,nuyell3.aud,nuyell4.aud,nuyell5.aud + Voices: + Select: await1,ready,report1,yessir1 + Move: ackno,affirm1,noprob,ritaway,roger,ugotit + Die: nuyell1,nuyell3,nuyell4,nuyell5 + DisableVariants: Die VehicleVoice: Variants: nod: .v00,.v02 gdi: .v00,.v02 - Select: vehic1,yessir1,report1,await1,unit1 - Move: ackno,affirm1,movout1 + Voices: + Select: vehic1,yessir1,report1,await1,unit1 + Move: ackno,affirm1,movout1 CivilianMaleVoice: - Select: guyyeah1 - Move: guyokay1 + Voices: + Select: guyyeah1 + Move: guyokay1 CivilianFemaleVoice: - Select: girlyeah - Move: girlokay + Voices: + Select: girlyeah + Move: girlokay CommandoVoice: - Select: rokroll1,yeah1,yes1,yo1 - Move: cmon1,onit1,gotit1 - Attack: keepem1,laugh1,bombit1,lefty1 - Die: ramyell1 + Voices: + Select: rokroll1,yeah1,yes1,yo1 + Move: cmon1,onit1,gotit1 + Attack: keepem1,laugh1,bombit1,lefty1 + Die: ramyell1 diff --git a/mods/ra/voices.yaml b/mods/ra/voices.yaml index f0e74c1930..716798fc60 100644 --- a/mods/ra/voices.yaml +++ b/mods/ra/voices.yaml @@ -4,73 +4,87 @@ GenericVoice: Variants: soviet: .r01,.r03 allies: .v01,.v03 - Select: await1,ready,report1,yessir1 - Move: ackno,affirm1,noprob,overout,ritaway,roger,ugotit - Die: dedman1.aud,dedman2.aud,dedman3.aud,dedman4.aud,dedman5.aud,dedman6.aud,dedman7.aud,dedman8.aud,dedman10.aud + Voices: + Select: await1,ready,report1,yessir1 + Move: ackno,affirm1,noprob,overout,ritaway,roger,ugotit + Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 + DisableVariants: Die VehicleVoice: Variants: soviet: .r00,.r02 allies: .v00,.v02 - Select: vehic1,yessir1,report1,await1 - Move: ackno,affirm1 + Voices: + Select: vehic1,yessir1,report1,await1 + Move: ackno,affirm1 ShipVoice: Variants: soviet: .r00,.r02 allies: .v00,.v02 - Select: vehic1,yessir1,report1,await1 - Move: ackno,affirm1 + Voices: + Select: vehic1,yessir1,report1,await1 + Move: ackno,affirm1 EngineerVoice: - Select: eengin1,eyessir1 - Move: eaffirm1,emovout1 - Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 + Voices: + Select: eengin1,eyessir1 + Move: eaffirm1,emovout1 + Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 MedicVoice: - Select: mrespon1,myessir1 - Move: maffirm1,mmovout1 - Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 + Voices: + Select: mrespon1,myessir1 + Move: maffirm1,mmovout1 + Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 TanyaVoice: - Select: yo1,yes1,yeah1 - Move: rokroll1,onit1,cmon1 - Attack: tuffguy1,bombit1,gotit1 - Die: tandeth1 + Voices: + Select: yo1,yes1,yeah1 + Move: rokroll1,onit1,cmon1 + Attack: tuffguy1,bombit1,gotit1 + Die: tandeth1 DogVoice: - Select: - Move: dogy1 - Attack: dogg5p,dogw3px - Die: dogw5,dogw6,dogw7 + Voices: + Select: + Move: dogy1 + Attack: dogg5p,dogw3px + Die: dogw5,dogw6,dogw7 SpyVoice: - Select: syessir1,scomnd1 - Move: sonway1,sindeed1 - Attack: sking1 - Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 + Voices: + Select: syessir1,scomnd1 + Move: sonway1,sindeed1 + Attack: sking1 + Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 ThiefVoice: - Select: swhat1,syeah1 - Move: saffirm1,smout1,sokay1 - Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 + Voices: + Select: swhat1,syeah1 + Move: saffirm1,smout1,sokay1 + Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 CivilianMaleVoice: - Select: guyyeah1 - Move: guyokay1 - Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 + Voices: + Select: guyyeah1 + Move: guyokay1 + Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 CivilianFemaleVoice: - Select: girlyeah - Move: girlokay - Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 + Voices: + Select: girlyeah + Move: girlokay + Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 EinsteinVoice: - Select: einah1,einok1,einyes1 - Move: einah1,einok1,einyes1 - Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 + Voices: + Select: einah1,einok1,einyes1 + Move: einah1,einok1,einyes1 + Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 ShokVoice: - Select: jchrge1,jjuice1,jjump1,jpower1 - Move: jdance1,jyes1 - Attack: jburn1,jcrisp1,jshock1,jlight1 + Voices: + Select: jchrge1,jjuice1,jjump1,jpower1 + Move: jdance1,jyes1 + Attack: jburn1,jcrisp1,jshock1,jlight1